KiCad PCB EDA Suite
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-2017 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 <class_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 
49 #include <wx/fontdlg.h>
50 #include <wx/snglinst.h>
51 #include <view/view.h>
52 #include <view/view_controls.h>
54 #include <tool/tool_manager.h>
55 #include <tool/tool_dispatcher.h>
56 #include <tool/actions.h>
57 
62 static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
63 
64 
67 
69 static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
71 static const wxString GridColorEntryKeyword( wxT( "GridColor" ) );
73 static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
75 static const wxString GalDisplayOptionsKeyword( wxT( "GalDisplayOptions" ) );
76 
77 const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
78 
79 static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );
80 
82 
96 static const wxString MaxUndoItemsEntry(wxT( "DevelMaxUndoItems" ) );
97 
98 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
99  EVT_CHAR_HOOK( EDA_DRAW_FRAME::OnCharHook )
100 
101  EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
102  EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
103  EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
105 
107  EDA_DRAW_FRAME::OnZoom )
108 
110  EDA_DRAW_FRAME::OnSelectGrid )
111 
112  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
114  EDA_DRAW_FRAME::OnSelectUnits )
115 
116  // Cursor shape cannot be implemented on OS X
117 #ifndef __APPLE__
119 #endif // !__APPLE__
120 
122  EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
123  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
124  EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
125  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
126  EDA_DRAW_FRAME::OnUpdateUnits )
127 END_EVENT_TABLE()
128 
129 
130 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
131  FRAME_T aFrameType,
132  const wxString& aTitle,
133  const wxPoint& aPos, const wxSize& aSize,
134  long aStyle, const wxString & aFrameName ) :
135  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
136  m_galDisplayOptions( std::make_unique<KIGFX::GAL_DISPLAY_OPTIONS>() )
137 {
138  m_drawToolBar = NULL;
139  m_optionsToolBar = NULL;
140  m_gridSelectBox = NULL;
141  m_zoomSelectBox = NULL;
142  m_hotkeysDescrList = NULL;
143 
144  m_canvas = NULL;
145  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
146  m_canvasTypeDirty = false;
147  m_galCanvas = NULL;
148  m_galCanvasActive = false;
149  m_actions = NULL;
150  m_toolManager = NULL;
151  m_toolDispatcher = NULL;
152  m_messagePanel = NULL;
153  m_currentScreen = NULL;
154  m_toolId = ID_NO_TOOL_SELECTED;
155  m_lastDrawToolId = ID_NO_TOOL_SELECTED;
156  m_showAxis = false; // true to draw axis.
157  m_showBorderAndTitleBlock = false; // true to display reference sheet.
158  m_showGridAxis = false; // true to draw the grid axis
159  m_showOriginAxis = false; // true to draw the grid origin
160  m_LastGridSizeId = 0;
161  m_drawGrid = true; // hide/Show grid. default = show
162  m_gridColor = COLOR4D( DARKGRAY ); // Default grid color
163  m_showPageLimits = false;
164  m_drawBgColor = COLOR4D( BLACK ); // the background color of the draw canvas:
165  // BLACK for Pcbnew, BLACK or WHITE for eeschema
166  m_snapToGrid = true;
167  m_MsgFrameHeight = EDA_MSG_PANEL::GetRequiredHeight();
168  m_movingCursorWithKeyboard = false;
169  m_zoomLevelCoeff = 1.0;
170 
171  m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
172 
173  CreateStatusBar( 6 );
174 
175  // set the size of the status bar subwindows:
176 
177  wxWindow* stsbar = GetStatusBar();
178 
179  int dims[] = {
180 
181  // remainder of status bar on far left is set to a default or whatever is left over.
182  -1,
183 
184  // When using GetTextSize() remember the width of character '1' is not the same
185  // as the width of '0' unless the font is fixed width, and it usually won't be.
186 
187  // zoom:
188  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
189 
190  // cursor coords
191  GetTextSize( wxT( "X 0234.567890 Y 0234.567890" ), stsbar ).x + 10,
192 
193  // delta distances
194  GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
195 
196  // units display, Inches is bigger than mm
197  GetTextSize( _( "Inches" ), stsbar ).x + 10,
198 
199  // Size for the panel used as "Current tool in play": will take longest string from
200  // void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) in pcbnew/edit.cpp
201  GetTextSize( wxT( "Add layer alignment target" ), stsbar ).x + 10,
202  };
203 
204  SetStatusWidths( DIM( dims ), dims );
205 
206  // Create child subwindows.
207  GetClientSize( &m_FrameSize.x, &m_FrameSize.y );
208  m_FramePos.x = m_FramePos.y = 0;
209  m_FrameSize.y -= m_MsgFrameHeight;
210 
211  m_canvas = new EDA_DRAW_PANEL( this, -1, wxPoint( 0, 0 ), m_FrameSize );
212  m_messagePanel = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
213  wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
214 
215  m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
216 }
217 
218 
220 {
221  if( m_canvasTypeDirty )
223 
224  delete m_actions;
225  delete m_toolManager;
226  delete m_toolDispatcher;
227  delete m_galCanvas;
228 
229  delete m_currentScreen;
230  m_currentScreen = NULL;
231 
232  m_auimgr.UnInit();
233 
234  ReleaseFile();
235 }
236 
237 
238 void EDA_DRAW_FRAME::OnCharHook( wxKeyEvent& event )
239 {
240  // Key events can be filtered here.
241  // Currently no filtering is made.
242  event.Skip();
243 }
244 
245 
247 {
248  m_file_checker = nullptr;
249 }
250 
251 
252 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
253 {
254  m_file_checker = ::LockFile( aFileName );
255 
256  return bool( m_file_checker );
257 }
258 
259 
261 {
262  UpdateStatusBar();
263  UpdateMsgPanel();
264 }
265 
266 
268 {
269  if( m_messagePanel )
271 }
272 
273 
274 void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
275 {
276  if( m_canvas )
277  m_canvas->SetCanStartBlock( -1 );
278 
279  event.Skip(); // required under wxMAC
280 }
281 
282 
283 void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
284 {
285  if( m_canvas )
286  m_canvas->SetCanStartBlock( -1 );
287 
288  event.Skip();
289 }
290 
291 
293 {
295 }
296 
297 
298 void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
299 {
301 
302  if( IsGalCanvasActive() )
303  {
306  }
307 
308  m_canvas->Refresh();
309 }
310 
311 
312 void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
313 {
314  if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && g_UserUnit != MILLIMETRES )
315  {
318  }
319  else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && g_UserUnit != INCHES )
320  {
321  g_UserUnit = INCHES;
323  }
324 }
325 
326 
327 void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
328 {
330  m_canvas->CrossHairOff( &dc );
331 
332  auto& galOpts = GetGalDisplayOptions();
333  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
334  galOpts.NotifyChanged();
335 
336  m_canvas->CrossHairOn( &dc );
337 }
338 
339 
340 void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
341 {
342  if( GetScreen() )
343  aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
344 }
345 
346 
347 void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
348 {
349  if( GetScreen() )
350  aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
351 }
352 
353 
354 void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
355 {
356  bool enable;
357 
358  enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (g_UserUnit == MILLIMETRES))
359  || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (g_UserUnit == INCHES)) );
360 
361  aEvent.Check( enable );
362  DisplayUnitsMsg();
363 }
364 
365 
366 void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
367 {
368  wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
369 
370  aEvent.Check( IsGridVisible() );
371  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
372 }
373 
374 
375 void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
376 {
377  aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
378 }
379 
380 
382 {
383 }
384 
385 
387 {
388 }
389 
390 
391 bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
392 {
393  return false;
394 }
395 
396 int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName )
397 {
398  int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
399 
400  if( IsGalCanvasActive() )
402 
403  return result;
404 }
405 
406 void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
407 {
408 }
409 
410 
411 void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
412 {
413  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
414 }
415 
416 
417 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
418 {
419  int* clientData;
420  int eventId = ID_POPUP_GRID_LEVEL_100;
421 
422  if( event.GetEventType() == wxEVT_CHOICE )
423  {
424  if( m_gridSelectBox == NULL ) // Should not happen
425  return;
426 
427  /*
428  * Don't use wxCommandEvent::GetClientData() here. It always
429  * returns NULL in GTK. This solution is not as elegant but
430  * it works.
431  */
432  int index = m_gridSelectBox->GetSelection();
433  wxASSERT( index != wxNOT_FOUND );
434  clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
435 
436  if( clientData != NULL )
437  eventId = *clientData;
438  }
439  else
440  {
441  eventId = event.GetId();
442  }
443 
444  int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
445 
446  // Notify GAL
447  TOOL_MANAGER* mgr = GetToolManager();
448 
449  if( mgr && IsGalCanvasActive() )
450  {
451  mgr->RunAction( "common.Control.gridPreset", true, idx );
452  }
453  else
454  SetPresetGrid( idx );
455 
456  m_canvas->Refresh();
457 }
458 
459 
460 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
461 {
462  if( m_zoomSelectBox == NULL )
463  return; // Should not happen!
464 
465  int id = m_zoomSelectBox->GetCurrentSelection();
466 
467  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
468  return;
469 
470  if( id == 0 ) // Auto zoom (Fit in Page)
471  {
472  Zoom_Automatique( true );
473  }
474  else
475  {
476  id--;
477  double selectedZoom = GetScreen()->m_ZoomList[id];
478 
479  if( GetScreen()->GetZoom() == selectedZoom )
480  return;
481 
482  GetScreen()->SetZoom( selectedZoom );
484  }
485 
486  // Notify GAL
487  TOOL_MANAGER* mgr = GetToolManager();
488 
489  if( mgr && IsGalCanvasActive() )
490  {
491  mgr->RunAction( "common.Control.zoomPreset", true, id );
492  UpdateStatusBar();
493  }
494 }
495 
496 
498 {
499  return GetScreen()->GetZoom();
500 }
501 
502 
503 void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
504 {
505  event.Skip();
506 }
507 
508 
509 void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
510 {
511 }
512 
513 
514 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
515 {
516  SetStatusText( msg, 5 );
517 }
518 
519 
521 {
522  wxString msg;
523 
524  switch( g_UserUnit )
525  {
526  case INCHES:
527  msg = _( "Inches" );
528  break;
529 
530  case MILLIMETRES:
531  msg = _( "mm" );
532  break;
533 
534  default:
535  msg = _( "Units" );
536  break;
537  }
538 
539  SetStatusText( msg, 4 );
540 }
541 
542 
543 
544 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
545 {
546  m_FrameSize = GetClientSize( );
547 
548  SizeEv.Skip();
549 }
550 
551 
552 void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
553 {
554  // Keep default cursor in toolbars
555  SetCursor( wxNullCursor );
556 
557  // Change m_canvas cursor if requested.
558  if( m_canvas && aCursor >= 0 )
559  m_canvas->SetCurrentCursor( aCursor );
560 
561  // Change GAL canvas cursor if requested.
562  if( IsGalCanvasActive() && aCursor >= 0 )
563  GetGalCanvas()->SetCurrentCursor( aCursor );
564 
565  DisplayToolMsg( aToolMsg );
566 
567  if( aId < 0 )
568  return;
569 
570  wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
571  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
572 
573  m_toolId = aId;
574 }
575 
576 
578 {
579  // Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
580 
581  int defaultCursor = wxCURSOR_DEFAULT;
582 
583  // Change GAL canvas cursor if requested.
584  if( IsGalCanvasActive() )
585  defaultCursor = GetGalCanvas()->GetDefaultCursor();
586  else if( m_canvas )
587  defaultCursor = m_canvas->GetDefaultCursor();
588 
589  SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
590 }
591 
593 {
594  wxPoint pos = aPosition;
595 
596  if( m_currentScreen != NULL && m_snapToGrid )
597  pos = GetNearestGridPosition( aPosition );
598 
599  return pos;
600 }
601 
602 
604 {
605  BASE_SCREEN * screen = GetScreen();
606 
607  int new_grid_cmd = screen->GetGridCmdId();
608 
609  // if the grid id is the not the last, increment it
610  if( screen->GridExists( new_grid_cmd + 1 ) )
611  new_grid_cmd += 1;
612 
613  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
614 }
615 
616 
618 {
619  BASE_SCREEN * screen = GetScreen();
620 
621  int new_grid_cmd = screen->GetGridCmdId();
622 
623  // if the grid id is the not the first, increment it
624  if( screen->GridExists( new_grid_cmd - 1 ) )
625  new_grid_cmd -= 1;
626 
627  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
628 }
629 
630 
632 {
633  BASE_SCREEN * screen = GetScreen();
634 
635  if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
636  aIndex = screen->GetGrids()[0].m_CmdId;
637 
638  // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
639  // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
640  int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
641 
642  if( m_gridSelectBox )
643  {
644  if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
645  {
646  wxASSERT_MSG( false, "Invalid grid index" );
647  return;
648  }
649 
650  m_gridSelectBox->SetSelection( glistIdx );
651  }
652 
653  // Be sure m_LastGridSizeId is up to date.
654  m_LastGridSizeId = aIndex;
655  GetScreen()->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 );
656 
657  // Put cursor on new grid
658  SetCrossHairPosition( RefPos( true ) );
659 }
660 
661 
663 {
664  return 0;
665 }
666 
667 
669 {
672 }
673 
674 
676 {
677 }
678 
679 
681 {
682  return false;
683 }
684 
685 
687 {
688  SetStatusText( GetZoomLevelIndicator(), 1 );
689 
690  // Absolute and relative cursor positions are handled by overloading this function and
691  // handling the internal to user units conversion at the appropriate level.
692 
693  // refresh units display
694  DisplayUnitsMsg();
695 }
696 
698 {
699  wxString Line;
700  double level = 0.0;
701 
702  if( IsGalCanvasActive() )
703  {
704  KIGFX::GAL* gal = m_galCanvas->GetGAL();
705  KIGFX::VIEW* view = m_galCanvas->GetView();
706  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
707  level = m_zoomLevelCoeff * zoomFactor * view->GetScale();
708  }
709  else if( BASE_SCREEN* screen = GetScreen() )
710  {
711  level = m_zoomLevelCoeff / (double) screen->GetZoom();
712  }
713 
714  // returns a human readable value which can be displayed as zoom
715  // level indicator in dialogs.
716  Line.Printf( wxT( "Z %.2f" ), level );
717 
718  return Line;
719 }
720 
721 
722 void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
723 {
725 
726  wxString baseCfgName = ConfigBaseName();
727 
728  bool btmp;
729  if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
730  SetGridVisibility( btmp );
731 
732  // Read grid color:
733  COLOR4D wtmp = COLOR4D::UNSPECIFIED;
734 
735  if( wtmp.SetFromWxString( aCfg->Read(
736  baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
737  SetGridColor( wtmp );
738 
739  aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
740 
741  // m_LastGridSizeId is an offset, expected to be >= 0
742  if( m_LastGridSizeId < 0 )
743  m_LastGridSizeId = 0;
744 
745  m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
746  long( DEFAULT_MAX_UNDO_ITEMS ) );
747 
748  aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
749 
750  m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
751 }
752 
753 
754 void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
755 {
757 
758  wxString baseCfgName = ConfigBaseName();
759 
760  aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
761  aCfg->Write( baseCfgName + GridColorEntryKeyword,
762  GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
763  aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
764  aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting );
765 
766  if( GetScreen() )
767  aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
768 
769  m_galDisplayOptions->WriteConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
770 }
771 
772 
773 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
774  const wxString& textLower,
775  COLOR4D color, int pad )
776 {
777  if( m_messagePanel == NULL )
778  return;
779 
780  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
781 }
782 
783 
785 {
786  if( m_messagePanel == NULL )
787  return;
788 
790 }
791 
792 
794 {
795  if( m_messagePanel == NULL )
796  return;
797 
798  ClearMsgPanel();
799 
800  for( unsigned i = 0; i < aList.size(); i++ )
801  m_messagePanel->AppendMessage( aList[i] );
802 }
803 
804 
806 {
807  wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
808 
809  MSG_PANEL_ITEMS items;
810  aItem->GetMsgPanelInfo( items );
811  SetMsgPanel( items );
812 }
813 
814 
816 {
817  EDA_ITEM* item = GetScreen()->GetCurItem();
818 
819  if( item )
820  SetMsgPanel( item );
821 }
822 
823 // FIXME: There needs to be a better way for child windows to load preferences.
824 // This function pushes four preferences from a parent window to a child window
825 // i.e. from eeschema to the schematic symbol editor
827 {
829  m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
830 }
831 
832 wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const
833 {
834  return ::CoordinateToString( aValue, aConvertToMils );
835 }
836 
837 wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) const
838 {
839  return ::LengthDoubleToString( aValue, aConvertToMils );
840 }
841 
842 
843 bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
844  int aExplicitCommand )
845 {
847 
848  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
849  return false;
850 
851  if( aExplicitCommand == 0 )
852  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
853  else
854  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
855 
856  if( block->GetCommand() == 0 )
857  return false;
858 
859  switch( block->GetCommand() )
860  {
861  case BLOCK_IDLE:
862  break;
863 
864  case BLOCK_MOVE: // Move
865  case BLOCK_DRAG: // Drag (block defined)
866  case BLOCK_DRAG_ITEM: // Drag from a drag item command
867  case BLOCK_DUPLICATE: // Duplicate
868  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
869  case BLOCK_DELETE: // Delete
870  case BLOCK_COPY: // Copy
871  case BLOCK_ROTATE: // Rotate 90 deg
872  case BLOCK_FLIP: // Flip
873  case BLOCK_ZOOM: // Window Zoom
874  case BLOCK_MIRROR_X:
875  case BLOCK_MIRROR_Y: // mirror
876  case BLOCK_PRESELECT_MOVE: // Move with preselection list
877  block->InitData( m_canvas, aPosition );
878  break;
879 
880  case BLOCK_PASTE:
881  block->InitData( m_canvas, aPosition );
882  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
884 
885  if( block->GetCount() == 0 ) // No data to paste
886  {
887  DisplayError( this, wxT( "No block to paste" ), 20 );
890  block->SetState( STATE_NO_BLOCK );
891  block->SetMessageBlock( this );
892  return true;
893  }
894 
895  if( !m_canvas->IsMouseCaptured() )
896  {
897  block->ClearItemsList();
898  DisplayError( this,
899  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
900  block->SetState( STATE_NO_BLOCK );
901  block->SetMessageBlock( this );
902  return true;
903  }
904 
905  block->SetState( STATE_BLOCK_MOVE );
906  m_canvas->CallMouseCapture( aDC, aPosition, false );
907  break;
908 
909  default:
910  {
911  wxString msg;
912  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
913  block->GetCommand();
914  DisplayError( this, msg );
915  }
916  break;
917  }
918 
919  block->SetMessageBlock( this );
920  return true;
921 }
922 
923 
924 // I am not seeing a problem with this size yet:
925 static const double MAX_AXIS = INT_MAX - 100;
926 
927 #define VIRT_MIN (-MAX_AXIS/2.0)
928 #define VIRT_MAX (MAX_AXIS/2.0)
929 
930 
931 void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
932 {
933  BASE_SCREEN* screen = GetScreen();
934 
935  if( !screen || !m_canvas )
936  return;
937 
938  double scale = screen->GetScalingFactor();
939 
940  wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
941  aCenterPositionIU.x, aCenterPositionIU.y, scale );
942 
943  // Calculate the portion of the drawing that can be displayed in the
944  // client area at the current zoom level.
945 
946  // visible viewport in device units ~ pixels
947  wxSize clientSizeDU = m_canvas->GetClientSize();
948 
949  // Size of the client window in IU
950  DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
951 
952  // Full drawing or "page" rectangle in internal units
953  DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
954 
955  // Account for scrollbars
956  wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
957  wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
958  wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
959 
960  // The upper left corner of the client rectangle in internal units.
961  double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
962  double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
963 
964  // If drawn around the center, adjust the client rectangle accordingly.
965  if( screen->m_Center )
966  {
967  // half page offset.
968  xIU += pageRectIU.GetWidth() / 2.0;
969  yIU += pageRectIU.GetHeight() / 2.0;
970  }
971 
972  DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
973  wxPoint centerPositionIU;
974 
975  // put "int" limits on the clientRect
976  if( clientRectIU.GetLeft() < VIRT_MIN )
977  clientRectIU.MoveLeftTo( VIRT_MIN );
978  if( clientRectIU.GetTop() < VIRT_MIN )
979  clientRectIU.MoveTopTo( VIRT_MIN );
980  if( clientRectIU.GetRight() > VIRT_MAX )
981  clientRectIU.MoveRightTo( VIRT_MAX );
982  if( clientRectIU.GetBottom() > VIRT_MAX )
983  clientRectIU.MoveBottomTo( VIRT_MAX );
984 
985  centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
986  centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
987 
988  if( screen->m_Center )
989  {
990  centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
991  centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
992  }
993 
994  DSIZE virtualSizeIU;
995 
996  if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
997  {
998  virtualSizeIU.x = pageRectIU.GetSize().x;
999  }
1000  else
1001  {
1002  double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
1003  double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
1004 
1005  if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
1006  {
1007  if( pageCenterX > clientCenterX )
1008  virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
1009  else if( pageCenterX < clientCenterX )
1010  virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
1011  else
1012  virtualSizeIU.x = clientRectIU.GetWidth();
1013  }
1014  else
1015  {
1016  if( pageCenterX > clientCenterX )
1017  virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
1018  else if( pageCenterX < clientCenterX )
1019  virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
1020  else
1021  virtualSizeIU.x = pageRectIU.GetWidth();
1022  }
1023  }
1024 
1025  if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
1026  {
1027  virtualSizeIU.y = pageRectIU.GetSize().y;
1028  }
1029  else
1030  {
1031  double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
1032  double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
1033 
1034  if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
1035  {
1036  if( pageCenterY > clientCenterY )
1037  virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
1038  else if( pageCenterY < clientCenterY )
1039  virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
1040  else
1041  virtualSizeIU.y = clientRectIU.GetHeight();
1042  }
1043  else
1044  {
1045  if( pageCenterY > clientCenterY )
1046  virtualSizeIU.y = pageRectIU.GetHeight() +
1047  ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
1048  else if( pageCenterY < clientCenterY )
1049  virtualSizeIU.y = pageRectIU.GetHeight() +
1050  ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
1051  else
1052  virtualSizeIU.y = pageRectIU.GetHeight();
1053  }
1054  }
1055 
1056  // put "int" limits on the virtualSizeIU
1057  virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
1058  virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
1059 
1060  if( screen->m_Center )
1061  {
1062  screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
1063  screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
1064  }
1065  else
1066  {
1067  screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
1068  screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
1069  }
1070 
1071  /* Always set scrollbar pixels per unit to 1 unless you want the zoom
1072  * around cursor to jump around. This reported problem occurs when the
1073  * zoom point is not on a pixel per unit increment. If you set the
1074  * pixels per unit to 10, you have potential for the zoom point to
1075  * jump around +/-5 pixels from the nearest grid point.
1076  */
1077  screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
1078 
1079  // Number of scroll bar units for the given zoom level in device units.
1080  double unitsX = virtualSizeIU.x * scale;
1081  double unitsY = virtualSizeIU.y * scale;
1082 
1083  // Store the requested center position for later use
1084  SetScrollCenterPosition( aCenterPositionIU );
1085 
1086  // Calculate the scroll bar position in internal units to place the
1087  // center position at the center of client rectangle.
1088  double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
1089  double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
1090 
1091  // Convert scroll bar position to device units.
1092  posX = KiROUND( posX * scale );
1093  posY = KiROUND( posY * scale );
1094 
1095  if( posX < 0 )
1096  {
1097  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1098  posX = 0;
1099  }
1100 
1101  if( posX > unitsX )
1102  {
1103  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1104  posX = unitsX;
1105  }
1106 
1107  if( posY < 0 )
1108  {
1109  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1110  posY = 0;
1111  }
1112 
1113  if( posY > unitsY )
1114  {
1115  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1116  posY = unitsY;
1117  }
1118 
1119  screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
1120  screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
1121 
1122  wxLogTrace( traceScrollSettings,
1123  wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
1124  virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
1125  screen->m_DrawOrg.x, screen->m_DrawOrg.y,
1127  screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
1128  screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
1129 
1130  bool noRefresh = true;
1131 
1132  m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
1133  screen->m_ScrollPixelsPerUnitY,
1134  screen->m_ScrollbarNumber.x,
1135  screen->m_ScrollbarNumber.y,
1136  screen->m_ScrollbarPos.x,
1137  screen->m_ScrollbarPos.y, noRefresh );
1138 }
1139 
1140 
1141 void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
1142 {
1143  KIGFX::VIEW* view = GetGalCanvas()->GetView();
1144  KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
1145 
1146  // Display the same view after canvas switching
1147  if( aEnable )
1148  {
1149  // Switch to GAL renderer from legacy
1150  if( !m_galCanvasActive )
1151  {
1152  // Set up viewport
1153  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1154  double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
1155  view->SetScale( zoom );
1157  }
1158 
1159  // Set up grid settings
1160  gal->SetGridVisibility( IsGridVisible() );
1161  gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
1162  gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
1163 
1164  // Transfer EDA_DRAW_PANEL settings
1168  }
1169  else if( m_galCanvasActive )
1170  {
1171  // Switch to legacy renderer from GAL
1172  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1173  // TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
1174  m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
1175  VECTOR2D center = view->GetCenter();
1176  AdjustScrollBars( wxPoint( center.x, center.y ) );
1177  }
1178 
1179  m_canvas->SetEvtHandlerEnabled( !aEnable );
1180  GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
1181 
1182  // Switch panes
1183  m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
1184  m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
1185  m_auimgr.Update();
1186 
1187  // Reset current tool on switch();
1189 
1190  m_galCanvasActive = aEnable;
1191 }
1192 
1193 
1195 {
1197  wxConfigBase* cfg = Kiface().KifaceSettings();
1198 
1199  if( cfg )
1200  canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE) cfg->ReadLong( CANVAS_TYPE_KEY,
1202 
1203  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1204  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1205  {
1206  assert( false );
1207  canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1208  }
1209 
1210  return canvasType;
1211 }
1212 
1213 
1215 {
1216  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1217  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1218  {
1219  assert( false );
1220  return false;
1221  }
1222 
1223  wxConfigBase* cfg = Kiface().KifaceSettings();
1224 
1225  if( cfg )
1226  return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
1227 
1228  return false;
1229 }
1230 
1231 //-----< BASE_SCREEN API moved here >--------------------------------------------
1232 
1234 {
1235  // subject to change, borrow from old BASE_SCREEN for now.
1236  if( IsGalCanvasActive() )
1237  {
1239 
1240  return wxPoint( cursor.x, cursor.y );
1241  }
1242  else
1243  {
1244  BASE_SCREEN* screen = GetScreen(); // virtual call
1245  return screen->getCrossHairPosition( aInvertY );
1246  }
1247 }
1248 
1249 
1250 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1251 {
1252  BASE_SCREEN* screen = GetScreen(); // virtual call
1253  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1254 }
1255 
1256 
1257 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1258 {
1259  BASE_SCREEN* screen = GetScreen(); // virtual call
1260  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1261 }
1262 
1263 
1264 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
1265 {
1266  BASE_SCREEN* screen = GetScreen(); // virtual call
1267  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1268 }
1269 
1270 
1272 {
1273  BASE_SCREEN* screen = GetScreen(); // virtual call
1274  return screen->getCrossHairScreenPosition();
1275 }
1276 
1277 
1279 {
1280  BASE_SCREEN* screen = GetScreen(); // virtual call
1281  screen->setMousePosition( aPosition );
1282 }
1283 
1284 
1285 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1286 {
1287  BASE_SCREEN* screen = GetScreen(); // virtual call
1288  return screen->refPos( useMouse );
1289 }
1290 
1291 
1293 {
1294  BASE_SCREEN* screen = GetScreen(); // virtual call
1295  return screen->getScrollCenterPosition();
1296 }
1297 
1298 
1300 {
1301  BASE_SCREEN* screen = GetScreen(); // virtual call
1302  screen->setScrollCenterPosition( aPoint );
1303 }
1304 
1305 //-----</BASE_SCREEN API moved here >--------------------------------------------
1306 
1308  const wxPoint &aEvtPos,
1309  wxDC* aDC )
1310 {
1311  wxPoint newpos = GetCrossHairPosition();
1312 
1313  // Redraw the crosshair if it moved
1314  if( aOldPos != newpos )
1315  {
1316  SetCrossHairPosition( aOldPos, false );
1317  m_canvas->CrossHairOff( aDC );
1318  SetCrossHairPosition( newpos, false );
1319  m_canvas->CrossHairOn( aDC );
1320 
1321  if( m_canvas->IsMouseCaptured() )
1322  {
1323 #ifdef USE_WX_OVERLAY
1324  wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
1325  oDC.Clear();
1326  m_canvas->CallMouseCapture( aDC, aEvtPos, false );
1327 #else
1328  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1329 #endif
1330  }
1331 #ifdef USE_WX_OVERLAY
1332  else
1333  {
1334  m_overlay.Reset();
1335  }
1336 #endif
1337  }
1338 }
1339 
1341  bool aSnapToGrid )
1342 {
1343  bool key_handled = false;
1344 
1345  // If requested snap the current position to the grid
1346  if( aSnapToGrid )
1347  *aPos = GetNearestGridPosition( *aPos );
1348 
1349  switch( aHotKey )
1350  {
1351  // All these keys have almost the same treatment
1352  case GR_KB_CTRL | WXK_NUMPAD8:
1353  case GR_KB_CTRL | WXK_UP:
1354  case GR_KB_CTRL | WXK_NUMPAD2:
1355  case GR_KB_CTRL | WXK_DOWN:
1356  case GR_KB_CTRL | WXK_NUMPAD4:
1357  case GR_KB_CTRL | WXK_LEFT:
1358  case GR_KB_CTRL | WXK_NUMPAD6:
1359  case GR_KB_CTRL | WXK_RIGHT:
1360  case WXK_NUMPAD8:
1361  case WXK_UP:
1362  case WXK_NUMPAD2:
1363  case WXK_DOWN:
1364  case WXK_NUMPAD4:
1365  case WXK_LEFT:
1366  case WXK_NUMPAD6:
1367  case WXK_RIGHT:
1368  key_handled = true;
1369  {
1370  /* Here's a tricky part: when doing cursor key movement, the
1371  * 'previous' point should be taken from memory, *not* from the
1372  * freshly computed position in the event. Otherwise you can't do
1373  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1374  * the automatic motion event generated by cursor warping */
1375  wxRealPoint gridSize = GetScreen()->GetGridSize();
1376  *aPos = GetCrossHairPosition();
1377 
1378  // Bonus: ^key moves faster (x10)
1379  switch( aHotKey )
1380  {
1381  case GR_KB_CTRL|WXK_NUMPAD8:
1382  case GR_KB_CTRL|WXK_UP:
1383  aPos->y -= KiROUND( 10 * gridSize.y );
1384  break;
1385 
1386  case GR_KB_CTRL|WXK_NUMPAD2:
1387  case GR_KB_CTRL|WXK_DOWN:
1388  aPos->y += KiROUND( 10 * gridSize.y );
1389  break;
1390 
1391  case GR_KB_CTRL|WXK_NUMPAD4:
1392  case GR_KB_CTRL|WXK_LEFT:
1393  aPos->x -= KiROUND( 10 * gridSize.x );
1394  break;
1395 
1396  case GR_KB_CTRL|WXK_NUMPAD6:
1397  case GR_KB_CTRL|WXK_RIGHT:
1398  aPos->x += KiROUND( 10 * gridSize.x );
1399  break;
1400 
1401  case WXK_NUMPAD8:
1402  case WXK_UP:
1403  aPos->y -= KiROUND( gridSize.y );
1404  break;
1405 
1406  case WXK_NUMPAD2:
1407  case WXK_DOWN:
1408  aPos->y += KiROUND( gridSize.y );
1409  break;
1410 
1411  case WXK_NUMPAD4:
1412  case WXK_LEFT:
1413  aPos->x -= KiROUND( gridSize.x );
1414  break;
1415 
1416  case WXK_NUMPAD6:
1417  case WXK_RIGHT:
1418  aPos->x += KiROUND( gridSize.x );
1419  break;
1420 
1421  default: /* Can't happen since we entered the statement */
1422  break;
1423  }
1424 
1425  m_canvas->MoveCursor( *aPos );
1427  }
1428  break;
1429 
1430  default:
1431  break;
1432  }
1433 
1434  return key_handled;
1435 }
1436 
1437 
1439 {
1440  const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
1441 
1442  if( !screen )
1443  return false;
1444 
1445  return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
1446  || ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
1447 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:95
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:118
virtual void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
Definition: draw_frame.cpp:386
#define DIM(x)
of elements in an array
Definition: macros.h:98
const VECTOR2D & GetCenter() const
Function GetCenter() Returns the center point of this VIEW (in world space coordinates) ...
Definition: view.h:316
coord_type GetY() const
Definition: box2.h:179
wxPoint getCursorPosition(bool aOnGrid, const wxPoint &aGridOrigin, wxRealPoint *aGridSize) const
Function getCursorPosition returns the current cursor position in logical (drawing) units...
double GetZoom()
Definition: draw_panel.cpp:276
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:282
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:111
wxPoint GetScreenCenterLogicalPosition()
Function GetScreenCenterLogicalPosition.
Definition: draw_panel.cpp:345
std::unique_ptr< KIGFX::GAL_DISPLAY_OPTIONS > m_galDisplayOptions
Definition: draw_frame.h:71
void AdjustScrollBars(const wxPoint &aCenterPosition)
Definition: draw_frame.cpp:931
void OnToggleCrossHairStyle(wxCommandEvent &aEvent)
Definition: draw_frame.cpp:327
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Structure EDA_HOTKEY_CONFIG contains the information required to save hot key information to a config...
Definition: hotkeys_basic.h:87
bool m_galCanvasActive
whether to use new GAL engine
Definition: draw_frame.h:66
void SetCurrentCursor(int aCursor)
Function SetCurrentCursor Set the current cursor shape for drawpanel.
static const wxString FirstRunShownKeyword(wxT("FirstRunShown"))
static const wxString MaxUndoItemsEntry(wxT("DevelMaxUndoItems"))
Integer to set the maximum number of undo items on the stack.
wxSize m_ScrollbarNumber
Current virtual draw area size in scroll units.
#define VIRT_MAX
max X or Y coordinate in virtual space
Definition: draw_frame.cpp:928
int m_ScrollPixelsPerUnitY
Pixels per scroll unit in the vertical direction.
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:900
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:697
void setScrollCenterPosition(const wxPoint &aPoint)
EDA_ITEM * GetCurItem() const
virtual void HandleBlockPlace(wxDC *DC)
Function HandleBlockPlace( ) Called after HandleBlockEnd, when a block command needs to be executed a...
Definition: draw_frame.cpp:675
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:332
double GetScalingFactor() const
Function GetScalingFactor returns the inverse of the current scale used to draw items on screen...
Definition: base_screen.cpp:92
bool GetEnableAutoPan() const
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
Function GetGridPosition returns the nearest grid position to aPosition if a screen is defined and sn...
Definition: draw_frame.cpp:592
virtual int BlockCommand(EDA_KEY aKey)
Function BlockCommand Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the...
Definition: draw_frame.cpp:662
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:96
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:679
double GetWorldScale() const
Get the world scale.
#define DEFAULT_MAX_UNDO_ITEMS
Definition: draw_frame.h:46
int GetGridCmdId() const
Return the command ID of the currently selected grid.
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:148
#define VIRT_MIN
min X or Y coordinate in virtual space
Definition: draw_frame.cpp:927
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
void SetScrollCenterPosition(const wxPoint &aPoint)
wxPoint getCrossHairScreenPosition() const
Function getCursorScreenPosition returns the cross hair position in device (display) units...
void OnMouseEvent(wxMouseEvent &event)
Definition: draw_frame.cpp:503
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: basicframe.cpp:320
void MoveBottomTo(coord_type aBottom)
Definition: box2.h:194
void SetMessageBlock(EDA_DRAW_FRAME *frame)
Function SetMessageBlock Displays the type of block command in the status bar of the window...
virtual bool OnHotKey(wxDC *aDC, int aHotKey, const wxPoint &aPosition, EDA_ITEM *aItem=NULL)
Definition: draw_frame.cpp:391
virtual void EnableMousewheelPan(bool aEnable)
Function EnableMousewheelPan() Enables or disables mousewheel panning.
wxString ConfigBaseName()
Function ConfigBaseName.
Definition: wxstruct.h:266
coord_type GetRight() const
Definition: box2.h:187
const GRIDS & GetGrids() const
Function GetGrids().
BLOCK_COMMAND_T
wxPoint GetCursorPosition(bool aOnGrid, wxRealPoint *aGridSize=NULL) const
Function GetCursorPosition returns 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
void SetCanStartBlock(int aStartBlock)
void ReleaseFile()
Function ReleaseFile Release the current file marked in use.
Definition: draw_frame.cpp:246
const wxPoint & GetScrollCenterPosition() const
Template specialization to enable wxStrings for certain containers (e.g. unordered_map) ...
Definition: bitmap.cpp:54
virtual void ToolOnRightClick(wxCommandEvent &event)
Definition: draw_frame.cpp:406
wxAuiManager m_auimgr
Definition: wxstruct.h:149
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void OnMenuOpen(wxMenuEvent &event)
Definition: draw_frame.cpp:283
void SkipNextLeftButtonReleaseEvent()
function SkipNextLeftButtonReleaseEvent after calling this function, if the left mouse button is down...
Definition: draw_frame.cpp:292
virtual void SetGridColor(COLOR4D aColor)
Function SetGridColor() , virtual.
Definition: draw_frame.h:518
FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::ProcessPreferences 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::OnUpdateLoadModuleFromBoard FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH
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
void MoveCursor(const wxPoint &aPosition)
Function MoveCursor moves the mouse pointer to aPosition in logical (drawing) units.
Definition: draw_panel.cpp:360
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()
Function SetPrevGrid() changes the grid size settings to the previous one available.
Definition: draw_frame.cpp:617
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
void PushPreferences(const EDA_DRAW_PANEL *aParentCanvas)
Function PushPreferences Pushes a few preferences from a parent window to a child window...
Definition: draw_frame.cpp:826
const Vec & GetSize() const
Definition: box2.h:177
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:247
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
wxChoice * m_gridSelectBox
Choice box to choose the grid size.
Definition: draw_frame.h:119
virtual void UseGalCanvas(bool aEnable)
Function UseGalCanvas used 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:75
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:754
virtual void InitBlockPasteInfos()
Definition: draw_frame.cpp:668
coord_type GetTop() const
Definition: box2.h:192
virtual const wxSize GetPageSizeIU() const =0
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
wxPoint refPos(bool useMouse) const
Function RefPos Return the reference position, coming from either the mouse position or the cursor po...
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:490
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:125
bool m_canvasTypeDirty
Flag indicating that drawing canvas type needs to be saved to config.
Definition: draw_frame.h:145
Auxiliary rendering target (noncached)
Definition: definitions.h:42
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)
Function GetTextSize returns the size of aSingleLine of text when it is rendered in aWindow using wha...
Definition: common.cpp:93
void DisplayUnitsMsg()
Function DisplayUnitsMsg displays current unit pane on the status bar.
Definition: draw_frame.cpp:520
void OnUpdateUndo(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:340
bool GeneralControlKeyMovement(int aHotKey, wxPoint *aPos, bool aSnapToGrid)
Function GeneralControlKeyMovement Handle the common part of GeneralControl dedicated to global curso...
coord_type GetWidth() const
Definition: box2.h:185
void SetState(BLOCK_STATE_T aState)
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.
Definition: draw_frame.cpp:843
void EnableCursorWarping(bool aEnable)
Function EnableCursorWarping() Enables or disables warping the cursor.
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
void MoveLeftTo(coord_type aLeft)
Definition: box2.h:195
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
static const wxString GalDisplayOptionsKeyword(wxT("GalDisplayOptions"))
GAL Display Options.
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:356
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:129
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:565
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
void OnUpdateRedo(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:347
BASE_SCREEN * m_currentScreen
current used SCREEN
Definition: draw_frame.h:63
virtual void PrintPage(wxDC *aDC, LSET aPrintMask, bool aPrintMirrorMode, void *aData=NULL)
Function PrintPage used to print a page Print the page pointed by current screen, set by the calling ...
Definition: draw_frame.cpp:411
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:588
wxPoint getCrossHairPosition(bool aInvertY) const
Function getCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:793
void EraseMsgBox()
Definition: draw_frame.cpp:267
wxString LengthDoubleToString(double aValue, bool aConvertToMils=false) const
Function LengthDoubleToString is a helper to convert the double value aValue to a string in inches or...
Definition: draw_frame.cpp:837
wxPoint getNearestGridPosition(const wxPoint &aPosition, const wxPoint &aGridOrigin, wxRealPoint *aGridSize) const
Function getNearestGridPosition returns the nearest aGridSize location to aPosition.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:568
bool m_Center
Center on screen.
bool IsMouseCaptured() const
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:132
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
Definition: common.h:145
wxChoice * m_zoomSelectBox
Choice box to choose the zoom value.
Definition: draw_frame.h:122
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
Definition: basicframe.cpp:260
double GetZoom()
Function GetZoom.
Definition: draw_frame.cpp:497
bool GetEnableZoomNoCenter() const
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
coord_type GetBottom() const
Definition: box2.h:188
void SetZoom(double mode)
Definition: draw_panel.cpp:282
static const wxString ShowGridEntryKeyword(wxT("ShowGrid"))
Nonzero to show grid (suffix)
int m_ScrollPixelsPerUnitX
Pixels per scroll unit in the horizontal direction.
virtual void ReCreateAuxiliaryToolbar()
Definition: draw_frame.cpp:381
Helper dialog and control classes.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
uint32_t EDA_KEY
Definition: common.h:52
void OnUpdateUnits(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:354
wxString LengthDoubleToString(double aValue, bool aConvertToMils)
Function LengthDoubleToString is a helper to convert the double length aValue to a string in inches...
Definition: base_units.cpp:123
void setMousePosition(const wxPoint &aPosition)
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:871
virtual void OnSize(wxSizeEvent &event)
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...
Definition: draw_frame.cpp:544
void OnToggleGridState(wxCommandEvent &aEvent)
Definition: draw_frame.cpp:298
const wxPoint & getScrollCenterPosition() const
virtual void EnableAutoPan(bool aEnabled)
Function EnableAutoPan Turns on/off auto panning (user setting to disable it entirely).
bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
void SetPresetGrid(int aIndex)
Function SetPresetGrid() changes the grid size to one of the preset values.
Definition: draw_frame.cpp:631
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:89
void EraseMsgBox()
Definition: msgpanel.cpp:215
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)
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Definition: draw_frame.cpp:552
void SetCurrentCursor(int aCursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
ID_POPUP_GRID_USER
Definition: draw_frame.cpp:109
virtual const wxPoint & GetGridOrigin() const =0
Function GetGridOrigin returns the absolute coordinates of the origin of the snap grid...
int m_LastGridSizeId
Definition: draw_frame.h:78
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:509
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:259
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: base_struct.h:304
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
Definition: solve.cpp:178
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:722
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting() const
Returns the canvas type stored in the application settings.
wxPoint m_ScrollbarPos
Current scroll bar position in scroll units.
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()
Function SetNextGrid() changes the grid size settings to the next one available.
Definition: draw_frame.cpp:603
EDA_DRAW_PANEL_GAL * m_galCanvas
GAL display options - this is the frame's interface to setting GAL display options.
Definition: draw_frame.h:68
static const wxString traceScrollSettings(wxT("KicadScrollSettings"))
Definition for enabling and disabling scroll bar setting trace output.
virtual bool HandleBlockEnd(wxDC *DC)
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
Definition: draw_frame.cpp:680
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
static const wxString LastGridSizeIdKeyword(wxT("_LastGridSize"))
Most recently used grid size (suffix)
wxPoint RefPos(bool useMouse) const
Function RefPos Return the reference position, coming from either the mouse position or the cursor po...
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:577
coord_type GetHeight() const
Definition: box2.h:186
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:773
void OnUpdateCrossHairStyle(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:375
void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Function RedrawScreen redraws the entire screen area by updating the scroll bars and mouse pointer in...
Definition: zoom.cpp:46
TOOL_MANAGER * GetToolManager() const
Function GetToolManager returns the tool manager instance, if any.
Definition: draw_frame.h:886
void setCrossHairPosition(const wxPoint &aPosition, const wxPoint &aGridOrigin, bool aSnapToGrid)
Function setCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
void CrossHairOn(wxDC *DC)
Definition: draw_panel.cpp:266
static const double MAX_AXIS
Definition: draw_frame.cpp:925
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:86
wxPoint GetNearestGridPosition(const wxPoint &aPosition, wxRealPoint *aGridSize=NULL) const
Function GetNearestGridPosition returns the nearest aGridSize location to aPosition.
const int scale
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:514
bool GridExists(int aCommandId)
Function GridExists tests for grid command ID (not an index in grid list, but a wxID) exists in grid ...
see class PGM_BASE
virtual void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Definition: draw_frame.cpp:417
BASE_SCREEN class implementation.
void OnUpdateGrid(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:366
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
BLOCK_STATE_T GetState() const
bool GetEnableMousewheelPan() const
KICAD_MANAGER_FRAME::language_change KICAD_MANAGER_FRAME::OnChangeIconsOptions EVT_UPDATE_UI(ID_SELECT_PREFERED_PDF_BROWSER, KICAD_MANAGER_FRAME::OnUpdatePreferredPdfBrowser) EVT_UPDATE_UI_RANGE(ID_TO_SCH
#define INSTALL_UNBUFFERED_DC(name, parent)
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...
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
The common library.
double GetZoomFactor() const
Get the zoom factor.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
double GetScale() const
Function GetScale()
Definition: view.h:265
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
>
Definition: draw_frame.cpp:396
BLOCK_COMMAND_T GetCommand() const
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:879
virtual void SetGridVisibility(bool aVisible)
Function SetGridVisibility() , virtual It may be overloaded by derived classes.
Definition: draw_frame.h:500
static const wxChar CANVAS_TYPE_KEY[]
Key in KifaceSettings to store the canvas type.
Definition: draw_frame.h:193
static const wxString GridColorEntryKeyword(wxT("GridColor"))
Grid color ID (suffix)
wxSize m_FrameSize
Definition: wxstruct.h:140
coord_type GetLeft() const
Definition: box2.h:191
Definition: colors.h:45
virtual void OnCharHook(wxKeyEvent &event)
this function capture the key event before it is sent to the GUI.
Definition: draw_frame.cpp:238
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)
Definition: draw_frame.cpp:312
virtual void unitsChangeRefresh()
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: draw_frame.cpp:260
Class VIEW.
Definition: view.h:58
int GetDefaultCursor() const
Function GetDefaultCursor.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
wxString CoordinateToString(int aValue, bool aConvertToMils=false) const
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: draw_frame.cpp:832
void MoveTopTo(coord_type aTop)
Definition: box2.h:193
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
coord_type GetX() const
Definition: box2.h:178
Message panel definition file.
wxPoint GetCrossHairScreenPosition() const
Function GetCursorScreenPosition returns the cross hair position in device (display) units...
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
int GetDefaultCursor() const
Function GetDefaultCursor.
ACTIONS * m_actions
Definition: draw_frame.h:97
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
Definition: draw_frame.cpp:509
#define GR_KB_CTRL
Definition: common.h:64
static int GetRequiredHeight()
Function GetRequiredHeight returns the required height (in pixels) of a EDA_MSG_PANEL.
Definition: msgpanel.cpp:71
void SetEnableAutoPan(bool aEnable)
Definition: draw_panel.cpp:670
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:686
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:74
bool isBusy() const
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
unsigned GetCount() const
virtual void OnActivate(wxActivateEvent &event)
Function OnActivate (virtual) is called when activating the frame.
Definition: draw_frame.cpp:274
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:142
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:784
void UpdateHotKeys()
>
long m_firstRunDialogSetting
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:116
virtual void OnSelectZoom(wxCommandEvent &event)
Functions OnSelectZoom sets the zoom factor when selected by the zoom list box in the main tool bar...
Definition: draw_frame.cpp:460
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
bool m_snapToGrid
Indicates if cursor should be snapped to grid.
Definition: draw_frame.h:65
bool LockFile(const wxString &aFileName)
Function LockFile marks a schematic file as being in use.
Definition: draw_frame.cpp:252
void SetCommand(BLOCK_COMMAND_T aCommand)
#define min(a, b)
Definition: auxiliary.h:85
Class GAL is the abstract interface for drawing on a 2D-surface.
virtual void UpdateMsgPanel()
Function UpdateMsgPanel redraws the message panel.
Definition: draw_frame.cpp:815
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void MoveRightTo(coord_type aRight)
Definition: box2.h:196
void SetIgnoreLeftButtonReleaseEvent(bool aIgnore)
File locking utilities.