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-2017 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 <schframe.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  wxString newFilename = fileName.GetFullPath();
104 
105  // Search for a schematic file having the same filename
106  // already in use in the hierarchy or on disk, in order to reuse it.
107  if( !g_RootSheet->SearchHierarchy( fileName.GetFullName(), &useScreen ) )
108  {
109  // if user entered a relative path, allow that to stay, but do the
110  // file existence test with an absolute (full) path. This transformation
111  // is local to this scope, but is the same one used at load time later.
112  newFilename = Prj().AbsolutePath( newFilename );
113 
114  loadFromFile = wxFileExists( newFilename );
115  }
116 
117  // Inside Eeschema, filenames are stored using unix notation
118  newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
119 
120  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
121 
122  if( aSheet->GetScreen() == NULL ) // New sheet.
123  {
124  if( useScreen || loadFromFile ) // Load from existing file.
125  {
126  if( useScreen != NULL )
127  {
128  msg.Printf( _( "A file named '%s' already exists in the current schematic "
129  "hierarchy." ), newFilename );
130  }
131  else
132  {
133  msg.Printf( _( "A file named '%s' already exists." ), newFilename );
134  }
135 
136  msg += _( "\n\nDo you want to create a sheet with the contents of this file?" );
137 
138  if( !IsOK( this, msg ) )
139  {
140  return false;
141  }
142  }
143  else // New file.
144  {
145  aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
146  aSheet->GetScreen()->SetModify();
148  aSheet->GetScreen()->SetFileName( newFilename );
149  }
150  }
151  else // Existing sheet.
152  {
153  bool isUndoable = true;
154  bool renameFile = false;
155 
156  // We are always using here a case insensitive comparison
157  // to avoid issues under Windows, although under Unix
158  // filenames are case sensitive.
159  // But many users create schematic under both Unix and Windows
160  if( newFilename.CmpNoCase( aSheet->GetFileName() ) != 0 )
161  {
162  // Sheet file name changes cannot be undone.
163  isUndoable = false;
164  msg = _( "Changing the sheet file name cannot be undone. " );
165 
166  if( useScreen || loadFromFile ) // Load from existing file.
167  {
168  wxString tmp;
169 
170  if( useScreen != NULL )
171  {
172  tmp.Printf( _( "A file named <%s> already exists in the current schematic "
173  "hierarchy." ), newFilename );
174  }
175  else
176  {
177  tmp.Printf( _( "A file named <%s> already exists." ), newFilename );
178  }
179 
180  msg += tmp;
181  msg += _( "\n\nDo you want to replace the sheet with the contents of this file?" );
182 
183  if( !IsOK( this, msg ) )
184  return false;
185 
186  if( loadFromFile )
187  aSheet->SetScreen( NULL );
188  }
189  else // Save to new file name.
190  {
191  if( aSheet->GetScreenCount() > 1 )
192  {
193  msg += _( "This sheet uses shared data in a complex hierarchy.\n\n" );
194  msg += _( "Do you wish to convert it to a simple hierarchical sheet?" );
195 
196  if( !IsOK( NULL, msg ) )
197  return false;
198  }
199 
200  renameFile = true;
201  }
202  }
203 
205 
206  if( isUndoable )
207  SaveCopyInUndoList( aSheet, UR_CHANGED );
208 
209  if( renameFile )
210  {
211  aSheet->GetScreen()->SetFileName( newFilename );
212 
213  try
214  {
215  pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
216  }
217  catch( const IO_ERROR& ioe )
218  {
219  msg.Printf( _( "Error occurred saving schematic file '%s'." ), newFilename );
220  DisplayErrorMessage( this, msg, ioe.What() );
221 
222  msg.Printf( _( "Failed to save schematic '%s'" ), newFilename );
223  AppendMsgPanel( wxEmptyString, msg, CYAN );
224 
225  return false;
226  }
227 
228  // If the the associated screen is shared by more than one sheet, remove the
229  // screen and reload the file to a new screen. Failure to do this will trash
230  // the screen reference counting in complex hierarchies.
231  if( aSheet->GetScreenCount() > 1 )
232  {
233  aSheet->SetScreen( NULL );
234  loadFromFile = true;
235  }
236  }
237  }
238 
239  aSheet->SetFileName( fileName.GetFullPath( wxPATH_UNIX ) );
240 
241  if( useScreen )
242  {
243  aSheet->SetScreen( useScreen );
244  }
245  else if( loadFromFile )
246  {
247  try
248  {
249  aSheet = pi->Load( newFilename, &Kiway(), aSheet );
250 
251  if( !pi->GetError().IsEmpty() )
252  {
253  DisplayErrorMessage( this,
254  _( "The entire schematic could not be load. Errors "
255  "occurred attempting to load hierarchical sheet "
256  "schematics." ),
257  pi->GetError() );
258  }
259  }
260  catch( const IO_ERROR& ioe )
261  {
262  msg.Printf( _( "Error occurred loading schematic file '%s'." ), newFilename );
263  DisplayErrorMessage( this, msg, ioe.What() );
264 
265  msg.Printf( _( "Failed to load schematic '%s'" ), newFilename );
266  AppendMsgPanel( wxEmptyString, msg, CYAN );
267 
268  return false;
269  }
270  }
271 
273  aSheet->SetName( dlg.GetSheetName() );
275 
276  if( aSheet->GetName().IsEmpty() )
277  aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
278  (long unsigned) aSheet->GetTimeStamp() ) );
279 
280  // Make sure the sheet changes do not cause any recursion.
281  SCH_SHEET_LIST sheetHierarchy( aSheet );
282 
283  // Make sure files have fully qualified path and file name.
284  wxFileName destFn = aHierarchy->Last()->GetFileName();
285 
286  if( destFn.IsRelative() )
287  destFn.MakeAbsolute( Prj().GetProjectPath() );
288 
289  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
290  {
291  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
292  "has the sheet <%s> or one of it's subsheets as a parent somewhere in "
293  "the schematic hierarchy." ),
294  newFilename );
295  DisplayError( this, msg );
296  return false;
297  }
298 
299  // Check to make sure the symbols have been remapped to the symbol library table.
300  SCH_SCREENS newScreens( aSheet );
301 
302  if( newScreens.HasNoFullyDefinedLibIds() )
303  {
304  msg.Printf(_( "The schematic '%s' has not been remapped to the symbol library table. "
305  "Most if not all of the symbol library links will be broken. Do you "
306  "want to continue?" ), fileName.GetFullName() );
307 
308  if( !IsOK( this, msg ) )
309  return false;
310  }
311 
313  m_canvas->SetIgnoreMouseEvents( false );
314  OnModify();
315 
316  return true;
317 }
318 
319 
320 /* Move selected sheet with the cursor.
321  * Callback function used by m_mouseCaptureCallback.
322  * Note also now this function is called only when resizing the sheet
323  * But the (very small code) relative to sheet move is still present here
324  */
325 static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
326  bool aErase )
327 {
328  BASE_SCREEN* screen = aPanel->GetScreen();
329  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
330 
331  if( sheet == nullptr ) // Be sure we are using the right object
332  return;
333 
334  if( aErase )
335  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
336 
337  wxPoint pos = sheet->GetPosition();
338 
339  int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
340  int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
341 
342  // If the sheet doesn't have any pins, clamp the minimum size to the default values.
343  width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
344  height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
345 
346  if( sheet->HasPins() )
347  {
348  int gridSizeX = KiROUND( screen->GetGridSize().x );
349  int gridSizeY = KiROUND( screen->GetGridSize().y );
350 
351  // If the sheet has pins, use the pin positions to clamp the minimum width and height.
352  height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
353  sheet->GetMinHeight() + gridSizeY : height;
354  width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
355  sheet->GetMinWidth() + gridSizeX : width;
356  }
357 
358  wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
359  wxPoint( pos.x + width, pos.y + height ) );
360  sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
361 
362  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
363 }
364 
365 
366 // Complete sheet move.
367 static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
368 {
369  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
370  SCH_ITEM* item = screen->GetCurItem();
371 
372  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
373 
374  if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
375  return;
376 
377  parent->SetRepeatItem( NULL );
378 
379  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
380 
381  if( item->IsNew() )
382  {
383  delete item;
384  }
385  else if( item->IsMoving() || item->IsResized() )
386  {
387  screen->Remove( item );
388  delete item;
389 
390  item = parent->GetUndoItem();
391 
392  wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
393 
394  screen->Append( item );
395  // the owner of item is no more parent, this is the draw list of screen:
396  parent->SetUndoItem( NULL );
397 
398  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
399  item->ClearFlags();
400  }
401  else
402  {
403  item->ClearFlags();
404  }
405 
406  screen->SetCurItem( NULL );
407 }
408 
409 
410 // Create hierarchy sheet.
412 {
413  SetRepeatItem( NULL );
414 
415  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
416 
417  sheet->SetFlags( IS_NEW | IS_RESIZED );
418  sheet->SetTimeStamp( GetNewTimeStamp() );
419  sheet->SetParent( GetScreen() );
420  sheet->SetScreen( NULL );
421 
422  // need to check if this is being added to the GetDrawItems().
423  // also need to update the hierarchy, if we are adding
424  // a sheet to a screen that already has multiple instances (!)
425  GetScreen()->SetCurItem( sheet );
427  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
428  m_canvas->CrossHairOff( aDC );
429 
431 
433  m_canvas->CrossHairOn( aDC );
434 
435  return sheet;
436 }
437 
438 
439 void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
440 {
441  if( aSheet == NULL || aSheet->IsNew() )
442  return;
443 
444  wxCHECK_RET( aSheet->Type() == SCH_SHEET_T,
445  wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
446  GetChars( aSheet->GetClass() ) ) );
447 
448  m_canvas->CrossHairOff( aDC );
451  m_canvas->CrossHairOn( aDC );
452 
453  SetUndoItem( aSheet );
454  aSheet->SetFlags( IS_RESIZED );
455 
457  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
458 
459  if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
460  SetUndoItem( aSheet );
461 }
462 
463 
465 {
466  if( aSheet == NULL )
467  return;
468 
469  // Save old sheet in undo list if not already in edit, or moving.
470  if( aSheet->GetFlags() == 0 )
471  SaveCopyInUndoList( aSheet, UR_CHANGED );
472 
473  // Rotate the sheet on itself. Sheets do not have a anchor point.
474  // Rotation is made around it center
475  wxPoint rotPoint = aSheet->GetBoundingBox().Centre();
476 
477  // rotate CCW, or CW. to rotate CW, rotate 3 times
478  aSheet->Rotate( rotPoint );
479 
480  if( !aRotCCW )
481  {
482  aSheet->Rotate( rotPoint );
483  aSheet->Rotate( rotPoint );
484  }
485 
486  GetCanvas()->Refresh();
487  OnModify();
488 }
489 
490 
491 void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
492 {
493  if( aSheet == NULL )
494  return;
495 
496  // Save old sheet in undo list if not already in edit, or moving.
497  if( aSheet->GetFlags() == 0 )
498  SaveCopyInUndoList( aSheet, UR_CHANGED );
499 
500  // Mirror the sheet on itself. Sheets do not have a anchor point.
501  // Mirroring is made around it center
502  wxPoint mirrorPoint = aSheet->GetBoundingBox().Centre();
503 
504  if( aFromXaxis ) // mirror relative to Horizontal axis
505  aSheet->MirrorX( mirrorPoint.y );
506  else // Mirror relative to vertical axis
507  aSheet->MirrorY( mirrorPoint.x );
508 
509  GetCanvas()->Refresh();
510  OnModify();
511 }
void SetSheetNameTextSize(const wxString &aTextSize)
Definition of the SCH_SHEET class for Eeschema.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
static void ExitSheet(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: sheet.cpp:367
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:225
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
bool IsMoving() const
Definition: base_struct.h:245
bool IsResized() const
Definition: base_struct.h:249
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
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
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:325
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:243
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:467
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:331
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
Definition: schframe.cpp:773
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
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:464
SCH_ITEM * GetUndoItem() const
Definition: schframe.h:1379
Schematic editor (Eeschema) main window.
Definition: schframe.h:118
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:171
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
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.
Definition: schframe.cpp:471
#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.
Definition: schframe.cpp:532
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:411
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:87
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:280
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:240
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder.
Definition: colors.h:59
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:382
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:325
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:174
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:89
Class SCH_SHEET_PATH.
wxPoint Centre() const
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:540
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:252
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:439
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:764
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:259
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)
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.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
void SetIgnoreMouseEvents(bool aIgnore)
Implementing DIALOG_SCH_SHEET_PROPS_BASE.
void SetMaxUndoItems(int aMax)
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
#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:281
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:491
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...
Definition: schframe.cpp:591
void SetFileName(const wxString &aFileName)
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:73
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:131
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.
const wxString SchematicFileExtension
timestamp_t GetTimeStamp() const
Definition: base_struct.h:231
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:230
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:720