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_canvasTypeDirty = true; // force saving new canvas type in config
145  m_canvasType = new_type;
146 }
147 
148 
149 void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
150 {
151  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
152 
153  viewlibFrame->PushPreferences( m_canvas );
154 
155  // On Windows, Raise() does not bring the window on screen, when iconized
156  if( viewlibFrame->IsIconized() )
157  viewlibFrame->Iconize( false );
158 
159  viewlibFrame->Show( true );
160  viewlibFrame->Raise();
161 }
162 
163 
165 {
167 }
168 
169 
171 {
173 }
174 
175 
176 void SCH_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
177 {
178  GetScreen()->SetPageSettings( aPageSettings );
179 }
180 
181 
183 {
184  return GetScreen()->GetPageSettings();
185 }
186 
187 
188 const wxSize SCH_BASE_FRAME::GetPageSizeIU() const
189 {
190  // GetSizeIU is compile time dependent:
191  return GetScreen()->GetPageSettings().GetSizeIU();
192 }
193 
194 
196 {
197  wxASSERT( GetScreen() );
198  return GetScreen()->GetAuxOrigin();
199 }
200 
201 
202 void SCH_BASE_FRAME::SetAuxOrigin( const wxPoint& aPosition )
203 {
204  wxASSERT( GetScreen() );
205  GetScreen()->SetAuxOrigin( aPosition );
206 }
207 
208 
210 {
211  wxASSERT( GetScreen() );
212  return GetScreen()->GetTitleBlock();
213 }
214 
215 
216 void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
217 {
218  wxASSERT( GetScreen() );
219  GetScreen()->SetTitleBlock( aTitleBlock );
220 }
221 
222 
224 {
225  wxString line;
226  int dx, dy;
227  BASE_SCREEN* screen = GetScreen();
228 
229  if( !screen )
230  return;
231 
233 
234  // Display absolute coordinates:
235  double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
236  double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
237 
238  if ( GetUserUnits() == MILLIMETRES )
239  {
240  dXpos = RoundTo0( dXpos, 100.0 );
241  dYpos = RoundTo0( dYpos, 100.0 );
242  }
243 
244  wxString absformatter;
245  wxString locformatter;
246 
247  switch( GetUserUnits() )
248  {
249  case INCHES:
250  absformatter = wxT( "X %.3f Y %.3f" );
251  locformatter = wxT( "dx %.3f dy %.3f dist %.3f" );
252  break;
253 
254  case MILLIMETRES:
255  absformatter = wxT( "X %.2f Y %.2f" );
256  locformatter = wxT( "dx %.2f dy %.2f dist %.2f" );
257  break;
258 
259  case UNSCALED_UNITS:
260  absformatter = wxT( "X %f Y %f" );
261  locformatter = wxT( "dx %f dy %f dist %f" );
262  break;
263 
264  case DEGREES:
265  wxASSERT( false );
266  break;
267  }
268 
269  line.Printf( absformatter, dXpos, dYpos );
270  SetStatusText( line, 2 );
271 
272  // Display relative coordinates:
273  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
274  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
275 
276  dXpos = To_User_Unit( GetUserUnits(), dx );
277  dYpos = To_User_Unit( GetUserUnits(), dy );
278 
279  if( GetUserUnits() == MILLIMETRES )
280  {
281  dXpos = RoundTo0( dXpos, 100.0 );
282  dYpos = RoundTo0( dYpos, 100.0 );
283  }
284 
285  // We already decided the formatter above
286  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
287  SetStatusText( line, 3 );
288 
289  // refresh units display
290  DisplayUnitsMsg();
291 }
292 
293 
294 void SCH_BASE_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
295 {
296  DIALOG_CONFIGURE_PATHS dlg( this, nullptr );
297  dlg.ShowModal();
298 }
299 
300 
301 void SCH_BASE_FRAME::OnEditSymbolLibTable( wxCommandEvent& aEvent )
302 {
304 }
305 
306 
307 LIB_ALIAS* SCH_BASE_FRAME::GetLibAlias( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowError )
308 {
309  PART_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL;
310 
311  return SchGetLibAlias( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowError );
312 }
313 
314 
315 LIB_PART* SCH_BASE_FRAME::GetLibPart( const LIB_ID& aLibId, bool aUseCacheLib, bool aShowErrorMsg )
316 {
317  PART_LIB* cache = ( aUseCacheLib ) ? Prj().SchLibs()->GetCacheLibrary() : NULL;
318 
319  return SchGetLibPart( aLibId, Prj().SchSymbolLibTable(), cache, this, aShowErrorMsg );
320 }
321 
322 
323 bool SCH_BASE_FRAME::saveSymbolLibTables( bool aGlobal, bool aProject )
324 {
325  wxString msg;
326  bool success = true;
327 
328  if( aGlobal )
329  {
330  try
331  {
333  }
334  catch( const IO_ERROR& ioe )
335  {
336  success = false;
337  msg.Printf( _( "Error saving global symbol library table:\n\n%s" ), ioe.What() );
338  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
339  }
340  }
341 
342  if( aProject && !Prj().GetProjectName().IsEmpty() )
343  {
344  wxFileName fn( Prj().GetProjectPath(), SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
345 
346  try
347  {
348  Prj().SchSymbolLibTable()->Save( fn.GetFullPath() );
349  }
350  catch( const IO_ERROR& ioe )
351  {
352  success = false;
353  msg.Printf( _( "Error saving project-specific symbol library table:\n\n%s" ), ioe.What() );
354  wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
355  }
356  }
357 
358  return success;
359 }
360 
361 
362 // Set the zoom level to show the contents of the view.
363 void SCH_BASE_FRAME::Zoom_Automatique( bool aWarpPointer )
364 {
365  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
366  KIGFX::VIEW* view = GetGalCanvas()->GetView();
367 
368  BOX2I bBox = GetDocumentExtents();
369 
370  VECTOR2D scrollbarSize = VECTOR2D( galCanvas->GetSize() - galCanvas->GetClientSize() );
371  VECTOR2D screenSize = view->ToWorld( galCanvas->GetClientSize(), false );
372 
373  if( bBox.GetWidth() == 0 || bBox.GetHeight() == 0 )
374  {
375  bBox = galCanvas->GetDefaultViewBBox();
376  }
377 
378  VECTOR2D vsize = bBox.GetSize();
379  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
380  fabs( vsize.y / screenSize.y ) );
381 
382  // Reserve a 10% margin around component bounding box.
383  double margin_scale_factor = 1.1;
384 
385  // Leave 20% for library editors & viewers
389  {
390  margin_scale_factor = 1.2;
391  }
392 
393  scale /= margin_scale_factor;
394 
395  GetScreen()->SetScalingFactor( 1 / scale );
396 
397  view->SetScale( scale );
398  view->SetCenter( bBox.Centre() );
399 
400  // Take scrollbars into account
401  VECTOR2D worldScrollbarSize = view->ToWorld( scrollbarSize, false );
402  view->SetCenter( view->GetCenter() + worldScrollbarSize / 2.0 );
403  galCanvas->Refresh();
404 }
405 
406 
407 // Set the zoom level to show the area of aRect
409 {
410  KIGFX::VIEW* view = GetGalCanvas()->GetView();
411  BOX2I selectionBox ( aRect.GetPosition(), aRect.GetSize() );
412 
413  VECTOR2D screenSize = view->ToWorld( GetGalCanvas()->GetClientSize(), false );
414 
415  if( selectionBox.GetWidth() == 0 || selectionBox.GetHeight() == 0 )
416  return;
417 
418  VECTOR2D vsize = selectionBox.GetSize();
419  double scale;
420  double ratio = std::max( fabs( vsize.x / screenSize.x ),
421  fabs( vsize.y / screenSize.y ) );
422 
423  scale = view->GetScale() / ratio;
424 
425  GetScreen()->SetScalingFactor( 1 / scale );
426 
427  view->SetScale( scale );
428  view->SetCenter( selectionBox.Centre() );
429  GetGalCanvas()->Refresh();
430 }
431 
432 
433 void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
434 {
435  KIGFX::GAL* gal = GetCanvas()->GetGAL();
436 
437  double selectedZoom = GetScreen()->GetZoom();
438  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
439  double scale = 1.0 / ( zoomFactor * selectedZoom );
440 
441  if( aCenterPoint != wxPoint( 0, 0 ) )
442  GetCanvas()->GetView()->SetScale( scale, aCenterPoint );
443  else
444  GetCanvas()->GetView()->SetScale( scale );
445 
446  if( aWarpPointer )
448 
449  GetCanvas()->Refresh();
450 }
451 
452 
453 void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
454 {
455  KIGFX::GAL* gal = GetCanvas()->GetGAL();
456 
457  double selectedZoom = GetScreen()->GetZoom();
458  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
459  double scale = 1.0 / ( zoomFactor * selectedZoom );
460 
461  GetCanvas()->GetView()->SetScale( scale );
462 
463  GetGalCanvas()->Refresh();
464 }
465 
466 
467 void SCH_BASE_FRAME::CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
468 {
469  GetCanvas()->GetView()->SetCenter( aCenterPoint );
470 
471  if( aWarpPointer )
472  GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint, true );
473 
474  GetGalCanvas()->Refresh();
475 }
476 
477 
479 {
480  // Currently: just refresh the screen
481  GetCanvas()->Refresh();
482 }
483 
484 
486 {
487  return static_cast<SCH_DRAW_PANEL*>( GetGalCanvas() );
488 }
489 
490 
492 {
493  KIGFX::PAINTER* painter = GetGalCanvas()->GetView()->GetPainter();
494  return static_cast<KIGFX::SCH_RENDER_SETTINGS*>( painter->GetSettings() );
495 }
496 
497 
498 bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
499  int aExplicitCommand )
500 {
502 
503  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
504  return false;
505 
506  if( aExplicitCommand == 0 )
507  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
508  else
509  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
510 
511  if( block->GetCommand() == 0 )
512  return false;
513 
514  switch( block->GetCommand() )
515  {
516  case BLOCK_IDLE:
517  break;
518 
519  case BLOCK_MOVE: // Move
520  case BLOCK_DRAG: // Drag (block defined)
521  case BLOCK_DRAG_ITEM: // Drag from a drag item command
522  case BLOCK_DUPLICATE: // Duplicate
523  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
524  case BLOCK_DELETE: // Delete
525  case BLOCK_COPY: // Copy
526  case BLOCK_FLIP: // Flip
527  case BLOCK_ZOOM: // Window Zoom
528  case BLOCK_MIRROR_X:
529  case BLOCK_MIRROR_Y: // mirror
530  case BLOCK_PRESELECT_MOVE: // Move with preselection list
531  block->InitData( m_canvas, aPosition );
533  break;
534 
535  case BLOCK_PASTE:
536  {
537  block->InitData( m_canvas, aPosition );
539 
540  wxRect bounds( 0, 0, 0, 0 );
541 
542  for( unsigned i = 0; i < block->GetCount(); ++i )
543  bounds.Union( block->GetItem( i )->GetBoundingBox() );
544 
545  block->SetOrigin( bounds.GetPosition() );
546  block->SetSize( bounds.GetSize() );
547  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
548 
549  if( block->GetCount() == 0 ) // No data to paste
550  {
551  DisplayError( this, _( "Nothing to paste" ), 20 );
554  block->SetState( STATE_NO_BLOCK );
555  block->SetMessageBlock( this );
556  return true;
557  }
558 
559  if( !m_canvas->IsMouseCaptured() )
560  {
561  block->ClearItemsList();
562  wxFAIL_MSG( "SCH_BASE_FRAME::HandleBlockBegin() error: m_mouseCaptureCallback NULL" );
563  block->SetState( STATE_NO_BLOCK );
564  block->SetMessageBlock( this );
565  return true;
566  }
567 
568  block->SetState( STATE_BLOCK_MOVE );
569  block->SetFlags( IS_MOVED );
570  m_canvas->CallMouseCapture( aDC, aPosition, false );
571  m_canvas->Refresh();
572  }
573  break;
574 
575  default:
576  wxFAIL_MSG( wxString::Format( "SCH_BASE_FRAME::HandleBlockBegin() unknown command: %s",
577  block->GetCommand() ) );
578  break;
579  }
580 
581  block->SetMessageBlock( this );
582  return true;
583 }
584 
586 {
588 
589  // Allows only a CAIRO or OPENGL canvas:
593 
594  m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
596 
597  m_useSingleCanvasPane = true;
598 
599  SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
600  UseGalCanvas( true );
601 }
602 
603 
604 void SCH_BASE_FRAME::RefreshItem( SCH_ITEM* aItem, bool isAddOrDelete )
605 {
606  EDA_ITEM* parent = aItem->GetParent();
607 
608  if( aItem->Type() == SCH_SHEET_PIN_T )
609  {
610  // Sheet pins aren't in the view. Refresh their parent.
611  if( parent )
612  GetCanvas()->GetView()->Update( parent );
613  }
614  else
615  {
616  if( !isAddOrDelete )
617  GetCanvas()->GetView()->Update( aItem );
618 
619  // Component children are drawn from their parents. Mark them for re-paint.
620  if( parent && parent->Type() == SCH_COMPONENT_T )
621  GetCanvas()->GetView()->Update( parent, KIGFX::REPAINT );
622  }
623 
624  GetCanvas()->Refresh();
625 }
626 
627 
629 {
630  GetScreen()->Append( aItem );
631  GetCanvas()->GetView()->Add( aItem );
632  RefreshItem( aItem, true ); // handle any additional parent semantics
633 }
634 
635 
637 {
638  for( SCH_ITEM* item = aItems.begin(); item; item = item->Next() )
639  {
640  GetCanvas()->GetView()->Add( item );
641  RefreshItem( item, true ); // handle any additional parent semantics
642  }
643 
644  GetScreen()->Append( aItems );
645 }
646 
647 
649 {
650  GetCanvas()->GetView()->Remove( aItem );
651  GetScreen()->Remove( aItem );
652  RefreshItem( aItem, true ); // handle any additional parent semantics
653 }
654 
655 
657 {
658  auto screen = GetScreen();
659  auto gal = GetGalCanvas()->GetGAL();
660 
661  auto gs = screen->GetGridSize();
662  gal->SetGridSize( VECTOR2D( gs.x, gs.y ));
664 }
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:946
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:179
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:473
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:1434
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:374
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:157
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:929
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...
bool m_canvasTypeDirty
Flag indicating that drawing canvas type needs to be saved to config.
Definition: draw_frame.h:176
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:397
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:599
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:284
void SetScalingFactor(double iu_per_du)
Function SetScalingFactor sets the scaling factor of "internal unit per device unit".
Definition: common.h:160
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:73
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:1530
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:928
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:344
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