2016-04-06 18:15:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-13 16:05:09 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2016-04-06 18:15:49 +00:00
|
|
|
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
|
|
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
2019-06-21 16:57:02 +00:00
|
|
|
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-04-06 18:15:49 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _DIALOG_PAD_PROPERTIES_H_
|
|
|
|
#define _DIALOG_PAD_PROPERTIES_H_
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <base_units.h>
|
2016-04-10 22:14:28 +00:00
|
|
|
#include <wx/valnum.h>
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
2017-01-13 17:51:22 +00:00
|
|
|
#include <class_drawsegment.h>
|
2016-04-06 18:15:49 +00:00
|
|
|
#include <origin_viewitem.h>
|
|
|
|
#include <dialog_pad_properties_base.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2017-01-02 06:13:45 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2018-05-23 06:11:47 +00:00
|
|
|
#include <widgets/unit_binder.h>
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
|
2016-04-06 18:15:49 +00:00
|
|
|
* created by wxFormBuilder
|
|
|
|
*/
|
|
|
|
class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aPad );
|
2018-08-19 16:11:58 +00:00
|
|
|
~DIALOG_PAD_PROPERTIES();
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_BASE_FRAME* m_parent;
|
|
|
|
D_PAD* m_currentPad; // pad currently being edited
|
|
|
|
D_PAD* m_dummyPad; // a working copy used to show changes
|
2018-05-23 06:11:47 +00:00
|
|
|
D_PAD* m_padMaster; // pad used to create new pads in board or footprint editor
|
|
|
|
BOARD* m_board; // the main board: this is the board handled by the PCB
|
|
|
|
// editor or the dummy board used by the footprint editor
|
|
|
|
bool m_isFlipped; // indicates the parent footprint is flipped (mirrored) in
|
|
|
|
// which case some Y coordinates values must be negated
|
2016-04-06 18:15:49 +00:00
|
|
|
bool m_canUpdate;
|
|
|
|
bool m_canEditNetName; // true only if the caller is the board editor
|
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
std::vector<std::shared_ptr<DRAWSEGMENT>> m_primitives; // the custom shape primitives in
|
|
|
|
// local coords, orient 0
|
|
|
|
// must define a single copper area
|
2018-05-23 06:11:47 +00:00
|
|
|
COLOR4D m_selectedColor; // color used to draw selected primitives when
|
|
|
|
// editing a custom pad shape
|
|
|
|
|
|
|
|
std::vector<DRAWSEGMENT*> m_highlight; // shapes highlighted in GAL mode
|
2020-06-05 18:07:23 +00:00
|
|
|
PCB_DRAW_PANEL_GAL* m_padPreviewGAL;
|
2018-05-23 06:11:47 +00:00
|
|
|
KIGFX::ORIGIN_VIEWITEM* m_axisOrigin; // origin of the preview canvas
|
|
|
|
static bool m_sketchPreview; // session storage
|
|
|
|
|
|
|
|
UNIT_BINDER m_posX, m_posY;
|
|
|
|
UNIT_BINDER m_sizeX, m_sizeY;
|
|
|
|
UNIT_BINDER m_offsetX, m_offsetY;
|
|
|
|
UNIT_BINDER m_padToDie;
|
|
|
|
UNIT_BINDER m_trapDelta;
|
|
|
|
UNIT_BINDER m_cornerRadius;
|
|
|
|
UNIT_BINDER m_holeX, m_holeY;
|
2016-04-10 22:14:28 +00:00
|
|
|
wxFloatingPointValidator<double> m_OrientValidator;
|
2018-05-23 06:11:47 +00:00
|
|
|
double m_OrientValue;
|
|
|
|
UNIT_BINDER m_clearance;
|
|
|
|
UNIT_BINDER m_maskClearance, m_pasteClearance;
|
|
|
|
UNIT_BINDER m_spokeWidth, m_thermalGap;
|
2016-04-10 22:14:28 +00:00
|
|
|
|
2016-04-06 18:15:49 +00:00
|
|
|
private:
|
2017-01-13 17:51:22 +00:00
|
|
|
void prepareCanvas(); // Initialize the canvases (legacy or gal) to display the pad
|
2016-04-06 18:15:49 +00:00
|
|
|
void initValues();
|
2017-09-20 08:28:52 +00:00
|
|
|
void displayPrimitivesList();
|
2017-01-13 17:51:22 +00:00
|
|
|
bool padValuesOK(); ///< test if all values are acceptable for the pad
|
2016-04-06 18:15:49 +00:00
|
|
|
void redraw();
|
2017-09-20 08:28:52 +00:00
|
|
|
void editPrimitive();
|
2016-04-06 18:15:49 +00:00
|
|
|
void updateRoundRectCornerValues();
|
2017-09-20 13:37:20 +00:00
|
|
|
void enablePrimitivePage( bool aEnable ); ///< enable (or disable) the primitive page editor
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function setPadLayersList
|
|
|
|
* updates the CheckBox states in pad layers list,
|
|
|
|
* @param layer_mask = pad layer mask (ORed layers bit mask)
|
|
|
|
*/
|
2020-08-23 17:11:47 +00:00
|
|
|
void setPadLayersList( LSET layer_mask, bool remove_unconnected, bool keep_top_bottom );
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
/// Copy values from dialog field to aPad's members
|
|
|
|
bool transferDataToPad( D_PAD* aPad );
|
|
|
|
|
|
|
|
// event handlers:
|
2017-01-13 17:51:22 +00:00
|
|
|
void OnInitDialog( wxInitDialogEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
void OnResize( wxSizeEvent& event );
|
2017-11-07 17:33:13 +00:00
|
|
|
void OnCancel( wxCommandEvent& event ) override;
|
2019-06-21 16:57:02 +00:00
|
|
|
void OnUpdateUI( wxUpdateUIEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2018-05-04 16:20:41 +00:00
|
|
|
void OnUpdateUINonCopperWarning( wxUpdateUIEvent& event ) override
|
2018-05-02 08:31:10 +00:00
|
|
|
{
|
2018-05-04 16:20:41 +00:00
|
|
|
bool isOnCopperLayer = ( m_dummyPad->GetLayerSet() & LSET::AllCuMask() ).any();
|
|
|
|
m_nonCopperWarningBook->SetSelection( isOnCopperLayer ? 0 : 1 );
|
2018-05-02 08:31:10 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnPadShapeSelection( wxCommandEvent& event ) override;
|
|
|
|
void OnDrillShapeSelected( wxCommandEvent& event ) override;
|
2018-01-13 16:05:09 +00:00
|
|
|
void onChangePadMode( wxCommandEvent& event ) override;
|
2020-06-01 16:05:40 +00:00
|
|
|
void OnOffsetCheckbox( wxCommandEvent& event ) override;
|
|
|
|
void OnPadToDieCheckbox( wxCommandEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
void PadOrientEvent( wxCommandEvent& event ) override;
|
|
|
|
void PadTypeSelected( wxCommandEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
2020-08-23 17:11:47 +00:00
|
|
|
void UpdateLayersDropdown();
|
|
|
|
void OnSetCopperLayers( wxCommandEvent& event ) override;
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnSetLayers( wxCommandEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
// Called when corner setup value is changed for rounded rect pads
|
2016-09-24 18:53:15 +00:00
|
|
|
void onCornerSizePercentChange( wxCommandEvent& event ) override;
|
2018-09-09 19:19:21 +00:00
|
|
|
void onCornerRadiusChange( wxCommandEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
/// Called when a dimension has changed.
|
|
|
|
/// Update the graphical pad shown in the panel.
|
2016-09-24 18:53:15 +00:00
|
|
|
void OnValuesChanged( wxCommandEvent& event ) override;
|
2016-04-06 18:15:49 +00:00
|
|
|
|
|
|
|
/// Updates the different parameters for the component being edited.
|
2016-04-10 10:40:31 +00:00
|
|
|
/// Automatically fired from the OK button click.
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
|
|
|
|
/// Event handlers of basic shapes list panel
|
2017-09-20 08:28:52 +00:00
|
|
|
void onDeletePrimitive( wxCommandEvent& event ) override;
|
|
|
|
void onEditPrimitive( wxCommandEvent& event ) override;
|
|
|
|
void onAddPrimitive( wxCommandEvent& event ) override;
|
2017-01-13 17:51:22 +00:00
|
|
|
void onGeometryTransform( wxCommandEvent& event ) override;
|
2017-09-20 08:28:52 +00:00
|
|
|
void onDuplicatePrimitive( wxCommandEvent& event ) override;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/// Called on a double click on the basic shapes list
|
2017-09-20 08:28:52 +00:00
|
|
|
void onPrimitiveDClick( wxMouseEvent& event ) override;
|
2017-01-13 17:51:22 +00:00
|
|
|
/// Called on selection/deselection of a basic shape
|
|
|
|
void OnPrimitiveSelection( wxListEvent& event ) override;
|
2019-12-11 10:36:45 +00:00
|
|
|
|
|
|
|
/// Return the pad property currently selected
|
|
|
|
PAD_PROP_T getSelectedProperty();
|
2017-01-13 17:51:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a dialog to edit basics shapes parameters.
|
|
|
|
* Polygonal shape is not handles by this dialog
|
|
|
|
*/
|
2017-09-20 08:28:52 +00:00
|
|
|
class DIALOG_PAD_PRIMITIVES_PROPERTIES: public DIALOG_PAD_PRIMITIVES_PROPERTIES_BASE
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-05-23 06:11:47 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_PROPERTIES( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
|
2020-06-24 11:12:39 +00:00
|
|
|
DRAWSEGMENT* aShape );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function TransferDataFromWindow
|
|
|
|
* Transfer data out of the GUI.
|
|
|
|
*/
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Function TransferDataToWindow
|
|
|
|
* Transfer data into the GUI.
|
|
|
|
*/
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
|
|
|
|
// The basic shape currently edited
|
2020-06-24 11:12:39 +00:00
|
|
|
DRAWSEGMENT* m_shape;
|
|
|
|
|
|
|
|
UNIT_BINDER m_startX;
|
|
|
|
UNIT_BINDER m_startY;
|
|
|
|
UNIT_BINDER m_ctrl1X;
|
|
|
|
UNIT_BINDER m_ctrl1Y;
|
|
|
|
UNIT_BINDER m_ctrl2X;
|
|
|
|
UNIT_BINDER m_ctrl2Y;
|
|
|
|
UNIT_BINDER m_endX;
|
|
|
|
UNIT_BINDER m_endY;
|
|
|
|
UNIT_BINDER m_radius;
|
|
|
|
UNIT_BINDER m_thickness;
|
2017-01-13 17:51:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* a dialog to edit basic polygonal shape parameters
|
|
|
|
*/
|
2017-09-20 08:28:52 +00:00
|
|
|
class DIALOG_PAD_PRIMITIVE_POLY_PROPS: public DIALOG_PAD_PRIMITIVE_POLY_PROPS_BASE
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
|
|
|
// The basic shape currently edited
|
2020-06-24 11:12:39 +00:00
|
|
|
DRAWSEGMENT* m_shape;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
// The working copy of the basic shape currently edited
|
2020-06-24 11:12:39 +00:00
|
|
|
std::vector<wxPoint> m_currPoints;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
2020-06-24 11:12:39 +00:00
|
|
|
UNIT_BINDER m_thickness;
|
2018-05-23 06:11:47 +00:00
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
public:
|
2018-05-23 06:11:47 +00:00
|
|
|
DIALOG_PAD_PRIMITIVE_POLY_PROPS( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
|
2020-06-24 11:12:39 +00:00
|
|
|
DRAWSEGMENT* aShape );
|
2017-09-20 08:28:52 +00:00
|
|
|
~DIALOG_PAD_PRIMITIVE_POLY_PROPS();
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function TransferDataFromWindow
|
|
|
|
* Transfer data out of the GUI.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool TransferDataFromWindow() override;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Function TransferDataToWindow
|
|
|
|
* Transfer data into the GUI.
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
bool TransferDataToWindow() override;
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* test for a valid polygon (a not self intersectiong polygon)
|
|
|
|
*/
|
|
|
|
bool Validate() override;
|
|
|
|
|
|
|
|
// Events handlers:
|
2018-05-23 06:11:47 +00:00
|
|
|
void OnButtonAdd( wxCommandEvent& event ) override;
|
2017-01-13 17:51:22 +00:00
|
|
|
void OnButtonDelete( wxCommandEvent& event ) override;
|
|
|
|
void onPaintPolyPanel( wxPaintEvent& event ) override;
|
|
|
|
void onPolyPanelResize( wxSizeEvent& event ) override;
|
|
|
|
void onGridSelect( wxGridRangeSelectEvent& event ) override;
|
|
|
|
void onCellChanging( wxGridEvent& event );
|
|
|
|
void onCellSelect( wxGridEvent& event ) override
|
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
2018-05-23 06:11:47 +00:00
|
|
|
|
|
|
|
bool doValidate( bool aRemoveRedundantCorners );
|
|
|
|
|
2017-01-13 17:51:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** A dialog to apply geometry transforms to a shape or set of shapes
|
|
|
|
* (move, rotate around origin, scaling factor, duplication).
|
|
|
|
* shapes are scaled, then moved then rotated.
|
|
|
|
* aList is a list of shapes to transform or duplicate
|
|
|
|
* if aShowDuplicate == false, the parameter "Duplicate count" is disabled
|
|
|
|
*/
|
|
|
|
|
2017-09-20 08:28:52 +00:00
|
|
|
class DIALOG_PAD_PRIMITIVES_TRANSFORM : public DIALOG_PAD_PRIMITIVES_TRANSFORM_BASE
|
2017-01-13 17:51:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-05-23 06:11:47 +00:00
|
|
|
DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aParent, PCB_BASE_FRAME* aFrame,
|
2020-06-24 11:12:39 +00:00
|
|
|
std::vector<std::shared_ptr<DRAWSEGMENT>>& aList,
|
|
|
|
bool aShowDuplicate );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Apply geometric transform (rotation, move, scale) defined in dialog
|
|
|
|
* aDuplicate = 1 .. n to duplicate the list of shapes
|
|
|
|
* aDuplicate = 0 to transform the list of shapes
|
|
|
|
* The duplicated items are transformed, but the initial shpes are not modified.
|
|
|
|
* The duplicated items are added to aList
|
|
|
|
*/
|
2020-06-24 11:12:39 +00:00
|
|
|
void Transform( std::vector<std::shared_ptr<DRAWSEGMENT>>* aList = NULL,
|
|
|
|
int aDuplicateCount = 0 );
|
2017-01-13 17:51:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the number of duplicate, chosen by user
|
|
|
|
*/
|
|
|
|
int GetDuplicateCount() { return m_spinCtrlDuplicateCount->GetValue(); }
|
|
|
|
|
|
|
|
private:
|
2020-06-24 11:12:39 +00:00
|
|
|
std::vector<std::shared_ptr<DRAWSEGMENT>>& m_list;
|
2018-05-23 06:11:47 +00:00
|
|
|
|
|
|
|
UNIT_BINDER m_vectorX;
|
|
|
|
UNIT_BINDER m_vectorY;
|
|
|
|
UNIT_BINDER m_rotation;
|
2016-04-06 18:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // #ifndef _DIALOG_PAD_PROPERTIES_H_
|