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 <sch_draw_panel.h>
31 #include <confirm.h>
32 #include <kiface_i.h>
33 #include <project.h>
35 
36 #include <sch_edit_frame.h>
37 #include <sch_legacy_plugin.h>
38 #include <sch_sheet.h>
39 #include <sch_sheet_path.h>
40 #include <sch_view.h>
41 
43 
44 
46  bool* aClearAnnotationNewItems )
47 {
48  if( aSheet == NULL || aHierarchy == NULL )
49  return false;
50 
51  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the schematic sheet hierarchy.
52 
53  // Get the new texts
54  DIALOG_SCH_SHEET_PROPS dlg( this, aSheet );
55 
56  if( dlg.ShowModal() == wxID_CANCEL )
57  return false;
58 
59  wxFileName fileName = dlg.GetFileName();
60  fileName.SetExt( SchematicFileExtension );
61 
62  wxString msg;
63  bool loadFromFile = false;
64  bool clearAnnotation = false;
65  SCH_SCREEN* useScreen = NULL;
66 
67  // Relative file names are relative to the path of the current sheet. This allows for
68  // nesting of schematic files in subfolders.
69  if( !fileName.IsAbsolute() )
70  {
71  const SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
72 
73  wxCHECK_MSG( currentScreen, false, "Invalid sheet path object." );
74 
75  wxFileName currentSheetFileName = currentScreen->GetFileName();
76 
77  wxCHECK_MSG( fileName.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() ), false,
78  "Cannot normalize new sheet schematic file path." );
79  }
80 
81  wxString newFilename = fileName.GetFullPath();
82 
83  // Search for a schematic file having the same filename
84  // already in use in the hierarchy or on disk, in order to reuse it.
85  if( !g_RootSheet->SearchHierarchy( newFilename, &useScreen ) )
86  {
87  loadFromFile = wxFileExists( newFilename );
88  wxLogDebug( "Sheet requested file \"%s\", %s",
89  newFilename,
90  ( loadFromFile ) ? "found" : "not found" );
91  }
92 
93  // Inside Eeschema, filenames are stored using unix notation
94  newFilename.Replace( wxT( "\\" ), wxT( "/" ) );
95 
96  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
97 
98  if( aSheet->GetScreen() == NULL ) // New sheet.
99  {
100  if( useScreen || loadFromFile ) // Load from existing file.
101  {
102  clearAnnotation = true;
103 
104  wxString existsMsg;
105  wxString linkMsg;
106  existsMsg.Printf( _( "\"%s\" already exists." ), fileName.GetFullName() );
107  linkMsg.Printf( _( "Link \"%s\" to this file?" ), dlg.GetSheetName() );
108  msg.Printf( wxT( "%s\n\n%s" ), existsMsg, linkMsg );
109 
110  if( !IsOK( this, msg ) )
111  return false;
112 
113  }
114  else // New file.
115  {
116  aSheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
117  aSheet->GetScreen()->SetModify();
119  aSheet->GetScreen()->SetFileName( newFilename );
120  }
121  }
122  else // Existing sheet.
123  {
124  bool isUndoable = true;
125  bool renameFile = false;
126  wxString replaceMsg;
127  wxString newMsg;
128  wxString noUndoMsg;
129 
130  // Changing the filename of a sheet can modify the full hierarchy structure
131  // and can be not always undoable.
132  // So prepare messages for user notifications:
133  replaceMsg.Printf( _( "Change \"%s\" link from \"%s\" to \"%s\"?" ),
134  dlg.GetSheetName(), aSheet->GetFileName(), fileName.GetFullName() );
135  newMsg.Printf( _( "Create new file \"%s\" with contents of \"%s\"?" ),
136  fileName.GetFullName(), aSheet->GetFileName() );
137  noUndoMsg = _( "This action cannot be undone." );
138 
139  // We are always using here a case insensitive comparison
140  // to avoid issues under Windows, although under Unix
141  // filenames are case sensitive.
142  // But many users create schematic under both Unix and Windows
143  // **
144  // N.B. 1: aSheet->GetFileName() will return a relative path
145  // aSheet->GetScreen()->GetFileName() returns a full path
146  //
147  // N.B. 2: newFilename uses the unix notation for separator.
148  // so we must use it also to compare the old filename to the new filename
149  wxString oldFilename = aSheet->GetScreen()->GetFileName();
150  oldFilename.Replace( wxT( "\\" ), wxT( "/" ) );
151 
152  if( newFilename.CmpNoCase( oldFilename ) != 0 )
153  {
154  // Sheet file name changes cannot be undone.
155  isUndoable = false;
156 
157  if( useScreen || loadFromFile ) // Load from existing file.
158  {
159  clearAnnotation = true;
160 
161  msg.Printf( wxT( "%s\n\n%s" ), replaceMsg, noUndoMsg );
162 
163  if( !IsOK( this, msg ) )
164  return false;
165 
166  if( loadFromFile )
167  aSheet->SetScreen( NULL );
168  }
169  else // Save to new file name.
170  {
171  if( aSheet->GetScreenCount() > 1 )
172  {
173  msg.Printf( wxT( "%s\n\n%s" ), newMsg, noUndoMsg );
174 
175  if( !IsOK( this, msg ) )
176  return false;
177  }
178 
179  renameFile = true;
180  }
181  }
182 
184 
185  if( isUndoable )
186  SaveCopyInUndoList( aSheet, UR_CHANGED );
187 
188  if( renameFile )
189  {
190  // If the the associated screen is shared by more than one sheet, do not
191  // change the filename of the corresponding screen here.
192  // (a new screen will be created later)
193  // if it is not shared, update the filename
194  if( aSheet->GetScreenCount() <= 1 )
195  aSheet->GetScreen()->SetFileName( newFilename );
196 
197  try
198  {
199  pi->Save( newFilename, aSheet->GetScreen(), &Kiway() );
200  }
201  catch( const IO_ERROR& ioe )
202  {
203  msg.Printf( _( "Error occurred saving schematic file \"%s\"." ), newFilename );
204  DisplayErrorMessage( this, msg, ioe.What() );
205 
206  msg.Printf( _( "Failed to save schematic \"%s\"" ), newFilename );
207  AppendMsgPanel( wxEmptyString, msg, CYAN );
208 
209  return false;
210  }
211 
212  // If the the associated screen is shared by more than one sheet, remove the
213  // screen and reload the file to a new screen. Failure to do this will trash
214  // the screen reference counting in complex hierarchies.
215  if( aSheet->GetScreenCount() > 1 )
216  {
217  aSheet->SetScreen( NULL );
218  loadFromFile = true;
219  }
220  }
221  }
222 
223  wxFileName userFileName = dlg.GetFileName();
224  userFileName.SetExt( SchematicFileExtension );
225  aSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
226 
227  if( useScreen )
228  {
229  aSheet->SetScreen( useScreen );
230  }
231  else if( loadFromFile )
232  {
233  try
234  {
235  aSheet = pi->Load( newFilename, &Kiway(), aSheet );
236 
237  if( !pi->GetError().IsEmpty() )
238  {
239  DisplayErrorMessage( this,
240  _( "The entire schematic could not be loaded.\n"
241  "Errors occurred loading hierarchical sheets." ),
242  pi->GetError() );
243  }
244  }
245  catch( const IO_ERROR& ioe )
246  {
247  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), newFilename );
248  DisplayErrorMessage( this, msg, ioe.What() );
249 
250  msg.Printf( _( "Failed to load schematic \"%s\"" ), newFilename );
251  AppendMsgPanel( wxEmptyString, msg, CYAN );
252 
253  return false;
254  }
255  }
256 
257  aSheet->SetFileNameSize( dlg.GetFileNameTextSize() );
258  aSheet->SetName( dlg.GetSheetName() );
259  aSheet->SetSheetNameSize( dlg.GetSheetNameTextSize() );
260 
261  if( aSheet->GetName().IsEmpty() )
262  aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ),
263  (long unsigned) aSheet->GetTimeStamp() ) );
264 
265  // Make sure the sheet changes do not cause any recursion.
266  SCH_SHEET_LIST sheetHierarchy( aSheet );
267 
268  // Make sure files have fully qualified path and file name.
269  wxFileName destFn = aHierarchy->Last()->GetFileName();
270 
271  if( destFn.IsRelative() )
272  destFn.MakeAbsolute( Prj().GetProjectPath() );
273 
274  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
275  {
276  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
277  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
278  "the schematic hierarchy." ),
279  newFilename );
280  DisplayError( this, msg );
281  return false;
282  }
283 
284  // Check to make sure the symbols have been remapped to the symbol library table.
285  SCH_SCREENS newScreens( aSheet );
286 
287  if( newScreens.HasNoFullyDefinedLibIds() )
288  {
289  msg.Printf(_( "The schematic \"%s\" has not been remapped to the symbol\nlibrary table. "
290  " The project this schematic belongs to must first be remapped\nbefore it "
291  "can be imported into the current project." ), fileName.GetFullName() );
292 
293  DisplayInfoMessage( this, msg );
294  return false;
295  }
296 
297  if( aClearAnnotationNewItems )
298  *aClearAnnotationNewItems = clearAnnotation;
299 
301  m_canvas->SetIgnoreMouseEvents( false );
302 
303  GetCanvas()->GetView()->Update( aSheet );
304 
305  OnModify();
306 
307  return true;
308 }
309 
310 
311 /* Move selected sheet with the cursor.
312  * Callback function used by m_mouseCaptureCallback.
313  * Note also now this function is called only when resizing the sheet
314  * But the (very small code) relative to sheet move is still present here
315  */
316 static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
317  bool aErase )
318 {
319  BASE_SCREEN* screen = aPanel->GetScreen();
320  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( screen->GetCurItem() );
321 
322  if( sheet == nullptr ) // Be sure we are using the right object
323  return;
324 
325  wxPoint pos = sheet->GetPosition();
326 
327  int width = aPanel->GetParent()->GetCrossHairPosition().x - pos.x;
328  int height = aPanel->GetParent()->GetCrossHairPosition().y - pos.y;
329 
330  // If the sheet doesn't have any pins, clamp the minimum size to the default values.
331  width = ( width < MIN_SHEET_WIDTH ) ? MIN_SHEET_WIDTH : width;
332  height = ( height < MIN_SHEET_HEIGHT ) ? MIN_SHEET_HEIGHT : height;
333 
334  if( sheet->HasPins() )
335  {
336  int gridSizeX = KiROUND( screen->GetGridSize().x );
337  int gridSizeY = KiROUND( screen->GetGridSize().y );
338 
339  // If the sheet has pins, use the pin positions to clamp the minimum width and height.
340  height = ( height < sheet->GetMinHeight() + gridSizeY ) ?
341  sheet->GetMinHeight() + gridSizeY : height;
342  width = ( width < sheet->GetMinWidth() + gridSizeX ) ?
343  sheet->GetMinWidth() + gridSizeX : width;
344  }
345 
346  wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
347  wxPoint( pos.x + width, pos.y + height ) );
348  sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
349 
350  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
351  auto view = panel->GetView();
352 
353  view->Hide( sheet );
354  view->ClearPreview();
355  view->AddToPreview( sheet->Clone() );
356 }
357 
358 
359 // Complete sheet move.
360 static void ExitSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
361 {
362  SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
363  SCH_ITEM* item = screen->GetCurItem();
364 
365  SCH_EDIT_FRAME* parent = (SCH_EDIT_FRAME*) aPanel->GetParent();
366 
367  if( (item == NULL) || (item->Type() != SCH_SHEET_T) || (parent == NULL) )
368  return;
369 
370  parent->SetRepeatItem( NULL );
371 
372  if( item->IsNew() )
373  {
374  delete item;
375  }
376  else if( item->IsMoving() || item->IsResized() )
377  {
378  parent->RemoveFromScreen( item );
379  delete item;
380 
381  item = parent->GetUndoItem();
382 
383  wxCHECK_RET( item != NULL, wxT( "Cannot restore undefined last sheet item." ) );
384 
385  parent->AddToScreen( item );
386 
387  // the owner of item is no more parent, this is the draw list of screen:
388  parent->SetUndoItem( NULL );
389 
390  item->ClearFlags();
391  }
392  else
393  {
394  item->ClearFlags();
395  }
396 
397  auto panel = static_cast<SCH_DRAW_PANEL*>( aPanel );
398  auto view = panel->GetView();
399  view->ClearPreview();
400 
401  screen->SetCurItem( NULL );
402 }
403 
404 
405 // Create hierarchy sheet.
407 {
408  SetRepeatItem( NULL );
409 
410  SCH_SHEET* sheet = new SCH_SHEET( GetCrossHairPosition() );
411 
412  sheet->SetFlags( IS_NEW | IS_RESIZED );
413  sheet->SetTimeStamp( GetNewTimeStamp() );
414  sheet->SetParent( GetScreen() );
415  sheet->SetScreen( NULL );
416 
417  // need to check if this is being added to the GetDrawItems().
418  // also need to update the hierarchy, if we are adding
419  // a sheet to a screen that already has multiple instances (!)
420  GetScreen()->SetCurItem( sheet );
422  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
423  m_canvas->CrossHairOff( aDC );
424 
426 
428  m_canvas->CrossHairOn( aDC );
429 
430  return sheet;
431 }
432 
433 
434 void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
435 {
436  if( aSheet == NULL || aSheet->IsNew() )
437  return;
438 
439  wxCHECK_RET( aSheet->Type() == SCH_SHEET_T,
440  wxString::Format( wxT( "Cannot perform sheet resize on %s object." ),
441  GetChars( aSheet->GetClass() ) ) );
442 
443  m_canvas->CrossHairOff( aDC );
446  m_canvas->CrossHairOn( aDC );
447 
448  SetUndoItem( aSheet );
449  aSheet->SetFlags( IS_RESIZED );
450 
452  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
453 
454  if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
455  SetUndoItem( aSheet );
456 }
457 
458 
460 {
461  if( aSheet == NULL )
462  return;
463 
464  // Save old sheet in undo list if not already in edit, or moving.
465  if( aSheet->GetFlags() == 0 )
466  SaveCopyInUndoList( aSheet, UR_CHANGED );
467 
468  // Rotate the sheet on itself. Sheets do not have a anchor point.
469  // Rotation is made around it center
470  wxPoint rotPoint = aSheet->GetBoundingBox().Centre();
471 
472  // Keep this rotation point on the grid, otherwise all items of this sheet
473  // will be moved off grid
474  rotPoint = GetNearestGridPosition( rotPoint );
475 
476  // rotate CCW, or CW. to rotate CW, rotate 3 times
477  aSheet->Rotate( rotPoint );
478 
479  if( !aRotCCW )
480  {
481  aSheet->Rotate( rotPoint );
482  aSheet->Rotate( rotPoint );
483  }
484 
485  GetCanvas()->GetView()->Update( aSheet );
486  OnModify();
487 }
488 
489 
490 void SCH_EDIT_FRAME::MirrorSheet( SCH_SHEET* aSheet, bool aFromXaxis )
491 {
492  if( aSheet == NULL )
493  return;
494 
495  // Save old sheet in undo list if not already in edit, or moving.
496  if( aSheet->GetFlags() == 0 )
497  SaveCopyInUndoList( aSheet, UR_CHANGED );
498 
499  // Mirror the sheet on itself. Sheets do not have a anchor point.
500  // Mirroring is made around it center
501  wxPoint mirrorPoint = aSheet->GetBoundingBox().Centre();
502 
503  if( aFromXaxis ) // mirror relative to Horizontal axis
504  aSheet->MirrorX( mirrorPoint.y );
505  else // Mirror relative to vertical axis
506  aSheet->MirrorY( mirrorPoint.x );
507 
508  GetCanvas()->GetView()->Update( aSheet );
509  OnModify();
510 }
virtual BASE_SCREEN * GetScreen()=0
Definition of the SCH_SHEET class for Eeschema.
static void ExitSheet(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Definition: sheet.cpp:360
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1488
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
bool IsMoving() const
Definition: base_struct.h:221
bool IsResized() const
Definition: base_struct.h:225
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:578
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:259
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
This file is part of the common library.
bool IsNew() const
Definition: base_struct.h:219
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:467
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:301
void RemoveFromScreen(SCH_ITEM *aItem)
Remove an item from the screen (and view)
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:131
wxPoint GetResizePosition() const
Return the position of the lower right corner of the sheet in drawing units.
Definition: sch_sheet.cpp:904
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:459
SCH_ITEM * GetUndoItem() const
Schematic editor (Eeschema) main window.
SCH_SCREEN * LastScreen() const
Function LastScreen.
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:279
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:45
#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:114
virtual EDA_DRAW_FRAME * GetParent() const =0
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_sheet.h:251
SCH_SHEET * CreateSheet(wxDC *DC)
Definition: sheet.cpp:406
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_sheet.cpp:514
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_sheet.cpp:704
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:216
SCH_ITEM * GetCurItem() const
Return the currently selected SCH_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: sch_screen.h:196
virtual void CrossHairOn(wxDC *DC=nullptr)
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
const std::string SchematicFileExtension
SCH_DRAW_PANEL * GetCanvas() const override
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 ClearPreview()
Definition: sch_view.cpp:95
virtual 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:316
The common library.
virtual void CrossHairOff(wxDC *DC=nullptr)
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...
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:118
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...
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:547
KIGFX::SCH_VIEW * GetView() const
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:680
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:661
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
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:434
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:123
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return 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
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:98
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
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 MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_sheet.cpp:716
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
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
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:48
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:115
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void MirrorSheet(SCH_SHEET *aSheet, bool aFromXaxis)
Mirror a hierarchical sheet.
Definition: sheet.cpp:490
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:129
void SetModify()
Definition: base_screen.h:324
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
wxString GetName() const
Definition: sch_sheet.h:267
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:277
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:245
wxPoint GetCrossHairPosition(bool aInvertY=false) const
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:76
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:295
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:736