KiCad PCB EDA Suite
dialog_sch_sheet_props.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) 2009 Wayne Stambaugh <stambaughw@gmail.com>
5  * Copyright (C) 2014-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU 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, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <dialog_sch_sheet_props.h>
26 #include <kiface_i.h>
27 #include <wx/string.h>
28 #include <wx/tooltip.h>
29 #include <confirm.h>
30 #include <validators.h>
32 #include <widgets/tab_traversal.h>
33 #include <sch_edit_frame.h>
34 #include <sch_sheet.h>
35 #include <bitmaps.h>
36 #include <eeschema_settings.h>
38 
39 
41  bool* aClearAnnotationNewItems ) :
42  DIALOG_SCH_SHEET_PROPS_BASE( aParent ),
43  m_frame( aParent ),
44  m_clearAnnotationNewItems( aClearAnnotationNewItems ),
45  m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true )
46 {
47  m_sheet = aSheet;
48  m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_sheet );
49 
50  m_width = 0;
53 
54  // Give a bit more room for combobox editors
55  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
56 
58  m_grid->PushEventHandler( new FIELDS_GRID_TRICKS( m_grid, this ) );
59 
60  // Show/hide columns according to user's preference
61  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
62  m_shownColumns = cfg->m_Appearance.edit_sheet_visible_columns;
64 
65  wxToolTip::Enable( true );
66  m_stdDialogButtonSizerOK->SetDefault();
67 
68  // Configure button logos
69  m_bpAdd->SetBitmap( KiBitmap( small_plus_xpm ) );
70  m_bpDelete->SetBitmap( KiBitmap( trash_xpm ) );
71  m_bpMoveUp->SetBitmap( KiBitmap( small_up_xpm ) );
72  m_bpMoveDown->SetBitmap( KiBitmap( small_down_xpm ) );
73 
74  // Set font sizes
75  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
76  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
77  m_hiearchicalPathLabel->SetFont( infoFont );
78  m_heirarchyPath->SetFont( infoFont );
79  m_heirarchyPath->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
80  m_timestampLabel->SetFont( infoFont );
81  m_textCtrlTimeStamp->SetFont( infoFont );
82  m_textCtrlTimeStamp->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_MENU ) );
83 
84  // wxFormBuilder doesn't include this event...
85  m_grid->Connect( wxEVT_GRID_CELL_CHANGING,
86  wxGridEventHandler( DIALOG_SCH_SHEET_PROPS::OnGridCellChanging ),
87  NULL, this );
88 
90 }
91 
92 
94 {
95  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
96  cfg->m_Appearance.edit_sheet_visible_columns = m_grid->GetShownColumns();
97 
98  // Prevents crash bug in wxGrid's d'tor
100 
101  m_grid->Disconnect( wxEVT_GRID_CELL_CHANGING,
102  wxGridEventHandler( DIALOG_SCH_SHEET_PROPS::OnGridCellChanging ),
103  NULL, this );
104 
105  // Delete the GRID_TRICKS.
106  m_grid->PopEventHandler( true );
107 }
108 
109 
111 {
112  if( !wxDialog::TransferDataToWindow() )
113  return false;
114 
115  // Push a copy of each field into m_fields
116  for( SCH_FIELD& field : m_sheet->GetFields() )
117  {
118  SCH_FIELD field_copy( field );
119 
120 #ifdef __WINDOWS__
121  // Filenames are stored using unix notation
122  if( field_copy.GetId() == SHEETFILENAME )
123  {
124  wxString filename = field_copy.GetText();
125  filename.Replace( wxT("/"), wxT("\\") );
126  field_copy.SetText( filename );
127  }
128 #endif
129 
130  // change offset to be symbol-relative
131  field_copy.Offset( -m_sheet->GetPosition() );
132 
133  m_fields->push_back( field_copy );
134  }
135 
136  // notify the grid
137  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );
138  m_grid->ProcessTableMessage( msg );
139  AdjustGridColumns( m_grid->GetRect().GetWidth() );
140 
141  // border width
143 
144  // set up color swatches
145  COLOR_SETTINGS* colorSettings = m_frame->GetColorSettings();
146  KIGFX::COLOR4D borderColor = m_sheet->GetBorderColor();
147  KIGFX::COLOR4D backgroundColor = m_sheet->GetBackgroundColor();
148 
149  if( borderColor == COLOR4D::UNSPECIFIED )
150  borderColor = colorSettings->GetColor( LAYER_SHEET );
151 
152  if( backgroundColor == COLOR4D::UNSPECIFIED )
153  backgroundColor = colorSettings->GetColor( LAYER_SHEET_BACKGROUND );
154 
155  m_borderColorSwatch->SetSwatchColor( borderColor, false );
156  m_backgroundColorSwatch->SetSwatchColor( backgroundColor, false );
157 
161 
162  // set up the read-only fields
164  m_textCtrlTimeStamp->SetValue( m_sheet->m_Uuid.AsString() );
165 
166  Layout();
167 
168  return true;
169 }
170 
171 
173 {
174  wxString msg;
175  LIB_ID id;
176 
177  if( !m_grid->CommitPendingChanges() || !m_grid->Validate() )
178  return false;
179 
180  // Check for missing field names.
181  for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields->size(); ++i )
182  {
183  SCH_FIELD& field = m_fields->at( i );
184  wxString fieldName = field.GetName( false );
185 
186  if( fieldName.IsEmpty() )
187  {
188  DisplayErrorMessage( this, _( "Fields must have a name." ) );
189 
191  m_delayedFocusRow = i;
192 
193  return false;
194  }
195  }
196 
197  return true;
198 }
199 
200 
201 static bool positioningChanged( const SCH_FIELD& a, const SCH_FIELD& b )
202 {
203  if( a.GetPosition() != b.GetPosition() )
204  return true;
205 
206  if( a.GetHorizJustify() != b.GetHorizJustify() )
207  return true;
208 
209  if( a.GetVertJustify() != b.GetVertJustify() )
210  return true;
211 
212  if( a.GetTextAngle() != b.GetTextAngle() )
213  return true;
214 
215  return false;
216 }
217 
218 
219 static bool positioningChanged( FIELDS_GRID_TABLE<SCH_FIELD>* a, std::vector<SCH_FIELD>& b )
220 {
221  for( size_t i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
222  {
223  if( positioningChanged( a->at( i ), b.at( i ) ) )
224  return true;
225  }
226 
227  return false;
228 }
229 
230 
232 {
233  if( !wxDialog::TransferDataFromWindow() ) // Calls our Validate() method.
234  return false;
235 
236  wxString newRelativeNativeFilename = m_fields->at( SHEETFILENAME ).GetText();
237  wxString newRelativeFilename = newRelativeNativeFilename;
238 
239  // Inside Eeschema, filenames are stored using unix notation
240  newRelativeFilename.Replace( wxT( "\\" ), wxT( "/" ) );
241 
242  wxString newSheetname = m_fields->at( SHEETNAME ).GetText();
243 
244  if( newSheetname.IsEmpty() )
245  newSheetname = _( "Untitled Sheet" );
246 
247  // Relative file names are relative to the path of the current sheet. This allows for
248  // nesting of schematic files in subfolders.
249  wxFileName fileName( newRelativeNativeFilename );
250  fileName.SetExt( LegacySchematicFileExtension );
251 
252  if( !fileName.IsAbsolute() )
253  {
254  const SCH_SCREEN* currentScreen = g_CurrentSheet->LastScreen();
255 
256  wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
257 
258  wxFileName currentSheetFileName = currentScreen->GetFileName();
259 
260  wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
261  "Cannot normalize new sheet schematic file path." );
262  }
263 
264  wxString newAbsoluteFilename = fileName.GetFullPath();
265 
266  // Inside Eeschema, filenames are stored using unix notation
267  newAbsoluteFilename.Replace( wxT( "\\" ), wxT( "/" ) );
268 
269  wxString msg;
270  bool renameFile = false;
271  bool loadFromFile = false;
272  bool clearAnnotation = false;
273  bool restoreSheet = false;
274  bool isExistingSheet = false;
275  SCH_SCREEN* useScreen = NULL;
276 
277  // Search for a schematic file having the same filename already in use in the hierarchy
278  // or on disk, in order to reuse it.
279  if( !g_RootSheet->SearchHierarchy( newAbsoluteFilename, &useScreen ) )
280  {
281  loadFromFile = wxFileExists( newAbsoluteFilename );
282  wxLogDebug( "Sheet requested file \"%s\", %s",
283  newAbsoluteFilename,
284  ( loadFromFile ) ? "found" : "not found" );
285  }
286 
287  if( m_sheet->GetScreen() == NULL ) // New sheet.
288  {
289  if( !m_frame->AllowCaseSensitiveFileNameClashes( newAbsoluteFilename ) )
290  return false;
291 
292  if( useScreen || loadFromFile ) // Load from existing file.
293  {
294  clearAnnotation = true;
295 
296  wxString existsMsg;
297  wxString linkMsg;
298  existsMsg.Printf( _( "\"%s\" already exists." ), fileName.GetFullName() );
299  linkMsg.Printf( _( "Link \"%s\" to this file?" ), newSheetname );
300  msg.Printf( wxT( "%s\n\n%s" ), existsMsg, linkMsg );
301 
302  if( !IsOK( this, msg ) )
303  return false;
304 
305  }
306  else // New file.
307  {
308  m_frame->InitSheet( m_sheet, newAbsoluteFilename );
309  }
310  }
311  else // Existing sheet.
312  {
313  bool isUndoable = true;
314  wxString replaceMsg;
315  wxString newMsg;
316  wxString noUndoMsg;
317 
318  isExistingSheet = true;
319 
320  if( !m_frame->AllowCaseSensitiveFileNameClashes( newAbsoluteFilename ) )
321  return false;
322 
323  // Changing the filename of a sheet can modify the full hierarchy structure
324  // and can be not always undoable.
325  // So prepare messages for user notifications:
326  replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ),
327  newSheetname,
328  m_sheet->GetFileName(),
329  fileName.GetFullName() );
330  newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ),
331  fileName.GetFullName(),
332  m_sheet->GetFileName() );
333  noUndoMsg = _( "This action cannot be undone." );
334 
335  // We are always using here a case insensitive comparison to avoid issues
336  // under Windows, although under Unix filenames are case sensitive.
337  // But many users create schematic under both Unix and Windows
338  // **
339  // N.B. 1: aSheet->GetFileName() will return a relative path
340  // aSheet->GetScreen()->GetFileName() returns a full path
341  //
342  // N.B. 2: newFilename uses the unix notation for separator.
343  // so we must use it also to compare the old and new filenames
344  wxString oldAbsoluteFilename = m_sheet->GetScreen()->GetFileName();
345  oldAbsoluteFilename.Replace( wxT( "\\" ), wxT( "/" ) );
346 
347  if( newAbsoluteFilename.Cmp( oldAbsoluteFilename ) != 0 )
348  {
349  // Sheet file name changes cannot be undone.
350  isUndoable = false;
351 
352  if( useScreen || loadFromFile ) // Load from existing file.
353  {
354  clearAnnotation = true;
355 
356  msg.Printf( wxT( "%s\n\n%s" ), replaceMsg, noUndoMsg );
357 
358  if( !IsOK( this, msg ) )
359  return false;
360 
361  if( loadFromFile )
362  m_sheet->SetScreen( NULL );
363  }
364  else // Save to new file name.
365  {
366  if( m_sheet->GetScreenCount() > 1 )
367  {
368  msg.Printf( wxT( "%s\n\n%s" ), newMsg, noUndoMsg );
369 
370  if( !IsOK( this, msg ) )
371  return false;
372  }
373 
374  renameFile = true;
375  }
376  }
377 
378  if( isUndoable )
380 
381  if( renameFile )
382  {
383  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
384 
385  // If the the associated screen is shared by more than one sheet, do not
386  // change the filename of the corresponding screen here.
387  // (a new screen will be created later)
388  // if it is not shared, update the filename
389  if( m_sheet->GetScreenCount() <= 1 )
390  m_sheet->GetScreen()->SetFileName( newAbsoluteFilename );
391 
392  try
393  {
394  pi->Save( newAbsoluteFilename, m_sheet->GetScreen(), &Kiway() );
395  }
396  catch( const IO_ERROR& ioe )
397  {
398  msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newAbsoluteFilename );
399  DisplayErrorMessage( this, msg, ioe.What() );
400 
401  msg.Printf( _( "Failed to save schematic \"%s\"" ), newAbsoluteFilename );
402  m_frame->AppendMsgPanel( wxEmptyString, msg, CYAN );
403 
404  return false;
405  }
406 
407  // If the the associated screen is shared by more than one sheet, remove the
408  // screen and reload the file to a new screen. Failure to do this will trash
409  // the screen reference counting in complex hierarchies.
410  if( m_sheet->GetScreenCount() > 1 )
411  {
412  m_sheet->SetScreen( NULL );
413  loadFromFile = true;
414  }
415  }
416  }
417 
418  wxFileName nativeFileName( newRelativeNativeFilename );
419  nativeFileName.SetExt( LegacySchematicFileExtension );
420 
421  if( useScreen )
422  {
423  // Create a temporary sheet for recursion testing to prevent a possible recursion error.
424  std::unique_ptr< SCH_SHEET> tmpSheet( new SCH_SHEET );
425  tmpSheet->GetFields()[SHEETNAME] = m_fields->at( SHEETNAME );
426  tmpSheet->GetFields()[SHEETFILENAME].SetText( nativeFileName.GetFullPath() );
427  tmpSheet->SetScreen( useScreen );
428 
429  // No need to check for valid library IDs if we are using an existing screen.
430  if( m_frame->CheckSheetForRecursion( tmpSheet.get(), g_CurrentSheet ) )
431  {
432  if( restoreSheet )
434 
435  return false;
436  }
437 
438  // It's safe to set the sheet screen now.
439  m_sheet->SetScreen( useScreen );
440  }
441  else if( loadFromFile )
442  {
443  if( isExistingSheet )
444  {
445  // Temporarily remove the sheet from the current schematic page so that recursion
446  // and symbol library link tests can be performed with the modified sheet settings.
447  restoreSheet = true;
449  }
450 
451  if( !m_frame->LoadSheetFromFile( m_sheet, g_CurrentSheet, newAbsoluteFilename )
453  {
454  if( restoreSheet )
456 
457  return false;
458  }
459 
460  if( restoreSheet )
462  }
463 
464  m_fields->at( SHEETFILENAME ).SetText( newRelativeFilename );
465  m_fields->at( SHEETNAME ).SetText( newSheetname );
466 
467  // change all field positions from relative to absolute
468  for( unsigned i = 0; i < m_fields->size(); ++i )
469  m_fields->at( i ).Offset( m_sheet->GetPosition() );
470 
473 
475 
477  *m_clearAnnotationNewItems = clearAnnotation;
478 
482 
485  m_frame->OnModify();
486 
487  return true;
488 }
489 
490 
492 {
493  wxGridCellEditor* editor = m_grid->GetCellEditor( event.GetRow(), event.GetCol() );
494  wxControl* control = editor->GetControl();
495 
496  if( control && control->GetValidator() && !control->GetValidator()->Validate( control ) )
497  {
498  event.Veto();
499  m_delayedFocusRow = event.GetRow();
500  m_delayedFocusColumn = event.GetCol();
501  }
502 
503  editor->DecRef();
504 }
505 
506 
507 void DIALOG_SCH_SHEET_PROPS::OnAddField( wxCommandEvent& event )
508 {
509  if( !m_grid->CommitPendingChanges() )
510  return;
511 
512  int fieldID = m_fields->size();
513  SCH_FIELD newField( wxPoint( 0, 0 ), fieldID, m_sheet );
514 
515  newField.SetName( SCH_SHEET::GetDefaultFieldName( fieldID ) );
516  newField.SetTextAngle( m_fields->at( SHEETNAME ).GetTextAngle() );
517 
518  m_fields->push_back( newField );
519 
520  // notify the grid
521  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
522  m_grid->ProcessTableMessage( msg );
523 
524  m_grid->MakeCellVisible( m_fields->size() - 1, 0 );
525  m_grid->SetGridCursor( m_fields->size() - 1, 0 );
526 
527  m_grid->EnableCellEditControl();
528  m_grid->ShowCellEditControl();
529 }
530 
531 
532 void DIALOG_SCH_SHEET_PROPS::OnDeleteField( wxCommandEvent& event )
533 {
534  int curRow = m_grid->GetGridCursorRow();
535 
536  if( curRow < 0 )
537  return;
538  else if( curRow < SHEET_MANDATORY_FIELDS )
539  {
540  DisplayError( this, wxString::Format( _( "The first %d fields are mandatory." ),
542  return;
543  }
544 
545  m_grid->CommitPendingChanges( true /* quiet mode */ );
546 
547  m_fields->erase( m_fields->begin() + curRow );
548 
549  // notify the grid
550  wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, curRow, 1 );
551  m_grid->ProcessTableMessage( msg );
552 
553  if( m_grid->GetNumberRows() > 0 )
554  {
555  m_grid->MakeCellVisible( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
556  m_grid->SetGridCursor( std::max( 0, curRow-1 ), m_grid->GetGridCursorCol() );
557  }
558 }
559 
560 
561 void DIALOG_SCH_SHEET_PROPS::OnMoveUp( wxCommandEvent& event )
562 {
563  if( !m_grid->CommitPendingChanges() )
564  return;
565 
566  int i = m_grid->GetGridCursorRow();
567 
568  if( i > SHEET_MANDATORY_FIELDS )
569  {
570  SCH_FIELD tmp = m_fields->at( (unsigned) i );
571  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
572  m_fields->insert( m_fields->begin() + i - 1, tmp );
573  m_grid->ForceRefresh();
574 
575  m_grid->SetGridCursor( i - 1, m_grid->GetGridCursorCol() );
576  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
577  }
578  else
579  wxBell();
580 }
581 
582 
583 void DIALOG_SCH_SHEET_PROPS::OnMoveDown( wxCommandEvent& event )
584 {
585  if( !m_grid->CommitPendingChanges() )
586  return;
587 
588  int i = m_grid->GetGridCursorRow();
589 
590  if( i >= SHEET_MANDATORY_FIELDS && i < m_grid->GetNumberRows() - 1 )
591  {
592  SCH_FIELD tmp = m_fields->at( (unsigned) i );
593  m_fields->erase( m_fields->begin() + i, m_fields->begin() + i + 1 );
594  m_fields->insert( m_fields->begin() + i + 1, tmp );
595  m_grid->ForceRefresh();
596 
597  m_grid->SetGridCursor( i + 1, m_grid->GetGridCursorCol() );
598  m_grid->MakeCellVisible( m_grid->GetGridCursorRow(), m_grid->GetGridCursorCol() );
599  }
600  else
601  wxBell();
602 }
603 
604 
606 {
607  m_width = aWidth;
608  // Account for scroll bars
609  aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
610 
611  m_grid->AutoSizeColumn( 0 );
612 
613  int fixedColsWidth = m_grid->GetColSize( 0 );
614 
615  for( int i = 2; i < m_grid->GetNumberCols(); i++ )
616  fixedColsWidth += m_grid->GetColSize( i );
617 
618  m_grid->SetColSize( 1, aWidth - fixedColsWidth );
619 }
620 
621 
622 void DIALOG_SCH_SHEET_PROPS::OnUpdateUI( wxUpdateUIEvent& event )
623 {
624  wxString shownColumns = m_grid->GetShownColumns();
625 
626  if( shownColumns != m_shownColumns )
627  {
628  m_shownColumns = shownColumns;
629 
630  if( !m_grid->IsCellEditControlShown() )
631  AdjustGridColumns( m_grid->GetRect().GetWidth() );
632  }
633 
634  // Handle a delayed focus
635  if( m_delayedFocusRow >= 0 )
636  {
637  m_grid->SetFocus();
638  m_grid->MakeCellVisible( m_delayedFocusRow, m_delayedFocusColumn );
639  m_grid->SetGridCursor( m_delayedFocusRow, m_delayedFocusColumn );
640 
641 
642  m_grid->EnableCellEditControl( true );
643  m_grid->ShowCellEditControl();
644 
645  m_delayedFocusRow = -1;
647  }
648 }
649 
650 
651 void DIALOG_SCH_SHEET_PROPS::OnSizeGrid( wxSizeEvent& event )
652 {
653  auto new_size = event.GetSize().GetX();
654 
655  if( m_width != new_size )
656  {
657  AdjustGridColumns( new_size );
658  }
659 
660  // Always propagate for a grid repaint (needed if the height changes, as well as width)
661  event.Skip();
662 }
663 
664 
665 void DIALOG_SCH_SHEET_PROPS::OnInitDlg( wxInitDialogEvent& event )
666 {
668 
669  // Now all widgets have the size fixed, call FinishDialogSettings
671 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:150
bool CheckSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:44
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
const BITMAP_OPAQUE trash_xpm[1]
Definition: trash.cpp:46
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:237
Functions for manipulating tab traversal in forms and dialogs.
const wxString & GetFileName() const
Definition: sch_screen.h:157
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:238
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:584
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
KIGFX::COLOR4D GetSwatchColor() const
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:184
void SetSwatchColor(KIGFX::COLOR4D aColor, bool sendEvent)
Set the current swatch color directly.
void OnMoveUp(wxCommandEvent &event) override
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_sheet.h:275
void OnDeleteField(wxCommandEvent &event) override
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:70
This file is part of the common library.
void ShowHideColumns(const wxString &shownColumns)
Show/hide the grid columns based on a tokenized string of shown column indexes.
Definition: wx_grid.cpp:119
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_field.cpp:537
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:149
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
double GetTextAngle() const
Definition: eda_text.h:158
int GetId() const
Definition: sch_field.h:108
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:93
wxString AsString() const
Definition: common.cpp:170
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:290
Schematic editor (Eeschema) main window.
void SetSwatchBackground(KIGFX::COLOR4D aBackground)
Set the swatch background color.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
COLOR_SETTINGS * GetColorSettings() override
Returns a pointer to the active color theme settings.
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:57
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
void OnAddField(wxCommandEvent &event) override
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:293
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:288
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:88
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
Definition: sch_sheet.cpp:172
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
int GetBorderWidth() const
Definition: sch_sheet.h:287
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:294
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:102
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:637
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:183
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
void OnGridCellChanging(wxGridEvent &event)
const BITMAP_OPAQUE small_down_xpm[1]
Definition: small_down.cpp:25
Definition: colors.h:59
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:291
Definition of file extensions used in Kicad.
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
Definition: sch_item.h:409
void OnInitDlg(wxInitDialogEvent &event) override
static const wxString GetDefaultFieldName(int aFieldNdx)
Definition: sch_sheet.cpp:43
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:172
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:491
static bool positioningChanged(const SCH_FIELD &a, const SCH_FIELD &b)
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:565
const BITMAP_OPAQUE small_up_xpm[1]
Definition: small_up.cpp:26
void OnUpdateUI(wxUpdateUIEvent &event) override
const std::string LegacySchematicFileExtension
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
const KIID m_Uuid
Definition: base_struct.h:169
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:516
wxString GetShownColumns()
Get a tokenized string containing the shown column indexes.
Definition: wx_grid.cpp:101
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Class DIALOG_SCH_SHEET_PROPS_BASE.
COLOR4D GetColor(int aLayer) const
SCH_SCREEN * LastScreen()
Function LastScreen.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:175
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
#define _(s)
Definition: 3d_actions.cpp:33
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
wxString GetName(bool aUseDefaultName=true) const
Function GetName returns the field name.
Definition: sch_field.cpp:403
void SetName(const wxString &aName)
Definition: sch_field.h:106
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
void OnSizeGrid(wxSizeEvent &event) override
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
SCH_SHEET * g_RootSheet
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:155
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:283
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
const BITMAP_OPAQUE small_plus_xpm[1]
Definition: small_plus.cpp:20
Custom text control validator definitions.
FIELDS_GRID_TABLE< SCH_FIELD > * m_fields
DIALOG_SCH_SHEET_PROPS(SCH_EDIT_FRAME *aParent, SCH_SHEET *aSheet, bool *aClearAnnotationNewItems)
void OnMoveDown(wxCommandEvent &event) override
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40