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