KiCad PCB EDA Suite
eeschema/block.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) 2009 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2018 KiCad Developers, see change_log.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <fctsys.h>
31 #include <pgm_base.h>
32 #include <gr_basic.h>
33 #include <sch_draw_panel.h>
34 #include <confirm.h>
35 #include <sch_edit_frame.h>
36 
37 #include <general.h>
38 #include <class_library.h>
39 #include <lib_pin.h>
40 #include <list_operations.h>
41 #include <sch_bus_entry.h>
42 #include <sch_marker.h>
43 #include <sch_junction.h>
44 #include <sch_line.h>
45 #include <sch_no_connect.h>
46 #include <sch_text.h>
47 #include <sch_component.h>
48 #include <sch_sheet.h>
49 #include <sch_sheet_path.h>
50 #include <list_operations.h>
51 
53 #include <sch_view.h>
54 #include <view/view_group.h>
55 
56 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
57  const wxPoint& aPosition, bool aErase );
58 
60 {
61  int cmd = BLOCK_IDLE;
62 
63  switch( key )
64  {
65  default:
66  cmd = key & 0xFF;
67  break;
68 
69  case 0:
70  cmd = BLOCK_MOVE;
71  break;
72 
73  case GR_KB_SHIFT:
74  cmd = BLOCK_DUPLICATE;
75  break;
76 
77  case GR_KB_CTRL:
78  cmd = BLOCK_DRAG;
79  break;
80 
81  case GR_KB_SHIFTCTRL:
82  cmd = BLOCK_DELETE;
83  break;
84 
85  case MOUSE_MIDDLE:
86  cmd = BLOCK_ZOOM;
87  break;
88  }
89 
90  return cmd;
91 }
92 
93 
95 {
97 
98  block->GetItems().CopyList( m_blockItems.GetItems() );
100 }
101 
102 
104 {
106 
107  wxCHECK_RET( m_canvas->IsMouseCaptured(), "No block mouse capture callback is set" );
108 
109  if( block->GetCount() == 0 )
110  {
111  wxString msg;
112  msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ),
113  block->GetCommand(), block->GetState() );
114  wxFAIL_MSG( msg );
115  }
116 
117  block->SetState( STATE_BLOCK_STOP );
118 
119  switch( block->GetCommand() )
120  {
121  case BLOCK_DRAG: // Drag from mouse
122  case BLOCK_DRAG_ITEM: // Drag from a component selection and drag command
123  case BLOCK_MOVE:
124  case BLOCK_DUPLICATE: /* Duplicate */
125  if( m_canvas->IsMouseCaptured() )
126  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
127 
128  // If the block wasn't changed, don't update the schematic
129  if( block->GetMoveVector() == wxPoint( 0, 0 ) && !block->AppendUndo() )
130  {
131  // This calls the block-abort command routine on cleanup
132  m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor() );
133 
134  // We set the dangling ends to the block-scope, so we must set them back to
135  // schematic-socpe.
137  return;
138  }
139 
140  if( block->GetCommand() != BLOCK_DUPLICATE )
141  SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo(), block->GetMoveVector() );
142 
143  for( unsigned ii = 0; ii < block->GetItems().GetCount(); ii++ )
144  {
145  SCH_ITEM* item = static_cast<SCH_ITEM*>( block->GetItems().GetPickedItem( ii ) );
146  item->Move( block->GetMoveVector() );
147  item->SetFlags( IS_MOVED );
148  GetCanvas()->GetView()->Update( item, KIGFX::GEOMETRY );
149  }
150  break;
151 
152  case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
153  if( m_canvas->IsMouseCaptured() )
154  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
155 
156  DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() );
157 
158  SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo() );
159  break;
160 
161  case BLOCK_PASTE:
162  if( m_canvas->IsMouseCaptured() )
163  m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
164 
165  PasteListOfItems( DC );
166  break;
167 
168  default: // others are handled by HandleBlockEnd()
169  break;
170  }
171 
172  CheckListConnections( block->GetItems(), true );
173  block->ClearItemsList();
174  SchematicCleanUp( true );
176  OnModify();
177 
178  // clear dome flags and pointers
181  GetScreen()->SetCurItem( NULL );
182 
183  m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, false );
184 
187 }
188 
189 
191 {
192  bool nextcmd = false;
193  bool append = false;
195 
196  auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas);
197  auto view = panel->GetView();
198 
199  view->ShowSelectionArea( false );
200  view->ClearHiddenFlags();
201 
202  if( block->GetCount() )
203  {
204  BLOCK_STATE_T state = block->GetState();
205  BLOCK_COMMAND_T command = block->GetCommand();
206 
208 
209  block->SetState( state );
210  block->SetCommand( command );
212 
213  if( block->GetCommand() != BLOCK_ABORT
214  && block->GetCommand() != BLOCK_DUPLICATE
215  && block->GetCommand() != BLOCK_COPY
216  && block->GetCommand() != BLOCK_CUT
217  && block->GetCommand() != BLOCK_DELETE )
218  {
219  SetCrossHairPosition( block->GetEnd() );
221  }
222  }
223 
224  if( m_canvas->IsMouseCaptured() )
225  {
226  switch( block->GetCommand() )
227  {
228  case BLOCK_IDLE:
229  DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
230  break;
231 
232  case BLOCK_DRAG:
233  case BLOCK_DRAG_ITEM: // Drag from a drag command
234  case BLOCK_MOVE:
235  case BLOCK_DUPLICATE:
237  if( block->GetCommand() == BLOCK_DRAG_ITEM )
238  {
239  // This is a drag command, not a mouse block command
240  // Only this item is put in list
241  if( GetScreen()->GetCurItem() )
242  {
243  ITEM_PICKER picker;
244  picker.SetItem( GetScreen()->GetCurItem() );
245  block->PushItem( picker );
246  }
247  }
248  else if( block->GetCommand() != BLOCK_PRESELECT_MOVE )
249  {
250  // Collect all items in the locate block
252  }
253 
255 
256  if( block->GetCommand() == BLOCK_DUPLICATE )
257  {
258  DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() );
260  SaveCopyInUndoList( block->GetItems(), UR_NEW );
261  }
262 
263  if( block->GetCount() )
264  {
265  nextcmd = true;
266  block->SetState( STATE_BLOCK_MOVE );
267 
268  if( block->GetCommand() != BLOCK_DRAG && block->GetCommand() != BLOCK_DRAG_ITEM )
269  {
270  // Mark dangling pins at the edges of the block:
271  std::vector<DANGLING_END_ITEM> internalPoints;
272 
273  for( unsigned i = 0; i < block->GetCount(); ++i )
274  {
275  auto item = static_cast<SCH_ITEM*>( block->GetItem( i ) );
276  item->GetEndPoints( internalPoints );
277  }
278 
279  for( unsigned i = 0; i < block->GetCount(); ++i )
280  {
281  auto item = static_cast<SCH_ITEM*>( block->GetItem( i ) );
282  item->UpdateDanglingState( internalPoints );
283  }
284  }
285 
287  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
288  }
289  else
290  {
291  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
292  m_canvas->SetMouseCapture( NULL, NULL );
293  }
294  break;
295 
296  case BLOCK_CUT:
297  case BLOCK_DELETE:
299  DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
300 
301  // The CUT variant needs to copy the items from their originial position
302  if( ( block->GetCommand() == BLOCK_CUT ) && block->GetCount() )
303  {
304  wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
305  copyBlockItems( block->GetItems(), move_vector );
306  }
307 
308  // We set this in a while loop to catch any newly created items
309  // as a result of the delete (e.g. merged wires)
310  while( block->GetCount() )
311  {
312  DeleteItemsInList( block->GetItems(), append );
313  SchematicCleanUp( true );
314  OnModify();
315  block->ClearItemsList();
317  append = true;
318  }
319 
321  break;
322 
323  case BLOCK_COPY: // Save a copy of items in paste buffer
325  DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
326 
327  if( block->GetCount() )
328  {
329  wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
330  copyBlockItems( block->GetItems(), move_vector );
331  }
332 
333  block->ClearItemsList();
334  break;
335 
336  case BLOCK_ZOOM:
337  Window_Zoom( GetScreen()->m_BlockLocate );
338  break;
339 
340  default:
341  break;
342  }
343  }
344 
345  if( !nextcmd )
346  {
347  block->SetState( STATE_NO_BLOCK );
348  block->SetCommand( BLOCK_IDLE );
350  GetScreen()->SetCurItem( NULL );
351  m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
352  false );
353  }
354 
355  view->ShowSelectionArea( false );
356  view->ShowPreview( nextcmd );
357 
358  return nextcmd;
359 }
360 
361 
362 /* Traces the outline of the search block structures
363  * The entire block follows the cursor
364  */
365 static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
366  bool aErase )
367 {
368  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
369  KIGFX::SCH_VIEW* view = panel->GetView();
370  KIGFX::VIEW_GROUP* preview = view->GetPreview();
371 
372  BASE_SCREEN* screen = aPanel->GetScreen();
373  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
374  SCH_ITEM* schitem;
375 
376  block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
377 
378  preview->Clear();
379  view->SetVisible( preview, true );
380 
381  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
382  {
383  schitem = (SCH_ITEM*) block->GetItem( ii );
384  SCH_ITEM* copy = static_cast<SCH_ITEM*>( schitem->Clone() );
385 
386  copy->Move( block->GetMoveVector() );
387  copy->SetFlags( IS_MOVED );
388  preview->Add( copy );
389 
390  view->Hide( schitem );
391  }
392 
393  view->Update( preview );
394 }
395 
396 
397 void SCH_EDIT_FRAME::copyBlockItems( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMoveVector )
398 {
399  m_blockItems.ClearListAndDeleteItems(); // delete previous saved list, if exists
400 
401  wxRect bounds;
402 
403  if( aItemsList.GetCount() > 0 )
404  bounds = aItemsList.GetPickedItem( 0 )->GetBoundingBox();
405 
406  for( unsigned i = 1; i < aItemsList.GetCount(); ++i )
407  bounds.Union( aItemsList.GetPickedItem( i )->GetBoundingBox() );
408 
409  wxPoint center( ( bounds.GetLeft() + bounds.GetRight() ) / 2,
410  ( bounds.GetTop() + bounds.GetBottom() ) / 2 );
411  center = GetNearestGridPosition( center );
412 
413  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
414  {
415  // Clear m_Flag member of selected items:
416  aItemsList.GetPickedItem( ii )->ClearFlags();
417 
418  /* Make a copy of the original picked item. */
419  SCH_ITEM* copy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
420  copy->SetParent( NULL );
421  copy->SetFlags( copy->GetFlags() | UR_TRANSIENT );
422  copy->Move( -center );
423  ITEM_PICKER item( copy, UR_NEW );
424 
425  m_blockItems.PushItem( item );
426  }
427 }
428 
429 
431 {
432  unsigned i;
433  SCH_ITEM* item;
434  SCH_SHEET_LIST hierarchy( g_RootSheet ); // This is the entire schematic hierarcy.
435 
436  if( m_blockItems.GetCount() == 0 )
437  {
438  DisplayError( this, _( "No item to paste." ) );
439  return;
440  }
441 
442  wxFileName destFn = m_CurrentSheet->Last()->GetFileName();
443 
444  if( destFn.IsRelative() )
445  destFn.MakeAbsolute( Prj().GetProjectPath() );
446 
447  // Make sure any sheets in the block to be pasted will not cause recursion in
448  // the destination sheet. Moreover new sheets create new sheetpaths, and component
449  // alternante references must be created and cleared
450  bool hasSheetPasted = false;
451  // Keep trace of existing sheet paths. Paste block can modify this list
452  SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
453 
454  for( i = 0; i < m_blockItems.GetCount(); i++ )
455  {
456  item = (SCH_ITEM*) m_blockItems.GetItem( i );
457 
458  if( item->Type() == SCH_SHEET_T )
459  {
460  SCH_SHEET* sheet = (SCH_SHEET*)item;
461  wxFileName srcFn = sheet->GetFileName();
462 
463  if( srcFn.IsRelative() )
464  srcFn.MakeAbsolute( Prj().GetProjectPath() );
465 
466  SCH_SHEET_LIST sheetHierarchy( sheet );
467 
468  if( hierarchy.TestForRecursion( sheetHierarchy,
469  destFn.GetFullPath( wxPATH_UNIX ) ) )
470  {
471  wxString msg;
472 
473  msg.Printf( _( "The sheet changes cannot be made because the destination "
474  "sheet already has the sheet \"%s\" or one of it's subsheets "
475  "as a parent somewhere in the schematic hierarchy." ),
476  GetChars( sheet->GetFileName() ) );
477  DisplayError( this, msg );
478  return;
479  }
480 
481  // Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
482  // based sheet name and update the time stamp for each sheet in the block.
483  timestamp_t timeStamp = GetNewTimeStamp();
484 
485  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) );
486  sheet->SetTimeStamp( timeStamp );
487  hasSheetPasted = true;
488  }
489  }
490 
491  PICKED_ITEMS_LIST picklist;
492 
493  for( i = 0; i < m_blockItems.GetCount(); i++ )
494  {
495  item = DuplicateStruct( (SCH_ITEM*) m_blockItems.GetItem( i ) );
496 
497  // Creates data, and push it as new data in undo item list buffer
498  ITEM_PICKER picker( item, UR_NEW );
499  picklist.PushItem( picker );
500 
501  // Clear annotation and init new time stamp for the new components and sheets:
502  if( item->Type() == SCH_COMPONENT_T )
503  {
504  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
505  cmp->SetTimeStamp( GetNewTimeStamp() );
506 
507  // clear the annotation, but preserve the selected unit
508  int unit = cmp->GetUnit();
509  cmp->ClearAnnotation( NULL );
510  cmp->SetUnit( unit );
511  }
512  else if( item->Type() == SCH_SHEET_T )
513  {
514  ( (SCH_SHEET*) item )->SetTimeStamp( GetNewTimeStamp() );
515  }
516  }
517 
518  SaveCopyInUndoList( picklist, UR_NEW );
519 
520  for( i = 0; i < picklist.GetCount(); ++i )
521  {
522  item = (SCH_ITEM*) picklist.GetPickedItem( i );
523 
524  item->Move( GetScreen()->m_BlockLocate.GetMoveVector() );
525 
526  SetSchItemParent( item, GetScreen() );
527  AddToScreen( item );
528  }
529 
530  if( hasSheetPasted )
531  {
532  // We clear annotation of new sheet paths.
533  // Annotation of new components added in current sheet is already cleared.
534  SCH_SCREENS screensList( g_RootSheet );
535  screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
536  }
537 
538  // Clear flags for all items.
540 
541  OnModify();
542 }
543 
544 void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
545  bool aErase )
546 {
547  auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
548  auto area = panel->GetView()->GetSelectionArea();
549  auto frame = static_cast<EDA_BASE_FRAME*>(aPanel->GetParent());
550 
552  bool isLibEdit = frame->IsType( FRAME_SCH_LIB_EDITOR );
553 
554  block = &aPanel->GetScreen()->m_BlockLocate;
555  block->SetMoveVector( wxPoint( 0, 0 ) );
556  block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition( isLibEdit ) );
557  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
558 
559  panel->GetView()->ClearPreview();
560  panel->GetView()->ClearHiddenFlags();
561 
562  area->SetOrigin( block->GetOrigin() );;
563  area->SetEnd( block->GetEnd() );
564 
565  panel->GetView()->SetVisible( area );
566  panel->GetView()->Hide( area, false );
567  panel->GetView()->Update( area );
568 
569  if( block->GetState() == STATE_BLOCK_INIT )
570  {
571  if( block->GetWidth() || block->GetHeight() )
572  // 2nd point exists: the rectangle is not surface anywhere
573  block->SetState( STATE_BLOCK_END );
574  }
575 }
virtual BASE_SCREEN * GetScreen()=0
Definition of the SCH_SHEET class for Eeschema.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1497
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void SetTimeStamp(timestamp_t aNewTimeStamp)
Change the time stamp to aNewTimeStamp and updates the reference path.
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
#define MOUSE_MIDDLE
bool SchematicCleanUp(bool aAppend=false)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void ClearHiddenFlags()
Definition: sch_view.cpp:177
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
bool AppendUndo() const
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:52
virtual EDA_DRAW_FRAME * GetParent() const override
This file is part of the common library.
virtual void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList)
Function GetEndPoints adds the schematic item end points to aItemList if the item has end points...
void OnModify()
Must be called after a schematic change in order to set the "modify" flag of the current screen* and ...
void DuplicateItemsInList(SCH_SCREEN *screen, PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMoveVector)
KIGFX::PREVIEW::SELECTION_AREA * GetSelectionArea() const
Definition: sch_view.h:84
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
virtual int BlockCommand(EDA_KEY aKey) override
Return the block command internal code (BLOCK_MOVE, BLOCK_DUPLICATE...) corresponding to the keys pre...
void AbortBlockCurrentCommand(EDA_DRAW_PANEL *aPanel, wxDC *aDC)
Function AbortBlockCurrentCommand cancels the current block operation.
void SetMoveVector(const wxPoint &aMoveVector)
virtual void Window_Zoom(EDA_RECT &aRect) override
int GetHeight() const
Definition: eda_rect.h:118
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
void ShowSelectionArea(bool aShow=true)
Definition: sch_view.cpp:157
BLOCK_COMMAND_T
#define GR_KB_CTRL
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void ClearBlockCommand()
Definition: base_screen.h:501
virtual void HandleBlockPlace(wxDC *DC) override
Call after HandleBlockEnd, when a block command needs to be executed after the block is moved to its ...
EDA_ITEM * GetItem(unsigned aIndex)
BLOCK_STATE_T
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
virtual void CallEndMouseCapture(wxDC *aDC)
Function CallEndMouseCapture calls the end mouse capture callback.
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
KIGFX::VIEW_GROUP * GetPreview() const
Definition: sch_view.h:86
virtual EDA_DRAW_FRAME * GetParent() const =0
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetState(BLOCK_STATE_T aState)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
virtual bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList)
Function IsDanglingStateChanged tests the schematic item to aItemList to check if it&#39;s dangling state...
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
void CopyList(const PICKED_ITEMS_LIST &aSource)
Function CopyList copies all data from aSource to the list.
void InitBlockPasteInfos() override
Initialize the parameters used by the block paste command.
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes only the list of EDA_ITEM * pointers, AND the data printed b...
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
int UpdatePickList()
Add all the items in the screen within the block selection rectangle to the pick list.
Definition: sch_screen.cpp:873
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
SCH_ITEM * DuplicateStruct(SCH_ITEM *aDrawStruct, bool aClone=false)
Routine to create a new copy of given struct.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void SetEnd(int x, int y)
Definition: eda_rect.h:134
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...
SCH_DRAW_PANEL * GetCanvas() const override
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:131
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
void DrawAndSizingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for...
uint32_t EDA_KEY
Definition: common.h:73
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
void SetUnit(int aUnit)
Change the unit number to aUnit.
int GetUnit() const
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
#define GR_KB_SHIFT
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 Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
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:1530
void SetItem(EDA_ITEM *aItem)
void SelectBlockItems()
Create a list of items found when a block command is initiated.
Definition: sch_screen.cpp:729
KIGFX::SCH_VIEW * GetView() const
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:661
Definition: solve.cpp:178
const wxPoint GetEnd() const
Definition: eda_rect.h:114
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
unsigned GetCount() const
Function GetCount.
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
wxPoint GetLastCursorPosition() const
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void copyBlockItems(PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMoveVector)
Copy the list of block item.
Definition the SCH_COMPONENT class for Eeschema.
#define GR_KB_SHIFTCTRL
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
see class PGM_BASE
void CheckListConnections(PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
Adds junctions if needed to each item in the list after they have been moved.
BLOCK_SELECTOR m_blockItems
List of selected items.
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
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
BLOCK_STATE_T GetState() const
int GetToolId() const
Definition: draw_frame.h:519
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
void SetCurItem(SCH_ITEM *aItem)
Sets the currently selected object, m_CurrentItem.
Definition: sch_screen.h:204
size_t i
Definition: json11.cpp:597
void DeleteItemsInList(PICKED_ITEMS_LIST &aItemsList, bool aAppend=false)
Removes all items (and unused junctions that connect to them) and saves each in the undo list...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
int GetWidth() const
Definition: eda_rect.h:117
PICKED_ITEMS_LIST & GetItems()
void PasteListOfItems(wxDC *DC)
Paste a list of items from the block stack.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1476
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Definition: base_struct.h:142
BLOCK_COMMAND_T GetCommand() const
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:928
virtual bool HandleBlockEnd(wxDC *aDC) override
Handle the "end" of a block command, i.e.
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:561
Definition for part library class.
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
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.
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
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.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Implementation of the label properties dialog.
unsigned GetCount() const
void SetSchItemParent(SCH_ITEM *Struct, SCH_SCREEN *Screen)
static void DrawMovingBlockOutlines(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:523
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
void SetCommand(BLOCK_COMMAND_T aCommand)
wxPoint GetMoveVector() const
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
Color has changed.
Definition: view_item.h:57
void PushItem(ITEM_PICKER &aItem)
Function PushItem adds aItem to the list of items.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.