KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eeschema/dialogs/dialog_shape_properties.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
22#include <stroke_params.h>
23#include <sch_edit_frame.h>
24#include <symbol_edit_frame.h>
25#include <sch_shape.h>
26#include <sch_rule_area.h>
29#include <widgets/wx_infobar.h>
31#include <sch_commit.h>
32#include <string_utils.h>
33#include <line_ending.h>
34
35
36// Mapping between wxChoice index and LINE_ENDING_STYLE enum.
37// Dropdown order: None, Arrow, Open Arrow, Circle, Square
38static bool isOpenShape( SHAPE_T aShape )
39{
40 return aShape == SHAPE_T::ARC || aShape == SHAPE_T::BEZIER || aShape == SHAPE_T::POLY || aShape == SHAPE_T::SEGMENT;
41}
42
43
45{
46 wxSizer* mainSizer = GetSizer();
47 wxCHECK_RET( mainSizer, wxT( "Shape properties dialog has no main sizer" ) );
48
49 m_endingsSizer = new wxBoxSizer( wxVERTICAL );
50
51 wxGridBagSizer* gbSizerEndings = new wxGridBagSizer( 3, 0 );
52 gbSizerEndings->SetFlexibleDirection( wxBOTH );
53 gbSizerEndings->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
54
55 m_startShapeLabel = new wxStaticText( this, wxID_ANY, _( "Start Shape:" ) );
56 m_startShapeLabel->Wrap( -1 );
57 gbSizerEndings->Add( m_startShapeLabel, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL | wxRIGHT,
58 5 );
59
60 m_startShapeChoice = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
61 nullptr, wxCB_READONLY );
62 gbSizerEndings->Add( m_startShapeChoice, wxGBPosition( 0, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL | wxEXPAND,
63 5 );
64
65 m_endShapeLabel = new wxStaticText( this, wxID_ANY, _( "End Shape:" ) );
66 m_endShapeLabel->Wrap( -1 );
67 gbSizerEndings->Add( m_endShapeLabel, wxGBPosition( 0, 4 ), wxGBSpan( 1, 1 ),
68 wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5 );
69
70 m_endShapeChoice = new wxBitmapComboBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,
71 nullptr, wxCB_READONLY );
72 gbSizerEndings->Add( m_endShapeChoice, wxGBPosition( 0, 5 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL | wxEXPAND,
73 5 );
74
75 auto addEndingValue = [&]( int aRow, int aCol, const wxString& aLabel, wxStaticText*& aLabelCtrl,
76 wxTextCtrl*& aValueCtrl, wxStaticText*& aUnitsCtrl, int aFlags )
77 {
78 aLabelCtrl = new wxStaticText( this, wxID_ANY, aLabel );
79 aLabelCtrl->Wrap( -1 );
80 gbSizerEndings->Add( aLabelCtrl, wxGBPosition( aRow, aCol ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL | aFlags,
81 5 );
82
83 aValueCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1, -1 ), 0 );
84 gbSizerEndings->Add( aValueCtrl, wxGBPosition( aRow, aCol + 1 ), wxGBSpan( 1, 1 ),
85 wxALIGN_CENTER_VERTICAL | wxEXPAND, 5 );
86
87 aUnitsCtrl = new wxStaticText( this, wxID_ANY, _( "unit" ) );
88 aUnitsCtrl->Wrap( -1 );
89 aUnitsCtrl->SetMinSize( wxSize( 60, -1 ) );
90 gbSizerEndings->Add( aUnitsCtrl, wxGBPosition( aRow, aCol + 2 ), wxGBSpan( 1, 1 ),
91 wxALIGN_CENTER_VERTICAL | wxLEFT, 3 );
92 };
93
94 addEndingValue( 1, 0, _( "Start Length:" ), m_startLengthLabel, m_startLengthCtrl, m_startLengthUnits, wxRIGHT );
95 addEndingValue( 1, 4, _( "End Length:" ), m_endLengthLabel, m_endLengthCtrl, m_endLengthUnits, wxLEFT | wxRIGHT );
96 addEndingValue( 2, 0, _( "Start Width:" ), m_startWidthLabel, m_startWidthCtrl, m_startWidthUnits, wxRIGHT );
97 addEndingValue( 2, 4, _( "End Width:" ), m_endWidthLabel, m_endWidthCtrl, m_endWidthUnits, wxLEFT | wxRIGHT );
98 addEndingValue( 3, 0, _( "Start Stroke Width:" ), m_startStrokeWidthLabel, m_startStrokeWidthCtrl,
99 m_startStrokeWidthUnits, wxRIGHT );
100 addEndingValue( 3, 4, _( "End Stroke Width:" ), m_endStrokeWidthLabel, m_endStrokeWidthCtrl, m_endStrokeWidthUnits,
101 wxLEFT | wxRIGHT );
102
103 gbSizerEndings->AddGrowableCol( 1 );
104 gbSizerEndings->AddGrowableCol( 5 );
105
106 m_endingsSizer->Add( gbSizerEndings, 0, wxEXPAND | wxALL, 10 );
107
108 m_endingsHelpLabel = new wxStaticText( this, wxID_ANY, wxEmptyString );
109 m_endingsHelpLabel->Wrap( -1 );
110 m_endingsSizer->Add( m_endingsHelpLabel, 0, wxLEFT | wxRIGHT | wxBOTTOM, 10 );
111
112 mainSizer->Insert( 3, m_endingsSizer, 0, wxEXPAND, 5 );
113
114 wxColour fg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
115 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
116 wxSize iconSize( 80, 24 );
117
118 struct
119 {
120 wxString name;
121 LINE_ENDING_STYLE style;
122 } shapeItems[] = {
123 { _( "None" ), LINE_ENDING_STYLE::NONE },
124 { _( "Arrow" ), LINE_ENDING_STYLE::ARROW },
125 { _( "Open Arrow" ), LINE_ENDING_STYLE::ARROW_OPEN },
126 { _( "Circle" ), LINE_ENDING_STYLE::CIRCLE },
127 { _( "Square" ), LINE_ENDING_STYLE::SQUARE },
128 };
129
130 for( const auto& item : shapeItems )
131 {
132 wxBitmap startBmp = MakeLineEndingBitmap( item.style, iconSize, fg, bg, this, false );
133 wxBitmap endBmp = MakeLineEndingBitmap( item.style, iconSize, fg, bg, this, true );
134 m_startShapeChoice->Append( item.name, startBmp );
135 m_endShapeChoice->Append( item.name, endBmp );
136 }
137
138 m_startShapeChoice->SetSelection( 0 );
139 m_endShapeChoice->SetSelection( 0 );
140
142 std::make_unique<UNIT_BINDER>( aParent, m_startLengthLabel, m_startLengthCtrl, m_startLengthUnits, true );
144 std::make_unique<UNIT_BINDER>( aParent, m_startWidthLabel, m_startWidthCtrl, m_startWidthUnits, true );
145 m_startStrokeWidth = std::make_unique<UNIT_BINDER>( aParent, m_startStrokeWidthLabel, m_startStrokeWidthCtrl,
147 m_endLength = std::make_unique<UNIT_BINDER>( aParent, m_endLengthLabel, m_endLengthCtrl, m_endLengthUnits, true );
148 m_endWidth = std::make_unique<UNIT_BINDER>( aParent, m_endWidthLabel, m_endWidthCtrl, m_endWidthUnits, true );
149 m_endStrokeWidth = std::make_unique<UNIT_BINDER>( aParent, m_endStrokeWidthLabel, m_endStrokeWidthCtrl,
150 m_endStrokeWidthUnits, true );
151}
152
153
156 m_frame( aParent ),
157 m_shape( aShape ),
159{
160 SetTitle( wxString::Format( GetTitle(), aShape->GetFriendlyName() ) );
161
162 // DIALOG_SHIM needs a unique hash_key because classname is not sufficient because the
163 // different shapes (and even whether or not we're within the symbol editor) cause different
164 // dialog layouts.
165 m_hash_key = TO_UTF8( GetTitle() + aParent->GetName() );
166
167 createLineEndingControls( aParent );
168
169 m_helpLabel1->SetFont( KIUI::GetInfoFont( this ).Italic() );
170 m_helpLabel2->SetFont( KIUI::GetInfoFont( this ).Italic() );
171
172 m_endingsHelpLabel->SetFont( KIUI::GetInfoFont( this ).Italic() );
173 m_endingsHelpLabel->SetLabel( wxString::Format( _( "Shape sizes of 0 = auto (%g\u00d7 line width)." ),
175
176 COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
177 COLOR4D schematicBackground = colorSettings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
178
179 m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
180 m_borderColorSwatch->SetSwatchBackground( schematicBackground );
181
182 for( const auto& [ lineStyle, lineStyleDesc ] : lineTypeNames )
183 m_borderStyleCombo->Append( lineStyleDesc.name, KiBitmapBundle( lineStyleDesc.bitmap ) );
184
185 m_fillColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
186 m_fillColorSwatch->SetSwatchBackground( schematicBackground );
187
188 KIGFX::COLOR4D canvas = m_frame->GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND );
189 m_borderColorSwatch->SetSwatchBackground( canvas.ToColour() );
190 m_fillColorSwatch->SetSwatchBackground( canvas.ToColour() );
191
192 if( m_frame->GetColorSettings()->GetOverrideSchItemColors() )
193 m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) );
194
195 m_ruleAreaSizer->Show( dynamic_cast<SCH_RULE_AREA*>( aShape ) != nullptr );
196
197 // Only show line ending controls for open shapes
198 m_endingsSizer->Show( isOpenShape( aShape->GetShape() ) );
199
201
202 // Required under wxGTK if we want to dismiss the dialog with the ESC key
203 SetFocus();
204
206
207 if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
208 {
209 m_fillBook->SetSelection( 1 );
210
211 if( !symbolEditor->IsSymbolGraphicallyEditable() )
212 {
213 m_sdbSizerCancel->SetDefault();
214 m_sdbSizerOK->SetLabel( _( "Read Only" ) );
215 m_sdbSizerOK->Enable( false );
216 }
217 }
218 else
219 {
220 m_fillBook->SetSelection( 0 );
221 m_symbolEditorSizer->Show( false );
222 }
223
224 m_borderColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, this );
225 m_customColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, this );
226
227 // Now all widgets have the size fixed, call FinishDialogSettings
229}
230
231
237
238
240{
241 if( !wxDialog::TransferDataToWindow() )
242 return false;
243
244 if( SCH_RULE_AREA* ruleArea = dynamic_cast<SCH_RULE_AREA*>( m_shape ) )
245 {
246 m_cbExcludeFromSim->SetValue( ruleArea->GetExcludedFromSim() );
247 m_cbExcludeFromBom->SetValue( ruleArea->GetExcludedFromBOM() );
248 m_cbExcludeFromBoard->SetValue( ruleArea->GetExcludedFromBoard() );
249 m_cbDNP->SetValue( ruleArea->GetDNP() );
250 }
251
252 if( m_shape->GetWidth() >= 0 )
253 {
254 m_borderCheckbox->SetValue( true );
255 m_borderWidth.SetValue( m_shape->GetWidth() );
256 }
257 else
258 {
259 m_borderCheckbox->SetValue( false );
260
261 m_borderWidth.Enable( false );
262 m_borderColorLabel->Enable( false );
263 m_borderColorSwatch->Enable( false );
264 m_borderStyleLabel->Enable( false );
265 m_borderStyleCombo->Enable( false );
266 }
267
268 m_borderColorSwatch->SetSwatchColor( m_shape->GetStroke().GetColor(), false );
269
270 int style = static_cast<int>( m_shape->GetStroke().GetLineStyle() );
271
272 if( style == -1 )
273 m_borderStyleCombo->SetStringSelection( DEFAULT_LINE_STYLE_LABEL );
274 else if( style < (int) lineTypeNames.size() )
275 m_borderStyleCombo->SetSelection( style );
276 else
277 wxFAIL_MSG( wxT( "Line type not found in the type lookup map" ) );
278
279 if( dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
280 {
281 m_rbFillNone->Enable( true );
282 m_rbFillOutline->Enable( true );
283 m_rbFillBackground->Enable( true );
284 m_rbFillCustom->Enable( true );
285 m_customColorSwatch->Enable( true );
286
287 if( m_shape->GetFillMode() == FILL_T::FILLED_SHAPE )
288 {
289 m_rbFillOutline->SetValue( true );
290
291 COLOR4D color = m_shape->GetStroke().GetColor();
292
293 if( color == COLOR4D::UNSPECIFIED )
294 color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE );
295
296 m_customColorSwatch->SetSwatchColor( color, false );
297 }
298 else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR )
299 {
300 m_rbFillBackground->SetValue( true );
301
302 COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND );
303 m_customColorSwatch->SetSwatchColor( color, false );
304 }
305 else if( m_shape->GetFillMode() == FILL_T::FILLED_WITH_COLOR )
306 {
307 m_rbFillCustom->SetValue( true );
308 m_customColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false );
309 }
310 else
311 {
312 m_rbFillNone->SetValue( true );
313 m_customColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
314 }
315
316 const SYMBOL* symbol = m_shape->GetParentSymbol();
317
318 m_privateCheckbox->SetValue( m_shape->IsPrivate() );
319 m_checkApplyToAllUnits->SetValue( symbol->IsMultiUnit() && m_shape->GetUnit() == 0 );
320 m_checkApplyToAllUnits->Enable( symbol->IsMultiUnit() );
321 m_checkApplyToAllBodyStyles->SetValue( symbol->IsMultiBodyStyle() && m_shape->GetBodyStyle() == 0 );
323 }
324 else
325 {
326 m_fillCtrl->SetSelection( m_shape->GetFillModeProp() );
327 m_fillColorSwatch->SetSwatchColor( m_shape->GetFillColor(), false );
328 }
329
330 m_fillColorLabel->Enable( m_fillCtrl->GetSelection() != UI_FILL_MODE::NONE );
331 m_fillColorSwatch->Enable( m_fillCtrl->GetSelection() != UI_FILL_MODE::NONE );
332
333 // Line endings (only populated for open shapes)
334 if( isOpenShape( m_shape->GetShape() ) )
335 {
336 m_startShapeChoice->SetSelection( LINE_ENDING::StyleToChoiceIndex( m_shape->GetStartEndingStyle() ) );
337 m_endShapeChoice->SetSelection( LINE_ENDING::StyleToChoiceIndex( m_shape->GetEndEndingStyle() ) );
338 m_startLength->SetValue( m_shape->GetStartEndingLength() );
339 m_startWidth->SetValue( m_shape->GetStartEndingWidth() );
340 m_startStrokeWidth->SetValue( m_shape->GetStartEndingStrokeWidth() );
341 m_endLength->SetValue( m_shape->GetEndEndingLength() );
342 m_endWidth->SetValue( m_shape->GetEndEndingWidth() );
343 m_endStrokeWidth->SetValue( m_shape->GetEndEndingStrokeWidth() );
344 }
345
346 return true;
347}
348
349
350void DIALOG_SHAPE_PROPERTIES::onBorderChecked( wxCommandEvent& event )
351{
352 bool border = m_borderCheckbox->GetValue();
353
354 if( border && m_borderWidth.GetValue() < 0 )
355 {
356 int defaultInMils;
357
358 if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
359 defaultInMils = symbolEditor->libeditconfig()->m_Defaults.line_width;
360 else
361 defaultInMils = m_frame->eeconfig()->m_Drawing.default_line_thickness;
362
363 m_borderWidth.SetValue( schIUScale.MilsToIU( defaultInMils ) );
364 }
365
366 m_borderWidth.Enable( border );
367 m_borderColorLabel->Enable( border );
368 m_borderColorSwatch->Enable( border );
369 m_borderStyleLabel->Enable( border );
370 m_borderStyleCombo->Enable( border );
371}
372
373
374void DIALOG_SHAPE_PROPERTIES::onFillChoice( wxCommandEvent& event )
375{
376 m_fillColorLabel->Enable( m_fillCtrl->GetSelection() != UI_FILL_MODE::NONE );
377 m_fillColorSwatch->Enable( m_fillCtrl->GetSelection() != UI_FILL_MODE::NONE );
378}
379
380
382{
383 if( event.GetId() == NO_FILL )
384 {
385 m_rbFillNone->SetValue( true );
386 m_customColorSwatch->SetSwatchColor( COLOR4D::UNSPECIFIED, false );
387 }
388 else if( event.GetId() == FILLED_SHAPE )
389 {
390 m_rbFillOutline->SetValue( true );
391
392 COLOR4D color = m_borderColorSwatch->GetSwatchColor();
393
394 if( color == COLOR4D::UNSPECIFIED || !m_rbFillOutline->GetValue() )
395 color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE );
396
397 m_customColorSwatch->SetSwatchColor( color, false );
398 }
399 else if( event.GetId() == FILLED_WITH_BG_BODYCOLOR )
400 {
401 m_rbFillBackground->SetValue( true );
402
403 COLOR4D color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND );
404 m_customColorSwatch->SetSwatchColor( color, false );
405 }
406 else if( event.GetId() == FILLED_WITH_COLOR )
407 {
408 m_rbFillCustom->SetValue( true );
409 m_customColorSwatch->GetNewSwatchColor();
410 }
411}
412
413
414void DIALOG_SHAPE_PROPERTIES::onBorderSwatch( wxCommandEvent& aEvent )
415{
416 if( m_rbFillOutline->GetValue() )
417 m_fillColorSwatch->SetSwatchColor( m_borderColorSwatch->GetSwatchColor(), false );
418
419 if( m_rbFillOutline->IsEnabled() && m_rbFillOutline->GetValue() )
420 {
422
423 if( m_rbFillOutline->GetValue() )
424 color = m_fillColorSwatch->GetSwatchColor();
425
426 if( color == COLOR4D::UNSPECIFIED )
427 color = m_frame->GetRenderSettings()->GetLayerColor( LAYER_DEVICE );
428
429 m_customColorSwatch->SetSwatchColor( color, false );
430 }
431}
432
433
435{
436 m_rbFillCustom->SetValue( true );
437}
438
439
441{
442 if( !wxDialog::TransferDataFromWindow() )
443 return false;
444
445 SCH_COMMIT commit( m_frame );
446
447 if( !m_shape->IsNew() )
448 commit.Modify( m_shape, m_frame->GetScreen() );
449
450 if( SCH_RULE_AREA* ruleArea = dynamic_cast<SCH_RULE_AREA*>( m_shape ) )
451 {
452 ruleArea->SetExcludedFromSim( m_cbExcludeFromSim->GetValue() );
453 ruleArea->SetExcludedFromBOM( m_cbExcludeFromBom->GetValue() );
454 ruleArea->SetExcludedFromBoard( m_cbExcludeFromBoard->GetValue() );
455 ruleArea->SetDNP( m_cbDNP->GetValue() );
456 }
457
458 STROKE_PARAMS stroke = m_shape->GetStroke();
459
460 if( m_borderCheckbox->GetValue() )
461 {
462 if( !m_borderWidth.IsIndeterminate() )
463 stroke.SetWidth( std::max( 0, m_borderWidth.GetIntValue() ) );
464 }
465 else
466 {
467 stroke.SetWidth( -1 );
468 }
469
470 auto it = lineTypeNames.begin();
471 std::advance( it, m_borderStyleCombo->GetSelection() );
472
473 if( it == lineTypeNames.end() )
475 else
476 stroke.SetLineStyle( it->first );
477
478 stroke.SetColor( m_borderColorSwatch->GetSwatchColor() );
479
480 m_shape->SetStroke( stroke );
481
482 if( SYMBOL_EDIT_FRAME* symbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) )
483 {
484 if( m_rbFillOutline->GetValue() )
485 m_shape->SetFillMode( FILL_T::FILLED_SHAPE );
486 else if( m_rbFillBackground->GetValue() )
488 else if( m_rbFillCustom->GetValue() )
489 m_shape->SetFillMode( FILL_T::FILLED_WITH_COLOR );
490 else
491 m_shape->SetFillMode( FILL_T::NO_FILL );
492
493 m_shape->SetFillColor( m_customColorSwatch->GetSwatchColor() );
494
495 m_shape->SetPrivate( m_privateCheckbox->GetValue() );
496
497 if( m_checkApplyToAllBodyStyles->IsChecked() )
498 m_shape->SetBodyStyle( 0 );
499 else
500 m_shape->SetBodyStyle( symbolEditor->GetBodyStyle() );
501
502 if( m_checkApplyToAllUnits->IsChecked() )
503 m_shape->SetUnit( 0 );
504 else
505 m_shape->SetUnit( symbolEditor->GetUnit() );
506 }
507 else
508 {
509 m_shape->SetFillModeProp( (UI_FILL_MODE) m_fillCtrl->GetSelection() );
510 m_shape->SetFillColor( m_fillColorSwatch->GetSwatchColor() );
511 }
512
513 // Line endings (only for open shapes)
514 if( isOpenShape( m_shape->GetShape() ) )
515 {
516 int startSel = m_startShapeChoice->GetSelection();
517
518 if( startSel >= 0 && startSel < LINE_ENDING::s_defaultChoiceCount )
519 m_shape->SetStartEndingStyle( LINE_ENDING::s_defaultChoiceOrder[startSel] );
520
521 int endSel = m_endShapeChoice->GetSelection();
522
523 if( endSel >= 0 && endSel < LINE_ENDING::s_defaultChoiceCount )
524 m_shape->SetEndEndingStyle( LINE_ENDING::s_defaultChoiceOrder[endSel] );
525
526 if( !m_startLength->IsIndeterminate() )
527 m_shape->SetStartEndingLength( std::max( 0, m_startLength->GetIntValue() ) );
528
529 if( !m_startWidth->IsIndeterminate() )
530 m_shape->SetStartEndingWidth( std::max( 0, m_startWidth->GetIntValue() ) );
531
532 if( !m_startStrokeWidth->IsIndeterminate() )
533 m_shape->SetStartEndingStrokeWidth( std::max( 0, m_startStrokeWidth->GetIntValue() ) );
534
535 if( !m_endLength->IsIndeterminate() )
536 m_shape->SetEndEndingLength( std::max( 0, m_endLength->GetIntValue() ) );
537
538 if( !m_endWidth->IsIndeterminate() )
539 m_shape->SetEndEndingWidth( std::max( 0, m_endWidth->GetIntValue() ) );
540
541 if( !m_endStrokeWidth->IsIndeterminate() )
542 m_shape->SetEndEndingStrokeWidth( std::max( 0, m_endStrokeWidth->GetIntValue() ) );
543 }
544
545 if( !commit.Empty() )
546 commit.Push( wxString::Format( _( "Edit %s" ), m_shape->GetFriendlyName() ) );
547
548 return true;
549}
const char * name
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:399
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
bool Empty() const
Definition commit.h:142
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:102
DIALOG_SHAPE_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("%s Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
std::unique_ptr< UNIT_BINDER > m_endWidth
wxBitmapComboBox * m_startShapeChoice
std::unique_ptr< UNIT_BINDER > m_startWidth
void createLineEndingControls(SCH_BASE_FRAME *aParent)
wxBitmapComboBox * m_endShapeChoice
DIALOG_SHAPE_PROPERTIES(SCH_BASE_FRAME *aParent, SCH_SHAPE *aShape)
std::unique_ptr< UNIT_BINDER > m_startStrokeWidth
std::unique_ptr< UNIT_BINDER > m_startLength
std::unique_ptr< UNIT_BINDER > m_endLength
void onBorderChecked(wxCommandEvent &aEvent) override
std::unique_ptr< UNIT_BINDER > m_endStrokeWidth
void onFillChoice(wxCommandEvent &event) override
void onFillRadioButton(wxCommandEvent &aEvent) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:94
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual wxString GetFriendlyName() const
Definition eda_item.cpp:565
SHAPE_T GetShape() const
Definition eda_shape.h:175
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
wxColour ToColour() const
Definition color4d.cpp:221
static constexpr double DEFAULT_RATIO_LENGTH
static const int s_defaultChoiceCount
static const LINE_ENDING_STYLE s_defaultChoiceOrder[]
Dropdown display order for line ending style choosers.
Definition line_ending.h:38
static int StyleToChoiceIndex(LINE_ENDING_STYLE aStyle)
Return the dropdown index for the given style, or 0 (NONE) if not found.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Simple container to manage line stroke parameters.
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void SetColor(const KIGFX::COLOR4D &aColor)
The symbol library editor main window.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition symbol.h:59
virtual bool IsMultiUnit() const =0
virtual bool IsMultiBodyStyle() const =0
#define _(s)
UI_FILL_MODE
Definition eda_fill.h:41
@ NONE
Definition eda_fill.h:42
@ FILLED_WITH_COLOR
Definition eda_fill.h:33
@ NO_FILL
Definition eda_fill.h:30
@ FILLED_WITH_BG_BODYCOLOR
Definition eda_fill.h:32
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
SHAPE_T
Definition eda_shape.h:54
@ SEGMENT
Definition eda_shape.h:56
static bool isOpenShape(SHAPE_T aShape)
@ LAYER_DEVICE
Definition layer_ids.h:488
@ LAYER_DEVICE_BACKGROUND
Definition layer_ids.h:506
@ LAYER_SCHEMATIC_BACKGROUND
Definition layer_ids.h:510
LINE_ENDING_STYLE
Line ending styles for graphic lines, arcs, and beziers.
Definition line_ending.h:44
wxBitmap MakeLineEndingBitmap(LINE_ENDING_STYLE aStyle, const wxSize &aSize, const wxColour &aForeground, const wxColour &aBackground, wxWindow *aWindow, bool aShapeOnRight)
Generate a DPI-aware bitmap icon showing a line ending style.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
static bool isOpenShape(SHAPE_T aShape)
#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
Conversion map between LINE_STYLE values and style names displayed.
#define DEFAULT_LINE_STYLE_LABEL