69 void BindCtrls(
size_t aFrom,
size_t aTo, std::function<
void()> aCb )
74 for(
size_t i = aFrom; i <= aTo; ++i )
77 [aCb]( wxCommandEvent& aEvent )
90 virtual bool Validate( wxArrayString& aErrs )
const {
return true; }
95 wxTextCtrl*
GetCtrl(
size_t aIndex )
const
104 return static_cast<int>(
m_boundCtrls[aIndex].m_Binder->GetValue() );
122 m_boundCtrls[aIndex].m_Binder->ChangeAngleValue( aValue );
162 wxASSERT( aBoundCtrls.size() ==
NUM_CTRLS );
184 bool Validate( wxArrayString& aErrs )
const override
191 aErrs.push_back(
_(
"Rectangle cannot be zero-sized." ) );
300 wxASSERT( aBoundCtrls.size() ==
NUM_CTRLS );
428 wxASSERT( aBoundCtrls.size() ==
NUM_CTRLS );
444 bool Validate( wxArrayString& aErrs )
const override
450 aErrs.push_back(
_(
"Arc angle must be greater than 0" ) );
458 if( start == mid || mid == end || start == end )
460 aErrs.push_back(
_(
"Arc must have 3 distinct points" ) );
467 double radius = ( center - start ).EuclideanNorm();
471 if( max_offset >= ( std::numeric_limits<VECTOR2I::coord_type>::max() / 2.0 )
472 || center_i == start || center_i == end )
474 aErrs.push_back( wxString::Format(
_(
"Invalid Arc with radius %f and angle %f." ),
560 wxASSERT( aBoundCtrls.size() ==
NUM_CTRLS );
582 bool Validate( wxArrayString& aErrs )
const override
586 aErrs.push_back(
_(
"Radius must be greater than 0" ) );
657 wxASSERT( aBoundCtrls.size() ==
NUM_CTRLS );
758 const wxString aName,
bool aRelative,
759 std::vector<BOUND_CONTROL>& aBoundCtrls )
764 wxWindow* parent = aSizer.GetContainingWindow();
766 wxStaticText* titleLabel =
new wxStaticText( parent, wxID_ANY, aName );
767 aSizer.Add( titleLabel, wxGBPosition( row, col ), wxGBSpan( 1, 3 ),
768 wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL | wxALL | wxEXPAND );
771 for(
size_t coord = 0; coord < 2; ++coord )
773 wxStaticText* label =
774 new wxStaticText( parent, wxID_ANY, coord == 0 ?
_(
"X" ) :
_(
"Y" ) );
775 aSizer.Add( label, wxGBPosition( row, col ), wxDefaultSpan,
776 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
778 wxTextCtrl* ctrl =
new wxTextCtrl( parent, wxID_ANY,
"" );
779 aSizer.Add( ctrl, wxGBPosition( row, col + 1 ), wxDefaultSpan,
780 wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5 );
782 wxStaticText* units =
new wxStaticText( parent, wxID_ANY,
_(
"mm" ) );
783 aSizer.Add( units, wxGBPosition( row, col + 2 ), wxDefaultSpan,
784 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
786 auto binder = std::make_unique<UNIT_BINDER>( &aFrame, label, ctrl, units );
795 aBoundCtrls.push_back(
BOUND_CONTROL{ std::move( binder ), ctrl } );
799 if( !aSizer.IsColGrowable( col + 1 ) )
800 aSizer.AddGrowableCol( col + 1 );
806 bool aIsAngle, std::vector<BOUND_CONTROL>& aBoundCtrls )
809 wxWindow* parent = aSizer.GetContainingWindow();
811 wxStaticText* label =
new wxStaticText( parent, wxID_ANY, aName );
812 aSizer.Add( label, wxGBPosition( row, col ), wxDefaultSpan,
813 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxLEFT, 5 );
815 wxTextCtrl* ctrl =
new wxTextCtrl( parent, wxID_ANY );
816 aSizer.Add( ctrl, wxGBPosition( row, col + 1 ), wxDefaultSpan,
817 wxEXPAND | wxTOP | wxLEFT | wxRIGHT, 5 );
819 wxStaticText* units =
new wxStaticText( parent, wxID_ANY,
_(
"mm" ) );
820 aSizer.Add( units, wxGBPosition( row, col + 2 ), wxDefaultSpan,
821 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
823 auto binder = std::make_unique<UNIT_BINDER>( &aFrame, label, ctrl, units );
824 binder->SetCoordType( aCoordType );
828 binder->SetPrecision( 4 );
832 aBoundCtrls.push_back(
BOUND_CONTROL{ std::move( binder ), ctrl } );
834 if( !aSizer.IsColGrowable( col + 1 ) )
835 aSizer.AddGrowableCol( col + 1 );
846 m_thickness( aParent, m_thicknessLabel, m_thicknessCtrl, m_thicknessUnits ),
847 m_solderMaskMargin( aParent, m_solderMaskMarginLabel, m_solderMaskMarginCtrl, m_solderMaskMarginUnit ),
848 m_workingCopy( *m_item )
858 std::set<int> shownPages;
860 const auto showPage = [&]( wxSizer& aMainSizer,
bool aSelect = false )
863 wxWindow* page = aMainSizer.GetContainingWindow();
868 shownPages.insert( pageIdx );
876 case SHAPE_T::RECTANGLE:
895 case SHAPE_T::SEGMENT:
929 case SHAPE_T::CIRCLE:
942 case SHAPE_T::BEZIER:
958 case SHAPE_T::UNDEFINED:
959 wxFAIL_MSG(
"Undefined shape" );
966 if( shownPages.count( i ) == 0 )
1002 for(
const auto& [ lineStyle, lineStyleDesc ] :
lineTypeNames )
1046 wxCHECK_RET( aShape, wxT(
"ShowGraphicItemPropertiesDialog() error: NULL item" ) );
1084 if( style == LINE_STYLE::DEFAULT )
1085 style = LINE_STYLE::SOLID;
1123 wxFAIL_MSG(
"Line type not found in the type lookup map" );
1137 return DIALOG_SHAPE_PROPERTIES_BASE::TransferDataToWindow();
1143 if( !DIALOG_SHAPE_PROPERTIES_BASE::TransferDataFromWindow() )
1199 commit.Push(
_(
"Edit Shape Properties" ) );
1214 wxArrayString errors;
1216 if( !DIALOG_SHAPE_PROPERTIES_BASE::Validate() )
1227 errors.Add(
_(
"Line width must be greater than zero." ) );
1230 case SHAPE_T::CIRCLE:
1232 errors.Add(
_(
"Line width must be greater than zero for an unfilled circle." ) );
1236 case SHAPE_T::RECTANGLE:
1238 errors.Add(
_(
"Line width must be greater than zero for an unfilled rectangle." ) );
1244 errors.Add(
_(
"Line width must be greater than zero for an unfilled polygon." ) );
1248 case SHAPE_T::SEGMENT:
1250 errors.Add(
_(
"Line width must be greater than zero." ) );
1254 case SHAPE_T::BEZIER:
1256 errors.Add(
_(
"Line width must be greater than zero for an unfilled curve." ) );
1265 if( errors.GetCount() )
1272 return errors.GetCount() == 0;
constexpr int ARC_HIGH_DEF
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
ARC_GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void updateAll() override
bool Validate(wxArrayString &aErrs) const override
BASE_SET & set(size_t pos)
BEZIER_GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void updateAll() override
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
virtual void SetLocked(bool aLocked)
virtual bool IsLocked() const
virtual bool IsOnCopperLayer() const
const NETINFO_LIST & GetNetInfo() const
void OnCenterPointChange()
bool Validate(wxArrayString &aErrs) const override
void updateCenterRadius()
CIRCLE_GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void updateAll() override
void OnCenterRadiusChange()
Class DIALOG_SHAPE_PROPERTIES_BASE.
wxGridBagSizer * m_gbsBezier
wxGridBagSizer * m_gbsRectangleByCorners
wxGridBagSizer * m_gbsCircleCenterRadius
wxCheckBox * m_hasSolderMask
wxGridBagSizer * m_gbsRectangleByCenterSize
wxGridBagSizer * m_gbsCircleCenterPoint
NET_SELECTOR * m_netSelector
wxGridBagSizer * m_gbsLineByEnds
wxStaticText * m_netLabel
wxStaticText * m_solderMaskMarginUnit
wxGridBagSizer * m_gbsRectangleByCornerSize
PCB_LAYER_BOX_SELECTOR * m_LayerSelectionCtrl
wxTextCtrl * m_solderMaskMarginCtrl
wxNotebook * m_notebookShapeDefs
wxGridBagSizer * m_gbsLineByMidEnd
wxStaticText * m_lineStyleLabel
wxStaticText * m_techLayersLabel
wxStaticText * m_solderMaskMarginLabel
wxGridBagSizer * m_gbsLineByLengthAngle
wxBitmapComboBox * m_lineStyleCombo
wxGridBagSizer * m_gbsArcByCSA
wxGridBagSizer * m_gbsArcBySME
wxCheckBox * m_filledCtrl
PCB_BASE_EDIT_FRAME * m_parent
DIALOG_SHAPE_PROPERTIES(SCH_BASE_FRAME *aParent, SCH_SHAPE *aShape)
UNIT_BINDER m_solderMaskMargin
~DIALOG_SHAPE_PROPERTIES()
std::unique_ptr< GEOM_SYNCER > m_geomSync
bool TransferDataToWindow() override
std::vector< BOUND_CONTROL > m_boundCtrls
void onLayerSelection(wxCommandEvent &event) override
void onTechLayersChanged(wxCommandEvent &event) override
void onFilledCheckbox(wxCommandEvent &event) override
void showHideTechLayers()
bool TransferDataFromWindow() override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
FRAME_T GetFrameType() const
The base class for create windows for drawing purpose.
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
const VECTOR2I & GetBezierC2() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
void SetFilled(bool aFlag)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
wxString SHAPE_T_asString() const
const VECTOR2I & GetBezierC1() const
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
VECTOR2I GetArcMid() const
static const TOOL_EVENT SelectedEvent
A class that operates over a list of BOUND_CONTROLs and keeps them in sync with a PCB_SHAPE.
void ChangeValue(size_t aIndex, int aValue)
wxTextCtrl * GetCtrl(size_t aIndex) const
EDA_ANGLE GetAngleValue(size_t aIndex) const
void BindCtrls(size_t aFrom, size_t aTo, std::function< void()> aCb)
void SetShape(PCB_SHAPE &aShape)
virtual void updateAll()=0
int GetIntValue(size_t aIndex) const
virtual bool Validate(wxArrayString &aErrs) const
const PCB_SHAPE & GetShape() const
void ChangeAngleValue(size_t aIndex, const EDA_ANGLE &aValue)
std::vector< BOUND_CONTROL > & m_boundCtrls
GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void ListSet(const wxString &aList)
Add a list of items.
int GetLayerSelection() const
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
void OnMidEndpointChange()
LINE_GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void updateAll() override
LSET is a set of PCB_LAYER_IDs.
static LSET ForbiddenFootprintLayers()
Layers which are not allowed within footprint definitions.
void SetNetInfo(const NETINFO_LIST *aNetInfoList)
void SetBoard(BOARD *aBoard)
void SetIndeterminateString(const wxString &aString)
void SetSelectedNetcode(int aNetcode)
Common, abstract interface for edit frames.
void ShowGraphicItemPropertiesDialog(PCB_SHAPE *aShape)
virtual PCB_LAYER_ID GetActiveLayer() const
The main frame for Pcbnew.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void SetNotAllowedLayerSet(LSET aMask)
std::optional< int > GetLocalSolderMaskMargin() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
bool HasSolderMask() const
void SetHasSolderMask(bool aVal)
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
wxString GetFriendlyName() const override
STROKE_PARAMS GetStroke() const override
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
void SetStroke(const STROKE_PARAMS &aStroke) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Class that keeps a rectangle's various fields all up to date.
void updateAll() override
bool Validate(wxArrayString &aErrs) const override
void OnCenterSizeChange()
RECTANGLE_GEOM_SYNCER(PCB_SHAPE &aShape, std::vector< BOUND_CONTROL > &aBoundCtrls)
void OnCornerSizeChange()
Simple container to manage line stroke parameters.
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
LINE_STYLE GetLineStyle() const
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
bool IsNull() const
Return true if the control holds no value (ie: empty string, not 0).
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
#define IN_EDIT
Item currently edited.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
bool IsExternalCopperLayer(int aLayerId)
Tests whether a layer is an external (F_Cu or B_Cu) copper layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void AddFieldToSizer(EDA_DRAW_FRAME &aFrame, wxGridBagSizer &aSizer, int row, int col, const wxString aName, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType, bool aIsAngle, std::vector< BOUND_CONTROL > &aBoundCtrls)
static std::map< SHAPE_T, int > s_lastTabForShape
static void AddXYPointToSizer(EDA_DRAW_FRAME &aFrame, wxGridBagSizer &aSizer, int row, int col, const wxString aName, bool aRelative, std::vector< BOUND_CONTROL > &aBoundCtrls)
static bool isCopper(const PNS::ITEM *aItem)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
LINE_STYLE
Dashed line types.
std::unique_ptr< UNIT_BINDER > m_Binder
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
VECTOR2< int32_t > VECTOR2I