KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_symbol_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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
25
26#include <memory>
27
28#include <bitmaps.h>
29#include <wx/tooltip.h>
30#include <wx/uiaction.h>
31#include <grid_tricks.h>
32#include <confirm.h>
33#include <kiface_base.h>
34#include <pin_numbers.h>
35#include <string_utils.h>
36#include <kiplatform/ui.h>
41#include <sch_collectors.h>
42#include <fields_grid_table.h>
43#include <sch_edit_frame.h>
44#include <sch_reference_list.h>
45#include <schematic.h>
46#include <sch_commit.h>
47#include <tool/tool_manager.h>
48#include <tool/actions.h>
49
50#include <dialog_sim_model.h>
52
53
54wxDEFINE_EVENT( SYMBOL_DELAY_FOCUS, wxCommandEvent );
55wxDEFINE_EVENT( SYMBOL_DELAY_SELECTION, wxCommandEvent );
56
57
62static void EnableFocusDebugging( wxWindow* aWindow, const wxString& aWindowName = wxEmptyString )
63{
64 // Lambda-based focus event handler
65 auto onFocus = [aWindowName]( wxFocusEvent& aEvent ) -> void
66 {
67 wxWindow* window = static_cast<wxWindow*>( aEvent.GetEventObject() );
68 if( !window )
69 return;
70
71 wxString controlName = window->GetName();
72 wxString controlLabel;
73
74 // Try to get a human-readable label for the control
75 wxControl* ctrl = dynamic_cast<wxControl*>( window );
76 if( ctrl && !ctrl->GetLabel().empty() )
77 controlLabel = ctrl->GetLabel();
78
79 wxString windowInfo = aWindowName.empty() ? wxString( "" ) : aWindowName + wxString( ": " );
80
81 if( aEvent.GetEventType() == wxEVT_SET_FOCUS )
82 {
83 wxLogTrace( wxS( "FOCUS_DEBUG" ), wxS( "%sFocus SET on: %s (name=%s, label=%s)" ),
84 windowInfo,
85 window->GetClassInfo()->GetClassName(),
86 controlName,
87 controlLabel );
88 }
89 else if( aEvent.GetEventType() == wxEVT_KILL_FOCUS )
90 {
91 wxLogTrace( wxS( "FOCUS_DEBUG" ), wxS( "%sFocus LOST from: %s (name=%s, label=%s)" ),
92 windowInfo,
93 window->GetClassInfo()->GetClassName(),
94 controlName,
95 controlLabel );
96 }
97
98 aEvent.Skip(); // Allow event to propagate
99 };
100
101 // Recursively attach handler to this window and all children
102 std::function<void( wxWindow* )> attachToTree = [&]( wxWindow* w ) -> void
103 {
104 if( !w )
105 return;
106
107 w->Bind( wxEVT_SET_FOCUS, onFocus );
108 w->Bind( wxEVT_KILL_FOCUS, onFocus );
109
110 // Recursively attach to all child windows
111 for( wxWindow* child : w->GetChildren() )
112 attachToTree( child );
113 };
114
115 attachToTree( aWindow );
116
117 wxLogTrace( wxS( "FOCUS_DEBUG" ), wxS( "Focus debugging enabled for: %s" ), aWindowName );
118}
119
120
131
132
133class SCH_PIN_TABLE_DATA_MODEL : public WX_GRID_TABLE_BASE, public std::vector<SCH_PIN>
134{
135public:
137 m_readOnlyAttr( nullptr ),
138 m_typeAttr( nullptr ),
139 m_shapeAttr( nullptr )
140 {
141 }
142
144 {
145 for( wxGridCellAttr* attr : m_nameAttrs )
146 attr->DecRef();
147
148 m_readOnlyAttr->DecRef();
149 m_typeAttr->DecRef();
150 m_shapeAttr->DecRef();
151 }
152
154 {
155 for( wxGridCellAttr* attr : m_nameAttrs )
156 attr->DecRef();
157
158 m_nameAttrs.clear();
159
160 if( m_readOnlyAttr )
161 m_readOnlyAttr->DecRef();
162
163 m_readOnlyAttr = new wxGridCellAttr;
164 m_readOnlyAttr->SetReadOnly( true );
165
166 for( const SCH_PIN& pin : *this )
167 {
168 SCH_PIN* lib_pin = pin.GetLibPin();
169 wxGridCellAttr* attr = nullptr;
170
171 if( !lib_pin || lib_pin->GetAlternates().empty() )
172 {
173 attr = new wxGridCellAttr;
174 attr->SetReadOnly( true );
175 attr->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
176 }
177 else
178 {
179 wxArrayString choices;
180 choices.push_back( lib_pin->GetName() );
181
182 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : lib_pin->GetAlternates() )
183 choices.push_back( alt.first );
184
185 attr = new wxGridCellAttr();
186 attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
187 }
188
189 m_nameAttrs.push_back( attr );
190 }
191
192 if( m_typeAttr )
193 m_typeAttr->DecRef();
194
195 m_typeAttr = new wxGridCellAttr;
197 m_typeAttr->SetReadOnly( true );
198
199 if( m_shapeAttr )
200 m_shapeAttr->DecRef();
201
202 m_shapeAttr = new wxGridCellAttr;
204 m_shapeAttr->SetReadOnly( true );
205 }
206
207 int GetNumberRows() override { return (int) size(); }
208 int GetNumberCols() override { return COL_COUNT; }
209
210 wxString GetColLabelValue( int aCol ) override
211 {
212 switch( aCol )
213 {
214 case COL_NUMBER: return _( "Number" );
215 case COL_BASE_NAME: return _( "Base Name" );
216 case COL_ALT_NAME: return _( "Alternate Assignment" );
217 case COL_TYPE: return _( "Electrical Type" );
218 case COL_SHAPE: return _( "Graphic Style" );
219 default: wxFAIL; return wxEmptyString;
220 }
221 }
222
223 bool IsEmptyCell( int row, int col ) override
224 {
225 return false; // don't allow adjacent cell overflow, even if we are actually empty
226 }
227
228 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
229 {
230 // Don't accept random values; must use the popup to change to a known alternate
231 return false;
232 }
233
234 wxString GetValue( int aRow, int aCol ) override
235 {
236 return GetValue( at( aRow ), aCol );
237 }
238
239 static wxString GetValue( const SCH_PIN& aPin, int aCol )
240 {
241 if( aCol == COL_ALT_NAME )
242 {
243 if( !aPin.GetLibPin() || aPin.GetLibPin()->GetAlternates().empty() )
244 return wxEmptyString;
245 else if( aPin.GetAlt().IsEmpty() )
246 return aPin.GetName();
247 else
248 return aPin.GetAlt();
249 }
250
251 switch( aCol )
252 {
253 case COL_NUMBER: return aPin.GetNumber();
254 case COL_BASE_NAME: return aPin.GetBaseName();
255 case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
256 case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
257 default: wxFAIL; return wxEmptyString;
258 }
259 }
260
261 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override
262 {
263 switch( aCol )
264 {
265 case COL_NUMBER:
266 case COL_BASE_NAME:
267 m_readOnlyAttr->IncRef();
268 return enhanceAttr( m_readOnlyAttr, aRow, aCol, aKind );
269
270 case COL_ALT_NAME:
271 m_nameAttrs[ aRow ]->IncRef();
272 return enhanceAttr( m_nameAttrs[ aRow ], aRow, aCol, aKind );
273
274 case COL_TYPE:
275 m_typeAttr->IncRef();
276 return enhanceAttr( m_typeAttr, aRow, aCol, aKind );
277
278 case COL_SHAPE:
279 m_shapeAttr->IncRef();
280 return enhanceAttr( m_shapeAttr, aRow, aCol, aKind );
281
282 default:
283 wxFAIL;
284 return nullptr;
285 }
286 }
287
288 void SetValue( int aRow, int aCol, const wxString &aValue ) override
289 {
290 SCH_PIN& pin = at( aRow );
291
292 switch( aCol )
293 {
294 case COL_ALT_NAME:
295 if( pin.GetLibPin() && aValue == pin.GetLibPin()->GetName() )
296 pin.SetAlt( wxEmptyString );
297 else
298 pin.SetAlt( aValue );
299 break;
300
301 case COL_NUMBER:
302 case COL_BASE_NAME:
303 case COL_TYPE:
304 case COL_SHAPE:
305 // Read-only.
306 break;
307
308 default:
309 wxFAIL;
310 break;
311 }
312 }
313
314 static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
315 {
316 wxString lhStr = GetValue( lhs, sortCol );
317 wxString rhStr = GetValue( rhs, sortCol );
318
319 if( lhStr == rhStr )
320 {
321 // Secondary sort key is always COL_NUMBER
322 sortCol = COL_NUMBER;
323 lhStr = GetValue( lhs, sortCol );
324 rhStr = GetValue( rhs, sortCol );
325 }
326
327 bool res;
328
329 // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
330 // to get the opposite sort. i.e. ~(a<b) != (a>b)
331 auto cmp = [ ascending ]( const auto a, const auto b )
332 {
333 if( ascending )
334 return a < b;
335 else
336 return b < a;
337 };
338
339 switch( sortCol )
340 {
341 case COL_NUMBER:
342 case COL_BASE_NAME:
343 case COL_ALT_NAME:
344 res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 );
345 break;
346 case COL_TYPE:
347 case COL_SHAPE:
348 res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
349 break;
350 default:
351 res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
352 break;
353 }
354
355 return res;
356 }
357
358 void SortRows( int aSortCol, bool ascending )
359 {
360 std::sort( begin(), end(),
361 [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
362 {
363 return compare( lhs, rhs, aSortCol, ascending );
364 } );
365 }
366
367protected:
368 std::vector<wxGridCellAttr*> m_nameAttrs;
369 wxGridCellAttr* m_readOnlyAttr;
370 wxGridCellAttr* m_typeAttr;
371 wxGridCellAttr* m_shapeAttr;
372};
373
374
377 m_symbol( nullptr ),
378 m_part( nullptr ),
380 m_editorShown( false ),
381 m_fields( nullptr ),
382 m_dataModel( nullptr ),
383 m_embeddedFiles( nullptr )
384{
385 m_symbol = aSymbol;
386 m_part = m_symbol->GetLibSymbolRef().get();
387
388 // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
389 // there for usual cases, but can be null when opening old schematics not storing the part
390 // so we need to handle m_part == nullptr
391 // wxASSERT( m_part );
392
393 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_symbol );
394
395 m_fieldsGrid->SetTable( m_fields );
396 m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
397 { &aParent->Schematic(), m_part },
398 [&]( wxCommandEvent& aEvent )
399 {
400 OnAddField( aEvent );
401 } ) );
402 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
403 m_fieldsGrid->ShowHideColumns( "0 1 2 3 4 5 6 7" );
404 m_shownColumns = m_fieldsGrid->GetShownColumns();
405
406 if( m_symbol->GetEmbeddedFiles() )
407 {
408 m_embeddedFiles = new PANEL_EMBEDDED_FILES( m_notebook1, m_symbol->GetEmbeddedFiles() );
409 m_notebook1->AddPage( m_embeddedFiles, _( "Embedded Files" ) );
410 }
411
412 if( m_part && m_part->IsMultiBodyStyle() )
413 {
414 // Multiple body styles are a superclass of alternate pin assignments, so don't allow
415 // free-form alternate assignments as well. (We won't know how to map the alternates
416 // back and forth when the body style is changed.)
417 m_pinTablePage->Disable();
418 m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for symbols with multiple "
419 "body styles." ) );
420 }
421 else
422 {
424
425 // Make a copy of the pins for editing
426 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
427 m_dataModel->push_back( *pin );
428
429 m_dataModel->SortRows( COL_NUMBER, true );
430 m_dataModel->BuildAttrs();
431
432 m_pinGrid->SetTable( m_dataModel );
433 }
434
435 if( m_part && m_part->IsPower() )
436 m_spiceFieldsButton->Hide();
437
438 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
439 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
440
441 wxFont infoFont = KIUI::GetSmallInfoFont( this );
442 m_libraryIDLabel->SetFont( infoFont );
443 m_tcLibraryID->SetFont( infoFont );
444 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
445
446 wxToolTip::Enable( true );
448
449 // Configure button logos
454
455 // Enable focus debugging to track which element has focus
456 EnableFocusDebugging( this, wxS( "DIALOG_SYMBOL_PROPERTIES" ) );
457
458 // wxFormBuilder doesn't include this event...
459 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
460 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
461 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
462 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
463
464
465 // On non-GTK platforms, just open the cell editor directly
466 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
467 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
468 QueueEvent( evt );
469
470 evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
471 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
472 QueueEvent( evt );
473
474 // Remind user that they are editing the current variant.
475 if( !aParent->Schematic().GetCurrentVariant().IsEmpty() )
476 SetTitle( GetTitle() + wxS( " - " ) + aParent->Schematic().GetCurrentVariant() + _( " Variant" ) );
477
478 Layout();
479
480 if( GetSizer() )
481 GetSizer()->Fit( this );
482
484}
485
486
488{
489 // Prevents crash bug in wxGrid's d'tor
490 m_fieldsGrid->DestroyTable( m_fields );
491
492 if( m_dataModel )
493 m_pinGrid->DestroyTable( m_dataModel );
494
495 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
496 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
497 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
498 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
499
500 // Delete the GRID_TRICKS.
501 m_fieldsGrid->PopEventHandler( true );
502 m_pinGrid->PopEventHandler( true );
503}
504
505
507{
508 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
509}
510
511
513{
514 if( !wxDialog::TransferDataToWindow() )
515 return false;
516
517 const SCHEMATIC& schematic = GetParent()->Schematic();
518 SCH_SHEET_PATH& sheetPath = schematic.CurrentSheet();
519 wxString variantName = schematic.GetCurrentVariant();
520 std::optional<SCH_SYMBOL_VARIANT> variant = m_symbol->GetVariant( sheetPath, variantName );
521 std::set<wxString> defined;
522
523 // Push a copy of each field into m_updateFields
524 for( SCH_FIELD& srcField : m_symbol->GetFields() )
525 {
526 SCH_FIELD field( srcField );
527
528 // change offset to be symbol-relative
529 field.Offset( -m_symbol->GetPosition() );
530 field.SetText( schematic.ConvertKIIDsToRefs( m_symbol->GetFieldText( field.GetName(), &sheetPath,
531 variantName ) ) );
532
533 defined.insert( field.GetName() );
534 m_fields->push_back( field );
535 }
536
537 // Add in any template fieldnames not yet defined:
538 for( const TEMPLATE_FIELDNAME& templateFieldname :
540 {
541 if( defined.count( templateFieldname.m_Name ) <= 0 )
542 {
543 SCH_FIELD field( m_symbol, FIELD_T::USER, templateFieldname.m_Name );
544 field.SetVisible( templateFieldname.m_Visible );
545 m_fields->push_back( field );
546 }
547 }
548
549 // notify the grid
550 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
551 m_fieldsGrid->ProcessTableMessage( msg );
552
553 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
554 if( m_symbol->IsMultiUnit() )
555 {
556 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
557 // from the current sheet path, because it can be modified by previous calculations
558 m_symbol->SetUnit( m_symbol->GetUnitSelection( &sheetPath ) );
559
560 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
561 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii, false ) );
562
563 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
564 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
565 }
566 else
567 {
568 m_unitLabel->Enable( false );
569 m_unitChoice->Enable( false );
570 }
571
572 if( m_part && m_part->IsMultiBodyStyle() )
573 {
574 if( m_part->HasDeMorganBodyStyles() )
575 {
576 m_bodyStyleChoice->Append( _( "Standard" ) );
577 m_bodyStyleChoice->Append( _( "Alternate" ) );
578 }
579 else
580 {
581 wxASSERT( (int)m_part->GetBodyStyleNames().size() == m_part->GetBodyStyleCount() );
582
583 for( int ii = 0; ii < m_part->GetBodyStyleCount(); ii++ )
584 {
585 try
586 {
587 m_bodyStyleChoice->Append( m_part->GetBodyStyleNames().at( ii ) );
588 }
589 catch( ... )
590 {
591 m_bodyStyleChoice->Append( wxT( "???" ) );
592 }
593 }
594 }
595
596 if( m_symbol->GetBodyStyle() <= (int) m_bodyStyleChoice->GetCount() )
597 m_bodyStyleChoice->SetSelection( m_symbol->GetBodyStyle() - 1 );
598 }
599 else
600 {
601 m_bodyStyle->Enable( false );
602 m_bodyStyleChoice->Enable( false );
603 }
604
605 // Set the symbol orientation and mirroring.
606 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
607
608 switch( orientation )
609 {
610 default:
611 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
612 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
613 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
614 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
615 }
616
617 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
618
619 switch( mirror )
620 {
621 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
622 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
623 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
624 }
625
626 m_cbExcludeFromSim->SetValue( m_symbol->GetExcludedFromSim( &sheetPath, variantName ) );
627 m_cbExcludeFromBom->SetValue( m_symbol->GetExcludedFromBOM( &sheetPath, variantName ) );
628 m_cbExcludeFromBoard->SetValue( m_symbol->GetExcludedFromBoard() );
629 m_cbExcludeFromPosFiles->SetValue( m_symbol->GetExcludedFromPosFiles() );
630 m_cbDNP->SetValue( m_symbol->GetDNP( &sheetPath, variantName ) );
631
632 if( m_part )
633 {
634 m_ShowPinNumButt->SetValue( m_part->GetShowPinNumbers() );
635 m_ShowPinNameButt->SetValue( m_part->GetShowPinNames() );
636 }
637
638 // Set the symbol's library name.
639 m_tcLibraryID->SetValue( UnescapeString( m_symbol->GetLibId().Format() ) );
640
641 if( m_embeddedFiles && !m_embeddedFiles->TransferDataToWindow() )
642 return false;
643
644 Layout();
645 m_fieldsGrid->Layout();
646
647#ifdef __WXGTK__
648 wxSafeYield();
649#endif
650
651 return true;
652}
653
654
656{
657 if( !m_fieldsGrid->CommitPendingChanges() )
658 return;
659
660 m_fieldsGrid->ClearSelection();
661
662 std::vector<SCH_FIELD> fields;
663
664 for( const SCH_FIELD& field : *m_fields )
665 fields.emplace_back( field );
666
667 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_symbol, fields );
668
669 if( dialog.ShowModal() != wxID_OK )
670 return;
671
672 // Add in any new fields
673 for( const SCH_FIELD& editedField : fields )
674 {
675 bool found = false;
676
677 for( SCH_FIELD& existingField : *m_fields )
678 {
679 if( existingField.GetName() == editedField.GetName() )
680 {
681 found = true;
682 existingField.SetText( editedField.GetText() );
683 break;
684 }
685 }
686
687 if( !found )
688 {
689 m_fields->emplace_back( editedField );
690 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
691 m_fieldsGrid->ProcessTableMessage( msg );
692 }
693 }
694
695 // Remove any deleted fields
696 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
697 {
698 SCH_FIELD& existingField = m_fields->at( ii );
699 bool found = false;
700
701 for( SCH_FIELD& editedField : fields )
702 {
703 if( editedField.GetName() == existingField.GetName() )
704 {
705 found = true;
706 break;
707 }
708 }
709
710 if( !found )
711 {
712 m_fieldsGrid->ClearSelection();
713 m_fields->erase( m_fields->begin() + ii );
714
715 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
716 m_fieldsGrid->ProcessTableMessage( msg );
717 }
718 }
719
720 OnModify();
721 m_fieldsGrid->ForceRefresh();
722}
723
724
726{
727 // Running the Footprint Browser gums up the works and causes the automatic cancel
728 // stuff to no longer work. So we do it here ourselves.
729 EndQuasiModal( wxID_CANCEL );
730}
731
732
734{
735 LIB_ID id;
736
737 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
738 return false;
739
740 // Check for missing field names.
741 for( size_t i = 0; i < m_fields->size(); ++i )
742 {
743 SCH_FIELD& field = m_fields->at( i );
744
745 if( field.IsMandatory() )
746 continue;
747
748 wxString fieldName = field.GetName( false );
749
750 if( fieldName.IsEmpty() )
751 {
752 DisplayErrorMessage( this, _( "Fields must have a name." ) );
753
754 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
755 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
756 QueueEvent( evt );
757
758 return false;
759 }
760 }
761
762 return true;
763}
764
765
767{
768 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
769 return false;
770
771 if( m_embeddedFiles && !m_embeddedFiles->TransferDataFromWindow() )
772 return false;
773
774 if( !m_fieldsGrid->CommitPendingChanges() )
775 return false;
776
777 if( !m_pinGrid->CommitPendingChanges() )
778 return false;
779
780 SCH_COMMIT commit( GetParent() );
781 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
782 SCH_SHEET_PATH currentSheet = GetParent()->Schematic().CurrentSheet();
783 wxString currentVariant = GetParent()->Schematic().GetCurrentVariant();
784 bool replaceOnCurrentScreen;
785
786 wxCHECK( currentScreen, false );
787
788 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
789 // the schematic file.
790 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
791
792 // save old cmp in undo list if not already in edit, or moving ...
793 if( m_symbol->GetEditFlags() == 0 )
794 commit.Modify( m_symbol, currentScreen );
795
796 // Save current flags which could be modified by next change settings
797 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
798
799 //Set the part selection in multiple part per package
800 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
801 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
802 m_symbol->SetUnit( unit_selection );
803
804 int bodyStyle_selection = m_bodyStyleChoice->IsEnabled() ? m_bodyStyleChoice->GetSelection() + 1 : 1;
805 m_symbol->SetBodyStyle( bodyStyle_selection );
806
807 switch( m_orientationCtrl->GetSelection() )
808 {
809 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
810 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
811 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
812 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
813 }
814
815 switch( m_mirrorCtrl->GetSelection() )
816 {
817 case 0: break;
818 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
819 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
820 }
821
822 m_symbol->SetShowPinNames( m_ShowPinNameButt->GetValue() );
823 m_symbol->SetShowPinNumbers( m_ShowPinNumButt->GetValue() );
824
825 // Restore m_Flag modified by SetUnit() and other change settings from the dialog
826 m_symbol->ClearFlags();
827 m_symbol->SetFlags( flags );
828
829 // change all field positions from relative to absolute
830 for( SCH_FIELD& field : *m_fields )
831 field.Offset( m_symbol->GetPosition() );
832
833 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
834
835 for( SCH_FIELD& field : *m_fields )
836 {
837 const wxString& fieldName = field.GetCanonicalName();
838
839 if( fieldName.IsEmpty() && field.GetText().IsEmpty() )
840 continue;
841 else if( fieldName.IsEmpty() )
842 field.SetName( _( "untitled" ) );
843
844 const SCH_FIELD* existingField = m_symbol->GetField( fieldName );
845 SCH_FIELD* tmp;
846
847 if( !existingField )
848 {
849 tmp = m_symbol->AddField( field );
850 tmp->SetParent( m_symbol );
851 }
852 else
853 {
854 wxString defaultText = m_symbol->Schematic()->ConvertRefsToKIIDs( existingField->GetText() );
855 tmp = const_cast<SCH_FIELD*>( existingField );
856
857 *tmp = field;
858
859 if( !currentVariant.IsEmpty() )
860 {
861 // Restore the default field text for existing fields.
862 tmp->SetText( defaultText, &currentSheet );
863
864 wxString variantText = m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() );
865 tmp->SetText( variantText, &currentSheet, currentVariant );
866 }
867 }
868
869 if( !field.IsMandatory() )
870 field.SetOrdinal( ordinal++ );
871 }
872
873 m_symbol->SetExcludedFromSim( m_cbExcludeFromSim->IsChecked(), &currentSheet, currentVariant );
874 m_symbol->SetExcludedFromBOM( m_cbExcludeFromBom->IsChecked(), &currentSheet, currentVariant );
875 m_symbol->SetExcludedFromBoard( m_cbExcludeFromBoard->IsChecked() );
876 m_symbol->SetExcludedFromPosFiles( m_cbExcludeFromPosFiles->IsChecked() );
877 m_symbol->SetDNP( m_cbDNP->IsChecked(), &currentSheet, currentVariant );
878
879 // Update any assignments
880 if( m_dataModel )
881 {
882 for( const SCH_PIN& model_pin : *m_dataModel )
883 {
884 // map from the edited copy back to the "real" pin in the symbol.
885 SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetNumber() );
886
887 if( src_pin )
888 src_pin->SetAlt( model_pin.GetAlt() );
889 }
890 }
891
892 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
893 // in sync in multi-unit parts.
894 m_symbol->SyncOtherUnits( currentSheet, commit, nullptr );
895
896 if( replaceOnCurrentScreen )
897 currentScreen->Append( m_symbol );
898
899 if( !commit.Empty() )
900 commit.Push( _( "Edit Symbol Properties" ) );
901
902 return true;
903}
904
905
907{
908 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
909 wxControl* control = editor->GetControl();
910
911 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
912 {
913 event.Veto();
914 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
915 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
916 QueueEvent( evt );
917 }
918 else if( event.GetCol() == FDC_NAME )
919 {
920 wxString newName = event.GetString();
921
922 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
923 {
924 if( i == event.GetRow() )
925 continue;
926
927 if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
928 {
929 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
930 newName ) );
931 event.Veto();
932 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
933 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
934 QueueEvent( evt );
935 }
936 }
937 }
938
939 editor->DecRef();
940}
941
942
944{
945 if( m_fields->at( aEvent.GetRow() ).GetId() == FIELD_T::REFERENCE
946 && aEvent.GetCol() == FDC_VALUE )
947 {
948 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
949 evt->SetClientData( new VECTOR2I( aEvent.GetRow(), aEvent.GetCol() ) );
950 QueueEvent( evt );
951 }
952
953 m_editorShown = true;
954}
955
956
958{
959 m_editorShown = false;
960}
961
962
963void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
964{
965 m_fieldsGrid->OnAddRow(
966 [&]() -> std::pair<int, int>
967 {
969
970 newField.SetTextAngle( m_fields->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
971 newField.SetVisible( false );
972
973 m_fields->push_back( newField );
974
975 // notify the grid
976 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
977 m_fieldsGrid->ProcessTableMessage( msg );
978 OnModify();
979
980 return { m_fields->size() - 1, FDC_NAME };
981 } );
982}
983
984
985void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
986{
987 m_fieldsGrid->OnDeleteRows(
988 [&]( int row )
989 {
990 if( row < m_fields->GetMandatoryRowCount() )
991 {
992 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
993 m_fields->GetMandatoryRowCount() ) );
994 return false;
995 }
996
997 return true;
998 },
999 [&]( int row )
1000 {
1001 m_fields->erase( m_fields->begin() + row );
1002
1003 // notify the grid
1004 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
1005 m_fieldsGrid->ProcessTableMessage( msg );
1006 } );
1007
1008 OnModify();
1009}
1010
1011
1012void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
1013{
1014 m_fieldsGrid->OnMoveRowUp(
1015 [&]( int row )
1016 {
1017 return row > m_fields->GetMandatoryRowCount();
1018 },
1019 [&]( int row )
1020 {
1021 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row - 1 ) );
1022 m_fieldsGrid->ForceRefresh();
1023 OnModify();
1024 } );
1025}
1026
1027
1028void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
1029{
1030 m_fieldsGrid->OnMoveRowDown(
1031 [&]( int row )
1032 {
1033 return row >= m_fields->GetMandatoryRowCount();
1034 },
1035 [&]( int row )
1036 {
1037 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row + 1 ) );
1038 m_fieldsGrid->ForceRefresh();
1039 OnModify();
1040 } );
1041}
1042
1043
1049
1050
1056
1057
1063
1064
1070
1071
1073{
1074 int row = aEvent.GetRow();
1075
1076 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) )
1077 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
1078
1079 // These are just to get the cells refreshed
1080 m_dataModel->SetValue( row, COL_TYPE, m_dataModel->GetValue( row, COL_TYPE ) );
1081 m_dataModel->SetValue( row, COL_SHAPE, m_dataModel->GetValue( row, COL_SHAPE ) );
1082
1083 OnModify();
1084}
1085
1086
1088{
1089 int sortCol = aEvent.GetCol();
1090 bool ascending;
1091
1092 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
1093 // event, and if we ask it will give us pre-event info.
1094 if( m_pinGrid->IsSortingBy( sortCol ) )
1095 // same column; invert ascending
1096 ascending = !m_pinGrid->IsSortOrderAscending();
1097 else
1098 // different column; start with ascending
1099 ascending = true;
1100
1101 m_dataModel->SortRows( sortCol, ascending );
1102 m_dataModel->BuildAttrs();
1103}
1104
1105
1107{
1108 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1109
1110 // Account for scroll bars
1111 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1112
1113 // Stretch the Base Name and Alternate Assignment columns to fit.
1114 for( int i = 0; i < COL_COUNT; ++i )
1115 {
1116 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1117 pinTblWidth -= m_pinGrid->GetColSize( i );
1118 }
1119
1120 if( pinTblWidth > 2 )
1121 {
1122 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1123 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1124 }
1125}
1126
1127
1128void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1129{
1130 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1131
1132 if( shownColumns != m_shownColumns )
1133 {
1134 m_shownColumns = shownColumns;
1135
1136 if( !m_fieldsGrid->IsCellEditControlShown() )
1137 m_fieldsGrid->SetGridWidthsDirty();
1138 }
1139}
1140
1141
1143{
1144 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1145
1146 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1147
1148 // Handle a delayed focus
1149
1150 m_fieldsGrid->SetFocus();
1151 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1152 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1153
1154 m_fieldsGrid->EnableCellEditControl( true );
1155 m_fieldsGrid->ShowCellEditControl();
1156
1157 delete loc;
1158}
1159
1160
1162{
1163 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1164
1165 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1166
1167 // Handle a delayed selection
1168 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( loc->x, loc->y );
1169
1170 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1172
1173 cellEditor->DecRef(); // we're done; must release
1174 delete loc;
1175}
1176
1177
1179{
1180 wxSize new_size = event.GetSize();
1181
1182 if( ( !m_editorShown || m_lastRequestedPinsSize != new_size ) && m_pinsSize != new_size )
1183 {
1184 m_pinsSize = new_size;
1185
1187 }
1188
1189 // We store this value to check whether the dialog is changing size. This might indicate
1190 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1191 // close (at least on GTK) when the user drags a dialog corner
1192 m_lastRequestedPinsSize = new_size;
1193
1194 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1195 event.Skip();
1196}
1197
1198
1199void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1200{
1202
1203 // Now all widgets have the size fixed, call FinishDialogSettings
1205}
1206
1207
1208void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1209{
1210 OnModify();
1211}
1212
1213
1214void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1215{
1216 if( m_dataModel )
1217 {
1218 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1219
1220 int unit_selection = m_unitChoice->GetSelection() + 1;
1221
1222 // We need to select a new unit to build the new unit pin list
1223 // but we should not change the symbol, so the initial unit will be selected
1224 // after rebuilding the pin list
1225 int old_unit = m_symbol->GetUnit();
1226 m_symbol->SetUnit( unit_selection );
1227
1228 // Rebuild a copy of the pins of the new unit for editing
1229 m_dataModel->clear();
1230
1231 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1232 m_dataModel->push_back( *pin );
1233
1234 m_dataModel->SortRows( COL_NUMBER, true );
1235 m_dataModel->BuildAttrs();
1236
1237 m_symbol->SetUnit( old_unit );
1238
1239 // Restore m_Flag modified by SetUnit()
1240 m_symbol->ClearFlags();
1241 m_symbol->SetFlags( flags );
1242 }
1243
1244 OnModify();
1245}
1246
1247
1249{
1250 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1251}
1252
1253
1255{
1256 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1257}
1258
1259
1260void DIALOG_SYMBOL_PROPERTIES::OnPageChanging( wxBookCtrlEvent& aEvent )
1261{
1262 if( !m_fieldsGrid->CommitPendingChanges() )
1263 aEvent.Veto();
1264
1265 if( !m_pinGrid->CommitPendingChanges() )
1266 aEvent.Veto();
1267}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
bool Empty() const
Definition commit.h:137
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:106
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void EndQuasiModal(int retCode)
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
EDA_BASE_FRAME * m_parentFrame
int ShowModal() override
DIALOG_SYMBOL_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Symbol Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU)
void OnSizePinsGrid(wxSizeEvent &event) override
void OnPinTableCellEdited(wxGridEvent &event) override
void OnGridEditorShown(wxGridEvent &event) override
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnEditSymbol(wxCommandEvent &) override
void OnCancelButtonClick(wxCommandEvent &event) override
virtual void onUpdateEditLibrarySymbol(wxUpdateUIEvent &event) override
SCH_PIN_TABLE_DATA_MODEL * m_dataModel
void OnMoveDown(wxCommandEvent &event) override
void OnPinTableColSort(wxGridEvent &aEvent)
void OnMoveUp(wxCommandEvent &event) override
void OnDeleteField(wxCommandEvent &event) override
void OnInitDlg(wxInitDialogEvent &event) override
void OnAddField(wxCommandEvent &event) override
void OnGridEditorHidden(wxGridEvent &event) override
PANEL_EMBEDDED_FILES * m_embeddedFiles
void OnUnitChoice(wxCommandEvent &event) override
void OnEditSpiceModel(wxCommandEvent &event) override
void OnPageChanging(wxNotebookEvent &event) override
DIALOG_SYMBOL_PROPERTIES(SCH_EDIT_FRAME *aParent, SCH_SYMBOL *aSymbol)
void HandleDelayedFocus(wxCommandEvent &event)
void HandleDelayedSelection(wxCommandEvent &event)
void OnCheckBox(wxCommandEvent &event) override
void OnGridCellChanging(wxGridEvent &event)
void OnEditLibrarySymbol(wxCommandEvent &) override
void OnUpdateSymbol(wxCommandEvent &) override
void OnExchangeSymbol(wxCommandEvent &) override
virtual void onUpdateEditSymbol(wxUpdateUIEvent &event) override
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.h:113
void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:603
virtual void SetVisible(bool aVisible)
Definition eda_text.cpp:395
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:308
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition grid_tricks.h:61
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:49
static int Compare(const wxString &lhs, const wxString &rhs)
Holds all the data relating to one schematic.
Definition schematic.h:88
SCHEMATIC_SETTINGS & Settings() const
wxString ConvertKIIDsToRefs(const wxString &aSource) const
wxString GetCurrentVariant() const
Return the current variant being edited.
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:187
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCHEMATIC & Schematic() const
void SetOrdinal(int aOrdinal)
Definition sch_field.h:128
bool IsMandatory() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:118
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
void SetText(const wxString &aText) override
bool IsEmptyCell(int row, int col) override
wxString GetValue(int aRow, int aCol) override
std::vector< wxGridCellAttr * > m_nameAttrs
static bool compare(const SCH_PIN &lhs, const SCH_PIN &rhs, int sortCol, bool ascending)
void SortRows(int aSortCol, bool ascending)
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
static wxString GetValue(const SCH_PIN &aPin, int aCol)
wxString GetColLabelValue(int aCol) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
void SetAlt(const wxString &aAlt)
Set the name of the alternate pin.
Definition sch_pin.cpp:433
const std::map< wxString, ALT > & GetAlternates() const
Definition sch_pin.h:160
ALT GetAlt(const wxString &aAlt)
Definition sch_pin.h:174
SCH_PIN * GetLibPin() const
Definition sch_pin.h:89
const wxString & GetName() const
Definition sch_pin.cpp:401
const wxString & GetBaseName() const
Get the name without any alternates.
Definition sch_pin.cpp:410
const wxString & GetNumber() const
Definition sch_pin.h:124
GRAPHIC_PINSHAPE GetShape() const
Definition sch_pin.cpp:278
ELECTRICAL_PINTYPE GetType() const
Definition sch_pin.cpp:313
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:76
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition wx_grid.cpp:46
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:202
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition confirm.cpp:177
This file is part of the common library.
static void EnableFocusDebugging(wxWindow *aWindow, const wxString &aWindowName=wxEmptyString)
Debug helper to trap all SetFocus events on a window and its children.
wxDEFINE_EVENT(SYMBOL_DELAY_FOCUS, wxCommandEvent)
@ SYMBOL_PROPS_EDIT_SCHEMATIC_SYMBOL
@ SYMBOL_PROPS_WANT_EXCHANGE_SYMBOL
@ SYMBOL_PROPS_WANT_UPDATE_SYMBOL
@ SYMBOL_PROPS_EDIT_LIBRARY_SYMBOL
#define _(s)
std::uint32_t EDA_ITEM_FLAGS
@ FDC_NAME
@ FDC_VALUE
wxColour GetDialogBGColour()
Definition wxgtk/ui.cpp:61
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition wxgtk/ui.cpp:264
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
const std::vector< BITMAPS > & PinTypeIcons()
Definition pin_type.cpp:162
const wxArrayString & PinTypeNames()
Definition pin_type.cpp:153
const wxArrayString & PinShapeNames()
Definition pin_type.cpp:171
const std::vector< BITMAPS > & PinShapeIcons()
Definition pin_type.cpp:180
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
Hold a name of a symbol's field, field value, and default visibility.
@ SYM_ORIENT_270
Definition symbol.h:42
@ SYM_MIRROR_Y
Definition symbol.h:44
@ SYM_ORIENT_180
Definition symbol.h:41
@ SYM_MIRROR_X
Definition symbol.h:43
@ SYM_ORIENT_90
Definition symbol.h:40
@ SYM_ORIENT_0
Definition symbol.h:39
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE
@ USER
The field ID hasn't been set yet; field is invalid.
@ REFERENCE
Field Reference of part, i.e. "IC21".
KIBIS_PIN * pin
VECTOR3I res
VECTOR2I end
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695