KiCad PCB EDA Suite
sch_base_frame.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) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2015-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 
25 #include <base_units.h>
26 #include <kiway.h>
27 #include <sch_draw_panel.h>
28 #include <sch_view.h>
29 #include <sch_painter.h>
31 #include <confirm.h>
33 #include <class_library.h>
34 #include <eeschema_id.h>
35 #include <lib_edit_frame.h>
36 #include <viewlib_frame.h>
37 #include <sch_base_frame.h>
38 #include <symbol_lib_table.h>
39 #include <dialog_configure_paths.h>
40 
42 
43 
44 
45 LIB_ALIAS* SchGetLibAlias( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
46  wxWindow* aParent, bool aShowErrorMsg )
47 {
48  // wxCHECK_MSG( aLibId.IsValid(), NULL, "LIB_ID is not valid." );
49  wxCHECK_MSG( aLibTable, NULL, "Invalid symbol library table." );
50 
51  LIB_ALIAS* alias = NULL;
52 
53  try
54  {
55  alias = aLibTable->LoadSymbol( aLibId );
56 
57  if( !alias && aCacheLib )
58  alias = aCacheLib->FindAlias( aLibId );
59  }
60  catch( const IO_ERROR& ioe )
61  {
62  if( aShowErrorMsg )
63  {
64  wxString msg;
65 
66  msg.Printf( _( "Could not load symbol \"%s\" from library \"%s\"." ),
67  aLibId.GetLibItemName().wx_str(), aLibId.GetLibNickname().wx_str() );
68  DisplayErrorMessage( aParent, msg, ioe.What() );
69  }
70  }
71 
72  return alias;
73 }
74 
75 
76 LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
77  wxWindow* aParent, bool aShowErrorMsg )
78 {
79  LIB_ALIAS* alias = SchGetLibAlias( aLibId, aLibTable, aCacheLib, aParent, aShowErrorMsg );
80 
81  return ( alias ) ? alias->GetPart() : NULL;
82 }
83 
84 
85 // Static members:
86 
87 SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
88  FRAME_T aWindowType, const wxString& aTitle,
89  const wxPoint& aPosition, const wxSize& aSize, long aStyle,
90  const wxString& aFrameName ) :
91  EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition,
92  aSize, aStyle, aFrameName )
93 {
94  createCanvas();
95 
96  m_zoomLevelCoeff = 11.0; // Adjusted to roughly displays zoom level = 1
97  // when the screen shows a 1:1 image
98  // obviously depends on the monitor,
99  // but this is an acceptable value
102 }
103 
104 
106 {
107 }
108 
109 
110 void SCH_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
111 {
112  wxMenuBar* menuBar = GetMenuBar();
113  EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
114  EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = gal_canvas->GetBackend();
115 
116  struct { int menuId; int galType; } menuList[] =
117  {
120  };
121 
122  for( auto ii: menuList )
123  {
124  wxMenuItem* item = menuBar->FindItem( ii.menuId );
125  if( ii.galType == canvasType )
126  {
127  item->Check( true );
128  }
129  }
130 }
131 
132 
133 void SCH_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
134 {
135  auto new_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
136 
137  if( aEvent.GetId() == ID_MENU_CANVAS_CAIRO )
139 
140  if( m_canvasType == new_type )
141  return;
142 
143  GetGalCanvas()->SwitchBackend( new_type );
144  m_canvasType = new_type;
145 }
146 
147 
148 void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
149 {
150  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
151 
152  viewlibFrame->PushPreferences( m_canvas );
153 
154  // On Windows, Raise() does not bring the window on screen, when iconized
155  if( viewlibFrame->IsIconized() )
156  viewlibFrame->Iconize( false );
157 
158  viewlibFrame->Show( true );
159  viewlibFrame->Raise();
160 }
161 
162 
164 {
166 }
167 
168 
170 {
172 }
173 
174 
175 void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
176 {
177  GetScreen()->SetPageSettings( aPageSettings );
178 }
179 
180 
182 {
183  return GetScreen()->GetPageSettings();
184 }
185 
186 
187 const wxSize SCH_BASE_FRAME::GetPageSizeIU() const
188 {
189  // GetSizeIU is compile time dependent:
190  return GetScreen()->GetPageSettings().GetSizeIU();
191 }
192 
193 
194 const wxPoint& SCH_BASE_FRAME::GetAuxOrigin() const
195 {
196  wxASSERT( GetScreen() );
197  return GetScreen()->GetAuxOrigin();
198 }
199 
200 
201 void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition )
202 {
203  wxASSERT( GetScreen() );
204  GetScreen()->SetAuxOrigin( aPosition );
205 }
206 
207 
209 {
210  wxASSERT( GetScreen() );
211  return GetScreen()->GetTitleBlock();
212 }
213 
214 
215 void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
216 {
217  wxASSERT( GetScreen() );
218  GetScreen()->SetTitleBlock( aTitleBlock );
219 }
220 
221 
223 {
224  wxString line;
225  int dx, dy;
226  BASE_SCREEN* screen = GetScreen();
227 
228  if( !screen )
229  return;
230 
232 
233  // Display absolute coordinates:
234  double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
235  double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
236 
237  if ( GetUserUnits() == MILLIMETRES )
238  {
239  dXpos = RoundTo0( dXpos, 100.0 );
240  dYpos = RoundTo0( dYpos, 100.0 );
241  }
242 
243  wxString absformatter;
244  wxString locformatter;
245 
246  switch( GetUserUnits() )
247  {
248  case INCHES:
249  absformatter = wxT( "X %.3f Y %.3f" );
250  locformatter = wxT( "dx %.3f dy %.3f dist %.3f" );
251  break;
252 
253  case MILLIMETRES:
254  absformatter = wxT( "X %.2f Y %.2f" );
255  locformatter = wxT( "dx %.2f dy %.2f dist %.2f" );
256  break;
257 
258  case UNSCALED_UNITS:
259  absformatter = wxT( "X %f Y %f" );
260  locformatter = wxT( "dx %f dy %f dist %f" );
261  break;
262 
263  case DEGREES:
264  wxASSERT( false );
265  break;
266  }
267 
268  line.Printf( absformatter, dXpos, dYpos );
269  SetStatusText( line, 2 );
270 
271  // Display relative coordinates:
272  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
273  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
274 
275  dXpos = To_User_Unit( GetUserUnits(), dx );
276  dYpos = To_User_Unit( GetUserUnits(), dy );
277 
278  if( GetUserUnits() == MILLIMETRES )
279  {
280  dXpos = RoundTo0( dXpos, 100.0 );
281  dYpos = RoundTo0( dYpos, 100.0 );
282  }
283 
284  // We already decided the formatter above
285  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
286  SetStatusText( line, 3 );
287 
288  // refresh units display
289  DisplayUnitsMsg();
290 }
291 
292 
293 void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
294 {
295  DIALOG_CONFIGURE_PATHS dlg( this, nullptr );
296  dlg.ShowModal();
297 }
298 
299 
300 void SCH_BASE_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent )
301 {
303 }
304 
305 
306 LIB_ALIAS* SCH_BASE_FRAME::GetLibAlias( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowError )
307 {
308  PART_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL;
309 
310  return SchGetLibAlias( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowError );
311 }
312 
313 
314 LIB_PART* SCH_BASE_FRAME::GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowErrorMsg )
315 {
316  PART_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL;
317 
318  return SchGetLibPart( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowErrorMsg );
319 }
320 
321 
322 bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
323 {
324  wxString msg;
325  bool success = true;
326 
327  if( aGlobal )
328  {
329  try
330  {
332  }
333  catch( const IO_ERROR& ioe )
334  {
335  success = false;
336  msg.Printf( _( "Error saving global symbol library table:\n\n%s" ), ioe.What() );
337  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
338  }
339  }
340 
341  if( aProject && !Prj().GetProjectName().IsEmpty() )
342  {
343  wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
344 
345  try
346  {
347  Prj().SchSymbolLibTable()->Save( fn.GetFullPath() );
348  }
349  catch( const IO_ERROR& ioe )
350  {
351  success = false;
352  msg.Printf( _( "Error saving project-specific symbol library table:\n\n%s" ), ioe.What() );
353  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
354  }
355  }
356 
357  return success;
358 }
359 
360 
361 // Set the zoom level to show the contents of the view.
362 void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
363 {
364  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
365  KIGFX::VIEW* view = GetGalCanvas()->GetView();
366 
367  BOX2I bBox = GetDocumentExtents();
368 
369  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
370  VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
371 
372  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
373  {
374  bBox = galCanvas->GetDefaultViewBBox();
375  }
376 
377  VECTOR2D vsize = bBox.GetSize();
378  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
379  fabs( vsize.y / screenSize.y ) );
380 
381  // Reserve a 10% margin around component bounding box.
382  double margin_scale_factor = 1.1;
383 
384  // Leave 20% for library editors & viewers
388  {
389  margin_scale_factor = 1.2;
390  }
391 
392  scale /= margin_scale_factor;
393 
394  GetScreen()->SetScalingFactor( 1 / scale );
395 
396  view->SetScale( scale );
397  view->SetCenter( bBox.Centre() );
398 
399  // Take scrollbars into account
400  VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
401  view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
402  galCanvas->Refresh();
403 }
404 
405 
406 // Set the zoom level to show the area of aRect
408 {
409  KIGFX::VIEW* view = GetGalCanvas()->GetView();
410  BOX2I selectionBox ( aRect.GetPosition(), aRect.GetSize() );
411 
412  VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
413 
414  if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
415  return;
416 
417  VECTOR2D vsize = selectionBox.GetSize();
418  double scale;
419  double ratio = std::max( fabs( vsize.x / screenSize.x ),
420  fabs( vsize.y / screenSize.y ) );
421 
422  scale = view->GetScale() / ratio;
423 
424  GetScreen()->SetScalingFactor( 1 / scale );
425 
426  view->SetScale( scale );
427  view->SetCenter( selectionBox.Centre() );
428  GetGalCanvas()->Refresh();
429 }
430 
431 
432 void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
433 {
434  KIGFX::GAL* gal = GetCanvas()->GetGAL();
435 
436  double selectedZoom = GetScreen()->GetZoom();
437  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
438  double scale = 1.0 / ( zoomFactor * selectedZoom );
439 
440  if( aCenterPoint != wxPoint( 0, 0 ) )
441  GetCanvas()->GetView()->SetScale( scale, aCenterPoint );
442  else
443  GetCanvas()->GetView()->SetScale( scale );
444 
445  if( aWarpPointer )
447 
448  GetCanvas()->Refresh();
449 }
450 
451 
452 void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
453 {
454  KIGFX::GAL* gal = GetCanvas()->GetGAL();
455 
456  double selectedZoom = GetScreen()->GetZoom();
457  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
458  double scale = 1.0 / ( zoomFactor * selectedZoom );
459 
460  GetCanvas()->GetView()->SetScale( scale );
461 
462  GetGalCanvas()->Refresh();
463 }
464 
465 
466 void SCH_BASE_FRAME::CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
467 {
468  GetCanvas()->GetView()->SetCenter( aCenterPoint );
469 
470  if( aWarpPointer )
471  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
472 
473  GetGalCanvas()->Refresh();
474 }
475 
476 
478 {
479  // Currently: just refresh the screen
480  GetCanvas()->Refresh();
481 }
482 
483 
485 {
486  return static_cast<SCH_DRAW_PANEL*>( GetGalCanvas() );
487 }
488 
489 
491 {
492  KIGFX::PAINTER* painter = GetGalCanvas()->GetView()->GetPainter();
493  return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( painter->GetSettings() );
494 }
495 
496 
497 bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
498  int aExplicitCommand )
499 {
501 
502  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
503  return false;
504 
505  if( aExplicitCommand == 0 )
506  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
507  else
508  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
509 
510  if( block->GetCommand() == 0 )
511  return false;
512 
513  switch( block->GetCommand() )
514  {
515  case BLOCK_IDLE:
516  break;
517 
518  case BLOCK_MOVE: // Move
519  case BLOCK_DRAG: // Drag (block defined)
520  case BLOCK_DRAG_ITEM: // Drag from a drag item command
521  case BLOCK_DUPLICATE: // Duplicate
522  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
523  case BLOCK_DELETE: // Delete
524  case BLOCK_COPY: // Copy
525  case BLOCK_FLIP: // Flip
526  case BLOCK_ZOOM: // Window Zoom
527  case BLOCK_MIRROR_X:
528  case BLOCK_MIRROR_Y: // mirror
529  case BLOCK_PRESELECT_MOVE: // Move with preselection list
530  block->InitData( m_canvas, aPosition );
532  break;
533 
534  case BLOCK_PASTE:
535  {
536  block->InitData( m_canvas, aPosition );
538 
539  wxRect bounds( 0, 0, 0, 0 );
540 
541  for( unsigned i = 0; i < block->GetCount(); ++i )
542  bounds.Union( block->GetItem( i )->GetBoundingBox() );
543 
544  block->SetOrigin( bounds.GetPosition() );
545  block->SetSize( bounds.GetSize() );
546  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
547 
548  if( block->GetCount() == 0 ) // No data to paste
549  {
550  DisplayError( this, _( "Nothing to paste" ), 20 );
553  block->SetState( STATE_NO_BLOCK );
554  block->SetMessageBlock( this );
555  return true;
556  }
557 
558  if( !m_canvas->IsMouseCaptured() )
559  {
560  block->ClearItemsList();
561  wxFAIL_MSG( "SCH_BASE_FRAME::HandleBlockBegin() error: m_mouseCaptureCallback NULL" );
562  block->SetState( STATE_NO_BLOCK );
563  block->SetMessageBlock( this );
564  return true;
565  }
566 
567  block->SetState( STATE_BLOCK_MOVE );
568  block->SetFlags( IS_MOVED );
569  m_canvas->CallMouseCapture( aDC, aPosition, false );
570  m_canvas->Refresh();
571  }
572  break;
573 
574  default:
575  wxFAIL_MSG( wxString::Format( "SCH_BASE_FRAME::HandleBlockBegin() unknown command: %s",
576  block->GetCommand() ) );
577  break;
578  }
579 
580  block->SetMessageBlock( this );
581  return true;
582 }
583 
585 {
587 
588  // Allows only a CAIRO or OPENGL canvas:
592 
593  m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
595 
596  m_useSingleCanvasPane = true;
597 
598  SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
599  UseGalCanvas( true );
600 }
601 
602 
603 void SCH_BASE_FRAME::RefreshItem( SCH_ITEM* aItem, bool isAddOrDelete )
604 {
605  EDA_ITEM* parent = aItem->GetParent();
606 
607  if( aItem->Type() == SCH_SHEET_PIN_T )
608  {
609  // Sheet pins aren't in the view. Refresh their parent.
610  if( parent )
611  GetCanvas()->GetView()->Update( parent );
612  }
613  else
614  {
615  if( !isAddOrDelete )
616  GetCanvas()->GetView()->Update( aItem );
617 
618  // Component children are drawn from their parents. Mark them for re-paint.
619  if( parent && parent->Type() == SCH_COMPONENT_T )
620  GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
621  }
622 
623  GetCanvas()->Refresh();
624 }
625 
626 
628 {
629  GetScreen()->Append( aItem );
630  GetCanvas()->GetView()->Add( aItem );
631  RefreshItem( aItem, true ); // handle any additional parent semantics
632 }
633 
634 
636 {
637  for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() )
638  {
639  GetCanvas()->GetView()->Add( item );
640  RefreshItem( item, true ); // handle any additional parent semantics
641  }
642 
643  GetScreen()->Append( aItems );
644 }
645 
646 
648 {
649  GetCanvas()->GetView()->Remove( aItem );
650  GetScreen()->Remove( aItem );
651  RefreshItem( aItem, true ); // handle any additional parent semantics
652 }
653 
654 
656 {
657  auto screen = GetScreen();
658  auto gal = GetGalCanvas()->GetGAL();
659 
660  auto gs = screen->GetGridSize();
661  gal->SetGridSize( VECTOR2D( gs.x, gs.y ));
663 }
LIB_ALIAS * LoadSymbol(const wxString &aNickname, const wxString &aAliasName)
Load a LIB_ALIAS having aAliasName from the library given by aNickname.
void OnUpdateSwitchCanvas(wxUpdateUIEvent &aEvent)
Update UI called when switches currently used canvas (Cairo / OpenGL).
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
virtual void RedrawScreen2(const wxPoint &posBefore) override
Put the crosshair back to the screen position it had before zooming.
static const wxString & GetSymbolLibTableFileName()
int m_repeatDeltaLabel
the increment value of labels like bus members when they are repeated
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
const wxPoint & GetAuxOrigin() const
Definition: sch_screen.h:133
const VECTOR2D & GetCenter() const
Function GetCenter() Returns the center point of this VIEW (in world space coordinates) ...
Definition: view.h:339
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Part library alias object definition.
virtual void Zoom_Automatique(bool aWarpPointer) override
Redraw the screen with best zoom level and the best centering that shows all the page or the board...
SCH_BASE_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aWindowType, const wxString &aTitle, const wxPoint &aPosition, const wxSize &aSize, long aStyle, const wxString &aFrameName)
static S3D_CACHE * cache
Definition: export_vrml.cpp:64
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0) override
Initialize a block command.
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
virtual void OnEditSymbolLibTable(wxCommandEvent &aEvent)
void OnOpenLibraryViewer(wxCommandEvent &event)
Open the library viewer only to browse library contents.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:259
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:943
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
virtual void HardRedraw() override
Rebuild the GAL and redraws the screen.
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
double RoundTo0(double x, double precision)
Round to the nearest precision.
Definition: common.cpp:228
virtual int BlockCommand(EDA_KEY aKey)
Return the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the keys pressed (ALT...
double GetWorldScale() const
Get the world scale.
const wxSize GetSize() const
Definition: eda_rect.h:101
#define DEFAULT_REPEAT_LABEL_INC
the default value (overwritten by the eeschema config)
Definition: general.h:49
virtual bool SwitchBackend(GAL_TYPE aGalType)
Function SwitchBackend Switches method of rendering graphics.
void OnConfigurePaths(wxCommandEvent &aEvent)
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
Definition: draw_frame.h:176
LIB_ALIAS * SchGetLibAlias(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
Load symbol from symbol library table.
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
void RemoveFromScreen(SCH_ITEM *aItem)
Remove an item from the screen (and view)
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates...
Definition: view.cpp:474
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1442
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void InvokeSchEditSymbolLibTable(KIWAY *aKiway, wxWindow *aParent)
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:375
wxPoint m_repeatStep
the increment value of the position of an item when it is repeated
virtual void Window_Zoom(EDA_RECT &aRect) override
EDA_ITEM * GetParent() const
Definition: base_struct.h:211
void ShowSelectionArea(bool aShow=true)
Definition: sch_view.cpp:159
BLOCK_COMMAND_T
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
T * begin() const
Definition: dlist.h:218
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: sch_screen.h:127
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:176
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
void SetGalCanvas(EDA_DRAW_PANEL_GAL *aPanel)
Definition: draw_frame.h:926
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
EDA_ITEM * GetItem(unsigned aIndex)
void SetAuxOrigin(const wxPoint &aPosition)
Definition: sch_screen.h:134
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Item needs to be redrawn.
Definition: view_item.h:61
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Push preferences from a parent window to a child window.
const Vec & GetSize() const
Definition: box2.h:187
bool m_useSingleCanvasPane
Definition: draw_frame.h:98
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
SCH_ITEM * Next() const
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
virtual void InitBlockPasteInfos()
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Symbol library viewer main window.
Definition: viewlib_frame.h:44
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
void DisplayUnitsMsg()
Display current unit pane on the status bar.
coord_type GetWidth() const
Definition: box2.h:195
void SetState(BLOCK_STATE_T aState)
virtual void CenterOnCursor() const =0
Function CenterOnCursor() Sets the viewport center to the current cursor position and warps the curso...
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
wxString wx_str() const
Definition: utf8.cpp:51
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:308
Item is being added to the view.
Definition: view_item.h:60
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:394
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:600
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
void SetAuxOrigin(const wxPoint &aPosition) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void SyncView()
Mark all items for refresh.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:281
void SetScalingFactor(double iu_per_du)
Function SetScalingFactor sets the scaling factor of "internal unit per device unit".
Definition: common.h:161
SCH_DRAW_PANEL * GetCanvas() const override
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
virtual const BOX2I GetDocumentExtents() const
Define a library symbol object.
LIB_ALIAS * FindAlias(const wxString &aName) const
Find LIB_ALIAS by aName.
virtual ~SCH_BASE_FRAME()
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
bool saveSymbolLibTables(bool aGlobal, bool aProject)
Saves Symbol Library Tables to disk.
uint32_t EDA_KEY
Definition: common.h:74
void SetFlags(const STATUS_FLAGS aFlag)
Function SetFlags sets a status flag on each item in a block selector.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
#define DEFAULT_REPEAT_OFFSET_Y
the default Y value (overwritten by the eeschema config)
Definition: general.h:47
LIB_ALIAS * GetLibAlias(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowError=false)
Load symbol from symbol library table.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: sch_screen.h:138
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:1538
KIGFX::SCH_VIEW * GetView() const
void SetPageSettings(const PAGE_INFO &aPageSettings) override
virtual BOX2I GetDefaultViewBBox() const
Returns the bounding box of the view that should be used if model is not valid For example...
Definition: solve.cpp:178
Vec Centre() const
Definition: box2.h:77
const wxPoint GetPosition() const
Definition: eda_rect.h:113
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:136
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
#define DEFAULT_REPEAT_OFFSET_X
the default X value (overwritten by the eeschema config)
Definition: general.h:46
const VECTOR2D & GetGridSize() const
Returns the grid size.
LIB_PART * GetPart() const
Get the shared LIB_PART.
void AddToScreen(SCH_ITEM *aItem)
Add an item to the screen (and view)
const PAGE_INFO & GetPageSettings() const override
void UpdateStatusBar() override
Update the status bar information.
coord_type GetHeight() const
Definition: box2.h:196
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void SetSize(const wxSize &size)
Definition: eda_rect.h:126
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
const int scale
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer) override
Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterP...
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
BLOCK_STATE_T GetState() const
void Append(SCH_ITEM *aItem)
Definition: sch_screen.h:162
#define max(a, b)
Definition: auxiliary.h:86
void RefreshItem(SCH_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
const TITLE_BLOCK & GetTitleBlock() const override
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
double GetZoomFactor() const
Get the zoom factor.
Class SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:66
double GetScale() const
Function GetScale()
Definition: view.h:268
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:126
Definition of class LIB_EDIT_FRAME.
BLOCK_COMMAND_T GetCommand() const
virtual void CenterScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:925
LIB_PART * SchGetLibPart(const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aLibTable, PART_LIB *aCacheLib, wxWindow *aParent, bool aShowErrorMsg)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:345
bool IsType(FRAME_T aType) const
void InitData(EDA_DRAW_PANEL *Panel, const wxPoint &startpos)
Function InitData sets the initial values of a BLOCK_SELECTOR, before starting a block command...
Definition for part library class.
Class VIEW.
Definition: view.h:61
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
Object used to load, save, search, and otherwise manipulate symbol library files. ...
virtual void UpdateStatusBar()
Update the status bar information.
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...
unsigned GetCount() const
static wxString GetGlobalTableFileName()
Fetch the global symbol library table file name.
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
void OnSwitchCanvas(wxCommandEvent &aEvent)
switches currently used canvas ( Cairo / OpenGL).
void SetCommand(BLOCK_COMMAND_T aCommand)
Class GAL is the abstract interface for drawing on a 2D-surface.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113