KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_dimension_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 (C) 2020 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
22
23#include <algorithm>
24
25#include <wx/msgdlg.h>
26
28#include <widgets/font_choice.h>
29#include <base_units.h>
30#include <bitmaps.h>
31#include <eda_units.h>
32#include <math/util.h>
33#include <board.h>
34#include <board_commit.h>
35#include <footprint.h>
36#include <pcb_dimension.h>
37#include <pcb_base_edit_frame.h>
39#include <widgets/unit_binder.h>
40
44
45
47 BOARD_ITEM* aItem ) :
49 m_frame( aParent ),
63{
64 wxASSERT( BaseType( aItem->Type() ) == PCB_DIMENSION_T );
65 m_dimension = static_cast<PCB_DIMENSION_BASE*>( aItem );
66 m_previewDimension = static_cast<PCB_DIMENSION_BASE*>( m_dimension->Clone() );
67 m_previewDimension->SetParent( m_frame->GetBoard() );
68
69 switch( m_dimension->Type() )
70 {
72 // Hide the main format controls and keep the leader controls shown
73 m_sizerFormat->GetStaticBox()->Hide();
74 m_sizerCenter->GetStaticBox()->Hide();
75
78
79 // Remove a fewings from text format
82 break;
83
85 m_sizerLeader->GetStaticBox()->Hide();
86 m_sizerFormat->GetStaticBox()->Hide();
87 m_sizerText->GetStaticBox()->Hide();
88
89 m_lblArrowLength->Hide();
90 m_txtArrowLength->Hide();
92
96
98 break;
99
100 default:
101 m_sizerLeader->GetStaticBox()->Hide();
102 m_sizerCenter->GetStaticBox()->Hide();
103 break;
104 }
105
106 // Value mode choice offered only for aligned orthogonal and radial
107 // centre and leader have no measured value
108 if( hasValueModeChoice() )
110 else
111 m_choiceValueMode->Show( false );
112
113 m_separator0->SetIsSeparator();
114
115 m_bold->SetIsCheckButton();
117 m_italic->SetIsCheckButton();
119
120 m_separator1->SetIsSeparator();
121
122 m_alignLeft->SetIsRadioButton();
124 m_alignCenter->SetIsRadioButton();
126 m_alignRight->SetIsRadioButton();
128
129 m_separator2->SetIsSeparator();
130
131 m_mirrored->SetIsCheckButton();
133
134 m_separator3->SetIsSeparator();
135
136 m_autoTextThickness->SetIsCheckButton();
138
139 // Fix the size after hiding/showing some of the properties
140 Layout();
141
142 // Configure display origin transforms
145
146 // Configure the layers list selector. Note that footprints are built outside the current
147 // board and so we may need to show all layers if the text is on an unactivated layer.
148 if( !m_frame->GetBoard()->IsLayerEnabled( m_dimension->GetLayer() ) )
149 m_cbLayerActual->ShowNonActivatedLayers( true );
150
151 m_cbLayerActual->SetLayersHotkeys( false );
152 m_cbLayerActual->SetBoardFrame( aParent );
153 m_cbLayerActual->Resync();
154
156 m_orientation.SetPrecision( 3 );
157
158 // Set predefined rotations in combo dropdown, according to the locale floating point
159 // separator notation
160 double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
161
162 for( size_t ii = 0; ii < m_cbTextOrientation->GetCount() && ii < 4; ++ii )
163 m_cbTextOrientation->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
164
165 m_choiceValueMode->Bind( wxEVT_CHOICE,
166 [&]( wxCommandEvent& evt )
167 {
168 // Driven mirrors geometry other modes hold user value
170
171 m_txtValue->Enable( mode != DIM_VALUE_MODE::DRIVEN );
172
173 if( mode == DIM_VALUE_MODE::DRIVEN )
174 {
175 m_txtValue->SetValue( m_dimension->GetValueText() );
176 }
177 else if( mode == DIM_VALUE_MODE::DRIVING )
178 {
179 // Default to measured value if stale expression is not positive
180 int lengthIU = 0;
181
182 if( !parseDrivingLength( lengthIU ) )
183 m_txtValue->SetValue( m_dimension->GetValueText() );
184 }
185
187 } );
188
189 auto updateEventHandler =
190 [&]( wxCommandEvent& evt )
191 {
193 m_txtValue->ChangeValue( m_dimension->GetValueText() );
194
196 };
197
198 // No need to use m_txtValueActual here since we don't have previewing for leaders
199 m_txtValue->Bind( wxEVT_TEXT, updateEventHandler );
200 m_txtPrefix->Bind( wxEVT_TEXT, updateEventHandler );
201 m_txtSuffix->Bind( wxEVT_TEXT, updateEventHandler );
202
203 m_cbUnits->Bind( wxEVT_CHOICE, updateEventHandler );
204 m_cbUnitsFormat->Bind( wxEVT_CHOICE, updateEventHandler );
205 m_cbPrecision->Bind( wxEVT_CHOICE, updateEventHandler );
206 m_cbSuppressZeroes->Bind( wxEVT_CHECKBOX, updateEventHandler );
207
208 m_cbTextPositionMode->Bind( wxEVT_CHOICE,
209 [&]( wxCommandEvent& aEvt )
210 {
211 // manual mode
212 bool allowPositioning = ( m_cbTextPositionMode->GetSelection() == 2 );
213
214 m_txtTextPosX->Enable( allowPositioning );
215 m_txtTextPosY->Enable( allowPositioning );
216 } );
217
219
220 m_cbKeepAligned->Bind( wxEVT_CHECKBOX,
221 [&]( wxCommandEvent& aEvt )
222 {
223 m_cbTextOrientation->Enable( !m_cbKeepAligned->GetValue() );
224 } );
225
227
229}
230
231
236
237
239{
240 BOARD* board = m_frame->GetBoard();
241
242 // Capture dimension units so Driving length round trips correctly
243 m_valueFieldUnits = m_dimension->GetUnits();
244
245 if( hasValueModeChoice() )
246 {
249 }
250
251 switch( m_dimension->GetUnitsMode() )
252 {
253 case DIM_UNITS_MODE::INCH: m_cbUnits->SetSelection( 0 ); break;
254 case DIM_UNITS_MODE::MILS: m_cbUnits->SetSelection( 1 ); break;
255 case DIM_UNITS_MODE::MM: m_cbUnits->SetSelection( 2 ); break;
256 case DIM_UNITS_MODE::AUTOMATIC: m_cbUnits->SetSelection( 3 ); break;
257 }
258
259 switch ( m_dimension->GetArrowDirection() )
260 {
261 case DIM_ARROW_DIRECTION::INWARD: m_cbArrowDirection->SetSelection( 0 ); break;
262 case DIM_ARROW_DIRECTION::OUTWARD: m_cbArrowDirection->SetSelection( 1 ); break;
263 }
264
265 m_cbUnitsFormat->SetSelection( static_cast<int>( m_dimension->GetUnitsFormat() ) );
266 m_cbPrecision->SetSelection( static_cast<int>( m_dimension->GetPrecision() ) );
267
268 m_txtPrefix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetPrefix() ) );
269 m_txtSuffix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetSuffix() ) );
270
271 if( m_cbLayerActual->SetLayerSelection( m_dimension->GetLayer() ) < 0 )
272 {
273 wxMessageBox( _( "This item was on a non-existing layer.\n"
274 "It has been moved to the first defined layer." ) );
275 m_cbLayerActual->SetSelection( 0 );
276 }
277
278 m_cbSuppressZeroes->SetValue( m_dimension->GetSuppressZeroes() );
279
280 m_fontCtrl->SetFontSelection( m_dimension->GetFont() );
281
282 m_textWidth.SetValue( m_dimension->GetTextSize().x );
283 m_textHeight.SetValue( m_dimension->GetTextSize().y );
284
285 if( m_dimension->GetAutoThickness() )
286 {
287 // Must match EDA_TEXT::SetAutoThickness() so unchecking auto keeps the rendered width
288 m_autoTextThickness->Check( true );
289 m_textThickness.SetValue( GetPenSizeForNormal( m_dimension->GetTextWidth() ) );
290 m_textThickness.Enable( false );
291 }
292 else
293 {
294 m_textThickness.SetValue( m_dimension->GetTextThickness() );
295 }
296
297 m_textPosX.SetValue( m_dimension->GetTextPos().x );
298 m_textPosY.SetValue( m_dimension->GetTextPos().y );
299 m_cbTextPositionMode->SetSelection( static_cast<int>( m_dimension->GetTextPositionMode() ) );
300
301 if( m_dimension->GetTextPositionMode() != DIM_TEXT_POSITION::MANUAL )
302 {
303 m_txtTextPosX->Disable();
304 m_txtTextPosY->Disable();
305 }
306
307 EDA_ANGLE orientation = m_dimension->GetTextAngle();
308 m_orientation.SetAngleValue( orientation.Normalize180() );
309 m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() );
310 m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() );
311
312 m_bold->Check( m_dimension->IsBold() );
313 m_italic->Check( m_dimension->IsItalic() );
314
315 switch ( m_dimension->GetHorizJustify() )
316 {
317 case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
318 case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
319 case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
321 }
322
323 m_mirrored->Check( m_dimension->IsMirrored() );
324
325 m_lineThickness.SetValue( m_dimension->GetLineThickness() );
326 m_arrowLength.SetValue( m_dimension->GetArrowLength() );
327 m_extensionOffset.SetValue( m_dimension->GetExtensionOffset() );
328
329 if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( m_dimension ) )
330 m_extensionOvershoot.SetValue( aligned->GetExtensionHeight() );
331 else
332 m_extensionOvershoot.Show( false );
333
334 // Do this last; it depends on the other settings
336 {
337 // Shows constraint length not geometry to prevent silent restage on OK
338 PCB_CONSTRAINT* lengthConstraint = FindDimensionLengthConstraint( board, m_dimension );
339 std::optional<double> value = lengthConstraint ? lengthConstraint->GetValue() : std::nullopt;
340
341 if( value )
343 m_valueFieldUnits, *value ) );
344 else
345 m_txtValueActual->SetValue( m_dimension->GetValueText() );
346 }
347 else if( m_dimension->GetOverrideTextEnabled() )
348 {
349 wxString txt = board->ConvertKIIDsToCrossReferences( m_dimension->GetOverrideText() );
350 m_txtValueActual->SetValue( txt );
351 }
352 else
353 {
354 m_txtValueActual->SetValue( m_dimension->GetValueText() );
355 }
356
357 if( PCB_DIM_LEADER* leader = dynamic_cast<PCB_DIM_LEADER*>( m_dimension ) )
358 m_cbTextFrame->SetSelection( static_cast<int>( leader->GetTextBorder() ) );
359
360 return DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataToWindow();
361}
362
363
365{
366 if( !DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataFromWindow() )
367 return false;
368
369 // Non positive length keeps dialog open avoids collapsing constraint to zero
371 {
372 int lengthIU = 0;
373
374 if( !parseDrivingLength( lengthIU ) )
375 {
376 wxMessageBox( _( "Enter a positive length for a driving dimension." ),
377 _( "Invalid Value" ), wxOK | wxICON_ERROR, this );
378 return false;
379 }
380 }
381
382 BOARD_COMMIT commit( m_frame );
383 commit.Modify( m_dimension );
384
385 // If no other command in progress, prepare undo command
386 // (for a command in progress, will be made later, at the completion of command)
387 bool pushCommit = ( m_dimension->GetEditFlags() == 0 );
388
389 /* set flag in edit to force undo/redo/abort proper operation,
390 * and avoid new calls to SaveCopyInUndoList for the same dimension
391 * this can occurs when a dimension is moved, and then rotated, edited ..
392 */
393 if( !pushCommit )
394 m_dimension->SetFlags( IN_EDIT );
395
397
398 // Value dimensions always own their commit so the constraint stages and pushes here
399 wxASSERT_MSG( pushCommit || !hasValueModeChoice(),
400 wxT( "value dimension edited without owning its commit; value mode would be lost" ) );
401
402 PCB_CONSTRAINT* drivingConstraint = pushCommit ? stageValueModeConstraint( commit ) : nullptr;
403
404 if( pushCommit )
405 commit.Push( _( "Edit Dimension Properties" ) );
406
407 if( drivingConstraint )
408 resolveDrivingConstraint( drivingConstraint );
409
410 return true;
411}
412
413
415{
416 switch( m_dimension->Type() )
417 {
420 case PCB_DIM_RADIAL_T:
421 return true;
422
423 default:
424 return false;
425 }
426}
427
428
430{
432
433 m_choiceValueMode->Clear();
434 m_choiceValueMode->Append( _( "Driven" ) );
435
437 m_choiceValueMode->Append( _( "Driving" ) );
438
439 m_choiceValueMode->Append( _( "Arbitrary" ) );
440 m_choiceValueMode->SetSelection( 0 );
441 m_choiceValueMode->Show( true );
442}
443
444
446{
447 int selection = m_choiceValueMode->GetSelection();
448
449 if( selection <= 0 )
451
453 return selection == 1 ? DIM_VALUE_MODE::DRIVING : DIM_VALUE_MODE::ARBITRARY;
454
456}
457
458
460{
461 int selection = 0;
462
463 switch( aMode )
464 {
466 selection = 0;
467 break;
468
470 // Driving may not be offered (endpoints not both bound); fall back to Driven.
471 selection = m_valueModeHasDriving ? 1 : 0;
472 break;
473
475 selection = m_valueModeHasDriving ? 2 : 1;
476 break;
477 }
478
479 m_choiceValueMode->SetSelection( selection );
480}
481
482
484{
485 if( hasValueModeChoice() )
487
488 return false;
489}
490
491
493{
494 if( !hasValueModeChoice() )
495 return nullptr;
496
498 std::optional<int> length;
499
500 if( mode == DIM_VALUE_MODE::DRIVING )
501 {
502 int lengthIU = 0;
503
504 // Already validated so failure here stages nothing not a zero length
505 if( parseDrivingLength( lengthIU ) )
506 length = lengthIU;
507 }
508
509 // Override text already written by updateDimensionFromDialog skip here
510 return SetDimensionValueMode( m_frame->GetBoard(), m_dimension, mode, length, std::nullopt,
511 [&]( BOARD_ITEM* aItem ) { aCommit.Modify( aItem ); },
512 [&]( BOARD_ITEM* aItem ) { aCommit.Add( aItem ); },
513 [&]( BOARD_ITEM* aItem ) { aCommit.Remove( aItem ); } );
514}
515
516
518{
519 // Parse using the field displayed units stale text parses to zero caught by positive check
521 m_txtValue->GetValue() );
522
523 if( !( iu > 0.0 ) )
524 return false;
525
526 aLengthIU = KiROUND( iu );
527 return true;
528}
529
530
532{
533 BOARD_COMMIT commit( m_frame );
534 std::vector<PCB_SHAPE*> modified;
535
536 // Driving length moves far endpoint and coincident geometry
537 // Stage each item just before it changes for clean undo
538 ApplyConstraintImmediately( m_frame->GetBoard(), aConstraint, &modified,
539 [&]( BOARD_ITEM* aItem )
540 {
541 commit.Modify( aItem );
542 } );
543
544 // APPEND_UNDO folds solve into prior edit one undo reverts both
545 if( !commit.Empty() )
546 commit.Push( _( "Apply Dimension Length" ), APPEND_UNDO );
547}
548
549
550void DIALOG_DIMENSION_PROPERTIES::onFontSelected( wxCommandEvent & aEvent )
551{
552 bool stroke = KIFONT::FONT::IsStroke( aEvent.GetString() );
553
554 m_textThickness.Show( stroke );
555 m_autoTextThickness->Show( stroke );
556}
557
558
559void DIALOG_DIMENSION_PROPERTIES::onTextSize( wxCommandEvent& aEvent )
560{
561 if( m_autoTextThickness->IsChecked() )
562 m_textThickness.SetValue( GetPenSizeForNormal( m_textWidth.GetValue() ) );
563
564 aEvent.Skip();
565}
566
567
569{
570 if( aEvent.IsChecked() )
571 {
572 m_textThickness.SetValue( GetPenSizeForNormal( m_textWidth.GetValue() ) );
573 m_textThickness.Enable( false );
574 }
575 else
576 {
577 m_textThickness.Enable( true );
578 }
579}
580
581
582void DIALOG_DIMENSION_PROPERTIES::onAlignButton( wxCommandEvent& aEvent )
583{
585 {
586 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
587 btn->Check( false );
588 }
589}
590
591
593{
594 BOARD* board = m_frame->GetBoard();
595
596 if( hasValueModeChoice() )
597 {
598 // Only Arbitrary shows custom text Driven and Driving measure geometry natively
600 {
601 aTarget->SetOverrideTextEnabled( true );
602 aTarget->SetOverrideText( board->ConvertCrossReferencesToKIIDs( m_txtValueActual->GetValue() ) );
603 }
604 else
605 {
606 aTarget->SetOverrideTextEnabled( false );
607 }
608 }
609 else
610 {
611 // Centre and leader lack value mode choice preserve existing override state
612 aTarget->SetOverrideTextEnabled( m_dimension->GetOverrideTextEnabled() );
613
614 if( m_dimension->GetOverrideTextEnabled() )
615 {
616 wxString txt = board->ConvertCrossReferencesToKIIDs( m_txtValueActual->GetValue() );
617 aTarget->SetOverrideText( txt );
618 }
619 }
620
621 aTarget->SetPrefix( board->ConvertCrossReferencesToKIIDs( m_txtPrefix->GetValue() ) );
622 aTarget->SetSuffix( board->ConvertCrossReferencesToKIIDs( m_txtSuffix->GetValue() ) );
623 aTarget->SetLayer( static_cast<PCB_LAYER_ID>( m_cbLayerActual->GetLayerSelection() ) );
624
625 switch ( m_cbArrowDirection->GetSelection() ) {
626 case 0: aTarget->SetArrowDirection( DIM_ARROW_DIRECTION::INWARD ); break;
627 case 1: aTarget->SetArrowDirection( DIM_ARROW_DIRECTION::OUTWARD ); break;
628 }
629
630 switch( m_cbUnits->GetSelection() )
631 {
632 case 0: aTarget->SetUnitsMode( DIM_UNITS_MODE::INCH ); break;
633 case 1: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); break;
634 case 2: aTarget->SetUnitsMode( DIM_UNITS_MODE::MM ); break;
635 case 3: aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); break;
636 }
637
638 aTarget->SetUnitsFormat( static_cast<DIM_UNITS_FORMAT>( m_cbUnitsFormat->GetSelection() ) );
639 aTarget->SetPrecision( static_cast<DIM_PRECISION>( m_cbPrecision->GetSelection() ) );
640 aTarget->SetSuppressZeroes( m_cbSuppressZeroes->GetValue() );
641
642 DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );
643 aTarget->SetTextPositionMode( tpm );
644
645 if( tpm == DIM_TEXT_POSITION::MANUAL )
646 {
647 VECTOR2I pos( m_textPosX.GetValue(), m_textPosY.GetValue() );
648 aTarget->SetTextPos( pos );
649 }
650
651 aTarget->SetKeepTextAligned( m_cbKeepAligned->GetValue() );
652
653 aTarget->SetTextAngle( m_orientation.GetAngleValue().Normalize() );
654 aTarget->SetTextWidth( m_textWidth.GetValue() );
655 aTarget->SetTextHeight( m_textHeight.GetValue() );
656
657 if( m_autoTextThickness->IsChecked() )
658 aTarget->SetAutoThickness( true );
659 else
660 aTarget->SetTextThickness( m_textThickness.GetValue() );
661
662 if( m_fontCtrl->HaveFontSelection() )
663 aTarget->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() ) );
664
665 // Must come after SetTextWidth/Height()
666 aTarget->SetBoldFlag( m_bold->IsChecked() );
667 aTarget->SetItalic( m_italic->IsChecked() );
668
669 if( m_alignLeft->IsChecked() )
671 else if( m_alignCenter->IsChecked() )
673 else
675
676 aTarget->SetMirrored( m_mirrored->IsChecked() );
677
678 aTarget->SetLineThickness( m_lineThickness.GetValue() );
679 aTarget->SetArrowLength( m_arrowLength.GetValue() );
680 aTarget->SetExtensionOffset( m_extensionOffset.GetValue() );
681
682 if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( aTarget ) )
683 aligned->SetExtensionHeight( m_extensionOvershoot.GetValue() );
684
685 if( PCB_DIM_LEADER* leader = dynamic_cast<PCB_DIM_LEADER*>( aTarget ) )
686 leader->SetTextBorder( static_cast<DIM_TEXT_BORDER>( m_cbTextFrame->GetSelection()));
687
688 aTarget->Update();
689}
690
691
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
@ text_align_right
@ text_align_left
@ text_align_center
CONSTRAINT_DIAGNOSIS ApplyConstraintImmediately(BOARD *aBoard, const PCB_CONSTRAINT *aConstraint, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::set< KIID > &aFixedShapes)
Solve a just-created constraint's cluster so the geometry snaps to satisfy it (SolidWorks-style),...
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:85
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:383
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition board.cpp:2368
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition board.cpp:2448
bool Empty() const
Definition commit.h:145
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_DIMENSION_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Dimension Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxSYSTEM_MENU)
void onFontSelected(wxCommandEvent &aEvent) override
void onTextSize(wxCommandEvent &aEvent)
PCB_LAYER_BOX_SELECTOR * m_cbLayerActual
void buildValueModeChoice()
Populate the value-mode choice, offering the Driving entry only when DimensionCanDrive.
PCB_CONSTRAINT * stageValueModeConstraint(BOARD_COMMIT &aCommit)
Stages FIXED_LENGTH constraint for the mode on aCommit Returns live driving constraint to re solve or...
DIM_VALUE_MODE selectedValueMode() const
The value mode the current choice selection represents.
bool parseDrivingLength(int &aLengthIU) const
Parses value field as Driving length into aLengthIU in internal units Returns false for non positive ...
void onAutoTextThickness(wxCommandEvent &aEvent) override
void updateDimensionFromDialog(PCB_DIMENSION_BASE *aTarget)
DIALOG_DIMENSION_PROPERTIES(PCB_BASE_EDIT_FRAME *aParent, BOARD_ITEM *aItem)
void setValueModeSelection(DIM_VALUE_MODE aMode)
Select the choice entry for aMode, falling back to Driven when Driving is not offered.
bool valueFieldTracksMeasurement() const
True when field mirrors geometry in Driven mode refreshable by other edits.
void onAlignButton(wxCommandEvent &aEvent) override
void resolveDrivingConstraint(PCB_CONSTRAINT *aConstraint)
Re-solve so the geometry bound to a now-driving dimension follows its entered length.
bool hasValueModeChoice() const
True for value bearing dims aligned orthogonal or radial centre and leader have no value.
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...
EDA_ANGLE Normalize180()
Definition eda_angle.h:273
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:556
void SetMirrored(bool isMirrored)
Definition eda_text.cpp:354
virtual void SetTextWidth(int aWidth)
Definition eda_text.cpp:534
void SetBoldFlag(bool aBold)
Set only the bold flag, without changing the font.
Definition eda_text.cpp:324
virtual void SetTextHeight(int aHeight)
Definition eda_text.cpp:545
void SetAutoThickness(bool aAuto)
Definition eda_text.cpp:258
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:290
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:471
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:370
virtual bool IsStroke() const
Definition font.h:101
Common, abstract interface for edit frames.
A geometric constraint between board items (issue #2329).
std::optional< double > GetValue() const
Abstract dimension API.
void Update()
Update the dimension's cached text and geometry.
void SetUnitsFormat(const DIM_UNITS_FORMAT aFormat)
void SetPrefix(const wxString &aPrefix)
void SetExtensionOffset(int aOffset)
void SetSuppressZeroes(bool aSuppress)
void SetOverrideTextEnabled(bool aOverride)
void SetSuffix(const wxString &aSuffix)
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
void SetLineThickness(int aWidth)
void SetArrowLength(int aLength)
void SetPrecision(DIM_PRECISION aPrecision)
void SetArrowDirection(const DIM_ARROW_DIRECTION &aDirection)
void SetOverrideText(const wxString &aValue)
void SetUnitsMode(DIM_UNITS_MODE aMode)
void SetKeepTextAligned(bool aKeepAligned)
For better understanding of the points that make a dimension:
A leader is a dimension-like object pointing to a specific point.
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
Definition pcb_text.cpp:512
void SetTextAngle(const EDA_ANGLE &aAngle) override
Definition pcb_text.cpp:572
@ FOR_GUI
Definition common.h:93
bool DimensionCanDrive(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpoint...
DIM_VALUE_MODE DimensionValueMode(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
The value mode aDimension is in, derived from state: a self driving length means Driving,...
PCB_CONSTRAINT * FindDimensionLengthConstraint(const BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the drivin...
PCB_CONSTRAINT * SetDimensionValueMode(BOARD *aBoard, PCB_DIMENSION_BASE *aDimension, DIM_VALUE_MODE aMode, std::optional< int > aDrivingLengthIU, const std::optional< wxString > &aOverrideText, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aStageAdd, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
Apply a value mode transition to aDimension Driving creates or updates the driving length with aDrivi...
DIM_VALUE_MODE
Mode a value bearing dimension value is in Driven mirrors measured geometry Driving forces geometry t...
#define _(s)
#define IN_EDIT
Item currently edited.
EDA_UNITS
Definition eda_units.h:44
int GetPenSizeForNormal(int aTextSize)
Definition gr_text.cpp:58
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
KICOMMON_API wxString StringFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Return the string from aValue according to aUnits (inch, mm ...) for display.
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
DIM_TEXT_POSITION
Where to place the text on a dimension.
@ MANUAL
Text placement is manually set by the user.
DIM_UNITS_FORMAT
How to display the units in a dimension's text.
DIM_TEXT_BORDER
Frame to show around dimension text.
DIM_PRECISION
#define APPEND_UNDO
Definition sch_commit.h:39
static const long long MM
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition typeinfo.h:260
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition typeinfo.h:98
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition typeinfo.h:95
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition typeinfo.h:96
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition typeinfo.h:94
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition typeinfo.h:92
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition typeinfo.h:97
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708