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  bool clearAnnotation = false;
102  SCH_SCREEN* useScreen = NULL;
103 
104  // Relative file names are relative to the path of the current sheet. This allows for
105  // nesting of schematic files in subfolders.
106  if( !fileName.IsAbsolute() )
107  {
108  const SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
109 
110  wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
111 
112  wxFileName currentSheetFileName = currentScreen->GetFileName();
113 
114  wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
115  "Cannot normalize new sheet schematic file path." );
116  }
117 
118  wxString newFilename = fileName.GetFullPath();
119 
120  // Search for a schematic file having the same filename
121  // already in use in the hierarchy or on disk, in order to reuse it.
122  if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
123  {
124  loadFromFile = wxFileExists( newFilename );
125  wxLogDebug( "Sheet requested file \"%s\", %s", newFilename,
126  ( loadFromFile ) ? "found" : "not found" );
127  }
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  clearAnnotation = true;
139 
140  wxString existsMsg;
141  wxString linkMsg;
142  existsMsg.Printf( _( "\"%s\" already exists." ), fileName.GetFullName() );
143  linkMsg.Printf( _( "Link \"%s\" to this file?" ), dlg.GetSheetName() );
144  msg.Printf( wxT( "%s\n\n%s" ), existsMsg, linkMsg );
145 
146  if( !IsOK( this, msg ) )
147  return false;
148 
149  }
150  else // New file.
151  {
152  aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
153  aSheet->GetScreen()->SetModify();
155  aSheet->GetScreen()->SetFileName( newFilename );
156  }
157  }
158  else // Existing sheet.
159  {
160  bool isUndoable = true;
161  bool renameFile = false;
162  wxString replaceMsg;
163  wxString newMsg;
164  wxString noUndoMsg;
165 
166  replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ),
167  dlg.GetSheetName(), aSheet->GetFileName(), fileName.GetFullName() );
168  newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ),
169  fileName.GetFullName(), aSheet->GetFileName() );
170  noUndoMsg = _( "This action cannot be undone." );
171 
172  // We are always using here a case insensitive comparison
173  // to avoid issues under Windows, although under Unix
174  // filenames are case sensitive.
175  // But many users create schematic under both Unix and Windows
176  // **
177  // N.B. aSheet->GetFileName() will return a relative path
178  // aSheet->GetScreen()->GetFileName() returns a full path
179  if( newFilename.CmpNoCase( aSheet->GetScreen()->GetFileName() ) != 0 )
180  {
181  // Sheet file name changes cannot be undone.
182  isUndoable = false;
183 
184  if( useScreen || loadFromFile ) // Load from existing file.
185  {
186  clearAnnotation = true;
187 
188  msg.Printf( wxT( "%s\n\n%s" ), replaceMsg, noUndoMsg );
189 
190  if( !IsOK( this, msg ) )
191  return false;
192 
193  if( loadFromFile )
194  aSheet->SetScreen( NULL );
195  }
196  else // Save to new file name.
197  {
198  if( aSheet->GetScreenCount() > 1 )
199  {
200  msg.Printf( wxT( "%s\n\n%s" ), newMsg, noUndoMsg );
201 
202  if( !IsOK( this, msg ) )
203  return false;
204  }
205 
206  renameFile = true;
207  }
208  }
209 
211 
212  if( isUndoable )
213  SaveCopyInUndoList( aSheet, UR_CHANGED );
214 
215  if( renameFile )
216  {
217  aSheet->GetScreen()->SetFileName( newFilename );
218 
219  try
220  {
221  pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
222  }
223  catch( const IO_ERROR& ioe )
224  {
225  msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newFilename );
226  DisplayErrorMessage( this, msg, ioe.What() );
227 
228  msg.Printf( _( "Failed to save schematic \"%s\"" ), newFilename );
229  AppendMsgPanel( wxEmptyString, msg, CYAN );
230 
231  return false;
232  }
233 
234  // If the the associated screen is shared by more than one sheet, remove the
235  // screen and reload the file to a new screen. Failure to do this will trash
236  // the screen reference counting in complex hierarchies.
237  if( aSheet->GetScreenCount() > 1 )
238  {
239  aSheet->SetScreen( NULL );
240  loadFromFile = true;
241  }
242  }
243  }
244 
245  wxFileName userFileName = dlg.GetFileName();
246  userFileName.SetExt( SchematicFileExtension );
247  aSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
248 
249  if( useScreen )
250  {
251  aSheet->SetScreen( useScreen );
252  }
253  else if( loadFromFile )
254  {
255  try
256  {
257  aSheet = pi->Load( newFilename, &Kiway(), aSheet );
258 
259  if( !pi->GetError().IsEmpty() )
260  {
261  DisplayErrorMessage( this,
262  _( "The entire schematic could not be load. Errors "
263  "occurred attempting to load hierarchical sheet "
264  "schematics." ),
265  pi->GetError() );
266  }
267  }
268  catch( const IO_ERROR& ioe )
269  {
270  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), newFilename );
271  DisplayErrorMessage( this, msg, ioe.What() );
272 
273  msg.Printf( _( "Failed to load schematic \"%s\"" ), newFilename );
274  AppendMsgPanel( wxEmptyString, msg, CYAN );
275 
276  return false;
277  }
278  }
279 
281  aSheet->SetName( dlg.GetSheetName() );
283 
284  if( aSheet->GetName().IsEmpty() )
285  aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
286  (long unsigned) aSheet->GetTimeStamp() ) );
287 
288  // Make sure the sheet changes do not cause any recursion.
289  SCH_SHEET_LIST sheetHierarchy( aSheet );
290 
291  // Make sure files have fully qualified path and file name.
292  wxFileName destFn = aHierarchy->Last()->GetFileName();
293 
294  if( destFn.IsRelative() )
295  destFn.MakeAbsolute( Prj().GetProjectPath() );
296 
297  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
298  {
299  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
300  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
301  "the schematic hierarchy." ),
302  newFilename );
303  DisplayError( this, msg );
304  return false;
305  }
306 
307  // Check to make sure the symbols have been remapped to the symbol library table.
308  SCH_SCREENS newScreens( aSheet );
309 
310  if( newScreens.HasNoFullyDefinedLibIds() )
311  {
312  msg.Printf(_( "The schematic \"%s\" has not been remapped to the symbol library table. "
313  "Most if not all of the symbol library links will be broken. Do you "
314  "want to continue?" ), fileName.GetFullName() );
315 
316  if( !IsOK( this, msg ) )
317  return false;
318  }
319 
320  if( clearAnnotation )
321  {
322  newScreens.ClearAnnotation();
323  }
324 
326  m_canvas->SetIgnoreMouseEvents( false );
327  OnModify();
328 
329  return true;
330 }
331 
332 
333 /* Move selected sheet with the cursor.
334  * Callback function used by m_mouseCaptureCallback.
335  * Note also now this function is called only when resizing the sheet
336  * But the (very small code) relative to sheet move is still present here
337  */
338 static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
339  bool aErase )
340 {
341  BASE_SCREEN* screen = aPanel->GetScreen();
342  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
343 
344  if( sheet == nullptr ) // Be sure we are using the right object
345  return;
346 
347  if( aErase )
348  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
349 
350  wxPoint pos = sheet->GetPosition();
351 
352  int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
353  int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
354 
355  // If the sheet doesn't have any pins, clamp the minimum size to the default values.
356  width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
357  height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
358 
359  if( sheet->HasPins() )
360  {
361  int gridSizeX = KiROUND( screen->GetGridSize().x );
362  int gridSizeY = KiROUND( screen->GetGridSize().y );
363 
364  // If the sheet has pins, use the pin positions to clamp the minimum width and height.
365  height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
366  sheet->GetMinHeight() + gridSizeY : height;
367  width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
368  sheet->GetMinWidth() + gridSizeX : width;
369  }
370 
371  wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
372  wxPoint( pos.x + width, pos.y + height ) );
373  sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
374 
375  sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
376 }
377 
378 
379 // Complete sheet move.
380 static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
381 {
382  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
383  SCH_ITEM* item = screen->GetCurItem();
384 
385  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
386 
387  if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
388  return;
389 
390  parent->SetRepeatItem( NULL );
391 
392  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
393 
394  if( item->IsNew() )
395  {
396  delete item;
397  }
398  else if( item->IsMoving() || item->IsResized() )
399  {
400  screen->Remove( item );
401  delete item;
402 
403  item = parent->GetUndoItem();
404 
405  wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
406 
407  screen->Append( item );
408  // the owner of item is no more parent, this is the draw list of screen:
409  parent->SetUndoItem( NULL );
410 
411  item->Draw( aPanel, aDC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
412  item->ClearFlags();
413  }
414  else
415  {
416  item->ClearFlags();
417  }
418 
419  screen->SetCurItem( NULL );
420 }
421 
422 
423 // Create hierarchy sheet.
425 {
426  SetRepeatItem( NULL );
427 
428  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
429 
430  sheet->SetFlags( IS_NEW | IS_RESIZED );
431  sheet->SetTimeStamp( GetNewTimeStamp() );
432  sheet->SetParent( GetScreen() );
433  sheet->SetScreen( NULL );
434 
435  // need to check if this is being added to the GetDrawItems().
436  // also need to update the hierarchy, if we are adding
437  // a sheet to a screen that already has multiple instances (!)
438  GetScreen()->SetCurItem( sheet );
440  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
441  m_canvas->CrossHairOff( aDC );
442 
444 
446  m_canvas->CrossHairOn( aDC );
447 
448  return sheet;
449 }
450 
451 
452 void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
453 {
454  if( aSheet == NULL || aSheet->IsNew() )
455  return;
456 
457  wxCHECK_RET( aSheet->Type() == SCH_SHEET_T,
458  wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
459  GetChars( aSheet->GetClass() ) ) );
460 
461  m_canvas->CrossHairOff( aDC );
464  m_canvas->CrossHairOn( aDC );
465 
466  SetUndoItem( aSheet );
467  aSheet->SetFlags( IS_RESIZED );
468 
470  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
471 
472  if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
473  SetUndoItem( aSheet );
474 }
475 
476 
478 {
479  if( aSheet == NULL )
480  return;
481 
482  // Save old sheet in undo list if not already in edit, or moving.
483  if( aSheet->GetFlags() == 0 )
484  SaveCopyInUndoList( aSheet, UR_CHANGED );
485 
486  // Rotate the sheet on itself. Sheets do not have a anchor point.
487  // Rotation is made around it center
488  wxPoint rotPoint = aSheet->GetBoundingBox().Centre();
489 
490  // Keep this rotation point on the grid, otherwise all items of this sheet
491  // will be moved off grid
492  rotPoint = GetNearestGridPosition( rotPoint );
493 
494  // rotate CCW, or CW. to rotate CW, rotate 3 times
495  aSheet->Rotate( rotPoint );
496 
497  if( !aRotCCW )
498  {
499  aSheet->Rotate( rotPoint );
500  aSheet->Rotate( rotPoint );
501  }
502 
503  GetCanvas()->Refresh();
504  OnModify();
505 }
506 
507 
508 void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
509 {
510  if( aSheet == NULL )
511  return;
512 
513  // Save old sheet in undo list if not already in edit, or moving.
514  if( aSheet->GetFlags() == 0 )
515  SaveCopyInUndoList( aSheet, UR_CHANGED );
516 
517  // Mirror the sheet on itself. Sheets do not have a anchor point.
518  // Mirroring is made around it center
519  wxPoint mirrorPoint = aSheet->GetBoundingBox().Centre();
520 
521  if( aFromXaxis ) // mirror relative to Horizontal axis
522  aSheet->MirrorX( mirrorPoint.y );
523  else // Mirror relative to vertical axis
524  aSheet->MirrorY( mirrorPoint.x );
525 
526  GetCanvas()->Refresh();
527  OnModify();
528 }
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:380
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
SCH_SHEET * FindSheetByName(const wxString &aSheetName)
Function FindSheetByName.
bool IsMoving() const
Definition: base_struct.h:229
bool IsResized() const
Definition: base_struct.h:233
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:563
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:199
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:338
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:227
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:467
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:351
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:458
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:301
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:205
void SetFileNameTextSizeUnits(const wxString &aUnits)
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
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:906
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:477
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:360
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:109
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:167
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_sheet.h:251
SCH_SHEET * CreateSheet(wxDC *DC)
Definition: sheet.cpp:424
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:264
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:499
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:689
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:224
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:338
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:370
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:180
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:94
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:127
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:265
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:665
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:646
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:57
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:452
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:98
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:812
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:426
#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:272
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
void ClearAnnotation()
Clear the annotation for all components in the hierarchy.
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
Definition: sch_sheet.cpp:261
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:701
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:193
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:48
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:110
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:265
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:508
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:185
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:233
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:215
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:214
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:721