KiCad PCB EDA Suite
legacy_gal/eda_draw_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) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.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 <kiface_i.h>
33 #include <gr_basic.h>
34 #include <common.h>
35 #include <bitmaps.h>
36 #include <macros.h>
37 #include <id.h>
38 #include <class_drawpanel.h>
39 #include <base_screen.h>
40 #include <msgpanel.h>
41 #include <draw_frame.h>
42 #include <confirm.h>
43 #include <kicad_device_context.h>
44 #include <dialog_helpers.h>
45 #include <base_units.h>
46 #include <math/box2.h>
47 #include <lockfile.h>
48 #include <trace_helpers.h>
49 //#include "../eeschema/sch_draw_panel.h"
50 #include <wx/fontdlg.h>
51 #include <wx/snglinst.h>
52 #include <view/view.h>
53 #include <view/view_controls.h>
55 #include <tool/tool_manager.h>
56 #include <tool/tool_dispatcher.h>
57 #include <tool/actions.h>
58 #include <wx/clipbrd.h>
59 #include <fctsys.h>
60 #include <gr_basic.h>
61 #include <common.h>
62 #include <id.h>
63 #include <base_screen.h>
64 #include <confirm.h>
65 #include <draw_frame.h>
66 #include <menus_helpers.h>
68 #include <page_info.h>
69 #include <title_block.h>
70 #include <advanced_config.h>
71 
76 static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
77 
78 
81 
82 const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
83 
84 static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );
85 
87 
101 static const wxString MaxUndoItemsEntry(wxT( "DevelMaxUndoItems" ) );
102 
103 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
104  EVT_CHAR_HOOK( EDA_DRAW_FRAME::OnCharHook )
105 
106  EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
107  EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
108  EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
110 
112  EDA_DRAW_FRAME::OnZoom )
113 
115  EDA_DRAW_FRAME::OnSelectGrid )
116 
117  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
119  EDA_DRAW_FRAME::OnSelectUnits )
120 
121  EVT_TOOL( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnToggleCrossHairStyle )
122 
123  EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
124  EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
125  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
126  EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
127  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
128  EDA_DRAW_FRAME::OnUpdateUnits )
129 END_EVENT_TABLE()
130 
131 
132 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
133  FRAME_T aFrameType,
134  const wxString& aTitle,
135  const wxPoint& aPos, const wxSize& aSize,
136  long aStyle, const wxString & aFrameName ) :
137  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
138 {
139  m_useSingleCanvasPane = false;
140  m_socketServer = nullptr;
141  m_drawToolBar = NULL;
142  m_optionsToolBar = NULL;
143  m_auxiliaryToolBar = NULL;
144  m_gridSelectBox = NULL;
145  m_zoomSelectBox = NULL;
146  m_hotkeysDescrList = NULL;
147 
148  m_canvas = NULL;
149  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
150  m_galCanvas = NULL;
151  m_galCanvasActive = false;
152  m_actions = NULL;
153  m_toolManager = NULL;
154  m_toolDispatcher = NULL;
155  m_messagePanel = NULL;
156  m_currentScreen = NULL;
157  m_toolId = ID_NO_TOOL_SELECTED;
158  m_lastDrawToolId = ID_NO_TOOL_SELECTED;
159  m_showAxis = false; // true to draw axis.
160  m_showBorderAndTitleBlock = false; // true to display reference sheet.
161  m_showGridAxis = false; // true to draw the grid axis
162  m_showOriginAxis = false; // true to draw the grid origin
163  m_LastGridSizeId = 0;
164  m_drawGrid = true; // hide/Show grid. default = show
165  m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
166  m_showPageLimits = false;
167  m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
168  // BLACK for Pcbnew, BLACK or WHITE for eeschema
169  m_snapToGrid = true;
170  m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
171  m_movingCursorWithKeyboard = false;
172  m_zoomLevelCoeff = 1.0;
173 
174  m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
175 
176  CreateStatusBar( 6 );
177 
178  // set the size of the status bar subwindows:
179 
180  wxWindow* stsbar = GetStatusBar();
181 
182  int dims[] = {
183 
184  // remainder of status bar on far left is set to a default or whatever is left over.
185  -1,
186 
187  // When using GetTextSize() remember the width of character '1' is not the same
188  // as the width of '0' unless the font is fixed width, and it usually won't be.
189 
190  // zoom:
191  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
192 
193  // cursor coords
194  GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
195 
196  // delta distances
197  GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
198 
199  // units display, Inches is bigger than mm
200  GetTextSize( _( "Inches" ), stsbar ).x + 10,
201 
202  // Size for the panel used as "Current tool in play": will take longest string from
203  // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp
204  GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
205  };
206 
207  SetStatusWidths( arrayDim( dims ), dims );
208 
209  // Create child subwindows.
210  GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
211  m_FramePos.x = m_FramePos.y = 0;
212  m_FrameSize.y -= m_MsgFrameHeight;
213 
214  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
215  wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
216 
217  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
218 }
219 
220 
222 {
223  delete m_socketServer;
224  for( auto socket : m_sockets )
225  {
226  socket->Shutdown();
227  socket->Destroy();
228  }
229 
231 
232  delete m_actions;
233  delete m_toolManager;
234  delete m_toolDispatcher;
235  delete m_galCanvas;
236 
237  delete m_currentScreen;
238  m_currentScreen = NULL;
239 
240  m_auimgr.UnInit();
241 
242  ReleaseFile();
243 }
244 
245 
246 void EDA_DRAW_FRAME::OnCharHook( wxKeyEvent& event )
247 {
248  wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_FRAME::OnCharHook %s", dump( event ) );
249  // Key events can be filtered here.
250  // Currently no filtering is made.
251  event.Skip();
252 }
253 
254 
256 {
257  m_file_checker = nullptr;
258 }
259 
260 
261 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
262 {
263  m_file_checker = ::LockFile( aFileName );
264 
265  return bool( m_file_checker );
266 }
267 
268 
270 {
271  UpdateStatusBar();
272  UpdateMsgPanel();
273 }
274 
275 
277 {
279 
280  wxConfigBase* settings = Pgm().CommonSettings();
281 
282  int autosaveInterval;
283  settings->Read( AUTOSAVE_INTERVAL_KEY, &autosaveInterval );
284  SetAutoSaveInterval( autosaveInterval );
285 
286  int historySize;
287  settings->Read( FILE_HISTORY_SIZE_KEY, &historySize, DEFAULT_FILE_HISTORY_SIZE );
288  Kiface().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
289 
290  bool option;
291  settings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
292  m_canvas->SetEnableMousewheelPan( option );
293 
294  settings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option );
295  m_canvas->SetEnableZoomNoCenter( option );
296 
297  settings->Read( ENBL_AUTO_PAN_KEY, &option );
298  m_canvas->SetEnableAutoPan( option );
299 
300  int tmp;
303 
306 
308 }
309 
310 
312 {
313  if( m_messagePanel )
315 }
316 
317 
318 void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
319 {
320  if( m_canvas )
321  m_canvas->SetCanStartBlock( -1 );
322 
323  event.Skip(); // required under wxMAC
324 }
325 
326 
327 void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
328 {
329  if( m_canvas )
330  m_canvas->SetCanStartBlock( -1 );
331 
332  event.Skip();
333 }
334 
335 
337 {
339 }
340 
341 
342 void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
343 {
345 
346  if( IsGalCanvasActive() )
347  {
350  }
351 
352  m_canvas->Refresh();
353 }
354 
355 
357 {
358  // Checks all the toolbars and returns true if the given tool id is toggled.
359  return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
360  ( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
361  ( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
362  ( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
363  );
364 }
365 
366 
367 wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
368 {
369  // Checks all the toolbars and returns a reference to the given tool id
370  // (or the first tool found, but only one or 0 tool is expected, because on
371  // Windows, when different tools have the same ID, it creates issues)
372  if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
373  return m_mainToolBar->FindTool( aToolId );
374 
375  if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
376  return m_optionsToolBar->FindTool( aToolId );
377 
378  if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
379  return m_drawToolBar->FindTool( aToolId );
380 
381  if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
382  return m_auxiliaryToolBar->FindTool( aToolId );
383 
384  return nullptr;
385 }
386 
387 
388 void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
389 {
390  if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )
391  {
394  }
395  else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && m_UserUnits != INCHES )
396  {
399  }
400 }
401 
402 
403 void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
404 {
405  auto& galOpts = GetGalDisplayOptions();
406  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
407 
408  galOpts.NotifyChanged();
409 
410  // make sure the cursor is redrawn
411  GetCanvas()->Refresh();
412 }
413 
414 
415 void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
416 {
417  if( GetScreen() )
418  aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
419 }
420 
421 
422 void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
423 {
424  if( GetScreen() )
425  aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
426 }
427 
428 
429 void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
430 {
431  bool enable;
432 
433  enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (m_UserUnits == MILLIMETRES))
434  || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (m_UserUnits == INCHES)) );
435 
436  aEvent.Check( enable );
437  DisplayUnitsMsg();
438 }
439 
440 
441 void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
442 {
443  wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
444 
445  aEvent.Check( IsGridVisible() );
446  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
447 }
448 
449 
450 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
451 {
452  // No need to update the grid select box if it doesn't exist or the grid setting change
453  // was made using the select box.
454  if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
455  return;
456 
457  int select = wxNOT_FOUND;
458 
459  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
460  {
461  if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
462  {
463  select = (int) i;
464  break;
465  }
466  }
467 
468  if( select != m_gridSelectBox->GetSelection() )
469  m_gridSelectBox->SetSelection( select );
470 }
471 
472 
473 void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
474 {
475  aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
476 }
477 
478 
480 {
481 }
482 
483 
485 {
486 }
487 
488 
489 bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
490 {
491  return false;
492 }
493 
494 
496  wxString* aFullFileName )
497 {
498  int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
499 
500  if( GetToolManager() )
502 
503  return result;
504 }
505 
506 
507 void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
508 {
509 }
510 
511 
512 void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
513 {
514  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
515 }
516 
517 
518 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
519 {
520  int* clientData;
521  int eventId = ID_POPUP_GRID_LEVEL_100;
522 
523  if( event.GetEventType() == wxEVT_COMBOBOX )
524  {
525  if( m_gridSelectBox == NULL ) // Should not happen
526  return;
527 
528  /*
529  * Don't use wxCommandEvent::GetClientData() here. It always
530  * returns NULL in GTK. This solution is not as elegant but
531  * it works.
532  */
533  int index = m_gridSelectBox->GetSelection();
534  wxASSERT( index != wxNOT_FOUND );
535 
536  if( index == int( m_gridSelectBox->GetCount() - 2 ) )
537  {
538  // this is the separator
539  wxUpdateUIEvent dummy;
540  OnUpdateSelectGrid( dummy );
541  return;
542  }
543  else if( index == int( m_gridSelectBox->GetCount() - 1 ) )
544  {
545  wxUpdateUIEvent dummy;
546  OnUpdateSelectGrid( dummy );
547  wxCommandEvent dummy2;
548  OnGridSettings( dummy2 );
549  return;
550  }
551 
552  clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
553 
554  if( clientData != NULL )
555  eventId = *clientData;
556  }
557  else
558  {
559  eventId = event.GetId();
560  }
561 
562  int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
563 
564  SetPresetGrid( idx );
565 }
566 
567 
568 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
569 {
570  if( m_zoomSelectBox == NULL )
571  return; // Should not happen!
572 
573  int id = m_zoomSelectBox->GetCurrentSelection();
574 
575  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
576  return;
577 
578  if( id == 0 ) // Auto zoom (Fit in Page)
579  {
580  Zoom_Automatique( true );
581  }
582  else
583  {
584  double selectedZoom = GetScreen()->m_ZoomList[id-1];
585 
586  if( GetScreen()->GetZoom() == selectedZoom )
587  return;
588 
589  GetScreen()->SetZoom( selectedZoom );
591  }
592 
593  // Notify GAL
594  TOOL_MANAGER* mgr = GetToolManager();
595 
596  if( mgr && IsGalCanvasActive() )
597  {
598  mgr->RunAction( "common.Control.zoomPreset", true, id );
599  UpdateStatusBar();
600  }
601 }
602 
603 
605 {
606  return GetScreen()->GetZoom();
607 }
608 
609 
610 void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
611 {
612  event.Skip();
613 }
614 
615 
616 void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
617 {
618 }
619 
620 
621 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
622 {
623  SetStatusText( msg, 5 );
624 }
625 
626 
628 {
629  wxString msg;
630 
631  switch( m_UserUnits )
632  {
633  case INCHES: msg = _( "Inches" ); break;
634  case MILLIMETRES: msg = _( "mm" ); break;
635  default: msg = _( "Units" ); break;
636  }
637 
638  SetStatusText( msg, 4 );
639 }
640 
641 
642 
643 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
644 {
645  m_FrameSize = GetClientSize( );
646 
647  SizeEv.Skip();
648 }
649 
650 
651 void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
652 {
653  // Keep default cursor in toolbars
654  SetCursor( wxNullCursor );
655 
656  // Change GAL canvas cursor if requested.
657  if( IsGalCanvasActive() && aCursor >= 0 )
658  GetGalCanvas()->SetCurrentCursor( aCursor );
659 
660  DisplayToolMsg( aToolMsg );
661 
662  if( aId < 0 )
663  return;
664 
665  wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
666  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
667 
668  m_toolId = aId;
669 }
670 
671 
673 {
674  // Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
675 
676  int defaultCursor = wxCURSOR_DEFAULT;
677 
678  // Change GAL canvas cursor if requested.
679  if( IsGalCanvasActive() )
680  defaultCursor = GetGalCanvas()->GetDefaultCursor();
681 
682  SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
683 }
684 
685 
686 wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
687 {
688  wxPoint pos = aPosition;
689 
690  if( m_currentScreen != NULL && m_snapToGrid )
691  pos = GetNearestGridPosition( aPosition );
692 
693  return pos;
694 }
695 
696 
698 {
699  BASE_SCREEN * screen = GetScreen();
700 
701  int new_grid_cmd = screen->GetGridCmdId();
702 
703  // if the grid id is the not the last, increment it
704  if( screen->GridExists( new_grid_cmd + 1 ) )
705  new_grid_cmd += 1;
706 
707  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
708 }
709 
710 
712 {
713  BASE_SCREEN * screen = GetScreen();
714 
715  int new_grid_cmd = screen->GetGridCmdId();
716 
717  // if the grid id is the not the first, increment it
718  if( screen->GridExists( new_grid_cmd - 1 ) )
719  new_grid_cmd -= 1;
720 
721  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
722 }
723 
724 
726 {
727  BASE_SCREEN* screen = GetScreen();
728  KIGFX::VIEW* view = GetGalCanvas()->GetView();
729 
730  if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
731  aIndex = 0;
732 
733  // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
734  // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
735  int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
736 
737  if( m_gridSelectBox )
738  {
739  if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
740  {
741  wxASSERT_MSG( false, "Invalid grid index" );
742  return;
743  }
744 
745  m_gridSelectBox->SetSelection( glistIdx );
746  }
747 
748  // Be sure m_LastGridSizeId is up to date.
749  m_LastGridSizeId = aIndex;
750 
751  screen->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 );
752  view->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
754 
755  // Put cursor on new grid
756  SetCrossHairPosition( RefPos( true ) );
757 }
758 
759 
761 {
762  return 0;
763 }
764 
765 
767 {
770 }
771 
772 
774 {
775 }
776 
777 
779 {
780  return false;
781 }
782 
783 
785 {
786  SetStatusText( GetZoomLevelIndicator(), 1 );
787 
788  // Absolute and relative cursor positions are handled by overloading this function and
789  // handling the internal to user units conversion at the appropriate level.
790 
791  // refresh units display
792  DisplayUnitsMsg();
793 }
794 
795 
797 {
798  wxString Line;
799  double level = 0.0;
800 
801  if( IsGalCanvasActive() )
802  {
803  level = m_galCanvas->GetGAL()->GetZoomFactor();
804  }
805  else if( BASE_SCREEN* screen = GetScreen() )
806  {
807  level = m_zoomLevelCoeff / screen->GetZoom();
808  }
809 
810  // returns a human readable value which can be displayed as zoom
811  // level indicator in dialogs.
812  Line.Printf( wxT( "Z %.2f" ), level );
813 
814  return Line;
815 }
816 
817 
818 void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
819 {
821 
822  wxString baseCfgName = ConfigBaseName();
823  wxConfigBase* cmnCfg = Pgm().CommonSettings();
824 
825  // Read units used in dialogs and toolbars
826  EDA_UNITS_T unitsTmp;
827 
828  if( aCfg->Read( baseCfgName + UserUnitsEntryKeyword, (int*) &unitsTmp ) )
829  SetUserUnits( unitsTmp );
830  else
832 
833  // Read show/hide grid entry
834  bool btmp;
835  if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
836  SetGridVisibility( btmp );
837 
838  aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, m_LastGridSizeId );
839 
840  // m_LastGridSizeId is an offset, expected to be >= 0
841  if( m_LastGridSizeId < 0 )
842  m_LastGridSizeId = 0;
843 
844  m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
845  long( DEFAULT_MAX_UNDO_ITEMS ) );
846 
847  aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
848 
850 
851  int temp;
854 
857 
859 }
860 
861 
862 void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
863 {
865 
866  wxString baseCfgName = ConfigBaseName();
867 
868  aCfg->Write( baseCfgName + UserUnitsEntryKeyword, (int) m_UserUnits );
869  aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
870  aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
871  aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting );
872 
873  if( GetScreen() )
874  aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
875 
877 }
878 
879 
880 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
881  const wxString& textLower,
882  COLOR4D color, int pad )
883 {
884  if( m_messagePanel == NULL )
885  return;
886 
887  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
888 }
889 
890 
892 {
893  if( m_messagePanel == NULL )
894  return;
895 
897 }
898 
899 
901 {
902  if( m_messagePanel == NULL )
903  return;
904 
905  ClearMsgPanel();
906 
907  for( unsigned i = 0; i < aList.size(); i++ )
908  m_messagePanel->AppendMessage( aList[i] );
909 }
910 
911 
913 {
914  wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
915 
916  MSG_PANEL_ITEMS items;
917  aItem->GetMsgPanelInfo( m_UserUnits, items );
918  SetMsgPanel( items );
919 }
920 
921 
923 {
924  EDA_ITEM* item = GetScreen()->GetCurItem();
925 
926  if( item )
927  SetMsgPanel( item );
928 }
929 
930 
931 // FIXME: There needs to be a better way for child windows to load preferences.
932 // This function pushes four preferences from a parent window to a child window
933 // i.e. from eeschema to the schematic symbol editor
935 {
937  m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
938 }
939 
940 
941 bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
942  int aExplicitCommand )
943 {
945 
946  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
947  return false;
948 
949  if( aExplicitCommand == 0 )
950  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
951  else
952  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
953 
954  if( block->GetCommand() == 0 )
955  return false;
956 
957  switch( block->GetCommand() )
958  {
959  case BLOCK_IDLE:
960  break;
961 
962  case BLOCK_MOVE: // Move
963  case BLOCK_DRAG: // Drag (block defined)
964  case BLOCK_DRAG_ITEM: // Drag from a drag item command
965  case BLOCK_DUPLICATE: // Duplicate
966  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
967  case BLOCK_DELETE: // Delete
968  case BLOCK_COPY: // Copy
969  case BLOCK_FLIP: // Flip
970  case BLOCK_ZOOM: // Window Zoom
971  case BLOCK_PRESELECT_MOVE: // Move with preselection list
972  block->InitData( m_canvas, aPosition );
973  break;
974 
975  case BLOCK_PASTE:
976  block->InitData( m_canvas, aPosition );
977  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
979 
980  if( block->GetCount() == 0 ) // No data to paste
981  {
982  DisplayError( this, wxT( "No block to paste" ), 20 );
985  block->SetState( STATE_NO_BLOCK );
986  block->SetMessageBlock( this );
987  return true;
988  }
989 
990  if( !m_canvas->IsMouseCaptured() )
991  {
992  block->ClearItemsList();
993  DisplayError( this,
994  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
995  block->SetState( STATE_NO_BLOCK );
996  block->SetMessageBlock( this );
997  return true;
998  }
999 
1000  block->SetState( STATE_BLOCK_MOVE );
1001  m_canvas->CallMouseCapture( aDC, aPosition, false );
1002  break;
1003 
1004  default:
1005  {
1006  wxString msg;
1007  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
1008  block->GetCommand();
1009  DisplayError( this, msg );
1010  }
1011  break;
1012  }
1013 
1014  block->SetMessageBlock( this );
1015  return true;
1016 }
1017 
1018 
1019 void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
1020 {
1021 }
1022 
1023 
1024 void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
1025 {
1026  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1027 
1028  // Display the same view after canvas switching
1029  if( aEnable )
1030  {
1031  // Switch to GAL renderer from legacy
1032  if( !m_galCanvasActive )
1033  {
1034  // Set up viewport
1035  KIGFX::VIEW* view = galCanvas->GetView();
1036  view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
1038  }
1039 
1040  // Transfer EDA_DRAW_PANEL settings
1041  KIGFX::VIEW_CONTROLS* viewControls = galCanvas->GetViewControls();
1042  viewControls->EnableCursorWarping( !m_canvas->GetEnableZoomNoCenter() );
1044  viewControls->EnableAutoPan( m_canvas->GetEnableAutoPan() );
1045  }
1046 
1047  galCanvas->SetEvtHandlerEnabled( aEnable );
1048 
1049  // Reset current tool on switch();
1051 
1052  m_galCanvasActive = aEnable;
1053 }
1054 
1055 
1057 {
1058  auto galCanvas = GetGalCanvas();
1059  wxCHECK( galCanvas, false );
1060  bool use_gal = galCanvas->SwitchBackend( aCanvasType );
1061  use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1062  UseGalCanvas( use_gal );
1063  m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1064 
1065  return use_gal;
1066 }
1067 
1068 
1070 {
1072  wxConfigBase* cfg = Kiface().KifaceSettings();
1073 
1074  if( cfg )
1075  canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE) cfg->ReadLong( CANVAS_TYPE_KEY,
1077 
1078  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1079  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1080  {
1081  wxASSERT( false );
1082  canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1083  }
1084 
1085  // Coerce the value into a GAL type when Legacy is not available
1086  // Default to Cairo, and on the first, user will be prompted for OpenGL
1087  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1088  && !ADVANCED_CFG::GetCfg().AllowLegacyCanvas() )
1089  {
1091  }
1092 
1093  return canvasType;
1094 }
1095 
1096 
1098 {
1099  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1100  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1101  {
1102  wxASSERT( false );
1103  return false;
1104  }
1105 
1106  wxConfigBase* cfg = Kiface().KifaceSettings();
1107 
1108  if( cfg )
1109  return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
1110 
1111  return false;
1112 }
1113 
1114 //-----< BASE_SCREEN API moved here >--------------------------------------------
1115 
1116 wxPoint EDA_DRAW_FRAME::GetCrossHairPosition( bool aInvertY ) const
1117 {
1119  return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y );
1120 }
1121 
1122 
1123 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1124 {
1125  // While we're now a GAL canvas, we still have a pre-GAL toolset so some code is going
1126  // to look for the crosshair position in the BASE_SCREEN and some code is going to look
1127  // for it in the VIEW_CONTROLS. Better set it in both.
1128 
1129  BASE_SCREEN* screen = GetScreen(); // virtual call
1130  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1131 
1132  wxPoint snappedPosition = screen->getCrossHairPosition( false );
1133  GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( snappedPosition, false );
1134 }
1135 
1136 
1137 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1138 {
1139  BASE_SCREEN* screen = GetScreen(); // virtual call
1140  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1141 }
1142 
1143 
1144 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
1145  wxRealPoint* aGridSize ) const
1146 {
1147  BASE_SCREEN* screen = GetScreen(); // virtual call
1148  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1149 }
1150 
1151 
1153 {
1154  BASE_SCREEN* screen = GetScreen(); // virtual call
1155  return screen->getCrossHairScreenPosition();
1156 }
1157 
1158 
1159 void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
1160 {
1161  BASE_SCREEN* screen = GetScreen(); // virtual call
1162  screen->setMousePosition( aPosition );
1163 }
1164 
1165 
1166 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1167 {
1168  BASE_SCREEN* screen = GetScreen(); // virtual call
1169  return screen->refPos( useMouse );
1170 }
1171 
1172 
1174 {
1175  BASE_SCREEN* screen = GetScreen(); // virtual call
1176  return screen->getScrollCenterPosition();
1177 }
1178 
1179 
1180 void EDA_DRAW_FRAME::SetScrollCenterPosition( const wxPoint& aPoint )
1181 {
1182  BASE_SCREEN* screen = GetScreen(); // virtual call
1183  screen->setScrollCenterPosition( aPoint );
1184 }
1185 
1186 //-----</BASE_SCREEN API moved here >--------------------------------------------
1187 
1188 void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos,
1189  const wxPoint &aEvtPos,
1190  wxDC* aDC )
1191 {
1192  wxFAIL_MSG( "shouldn't be using RefreshCrossHair() anymore; use CallMouseCapture() directly" );
1193 
1194  // CrossHair is no longer XORed; no need for most of this
1195 #if 0
1196  wxPoint newpos = GetCrossHairPosition();
1197 
1198 
1199  // Redraw the crosshair if it moved
1200  if( aOldPos != newpos )
1201  {
1202  SetCrossHairPosition( aOldPos, false );
1203  m_canvas->CrossHairOff( aDC );
1204  SetCrossHairPosition( newpos, false );
1205  m_canvas->CrossHairOn( aDC );
1206 #endif
1207  if( m_canvas->IsMouseCaptured() )
1208  {
1209  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1210  }
1211 #if 0
1212  }
1213 #endif
1214 }
1215 
1216 
1217 bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos,
1218  bool aSnapToGrid )
1219 {
1220  bool key_handled = false;
1221 
1222  // If requested snap the current position to the grid
1223  if( aSnapToGrid )
1224  *aPos = GetNearestGridPosition( *aPos );
1225 
1226  switch( aHotKey )
1227  {
1228  // All these keys have almost the same treatment
1229  case GR_KB_CTRL | WXK_NUMPAD8:
1230  case GR_KB_CTRL | WXK_UP:
1231  case GR_KB_CTRL | WXK_NUMPAD2:
1232  case GR_KB_CTRL | WXK_DOWN:
1233  case GR_KB_CTRL | WXK_NUMPAD4:
1234  case GR_KB_CTRL | WXK_LEFT:
1235  case GR_KB_CTRL | WXK_NUMPAD6:
1236  case GR_KB_CTRL | WXK_RIGHT:
1237  case WXK_NUMPAD8:
1238  case WXK_UP:
1239  case WXK_NUMPAD2:
1240  case WXK_DOWN:
1241  case WXK_NUMPAD4:
1242  case WXK_LEFT:
1243  case WXK_NUMPAD6:
1244  case WXK_RIGHT:
1245  key_handled = true;
1246  {
1247  /* Here's a tricky part: when doing cursor key movement, the
1248  * 'previous' point should be taken from memory, *not* from the
1249  * freshly computed position in the event. Otherwise you can't do
1250  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1251  * the automatic motion event generated by cursor warping */
1252  wxRealPoint gridSize = GetScreen()->GetGridSize();
1253  *aPos = GetCrossHairPosition();
1254 
1255  // Bonus: ^key moves faster (x10)
1256  switch( aHotKey )
1257  {
1258  case GR_KB_CTRL|WXK_NUMPAD8:
1259  case GR_KB_CTRL|WXK_UP:
1260  aPos->y -= KiROUND( 10 * gridSize.y );
1261  break;
1262 
1263  case GR_KB_CTRL|WXK_NUMPAD2:
1264  case GR_KB_CTRL|WXK_DOWN:
1265  aPos->y += KiROUND( 10 * gridSize.y );
1266  break;
1267 
1268  case GR_KB_CTRL|WXK_NUMPAD4:
1269  case GR_KB_CTRL|WXK_LEFT:
1270  aPos->x -= KiROUND( 10 * gridSize.x );
1271  break;
1272 
1273  case GR_KB_CTRL|WXK_NUMPAD6:
1274  case GR_KB_CTRL|WXK_RIGHT:
1275  aPos->x += KiROUND( 10 * gridSize.x );
1276  break;
1277 
1278  case WXK_NUMPAD8:
1279  case WXK_UP:
1280  aPos->y -= KiROUND( gridSize.y );
1281  break;
1282 
1283  case WXK_NUMPAD2:
1284  case WXK_DOWN:
1285  aPos->y += KiROUND( gridSize.y );
1286  break;
1287 
1288  case WXK_NUMPAD4:
1289  case WXK_LEFT:
1290  aPos->x -= KiROUND( gridSize.x );
1291  break;
1292 
1293  case WXK_NUMPAD6:
1294  case WXK_RIGHT:
1295  aPos->x += KiROUND( gridSize.x );
1296  break;
1297 
1298  default: /* Can't happen since we entered the statement */
1299  break;
1300  }
1301 
1302  m_canvas->MoveCursor( *aPos );
1304  }
1305  break;
1306 
1307  default:
1308  break;
1309  }
1310 
1311  return key_handled;
1312 }
1313 
1314 
1316 {
1317  const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
1318 
1319  if( !screen )
1320  return false;
1321 
1322  return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
1323  || ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
1324 }
1325 
1326 
1328 {
1329  return BOX2I();
1330 }
1331 
1332 
1333 void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
1334 {
1335 }
1336 
1337 
1338 void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
1339 {
1340 }
1341 
1342 
1344 {
1345 }
1346 
1347 
1348 // Factor out the calculation portion of the various BestZoom() implementations.
1349 //
1350 // Note that like it's forerunners this routine has an intentional side-effect: it
1351 // sets the scroll centre position. While I'm not happy about that, it's probably
1352 // not worth fixing as its days are numbered (GAL canvases use a different method).
1353 double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre )
1354 {
1355  return 1.0;
1356 }
1357 
1358 
1359 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
1360 {
1361  if ( IsGalCanvasActive() )
1362  {
1363  m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
1364  return;
1365  }
1366 
1367 }
1368 
1369 
1371 {
1372 }
1373 
1374 
1375 void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
1376 {
1377  if( m_canvas == NULL )
1378  return;
1379 
1380  int id = event.GetId();
1381  bool warp_cursor = false;
1382  VECTOR2D cpos = GetCrossHairPosition();//GetGalCanvas()->GetViewControls()->GetCursorPosition();
1383  wxPoint zoom_center( (int)cpos.x, (int)cpos.y );
1384 
1385  if ( id == ID_KEY_ZOOM_IN )
1386  {
1387  id = GetCanvas()->GetEnableZoomNoCenter() ?
1389  }
1390  else if ( id == ID_KEY_ZOOM_OUT )
1391  {
1392  id = GetCanvas()->GetEnableZoomNoCenter() ?
1394  }
1395 
1396  switch( id )
1397  {
1398  case ID_OFFCENTER_ZOOM_IN:
1399  SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
1400  break;
1401 
1402  case ID_POPUP_ZOOM_IN:
1403  warp_cursor = true;
1404  // fall thru
1405  case ID_VIEWER_ZOOM_IN:
1406  case ID_ZOOM_IN:
1407  SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
1408  break;
1409 
1410  case ID_OFFCENTER_ZOOM_OUT:
1411  SetNextZoomAndRedraw( zoom_center, warp_cursor );
1412  break;
1413 
1414  case ID_POPUP_ZOOM_OUT:
1415  warp_cursor = true;
1416  // fall thru
1417  case ID_VIEWER_ZOOM_OUT:
1418  case ID_ZOOM_OUT:
1419  SetNextZoomAndRedraw( zoom_center, warp_cursor );
1420  break;
1421 
1422  case ID_VIEWER_ZOOM_REDRAW:
1423  case ID_POPUP_ZOOM_REDRAW:
1424  case ID_ZOOM_REDRAW:
1425  // This usually means something went wrong. Do a hard refresh.
1426  HardRedraw();
1427  break;
1428 
1429  case ID_POPUP_ZOOM_CENTER:
1430  GetGalCanvas()->GetView()->SetScale( GetGalCanvas()->GetView()->GetScale(), zoom_center );
1432  break;
1433 
1434  case ID_POPUP_ZOOM_PAGE:
1435  case ID_VIEWER_ZOOM_PAGE:
1436  case ID_ZOOM_PAGE:
1437  Zoom_Automatique( false );
1438  break;
1439 
1440  case ID_POPUP_ZOOM_SELECT:
1441  break;
1442 
1443  case ID_POPUP_CANCEL:
1445  break;
1446 
1447  default:
1449  }
1450 
1451  UpdateStatusBar();
1452 }
1453 
1454 
1456 {
1457  GetScreen()->SetNextZoom();
1458 }
1459 
1460 
1462 {
1464 }
1465 
1466 
1467 void EDA_DRAW_FRAME::SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
1468 {
1469  double zoom = GetGalCanvas()->GetLegacyZoom();
1470  zoom *= 1.3;
1471 
1472  // Now look for the next closest menu step
1473  std::vector<double>& zoomList = GetScreen()->m_ZoomList;
1474  int idx;
1475 
1476  for( idx = 0; idx < (int)zoomList.size(); ++idx )
1477  {
1478  if( zoomList[idx] > zoom )
1479  break;
1480  }
1481 
1482  if( idx >= (int)zoomList.size() )
1483  return;
1484 
1485  if( m_zoomSelectBox )
1486  m_zoomSelectBox->SetSelection( idx );
1487 
1488  GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] );
1489  RedrawScreen( aCenterPoint, aWarpPointer );
1490 }
1491 
1492 
1493 void EDA_DRAW_FRAME::SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
1494 {
1495  double zoom = GetGalCanvas()->GetLegacyZoom();
1496  zoom /= 1.3;
1497 
1498  // Now look for the next closest menu step
1499  std::vector<double>& zoomList = GetScreen()->m_ZoomList;
1500  int idx;
1501 
1502  for( idx = zoomList.size() - 1; idx >= 0; --idx )
1503  {
1504  if( zoomList[idx] < zoom )
1505  break;
1506  }
1507 
1508  if( idx < 0 )
1509  return;
1510 
1511  if( m_zoomSelectBox )
1512  m_zoomSelectBox->SetSelection( idx );
1513 
1514  GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] );
1515  RedrawScreen( aCenterPoint, aWarpPointer );
1516 }
1517 
1518 
1520 {
1521  BASE_SCREEN* screen = GetScreen();
1522 
1523  if( aIndex >= (int) screen->m_ZoomList.size() )
1524  {
1525  wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ),
1526  __TFILE__, __LINE__, aIndex );
1527  return;
1528  }
1529 
1530  if( m_zoomSelectBox )
1531  m_zoomSelectBox->SetSelection( aIndex );
1532 
1533  if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
1535 
1536  UpdateStatusBar();
1537 }
1538 
1539 
1540 void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
1541 {
1542  int maxZoomIds;
1543  double zoom;
1544  wxString msg;
1545  BASE_SCREEN* screen = m_canvas->GetScreen();
1546 
1547  msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
1548  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
1549  msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN );
1550  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
1551  msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
1552  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
1553  msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
1554  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
1555  msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
1556  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
1557 
1558 
1559  wxMenu* zoom_choice = new wxMenu;
1560  AddMenuItem( MasterMenu, zoom_choice,
1561  ID_POPUP_ZOOM_SELECT, _( "Zoom" ),
1562  KiBitmap( zoom_selection_xpm ) );
1563 
1564  zoom = screen->GetZoom();
1566  maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
1567  maxZoomIds : screen->m_ZoomList.size();
1568 
1569  // Populate zoom submenu.
1570  for( int i = 0; i < maxZoomIds; i++ )
1571  {
1572  msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
1573 
1574  zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
1575  wxEmptyString, wxITEM_CHECK );
1576  if( zoom == screen->m_ZoomList[i] )
1577  zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
1578  }
1579 
1580  // Create grid submenu as required.
1581  if( screen->GetGridCount() )
1582  {
1583  wxMenu* gridMenu = new wxMenu;
1584  AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
1585  _( "Grid" ), KiBitmap( grid_select_xpm ) );
1586 
1587  wxArrayString gridsList;
1588  int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1589 
1590  for( unsigned i = 0; i < gridsList.GetCount(); i++ )
1591  {
1592  GRID_TYPE& grid = screen->GetGrid( i );
1593  gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
1594 
1595  if( (int)i == icurr )
1596  gridMenu->Check( grid.m_CmdId, true );
1597  }
1598  }
1599 
1600  MasterMenu->AppendSeparator();
1601  AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
1602 }
1603 
1604 
1605 // Find the first child dialog.
1606 wxWindow* findDialog( wxWindowList& aList )
1607 {
1608  for( wxWindow* window : aList )
1609  {
1610  if( dynamic_cast<DIALOG_SHIM*>( window ) )
1611  return window;
1612  }
1613  return NULL;
1614 }
1615 
1616 
1617 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, bool aCenterView )
1618 {
1619  if( aCenterView )
1620  {
1621  wxWindow* dialog = findDialog( GetChildren() );
1622 
1623  // If a dialog partly obscures the window, then center on the uncovered area.
1624  if( dialog )
1625  {
1626  wxRect dialogRect( GetGalCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
1627  dialog->GetSize() );
1628  GetGalCanvas()->GetView()->SetCenter( aPos, dialogRect );
1629  }
1630  else
1631  GetGalCanvas()->GetView()->SetCenter( aPos );
1632  }
1633 
1634  if( aWarpCursor )
1636  else
1638 }
1639 
1640 
1641 static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
1642 
1643 
1644 void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
1645 {
1646  DrawPageOnClipboard( this );
1647 
1648  if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
1649  {
1650  // fixme-gal
1651  //if( GetScreen()->IsBlockActive() )
1652  //m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
1653 
1655  }
1656 }
1657 
1658 
1659 /* copy the current page or block to the clipboard ,
1660  * to export drawings to other applications (word processing ...)
1661  * This is not suitable for copy command within Eeschema or Pcbnew
1662  */
1664 {
1665  bool DrawBlock = false;
1666  wxRect DrawArea;
1667  BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
1668 
1669  if( screen->IsBlockActive() )
1670  {
1671  DrawBlock = true;
1672  DrawArea.SetX( screen->m_BlockLocate.GetX() );
1673  DrawArea.SetY( screen->m_BlockLocate.GetY() );
1674  DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
1675  DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() );
1676  }
1677  else
1678  DrawArea.SetSize( aFrame->GetPageSizeIU() );
1679 
1680  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
1681  // the drawings into the dc size
1682  // scale is the ratio resolution (in PPI) / internal units
1683  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
1684  double inch2Iu = 1000.0 * (double) screen->MilsToIuScalar();
1685  double scale = ppi / inch2Iu;
1686 
1687  wxSize dcsize = DrawArea.GetSize();
1688 
1689  int maxdim = std::max( dcsize.x, dcsize.y );
1690  // the max size in pixels of the bitmap used to byuild the sheet copy
1691  const int maxbitmapsize = 3000;
1692 
1693  while( int( maxdim * scale ) > maxbitmapsize )
1694  {
1695  ppi = ppi / 1.5;
1696  scale = ppi / inch2Iu;
1697  }
1698 
1699  dcsize.x *= scale;
1700  dcsize.y *= scale;
1701 
1702  // Set draw offset, zoom... to values needed to draw in the memory DC
1703  // after saving initial values:
1704  wxPoint tmp_startvisu = screen->m_StartVisu;
1705  double tmpzoom = screen->GetZoom();
1706  wxPoint old_org = screen->m_DrawOrg;
1707  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
1708  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
1709 
1710  screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
1711 
1712  wxMemoryDC dc;
1713  wxBitmap image( dcsize );
1714  dc.SelectObject( image );
1715 
1716  EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox();
1717  GRResetPenAndBrush( &dc );
1718  GRForceBlackPen( false );
1719  screen->m_IsPrinting = true;
1720  dc.SetUserScale( scale, scale );
1721 
1722  aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
1723  wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
1724 
1725  if( DrawBlock )
1726  {
1727  dc.SetClippingRegion( DrawArea );
1728  }
1729 
1730  dc.Clear();
1731  aFrame->GetCanvas()->EraseScreen( &dc );
1732  const LSET allLayersMask = LSET().set();
1733  aFrame->PrintPage( &dc, allLayersMask, false );
1734  screen->m_IsPrinting = false;
1735  aFrame->GetCanvas()->SetClipBox( tmp );
1736 
1737  bool success = true;
1738 
1739  if( wxTheClipboard->Open() )
1740  {
1741  // This data objects are held by the clipboard,
1742  // so do not delete them in the app.
1743  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
1744  wxTheClipboard->SetData( clipbrd_data );
1745  wxTheClipboard->Close();
1746  }
1747  else
1748  success = false;
1749 
1750  // Deselect Bitmap from DC in order to delete the MemoryDC safely
1751  // without deleting the bitmap
1752  dc.SelectObject( wxNullBitmap );
1753 
1754  GRForceBlackPen( false );
1755 
1756  screen->m_StartVisu = tmp_startvisu;
1757  screen->m_DrawOrg = old_org;
1758  screen->SetZoom( tmpzoom );
1759 
1760  return success;
1761 }
1762 
1763 static const wxString productName = wxT( "KiCad E.D.A. " );
1764 
1765 void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
1766  const PAGE_INFO& aPageInfo,
1767  const wxString &aFullSheetName,
1768  const wxString& aFileName,
1769  TITLE_BLOCK& aTitleBlock,
1770  int aSheetCount, int aSheetNumber,
1771  int aPenWidth, double aScalar,
1772  COLOR4D aColor, COLOR4D aAltColor,
1773  const wxString& aSheetLayer )
1774 {
1775  WS_DRAW_ITEM_LIST drawList;
1776 
1777  drawList.SetPenSize( aPenWidth );
1778  drawList.SetMilsToIUfactor( aScalar );
1779  drawList.SetSheetNumber( aSheetNumber );
1780  drawList.SetSheetCount( aSheetCount );
1781  drawList.SetFileName( aFileName );
1782  drawList.SetSheetName( aFullSheetName );
1783  drawList.SetSheetLayer( aSheetLayer );
1784 
1785  drawList.BuildWorkSheetGraphicList( aPageInfo,
1786  aTitleBlock, aColor, aAltColor );
1787 
1788  // Draw item list
1789  drawList.Draw( aClipBox, aDC );
1790 }
1791 
1792 
1793 void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
1794  double aScalar, const wxString &aFilename,
1795  const wxString &aSheetLayer )
1796 {
1798  return;
1799 
1800  const PAGE_INFO& pageInfo = GetPageSettings();
1801  wxSize pageSize = pageInfo.GetSizeMils();
1802 
1803  // if not printing, draw the page limits:
1804  if( !aScreen->m_IsPrinting && m_showPageLimits )
1805  {
1806  GRSetDrawMode( aDC, GR_COPY );
1807  GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
1808  pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
1810  }
1811 
1812  TITLE_BLOCK t_block = GetTitleBlock();
1813  COLOR4D color = COLOR4D( RED );
1814 
1815  wxPoint origin = aDC->GetDeviceOrigin();
1816 
1817  if( aScreen->m_IsPrinting && origin.y > 0 )
1818  {
1819  aDC->SetDeviceOrigin( 0, 0 );
1820  aDC->SetAxisOrientation( true, false );
1821  }
1822 
1823  DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
1824  GetScreenDesc(), aFilename, t_block,
1825  aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
1826  aLineWidth, aScalar, color, color, aSheetLayer );
1827 
1828  if( aScreen->m_IsPrinting && origin.y > 0 )
1829  {
1830  aDC->SetDeviceOrigin( origin.x, origin.y );
1831  aDC->SetAxisOrientation( true, true );
1832  }
1833 }
1834 
1835 
1837 {
1838  // Virtual function. Base class implementation returns an empty string.
1839  return wxEmptyString;
1840 }
1841 
1842 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
1843  const wxString& wildcard, const wxString& ext,
1844  bool isDirectory )
1845 {
1846  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
1847  aFilename.SetExt( ext );
1848 
1849  if( isDirectory )
1850  {
1851  wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
1852  doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
1853 
1854  if( dlg.ShowModal() == wxID_CANCEL )
1855  return false;
1856 
1857  aFilename = dlg.GetPath();
1858  aFilename.SetExt( ext );
1859  }
1860  else
1861  {
1862  wxFileDialog dlg( this, prompt, Prj().GetProjectPath(), aFilename.GetFullName() ,
1863  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1864  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1865 
1866  if( dlg.ShowModal() == wxID_CANCEL )
1867  return false;
1868 
1869  aFilename = dlg.GetPath();
1870  aFilename.SetExt( ext );
1871  }
1872 
1873  return true;
1874 }
1875 
1876 
1877 bool EDA_DRAW_FRAME::saveCanvasImageToFile( const wxString& aFileName, wxBitmapType aBitmapType )
1878 {
1879  return SaveCanvasImageToFile( this, aFileName, aBitmapType );
1880 }
virtual BASE_SCREEN * GetScreen()=0
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:125
virtual void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:123
wxPoint getCursorPosition(bool aOnGrid, const wxPoint &aGridOrigin, wxRealPoint *aGridSize) const
Function getCursorPosition returns the current cursor position in logical (drawing) units...
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:258
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
virtual wxPoint GetScreenCenterLogicalPosition()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void AdjustScrollBars(const wxPoint &aCenterPosition)
int m_ScreenNumber
Definition: base_screen.h:216
void OnToggleCrossHairStyle(wxCommandEvent &aEvent)
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:94
bool m_galCanvasActive
whether to use new GAL engine
Definition: draw_frame.h:97
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
static const wxString MaxUndoItemsEntry(wxT("DevelMaxUndoItems"))
Integer to set the maximum number of undo items on the stack.
void SetPenSize(int aPenSize)
Function SetPenSize Set the default pen size to draw/plot lines and texts.
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:385
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
void SetPreviousZoomAndRedraw(const wxPoint &aCenterPoint, bool aWarpPointer)
Change the zoom to the previous one available redraws the screen and warp the mouse pointer on reques...
virtual const TITLE_BLOCK & GetTitleBlock() const =0
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:943
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:121
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
void setScrollCenterPosition(const wxPoint &aPoint)
Definition: base_screen.h:174
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual void HandleBlockPlace(wxDC *DC)
Called after HandleBlockEnd, when a block command needs to be executed after the block is moved to it...
bool SaveCanvasImageToFile(EDA_DRAW_FRAME *aFrame, const wxString &aFileName, wxBitmapType aBitmapType)
Save the current view as an image file.
Definition: bitmap.cpp:195
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
wxPoint GetGridPosition(const wxPoint &aPosition) const
Return the nearest grid position to aPosition if a screen is defined and snap to grid is enabled...
virtual int BlockCommand(EDA_KEY aKey)
Return the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the keys pressed (ALT...
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:126
virtual void SetEnableZoomNoCenter(bool aEnable)
#define DEFAULT_MAX_UNDO_ITEMS
Definition: draw_frame.h:47
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
int GetGridCmdId() const
Return the command ID of the currently selected grid.
Definition: base_screen.h:403
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:223
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
VIEW_CONTROLS class definition.
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
virtual void OnGridSettings(wxCommandEvent &event)
Definition: draw_frame.h:594
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
static const wxString productName
void SetScrollCenterPosition(const wxPoint &aPoint)
wxPoint getCrossHairScreenPosition() const
Function getCursorScreenPosition returns the cross hair position in device (display) units...
void OnMouseEvent(wxMouseEvent &event)
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
int color
Definition: DXF_plotter.cpp:62
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
Definition: id.h:241
virtual bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL)
std::vector< wxSocketBase * > m_sockets
interprocess communication
Definition: draw_frame.h:101
int GetHeight() const
Definition: eda_rect.h:118
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
virtual void EnableMousewheelPan(bool aEnable)
Function EnableMousewheelPan() Enables or disables mousewheel panning.
wxString ConfigBaseName()
Function ConfigBaseName.
virtual void EndMouseCapture(int aId=-1, int aCursorId=-1, const wxString &aTitle=wxEmptyString, bool aCallEndFunc=true)
Function EndMouseCapture ends mouse a capture.
const GRIDS & GetGrids() const
Function GetGrids().
Definition: base_screen.h:472
BLOCK_COMMAND_T
static bool DrawPageOnClipboard(EDA_DRAW_FRAME *aFrame)
wxPoint GetCursorPosition(bool aOnGrid, wxRealPoint *aGridSize=NULL) const
Return the current cursor position in logical (drawing) units.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
#define GR_KB_CTRL
void SetCanStartBlock(int aStartBlock)
void ReleaseFile()
Release the current file marked in use.
const wxPoint & GetScrollCenterPosition() const
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
virtual void ToolOnRightClick(wxCommandEvent &event)
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
EDA_DRAW_FRAME::OnSelectGrid EVT_TOOL_RANGE(ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH, EDA_DRAW_FRAME::OnSelectUnits) EVT_UPDATE_UI_RANGE(ID_TB_OPTIONS_SELECT_UNIT_MM
EVT_MENU_RANGE(ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE, EDA_DRAW_FRAME::OnZoom) EVT_MENU_RANGE(ID_POPUP_GRID_LEVEL_1000
wxAuiManager m_auimgr
virtual EDA_RECT * GetClipBox()
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock, COLOR4D aColor, COLOR4D aAltColor)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
virtual void OnZoom(wxCommandEvent &event)
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void OnMenuOpen(wxMenuEvent &event)
void SkipNextLeftButtonReleaseEvent()
After calling this function, if the left mouse button is down, the next left mouse button release eve...
void CopyToClipboard(wxCommandEvent &event)
Copy the current page or the current block to the clipboard.
virtual void MoveCursor(const wxPoint &aPosition)
Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.
class EDA_MSG_PANEL is a panel to display various information messages.
Definition: msgpanel.h:111
Sentinel, do not use as a parameter.
virtual void SetPrevGrid()
Change the grid size settings to the previous one available.
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Push preferences from a parent window to a child window.
void FocusOnLocation(const wxPoint &aPos, bool aWarpCursor=true, bool aCenterView=false)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
COLOR4D m_drawBgColor
the background color of the draw canvas BLACK for Pcbnew, BLACK or WHITE for eeschema ...
Definition: draw_frame.h:113
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
bool SetPreviousZoom()
wxComboBox * m_zoomSelectBox
Definition: draw_frame.h:149
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:250
static const wxChar CANVAS_TYPE_KEY[]
Key in KifaceSettings to store the canvas type.
Definition: draw_frame.h:234
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
prevents opening same file multiple times.
Definition: draw_frame.h:103
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
virtual void InitBlockPasteInfos()
virtual const wxSize GetPageSizeIU() const =0
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
wxPoint refPos(bool useMouse) const
Function RefPos Return the reference position, coming from either the mouse position or the cursor po...
Definition: base_screen.h:168
double GetZoomLevelCoeff() const
Return the coefficient to convert internal display scale factor to zoom level.
Definition: draw_frame.h:461
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Definition: draw_frame.h:525
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: pgm_base.h:48
bool SetNextZoom()
Auxiliary rendering target (noncached)
Definition: definitions.h:42
void SetClipBox(const EDA_RECT &aRect)
This file contains miscellaneous commonly used macros and functions.
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: common.cpp:111
void DisplayUnitsMsg()
Display current unit pane on the status bar.
const wxSize & GetSizeMils() const
Definition: page_info.h:142
bool saveCanvasImageToFile(const wxString &aFileName, wxBitmapType aBitmapType=wxBITMAP_TYPE_PNG)
void OnUpdateUndo(wxUpdateUIEvent &aEvent)
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Handle the common part of GeneralControl dedicated to global cursor keys (i.e.
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
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...
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
Class TOOL_MANAGER.
Definition: tool_manager.h:49
virtual bool HandleBlockBegin(wxDC *aDC, EDA_KEY aKey, const wxPoint &aPosition, int aExplicitCommand=0)
Initialize a block command.
void EnableCursorWarping(bool aEnable)
Function EnableCursorWarping() Enables or disables warping the cursor.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
virtual const PAGE_INFO & GetPageSettings() const =0
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board...
#define GAL_DISPLAY_OPTIONS_KEY
Definition: pgm_base.h:53
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device) ...
Definition: base_screen.h:198
void ReadConfig(wxConfigBase *aCfg, const wxString &aBaseName)
void DrawPageLayout(wxDC *aDC, EDA_RECT *aClipBox, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, TITLE_BLOCK &aTitleBlock, int aSheetCount, int aSheetNumber, int aPenWidth, double aScalar, COLOR4D aColor, COLOR4D aAltColor, const wxString &aSheetLayer)
Function DrawPageLayout is a core function to draw the page layout with the frame and the basic inscr...
bool IsBlockActive() const
Definition: base_screen.h:499
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
#define ENBL_AUTO_PAN_KEY
Definition: pgm_base.h:51
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
Definition: draw_frame.h:153
#define DEFAULT_FILE_HISTORY_SIZE
The default file history size is 9.
Definition: pgm_base.h:60
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:394
Class LSET is a set of PCB_LAYER_IDs.
a helper to handle the real device context used in KiCad
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:160
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:600
void OnUpdateRedo(wxUpdateUIEvent &aEvent)
BASE_SCREEN * m_currentScreen
current used SCREEN
Definition: draw_frame.h:87
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
virtual void PrintPage(wxDC *aDC, LSET aPrintMask, bool aPrintMirrorMode, void *aData=NULL)
Print the page pointed by current screen, set by the calling print function.
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:105
void RefreshCrossHair(const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC *aDC)
Move and refresh the crosshair after movement and call the mouse capture function.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
wxPoint getCrossHairPosition(bool aInvertY) const
Function getCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
Definition: base_screen.h:107
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
virtual wxString GetScreenDesc() const
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
wxPoint getNearestGridPosition(const wxPoint &aPosition, const wxPoint &aGridOrigin, wxRealPoint *aGridSize) const
Function getNearestGridPosition returns the nearest aGridSize location to aPosition.
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:204
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:180
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:596
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
wxComboBox * m_gridSelectBox
Definition: draw_frame.h:148
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:163
virtual void CrossHairOn(wxDC *DC=nullptr)
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
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
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:143
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
Definition: common.h:161
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
bool GetEnableZoomNoCenter() const
virtual void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units ( mils) to draw/plot units...
virtual const BOX2I GetDocumentExtents() const
wxWindow * findDialog(wxWindowList &aList)
static const wxString ShowGridEntryKeyword(wxT("ShowGrid"))
Nonzero to show grid (suffix)
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:49
virtual void ReCreateAuxiliaryToolbar()
Helper dialog and control classes.
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:52
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
virtual void CrossHairOff(wxDC *DC=nullptr)
uint32_t EDA_KEY
Definition: common.h:74
wxAuiToolBarItem * GetToolbarTool(int aToolId)
Checks all the toolbars and returns a reference to the given tool id or nullptr if not found...
void OnUpdateUnits(wxUpdateUIEvent &aEvent)
wxLogTrace helper definitions.
void setMousePosition(const wxPoint &aPosition)
Definition: base_screen.h:156
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:918
static const wxString UserUnitsEntryKeyword(wxT("Units"))
User units.
Definition: colors.h:60
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
void OnToggleGridState(wxCommandEvent &aEvent)
virtual bool SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
virtual int MilsToIuScalar()
Function MilsToIuScalar returns the scalar required to convert mils to internal units.
Definition: base_screen.h:245
void SetPresetZoom(int aIndex)
Change zoom to one of the preset values.
const wxPoint & getScrollCenterPosition() const
Definition: base_screen.h:173
virtual void EnableAutoPan(bool aEnabled)
Function EnableAutoPan Turns on/off auto panning (user setting to disable it entirely).
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
void SetPresetGrid(int aIndex)
Change the grid size to one of the preset values.
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:118
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
void EraseMsgBox()
Definition: msgpanel.cpp:216
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
Definition: base_struct.h:297
virtual void SetCurrentCursor(int aCursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
virtual int GetDefaultCursor() const
Function GetDefaultCursor.
static const wxString FirstRunShownKeyword(wxT("FirstRunShown"))
virtual const wxPoint & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
int m_LastGridSizeId
Definition: draw_frame.h:107
virtual void RedrawScreen2(const wxPoint &posBefore)
Put the crosshair back to the screen position it had before zooming.
static const wxString traceScrollSettings(wxT("KicadScrollSettings"))
Definition for enabling and disabling scroll bar setting trace output.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory)
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:157
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
bool m_IsPrinting
Definition: base_screen.h:220
Definition: solve.cpp:178
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
#define AUTOSAVE_INTERVAL_KEY
Definition: pgm_base.h:47
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, COLOR4D aColor, int aPad=6)
Function AppendMessage appends a message to the message panel.
Definition: msgpanel.cpp:110
virtual void SetNextGrid()
Change the grid size settings to the next one available.
EDA_DRAW_PANEL_GAL * m_galCanvas
GAL display options - this is the frame&#39;s interface to setting GAL display options.
Definition: draw_frame.h:91
virtual bool HandleBlockEnd(wxDC *DC)
Handle the "end" of a block command, i.e.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
of elements in an array. This implements type-safe compile time checking
Definition: macros.h:99
wxSocketServer * m_socketServer
Definition: draw_frame.h:100
static const wxString LastGridSizeIdKeyword(wxT("_LastGridSize"))
Most recently used grid size (suffix)
wxPoint RefPos(bool useMouse) const
Return the reference position, coming from either the mouse position or the cursor position...
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
void OnUpdateCrossHairStyle(wxUpdateUIEvent &aEvent)
void WriteConfig(wxConfigBase *aCfg, const wxString &aBaseName)
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterP...
void SetMaxFiles(size_t aMaxFiles)
Definition: pgm_base.cpp:79
TOOL_MANAGER * GetToolManager() const
Return the tool manager instance, if any.
Definition: draw_frame.h:931
void setCrossHairPosition(const wxPoint &aPosition, const wxPoint &aGridOrigin, bool aSnapToGrid)
Function setCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:54
void SetAutoSaveInterval(int aInterval)
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Return the nearest aGridSize location to aPosition.
const int scale
void DisplayToolMsg(const wxString &msg)
bool GridExists(int aCommandId)
Function GridExists tests for grid command ID (not an index in grid list, but a wxID) exists in grid ...
wxString AddHotkeyName(const wxString &aText, EDA_HOTKEY **aList, int aCommandId, HOTKEY_ACTION_TYPE aShortCutType)
Function AddHotkeyName Add the key name from the Command id value ( m_Idcommand member value) ...
see class PGM_BASE
virtual void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void OnUpdateGrid(wxUpdateUIEvent &aEvent)
void SetMousePosition(const wxPoint &aPosition)
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
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
BLOCK_STATE_T GetState() const
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
#define max(a, b)
Definition: auxiliary.h:86
bool GetEnableMousewheelPan() const
virtual int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL)
Function WriteHotkeyConfig Store the current hotkey list It is stored using the standard wxConfig mec...
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
Definition: draw_frame.h:94
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:189
size_t i
Definition: json11.cpp:597
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:183
virtual void SetEnableMousewheelPan(bool aEnable)
int GetX() const
Definition: eda_rect.h:109
void SetNextZoom()
Change the zoom to the next one available.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
#define CAIRO_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:55
The common library.
int GetWidth() const
Definition: eda_rect.h:117
double GetZoomFactor() const
Get the zoom factor.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool m_showPageLimits
true to display the page limits
Definition: draw_frame.h:111
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
Definition: colors.h:49
int GetY() const
Definition: eda_rect.h:110
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
int WriteHotkeyConfig(struct EDA_HOTKEY_CONFIG *aDescList, wxString *aFullFileName=NULL) override
>
virtual void Window_Zoom(EDA_RECT &Rect)
int m_NumberOfScreens
Definition: base_screen.h:217
BLOCK_COMMAND_T GetCommand() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance&#39;s config, which is shared by all consumers of advanced config...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:925
virtual void CommonSettingsChanged()
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
virtual void AddMenuZoomAndGrid(wxMenu *aMasterMenu)
Add standard zoom commands and submenu zoom and grid selection to a popup menu uses zoom hotkeys info...
classes and function to generate graphics to plt or draw titles blocks and frame references ...
virtual void SetGridVisibility(bool aVisible)
It may be overloaded by derived classes.
Definition: draw_frame.h:534
void DrawWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Draws on screen the page layout with the frame and the basic inscriptions.
void Draw(EDA_RECT *aClipBox, wxDC *aDC)
Draws the item list created by BuildWorkSheetGraphicList.
Definition: colors.h:45
virtual void OnCharHook(wxKeyEvent &event)
Capture the key event before it is sent to the GUI.
void InitData(EDA_DRAW_PANEL *Panel, const wxPoint &startpos)
Function InitData sets the initial values of a BLOCK_SELECTOR, before starting a block command...
void OnSelectUnits(wxCommandEvent &aEvent)
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
Class VIEW.
Definition: view.h:61
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
bool GetToolToggled(int aToolId)
Checks all the toolbars and returns true if the given tool id is toggled.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Set the screen cross hair position to aPosition in logical (drawing) units.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
int m_CmdId
Definition: base_screen.h:48
BASE_SCREEN class implementation.
Message panel definition file.
wxPoint GetCrossHairScreenPosition() const
Return the cross hair position in device (display) units.b.
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
virtual void EraseScreen(wxDC *DC)
Function OnMouseWheel handles mouse wheel events.
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
ACTIONS * m_actions
Definition: draw_frame.h:127
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
static int GetRequiredHeight()
Function GetRequiredHeight returns the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:71
void SetPrevZoom()
Change the zoom to the previous one available.
virtual void SetEnableAutoPan(bool aEnable)
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.
unsigned GetCount() const
virtual void OnActivate(wxActivateEvent &event)
Called when activating the frame.
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:173
void ClearMsgPanel(void)
Clear all messages from the message panel.
void UpdateHotKeys()
>
EDA_UNITS_T
Definition: common.h:160
void SetNextZoomAndRedraw(const wxPoint &aCenterPoint, bool aWarpPointer)
Change the zoom to the next one available redraws the screen and warp the mouse pointer on request...
virtual void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
long m_firstRunDialogSetting
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:146
void SetUserUnits(EDA_UNITS_T aUnits)
Definition: draw_frame.h:282
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
bool m_snapToGrid
Indicates if cursor should be snapped to grid.
Definition: draw_frame.h:89
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
void SetCommand(BLOCK_COMMAND_T aCommand)
virtual void UpdateMsgPanel()
Redraw the message panel.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void SetIgnoreLeftButtonReleaseEvent(bool aIgnore)
File locking utilities.