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  double selectedZoom = GetScreen()->m_ZoomList[id-1];
516 
517  if( GetScreen()->GetZoom() == selectedZoom )
518  return;
519 
520  GetScreen()->SetZoom( selectedZoom );
522  }
523 
524  // Notify GAL
525  TOOL_MANAGER* mgr = GetToolManager();
526 
527  if( mgr && IsGalCanvasActive() )
528  {
529  mgr->RunAction( "common.Control.zoomPreset", true, id );
530  UpdateStatusBar();
531  }
532 }
533 
534 
536 {
537  return GetScreen()->GetZoom();
538 }
539 
540 
541 void EDA_DRAW_FRAME::OnMouseEvent( wxMouseEvent& event )
542 {
543  event.Skip();
544 }
545 
546 
547 void EDA_DRAW_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
548 {
549 }
550 
551 
552 void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
553 {
554  SetStatusText( msg, 5 );
555 }
556 
557 
559 {
560  wxString msg;
561 
562  switch( g_UserUnit )
563  {
564  case INCHES:
565  msg = _( "Inches" );
566  break;
567 
568  case MILLIMETRES:
569  msg = _( "mm" );
570  break;
571 
572  default:
573  msg = _( "Units" );
574  break;
575  }
576 
577  SetStatusText( msg, 4 );
578 }
579 
580 
581 
582 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
583 {
584  m_FrameSize = GetClientSize( );
585 
586  SizeEv.Skip();
587 }
588 
589 
590 void EDA_DRAW_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
591 {
592  // Keep default cursor in toolbars
593  SetCursor( wxNullCursor );
594 
595  // Change m_canvas cursor if requested.
596  if( m_canvas && aCursor >= 0 )
597  m_canvas->SetCurrentCursor( aCursor );
598 
599  // Change GAL canvas cursor if requested.
600  if( IsGalCanvasActive() && aCursor >= 0 )
601  GetGalCanvas()->SetCurrentCursor( aCursor );
602 
603  DisplayToolMsg( aToolMsg );
604 
605  if( aId < 0 )
606  return;
607 
608  wxCHECK2_MSG( aId >= ID_NO_TOOL_SELECTED, aId = ID_NO_TOOL_SELECTED,
609  wxString::Format( wxT( "Current tool ID cannot be set to %d." ), aId ) );
610 
611  m_toolId = aId;
612 }
613 
614 
616 {
617  // Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
618 
619  int defaultCursor = wxCURSOR_DEFAULT;
620 
621  // Change GAL canvas cursor if requested.
622  if( IsGalCanvasActive() )
623  defaultCursor = GetGalCanvas()->GetDefaultCursor();
624  else if( m_canvas )
625  defaultCursor = m_canvas->GetDefaultCursor();
626 
627  SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
628 }
629 
631 {
632  wxPoint pos = aPosition;
633 
634  if( m_currentScreen != NULL && m_snapToGrid )
635  pos = GetNearestGridPosition( aPosition );
636 
637  return pos;
638 }
639 
640 
642 {
643  BASE_SCREEN * screen = GetScreen();
644 
645  int new_grid_cmd = screen->GetGridCmdId();
646 
647  // if the grid id is the not the last, increment it
648  if( screen->GridExists( new_grid_cmd + 1 ) )
649  new_grid_cmd += 1;
650 
651  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
652 }
653 
654 
656 {
657  BASE_SCREEN * screen = GetScreen();
658 
659  int new_grid_cmd = screen->GetGridCmdId();
660 
661  // if the grid id is the not the first, increment it
662  if( screen->GridExists( new_grid_cmd - 1 ) )
663  new_grid_cmd -= 1;
664 
665  SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
666 }
667 
668 
670 {
671  BASE_SCREEN * screen = GetScreen();
672 
673  if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
674  aIndex = screen->GetGrids()[0].m_CmdId;
675 
676  // aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
677  // we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
678  int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
679 
680  if( m_gridSelectBox )
681  {
682  if( glistIdx < 0 || glistIdx >= (int) m_gridSelectBox->GetCount() )
683  {
684  wxASSERT_MSG( false, "Invalid grid index" );
685  return;
686  }
687 
688  m_gridSelectBox->SetSelection( glistIdx );
689  }
690 
691  // Be sure m_LastGridSizeId is up to date.
692  m_LastGridSizeId = aIndex;
694 
695  // Put cursor on new grid
696  SetCrossHairPosition( RefPos( true ) );
697 }
698 
699 
701 {
702  return 0;
703 }
704 
705 
707 {
710 }
711 
712 
714 {
715 }
716 
717 
719 {
720  return false;
721 }
722 
723 
725 {
726  SetStatusText( GetZoomLevelIndicator(), 1 );
727 
728  // Absolute and relative cursor positions are handled by overloading this function and
729  // handling the internal to user units conversion at the appropriate level.
730 
731  // refresh units display
732  DisplayUnitsMsg();
733 }
734 
736 {
737  wxString Line;
738  double level = 0.0;
739 
740  if( IsGalCanvasActive() )
741  {
742  KIGFX::GAL* gal = m_galCanvas->GetGAL();
743  KIGFX::VIEW* view = m_galCanvas->GetView();
744  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
745  level = m_zoomLevelCoeff * zoomFactor * view->GetScale();
746  }
747  else if( BASE_SCREEN* screen = GetScreen() )
748  {
749  level = m_zoomLevelCoeff / (double) screen->GetZoom();
750  }
751 
752  // returns a human readable value which can be displayed as zoom
753  // level indicator in dialogs.
754  Line.Printf( wxT( "Z %.2f" ), level );
755 
756  return Line;
757 }
758 
759 
760 void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
761 {
763 
764  wxString baseCfgName = ConfigBaseName();
765 
766  bool btmp;
767  if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )
768  SetGridVisibility( btmp );
769 
770  // Read grid color:
771  COLOR4D wtmp = COLOR4D::UNSPECIFIED;
772 
773  if( wtmp.SetFromWxString( aCfg->Read(
774  baseCfgName + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
775  SetGridColor( wtmp );
776 
777  aCfg->Read( baseCfgName + LastGridSizeIdKeyword, &m_LastGridSizeId, 0L );
778 
779  // m_LastGridSizeId is an offset, expected to be >= 0
780  if( m_LastGridSizeId < 0 )
781  m_LastGridSizeId = 0;
782 
783  m_UndoRedoCountMax = aCfg->Read( baseCfgName + MaxUndoItemsEntry,
784  long( DEFAULT_MAX_UNDO_ITEMS ) );
785 
786  aCfg->Read( baseCfgName + FirstRunShownKeyword, &m_firstRunDialogSetting, 0L );
787 
788  m_galDisplayOptions->ReadConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
789 }
790 
791 
792 void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
793 {
795 
796  wxString baseCfgName = ConfigBaseName();
797 
798  aCfg->Write( baseCfgName + ShowGridEntryKeyword, IsGridVisible() );
799  aCfg->Write( baseCfgName + GridColorEntryKeyword,
800  GetGridColor().ToColour().GetAsString( wxC2S_CSS_SYNTAX ) );
801  aCfg->Write( baseCfgName + LastGridSizeIdKeyword, ( long ) m_LastGridSizeId );
802  aCfg->Write( baseCfgName + FirstRunShownKeyword, m_firstRunDialogSetting );
803 
804  if( GetScreen() )
805  aCfg->Write( baseCfgName + MaxUndoItemsEntry, long( GetScreen()->GetMaxUndoItems() ) );
806 
807  m_galDisplayOptions->WriteConfig( aCfg, baseCfgName + GalDisplayOptionsKeyword );
808 }
809 
810 
811 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
812  const wxString& textLower,
813  COLOR4D color, int pad )
814 {
815  if( m_messagePanel == NULL )
816  return;
817 
818  m_messagePanel->AppendMessage( textUpper, textLower, color, pad );
819 }
820 
821 
823 {
824  if( m_messagePanel == NULL )
825  return;
826 
828 }
829 
830 
832 {
833  if( m_messagePanel == NULL )
834  return;
835 
836  ClearMsgPanel();
837 
838  for( unsigned i = 0; i < aList.size(); i++ )
839  m_messagePanel->AppendMessage( aList[i] );
840 }
841 
842 
844 {
845  wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) );
846 
847  MSG_PANEL_ITEMS items;
848  aItem->GetMsgPanelInfo( items );
849  SetMsgPanel( items );
850 }
851 
852 
854 {
855  EDA_ITEM* item = GetScreen()->GetCurItem();
856 
857  if( item )
858  SetMsgPanel( item );
859 }
860 
861 // FIXME: There needs to be a better way for child windows to load preferences.
862 // This function pushes four preferences from a parent window to a child window
863 // i.e. from eeschema to the schematic symbol editor
865 {
867  m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
868 }
869 
870 wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) const
871 {
872  return ::CoordinateToString( aValue, aConvertToMils );
873 }
874 
875 wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils ) const
876 {
877  return ::LengthDoubleToString( aValue, aConvertToMils );
878 }
879 
880 
881 bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
882  int aExplicitCommand )
883 {
885 
886  if( ( block->GetCommand() != BLOCK_IDLE ) || ( block->GetState() != STATE_NO_BLOCK ) )
887  return false;
888 
889  if( aExplicitCommand == 0 )
890  block->SetCommand( (BLOCK_COMMAND_T) BlockCommand( aKey ) );
891  else
892  block->SetCommand( (BLOCK_COMMAND_T) aExplicitCommand );
893 
894  if( block->GetCommand() == 0 )
895  return false;
896 
897  switch( block->GetCommand() )
898  {
899  case BLOCK_IDLE:
900  break;
901 
902  case BLOCK_MOVE: // Move
903  case BLOCK_DRAG: // Drag (block defined)
904  case BLOCK_DRAG_ITEM: // Drag from a drag item command
905  case BLOCK_DUPLICATE: // Duplicate
906  case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
907  case BLOCK_DELETE: // Delete
908  case BLOCK_COPY: // Copy
909  case BLOCK_ROTATE: // Rotate 90 deg
910  case BLOCK_FLIP: // Flip
911  case BLOCK_ZOOM: // Window Zoom
912  case BLOCK_MIRROR_X:
913  case BLOCK_MIRROR_Y: // mirror
914  case BLOCK_PRESELECT_MOVE: // Move with preselection list
915  block->InitData( m_canvas, aPosition );
916  break;
917 
918  case BLOCK_PASTE:
919  block->InitData( m_canvas, aPosition );
920  block->SetLastCursorPosition( wxPoint( 0, 0 ) );
922 
923  if( block->GetCount() == 0 ) // No data to paste
924  {
925  DisplayError( this, wxT( "No block to paste" ), 20 );
928  block->SetState( STATE_NO_BLOCK );
929  block->SetMessageBlock( this );
930  return true;
931  }
932 
933  if( !m_canvas->IsMouseCaptured() )
934  {
935  block->ClearItemsList();
936  DisplayError( this,
937  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
938  block->SetState( STATE_NO_BLOCK );
939  block->SetMessageBlock( this );
940  return true;
941  }
942 
943  block->SetState( STATE_BLOCK_MOVE );
944  m_canvas->CallMouseCapture( aDC, aPosition, false );
945  break;
946 
947  default:
948  {
949  wxString msg;
950  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
951  block->GetCommand();
952  DisplayError( this, msg );
953  }
954  break;
955  }
956 
957  block->SetMessageBlock( this );
958  return true;
959 }
960 
961 
962 // I am not seeing a problem with this size yet:
963 static const double MAX_AXIS = INT_MAX - 100;
964 
965 #define VIRT_MIN (-MAX_AXIS/2.0)
966 #define VIRT_MAX (MAX_AXIS/2.0)
967 
968 
969 void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
970 {
971  BASE_SCREEN* screen = GetScreen();
972 
973  if( !screen || !m_canvas )
974  return;
975 
976  double scale = screen->GetScalingFactor();
977 
978  wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
979  aCenterPositionIU.x, aCenterPositionIU.y, scale );
980 
981  // Calculate the portion of the drawing that can be displayed in the
982  // client area at the current zoom level.
983 
984  // visible viewport in device units ~ pixels
985  wxSize clientSizeDU = m_canvas->GetClientSize();
986 
987  // Size of the client window in IU
988  DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
989 
990  // Full drawing or "page" rectangle in internal units
991  DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
992 
993  // Remark: if something is modified here, perhaps EDA_DRAW_FRAME::RedrawScreen2()
994  // will need changes accordint to the way the center is computed
995  // Account for scrollbars
996  wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
997  wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
998  wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
999 
1000  // The upper left corner of the client rectangle in internal units.
1001  double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
1002  double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
1003 
1004  // If drawn around the center, adjust the client rectangle accordingly.
1005  if( screen->m_Center )
1006  {
1007  // half page offset.
1008  xIU += pageRectIU.GetWidth() / 2.0;
1009  yIU += pageRectIU.GetHeight() / 2.0;
1010  }
1011 
1012  DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
1013  wxPoint centerPositionIU;
1014 
1015  // put "int" limits on the clientRect
1016  if( clientRectIU.GetLeft() < VIRT_MIN )
1017  clientRectIU.MoveLeftTo( VIRT_MIN );
1018  if( clientRectIU.GetTop() < VIRT_MIN )
1019  clientRectIU.MoveTopTo( VIRT_MIN );
1020  if( clientRectIU.GetRight() > VIRT_MAX )
1021  clientRectIU.MoveRightTo( VIRT_MAX );
1022  if( clientRectIU.GetBottom() > VIRT_MAX )
1023  clientRectIU.MoveBottomTo( VIRT_MAX );
1024 
1025  centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
1026  centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
1027 
1028  if( screen->m_Center )
1029  {
1030  centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
1031  centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
1032  }
1033 
1034  DSIZE virtualSizeIU;
1035 
1036  if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
1037  {
1038  virtualSizeIU.x = pageRectIU.GetSize().x;
1039  }
1040  else
1041  {
1042  double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
1043  double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
1044 
1045  if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
1046  {
1047  if( pageCenterX > clientCenterX )
1048  virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
1049  else if( pageCenterX < clientCenterX )
1050  virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
1051  else
1052  virtualSizeIU.x = clientRectIU.GetWidth();
1053  }
1054  else
1055  {
1056  if( pageCenterX > clientCenterX )
1057  virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
1058  else if( pageCenterX < clientCenterX )
1059  virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
1060  else
1061  virtualSizeIU.x = pageRectIU.GetWidth();
1062  }
1063  }
1064 
1065  if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
1066  {
1067  virtualSizeIU.y = pageRectIU.GetSize().y;
1068  }
1069  else
1070  {
1071  double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
1072  double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
1073 
1074  if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
1075  {
1076  if( pageCenterY > clientCenterY )
1077  virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
1078  else if( pageCenterY < clientCenterY )
1079  virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
1080  else
1081  virtualSizeIU.y = clientRectIU.GetHeight();
1082  }
1083  else
1084  {
1085  if( pageCenterY > clientCenterY )
1086  virtualSizeIU.y = pageRectIU.GetHeight() +
1087  ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
1088  else if( pageCenterY < clientCenterY )
1089  virtualSizeIU.y = pageRectIU.GetHeight() +
1090  ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
1091  else
1092  virtualSizeIU.y = pageRectIU.GetHeight();
1093  }
1094  }
1095 
1096  // put "int" limits on the virtualSizeIU
1097  virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
1098  virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
1099 
1100  if( screen->m_Center )
1101  {
1102  screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
1103  screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
1104  }
1105  else
1106  {
1107  screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
1108  screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
1109  }
1110 
1111  /* Always set scrollbar pixels per unit to 1 unless you want the zoom
1112  * around cursor to jump around. This reported problem occurs when the
1113  * zoom point is not on a pixel per unit increment. If you set the
1114  * pixels per unit to 10, you have potential for the zoom point to
1115  * jump around +/-5 pixels from the nearest grid point.
1116  */
1117  screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
1118 
1119  // Number of scroll bar units for the given zoom level in device units.
1120  double unitsX = virtualSizeIU.x * scale;
1121  double unitsY = virtualSizeIU.y * scale;
1122 
1123  // Store the requested center position for later use
1124  SetScrollCenterPosition( aCenterPositionIU );
1125 
1126  // Calculate the scroll bar position in internal units to place the
1127  // center position at the center of client rectangle.
1128  double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
1129  double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
1130 
1131  // Convert scroll bar position to device units.
1132  posX = KiROUND( posX * scale );
1133  posY = KiROUND( posY * scale );
1134 
1135  if( posX < 0 )
1136  {
1137  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1138  posX = 0;
1139  }
1140 
1141  if( posX > unitsX )
1142  {
1143  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1144  posX = unitsX;
1145  }
1146 
1147  if( posY < 0 )
1148  {
1149  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1150  posY = 0;
1151  }
1152 
1153  if( posY > unitsY )
1154  {
1155  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1156  posY = unitsY;
1157  }
1158 
1159  screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
1160  screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
1161 
1162  wxLogTrace( traceScrollSettings,
1163  wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
1164  virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
1165  screen->m_DrawOrg.x, screen->m_DrawOrg.y,
1167  screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
1168  screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
1169 
1170  bool noRefresh = true;
1171 
1172  m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
1173  screen->m_ScrollPixelsPerUnitY,
1174  screen->m_ScrollbarNumber.x,
1175  screen->m_ScrollbarNumber.y,
1176  screen->m_ScrollbarPos.x,
1177  screen->m_ScrollbarPos.y, noRefresh );
1178 }
1179 
1180 
1181 void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
1182 {
1183  KIGFX::VIEW* view = GetGalCanvas()->GetView();
1184  KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
1185 
1186  // Display the same view after canvas switching
1187  if( aEnable )
1188  {
1189  // Switch to GAL renderer from legacy
1190  if( !m_galCanvasActive )
1191  {
1192  // Set up viewport
1193  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1194  double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
1195  view->SetScale( zoom );
1197  }
1198 
1199  // Set up grid settings
1200  gal->SetGridVisibility( IsGridVisible() );
1201  gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
1202  gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
1203 
1204  // Transfer EDA_DRAW_PANEL settings
1208  }
1209  else if( m_galCanvasActive )
1210  {
1211  // Switch to legacy renderer from GAL
1212  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1213  // TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
1214  m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
1215  VECTOR2D center = view->GetCenter();
1216  AdjustScrollBars( wxPoint( center.x, center.y ) );
1217  }
1218 
1219  m_canvas->SetEvtHandlerEnabled( !aEnable );
1220  GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
1221 
1222  // Switch panes
1223  m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
1224  m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
1225  m_auimgr.Update();
1226 
1227  // Reset current tool on switch();
1229 
1230  m_galCanvasActive = aEnable;
1231 }
1232 
1233 
1235 {
1236  auto galCanvas = GetGalCanvas();
1237  wxCHECK( galCanvas, false );
1238  bool use_gal = galCanvas->SwitchBackend( aCanvasType );
1239  use_gal &= aCanvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1240  UseGalCanvas( use_gal );
1241  m_canvasType = use_gal ? aCanvasType : EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1242  m_canvasTypeDirty = true;
1243 
1244  return use_gal;
1245 }
1246 
1247 
1249 {
1251  wxConfigBase* cfg = Kiface().KifaceSettings();
1252 
1253  if( cfg )
1254  canvasType = (EDA_DRAW_PANEL_GAL::GAL_TYPE) cfg->ReadLong( CANVAS_TYPE_KEY,
1256 
1257  if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1258  || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1259  {
1260  assert( false );
1261  canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
1262  }
1263 
1264  return canvasType;
1265 }
1266 
1267 
1269 {
1270  if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
1271  || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
1272  {
1273  assert( false );
1274  return false;
1275  }
1276 
1277  wxConfigBase* cfg = Kiface().KifaceSettings();
1278 
1279  if( cfg )
1280  return cfg->Write( CANVAS_TYPE_KEY, (long) aCanvasType );
1281 
1282  return false;
1283 }
1284 
1285 //-----< BASE_SCREEN API moved here >--------------------------------------------
1286 
1288 {
1289  // subject to change, borrow from old BASE_SCREEN for now.
1290  if( IsGalCanvasActive() )
1291  {
1293 
1294  return wxPoint( cursor.x, cursor.y );
1295  }
1296  else
1297  {
1298  BASE_SCREEN* screen = GetScreen(); // virtual call
1299  return screen->getCrossHairPosition( aInvertY );
1300  }
1301 }
1302 
1303 
1304 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1305 {
1306  BASE_SCREEN* screen = GetScreen(); // virtual call
1307  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1308 }
1309 
1310 
1311 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1312 {
1313  BASE_SCREEN* screen = GetScreen(); // virtual call
1314  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1315 }
1316 
1317 
1318 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
1319 {
1320  BASE_SCREEN* screen = GetScreen(); // virtual call
1321  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1322 }
1323 
1324 
1326 {
1327  BASE_SCREEN* screen = GetScreen(); // virtual call
1328  return screen->getCrossHairScreenPosition();
1329 }
1330 
1331 
1333 {
1334  BASE_SCREEN* screen = GetScreen(); // virtual call
1335  screen->setMousePosition( aPosition );
1336 }
1337 
1338 
1339 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1340 {
1341  BASE_SCREEN* screen = GetScreen(); // virtual call
1342  return screen->refPos( useMouse );
1343 }
1344 
1345 
1347 {
1348  BASE_SCREEN* screen = GetScreen(); // virtual call
1349  return screen->getScrollCenterPosition();
1350 }
1351 
1352 
1354 {
1355  BASE_SCREEN* screen = GetScreen(); // virtual call
1356  screen->setScrollCenterPosition( aPoint );
1357 }
1358 
1359 //-----</BASE_SCREEN API moved here >--------------------------------------------
1360 
1362  const wxPoint &aEvtPos,
1363  wxDC* aDC )
1364 {
1365  wxPoint newpos = GetCrossHairPosition();
1366 
1367  // Redraw the crosshair if it moved
1368  if( aOldPos != newpos )
1369  {
1370  SetCrossHairPosition( aOldPos, false );
1371  m_canvas->CrossHairOff( aDC );
1372  SetCrossHairPosition( newpos, false );
1373  m_canvas->CrossHairOn( aDC );
1374 
1375  if( m_canvas->IsMouseCaptured() )
1376  {
1377 #ifdef USE_WX_OVERLAY
1378  wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
1379  oDC.Clear();
1380  m_canvas->CallMouseCapture( aDC, aEvtPos, false );
1381 #else
1382  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1383 #endif
1384  }
1385 #ifdef USE_WX_OVERLAY
1386  else
1387  {
1388  m_overlay.Reset();
1389  }
1390 #endif
1391  }
1392 }
1393 
1395  bool aSnapToGrid )
1396 {
1397  bool key_handled = false;
1398 
1399  // If requested snap the current position to the grid
1400  if( aSnapToGrid )
1401  *aPos = GetNearestGridPosition( *aPos );
1402 
1403  switch( aHotKey )
1404  {
1405  // All these keys have almost the same treatment
1406  case GR_KB_CTRL | WXK_NUMPAD8:
1407  case GR_KB_CTRL | WXK_UP:
1408  case GR_KB_CTRL | WXK_NUMPAD2:
1409  case GR_KB_CTRL | WXK_DOWN:
1410  case GR_KB_CTRL | WXK_NUMPAD4:
1411  case GR_KB_CTRL | WXK_LEFT:
1412  case GR_KB_CTRL | WXK_NUMPAD6:
1413  case GR_KB_CTRL | WXK_RIGHT:
1414  case WXK_NUMPAD8:
1415  case WXK_UP:
1416  case WXK_NUMPAD2:
1417  case WXK_DOWN:
1418  case WXK_NUMPAD4:
1419  case WXK_LEFT:
1420  case WXK_NUMPAD6:
1421  case WXK_RIGHT:
1422  key_handled = true;
1423  {
1424  /* Here's a tricky part: when doing cursor key movement, the
1425  * 'previous' point should be taken from memory, *not* from the
1426  * freshly computed position in the event. Otherwise you can't do
1427  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1428  * the automatic motion event generated by cursor warping */
1429  wxRealPoint gridSize = GetScreen()->GetGridSize();
1430  *aPos = GetCrossHairPosition();
1431 
1432  // Bonus: ^key moves faster (x10)
1433  switch( aHotKey )
1434  {
1435  case GR_KB_CTRL|WXK_NUMPAD8:
1436  case GR_KB_CTRL|WXK_UP:
1437  aPos->y -= KiROUND( 10 * gridSize.y );
1438  break;
1439 
1440  case GR_KB_CTRL|WXK_NUMPAD2:
1441  case GR_KB_CTRL|WXK_DOWN:
1442  aPos->y += KiROUND( 10 * gridSize.y );
1443  break;
1444 
1445  case GR_KB_CTRL|WXK_NUMPAD4:
1446  case GR_KB_CTRL|WXK_LEFT:
1447  aPos->x -= KiROUND( 10 * gridSize.x );
1448  break;
1449 
1450  case GR_KB_CTRL|WXK_NUMPAD6:
1451  case GR_KB_CTRL|WXK_RIGHT:
1452  aPos->x += KiROUND( 10 * gridSize.x );
1453  break;
1454 
1455  case WXK_NUMPAD8:
1456  case WXK_UP:
1457  aPos->y -= KiROUND( gridSize.y );
1458  break;
1459 
1460  case WXK_NUMPAD2:
1461  case WXK_DOWN:
1462  aPos->y += KiROUND( gridSize.y );
1463  break;
1464 
1465  case WXK_NUMPAD4:
1466  case WXK_LEFT:
1467  aPos->x -= KiROUND( gridSize.x );
1468  break;
1469 
1470  case WXK_NUMPAD6:
1471  case WXK_RIGHT:
1472  aPos->x += KiROUND( gridSize.x );
1473  break;
1474 
1475  default: /* Can't happen since we entered the statement */
1476  break;
1477  }
1478 
1479  m_canvas->MoveCursor( *aPos );
1481  }
1482  break;
1483 
1484  default:
1485  break;
1486  }
1487 
1488  return key_handled;
1489 }
1490 
1491 
1493 {
1494  const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
1495 
1496  if( !screen )
1497  return false;
1498 
1499  return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
1500  || ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
1501 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:108
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:80
void AdjustScrollBars(const wxPoint &aCenterPosition)
Definition: draw_frame.cpp:969
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:89
bool m_galCanvasActive
whether to use new GAL engine
Definition: draw_frame.h:75
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:966
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:924
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:735
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:713
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it by 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:630
virtual int BlockCommand(EDA_KEY aKey)
Function BlockCommand Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the...
Definition: draw_frame.cpp:700
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:109
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:165
#define VIRT_MIN
min X or Y coordinate in virtual space
Definition: draw_frame.cpp:965
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:541
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...
PCB_EDIT_FRAME::OnResetModuleTextSizes PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::OnSelectOptionToolbar PCB_EDIT_FRAME::ProcessMuWaveFunctions PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar PCB_EDIT_FRAME::OnUpdateSelectCustomTrackWidth EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH8, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth) EVT_UPDATE_UI_RANGE(ID_POPUP_PCB_SELECT_VIASIZE1
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:85
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:534
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:655
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
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:864
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:132
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:87
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:792
virtual void InitBlockPasteInfos()
Definition: draw_frame.cpp:706
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:506
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:162
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)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: common.cpp:87
void DisplayUnitsMsg()
Function DisplayUnitsMsg displays current unit pane on the status bar.
Definition: draw_frame.cpp:558
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:881
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:106
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:139
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:369
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:146
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:72
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:831
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:875
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:149
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:146
wxChoice * m_zoomSelectBox
Choice box to choose the zoom value.
Definition: draw_frame.h:135
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
double GetZoom()
Function GetZoom.
Definition: draw_frame.cpp:535
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:895
virtual void OnSize(wxSizeEvent &event)
Function OnSize recalculates the size of toolbars and display panel when the frame size changes...
Definition: draw_frame.cpp:582
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:669
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:102
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:590
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:91
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:525
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:143
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:760
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:641
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:77
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:718
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
wxSocketServer * m_socketServer
Definition: draw_frame.h:84
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:615
coord_type GetHeight() const
Definition: box2.h:186
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:106
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:811
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:910
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:963
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:99
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:552
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.
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:903
virtual void SetGridVisibility(bool aVisible)
Function SetGridVisibility() , virtual It may be overloaded by derived classes.
Definition: draw_frame.h:516
static const wxChar CANVAS_TYPE_KEY[]
Key in KifaceSettings to store the canvas type.
Definition: draw_frame.h:212
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:870
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:110
virtual void OnLeftDClick(wxDC *DC, const wxPoint &MousePos)
Definition: draw_frame.cpp:547
#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:724
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:159
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:822
void UpdateHotKeys()
>
long m_firstRunDialogSetting
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:129
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:74
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:853
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.