KiCad PCB EDA Suite
sheet.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2018 KiCad Developers, see change_log.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 
29 #include <fctsys.h>
30 #include <class_drawpanel.h>
31 #include <confirm.h>
32 #include <base_units.h>
33 #include <kiface_i.h>
34 #include <project.h>
36 
37 #include <sch_edit_frame.h>
38 #include <sch_legacy_plugin.h>
39 #include <sch_sheet.h>
40 #include <sch_sheet_path.h>
41 
43 
44 
46 {
47  if( aSheet == NULL || aHierarchy == NULL )
48  return false;
49 
50  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
51 
52  // Get the new texts
53  DIALOG_SCH_SHEET_PROPS dlg( this );
54 
55  wxString units = GetUnitsLabel( g_UserUnit );
56  dlg.SetFileName( aSheet->GetFileName() );
58  dlg.SetFileNameTextSizeUnits( units );
59  dlg.SetSheetName( aSheet->GetName() );
61  dlg.SetSheetNameTextSizeUnits( units );
62  dlg.SetSheetTimeStamp( wxString::Format( wxT( "%8.8lX" ),
63  (unsigned long) aSheet->GetTimeStamp() ) );
64 
65  /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier
66  * versions for the flex grid sizer in wxGTK that prevents the last
67  * column from being sized correctly. It doesn't cause any problems
68  * on win32 so it doesn't need to wrapped in ugly #ifdef __WXGTK__
69  * #endif.
70  * Still present in wxWidgets 3.0.2
71  */
72  dlg.Layout();
73  dlg.Fit();
74  dlg.SetMinSize( dlg.GetSize() );
75  dlg.GetSizer()->Fit( &dlg );
76 
77  if( dlg.ShowModal() == wxID_CANCEL )
78  return false;
79 
80  wxFileName fileName = dlg.GetFileName();
81  fileName.SetExt( SchematicFileExtension );
82 
83  if( !fileName.IsOk() )
84  {
85  DisplayError( this, _( "File name is not valid!" ) );
86  return false;
87  }
88 
89  // Duplicate sheet names are not valid.
90  const SCH_SHEET* sheet = hierarchy.FindSheetByName( dlg.GetSheetName() );
91 
92  if( sheet && (sheet != aSheet) )
93  {
94  DisplayError( this, wxString::Format( _( "A sheet named \"%s\" already exists." ),
95  dlg.GetSheetName() ) );
96  return false;
97  }
98 
99  wxString msg;
100  bool loadFromFile = false;
101  SCH_SCREEN* useScreen = NULL;
102 
103  // Relative file names are relative to the path of the current sheet. This allows for
104  // nesting of schematic files in subfolders.
105  if( !fileName.IsAbsolute() )
106  {
107  const SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
108 
109  wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
110 
111  wxFileName currentSheetFileName = currentScreen->GetFileName();
112 
113  wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
114  "Cannot normalize new sheet schematic file path." );
115  }
116 
117  wxString newFilename = fileName.GetFullPath();
118 
119  // Search for a schematic file having the same filename
120  // already in use in the hierarchy or on disk, in order to reuse it.
121  if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
122  {
123  loadFromFile = wxFileExists( newFilename );
124  }
125 
126  wxLogDebug( "Sheet requested file \"%s\", %s", newFilename,
127  (loadFromFile) ? "found" : "not found" );
128 
129  // Inside Eeschema, filenames are stored using unix notation
130  newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
131 
132  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
133 
134  if( aSheet->GetScreen() == NULL ) // New sheet.
135  {
136  if( useScreen || loadFromFile ) // Load from existing file.
137  {
138  if( useScreen != NULL )
139  {
140  msg.Printf( _( "A file named \"%s\" already exists in the current schematic "
141  "hierarchy." ), newFilename );
142  }
143  else
144  {
145  msg.Printf( _( "A file named \"%s\" already exists." ), newFilename );
146  }
147 
148  msg += _( "\n\nDo you want to create a sheet with the contents of this file?" );
149 
150  if( !IsOK( this, msg ) )
151  {
152  return false;
153  }
154  }
155  else // New file.
156  {
157  aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
158  aSheet->GetScreen()->SetModify();
160  aSheet->GetScreen()->SetFileName( newFilename );
161  }
162  }
163  else // Existing sheet.
164  {
165  bool isUndoable = true;
166  bool renameFile = false;
167 
168  // We are always using here a case insensitive comparison
169  // to avoid issues under Windows, although under Unix
170  // filenames are case sensitive.
171  // But many users create schematic under both Unix and Windows
172  if( newFilename.CmpNoCase( aSheet->GetFileName() ) != 0 )
173  {
174  // Sheet file name changes cannot be undone.
175  isUndoable = false;
176  msg = _( "Changing the sheet file name cannot be undone. " );
177 
178  if( useScreen || loadFromFile ) // Load from existing file.
179  {
180  wxString tmp;
181 
182  if( useScreen != NULL )
183  {
184  tmp.Printf( _( "A file named \"%s\" already exists in the current schematic "
185  "hierarchy." ), newFilename );
186  }
187  else
188  {
189  tmp.Printf( _( "A file named \"%s\" already exists." ), newFilename );
190  }
191 
192  msg += tmp;
193  msg += _( "\n\nDo you want to replace the sheet with the contents of this file?" );
194 
195  if( !IsOK( this, msg ) )
196  return false;
197 
198  if( loadFromFile )
199  aSheet->SetScreen( NULL );
200  }
201  else // Save to new file name.
202  {
203  if( aSheet->GetScreenCount() > 1 )
204  {
205  msg += _( "This sheet uses shared data in a complex hierarchy.\n\n" );
206  msg += _( "Do you wish to convert it to a simple hierarchical sheet?" );
207 
208  if( !IsOK( NULL, msg ) )
209  return false;
210  }
211 
212  renameFile = true;
213  }
214  }
215 
217 
218  if( isUndoable )
219  SaveCopyInUndoList( aSheet, UR_CHANGED );
220 
221  if( renameFile )
222  {
223  aSheet->GetScreen()->SetFileName( newFilename );
224 
225  try
226  {
227  pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
228  }
229  catch( const IO_ERROR& ioe )
230  {
231  msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newFilename );
232  DisplayErrorMessage( this, msg, ioe.What() );
233 
234  msg.Printf( _( "Failed to save schematic \"%s\"" ), newFilename );
235  AppendMsgPanel( wxEmptyString, msg, CYAN );
236 
237  return false;
238  }
239 
240  // If the the associated screen is shared by more than one sheet, remove the
241  // screen and reload the file to a new screen. Failure to do this will trash
242  // the screen reference counting in complex hierarchies.
243  if( aSheet->GetScreenCount() > 1 )
244  {
245  aSheet->SetScreen( NULL );
246  loadFromFile = true;
247  }
248  }
249  }
250 
251  wxFileName userFileName = dlg.GetFileName();
252  userFileName.SetExt( SchematicFileExtension );
253  aSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
254 
255  if( useScreen )
256  {
257  aSheet->SetScreen( useScreen );
258  }
259  else if( loadFromFile )
260  {
261  try
262  {
263  aSheet = pi->Load( newFilename, &Kiway(), aSheet );
264 
265  if( !pi->GetError().IsEmpty() )
266  {
267  DisplayErrorMessage( this,
268  _( "The entire schematic could not be load. Errors "
269  "occurred attempting to load hierarchical sheet "
270  "schematics." ),
271  pi->GetError() );
272  }
273  }
274  catch( const IO_ERROR& ioe )
275  {
276  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), newFilename );
277  DisplayErrorMessage( this, msg, ioe.What() );
278 
279  msg.Printf( _( "Failed to load schematic \"%s\"" ), newFilename );
280  AppendMsgPanel( wxEmptyString, msg, CYAN );
281 
282  return false;
283  }
284  }
285 
287  aSheet->SetName( dlg.GetSheetName() );
289 
290  if( aSheet->GetName().IsEmpty() )
291  aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
292  (long unsigned) aSheet->GetTimeStamp() ) );
293 
294  // Make sure the sheet changes do not cause any recursion.
295  SCH_SHEET_LIST sheetHierarchy( aSheet );
296 
297  // Make sure files have fully qualified path and file name.
298  wxFileName destFn = aHierarchy->Last()->GetFileName();
299 
300  if( destFn.IsRelative() )
301  destFn.MakeAbsolute( Prj().GetProjectPath() );
302 
303  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
304  {
305  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
306  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
307  "the schematic hierarchy." ),
308  newFilename );
309  DisplayError( this, msg );
310  return false;
311  }
312 
313  // Check to make sure the symbols have been remapped to the symbol library table.
314  SCH_SCREENS newScreens( aSheet );
315 
316  if( newScreens.HasNoFullyDefinedLibIds() )
317  {
318  msg.Printf(_( "The schematic \"%s\" has not been remapped to the symbol library table. "
319  "Most if not all of the symbol library links will be broken. Do you "
320  "want to continue?" ), fileName.GetFullName() );
321 
322  if( !IsOK( this, msg ) )
323  return false;
324  }
325 
327  m_canvas->SetIgnoreMouseEvents( false );
328  OnModify();
329 
330  return true;
331 }
332 
333 
334 /* Move selected sheet with the cursor.
335  * Callback function used by m_mouseCaptureCallback.
336  * Note also now this function is called only when resizing the sheet
337  * But the (very small code) relative to sheet move is still present here
338  */
339 static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
340  bool aErase )
341 {
342  BASE_SCREEN* screen = aPanel->GetScreen();
343  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
344 
345  if( sheet == nullptr ) // Be sure we are using the right object
346  return;
347 
348  if( aErase )
349  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
350 
351  wxPoint pos = sheet->GetPosition();
352 
353  int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
354  int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
355 
356  // If the sheet doesn't have any pins, clamp the minimum size to the default values.
357  width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
358  height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
359 
360  if( sheet->HasPins() )
361  {
362  int gridSizeX = KiROUND( screen->GetGridSize().x );
363  int gridSizeY = KiROUND( screen->GetGridSize().y );
364 
365  // If the sheet has pins, use the pin positions to clamp the minimum width and height.
366  height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
367  sheet->GetMinHeight() + gridSizeY : height;
368  width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
369  sheet->GetMinWidth() + gridSizeX : width;
370  }
371 
372  wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
373  wxPoint( pos.x + width, pos.y + height ) );
374  sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
375 
376  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
377 }
378 
379 
380 // Complete sheet move.
381 static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
382 {
383  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
384  SCH_ITEM* item = screen->GetCurItem();
385 
386  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
387 
388  if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
389  return;
390 
391  parent->SetRepeatItem( NULL );
392 
393  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
394 
395  if( item->IsNew() )
396  {
397  delete item;
398  }
399  else if( item->IsMoving() || item->IsResized() )
400  {
401  screen->Remove( item );
402  delete item;
403 
404  item = parent->GetUndoItem();
405 
406  wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
407 
408  screen->Append( item );
409  // the owner of item is no more parent, this is the draw list of screen:
410  parent->SetUndoItem( NULL );
411 
412  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
413  item->ClearFlags();
414  }
415  else
416  {
417  item->ClearFlags();
418  }
419 
420  screen->SetCurItem( NULL );
421 }
422 
423 
424 // Create hierarchy sheet.
426 {
427  SetRepeatItem( NULL );
428 
429  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
430 
431  sheet->SetFlags( IS_NEW | IS_RESIZED );
432  sheet->SetTimeStamp( GetNewTimeStamp() );
433  sheet->SetParent( GetScreen() );
434  sheet->SetScreen( NULL );
435 
436  // need to check if this is being added to the GetDrawItems().
437  // also need to update the hierarchy, if we are adding
438  // a sheet to a screen that already has multiple instances (!)
439  GetScreen()->SetCurItem( sheet );
441  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
442  m_canvas->CrossHairOff( aDC );
443 
445 
447  m_canvas->CrossHairOn( aDC );
448 
449  return sheet;
450 }
451 
452 
453 void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
454 {
455  if( aSheet == NULL || aSheet->IsNew() )
456  return;
457 
458  wxCHECK_RET( aSheet->Type() == SCH_SHEET_T,
459  wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
460  GetChars( aSheet->GetClass() ) ) );
461 
462  m_canvas->CrossHairOff( aDC );
465  m_canvas->CrossHairOn( aDC );
466 
467  SetUndoItem( aSheet );
468  aSheet->SetFlags( IS_RESIZED );
469 
471  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
472 
473  if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
474  SetUndoItem( aSheet );
475 }
476 
477 
479 {
480  if( aSheet == NULL )
481  return;
482 
483  // Save old sheet in undo list if not already in edit, or moving.
484  if( aSheet->GetFlags() == 0 )
485  SaveCopyInUndoList( aSheet, UR_CHANGED );
486 
487  // Rotate the sheet on itself. Sheets do not have a anchor point.
488  // Rotation is made around it center
489  wxPoint rotPoint = aSheet->GetBoundingBox().Centre();
490 
491  // rotate CCW, or CW. to rotate CW, rotate 3 times
492  aSheet->Rotate( rotPoint );
493 
494  if( !aRotCCW )
495  {
496  aSheet->Rotate( rotPoint );
497  aSheet->Rotate( rotPoint );
498  }
499 
500  GetCanvas()->Refresh();
501  OnModify();
502 }
503 
504 
505 void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
506 {
507  if( aSheet == NULL )
508  return;
509 
510  // Save old sheet in undo list if not already in edit, or moving.
511  if( aSheet->GetFlags() == 0 )
512  SaveCopyInUndoList( aSheet, UR_CHANGED );
513 
514  // Mirror the sheet on itself. Sheets do not have a anchor point.
515  // Mirroring is made around it center
516  wxPoint mirrorPoint = aSheet->GetBoundingBox().Centre();
517 
518  if( aFromXaxis ) // mirror relative to Horizontal axis
519  aSheet->MirrorX( mirrorPoint.y );
520  else // Mirror relative to vertical axis
521  aSheet->MirrorY( mirrorPoint.x );
522 
523  GetCanvas()->Refresh();
524  OnModify();
525 }
void SetSheetNameTextSize(const wxString &aTextSize)
Definition of the SCH_SHEET class for Eeschema.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
static void ExitSheet(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: sheet.cpp:381
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:284
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
bool IsMoving() const
Definition: base_struct.h:247
bool IsResized() const
Definition: base_struct.h:251
void SetFileNameSize(int aSize)
Definition: sch_sheet.h:277
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:562
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:255
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:245
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:467
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:342
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
wxString GetUnitsLabel(EDA_UNITS_T aUnit)
Get a human readable units string.
Definition: base_units.cpp:457
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:300
wxString StringFromValue(EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol)
Function StringFromValue returns the string from aValue according to units (inch, mm ...
Definition: base_units.cpp:204
void SetFileNameTextSizeUnits(const wxString &aUnits)
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
const wxString & GetFileName() const
Definition: sch_screen.h:120
wxPoint GetResizePosition() const
Return the position of the lower right corner of the sheet in drawing units.
Definition: sch_sheet.cpp:905
virtual SCH_SHEET * Load(const wxString &aFileName, KIWAY *aKiway, SCH_SHEET *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL)
Load information from some input file format that this SCH_PLUGIN implementation knows about...
Definition: sch_plugin.cpp:50
void RotateHierarchicalSheet(SCH_SHEET *aSheet, bool aRotCCW)
Rotate a sheet object.
Definition: sheet.cpp:478
SCH_ITEM * GetUndoItem() const
Schematic editor (Eeschema) main window.
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:169
SCH_SCREEN * LastScreen() const
Function LastScreen.
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:361
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:47
void SetRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
int GetSheetNameSize() const
Definition: sch_sheet.h:271
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:166
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_sheet.h:251
SCH_SHEET * CreateSheet(wxDC *DC)
Definition: sheet.cpp:425
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:498
void SetSheetName(const wxString &aSheetName)
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_sheet.cpp:688
bool HasPins()
Definition: sch_sheet.h:374
void SetSheetNameSize(int aSize)
Definition: sch_sheet.h:273
void SetName(const wxString &aName)
Definition: sch_sheet.h:269
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:242
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:174
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder.
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 CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
static void resizeSheetWithMouseCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: sheet.cpp:339
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application...
Definition: base_units.cpp:369
The common library.
void SetSheetTimeStamp(const wxString &aTimeStamp)
void SetSheetNameTextSizeUnits(const wxString &aUnits)
int GetFileNameSize() const
Definition: sch_sheet.h:275
virtual const wxString & GetError() const
Return an error string to the caller.
Definition: sch_plugin.cpp:193
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:181
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:89
Class SCH_SHEET_PATH.
wxPoint Centre() const
Definition: eda_rect.h:60
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
Definition: sch_sheet.cpp:126
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:547
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:266
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:664
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:645
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:523
void ReSizeSheet(SCH_SHEET *Sheet, wxDC *DC)
Definition: sheet.cpp:453
virtual void Save(const wxString &aFileName, SCH_SCREEN *aSchematic, KIWAY *aKiway, const PROPERTIES *aProperties=NULL)
Write aSchematic to a storage file in a format that this SCH_PLUGIN implementation knows about...
Definition: sch_plugin.cpp:58
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:770
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_sheet.cpp:425
#define GR_DEFAULT_DRAWMODE
Definition: general.h:70
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:273
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Function GetNearestGridPosition returns the nearest aGridSize location to aPosition.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
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.h:140
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
Definition: sch_sheet.cpp:260
void SetFileName(const wxString &aFileName)
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_sheet.cpp:700
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:182
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
void SetIgnoreMouseEvents(bool aIgnore)
Implementing DIALOG_SCH_SHEET_PROPS_BASE.
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:313
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:194
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:48
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:128
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
void MirrorSheet(SCH_SHEET *aSheet, bool aFromXaxis)
Mirror a hierarchical sheet.
Definition: sheet.cpp:505
void SetUndoItem(const SCH_ITEM *aItem)
Clone aItem which can be used to restore the state of the item being edited when the user cancels the...
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:118
void SetModify()
Definition: base_screen.h:324
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
void SetFileNameTextSize(const wxString &aTextSize)
wxString GetName() const
Definition: sch_sheet.h:267
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:241
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED)=0
Function Draw Draw a schematic item.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:503
const wxString SchematicFileExtension
timestamp_t GetTimeStamp() const
Definition: base_struct.h:233
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:232
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:720