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 
75 static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
76 
77 
80 
81 const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
82 
83 static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );
84 
86 
100 static const wxString MaxUndoItemsEntry(wxT( "DevelMaxUndoItems" ) );
101 
102 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
103  EVT_CHAR_HOOK( EDA_DRAW_FRAME::OnCharHook )
104 
105  EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
106  EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
107  EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
109 
111  EDA_DRAW_FRAME::OnZoom )
112 
114  EDA_DRAW_FRAME::OnSelectGrid )
115 
116  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
118  EDA_DRAW_FRAME::OnSelectUnits )
119 
120  EVT_TOOL( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnToggleCrossHairStyle )
121 
122  EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
123  EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
124  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
125  EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
126  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
127  EDA_DRAW_FRAME::OnUpdateUnits )
128 END_EVENT_TABLE()
129 
130 
131 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
132  FRAME_T aFrameType,
133  const wxString& aTitle,
134  const wxPoint& aPos, const wxSize& aSize,
135  long aStyle, const wxString & aFrameName ) :
136  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
137 {
138  m_useSingleCanvasPane = false;
139  m_socketServer = nullptr;
140  m_drawToolBar = NULL;
141  m_optionsToolBar = NULL;
142  m_auxiliaryToolBar = NULL;
143  m_gridSelectBox = NULL;
144  m_zoomSelectBox = NULL;
145  m_hotkeysDescrList = NULL;
146 
147  m_canvas = NULL;
148  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
149  m_canvasTypeDirty = false;
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( DIM( 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 
230  if( m_canvasTypeDirty ) // the canvas type has changed: save the new type
232 
233  delete m_actions;
234  delete m_toolManager;
235  delete m_toolDispatcher;
236  delete m_galCanvas;
237 
238  delete m_currentScreen;
239  m_currentScreen = NULL;
240 
241  m_auimgr.UnInit();
242 
243  ReleaseFile();
244 }
245 
246 
247 void EDA_DRAW_FRAME::OnCharHook( wxKeyEvent& event )
248 {
249  wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_FRAME::OnCharHook %s", dump( event ) );
250  // Key events can be filtered here.
251  // Currently no filtering is made.
252  event.Skip();
253 }
254 
255 
257 {
258  m_file_checker = nullptr;
259 }
260 
261 
262 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
263 {
264  m_file_checker = ::LockFile( aFileName );
265 
266  return bool( m_file_checker );
267 }
268 
269 
271 {
272  UpdateStatusBar();
273  UpdateMsgPanel();
274 }
275 
276 
278 {
280 
281  wxConfigBase* settings = Pgm().CommonSettings();
282 
283  int autosaveInterval;
284  settings->Read( AUTOSAVE_INTERVAL_KEY, &autosaveInterval );
285  SetAutoSaveInterval( autosaveInterval );
286 
287  int historySize;
288  settings->Read( FILE_HISTORY_SIZE_KEY, &historySize, DEFAULT_FILE_HISTORY_SIZE );
289  Kiface().GetFileHistory().SetMaxFiles( (unsigned) std::max( 0, historySize ) );
290 
291  bool option;
292  settings->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
293  m_canvas->SetEnableMousewheelPan( option );
294 
295  settings->Read( ENBL_ZOOM_NO_CENTER_KEY, &option );
296  m_canvas->SetEnableZoomNoCenter( option );
297 
298  settings->Read( ENBL_AUTO_PAN_KEY, &option );
299  m_canvas->SetEnableAutoPan( option );
300 
301  int tmp;
305 }
306 
307 
309 {
310  if( m_messagePanel )
312 }
313 
314 
315 void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
316 {
317  if( m_canvas )
318  m_canvas->SetCanStartBlock( -1 );
319 
320  event.Skip(); // required under wxMAC
321 }
322 
323 
324 void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
325 {
326  if( m_canvas )
327  m_canvas->SetCanStartBlock( -1 );
328 
329  event.Skip();
330 }
331 
332 
334 {
336 }
337 
338 
339 void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
340 {
342 
343  if( IsGalCanvasActive() )
344  {
347  }
348 
349  m_canvas->Refresh();
350 }
351 
352 
354 {
355  // Checks all the toolbars and returns true if the given tool id is toggled.
356  return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
357  ( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
358  ( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
359  ( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
360  );
361 }
362 
363 
364 wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
365 {
366  // Checks all the toolbars and returns a reference to the given tool id
367  // (or the first tool found, but only one or 0 tool is expected, because on
368  // Windows, when different tools have the same ID, it creates issues)
369  if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
370  return m_mainToolBar->FindTool( aToolId );
371 
372  if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
373  return m_optionsToolBar->FindTool( aToolId );
374 
375  if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
376  return m_drawToolBar->FindTool( aToolId );
377 
378  if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
379  return m_auxiliaryToolBar->FindTool( aToolId );
380 
381  return nullptr;
382 }
383 
384 
385 void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
386 {
387  if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )
388  {
391  }
392  else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && m_UserUnits != INCHES )
393  {
396  }
397 }
398 
399 
400 void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
401 {
402  auto& galOpts = GetGalDisplayOptions();
403  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
404 
405  galOpts.NotifyChanged();
406 
407  // make sure the cursor is redrawn
408  GetCanvas()->Refresh();
409 }
410 
411 
412 void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
413 {
414  if( GetScreen() )
415  aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
416 }
417 
418 
419 void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
420 {
421  if( GetScreen() )
422  aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
423 }
424 
425 
426 void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
427 {
428  bool enable;
429 
430  enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (m_UserUnits == MILLIMETRES))
431  || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (m_UserUnits == INCHES)) );
432 
433  aEvent.Check( enable );
434  DisplayUnitsMsg();
435 }
436 
437 
438 void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
439 {
440  wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
441 
442  aEvent.Check( IsGridVisible() );
443  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
444 }
445 
446 
447 void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
448 {
449  // No need to update the grid select box if it doesn't exist or the grid setting change
450  // was made using the select box.
451  if( m_gridSelectBox == NULL || m_auxiliaryToolBar == NULL )
452  return;
453 
454  int select = wxNOT_FOUND;
455 
456  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
457  {
458  if( GetScreen()->GetGridCmdId() == GetScreen()->GetGrid( i ).m_CmdId )
459  {
460  select = (int) i;
461  break;
462  }
463  }
464 
465  if( select != m_gridSelectBox->GetSelection() )
466  m_gridSelectBox->SetSelection( select );
467 }
468 
469 
470 void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
471 {
472  aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
473 }
474 
475 
477 {
478 }
479 
480 
482 {
483 }
484 
485 
486 bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
487 {
488  return false;
489 }
490 
491 
493  wxString* aFullFileName )
494 {
495  int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
496 
497  if( GetToolManager() )
499 
500  return result;
501 }
502 
503 
504 void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
505 {
506 }
507 
508 
509 void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
510 {
511  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
512 }
513 
514 
515 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
516 {
517  int* clientData;
518  int eventId = ID_POPUP_GRID_LEVEL_100;
519 
520  if( event.GetEventType() == wxEVT_CHOICE )
521  {
522  if( m_gridSelectBox == NULL ) // Should not happen
523  return;
524 
525  /*
526  * Don't use wxCommandEvent::GetClientData() here. It always
527  * returns NULL in GTK. This solution is not as elegant but
528  * it works.
529  */
530  int index = m_gridSelectBox->GetSelection();
531  wxASSERT( index != wxNOT_FOUND );
532 
533  if( index == int( m_gridSelectBox->GetCount() - 2 ) )
534  {
535  // this is the separator
536  wxUpdateUIEvent dummy;
537  OnUpdateSelectGrid( dummy );
538  return;
539  }
540  else if( index == int( m_gridSelectBox->GetCount() - 1 ) )
541  {
542  wxUpdateUIEvent dummy;
543  OnUpdateSelectGrid( dummy );
544  wxCommandEvent dummy2;
545  OnGridSettings( dummy2 );
546  return;
547  }
548 
549  clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
550 
551  if( clientData != NULL )
552  eventId = *clientData;
553  }
554  else
555  {
556  eventId = event.GetId();
557  }
558 
559  int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
560 
561  SetPresetGrid( idx );
562 }
563 
564 
565 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
566 {
567  if( m_zoomSelectBox == NULL )
568  return; // Should not happen!
569 
570  int id = m_zoomSelectBox->GetCurrentSelection();
571 
572  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
573  return;
574 
575  if( id == 0 ) // Auto zoom (Fit in Page)
576  {
577  Zoom_Automatique( true );
578  }
579  else
580  {
581  double selectedZoom = GetScreen()->m_ZoomList[id-1];
582 
583  if( GetScreen()->GetZoom() == selectedZoom )
584  return;
585 
586  GetScreen()->SetZoom( selectedZoom );
588  }
589 
590  // Notify GAL
591  TOOL_MANAGER* mgr = GetToolManager();
592 
593  if( mgr && IsGalCanvasActive() )
594  {
595  mgr->RunAction( "common.Control.zoomPreset", true, id );
596  UpdateStatusBar();
597  }
598 }
599 
600 
602 {
603  return GetScreen()->GetZoom();
604 }
605 
606 
607 void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
608 {
609  event.Skip();
610 }
611 
612 
613 void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
614 {
615 }
616 
617 
618 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
619 {
620  SetStatusText( msg, 5 );
621 }
622 
623 
625 {
626  wxString msg;
627 
628  switch( m_UserUnits )
629  {
630  case INCHES: msg = _( "Inches" ); break;
631  case MILLIMETRES: msg = _( "mm" ); break;
632  default: msg = _( "Units" ); break;
633  }
634 
635  SetStatusText( msg, 4 );
636 }
637 
638 
639 
640 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
641 {
642  m_FrameSize = GetClientSize( );
643 
644  SizeEv.Skip();
645 }
646 
647 
648 void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
649 {
650  // Keep default cursor in toolbars
651  SetCursor( wxNullCursor );
652 
653  // Change GAL canvas cursor if requested.
654  if( IsGalCanvasActive() && aCursor >= 0 )
655  GetGalCanvas()->SetCurrentCursor( aCursor );
656 
657  DisplayToolMsg( aToolMsg );
658 
659  if( aId < 0 )
660  return;
661 
662  wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
663  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
664 
665  m_toolId = aId;
666 }
667 
668 
670 {
671  // Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
672 
673  int defaultCursor = wxCURSOR_DEFAULT;
674 
675  // Change GAL canvas cursor if requested.
676  if( IsGalCanvasActive() )
677  defaultCursor = GetGalCanvas()->GetDefaultCursor();
678 
679  SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
680 }
681 
682 
684 {
685  wxPoint pos = aPosition;
686 
687  if( m_currentScreen != NULL && m_snapToGrid )
688  pos = GetNearestGridPosition( aPosition );
689 
690  return pos;
691 }
692 
693 
695 {
696  BASE_SCREEN * screen = GetScreen();
697 
698  int new_grid_cmd = screen->GetGridCmdId();
699 
700  // if the grid id is the not the last, increment it
701  if( screen->GridExists( new_grid_cmd + 1 ) )
702  new_grid_cmd += 1;
703 
704  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
705 }
706 
707 
709 {
710  BASE_SCREEN * screen = GetScreen();
711 
712  int new_grid_cmd = screen->GetGridCmdId();
713 
714  // if the grid id is the not the first, increment it
715  if( screen->GridExists( new_grid_cmd - 1 ) )
716  new_grid_cmd -= 1;
717 
718  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
719 }
720 
721 
723 {
724  BASE_SCREEN* screen = GetScreen();
725  KIGFX::VIEW* view = GetGalCanvas()->GetView();
726 
727  if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
728  aIndex = screen->GetGrids()[0].m_CmdId;
729 
730  // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
731  // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
732  int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
733 
734  if( m_gridSelectBox )
735  {
736  if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
737  {
738  wxASSERT_MSG( false, "Invalid grid index" );
739  return;
740  }
741 
742  m_gridSelectBox->SetSelection( glistIdx );
743  }
744 
745  // Be sure m_LastGridSizeId is up to date.
746  m_LastGridSizeId = aIndex;
747 
748  screen->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 );
749  view->GetGAL()->SetGridSize( VECTOR2D( screen->GetGridSize() ) );
751 
752  // Put cursor on new grid
753  SetCrossHairPosition( RefPos( true ) );
754 }
755 
756 
758 {
759  return 0;
760 }
761 
762 
764 {
767 }
768 
769 
771 {
772 }
773 
774 
776 {
777  return false;
778 }
779 
780 
782 {
783  SetStatusText( GetZoomLevelIndicator(), 1 );
784 
785  // Absolute and relative cursor positions are handled by overloading this function and
786  // handling the internal to user units conversion at the appropriate level.
787 
788  // refresh units display
789  DisplayUnitsMsg();
790 }
791 
792 
794 {
795  wxString Line;
796  double level = 0.0;
797 
798  if( IsGalCanvasActive() )
799  {
800  level = m_galCanvas->GetGAL()->GetZoomFactor();
801  }
802  else if( BASE_SCREEN* screen = GetScreen() )
803  {
804  level = m_zoomLevelCoeff / screen->GetZoom();
805  }
806 
807  // returns a human readable value which can be displayed as zoom
808  // level indicator in dialogs.
809  Line.Printf( wxT( "Z %.2f" ), level );
810 
811  return Line;
812 }
813 
814 
815 void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
816 {
818 
819  wxString baseCfgName = ConfigBaseName();
820  wxConfigBase* cmnCfg = Pgm().CommonSettings();
821 
822  // Read units used in dialogs and toolbars
823  EDA_UNITS_T unitsTmp;
824 
825  if( aCfg->Read( baseCfgName + UserUnitsEntryKeyword, (int*) &unitsTmp ) )
826  SetUserUnits( unitsTmp );
827  else
829 
830  // Read show/hide grid entry
831  bool btmp;
832  if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
833  SetGridVisibility( btmp );
834 
835  aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
836 
837  // m_LastGridSizeId is an offset, expected to be >= 0
838  if( m_LastGridSizeId < 0 )
839  m_LastGridSizeId = 0;
840 
841  m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
842  long( DEFAULT_MAX_UNDO_ITEMS ) );
843 
844  aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
845 
847 
848  int temp;
852 }
853 
854 
855 void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
856 {
858 
859  wxString baseCfgName = ConfigBaseName();
860 
861  aCfg->Write( baseCfgName + UserUnitsEntryKeyword, (int) m_UserUnits );
862  aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
863  aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
864  aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting );
865 
866  if( GetScreen() )
867  aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
868 
870 }
871 
872 
873 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
874  const wxString& textLower,
875  COLOR4D color, int pad )
876 {
877  if( m_messagePanel == NULL )
878  return;
879 
880  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
881 }
882 
883 
885 {
886  if( m_messagePanel == NULL )
887  return;
888 
890 }
891 
892 
894 {
895  if( m_messagePanel == NULL )
896  return;
897 
898  ClearMsgPanel();
899 
900  for( unsigned i = 0; i < aList.size(); i++ )
901  m_messagePanel->AppendMessage( aList[i] );
902 }
903 
904 
906 {
907  wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
908 
909  MSG_PANEL_ITEMS items;
910  aItem->GetMsgPanelInfo( m_UserUnits, items );
911  SetMsgPanel( items );
912 }
913 
914 
916 {
917  EDA_ITEM* item = GetScreen()->GetCurItem();
918 
919  if( item )
920  SetMsgPanel( item );
921 }
922 
923 
924 // FIXME: There needs to be a better way for child windows to load preferences.
925 // This function pushes four preferences from a parent window to a child window
926 // i.e. from eeschema to the schematic symbol editor
928 {
930  m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
931 }
932 
933 
934 bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
935  int aExplicitCommand )
936 {
938 
939  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
940  return false;
941 
942  if( aExplicitCommand == 0 )
943  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
944  else
945  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
946 
947  if( block->GetCommand() == 0 )
948  return false;
949 
950  switch( block->GetCommand() )
951  {
952  case BLOCK_IDLE:
953  break;
954 
955  case BLOCK_MOVE: // Move
956  case BLOCK_DRAG: // Drag (block defined)
957  case BLOCK_DRAG_ITEM: // Drag from a drag item command
958  case BLOCK_DUPLICATE: // Duplicate
959  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
960  case BLOCK_DELETE: // Delete
961  case BLOCK_COPY: // Copy
962  case BLOCK_FLIP: // Flip
963  case BLOCK_ZOOM: // Window Zoom
964  case BLOCK_PRESELECT_MOVE: // Move with preselection list
965  block->InitData( m_canvas, aPosition );
966  break;
967 
968  case BLOCK_PASTE:
969  block->InitData( m_canvas, aPosition );
970  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
972 
973  if( block->GetCount() == 0 ) // No data to paste
974  {
975  DisplayError( this, wxT( "No block to paste" ), 20 );
978  block->SetState( STATE_NO_BLOCK );
979  block->SetMessageBlock( this );
980  return true;
981  }
982 
983  if( !m_canvas->IsMouseCaptured() )
984  {
985  block->ClearItemsList();
986  DisplayError( this,
987  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
988  block->SetState( STATE_NO_BLOCK );
989  block->SetMessageBlock( this );
990  return true;
991  }
992 
993  block->SetState( STATE_BLOCK_MOVE );
994  m_canvas->CallMouseCapture( aDC, aPosition, false );
995  break;
996 
997  default:
998  {
999  wxString msg;
1000  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
1001  block->GetCommand();
1002  DisplayError( this, msg );
1003  }
1004  break;
1005  }
1006 
1007  block->SetMessageBlock( this );
1008  return true;
1009 }
1010 
1011 
1012 // I am not seeing a problem with this size yet:
1013 static const double MAX_AXIS = INT_MAX - 100;
1014 
1015 #define VIRT_MIN (-MAX_AXIS/2.0)
1016 #define VIRT_MAX (MAX_AXIS/2.0)
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  m_canvasTypeDirty = true;
1065 
1066  return use_gal;
1067 }
1068 
1069 
1071 {
1073  wxConfigBase* cfg = Kiface().KifaceSettings();
1074 
1075  if( cfg )
1076  canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE) cfg->ReadLong( CANVAS_TYPE_KEY,
1078 
1079  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1080  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1081  {
1082  wxASSERT( false );
1083  canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1084  }
1085 
1086  return canvasType;
1087 }
1088 
1089 
1091 {
1092  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1093  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1094  {
1095  wxASSERT( false );
1096  return false;
1097  }
1098 
1099  wxConfigBase* cfg = Kiface().KifaceSettings();
1100 
1101  if( cfg )
1102  return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
1103 
1104  return false;
1105 }
1106 
1107 //-----< BASE_SCREEN API moved here >--------------------------------------------
1108 
1110 {
1112  return wxPoint( cursor.x, aInvertY ? -cursor.y : cursor.y );
1113 }
1114 
1115 
1116 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1117 {
1118  // While we're now a GAL canvas, we still have a pre-GAL toolset so some code is going
1119  // to look for the crosshair position in the BASE_SCREEN and some code is going to look
1120  // for it in the VIEW_CONTROLS. Better set it in both.
1121 
1122  BASE_SCREEN* screen = GetScreen(); // virtual call
1123  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1124 
1125  wxPoint snappedPosition = screen->getCrossHairPosition( false );
1126  GetGalCanvas()->GetViewControls()->SetCrossHairCursorPosition( snappedPosition, false );
1127 }
1128 
1129 
1130 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1131 {
1132  BASE_SCREEN* screen = GetScreen(); // virtual call
1133  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1134 }
1135 
1136 
1138  wxRealPoint* aGridSize ) const
1139 {
1140  BASE_SCREEN* screen = GetScreen(); // virtual call
1141  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1142 }
1143 
1144 
1146 {
1147  BASE_SCREEN* screen = GetScreen(); // virtual call
1148  return screen->getCrossHairScreenPosition();
1149 }
1150 
1151 
1153 {
1154  BASE_SCREEN* screen = GetScreen(); // virtual call
1155  screen->setMousePosition( aPosition );
1156 }
1157 
1158 
1159 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1160 {
1161  BASE_SCREEN* screen = GetScreen(); // virtual call
1162  return screen->refPos( useMouse );
1163 }
1164 
1165 
1167 {
1168  BASE_SCREEN* screen = GetScreen(); // virtual call
1169  return screen->getScrollCenterPosition();
1170 }
1171 
1172 
1174 {
1175  BASE_SCREEN* screen = GetScreen(); // virtual call
1176  screen->setScrollCenterPosition( aPoint );
1177 }
1178 
1179 //-----</BASE_SCREEN API moved here >--------------------------------------------
1180 
1182  const wxPoint &aEvtPos,
1183  wxDC* aDC )
1184 {
1185  wxFAIL_MSG( "shouldn't be using RefreshCrossHair() anymore; use CallMouseCapture() directly" );
1186 
1187  // CrossHair is no longer XORed; no need for most of this
1188 #if 0
1189  wxPoint newpos = GetCrossHairPosition();
1190 
1191 
1192  // Redraw the crosshair if it moved
1193  if( aOldPos != newpos )
1194  {
1195  SetCrossHairPosition( aOldPos, false );
1196  m_canvas->CrossHairOff( aDC );
1197  SetCrossHairPosition( newpos, false );
1198  m_canvas->CrossHairOn( aDC );
1199 #endif
1200  if( m_canvas->IsMouseCaptured() )
1201  {
1202  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1203  }
1204 #if 0
1205  }
1206 #endif
1207 }
1208 
1209 
1211  bool aSnapToGrid )
1212 {
1213  bool key_handled = false;
1214 
1215  // If requested snap the current position to the grid
1216  if( aSnapToGrid )
1217  *aPos = GetNearestGridPosition( *aPos );
1218 
1219  switch( aHotKey )
1220  {
1221  // All these keys have almost the same treatment
1222  case GR_KB_CTRL | WXK_NUMPAD8:
1223  case GR_KB_CTRL | WXK_UP:
1224  case GR_KB_CTRL | WXK_NUMPAD2:
1225  case GR_KB_CTRL | WXK_DOWN:
1226  case GR_KB_CTRL | WXK_NUMPAD4:
1227  case GR_KB_CTRL | WXK_LEFT:
1228  case GR_KB_CTRL | WXK_NUMPAD6:
1229  case GR_KB_CTRL | WXK_RIGHT:
1230  case WXK_NUMPAD8:
1231  case WXK_UP:
1232  case WXK_NUMPAD2:
1233  case WXK_DOWN:
1234  case WXK_NUMPAD4:
1235  case WXK_LEFT:
1236  case WXK_NUMPAD6:
1237  case WXK_RIGHT:
1238  key_handled = true;
1239  {
1240  /* Here's a tricky part: when doing cursor key movement, the
1241  * 'previous' point should be taken from memory, *not* from the
1242  * freshly computed position in the event. Otherwise you can't do
1243  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1244  * the automatic motion event generated by cursor warping */
1245  wxRealPoint gridSize = GetScreen()->GetGridSize();
1246  *aPos = GetCrossHairPosition();
1247 
1248  // Bonus: ^key moves faster (x10)
1249  switch( aHotKey )
1250  {
1251  case GR_KB_CTRL|WXK_NUMPAD8:
1252  case GR_KB_CTRL|WXK_UP:
1253  aPos->y -= KiROUND( 10 * gridSize.y );
1254  break;
1255 
1256  case GR_KB_CTRL|WXK_NUMPAD2:
1257  case GR_KB_CTRL|WXK_DOWN:
1258  aPos->y += KiROUND( 10 * gridSize.y );
1259  break;
1260 
1261  case GR_KB_CTRL|WXK_NUMPAD4:
1262  case GR_KB_CTRL|WXK_LEFT:
1263  aPos->x -= KiROUND( 10 * gridSize.x );
1264  break;
1265 
1266  case GR_KB_CTRL|WXK_NUMPAD6:
1267  case GR_KB_CTRL|WXK_RIGHT:
1268  aPos->x += KiROUND( 10 * gridSize.x );
1269  break;
1270 
1271  case WXK_NUMPAD8:
1272  case WXK_UP:
1273  aPos->y -= KiROUND( gridSize.y );
1274  break;
1275 
1276  case WXK_NUMPAD2:
1277  case WXK_DOWN:
1278  aPos->y += KiROUND( gridSize.y );
1279  break;
1280 
1281  case WXK_NUMPAD4:
1282  case WXK_LEFT:
1283  aPos->x -= KiROUND( gridSize.x );
1284  break;
1285 
1286  case WXK_NUMPAD6:
1287  case WXK_RIGHT:
1288  aPos->x += KiROUND( gridSize.x );
1289  break;
1290 
1291  default: /* Can't happen since we entered the statement */
1292  break;
1293  }
1294 
1295  m_canvas->MoveCursor( *aPos );
1297  }
1298  break;
1299 
1300  default:
1301  break;
1302  }
1303 
1304  return key_handled;
1305 }
1306 
1307 
1309 {
1310  const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
1311 
1312  if( !screen )
1313  return false;
1314 
1315  return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
1316  || ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
1317 }
1318 
1319 
1321 {
1322  return BOX2I();
1323 }
1324 
1325 
1326 void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
1327 {
1328 }
1329 
1330 
1331 void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
1332 {
1333 }
1334 
1335 
1337 {
1338 }
1339 
1340 
1341 // Factor out the calculation portion of the various BestZoom() implementations.
1342 //
1343 // Note that like it's forerunners this routine has an intentional side-effect: it
1344 // sets the scroll centre position. While I'm not happy about that, it's probably
1345 // not worth fixing as its days are numbered (GAL canvases use a different method).
1346 double EDA_DRAW_FRAME::bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre )
1347 {
1348  return 1.0;
1349 }
1350 
1351 
1352 void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
1353 {
1354  if ( IsGalCanvasActive() )
1355  {
1356  m_toolManager->RunAction( "common.Control.zoomFitScreen", true );
1357  return;
1358  }
1359 
1360 }
1361 
1362 
1364 {
1365 }
1366 
1367 
1368 void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
1369 {
1370  if( m_canvas == NULL )
1371  return;
1372 
1373  int id = event.GetId();
1374  bool warp_cursor = false;
1375  VECTOR2D cpos = GetCrossHairPosition();//GetGalCanvas()->GetViewControls()->GetCursorPosition();
1376  wxPoint zoom_center( (int)cpos.x, (int)cpos.y );
1377 
1378  if ( id == ID_KEY_ZOOM_IN )
1379  {
1380  id = GetCanvas()->GetEnableZoomNoCenter() ?
1382  }
1383  else if ( id == ID_KEY_ZOOM_OUT )
1384  {
1385  id = GetCanvas()->GetEnableZoomNoCenter() ?
1387  }
1388 
1389  switch( id )
1390  {
1391  case ID_OFFCENTER_ZOOM_IN:
1392  SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
1393  break;
1394 
1395  case ID_POPUP_ZOOM_IN:
1396  warp_cursor = true;
1397  // fall thru
1398  case ID_VIEWER_ZOOM_IN:
1399  case ID_ZOOM_IN:
1400  SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
1401  break;
1402 
1403  case ID_OFFCENTER_ZOOM_OUT:
1404  SetNextZoomAndRedraw( zoom_center, warp_cursor );
1405  break;
1406 
1407  case ID_POPUP_ZOOM_OUT:
1408  warp_cursor = true;
1409  // fall thru
1410  case ID_VIEWER_ZOOM_OUT:
1411  case ID_ZOOM_OUT:
1412  SetNextZoomAndRedraw( zoom_center, warp_cursor );
1413  break;
1414 
1415  case ID_VIEWER_ZOOM_REDRAW:
1416  case ID_POPUP_ZOOM_REDRAW:
1417  case ID_ZOOM_REDRAW:
1418  // This usually means something went wrong. Do a hard refresh.
1419  HardRedraw();
1420  break;
1421 
1422  case ID_POPUP_ZOOM_CENTER:
1423  GetGalCanvas()->GetView()->SetScale( GetGalCanvas()->GetView()->GetScale(), zoom_center );
1425  break;
1426 
1427  case ID_POPUP_ZOOM_PAGE:
1428  case ID_VIEWER_ZOOM_PAGE:
1429  case ID_ZOOM_PAGE:
1430  Zoom_Automatique( false );
1431  break;
1432 
1433  case ID_POPUP_ZOOM_SELECT:
1434  break;
1435 
1436  case ID_POPUP_CANCEL:
1438  break;
1439 
1440  default:
1442  }
1443 
1444  UpdateStatusBar();
1445 }
1446 
1447 
1449 {
1450  GetScreen()->SetNextZoom();
1451 }
1452 
1453 
1455 {
1457 }
1458 
1459 
1460 void EDA_DRAW_FRAME::SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
1461 {
1462  double zoom = GetGalCanvas()->GetLegacyZoom();
1463  zoom *= 1.3;
1464 
1465  // Now look for the next closest menu step
1466  std::vector<double>& zoomList = GetScreen()->m_ZoomList;
1467  int idx;
1468 
1469  for( idx = 0; idx < (int)zoomList.size(); ++idx )
1470  {
1471  if( zoomList[idx] > zoom )
1472  break;
1473  }
1474 
1475  if( idx >= (int)zoomList.size() )
1476  return;
1477 
1478  if( m_zoomSelectBox )
1479  m_zoomSelectBox->SetSelection( idx );
1480 
1481  if( GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] ) )
1482  RedrawScreen( aCenterPoint, aWarpPointer );
1483 }
1484 
1485 
1486 void EDA_DRAW_FRAME::SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
1487 {
1488  double zoom = GetGalCanvas()->GetLegacyZoom();
1489  zoom /= 1.3;
1490 
1491  // Now look for the next closest menu step
1492  std::vector<double>& zoomList = GetScreen()->m_ZoomList;
1493  int idx;
1494 
1495  for( idx = zoomList.size() - 1; idx >= 0; --idx )
1496  {
1497  if( zoomList[idx] < zoom )
1498  break;
1499  }
1500 
1501  if( idx < 0 )
1502  return;
1503 
1504  if( m_zoomSelectBox )
1505  m_zoomSelectBox->SetSelection( idx );
1506 
1507  if( GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] ) )
1508  RedrawScreen( aCenterPoint, aWarpPointer );
1509 }
1510 
1511 
1513 {
1514  BASE_SCREEN* screen = GetScreen();
1515 
1516  if( aIndex >= (int) screen->m_ZoomList.size() )
1517  {
1518  wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ),
1519  __TFILE__, __LINE__, aIndex );
1520  return;
1521  }
1522 
1523  if( m_zoomSelectBox )
1524  m_zoomSelectBox->SetSelection( aIndex );
1525 
1526  if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
1528 
1529  UpdateStatusBar();
1530 }
1531 
1532 
1533 void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
1534 {
1535  int maxZoomIds;
1536  double zoom;
1537  wxString msg;
1538  BASE_SCREEN* screen = m_canvas->GetScreen();
1539 
1540  msg = AddHotkeyName( _( "Center" ), m_hotkeysDescrList, HK_ZOOM_CENTER );
1541  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_CENTER, msg, KiBitmap( zoom_center_on_screen_xpm ) );
1542  msg = AddHotkeyName( _( "Zoom In" ), m_hotkeysDescrList, HK_ZOOM_IN );
1543  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_IN, msg, KiBitmap( zoom_in_xpm ) );
1544  msg = AddHotkeyName( _( "Zoom Out" ), m_hotkeysDescrList, HK_ZOOM_OUT );
1545  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_OUT, msg, KiBitmap( zoom_out_xpm ) );
1546  msg = AddHotkeyName( _( "Redraw View" ), m_hotkeysDescrList, HK_ZOOM_REDRAW );
1547  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_REDRAW, msg, KiBitmap( zoom_redraw_xpm ) );
1548  msg = AddHotkeyName( _( "Zoom to Fit" ), m_hotkeysDescrList, HK_ZOOM_AUTO );
1549  AddMenuItem( MasterMenu, ID_POPUP_ZOOM_PAGE, msg, KiBitmap( zoom_fit_in_page_xpm ) );
1550 
1551 
1552  wxMenu* zoom_choice = new wxMenu;
1553  AddMenuItem( MasterMenu, zoom_choice,
1554  ID_POPUP_ZOOM_SELECT, _( "Zoom" ),
1555  KiBitmap( zoom_selection_xpm ) );
1556 
1557  zoom = screen->GetZoom();
1559  maxZoomIds = ( (size_t) maxZoomIds < screen->m_ZoomList.size() ) ?
1560  maxZoomIds : screen->m_ZoomList.size();
1561 
1562  // Populate zoom submenu.
1563  for( int i = 0; i < maxZoomIds; i++ )
1564  {
1565  msg.Printf( wxT( "%.2f" ), m_zoomLevelCoeff / screen->m_ZoomList[i] );
1566 
1567  zoom_choice->Append( ID_POPUP_ZOOM_LEVEL_START + i, _( "Zoom: " ) + msg,
1568  wxEmptyString, wxITEM_CHECK );
1569  if( zoom == screen->m_ZoomList[i] )
1570  zoom_choice->Check( ID_POPUP_ZOOM_LEVEL_START + i, true );
1571  }
1572 
1573  // Create grid submenu as required.
1574  if( screen->GetGridCount() )
1575  {
1576  wxMenu* gridMenu = new wxMenu;
1577  AddMenuItem( MasterMenu, gridMenu, ID_POPUP_GRID_SELECT,
1578  _( "Grid" ), KiBitmap( grid_select_xpm ) );
1579 
1580  wxArrayString gridsList;
1581  int icurr = screen->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1582 
1583  for( unsigned i = 0; i < gridsList.GetCount(); i++ )
1584  {
1585  GRID_TYPE& grid = screen->GetGrid( i );
1586  gridMenu->Append( grid.m_CmdId, gridsList[i], wxEmptyString, wxITEM_CHECK );
1587 
1588  if( (int)i == icurr )
1589  gridMenu->Check( grid.m_CmdId, true );
1590  }
1591  }
1592 
1593  MasterMenu->AppendSeparator();
1594  AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
1595 }
1596 
1597 
1598 // Find the first child dialog.
1599 wxWindow* findDialog( wxWindowList& aList )
1600 {
1601  for( wxWindow* window : aList )
1602  {
1603  if( dynamic_cast<DIALOG_SHIM*>( window ) )
1604  return window;
1605  }
1606  return NULL;
1607 }
1608 
1609 
1610 void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, bool aCenterView )
1611 {
1612  if( aCenterView )
1613  {
1614  wxWindow* dialog = findDialog( GetChildren() );
1615 
1616  // If a dialog partly obscures the window, then center on the uncovered area.
1617  if( dialog )
1618  {
1619  wxRect dialogRect( GetGalCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
1620  dialog->GetSize() );
1621  GetGalCanvas()->GetView()->SetCenter( aPos, dialogRect );
1622  }
1623  else
1624  GetGalCanvas()->GetView()->SetCenter( aPos );
1625  }
1626 
1627  if( aWarpCursor )
1629  else
1631 }
1632 
1633 
1634 static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
1635 
1636 
1637 void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
1638 {
1639  DrawPageOnClipboard( this );
1640 
1641  if( event.GetId() == ID_GEN_COPY_BLOCK_TO_CLIPBOARD )
1642  {
1643  // fixme-gal
1644  //if( GetScreen()->IsBlockActive() )
1645  //m_canvas->SetCursor( wxCursor( (wxStockCursor) m_canvas->GetDefaultCursor() ) );
1646 
1648  }
1649 }
1650 
1651 
1652 /* copy the current page or block to the clipboard ,
1653  * to export drawings to other applications (word processing ...)
1654  * This is not suitable for copy command within Eeschema or Pcbnew
1655  */
1657 {
1658  bool DrawBlock = false;
1659  wxRect DrawArea;
1660  BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
1661 
1662  if( screen->IsBlockActive() )
1663  {
1664  DrawBlock = true;
1665  DrawArea.SetX( screen->m_BlockLocate.GetX() );
1666  DrawArea.SetY( screen->m_BlockLocate.GetY() );
1667  DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
1668  DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() );
1669  }
1670  else
1671  DrawArea.SetSize( aFrame->GetPageSizeIU() );
1672 
1673  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
1674  // the drawings into the dc size
1675  // scale is the ratio resolution (in PPI) / internal units
1676  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
1677  double inch2Iu = 1000.0 * (double) screen->MilsToIuScalar();
1678  double scale = ppi / inch2Iu;
1679 
1680  wxSize dcsize = DrawArea.GetSize();
1681 
1682  int maxdim = std::max( dcsize.x, dcsize.y );
1683  // the max size in pixels of the bitmap used to byuild the sheet copy
1684  const int maxbitmapsize = 3000;
1685 
1686  while( int( maxdim * scale ) > maxbitmapsize )
1687  {
1688  ppi = ppi / 1.5;
1689  scale = ppi / inch2Iu;
1690  }
1691 
1692  dcsize.x *= scale;
1693  dcsize.y *= scale;
1694 
1695  // Set draw offset, zoom... to values needed to draw in the memory DC
1696  // after saving initial values:
1697  wxPoint tmp_startvisu = screen->m_StartVisu;
1698  double tmpzoom = screen->GetZoom();
1699  wxPoint old_org = screen->m_DrawOrg;
1700  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
1701  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
1702 
1703  screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
1704 
1705  wxMemoryDC dc;
1706  wxBitmap image( dcsize );
1707  dc.SelectObject( image );
1708 
1709  EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox();
1710  GRResetPenAndBrush( &dc );
1711  GRForceBlackPen( false );
1712  screen->m_IsPrinting = true;
1713  dc.SetUserScale( scale, scale );
1714 
1715  aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
1716  wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
1717 
1718  if( DrawBlock )
1719  {
1720  dc.SetClippingRegion( DrawArea );
1721  }
1722 
1723  dc.Clear();
1724  aFrame->GetCanvas()->EraseScreen( &dc );
1725  const LSET allLayersMask = LSET().set();
1726  aFrame->PrintPage( &dc, allLayersMask, false );
1727  screen->m_IsPrinting = false;
1728  aFrame->GetCanvas()->SetClipBox( tmp );
1729 
1730  bool success = true;
1731 
1732  if( wxTheClipboard->Open() )
1733  {
1734  // This data objects are held by the clipboard,
1735  // so do not delete them in the app.
1736  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
1737  wxTheClipboard->SetData( clipbrd_data );
1738  wxTheClipboard->Close();
1739  }
1740  else
1741  success = false;
1742 
1743  // Deselect Bitmap from DC in order to delete the MemoryDC safely
1744  // without deleting the bitmap
1745  dc.SelectObject( wxNullBitmap );
1746 
1747  GRForceBlackPen( false );
1748 
1749  screen->m_StartVisu = tmp_startvisu;
1750  screen->m_DrawOrg = old_org;
1751  screen->SetZoom( tmpzoom );
1752 
1753  return success;
1754 }
1755 
1756 static const wxString productName = wxT( "KiCad E.D.A. " );
1757 
1758 void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
1759  const PAGE_INFO& aPageInfo,
1760  const wxString &aFullSheetName,
1761  const wxString& aFileName,
1762  TITLE_BLOCK& aTitleBlock,
1763  int aSheetCount, int aSheetNumber,
1764  int aPenWidth, double aScalar,
1765  COLOR4D aColor, COLOR4D aAltColor,
1766  const wxString& aSheetLayer )
1767 {
1768  WS_DRAW_ITEM_LIST drawList;
1769 
1770  drawList.SetPenSize( aPenWidth );
1771  drawList.SetMilsToIUfactor( aScalar );
1772  drawList.SetSheetNumber( aSheetNumber );
1773  drawList.SetSheetCount( aSheetCount );
1774  drawList.SetFileName( aFileName );
1775  drawList.SetSheetName( aFullSheetName );
1776  drawList.SetSheetLayer( aSheetLayer );
1777 
1778  drawList.BuildWorkSheetGraphicList( aPageInfo,
1779  aTitleBlock, aColor, aAltColor );
1780 
1781  // Draw item list
1782  drawList.Draw( aClipBox, aDC );
1783 }
1784 
1785 
1786 void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
1787  double aScalar, const wxString &aFilename,
1788  const wxString &aSheetLayer )
1789 {
1791  return;
1792 
1793  const PAGE_INFO& pageInfo = GetPageSettings();
1794  wxSize pageSize = pageInfo.GetSizeMils();
1795 
1796  // if not printing, draw the page limits:
1797  if( !aScreen->m_IsPrinting && m_showPageLimits )
1798  {
1799  GRSetDrawMode( aDC, GR_COPY );
1800  GRRect( m_canvas->GetClipBox(), aDC, 0, 0,
1801  pageSize.x * aScalar, pageSize.y * aScalar, aLineWidth,
1803  }
1804 
1805  TITLE_BLOCK t_block = GetTitleBlock();
1806  COLOR4D color = COLOR4D( RED );
1807 
1808  wxPoint origin = aDC->GetDeviceOrigin();
1809 
1810  if( aScreen->m_IsPrinting && origin.y > 0 )
1811  {
1812  aDC->SetDeviceOrigin( 0, 0 );
1813  aDC->SetAxisOrientation( true, false );
1814  }
1815 
1816  DrawPageLayout( aDC, m_canvas->GetClipBox(), pageInfo,
1817  GetScreenDesc(), aFilename, t_block,
1818  aScreen->m_NumberOfScreens, aScreen->m_ScreenNumber,
1819  aLineWidth, aScalar, color, color, aSheetLayer );
1820 
1821  if( aScreen->m_IsPrinting && origin.y > 0 )
1822  {
1823  aDC->SetDeviceOrigin( origin.x, origin.y );
1824  aDC->SetAxisOrientation( true, true );
1825  }
1826 }
1827 
1828 
1830 {
1831  // Virtual function. Base class implementation returns an empty string.
1832  return wxEmptyString;
1833 }
1834 
1835 bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
1836  const wxString& wildcard, const wxString& ext,
1837  bool isDirectory )
1838 {
1839  wxString prompt = doOpen ? _( "Select Library" ) : _( "New Library" );
1840  aFilename.SetExt( ext );
1841 
1842  if( isDirectory )
1843  {
1844  wxDirDialog dlg( this, prompt, Prj().GetProjectPath(),
1845  doOpen ? wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST : wxDD_DEFAULT_STYLE );
1846 
1847  if( dlg.ShowModal() == wxID_CANCEL )
1848  return false;
1849 
1850  aFilename = dlg.GetPath();
1851  aFilename.SetExt( ext );
1852  }
1853  else
1854  {
1855  wxFileDialog dlg( this, prompt, Prj().GetProjectPath(), aFilename.GetFullName() ,
1856  wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
1857  : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
1858 
1859  if( dlg.ShowModal() == wxID_CANCEL )
1860  return false;
1861 
1862  aFilename = dlg.GetPath();
1863  aFilename.SetExt( ext );
1864  }
1865 
1866  return true;
1867 }
1868 
1869 
1870 bool EDA_DRAW_FRAME::saveCanvasImageToFile( const wxString& aFileName, wxBitmapType aBitmapType )
1871 {
1872  return SaveCanvasImageToFile( this, aFileName, aBitmapType );
1873 }
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.
#define DIM(x)
of elements in an array
Definition: macros.h:98
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:388
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:946
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
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:179
virtual void OnGridSettings(wxCommandEvent &event)
Definition: draw_frame.h:597
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()
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:237
wxChoice * m_gridSelectBox
Definition: draw_frame.h:148
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:464
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Definition: draw_frame.h:528
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
#define ENBL_ZOOM_NO_CENTER_KEY
Definition: pgm_base.h:47
bool m_canvasTypeDirty
Flag indicating that drawing canvas type needs to be saved to config.
Definition: draw_frame.h:176
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.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
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:52
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:50
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:58
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:397
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:599
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.
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:284
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
Definition: common.h:160
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:149
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:48
virtual void ReCreateAuxiliaryToolbar()
Helper dialog and control classes.
#define FILE_HISTORY_SIZE_KEY
Definition: pgm_base.h:51
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:73
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:921
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:46
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.
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:934
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:53
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:187
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
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
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:928
static const double MAX_AXIS
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:537
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:159
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:285
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
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.