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