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#include <widgets/font_choice.h>
23#include <base_units.h>
24#include <eda_units.h>
25#include <math/util.h>
26#include <board.h>
27#include <board_commit.h>
28#include <footprint.h>
29#include <pcb_dimension.h>
30#include <pcb_base_edit_frame.h>
32#include <widgets/unit_binder.h>
33#include <wx/msgdlg.h>
34
38
40
41#include <algorithm>
42
43
45 BOARD_ITEM* aItem ) :
47 m_frame( aParent ),
61{
62 wxASSERT( BaseType( aItem->Type() ) == PCB_DIMENSION_T );
63 m_dimension = static_cast<PCB_DIMENSION_BASE*>( aItem );
64 m_previewDimension = static_cast<PCB_DIMENSION_BASE*>( m_dimension->Clone() );
65 m_previewDimension->SetParent( m_frame->GetBoard() );
66
67 switch( m_dimension->Type() )
68 {
70 // Hide the main format controls and keep the leader controls shown
71 m_sizerFormat->GetStaticBox()->Hide();
72 m_sizerCenter->GetStaticBox()->Hide();
73
76
77 // Remove a fewings from text format
80 break;
81
83 m_sizerLeader->GetStaticBox()->Hide();
84 m_sizerFormat->GetStaticBox()->Hide();
85 m_sizerText->GetStaticBox()->Hide();
86
87 m_lblArrowLength->Hide();
88 m_txtArrowLength->Hide();
90
94
96 break;
97
98 default:
99 m_sizerLeader->GetStaticBox()->Hide();
100 m_sizerCenter->GetStaticBox()->Hide();
101 break;
102 }
103
104 // Value mode choice offered only for aligned orthogonal and radial
105 // centre and leader have no measured value
106 if( hasValueModeChoice() )
108 else
109 m_choiceValueMode->Show( false );
110
111 m_separator0->SetIsSeparator();
112
113 m_bold->SetIsCheckButton();
115 m_italic->SetIsCheckButton();
117
118 m_separator1->SetIsSeparator();
119
120 m_alignLeft->SetIsRadioButton();
122 m_alignCenter->SetIsRadioButton();
124 m_alignRight->SetIsRadioButton();
126
127 m_separator2->SetIsSeparator();
128
129 m_mirrored->SetIsCheckButton();
131
132 m_separator3->SetIsSeparator();
133
134 // Fix the size after hiding/showing some of the properties
135 Layout();
136
137 // Configure display origin transforms
140
141 // Configure the layers list selector. Note that footprints are built outside the current
142 // board and so we may need to show all layers if the text is on an unactivated layer.
143 if( !m_frame->GetBoard()->IsLayerEnabled( m_dimension->GetLayer() ) )
144 m_cbLayerActual->ShowNonActivatedLayers( true );
145
146 m_cbLayerActual->SetLayersHotkeys( false );
147 m_cbLayerActual->SetBoardFrame( aParent );
148 m_cbLayerActual->Resync();
149
151 m_orientation.SetPrecision( 3 );
152
153 // Set predefined rotations in combo dropdown, according to the locale floating point
154 // separator notation
155 double rot_list[] = { 0.0, 90.0, -90.0, 180.0 };
156
157 for( size_t ii = 0; ii < m_cbTextOrientation->GetCount() && ii < 4; ++ii )
158 m_cbTextOrientation->SetString( ii, wxString::Format( "%.1f", rot_list[ii] ) );
159
160 m_choiceValueMode->Bind( wxEVT_CHOICE,
161 [&]( wxCommandEvent& evt )
162 {
163 // Driven mirrors geometry other modes hold user value
165
166 m_txtValue->Enable( mode != DIM_VALUE_MODE::DRIVEN );
167
168 if( mode == DIM_VALUE_MODE::DRIVEN )
169 {
170 m_txtValue->SetValue( m_dimension->GetValueText() );
171 }
172 else if( mode == DIM_VALUE_MODE::DRIVING )
173 {
174 // Default to measured value if stale expression is not positive
175 int lengthIU = 0;
176
177 if( !parseDrivingLength( lengthIU ) )
178 m_txtValue->SetValue( m_dimension->GetValueText() );
179 }
180
182 } );
183
184 auto updateEventHandler =
185 [&]( wxCommandEvent& evt )
186 {
188 m_txtValue->ChangeValue( m_dimension->GetValueText() );
189
191 };
192
193 // No need to use m_txtValueActual here since we don't have previewing for leaders
194 m_txtValue->Bind( wxEVT_TEXT, updateEventHandler );
195 m_txtPrefix->Bind( wxEVT_TEXT, updateEventHandler );
196 m_txtSuffix->Bind( wxEVT_TEXT, updateEventHandler );
197
198 m_cbUnits->Bind( wxEVT_CHOICE, updateEventHandler );
199 m_cbUnitsFormat->Bind( wxEVT_CHOICE, updateEventHandler );
200 m_cbPrecision->Bind( wxEVT_CHOICE, updateEventHandler );
201 m_cbSuppressZeroes->Bind( wxEVT_CHECKBOX, updateEventHandler );
202
203 m_cbTextPositionMode->Bind( wxEVT_CHOICE,
204 [&]( wxCommandEvent& aEvt )
205 {
206 // manual mode
207 bool allowPositioning = ( m_cbTextPositionMode->GetSelection() == 2 );
208
209 m_txtTextPosX->Enable( allowPositioning );
210 m_txtTextPosY->Enable( allowPositioning );
211 } );
212
213 m_cbKeepAligned->Bind( wxEVT_CHECKBOX,
214 [&]( wxCommandEvent& aEvt )
215 {
216 m_cbTextOrientation->Enable( !m_cbKeepAligned->GetValue() );
217 } );
218
220
222}
223
224
229
230
232{
233 BOARD* board = m_frame->GetBoard();
234
235 // Capture dimension units so Driving length round trips correctly
236 m_valueFieldUnits = m_dimension->GetUnits();
237
238 if( hasValueModeChoice() )
239 {
242 }
243
244 switch( m_dimension->GetUnitsMode() )
245 {
246 case DIM_UNITS_MODE::INCH: m_cbUnits->SetSelection( 0 ); break;
247 case DIM_UNITS_MODE::MILS: m_cbUnits->SetSelection( 1 ); break;
248 case DIM_UNITS_MODE::MM: m_cbUnits->SetSelection( 2 ); break;
249 case DIM_UNITS_MODE::AUTOMATIC: m_cbUnits->SetSelection( 3 ); break;
250 }
251
252 switch ( m_dimension->GetArrowDirection() )
253 {
254 case DIM_ARROW_DIRECTION::INWARD: m_cbArrowDirection->SetSelection( 0 ); break;
255 case DIM_ARROW_DIRECTION::OUTWARD: m_cbArrowDirection->SetSelection( 1 ); break;
256 }
257
258 m_cbUnitsFormat->SetSelection( static_cast<int>( m_dimension->GetUnitsFormat() ) );
259 m_cbPrecision->SetSelection( static_cast<int>( m_dimension->GetPrecision() ) );
260
261 m_txtPrefix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetPrefix() ) );
262 m_txtSuffix->SetValue( board->ConvertKIIDsToCrossReferences( m_dimension->GetSuffix() ) );
263
264 if( m_cbLayerActual->SetLayerSelection( m_dimension->GetLayer() ) < 0 )
265 {
266 wxMessageBox( _( "This item was on a non-existing layer.\n"
267 "It has been moved to the first defined layer." ) );
268 m_cbLayerActual->SetSelection( 0 );
269 }
270
271 m_cbSuppressZeroes->SetValue( m_dimension->GetSuppressZeroes() );
272
273 m_fontCtrl->SetFontSelection( m_dimension->GetFont() );
274
275 m_textWidth.SetValue( m_dimension->GetTextSize().x );
276 m_textHeight.SetValue( m_dimension->GetTextSize().y );
277 m_textThickness.SetValue( m_dimension->GetTextThickness() );
278
279 m_textPosX.SetValue( m_dimension->GetTextPos().x );
280 m_textPosY.SetValue( m_dimension->GetTextPos().y );
281 m_cbTextPositionMode->SetSelection( static_cast<int>( m_dimension->GetTextPositionMode() ) );
282
283 if( m_dimension->GetTextPositionMode() != DIM_TEXT_POSITION::MANUAL )
284 {
285 m_txtTextPosX->Disable();
286 m_txtTextPosY->Disable();
287 }
288
289 EDA_ANGLE orientation = m_dimension->GetTextAngle();
290 m_orientation.SetAngleValue( orientation.Normalize180() );
291 m_cbTextOrientation->Enable( !m_dimension->GetKeepTextAligned() );
292 m_cbKeepAligned->SetValue( m_dimension->GetKeepTextAligned() );
293
294 m_bold->Check( m_dimension->IsBold() );
295 m_italic->Check( m_dimension->IsItalic() );
296
297 switch ( m_dimension->GetHorizJustify() )
298 {
299 case GR_TEXT_H_ALIGN_LEFT: m_alignLeft->Check( true ); break;
300 case GR_TEXT_H_ALIGN_CENTER: m_alignCenter->Check( true ); break;
301 case GR_TEXT_H_ALIGN_RIGHT: m_alignRight->Check( true ); break;
303 }
304
305 m_mirrored->Check( m_dimension->IsMirrored() );
306
307 m_lineThickness.SetValue( m_dimension->GetLineThickness() );
308 m_arrowLength.SetValue( m_dimension->GetArrowLength() );
309 m_extensionOffset.SetValue( m_dimension->GetExtensionOffset() );
310
311 if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( m_dimension ) )
312 m_extensionOvershoot.SetValue( aligned->GetExtensionHeight() );
313 else
314 m_extensionOvershoot.Show( false );
315
316 // Do this last; it depends on the other settings
318 {
319 // Shows constraint length not geometry to prevent silent restage on OK
320 PCB_CONSTRAINT* lengthConstraint = FindDimensionLengthConstraint( board, m_dimension );
321 std::optional<double> value = lengthConstraint ? lengthConstraint->GetValue() : std::nullopt;
322
323 if( value )
325 m_valueFieldUnits, *value ) );
326 else
327 m_txtValueActual->SetValue( m_dimension->GetValueText() );
328 }
329 else if( m_dimension->GetOverrideTextEnabled() )
330 {
331 wxString txt = board->ConvertKIIDsToCrossReferences( m_dimension->GetOverrideText() );
332 m_txtValueActual->SetValue( txt );
333 }
334 else
335 {
336 m_txtValueActual->SetValue( m_dimension->GetValueText() );
337 }
338
339 if( PCB_DIM_LEADER* leader = static_cast<PCB_DIM_LEADER*>( m_dimension ) )
340 m_cbTextFrame->SetSelection( static_cast<int>( leader->GetTextBorder() ) );
341
342 return DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataToWindow();
343}
344
345
347{
348 if( !DIALOG_DIMENSION_PROPERTIES_BASE::TransferDataFromWindow() )
349 return false;
350
351 // Non positive length keeps dialog open avoids collapsing constraint to zero
353 {
354 int lengthIU = 0;
355
356 if( !parseDrivingLength( lengthIU ) )
357 {
358 wxMessageBox( _( "Enter a positive length for a driving dimension." ),
359 _( "Invalid Value" ), wxOK | wxICON_ERROR, this );
360 return false;
361 }
362 }
363
364 BOARD_COMMIT commit( m_frame );
365 commit.Modify( m_dimension );
366
367 // If no other command in progress, prepare undo command
368 // (for a command in progress, will be made later, at the completion of command)
369 bool pushCommit = ( m_dimension->GetEditFlags() == 0 );
370
371 /* set flag in edit to force undo/redo/abort proper operation,
372 * and avoid new calls to SaveCopyInUndoList for the same dimension
373 * this can occurs when a dimension is moved, and then rotated, edited ..
374 */
375 if( !pushCommit )
376 m_dimension->SetFlags( IN_EDIT );
377
379
380 // Value dimensions always own their commit so the constraint stages and pushes here
381 wxASSERT_MSG( pushCommit || !hasValueModeChoice(),
382 wxT( "value dimension edited without owning its commit; value mode would be lost" ) );
383
384 PCB_CONSTRAINT* drivingConstraint = pushCommit ? stageValueModeConstraint( commit ) : nullptr;
385
386 if( pushCommit )
387 commit.Push( _( "Edit Dimension Properties" ) );
388
389 if( drivingConstraint )
390 resolveDrivingConstraint( drivingConstraint );
391
392 return true;
393}
394
395
397{
398 switch( m_dimension->Type() )
399 {
402 case PCB_DIM_RADIAL_T:
403 return true;
404
405 default:
406 return false;
407 }
408}
409
410
412{
414
415 m_choiceValueMode->Clear();
416 m_choiceValueMode->Append( _( "Driven" ) );
417
419 m_choiceValueMode->Append( _( "Driving" ) );
420
421 m_choiceValueMode->Append( _( "Arbitrary" ) );
422 m_choiceValueMode->SetSelection( 0 );
423 m_choiceValueMode->Show( true );
424}
425
426
428{
429 int selection = m_choiceValueMode->GetSelection();
430
431 if( selection <= 0 )
433
435 return selection == 1 ? DIM_VALUE_MODE::DRIVING : DIM_VALUE_MODE::ARBITRARY;
436
438}
439
440
442{
443 int selection = 0;
444
445 switch( aMode )
446 {
448 selection = 0;
449 break;
450
452 // Driving may not be offered (endpoints not both bound); fall back to Driven.
453 selection = m_valueModeHasDriving ? 1 : 0;
454 break;
455
457 selection = m_valueModeHasDriving ? 2 : 1;
458 break;
459 }
460
461 m_choiceValueMode->SetSelection( selection );
462}
463
464
466{
467 if( hasValueModeChoice() )
469
470 return false;
471}
472
473
475{
476 if( !hasValueModeChoice() )
477 return nullptr;
478
480 std::optional<int> length;
481
482 if( mode == DIM_VALUE_MODE::DRIVING )
483 {
484 int lengthIU = 0;
485
486 // Already validated so failure here stages nothing not a zero length
487 if( parseDrivingLength( lengthIU ) )
488 length = lengthIU;
489 }
490
491 // Override text already written by updateDimensionFromDialog skip here
492 return SetDimensionValueMode( m_frame->GetBoard(), m_dimension, mode, length, std::nullopt,
493 [&]( BOARD_ITEM* aItem ) { aCommit.Modify( aItem ); },
494 [&]( BOARD_ITEM* aItem ) { aCommit.Add( aItem ); },
495 [&]( BOARD_ITEM* aItem ) { aCommit.Remove( aItem ); } );
496}
497
498
500{
501 // Parse using the field displayed units stale text parses to zero caught by positive check
503 m_txtValue->GetValue() );
504
505 if( !( iu > 0.0 ) )
506 return false;
507
508 aLengthIU = KiROUND( iu );
509 return true;
510}
511
512
514{
515 BOARD_COMMIT commit( m_frame );
516 std::vector<PCB_SHAPE*> modified;
517
518 // Driving length moves far endpoint and coincident geometry
519 // Stage each item just before it changes for clean undo
520 ApplyConstraintImmediately( m_frame->GetBoard(), aConstraint, &modified,
521 [&]( BOARD_ITEM* aItem )
522 {
523 commit.Modify( aItem );
524 } );
525
526 // APPEND_UNDO folds solve into prior edit one undo reverts both
527 if( !commit.Empty() )
528 commit.Push( _( "Apply Dimension Length" ), APPEND_UNDO );
529}
530
531
532void DIALOG_DIMENSION_PROPERTIES::onFontSelected( wxCommandEvent & aEvent )
533{
534 m_textThickness.Show( KIFONT::FONT::IsStroke( aEvent.GetString() ) );
535}
536
537
538void DIALOG_DIMENSION_PROPERTIES::onAlignButton( wxCommandEvent& aEvent )
539{
541 {
542 if( btn->IsChecked() && btn != aEvent.GetEventObject() )
543 btn->Check( false );
544 }
545}
546
547
549{
550 BOARD* board = m_frame->GetBoard();
551
552 if( hasValueModeChoice() )
553 {
554 // Only Arbitrary shows custom text Driven and Driving measure geometry natively
556 {
557 aTarget->SetOverrideTextEnabled( true );
558 aTarget->SetOverrideText( board->ConvertCrossReferencesToKIIDs( m_txtValueActual->GetValue() ) );
559 }
560 else
561 {
562 aTarget->SetOverrideTextEnabled( false );
563 }
564 }
565 else
566 {
567 // Centre and leader lack value mode choice preserve existing override state
568 aTarget->SetOverrideTextEnabled( m_dimension->GetOverrideTextEnabled() );
569
570 if( m_dimension->GetOverrideTextEnabled() )
571 {
572 wxString txt = board->ConvertCrossReferencesToKIIDs( m_txtValueActual->GetValue() );
573 aTarget->SetOverrideText( txt );
574 }
575 }
576
577 aTarget->SetPrefix( board->ConvertCrossReferencesToKIIDs( m_txtPrefix->GetValue() ) );
578 aTarget->SetSuffix( board->ConvertCrossReferencesToKIIDs( m_txtSuffix->GetValue() ) );
579 aTarget->SetLayer( static_cast<PCB_LAYER_ID>( m_cbLayerActual->GetLayerSelection() ) );
580
581 switch ( m_cbArrowDirection->GetSelection() ) {
582 case 0: aTarget->SetArrowDirection( DIM_ARROW_DIRECTION::INWARD ); break;
583 case 1: aTarget->SetArrowDirection( DIM_ARROW_DIRECTION::OUTWARD ); break;
584 }
585
586 switch( m_cbUnits->GetSelection() )
587 {
588 case 0: aTarget->SetUnitsMode( DIM_UNITS_MODE::INCH ); break;
589 case 1: aTarget->SetUnitsMode( DIM_UNITS_MODE::MILS ); break;
590 case 2: aTarget->SetUnitsMode( DIM_UNITS_MODE::MM ); break;
591 case 3: aTarget->SetUnitsMode( DIM_UNITS_MODE::AUTOMATIC ); break;
592 }
593
594 aTarget->SetUnitsFormat( static_cast<DIM_UNITS_FORMAT>( m_cbUnitsFormat->GetSelection() ) );
595 aTarget->SetPrecision( static_cast<DIM_PRECISION>( m_cbPrecision->GetSelection() ) );
596 aTarget->SetSuppressZeroes( m_cbSuppressZeroes->GetValue() );
597
598 DIM_TEXT_POSITION tpm = static_cast<DIM_TEXT_POSITION>( m_cbTextPositionMode->GetSelection() );
599 aTarget->SetTextPositionMode( tpm );
600
601 if( tpm == DIM_TEXT_POSITION::MANUAL )
602 {
603 VECTOR2I pos( m_textPosX.GetValue(), m_textPosY.GetValue() );
604 aTarget->SetTextPos( pos );
605 }
606
607 aTarget->SetKeepTextAligned( m_cbKeepAligned->GetValue() );
608
609 aTarget->SetTextAngle( m_orientation.GetAngleValue().Normalize() );
610 aTarget->SetTextWidth( m_textWidth.GetValue() );
611 aTarget->SetTextHeight( m_textHeight.GetValue() );
612 aTarget->SetTextThickness( m_textThickness.GetValue() );
613
614 if( m_fontCtrl->HaveFontSelection() )
615 aTarget->SetFont( m_fontCtrl->GetFontSelection( m_bold->IsChecked(), m_italic->IsChecked() ) );
616
617 // Must come after SetTextWidth/Height()
618 aTarget->SetBoldFlag( m_bold->IsChecked() );
619 aTarget->SetItalic( m_italic->IsChecked() );
620
621 if( m_alignLeft->IsChecked() )
623 else if( m_alignCenter->IsChecked() )
625 else
627
628 aTarget->SetMirrored( m_mirrored->IsChecked() );
629
630 aTarget->SetLineThickness( m_lineThickness.GetValue() );
631 aTarget->SetArrowLength( m_arrowLength.GetValue() );
632 aTarget->SetExtensionOffset( m_extensionOffset.GetValue() );
633
634 if( PCB_DIM_ALIGNED* aligned = dynamic_cast<PCB_DIM_ALIGNED*>( aTarget ) )
635 aligned->SetExtensionHeight( m_extensionOvershoot.GetValue() );
636
637 if( PCB_DIM_LEADER* leader = dynamic_cast<PCB_DIM_LEADER*>( aTarget ) )
638 leader->SetTextBorder( static_cast<DIM_TEXT_BORDER>( m_cbTextFrame->GetSelection()));
639
640 aTarget->Update();
641}
642
643
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
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:995
A bitmap button widget that behaves like an AUI toolbar item's button when it is drawn.
virtual 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:84
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:374
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
Definition board.cpp:2551
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
Definition board.cpp:2631
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_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
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 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:268
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:539
void SetMirrored(bool isMirrored)
Definition eda_text.cpp:349
virtual void SetTextWidth(int aWidth)
Definition eda_text.cpp:517
void SetBoldFlag(bool aBold)
Set only the bold flag, without changing the font.
Definition eda_text.cpp:319
virtual void SetTextHeight(int aHeight)
Definition eda_text.cpp:528
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:285
void SetFont(KIFONT::FONT *aFont)
Definition eda_text.cpp:458
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:365
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:569
@ FOR_GUI
Definition common.h:89
DIM_VALUE_MODE DimensionValueMode(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(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the drivin...
bool DimensionCanDrive(BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpoint...
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
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:259
@ 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:683