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 <grid_tricks.h>
31#include <confirm.h>
32#include <kiface_base.h>
33#include <pin_numbers.h>
34#include <string_utils.h>
35#include <kiplatform/ui.h>
40#include <sch_collectors.h>
41#include <symbol_library.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>
51
52
53wxDEFINE_EVENT( SYMBOL_DELAY_FOCUS, wxCommandEvent );
54wxDEFINE_EVENT( SYMBOL_DELAY_SELECTION, wxCommandEvent );
55
57{
63
64 COL_COUNT // keep as last
65};
66
67
68class SCH_PIN_TABLE_DATA_MODEL : public WX_GRID_TABLE_BASE, public std::vector<SCH_PIN>
69{
70public:
72 m_readOnlyAttr( nullptr ),
73 m_typeAttr( nullptr ),
74 m_shapeAttr( nullptr )
75 {
76 }
77
79 {
80 for( wxGridCellAttr* attr : m_nameAttrs )
81 attr->DecRef();
82
83 m_readOnlyAttr->DecRef();
84 m_typeAttr->DecRef();
85 m_shapeAttr->DecRef();
86 }
87
89 {
90 for( wxGridCellAttr* attr : m_nameAttrs )
91 attr->DecRef();
92
93 m_nameAttrs.clear();
94
95 if( m_readOnlyAttr )
96 m_readOnlyAttr->DecRef();
97
98 m_readOnlyAttr = new wxGridCellAttr;
99 m_readOnlyAttr->SetReadOnly( true );
100
101 for( const SCH_PIN& pin : *this )
102 {
103 SCH_PIN* lib_pin = pin.GetLibPin();
104 wxGridCellAttr* attr = nullptr;
105
106 if( lib_pin->GetAlternates().empty() )
107 {
108 attr = new wxGridCellAttr;
109 attr->SetReadOnly( true );
110 attr->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
111 }
112 else
113 {
114 wxArrayString choices;
115 choices.push_back( lib_pin->GetName() );
116
117 for( const std::pair<const wxString, SCH_PIN::ALT>& alt : lib_pin->GetAlternates() )
118 choices.push_back( alt.first );
119
120 attr = new wxGridCellAttr();
121 attr->SetEditor( new GRID_CELL_COMBOBOX( choices ) );
122 }
123
124 m_nameAttrs.push_back( attr );
125 }
126
127 if( m_typeAttr )
128 m_typeAttr->DecRef();
129
130 m_typeAttr = new wxGridCellAttr;
132 m_typeAttr->SetReadOnly( true );
133
134 if( m_shapeAttr )
135 m_shapeAttr->DecRef();
136
137 m_shapeAttr = new wxGridCellAttr;
139 m_shapeAttr->SetReadOnly( true );
140 }
141
142 int GetNumberRows() override { return (int) size(); }
143 int GetNumberCols() override { return COL_COUNT; }
144
145 wxString GetColLabelValue( int aCol ) override
146 {
147 switch( aCol )
148 {
149 case COL_NUMBER: return _( "Number" );
150 case COL_BASE_NAME: return _( "Base Name" );
151 case COL_ALT_NAME: return _( "Alternate Assignment" );
152 case COL_TYPE: return _( "Electrical Type" );
153 case COL_SHAPE: return _( "Graphic Style" );
154 default: wxFAIL; return wxEmptyString;
155 }
156 }
157
158 bool IsEmptyCell( int row, int col ) override
159 {
160 return false; // don't allow adjacent cell overflow, even if we are actually empty
161 }
162
163 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
164 {
165 // Don't accept random values; must use the popup to change to a known alternate
166 return false;
167 }
168
169 wxString GetValue( int aRow, int aCol ) override
170 {
171 return GetValue( at( aRow ), aCol );
172 }
173
174 static wxString GetValue( const SCH_PIN& aPin, int aCol )
175 {
176 if( aCol == COL_ALT_NAME )
177 {
178 if( aPin.GetLibPin()->GetAlternates().empty() )
179 return wxEmptyString;
180 else if( aPin.GetAlt().IsEmpty() )
181 return aPin.GetName();
182 else
183 return aPin.GetAlt();
184 }
185
186 switch( aCol )
187 {
188 case COL_NUMBER: return aPin.GetNumber();
189 case COL_BASE_NAME: return aPin.GetLibPin()->GetName();
190 case COL_TYPE: return PinTypeNames()[static_cast<int>( aPin.GetType() )];
191 case COL_SHAPE: return PinShapeNames()[static_cast<int>( aPin.GetShape() )];
192 default: wxFAIL; return wxEmptyString;
193 }
194 }
195
196 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override
197 {
198 switch( aCol )
199 {
200 case COL_NUMBER:
201 case COL_BASE_NAME:
202 m_readOnlyAttr->IncRef();
203 return enhanceAttr( m_readOnlyAttr, aRow, aCol, aKind );
204
205 case COL_ALT_NAME:
206 m_nameAttrs[ aRow ]->IncRef();
207 return enhanceAttr( m_nameAttrs[ aRow ], aRow, aCol, aKind );
208
209 case COL_TYPE:
210 m_typeAttr->IncRef();
211 return enhanceAttr( m_typeAttr, aRow, aCol, aKind );
212
213 case COL_SHAPE:
214 m_shapeAttr->IncRef();
215 return enhanceAttr( m_shapeAttr, aRow, aCol, aKind );
216
217 default:
218 wxFAIL;
219 return nullptr;
220 }
221 }
222
223 void SetValue( int aRow, int aCol, const wxString &aValue ) override
224 {
225 switch( aCol )
226 {
227 case COL_ALT_NAME:
228 if( aValue == at( aRow ).GetLibPin()->GetName() )
229 at( aRow ).SetAlt( wxEmptyString );
230 else
231 at( aRow ).SetAlt( aValue );
232 break;
233
234 case COL_NUMBER:
235 case COL_BASE_NAME:
236 case COL_TYPE:
237 case COL_SHAPE:
238 // Read-only.
239 break;
240
241 default:
242 wxFAIL;
243 break;
244 }
245 }
246
247 static bool compare( const SCH_PIN& lhs, const SCH_PIN& rhs, int sortCol, bool ascending )
248 {
249 wxString lhStr = GetValue( lhs, sortCol );
250 wxString rhStr = GetValue( rhs, sortCol );
251
252 if( lhStr == rhStr )
253 {
254 // Secondary sort key is always COL_NUMBER
255 sortCol = COL_NUMBER;
256 lhStr = GetValue( lhs, sortCol );
257 rhStr = GetValue( rhs, sortCol );
258 }
259
260 bool res;
261
262 // N.B. To meet the iterator sort conditions, we cannot simply invert the truth
263 // to get the opposite sort. i.e. ~(a<b) != (a>b)
264 auto cmp = [ ascending ]( const auto a, const auto b )
265 {
266 if( ascending )
267 return a < b;
268 else
269 return b < a;
270 };
271
272 switch( sortCol )
273 {
274 case COL_NUMBER:
275 case COL_BASE_NAME:
276 case COL_ALT_NAME:
277 res = cmp( PIN_NUMBERS::Compare( lhStr, rhStr ), 0 );
278 break;
279 case COL_TYPE:
280 case COL_SHAPE:
281 res = cmp( lhStr.CmpNoCase( rhStr ), 0 );
282 break;
283 default:
284 res = cmp( StrNumCmp( lhStr, rhStr ), 0 );
285 break;
286 }
287
288 return res;
289 }
290
291 void SortRows( int aSortCol, bool ascending )
292 {
293 std::sort( begin(), end(),
294 [ aSortCol, ascending ]( const SCH_PIN& lhs, const SCH_PIN& rhs ) -> bool
295 {
296 return compare( lhs, rhs, aSortCol, ascending );
297 } );
298 }
299
300protected:
301 std::vector<wxGridCellAttr*> m_nameAttrs;
302 wxGridCellAttr* m_readOnlyAttr;
303 wxGridCellAttr* m_typeAttr;
304 wxGridCellAttr* m_shapeAttr;
305};
306
307
310 m_symbol( nullptr ),
311 m_part( nullptr ),
312 m_fieldsSize( 0, 0 ),
313 m_lastRequestedFieldsSize( 0, 0 ),
314 m_lastRequestedPinsSize( 0, 0 ),
315 m_editorShown( false ),
316 m_fields( nullptr ),
317 m_dataModel( nullptr )
318{
319 m_symbol = aSymbol;
321
322 // GetLibSymbolRef() now points to the cached part in the schematic, which should always be
323 // there for usual cases, but can be null when opening old schematics not storing the part
324 // so we need to handle m_part == nullptr
325 // wxASSERT( m_part );
326
327 m_fields = new FIELDS_GRID_TABLE( this, aParent, m_fieldsGrid, m_symbol );
328
330 m_fieldsGrid->PushEventHandler( new FIELDS_GRID_TRICKS( m_fieldsGrid, this,
331 { &aParent->Schematic(), m_part },
332 [&]( wxCommandEvent& aEvent )
333 {
334 OnAddField( aEvent );
335 } ) );
336 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
337
338 // Show/hide columns according to user's preference
339 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
340 {
341 m_fieldsGrid->ShowHideColumns( cfg->m_Appearance.edit_symbol_visible_columns );
343 }
344
346 {
347 // DeMorgan conversions are a subclass of alternate pin assignments, so don't allow
348 // free-form alternate assignments as well. (We won't know how to map the alternates
349 // back and forth when the conversion is changed.)
350 m_pinTablePage->Disable();
351 m_pinTablePage->SetToolTip( _( "Alternate pin assignments are not available for De Morgan symbols." ) );
352 }
353 else
354 {
356
357 // Make a copy of the pins for editing
358 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
359 m_dataModel->push_back( *pin );
360
363
365 }
366
367 if( m_part && m_part->IsPower() )
368 m_spiceFieldsButton->Hide();
369
370 m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) );
371 m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
372
373 wxFont infoFont = KIUI::GetSmallInfoFont( this );
374 m_libraryIDLabel->SetFont( infoFont );
375 m_tcLibraryID->SetFont( infoFont );
376 m_tcLibraryID->SetBackgroundColour( KIPLATFORM::UI::GetDialogBGColour() );
377
378 wxToolTip::Enable( true );
380
381 // Configure button logos
382 m_bpAdd->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
383 m_bpDelete->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
384 m_bpMoveUp->SetBitmap( KiBitmapBundle( BITMAPS::small_up ) );
385 m_bpMoveDown->SetBitmap( KiBitmapBundle( BITMAPS::small_down ) );
386
387 // wxFormBuilder doesn't include this event...
388 m_fieldsGrid->Bind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
389 m_pinGrid->Bind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
390 Bind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
391 Bind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
392
393 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
394 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
395 QueueEvent( evt );
396 evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
397 evt->SetClientData( new VECTOR2I( 0, FDC_VALUE ) );
398 QueueEvent( evt );
399
401}
402
403
405{
406 if( EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() ) )
407 {
408 cfg->m_Appearance.edit_symbol_visible_columns = m_fieldsGrid->GetShownColumnsAsString();
409 cfg->m_Appearance.edit_symbol_width = GetSize().x;
410 cfg->m_Appearance.edit_symbol_height = GetSize().y;
411 }
412
413 // Prevents crash bug in wxGrid's d'tor
415
416 if( m_dataModel )
418
419 m_fieldsGrid->Unbind( wxEVT_GRID_CELL_CHANGING, &DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging, this );
420 m_pinGrid->Unbind( wxEVT_GRID_COL_SORT, &DIALOG_SYMBOL_PROPERTIES::OnPinTableColSort, this );
421 Unbind( SYMBOL_DELAY_FOCUS, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedFocus, this );
422 Unbind( SYMBOL_DELAY_SELECTION, &DIALOG_SYMBOL_PROPERTIES::HandleDelayedSelection, this );
423
424 // Delete the GRID_TRICKS.
425 m_fieldsGrid->PopEventHandler( true );
426 m_pinGrid->PopEventHandler( true );
427}
428
429
431{
432 return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
433}
434
435
437{
438 if( !wxDialog::TransferDataToWindow() )
439 return false;
440
441 std::set<wxString> defined;
442
443 // Push a copy of each field into m_updateFields
444 for( SCH_FIELD& srcField : m_symbol->GetFields() )
445 {
446 SCH_FIELD field( srcField );
447
448 // change offset to be symbol-relative
449 field.Offset( -m_symbol->GetPosition() );
450
451 field.SetText( m_symbol->Schematic()->ConvertKIIDsToRefs( field.GetText() ) );
452
453 defined.insert( field.GetName() );
454 m_fields->push_back( field );
455 }
456
457 // Add in any template fieldnames not yet defined:
458 for( const TEMPLATE_FIELDNAME& templateFieldname :
459 GetParent()->Schematic().Settings().m_TemplateFieldNames.GetTemplateFieldNames() )
460 {
461 if( defined.count( templateFieldname.m_Name ) <= 0 )
462 {
463 SCH_FIELD field( m_symbol, FIELD_T::USER, templateFieldname.m_Name );
464 field.SetVisible( templateFieldname.m_Visible );
465 m_fields->push_back( field );
466 }
467 }
468
469 // notify the grid
470 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->GetNumberRows() );
471 m_fieldsGrid->ProcessTableMessage( msg );
473
474 // If a multi-unit symbol, set up the unit selector and interchangeable checkbox.
475 if( m_symbol->GetUnitCount() > 1 )
476 {
477 // Ensure symbol unit is the currently selected unit (mandatory in complex hierarchies)
478 // from the current sheet path, because it can be modified by previous calculations
479 m_symbol->SetUnit( m_symbol->GetUnitSelection( &GetParent()->GetCurrentSheet() ) );
480
481 for( int ii = 1; ii <= m_symbol->GetUnitCount(); ii++ )
482 m_unitChoice->Append( m_symbol->GetUnitDisplayName( ii, false ) );
483
484 if( m_symbol->GetUnit() <= ( int )m_unitChoice->GetCount() )
485 m_unitChoice->SetSelection( m_symbol->GetUnit() - 1 );
486 }
487 else
488 {
489 m_unitLabel->Enable( false );
490 m_unitChoice->Enable( false );
491 }
492
494 {
495 if( m_symbol->GetBodyStyle() > BODY_STYLE::BASE )
496 m_cbAlternateSymbol->SetValue( true );
497 }
498 else
499 {
500 m_cbAlternateSymbol->Enable( false );
501 }
502
503 // Set the symbol orientation and mirroring.
504 int orientation = m_symbol->GetOrientation() & ~( SYM_MIRROR_X | SYM_MIRROR_Y );
505
506 switch( orientation )
507 {
508 default:
509 case SYM_ORIENT_0: m_orientationCtrl->SetSelection( 0 ); break;
510 case SYM_ORIENT_90: m_orientationCtrl->SetSelection( 1 ); break;
511 case SYM_ORIENT_270: m_orientationCtrl->SetSelection( 2 ); break;
512 case SYM_ORIENT_180: m_orientationCtrl->SetSelection( 3 ); break;
513 }
514
515 int mirror = m_symbol->GetOrientation() & ( SYM_MIRROR_X | SYM_MIRROR_Y );
516
517 switch( mirror )
518 {
519 default: m_mirrorCtrl->SetSelection( 0 ) ; break;
520 case SYM_MIRROR_X: m_mirrorCtrl->SetSelection( 1 ); break;
521 case SYM_MIRROR_Y: m_mirrorCtrl->SetSelection( 2 ); break;
522 }
523
527 m_cbDNP->SetValue( m_symbol->GetDNP() );
528
529 if( m_part )
530 {
533 }
534
535 // Set the symbol's library name.
537
538 Layout();
539 m_fieldsGrid->Layout();
540 wxSafeYield();
541
542 return true;
543}
544
545
547{
549 return;
550
551 m_fieldsGrid->ClearSelection();
552
553 std::vector<SCH_FIELD> fields;
554
555 for( const SCH_FIELD& field : *m_fields )
556 fields.emplace_back( field );
557
558 DIALOG_SIM_MODEL dialog( this, m_parentFrame, *m_symbol, fields );
559
560 if( dialog.ShowModal() != wxID_OK )
561 return;
562
563 // Add in any new fields
564 for( const SCH_FIELD& editedField : fields )
565 {
566 bool found = false;
567
568 for( SCH_FIELD& existingField : *m_fields )
569 {
570 if( existingField.GetName() == editedField.GetName() )
571 {
572 found = true;
573 existingField.SetText( editedField.GetText() );
574 break;
575 }
576 }
577
578 if( !found )
579 {
580 m_fields->emplace_back( editedField );
581 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
582 m_fieldsGrid->ProcessTableMessage( msg );
583 }
584 }
585
586 // Remove any deleted fields
587 for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
588 {
589 SCH_FIELD& existingField = m_fields->at( ii );
590 bool found = false;
591
592 for( SCH_FIELD& editedField : fields )
593 {
594 if( editedField.GetName() == existingField.GetName() )
595 {
596 found = true;
597 break;
598 }
599 }
600
601 if( !found )
602 {
603 m_fieldsGrid->ClearSelection();
604 m_fields->erase( m_fields->begin() + ii );
605
606 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
607 m_fieldsGrid->ProcessTableMessage( msg );
608 }
609 }
610
611 OnModify();
612 m_fieldsGrid->ForceRefresh();
613}
614
615
617{
618 // Running the Footprint Browser gums up the works and causes the automatic cancel
619 // stuff to no longer work. So we do it here ourselves.
620 EndQuasiModal( wxID_CANCEL );
621}
622
623
625{
626 LIB_ID id;
627
628 if( !m_fieldsGrid->CommitPendingChanges() || !m_fieldsGrid->Validate() )
629 return false;
630
631 // Check for missing field names.
632 for( size_t i = 0; i < m_fields->size(); ++i )
633 {
634 SCH_FIELD& field = m_fields->at( i );
635
636 if( field.IsMandatory() )
637 continue;
638
639 wxString fieldName = field.GetName( false );
640
641 if( fieldName.IsEmpty() )
642 {
643 DisplayErrorMessage( this, _( "Fields must have a name." ) );
644
645 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
646 evt->SetClientData( new VECTOR2I( i, FDC_VALUE ) );
647 QueueEvent( evt );
648
649 return false;
650 }
651 }
652
653 return true;
654}
655
656
658{
659 if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
660 return false;
661
663 return false;
664
666 return false;
667
668 SCH_COMMIT commit( GetParent() );
669 SCH_SCREEN* currentScreen = GetParent()->GetScreen();
670 bool replaceOnCurrentScreen;
671 wxCHECK( currentScreen, false );
672
673 // This needs to be done before the LIB_ID is changed to prevent stale library symbols in
674 // the schematic file.
675 replaceOnCurrentScreen = currentScreen->Remove( m_symbol );
676
677 // save old cmp in undo list if not already in edit, or moving ...
678 if( m_symbol->GetEditFlags() == 0 )
679 commit.Modify( m_symbol, currentScreen );
680
681 // Save current flags which could be modified by next change settings
683
684 // For symbols with multiple shapes (De Morgan representation) Set the selected shape:
685 if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
686 m_symbol->SetBodyStyle( BODY_STYLE::DEMORGAN );
687 else
688 m_symbol->SetBodyStyle( BODY_STYLE::BASE );
689
690 //Set the part selection in multiple part per package
691 int unit_selection = m_unitChoice->IsEnabled() ? m_unitChoice->GetSelection() + 1 : 1;
692 m_symbol->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
693 m_symbol->SetUnit( unit_selection );
694
695 switch( m_orientationCtrl->GetSelection() )
696 {
697 case 0: m_symbol->SetOrientation( SYM_ORIENT_0 ); break;
698 case 1: m_symbol->SetOrientation( SYM_ORIENT_90 ); break;
699 case 2: m_symbol->SetOrientation( SYM_ORIENT_270 ); break;
700 case 3: m_symbol->SetOrientation( SYM_ORIENT_180 ); break;
701 }
702
703 switch( m_mirrorCtrl->GetSelection() )
704 {
705 case 0: break;
706 case 1: m_symbol->SetOrientation( SYM_MIRROR_X ); break;
707 case 2: m_symbol->SetOrientation( SYM_MIRROR_Y ); break;
708 }
709
712
713 // Restore m_Flag modified by SetUnit() and other change settings from the dialog
715 m_symbol->SetFlags( flags );
716
717 // change all field positions from relative to absolute
718 for( SCH_FIELD& field : *m_fields )
719 {
720 field.Offset( m_symbol->GetPosition() );
721 field.SetText( m_symbol->Schematic()->ConvertRefsToKIIDs( field.GetText() ) );
722 }
723
724 SCH_FIELDS& fields = m_symbol->GetFields();
725 fields.clear();
726
727 for( SCH_FIELD& field : *m_fields )
728 {
729 const wxString& fieldName = field.GetCanonicalName();
730
731 if( fieldName.IsEmpty() && field.GetText().IsEmpty() )
732 continue;
733 else if( fieldName.IsEmpty() )
734 field.SetName( _( "untitled" ) );
735
736 fields.push_back( field );
737 }
738
739 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T ids.
740
741 for( SCH_FIELD& field : fields )
742 {
743 if( !field.IsMandatory() )
744 field.SetOrdinal( ordinal++ );
745 }
746
747 // Reference has a specific initialization, depending on the current active sheet
748 // because for a given symbol, in a complex hierarchy, there are more than one
749 // reference.
750 m_symbol->SetRef( &GetParent()->GetCurrentSheet(), m_fields->GetField( FIELD_T::REFERENCE )->GetText() );
751
752 // Similar for Value and Footprint, except that the GUI behavior is that they are kept
753 // in sync between multiple instances.
754 m_symbol->SetValueFieldText( m_fields->GetField( FIELD_T::VALUE )->GetText() );
755 m_symbol->SetFootprintFieldText( m_fields->GetField( FIELD_T::FOOTPRINT )->GetText() );
756
760 m_symbol->SetDNP( m_cbDNP->IsChecked() );
761
762 // Update any assignments
763 if( m_dataModel )
764 {
765 for( const SCH_PIN& model_pin : *m_dataModel )
766 {
767 // map from the edited copy back to the "real" pin in the symbol.
768 SCH_PIN* src_pin = m_symbol->GetPin( model_pin.GetNumber() );
769
770 if( src_pin )
771 src_pin->SetAlt( model_pin.GetAlt() );
772 }
773 }
774
775 // Keep fields other than the reference, include/exclude flags, and alternate pin assignements
776 // in sync in multi-unit parts.
777 m_symbol->SyncOtherUnits( GetParent()->GetCurrentSheet(), commit, nullptr );
778
779 if( replaceOnCurrentScreen )
780 currentScreen->Append( m_symbol );
781
782 if( !commit.Empty() )
783 commit.Push( _( "Edit Symbol Properties" ) );
784
785 return true;
786}
787
788
790{
791 wxGridCellEditor* editor = m_fieldsGrid->GetCellEditor( event.GetRow(), event.GetCol() );
792 wxControl* control = editor->GetControl();
793
794 if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
795 {
796 event.Veto();
797 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
798 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
799 QueueEvent( evt );
800 }
801 else if( event.GetCol() == FDC_NAME )
802 {
803 wxString newName = event.GetString();
804
805 for( int i = 0; i < m_fieldsGrid->GetNumberRows(); ++i )
806 {
807 if( i == event.GetRow() )
808 continue;
809
810 if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 )
811 {
812 DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ),
813 newName ) );
814 event.Veto();
815 wxCommandEvent *evt = new wxCommandEvent( SYMBOL_DELAY_FOCUS );
816 evt->SetClientData( new VECTOR2I( event.GetRow(), event.GetCol() ) );
817 QueueEvent( evt );
818 }
819 }
820 }
821
822 editor->DecRef();
823}
824
825
827{
828 if( m_fields->at( aEvent.GetRow() ).GetId() == FIELD_T::REFERENCE
829 && aEvent.GetCol() == FDC_VALUE )
830 {
831 wxCommandEvent* evt = new wxCommandEvent( SYMBOL_DELAY_SELECTION );
832 evt->SetClientData( new VECTOR2I( aEvent.GetRow(), aEvent.GetCol() ) );
833 QueueEvent( evt );
834 }
835
836 m_editorShown = true;
837}
838
839
841{
842 m_editorShown = false;
843}
844
845
846void DIALOG_SYMBOL_PROPERTIES::OnAddField( wxCommandEvent& event )
847{
849 [&]() -> std::pair<int, int>
850 {
851 SCH_FIELD newField( m_symbol, FIELD_T::USER, GetUserFieldName( m_fields->size(), DO_TRANSLATE ) );
852
853 newField.SetTextAngle( m_fields->GetField( FIELD_T::REFERENCE )->GetTextAngle() );
854 newField.SetVisible( false );
855
856 m_fields->push_back( newField );
857
858 // notify the grid
859 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
860 m_fieldsGrid->ProcessTableMessage( msg );
861 OnModify();
862
863 return { m_fields->size() - 1, FDC_NAME };
864 } );
865}
866
867
868void DIALOG_SYMBOL_PROPERTIES::OnDeleteField( wxCommandEvent& event )
869{
871 [&]( int row )
872 {
873 if( row < m_fields->GetMandatoryRowCount() )
874 {
875 DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
877 return false;
878 }
879
880 return true;
881 },
882 [&]( int row )
883 {
884 m_fields->erase( m_fields->begin() + row );
885
886 // notify the grid
887 wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, row, 1 );
888 m_fieldsGrid->ProcessTableMessage( msg );
889 } );
890
891 OnModify();
892}
893
894
895void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
896{
898 [&]( int row )
899 {
900 return row > m_fields->GetMandatoryRowCount();
901 },
902 [&]( int row )
903 {
904 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row - 1 ) );
905 m_fieldsGrid->ForceRefresh();
906 OnModify();
907 } );
908}
909
910
911void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
912{
914 [&]( int row )
915 {
916 return row >= m_fields->GetMandatoryRowCount();
917 },
918 [&]( int row )
919 {
920 std::swap( *( m_fields->begin() + row ), *( m_fields->begin() + row + 1 ) );
921 m_fieldsGrid->ForceRefresh();
922 OnModify();
923 } );
924}
925
926
928{
931}
932
933
935{
938}
939
940
942{
945}
946
947
949{
952}
953
954
956{
957 int row = aEvent.GetRow();
958
959 if( m_pinGrid->GetCellValue( row, COL_ALT_NAME ) == m_dataModel->GetValue( row, COL_BASE_NAME ) )
960 m_dataModel->SetValue( row, COL_ALT_NAME, wxEmptyString );
961
962 // These are just to get the cells refreshed
965
966 OnModify();
967}
968
969
971{
972 int sortCol = aEvent.GetCol();
973 bool ascending;
974
975 // This is bonkers, but wxWidgets doesn't tell us ascending/descending in the
976 // event, and if we ask it will give us pre-event info.
977 if( m_pinGrid->IsSortingBy( sortCol ) )
978 // same column; invert ascending
979 ascending = !m_pinGrid->IsSortOrderAscending();
980 else
981 // different column; start with ascending
982 ascending = true;
983
984 m_dataModel->SortRows( sortCol, ascending );
986}
987
988
990{
991 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_fieldsGrid );
992
993 // Account for scroll bars
994 int fieldsWidth = KIPLATFORM::UI::GetUnobscuredSize( m_fieldsGrid ).x;
995
996 m_fieldsGrid->AutoSizeColumn( 0 );
997 m_fieldsGrid->SetColSize( 0, std::max( 72, m_fieldsGrid->GetColSize( 0 ) ) );
998
999 int fixedColsWidth = m_fieldsGrid->GetColSize( 0 );
1000
1001 for( int i = 2; i < m_fieldsGrid->GetNumberCols(); i++ )
1002 fixedColsWidth += m_fieldsGrid->GetColSize( i );
1003
1004 m_fieldsGrid->SetColSize( 1, std::max( 120, fieldsWidth - fixedColsWidth ) );
1005}
1006
1007
1009{
1010 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinGrid );
1011
1012 // Account for scroll bars
1013 int pinTblWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinGrid ).x;
1014
1015 // Stretch the Base Name and Alternate Assignment columns to fit.
1016 for( int i = 0; i < COL_COUNT; ++i )
1017 {
1018 if( i != COL_BASE_NAME && i != COL_ALT_NAME )
1019 pinTblWidth -= m_pinGrid->GetColSize( i );
1020 }
1021
1022 if( pinTblWidth > 2 )
1023 {
1024 m_pinGrid->SetColSize( COL_BASE_NAME, pinTblWidth / 2 );
1025 m_pinGrid->SetColSize( COL_ALT_NAME, pinTblWidth / 2 );
1026 }
1027}
1028
1029
1030void DIALOG_SYMBOL_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
1031{
1032 std::bitset<64> shownColumns = m_fieldsGrid->GetShownColumns();
1033
1034 if( shownColumns != m_shownColumns )
1035 {
1036 m_shownColumns = shownColumns;
1037
1038 if( !m_fieldsGrid->IsCellEditControlShown() )
1040 }
1041}
1042
1043
1045{
1046 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1047
1048 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1049
1050 // Handle a delayed focus
1051
1052 m_fieldsGrid->SetFocus();
1053 m_fieldsGrid->MakeCellVisible( loc->x, loc->y );
1054 m_fieldsGrid->SetGridCursor( loc->x, loc->y );
1055
1056 m_fieldsGrid->EnableCellEditControl( true );
1057 m_fieldsGrid->ShowCellEditControl();
1058
1059 delete loc;
1060}
1061
1062
1064{
1065 VECTOR2I *loc = static_cast<VECTOR2I*>( event.GetClientData() );
1066
1067 wxCHECK_RET( loc, wxT( "Missing focus cell location" ) );
1068
1069 // Handle a delayed selection
1070 wxGridCellEditor* cellEditor = m_fieldsGrid->GetCellEditor( loc->x, loc->y );
1071
1072 if( wxTextEntry* txt = dynamic_cast<wxTextEntry*>( cellEditor->GetControl() ) )
1074
1075 cellEditor->DecRef(); // we're done; must release
1076}
1077
1079{
1080 wxSize new_size = event.GetSize();
1081
1082 if( ( !m_editorShown || m_lastRequestedFieldsSize != new_size ) && m_fieldsSize != new_size )
1083 {
1084 m_fieldsSize = new_size;
1085
1087 }
1088
1089 // We store this value to check whether the dialog is changing size. This might indicate
1090 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1091 // close (at least on GTK) when the user drags a dialog corner
1092 m_lastRequestedFieldsSize = new_size;
1093
1094 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1095 event.Skip();
1096}
1097
1098
1100{
1101 wxSize new_size = event.GetSize();
1102
1103 if( ( !m_editorShown || m_lastRequestedPinsSize != new_size ) && m_pinsSize != new_size )
1104 {
1105 m_pinsSize = new_size;
1106
1108 }
1109
1110 // We store this value to check whether the dialog is changing size. This might indicate
1111 // that the user is scaling the dialog with a grid-cell-editor shown. Some editors do not
1112 // close (at least on GTK) when the user drags a dialog corner
1113 m_lastRequestedPinsSize = new_size;
1114
1115 // Always propagate for a grid repaint (needed if the height changes, as well as width)
1116 event.Skip();
1117}
1118
1119
1120void DIALOG_SYMBOL_PROPERTIES::OnInitDlg( wxInitDialogEvent& event )
1121{
1123
1124 // Now all widgets have the size fixed, call FinishDialogSettings
1126
1127 EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
1128
1129 if( cfg && cfg->m_Appearance.edit_symbol_width > 0 && cfg->m_Appearance.edit_symbol_height > 0 )
1131}
1132
1133
1134void DIALOG_SYMBOL_PROPERTIES::OnCheckBox( wxCommandEvent& event )
1135{
1136 OnModify();
1137}
1138
1139
1140void DIALOG_SYMBOL_PROPERTIES::OnUnitChoice( wxCommandEvent& event )
1141{
1142 if( m_dataModel )
1143 {
1144 EDA_ITEM_FLAGS flags = m_symbol->GetFlags();
1145
1146 int unit_selection = m_unitChoice->GetSelection() + 1;
1147
1148 // We need to select a new unit to build the new unit pin list
1149 // but we should not change the symbol, so the initial unit will be selected
1150 // after rebuilding the pin list
1151 int old_unit = m_symbol->GetUnit();
1152 m_symbol->SetUnit( unit_selection );
1153
1154 // Rebuild a copy of the pins of the new unit for editing
1155 m_dataModel->clear();
1156
1157 for( const std::unique_ptr<SCH_PIN>& pin : m_symbol->GetRawPins() )
1158 m_dataModel->push_back( *pin );
1159
1162
1163 m_symbol->SetUnit( old_unit );
1164
1165 // Restore m_Flag modified by SetUnit()
1167 m_symbol->SetFlags( flags );
1168 }
1169
1170 OnModify();
1171}
1172
1173
1175{
1176 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1177}
1178
1179
1181{
1182 event.Enable( m_symbol && m_symbol->GetLibSymbolRef() );
1183}
1184
1185
1186void DIALOG_SYMBOL_PROPERTIES::OnPageChanging( wxBookCtrlEvent& aEvent )
1187{
1189 aEvent.Veto();
1190
1192 aEvent.Veto();
1193}
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
bool Empty() const
Definition: commit.h:152
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:107
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void EndQuasiModal(int retCode)
void OnModify()
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
Definition: dialog_shim.h:254
int ShowModal() override
Class DIALOG_SYMBOL_PROPERTIES_BASE.
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 OnSizeFieldsGrid(wxSizeEvent &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
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
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:148
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:144
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:145
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:596
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:386
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
SCH_FIELD * GetField(FIELD_T aFieldId)
int GetNumberRows() override
void push_back(const SCH_FIELD &field)
int GetMandatoryRowCount() const
void emplace_back(const SCH_FIELD &field)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
UTF8 Format() const
Definition: lib_id.cpp:119
bool IsPower() const override
Definition: lib_symbol.cpp:469
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
static int Compare(const wxString &lhs, const wxString &rhs)
wxString ConvertKIIDsToRefs(const wxString &aSource) const
Definition: schematic.cpp:625
wxString ConvertRefsToKIIDs(const wxString &aSource) const
Definition: schematic.cpp:555
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
Definition: sch_commit.cpp:489
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
bool IsMandatory() const
Definition: sch_field.cpp:1359
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1103
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1089
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
int GetBodyStyle() const
Definition: sch_item.h:248
int GetUnit() const
Definition: sch_item.h:239
virtual void SetUnit(int aUnit)
Definition: sch_item.h:238
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:389
const std::map< wxString, ALT > & GetAlternates() const
Definition: sch_pin.h:133
ALT GetAlt(const wxString &aAlt)
Definition: sch_pin.h:147
SCH_PIN * GetLibPin() const
Definition: sch_pin.h:88
const wxString & GetName() const
Definition: sch_pin.cpp:357
const wxString & GetNumber() const
Definition: sch_pin.h:123
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:234
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:269
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Definition: sch_screen.cpp:160
bool Remove(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:330
Schematic symbol object.
Definition: sch_symbol.h:75
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:444
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:633
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:738
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:413
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
Definition: sch_symbol.cpp:916
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:600
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
Definition: sch_symbol.cpp:788
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:754
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:767
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:164
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:686
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:435
int GetOrientation() const override
Get the display symbol orientation.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:702
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:183
void SetBitmap(const wxBitmapBundle &aBmp)
void SetExcludedFromBoard(bool aExcludeFromBoard) override
Set or clear exclude from board netlist flag.
Definition: symbol.h:186
void SetDNP(bool aDNP) override
Definition: symbol.h:193
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: symbol.h:170
bool GetExcludedFromBoard() const override
Definition: symbol.h:187
void SetExcludedFromBOM(bool aExcludeFromBOM) override
Set or clear the exclude from schematic bill of materials flag.
Definition: symbol.h:180
virtual bool GetShowPinNames() const
Definition: symbol.h:159
bool GetDNP() const override
Set or clear the 'Do Not Populate' flag.
Definition: symbol.h:192
virtual bool GetShowPinNumbers() const
Definition: symbol.h:165
bool GetExcludedFromBOM() const override
Definition: symbol.h:181
bool GetExcludedFromSim() const override
Definition: symbol.h:175
wxGridCellAttr * enhanceAttr(wxGridCellAttr *aInputAttr, int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind)
Definition: wx_grid.cpp:45
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:494
void OnMoveRowUp(const std::function< void(int row)> &aMover)
Definition: wx_grid.cpp:766
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:273
void DestroyTable(wxGridTableBase *aTable)
Work-around for a bug in wxGrid which crashes when deleting the table if the cell edit control was no...
Definition: wx_grid.cpp:450
void OnMoveRowDown(const std::function< void(int row)> &aMover)
Definition: wx_grid.cpp:799
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
Definition: wx_grid.cpp:704
wxString GetShownColumnsAsString()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:464
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
Definition: wx_grid.cpp:684
std::bitset< 64 > GetShownColumns()
Definition: wx_grid.cpp:483
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:632
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:169
This file is part of the common library.
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:258
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:162
KICOMMON_API void SelectReferenceNumber(wxTextEntry *aTextEntry)
Select the number (or "?") in a reference for ease of editing.
Definition: ui_common.cpp:236
const std::vector< BITMAPS > & PinTypeIcons()
Definition: pin_type.cpp:167
const wxArrayString & PinTypeNames()
Definition: pin_type.cpp:158
const wxArrayString & PinShapeNames()
Definition: pin_type.cpp:176
const std::vector< BITMAPS > & PinShapeIcons()
Definition: pin_type.cpp:185
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:63
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
Definition for symbol library class.
wxString GetUserFieldName(int aFieldNdx, bool aTranslateForHI)
#define DO_TRANSLATE
VECTOR3I res
VECTOR2I end
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695