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-2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <fctsys.h>
31 #include <pgm_base.h>
32 #include <kiface_i.h>
33 #include <gr_basic.h>
34 #include <common.h>
35 #include <bitmaps.h>
36 #include <macros.h>
37 #include <id.h>
38 #include <class_drawpanel.h>
39 #include <base_screen.h>
40 #include <msgpanel.h>
41 #include <draw_frame.h>
42 #include <confirm.h>
43 #include <kicad_device_context.h>
44 #include <dialog_helpers.h>
45 #include <base_units.h>
46 #include <math/box2.h>
47 #include <lockfile.h>
48 #include <trace_helpers.h>
49 
50 #include <wx/fontdlg.h>
51 #include <wx/snglinst.h>
52 #include <view/view.h>
53 #include <view/view_controls.h>
55 #include <tool/tool_manager.h>
56 #include <tool/tool_dispatcher.h>
57 #include <tool/actions.h>
58 
63 static const wxString traceScrollSettings( wxT( "KicadScrollSettings" ) );
64 
65 
68 
70 static const wxString ShowGridEntryKeyword( wxT( "ShowGrid" ) );
72 static const wxString GridColorEntryKeyword( wxT( "GridColor" ) );
74 static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
76 static const wxString GalDisplayOptionsKeyword( wxT( "GalDisplayOptions" ) );
77 
78 const wxChar EDA_DRAW_FRAME::CANVAS_TYPE_KEY[] = wxT( "canvas_type" );
79 
80 static const wxString FirstRunShownKeyword( wxT( "FirstRunShown" ) );
81 
83 
97 static const wxString MaxUndoItemsEntry(wxT( "DevelMaxUndoItems" ) );
98 
99 BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
100  EVT_CHAR_HOOK( EDA_DRAW_FRAME::OnCharHook )
101 
102  EVT_MOUSEWHEEL( EDA_DRAW_FRAME::OnMouseEvent )
103  EVT_MENU_OPEN( EDA_DRAW_FRAME::OnMenuOpen )
104  EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
106 
108  EDA_DRAW_FRAME::OnZoom )
109 
111  EDA_DRAW_FRAME::OnSelectGrid )
112 
113  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnToggleGridState )
115  EDA_DRAW_FRAME::OnSelectUnits )
116 
117  EVT_TOOL( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnToggleCrossHairStyle )
118 
119  EVT_UPDATE_UI( wxID_UNDO, EDA_DRAW_FRAME::OnUpdateUndo )
120  EVT_UPDATE_UI( wxID_REDO, EDA_DRAW_FRAME::OnUpdateRedo )
121  EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_GRID, EDA_DRAW_FRAME::OnUpdateGrid )
122  EVT_UPDATE_UI( ID_TB_OPTIONS_SELECT_CURSOR, EDA_DRAW_FRAME::OnUpdateCrossHairStyle )
123  EVT_UPDATE_UI_RANGE( ID_TB_OPTIONS_SELECT_UNIT_MM, ID_TB_OPTIONS_SELECT_UNIT_INCH,
124  EDA_DRAW_FRAME::OnUpdateUnits )
125 END_EVENT_TABLE()
126 
127 
128 EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
129  FRAME_T aFrameType,
130  const wxString& aTitle,
131  const wxPoint& aPos, const wxSize& aSize,
132  long aStyle, const wxString & aFrameName ) :
133  KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
134  m_galDisplayOptions( std::make_unique<KIGFX::GAL_DISPLAY_OPTIONS>() )
135 {
136  m_socketServer = nullptr;
137  m_drawToolBar = NULL;
138  m_optionsToolBar = NULL;
139  m_auxiliaryToolBar = 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  delete m_socketServer;
222  for( auto socket : m_sockets )
223  {
224  socket->Shutdown();
225  socket->Destroy();
226  }
227 
228  if( m_canvasTypeDirty )
230 
231  delete m_actions;
232  delete m_toolManager;
233  delete m_toolDispatcher;
234  delete m_galCanvas;
235 
236  delete m_currentScreen;
237  m_currentScreen = NULL;
238 
239  m_auimgr.UnInit();
240 
241  ReleaseFile();
242 }
243 
244 
245 void EDA_DRAW_FRAME::OnCharHook( wxKeyEvent& event )
246 {
247  wxLogTrace( kicadTraceKeyEvent, "EDA_DRAW_FRAME::OnCharHook %s", dump( event ) );
248  // Key events can be filtered here.
249  // Currently no filtering is made.
250  event.Skip();
251 }
252 
253 
255 {
256  m_file_checker = nullptr;
257 }
258 
259 
260 bool EDA_DRAW_FRAME::LockFile( const wxString& aFileName )
261 {
262  m_file_checker = ::LockFile( aFileName );
263 
264  return bool( m_file_checker );
265 }
266 
267 
269 {
270  UpdateStatusBar();
271  UpdateMsgPanel();
272 }
273 
274 
276 {
277  if( m_messagePanel )
279 }
280 
281 
282 void EDA_DRAW_FRAME::OnActivate( wxActivateEvent& event )
283 {
284  if( m_canvas )
285  m_canvas->SetCanStartBlock( -1 );
286 
287  event.Skip(); // required under wxMAC
288 }
289 
290 
291 void EDA_DRAW_FRAME::OnMenuOpen( wxMenuEvent& event )
292 {
293  if( m_canvas )
294  m_canvas->SetCanStartBlock( -1 );
295 
296  event.Skip();
297 }
298 
299 
301 {
303 }
304 
305 
306 void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
307 {
309 
310  if( IsGalCanvasActive() )
311  {
314  }
315 
316  m_canvas->Refresh();
317 }
318 
320 {
321  // Checks all the toolbars and returns true if the given tool id is toggled.
322  return ( ( m_mainToolBar && m_mainToolBar->GetToolToggled( aToolId ) ) ||
323  ( m_optionsToolBar && m_optionsToolBar->GetToolToggled( aToolId ) ) ||
324  ( m_drawToolBar && m_drawToolBar->GetToolToggled( aToolId ) ) ||
325  ( m_auxiliaryToolBar && m_auxiliaryToolBar->GetToolToggled( aToolId ) )
326  );
327 }
328 
329 
330 wxAuiToolBarItem* EDA_DRAW_FRAME::GetToolbarTool( int aToolId )
331 {
332  // Checks all the toolbars and returns a reference to the given tool id
333  // (or the first tool found, but only one or 0 tool is expected, because on
334  // Windows, when different tools have the same ID, it creates issues)
335  if( m_mainToolBar && m_mainToolBar->FindTool( aToolId ) )
336  return m_mainToolBar->FindTool( aToolId );
337 
338  if( m_optionsToolBar && m_optionsToolBar->FindTool( aToolId ) )
339  return m_optionsToolBar->FindTool( aToolId );
340 
341  if( m_drawToolBar && m_drawToolBar->FindTool( aToolId ) )
342  return m_drawToolBar->FindTool( aToolId );
343 
344  if( m_auxiliaryToolBar && m_auxiliaryToolBar->FindTool( aToolId ) )
345  return m_auxiliaryToolBar->FindTool( aToolId );
346 
347  return nullptr;
348 }
349 
350 
351 void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
352 {
353  if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && g_UserUnit != MILLIMETRES )
354  {
357  }
358  else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && g_UserUnit != INCHES )
359  {
360  g_UserUnit = INCHES;
362  }
363 }
364 
365 
366 void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
367 {
369  m_canvas->CrossHairOff( &dc );
370 
371  auto& galOpts = GetGalDisplayOptions();
372  galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
373  galOpts.NotifyChanged();
374 
375  m_canvas->CrossHairOn( &dc );
376 }
377 
378 
379 void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
380 {
381  if( GetScreen() )
382  aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
383 }
384 
385 
386 void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
387 {
388  if( GetScreen() )
389  aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
390 }
391 
392 
393 void EDA_DRAW_FRAME::OnUpdateUnits( wxUpdateUIEvent& aEvent )
394 {
395  bool enable;
396 
397  enable = ( ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM) && (g_UserUnit == MILLIMETRES))
398  || ((aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH) && (g_UserUnit == INCHES)) );
399 
400  aEvent.Check( enable );
401  DisplayUnitsMsg();
402 }
403 
404 
405 void EDA_DRAW_FRAME::OnUpdateGrid( wxUpdateUIEvent& aEvent )
406 {
407  wxString tool_tip = IsGridVisible() ? _( "Hide grid" ) : _( "Show grid" );
408 
409  aEvent.Check( IsGridVisible() );
410  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID, tool_tip );
411 }
412 
413 
414 void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
415 {
416  aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
417 }
418 
419 
421 {
422 }
423 
424 
426 {
427 }
428 
429 
430 bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem )
431 {
432  return false;
433 }
434 
435 int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName )
436 {
437  int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
438 
439  if( IsGalCanvasActive() )
441 
442  return result;
443 }
444 
445 void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
446 {
447 }
448 
449 
450 void EDA_DRAW_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
451 {
452  wxMessageBox( wxT("EDA_DRAW_FRAME::PrintPage() error") );
453 }
454 
455 
456 void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
457 {
458  int* clientData;
459  int eventId = ID_POPUP_GRID_LEVEL_100;
460 
461  if( event.GetEventType() == wxEVT_CHOICE )
462  {
463  if( m_gridSelectBox == NULL ) // Should not happen
464  return;
465 
466  /*
467  * Don't use wxCommandEvent::GetClientData() here. It always
468  * returns NULL in GTK. This solution is not as elegant but
469  * it works.
470  */
471  int index = m_gridSelectBox->GetSelection();
472  wxASSERT( index != wxNOT_FOUND );
473  clientData = (int*) m_gridSelectBox->wxItemContainer::GetClientData( index );
474 
475  if( clientData != NULL )
476  eventId = *clientData;
477  }
478  else
479  {
480  eventId = event.GetId();
481  }
482 
483  int idx = eventId - ID_POPUP_GRID_LEVEL_1000;
484 
485  // Notify GAL
486  TOOL_MANAGER* mgr = GetToolManager();
487 
488  if( mgr && IsGalCanvasActive() )
489  {
490  mgr->RunAction( "common.Control.gridPreset", true, idx );
491  }
492  else
493  SetPresetGrid( idx );
494 
495  m_canvas->Refresh();
496 }
497 
498 
499 void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
500 {
501  if( m_zoomSelectBox == NULL )
502  return; // Should not happen!
503 
504  int id = m_zoomSelectBox->GetCurrentSelection();
505 
506  if( id < 0 || !( id < (int)m_zoomSelectBox->GetCount() ) )
507  return;
508 
509  if( id == 0 ) // Auto zoom (Fit in Page)
510  {
511  Zoom_Automatique( true );
512  }
513  else
514  {
515  id--;
516  double selectedZoom = GetScreen()->m_ZoomList[id];
517 
518  if( GetScreen()->GetZoom() == selectedZoom )
519  return;
520 
521  GetScreen()->SetZoom( selectedZoom );
523  }
524 
525  // Notify GAL
526  TOOL_MANAGER* mgr = GetToolManager();
527 
528  if( mgr && IsGalCanvasActive() )
529  {
530  mgr->RunAction( "common.Control.zoomPreset", true, id );
531  UpdateStatusBar();
532  }
533 }
534 
535 
537 {
538  return GetScreen()->GetZoom();
539 }
540 
541 
542 void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
543 {
544  event.Skip();
545 }
546 
547 
548 void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
549 {
550 }
551 
552 
553 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
554 {
555  SetStatusText( msg, 5 );
556 }
557 
558 
560 {
561  wxString msg;
562 
563  switch( g_UserUnit )
564  {
565  case INCHES:
566  msg = _( "Inches" );
567  break;
568 
569  case MILLIMETRES:
570  msg = _( "mm" );
571  break;
572 
573  default:
574  msg = _( "Units" );
575  break;
576  }
577 
578  SetStatusText( msg, 4 );
579 }
580 
581 
582 
583 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
584 {
585  m_FrameSize = GetClientSize( );
586 
587  SizeEv.Skip();
588 }
589 
590 
591 void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
592 {
593  // Keep default cursor in toolbars
594  SetCursor( wxNullCursor );
595 
596  // Change m_canvas cursor if requested.
597  if( m_canvas && aCursor >= 0 )
598  m_canvas->SetCurrentCursor( aCursor );
599 
600  // Change GAL canvas cursor if requested.
601  if( IsGalCanvasActive() && aCursor >= 0 )
602  GetGalCanvas()->SetCurrentCursor( aCursor );
603 
604  DisplayToolMsg( aToolMsg );
605 
606  if( aId < 0 )
607  return;
608 
609  wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
610  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
611 
612  m_toolId = aId;
613 }
614 
615 
617 {
618  // Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
619 
620  int defaultCursor = wxCURSOR_DEFAULT;
621 
622  // Change GAL canvas cursor if requested.
623  if( IsGalCanvasActive() )
624  defaultCursor = GetGalCanvas()->GetDefaultCursor();
625  else if( m_canvas )
626  defaultCursor = m_canvas->GetDefaultCursor();
627 
628  SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
629 }
630 
632 {
633  wxPoint pos = aPosition;
634 
635  if( m_currentScreen != NULL && m_snapToGrid )
636  pos = GetNearestGridPosition( aPosition );
637 
638  return pos;
639 }
640 
641 
643 {
644  BASE_SCREEN * screen = GetScreen();
645 
646  int new_grid_cmd = screen->GetGridCmdId();
647 
648  // if the grid id is the not the last, increment it
649  if( screen->GridExists( new_grid_cmd + 1 ) )
650  new_grid_cmd += 1;
651 
652  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
653 }
654 
655 
657 {
658  BASE_SCREEN * screen = GetScreen();
659 
660  int new_grid_cmd = screen->GetGridCmdId();
661 
662  // if the grid id is the not the first, increment it
663  if( screen->GridExists( new_grid_cmd - 1 ) )
664  new_grid_cmd -= 1;
665 
666  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
667 }
668 
669 
671 {
672  BASE_SCREEN * screen = GetScreen();
673 
674  if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
675  aIndex = screen->GetGrids()[0].m_CmdId;
676 
677  // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
678  // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
679  int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
680 
681  if( m_gridSelectBox )
682  {
683  if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
684  {
685  wxASSERT_MSG( false, "Invalid grid index" );
686  return;
687  }
688 
689  m_gridSelectBox->SetSelection( glistIdx );
690  }
691 
692  // Be sure m_LastGridSizeId is up to date.
693  m_LastGridSizeId = aIndex;
695 
696  // Put cursor on new grid
697  SetCrossHairPosition( RefPos( true ) );
698 }
699 
700 
702 {
703  return 0;
704 }
705 
706 
708 {
711 }
712 
713 
715 {
716 }
717 
718 
720 {
721  return false;
722 }
723 
724 
726 {
727  SetStatusText( GetZoomLevelIndicator(), 1 );
728 
729  // Absolute and relative cursor positions are handled by overloading this function and
730  // handling the internal to user units conversion at the appropriate level.
731 
732  // refresh units display
733  DisplayUnitsMsg();
734 }
735 
737 {
738  wxString Line;
739  double level = 0.0;
740 
741  if( IsGalCanvasActive() )
742  {
743  KIGFX::GAL* gal = m_galCanvas->GetGAL();
744  KIGFX::VIEW* view = m_galCanvas->GetView();
745  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
746  level = m_zoomLevelCoeff * zoomFactor * view->GetScale();
747  }
748  else if( BASE_SCREEN* screen = GetScreen() )
749  {
750  level = m_zoomLevelCoeff / (double) screen->GetZoom();
751  }
752 
753  // returns a human readable value which can be displayed as zoom
754  // level indicator in dialogs.
755  Line.Printf( wxT( "Z %.2f" ), level );
756 
757  return Line;
758 }
759 
760 
761 void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
762 {
764 
765  wxString baseCfgName = ConfigBaseName();
766 
767  bool btmp;
768  if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
769  SetGridVisibility( btmp );
770 
771  // Read grid color:
772  COLOR4D wtmp = COLOR4D::UNSPECIFIED;
773 
774  if( wtmp.SetFromWxString( aCfg->Read(
775  baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
776  SetGridColor( wtmp );
777 
778  aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
779 
780  // m_LastGridSizeId is an offset, expected to be >= 0
781  if( m_LastGridSizeId < 0 )
782  m_LastGridSizeId = 0;
783 
784  m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
785  long( DEFAULT_MAX_UNDO_ITEMS ) );
786 
787  aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
788 
789  m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
790 }
791 
792 
793 void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
794 {
796 
797  wxString baseCfgName = ConfigBaseName();
798 
799  aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
800  aCfg->Write( baseCfgName + GridColorEntryKeyword,
801  GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
802  aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
803  aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting );
804 
805  if( GetScreen() )
806  aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
807 
808  m_galDisplayOptions->WriteConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
809 }
810 
811 
812 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
813  const wxString& textLower,
814  COLOR4D color, int pad )
815 {
816  if( m_messagePanel == NULL )
817  return;
818 
819  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
820 }
821 
822 
824 {
825  if( m_messagePanel == NULL )
826  return;
827 
829 }
830 
831 
833 {
834  if( m_messagePanel == NULL )
835  return;
836 
837  ClearMsgPanel();
838 
839  for( unsigned i = 0; i < aList.size(); i++ )
840  m_messagePanel->AppendMessage( aList[i] );
841 }
842 
843 
845 {
846  wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
847 
848  MSG_PANEL_ITEMS items;
849  aItem->GetMsgPanelInfo( items );
850  SetMsgPanel( items );
851 }
852 
853 
855 {
856  EDA_ITEM* item = GetScreen()->GetCurItem();
857 
858  if( item )
859  SetMsgPanel( item );
860 }
861 
862 // FIXME: There needs to be a better way for child windows to load preferences.
863 // This function pushes four preferences from a parent window to a child window
864 // i.e. from eeschema to the schematic symbol editor
866 {
868  m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
869 }
870 
871 wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const
872 {
873  return ::CoordinateToString( aValue, aConvertToMils );
874 }
875 
876 wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) const
877 {
878  return ::LengthDoubleToString( aValue, aConvertToMils );
879 }
880 
881 
882 bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
883  int aExplicitCommand )
884 {
886 
887  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
888  return false;
889 
890  if( aExplicitCommand == 0 )
891  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
892  else
893  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
894 
895  if( block->GetCommand() == 0 )
896  return false;
897 
898  switch( block->GetCommand() )
899  {
900  case BLOCK_IDLE:
901  break;
902 
903  case BLOCK_MOVE: // Move
904  case BLOCK_DRAG: // Drag (block defined)
905  case BLOCK_DRAG_ITEM: // Drag from a drag item command
906  case BLOCK_DUPLICATE: // Duplicate
907  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
908  case BLOCK_DELETE: // Delete
909  case BLOCK_COPY: // Copy
910  case BLOCK_ROTATE: // Rotate 90 deg
911  case BLOCK_FLIP: // Flip
912  case BLOCK_ZOOM: // Window Zoom
913  case BLOCK_MIRROR_X:
914  case BLOCK_MIRROR_Y: // mirror
915  case BLOCK_PRESELECT_MOVE: // Move with preselection list
916  block->InitData( m_canvas, aPosition );
917  break;
918 
919  case BLOCK_PASTE:
920  block->InitData( m_canvas, aPosition );
921  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
923 
924  if( block->GetCount() == 0 ) // No data to paste
925  {
926  DisplayError( this, wxT( "No block to paste" ), 20 );
929  block->SetState( STATE_NO_BLOCK );
930  block->SetMessageBlock( this );
931  return true;
932  }
933 
934  if( !m_canvas->IsMouseCaptured() )
935  {
936  block->ClearItemsList();
937  DisplayError( this,
938  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
939  block->SetState( STATE_NO_BLOCK );
940  block->SetMessageBlock( this );
941  return true;
942  }
943 
944  block->SetState( STATE_BLOCK_MOVE );
945  m_canvas->CallMouseCapture( aDC, aPosition, false );
946  break;
947 
948  default:
949  {
950  wxString msg;
951  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
952  block->GetCommand();
953  DisplayError( this, msg );
954  }
955  break;
956  }
957 
958  block->SetMessageBlock( this );
959  return true;
960 }
961 
962 
963 // I am not seeing a problem with this size yet:
964 static const double MAX_AXIS = INT_MAX - 100;
965 
966 #define VIRT_MIN (-MAX_AXIS/2.0)
967 #define VIRT_MAX (MAX_AXIS/2.0)
968 
969 
970 void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
971 {
972  BASE_SCREEN* screen = GetScreen();
973 
974  if( !screen || !m_canvas )
975  return;
976 
977  double scale = screen->GetScalingFactor();
978 
979  wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
980  aCenterPositionIU.x, aCenterPositionIU.y, scale );
981 
982  // Calculate the portion of the drawing that can be displayed in the
983  // client area at the current zoom level.
984 
985  // visible viewport in device units ~ pixels
986  wxSize clientSizeDU = m_canvas->GetClientSize();
987 
988  // Size of the client window in IU
989  DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
990 
991  // Full drawing or "page" rectangle in internal units
992  DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
993 
994  // Account for scrollbars
995  wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
996  wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
997  wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
998 
999  // The upper left corner of the client rectangle in internal units.
1000  double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
1001  double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
1002 
1003  // If drawn around the center, adjust the client rectangle accordingly.
1004  if( screen->m_Center )
1005  {
1006  // half page offset.
1007  xIU += pageRectIU.GetWidth() / 2.0;
1008  yIU += pageRectIU.GetHeight() / 2.0;
1009  }
1010 
1011  DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
1012  wxPoint centerPositionIU;
1013 
1014  // put "int" limits on the clientRect
1015  if( clientRectIU.GetLeft() < VIRT_MIN )
1016  clientRectIU.MoveLeftTo( VIRT_MIN );
1017  if( clientRectIU.GetTop() < VIRT_MIN )
1018  clientRectIU.MoveTopTo( VIRT_MIN );
1019  if( clientRectIU.GetRight() > VIRT_MAX )
1020  clientRectIU.MoveRightTo( VIRT_MAX );
1021  if( clientRectIU.GetBottom() > VIRT_MAX )
1022  clientRectIU.MoveBottomTo( VIRT_MAX );
1023 
1024  centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
1025  centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
1026 
1027  if( screen->m_Center )
1028  {
1029  centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
1030  centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
1031  }
1032 
1033  DSIZE virtualSizeIU;
1034 
1035  if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
1036  {
1037  virtualSizeIU.x = pageRectIU.GetSize().x;
1038  }
1039  else
1040  {
1041  double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
1042  double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
1043 
1044  if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
1045  {
1046  if( pageCenterX > clientCenterX )
1047  virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
1048  else if( pageCenterX < clientCenterX )
1049  virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
1050  else
1051  virtualSizeIU.x = clientRectIU.GetWidth();
1052  }
1053  else
1054  {
1055  if( pageCenterX > clientCenterX )
1056  virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
1057  else if( pageCenterX < clientCenterX )
1058  virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
1059  else
1060  virtualSizeIU.x = pageRectIU.GetWidth();
1061  }
1062  }
1063 
1064  if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
1065  {
1066  virtualSizeIU.y = pageRectIU.GetSize().y;
1067  }
1068  else
1069  {
1070  double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
1071  double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
1072 
1073  if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
1074  {
1075  if( pageCenterY > clientCenterY )
1076  virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
1077  else if( pageCenterY < clientCenterY )
1078  virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
1079  else
1080  virtualSizeIU.y = clientRectIU.GetHeight();
1081  }
1082  else
1083  {
1084  if( pageCenterY > clientCenterY )
1085  virtualSizeIU.y = pageRectIU.GetHeight() +
1086  ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
1087  else if( pageCenterY < clientCenterY )
1088  virtualSizeIU.y = pageRectIU.GetHeight() +
1089  ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
1090  else
1091  virtualSizeIU.y = pageRectIU.GetHeight();
1092  }
1093  }
1094 
1095  // put "int" limits on the virtualSizeIU
1096  virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
1097  virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
1098 
1099  if( screen->m_Center )
1100  {
1101  screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
1102  screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
1103  }
1104  else
1105  {
1106  screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
1107  screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
1108  }
1109 
1110  /* Always set scrollbar pixels per unit to 1 unless you want the zoom
1111  * around cursor to jump around. This reported problem occurs when the
1112  * zoom point is not on a pixel per unit increment. If you set the
1113  * pixels per unit to 10, you have potential for the zoom point to
1114  * jump around +/-5 pixels from the nearest grid point.
1115  */
1116  screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
1117 
1118  // Number of scroll bar units for the given zoom level in device units.
1119  double unitsX = virtualSizeIU.x * scale;
1120  double unitsY = virtualSizeIU.y * scale;
1121 
1122  // Store the requested center position for later use
1123  SetScrollCenterPosition( aCenterPositionIU );
1124 
1125  // Calculate the scroll bar position in internal units to place the
1126  // center position at the center of client rectangle.
1127  double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
1128  double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
1129 
1130  // Convert scroll bar position to device units.
1131  posX = KiROUND( posX * scale );
1132  posY = KiROUND( posY * scale );
1133 
1134  if( posX < 0 )
1135  {
1136  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1137  posX = 0;
1138  }
1139 
1140  if( posX > unitsX )
1141  {
1142  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1143  posX = unitsX;
1144  }
1145 
1146  if( posY < 0 )
1147  {
1148  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1149  posY = 0;
1150  }
1151 
1152  if( posY > unitsY )
1153  {
1154  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1155  posY = unitsY;
1156  }
1157 
1158  screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
1159  screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
1160 
1161  wxLogTrace( traceScrollSettings,
1162  wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
1163  virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
1164  screen->m_DrawOrg.x, screen->m_DrawOrg.y,
1166  screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
1167  screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
1168 
1169  bool noRefresh = true;
1170 
1171  m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
1172  screen->m_ScrollPixelsPerUnitY,
1173  screen->m_ScrollbarNumber.x,
1174  screen->m_ScrollbarNumber.y,
1175  screen->m_ScrollbarPos.x,
1176  screen->m_ScrollbarPos.y, noRefresh );
1177 }
1178 
1179 
1180 void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
1181 {
1182  KIGFX::VIEW* view = GetGalCanvas()->GetView();
1183  KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
1184 
1185  // Display the same view after canvas switching
1186  if( aEnable )
1187  {
1188  // Switch to GAL renderer from legacy
1189  if( !m_galCanvasActive )
1190  {
1191  // Set up viewport
1192  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1193  double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
1194  view->SetScale( zoom );
1196  }
1197 
1198  // Set up grid settings
1199  gal->SetGridVisibility( IsGridVisible() );
1200  gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
1201  gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
1202 
1203  // Transfer EDA_DRAW_PANEL settings
1207  }
1208  else if( m_galCanvasActive )
1209  {
1210  // Switch to legacy renderer from GAL
1211  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1212  // TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
1213  m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
1214  VECTOR2D center = view->GetCenter();
1215  AdjustScrollBars( wxPoint( center.x, center.y ) );
1216  }
1217 
1218  m_canvas->SetEvtHandlerEnabled( !aEnable );
1219  GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
1220 
1221  // Switch panes
1222  m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
1223  m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
1224  m_auimgr.Update();
1225 
1226  // Reset current tool on switch();
1228 
1229  m_galCanvasActive = aEnable;
1230 }
1231 
1232 
1234 {
1235  auto galCanvas = GetGalCanvas();
1236  wxCHECK( galCanvas, false );
1237  bool use_gal = galCanvas->SwitchBackend( aCanvasType );
1238  use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1239  UseGalCanvas( use_gal );
1240  m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1241  m_canvasTypeDirty = true;
1242 
1243  return use_gal;
1244 }
1245 
1246 
1248 {
1250  wxConfigBase* cfg = Kiface().KifaceSettings();
1251 
1252  if( cfg )
1253  canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE) cfg->ReadLong( CANVAS_TYPE_KEY,
1255 
1256  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1257  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1258  {
1259  assert( false );
1260  canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1261  }
1262 
1263  return canvasType;
1264 }
1265 
1266 
1268 {
1269  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1270  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1271  {
1272  assert( false );
1273  return false;
1274  }
1275 
1276  wxConfigBase* cfg = Kiface().KifaceSettings();
1277 
1278  if( cfg )
1279  return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
1280 
1281  return false;
1282 }
1283 
1284 //-----< BASE_SCREEN API moved here >--------------------------------------------
1285 
1287 {
1288  // subject to change, borrow from old BASE_SCREEN for now.
1289  if( IsGalCanvasActive() )
1290  {
1292 
1293  return wxPoint( cursor.x, cursor.y );
1294  }
1295  else
1296  {
1297  BASE_SCREEN* screen = GetScreen(); // virtual call
1298  return screen->getCrossHairPosition( aInvertY );
1299  }
1300 }
1301 
1302 
1303 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1304 {
1305  BASE_SCREEN* screen = GetScreen(); // virtual call
1306  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1307 }
1308 
1309 
1310 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1311 {
1312  BASE_SCREEN* screen = GetScreen(); // virtual call
1313  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1314 }
1315 
1316 
1317 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
1318 {
1319  BASE_SCREEN* screen = GetScreen(); // virtual call
1320  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1321 }
1322 
1323 
1325 {
1326  BASE_SCREEN* screen = GetScreen(); // virtual call
1327  return screen->getCrossHairScreenPosition();
1328 }
1329 
1330 
1332 {
1333  BASE_SCREEN* screen = GetScreen(); // virtual call
1334  screen->setMousePosition( aPosition );
1335 }
1336 
1337 
1338 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1339 {
1340  BASE_SCREEN* screen = GetScreen(); // virtual call
1341  return screen->refPos( useMouse );
1342 }
1343 
1344 
1346 {
1347  BASE_SCREEN* screen = GetScreen(); // virtual call
1348  return screen->getScrollCenterPosition();
1349 }
1350 
1351 
1353 {
1354  BASE_SCREEN* screen = GetScreen(); // virtual call
1355  screen->setScrollCenterPosition( aPoint );
1356 }
1357 
1358 //-----</BASE_SCREEN API moved here >--------------------------------------------
1359 
1361  const wxPoint &aEvtPos,
1362  wxDC* aDC )
1363 {
1364  wxPoint newpos = GetCrossHairPosition();
1365 
1366  // Redraw the crosshair if it moved
1367  if( aOldPos != newpos )
1368  {
1369  SetCrossHairPosition( aOldPos, false );
1370  m_canvas->CrossHairOff( aDC );
1371  SetCrossHairPosition( newpos, false );
1372  m_canvas->CrossHairOn( aDC );
1373 
1374  if( m_canvas->IsMouseCaptured() )
1375  {
1376 #ifdef USE_WX_OVERLAY
1377  wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
1378  oDC.Clear();
1379  m_canvas->CallMouseCapture( aDC, aEvtPos, false );
1380 #else
1381  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1382 #endif
1383  }
1384 #ifdef USE_WX_OVERLAY
1385  else
1386  {
1387  m_overlay.Reset();
1388  }
1389 #endif
1390  }
1391 }
1392 
1394  bool aSnapToGrid )
1395 {
1396  bool key_handled = false;
1397 
1398  // If requested snap the current position to the grid
1399  if( aSnapToGrid )
1400  *aPos = GetNearestGridPosition( *aPos );
1401 
1402  switch( aHotKey )
1403  {
1404  // All these keys have almost the same treatment
1405  case GR_KB_CTRL | WXK_NUMPAD8:
1406  case GR_KB_CTRL | WXK_UP:
1407  case GR_KB_CTRL | WXK_NUMPAD2:
1408  case GR_KB_CTRL | WXK_DOWN:
1409  case GR_KB_CTRL | WXK_NUMPAD4:
1410  case GR_KB_CTRL | WXK_LEFT:
1411  case GR_KB_CTRL | WXK_NUMPAD6:
1412  case GR_KB_CTRL | WXK_RIGHT:
1413  case WXK_NUMPAD8:
1414  case WXK_UP:
1415  case WXK_NUMPAD2:
1416  case WXK_DOWN:
1417  case WXK_NUMPAD4:
1418  case WXK_LEFT:
1419  case WXK_NUMPAD6:
1420  case WXK_RIGHT:
1421  key_handled = true;
1422  {
1423  /* Here's a tricky part: when doing cursor key movement, the
1424  * 'previous' point should be taken from memory, *not* from the
1425  * freshly computed position in the event. Otherwise you can't do
1426  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1427  * the automatic motion event generated by cursor warping */
1428  wxRealPoint gridSize = GetScreen()->GetGridSize();
1429  *aPos = GetCrossHairPosition();
1430 
1431  // Bonus: ^key moves faster (x10)
1432  switch( aHotKey )
1433  {
1434  case GR_KB_CTRL|WXK_NUMPAD8:
1435  case GR_KB_CTRL|WXK_UP:
1436  aPos->y -= KiROUND( 10 * gridSize.y );
1437  break;
1438 
1439  case GR_KB_CTRL|WXK_NUMPAD2:
1440  case GR_KB_CTRL|WXK_DOWN:
1441  aPos->y += KiROUND( 10 * gridSize.y );
1442  break;
1443 
1444  case GR_KB_CTRL|WXK_NUMPAD4:
1445  case GR_KB_CTRL|WXK_LEFT:
1446  aPos->x -= KiROUND( 10 * gridSize.x );
1447  break;
1448 
1449  case GR_KB_CTRL|WXK_NUMPAD6:
1450  case GR_KB_CTRL|WXK_RIGHT:
1451  aPos->x += KiROUND( 10 * gridSize.x );
1452  break;
1453 
1454  case WXK_NUMPAD8:
1455  case WXK_UP:
1456  aPos->y -= KiROUND( gridSize.y );
1457  break;
1458 
1459  case WXK_NUMPAD2:
1460  case WXK_DOWN:
1461  aPos->y += KiROUND( gridSize.y );
1462  break;
1463 
1464  case WXK_NUMPAD4:
1465  case WXK_LEFT:
1466  aPos->x -= KiROUND( gridSize.x );
1467  break;
1468 
1469  case WXK_NUMPAD6:
1470  case WXK_RIGHT:
1471  aPos->x += KiROUND( gridSize.x );
1472  break;
1473 
1474  default: /* Can't happen since we entered the statement */
1475  break;
1476  }
1477 
1478  m_canvas->MoveCursor( *aPos );
1480  }
1481  break;
1482 
1483  default:
1484  break;
1485  }
1486 
1487  return key_handled;
1488 }
1489 
1490 
1492 {
1493  const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
1494 
1495  if( !screen )
1496  return false;
1497 
1498  return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
1499  || ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
1500 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:100
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:425
#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:282
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:266
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:351
std::unique_ptr< KIGFX::GAL_DISPLAY_OPTIONS > m_galDisplayOptions
Definition: draw_frame.h:72
void AdjustScrollBars(const wxPoint &aCenterPosition)
Definition: draw_frame.cpp:970
void OnToggleCrossHairStyle(wxCommandEvent &aEvent)
Definition: draw_frame.cpp:366
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
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:67
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.
Definition: base_screen.h:192
#define VIRT_MAX
max X or Y coordinate in virtual space
Definition: draw_frame.cpp:967
int m_ScrollPixelsPerUnitY
Pixels per scroll unit in the vertical direction.
Definition: base_screen.h:190
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:916
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:736
void setScrollCenterPosition(const wxPoint &aPoint)
Definition: base_screen.h:174
EDA_ITEM * GetCurItem() const
Definition: base_screen.h:233
virtual void HandleBlockPlace(wxDC *DC)
Function HandleBlockPlace( ) Called after HandleBlockEnd, when a block command needs to be executed a...
Definition: draw_frame.cpp:714
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:338
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:631
virtual int BlockCommand(EDA_KEY aKey)
Function BlockCommand Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the...
Definition: draw_frame.cpp:701
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:101
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:685
double GetWorldScale() const
Get the world scale.
#define DEFAULT_MAX_UNDO_ITEMS
Definition: draw_frame.h:47
int GetGridCmdId() const
Return the command ID of the currently selected grid.
Definition: base_screen.h:403
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:157
#define VIRT_MIN
min X or Y coordinate in virtual space
Definition: draw_frame.cpp:966
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
void 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:542
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
int color
Definition: DXF_plotter.cpp:62
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:430
std::vector< wxSocketBase * > m_sockets
interprocess communication
Definition: draw_frame.h:77
virtual void EnableMousewheelPan(bool aEnable)
Function EnableMousewheelPan() Enables or disables mousewheel panning.
wxString ConfigBaseName()
Function ConfigBaseName.
coord_type GetRight() const
Definition: box2.h:187
const GRIDS & GetGrids() const
Function GetGrids().
Definition: base_screen.h:472
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:254
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:445
wxAuiManager m_auimgr
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:291
void SkipNextLeftButtonReleaseEvent()
function SkipNextLeftButtonReleaseEvent after calling this function, if the left mouse button is down...
Definition: draw_frame.cpp:300
virtual void SetGridColor(COLOR4D aColor)
Function SetGridColor() , virtual.
Definition: draw_frame.h:526
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:366
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:656
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:55
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:865
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:124
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:79
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:793
virtual void InitBlockPasteInfos()
Definition: draw_frame.cpp:707
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...
Definition: base_screen.h:168
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:498
EDA_DRAW_FRAME::OnSelectGrid ID_TB_OPTIONS_SELECT_UNIT_INCH
Definition: draw_frame.cpp:123
bool m_canvasTypeDirty
Flag indicating that drawing canvas type needs to be saved to config.
Definition: draw_frame.h:154
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:94
void DisplayUnitsMsg()
Function DisplayUnitsMsg displays current unit pane on the status bar.
Definition: draw_frame.cpp:559
void OnUpdateUndo(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:379
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)
EVT_TOOL(ID_MODVIEW_SELECT_LIB, FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary) EVT_TOOL(ID_MODVIEW_SELECT_PART
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:882
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:102
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.
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
Definition: draw_frame.h:131
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:361
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:138
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:587
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:386
BASE_SCREEN * m_currentScreen
current used SCREEN
Definition: draw_frame.h:64
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:450
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...
Definition: base_screen.h:107
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
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:832
void EraseMsgBox()
Definition: draw_frame.cpp:275
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:876
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 &#39;dirty&#39; flag.
Definition: view.h:577
bool m_Center
Center on screen.
Definition: base_screen.h:202
bool IsMouseCaptured() const
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:141
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
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:127
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
double GetZoom()
Function GetZoom.
Definition: draw_frame.cpp:536
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:288
static const wxString ShowGridEntryKeyword(wxT("ShowGrid"))
Nonzero to show grid (suffix)
int m_ScrollPixelsPerUnitX
Pixels per scroll unit in the horizontal direction.
Definition: base_screen.h:189
virtual void ReCreateAuxiliaryToolbar()
Definition: draw_frame.cpp:420
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
wxAuiToolBarItem * GetToolbarTool(int aToolId)
Checks all the toolbars and returns a reference to the given tool id or nullptr if not found...
Definition: draw_frame.cpp:330
void OnUpdateUnits(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:393
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
wxLogTrace helper definitions.
void setMousePosition(const wxPoint &aPosition)
Definition: base_screen.h:156
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:887
virtual void OnSize(wxSizeEvent &event)
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...
Definition: draw_frame.cpp:583
void OnToggleGridState(wxCommandEvent &aEvent)
Definition: draw_frame.cpp:306
virtual bool SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
const wxPoint & getScrollCenterPosition() const
Definition: base_screen.h:173
virtual void EnableAutoPan(bool aEnabled)
Function EnableAutoPan Turns on/off auto panning (user setting to disable it entirely).
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:670
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:94
void EraseMsgBox()
Definition: msgpanel.cpp:215
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:591
void SetCurrentCursor(int aCursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
ID_POPUP_GRID_USER
Definition: draw_frame.cpp:110
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:83
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:517
void SetMouseCaptureCallback(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback)
void CrossHairOff(wxDC *DC)
Definition: draw_panel.cpp:265
virtual void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
Definition: base_struct.h:288
void SetGridSize(const VECTOR2D &aGridSize)
Set the grid size.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:135
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: solve.cpp:178
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:761
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.
Definition: base_screen.h:196
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:642
EDA_DRAW_PANEL_GAL * m_galCanvas
GAL display options - this is the frame&#39;s interface to setting GAL display options.
Definition: draw_frame.h:69
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:719
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
wxSocketServer * m_socketServer
Definition: draw_frame.h:76
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:616
coord_type GetHeight() const
Definition: box2.h:186
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:98
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:812
void OnUpdateCrossHairStyle(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:414
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:902
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:272
static const double MAX_AXIS
Definition: draw_frame.cpp:964
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:91
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:553
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:456
void OnUpdateGrid(wxUpdateUIEvent &aEvent)
Definition: draw_frame.cpp:405
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...
size_t i
Definition: json11.cpp:597
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:410
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:183
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
The common library.
double GetZoomFactor() const
Get the zoom factor.
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_HIGH_CONTRAST_MODE
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:435
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:895
virtual void SetGridVisibility(bool aVisible)
Function SetGridVisibility() , virtual It may be overloaded by derived classes.
Definition: draw_frame.h:508
static const wxChar CANVAS_TYPE_KEY[]
Key in KifaceSettings to store the canvas type.
Definition: draw_frame.h:204
static const wxString GridColorEntryKeyword(wxT("GridColor"))
Grid color ID (suffix)
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:245
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:351
virtual void unitsChangeRefresh()
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: draw_frame.cpp:268
Class VIEW.
Definition: view.h:58
bool GetToolToggled(int aToolId)
Checks all the toolbars and returns true if the given tool id is toggled.
Definition: draw_frame.cpp:319
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:871
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
BASE_SCREEN class implementation.
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:102
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
Definition: draw_frame.cpp:548
#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:676
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:725
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:185
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:282
bool m_movingCursorWithKeyboard
One-shot to avoid a recursive mouse event during hotkey movement.
Definition: draw_frame.h:151
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:823
void UpdateHotKeys()
>
long m_firstRunDialogSetting
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:121
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:499
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
bool m_snapToGrid
Indicates if cursor should be snapped to grid.
Definition: draw_frame.h:66
bool LockFile(const wxString &aFileName)
Function LockFile marks a schematic file as being in use.
Definition: draw_frame.cpp:260
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:854
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.