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_COPY: // Copy
848  case BLOCK_COPY_AND_INCREMENT: // Copy and increment relevant references
849  case BLOCK_DELETE: // Delete
850  case BLOCK_SAVE: // Save
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  return true;
871  }
872 
873  if( !m_canvas->IsMouseCaptured() )
874  {
875  block->ClearItemsList();
876  DisplayError( this,
877  wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
878  return true;
879  }
880 
881  block->SetState( STATE_BLOCK_MOVE );
882  m_canvas->CallMouseCapture( aDC, aPosition, false );
883  break;
884 
885  default:
886  {
887  wxString msg;
888  msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
889  block->GetCommand();
890  DisplayError( this, msg );
891  }
892  break;
893  }
894 
895  block->SetMessageBlock( this );
896  return true;
897 }
898 
899 
900 // I am not seeing a problem with this size yet:
901 static const double MAX_AXIS = INT_MAX - 100;
902 
903 #define VIRT_MIN (-MAX_AXIS/2.0)
904 #define VIRT_MAX (MAX_AXIS/2.0)
905 
906 
907 void EDA_DRAW_FRAME::AdjustScrollBars( const wxPoint& aCenterPositionIU )
908 {
909  BASE_SCREEN* screen = GetScreen();
910 
911  if( !screen || !m_canvas )
912  return;
913 
914  double scale = screen->GetScalingFactor();
915 
916  wxLogTrace( traceScrollSettings, wxT( "Center Position = ( %d, %d ), scale = %.10g" ),
917  aCenterPositionIU.x, aCenterPositionIU.y, scale );
918 
919  // Calculate the portion of the drawing that can be displayed in the
920  // client area at the current zoom level.
921 
922  // visible viewport in device units ~ pixels
923  wxSize clientSizeDU = m_canvas->GetClientSize();
924 
925  // Size of the client window in IU
926  DSIZE clientSizeIU( clientSizeDU.x / scale, clientSizeDU.y / scale );
927 
928  // Full drawing or "page" rectangle in internal units
929  DBOX pageRectIU( wxPoint( 0, 0 ), wxSize( GetPageSizeIU().x, GetPageSizeIU().y ) );
930 
931  // Account for scrollbars
932  wxSize scrollbarSizeDU = m_canvas->GetSize() - m_canvas->GetClientSize();
933  wxSize scrollbarSizeIU = scrollbarSizeDU * (1 / scale);
934  wxPoint centerAdjustedIU = aCenterPositionIU + scrollbarSizeIU / 2;
935 
936  // The upper left corner of the client rectangle in internal units.
937  double xIU = centerAdjustedIU.x - clientSizeIU.x / 2.0;
938  double yIU = centerAdjustedIU.y - clientSizeIU.y / 2.0;
939 
940  // If drawn around the center, adjust the client rectangle accordingly.
941  if( screen->m_Center )
942  {
943  // half page offset.
944  xIU += pageRectIU.GetWidth() / 2.0;
945  yIU += pageRectIU.GetHeight() / 2.0;
946  }
947 
948  DBOX clientRectIU( wxPoint( xIU, yIU ), wxSize( clientSizeIU.x, clientSizeIU.y ) );
949  wxPoint centerPositionIU;
950 
951  // put "int" limits on the clientRect
952  if( clientRectIU.GetLeft() < VIRT_MIN )
953  clientRectIU.MoveLeftTo( VIRT_MIN );
954  if( clientRectIU.GetTop() < VIRT_MIN )
955  clientRectIU.MoveTopTo( VIRT_MIN );
956  if( clientRectIU.GetRight() > VIRT_MAX )
957  clientRectIU.MoveRightTo( VIRT_MAX );
958  if( clientRectIU.GetBottom() > VIRT_MAX )
959  clientRectIU.MoveBottomTo( VIRT_MAX );
960 
961  centerPositionIU.x = KiROUND( clientRectIU.GetX() + clientRectIU.GetWidth() / 2 );
962  centerPositionIU.y = KiROUND( clientRectIU.GetY() + clientRectIU.GetHeight() / 2 );
963 
964  if( screen->m_Center )
965  {
966  centerPositionIU.x -= KiROUND( pageRectIU.GetWidth() / 2.0 );
967  centerPositionIU.y -= KiROUND( pageRectIU.GetHeight() / 2.0 );
968  }
969 
970  DSIZE virtualSizeIU;
971 
972  if( pageRectIU.GetLeft() < clientRectIU.GetLeft() && pageRectIU.GetRight() > clientRectIU.GetRight() )
973  {
974  virtualSizeIU.x = pageRectIU.GetSize().x;
975  }
976  else
977  {
978  double pageCenterX = pageRectIU.GetX() + ( pageRectIU.GetWidth() / 2 );
979  double clientCenterX = clientRectIU.GetX() + ( clientRectIU.GetWidth() / 2 );
980 
981  if( clientRectIU.GetWidth() > pageRectIU.GetWidth() )
982  {
983  if( pageCenterX > clientCenterX )
984  virtualSizeIU.x = ( pageCenterX - clientRectIU.GetLeft() ) * 2;
985  else if( pageCenterX < clientCenterX )
986  virtualSizeIU.x = ( clientRectIU.GetRight() - pageCenterX ) * 2;
987  else
988  virtualSizeIU.x = clientRectIU.GetWidth();
989  }
990  else
991  {
992  if( pageCenterX > clientCenterX )
993  virtualSizeIU.x = pageRectIU.GetWidth() + ( (pageRectIU.GetLeft() - clientRectIU.GetLeft() ) * 2 );
994  else if( pageCenterX < clientCenterX )
995  virtualSizeIU.x = pageRectIU.GetWidth() + ( (clientRectIU.GetRight() - pageRectIU.GetRight() ) * 2 );
996  else
997  virtualSizeIU.x = pageRectIU.GetWidth();
998  }
999  }
1000 
1001  if( pageRectIU.GetTop() < clientRectIU.GetTop() && pageRectIU.GetBottom() > clientRectIU.GetBottom() )
1002  {
1003  virtualSizeIU.y = pageRectIU.GetSize().y;
1004  }
1005  else
1006  {
1007  double pageCenterY = pageRectIU.GetY() + ( pageRectIU.GetHeight() / 2 );
1008  double clientCenterY = clientRectIU.GetY() + ( clientRectIU.GetHeight() / 2 );
1009 
1010  if( clientRectIU.GetHeight() > pageRectIU.GetHeight() )
1011  {
1012  if( pageCenterY > clientCenterY )
1013  virtualSizeIU.y = ( pageCenterY - clientRectIU.GetTop() ) * 2;
1014  else if( pageCenterY < clientCenterY )
1015  virtualSizeIU.y = ( clientRectIU.GetBottom() - pageCenterY ) * 2;
1016  else
1017  virtualSizeIU.y = clientRectIU.GetHeight();
1018  }
1019  else
1020  {
1021  if( pageCenterY > clientCenterY )
1022  virtualSizeIU.y = pageRectIU.GetHeight() +
1023  ( ( pageRectIU.GetTop() - clientRectIU.GetTop() ) * 2 );
1024  else if( pageCenterY < clientCenterY )
1025  virtualSizeIU.y = pageRectIU.GetHeight() +
1026  ( ( clientRectIU.GetBottom() - pageRectIU.GetBottom() ) * 2 );
1027  else
1028  virtualSizeIU.y = pageRectIU.GetHeight();
1029  }
1030  }
1031 
1032  // put "int" limits on the virtualSizeIU
1033  virtualSizeIU.x = std::min( virtualSizeIU.x, MAX_AXIS );
1034  virtualSizeIU.y = std::min( virtualSizeIU.y, MAX_AXIS );
1035 
1036  if( screen->m_Center )
1037  {
1038  screen->m_DrawOrg.x = -KiROUND( virtualSizeIU.x / 2.0 );
1039  screen->m_DrawOrg.y = -KiROUND( virtualSizeIU.y / 2.0 );
1040  }
1041  else
1042  {
1043  screen->m_DrawOrg.x = -KiROUND( ( virtualSizeIU.x - pageRectIU.GetWidth() ) / 2.0 );
1044  screen->m_DrawOrg.y = -KiROUND( ( virtualSizeIU.y - pageRectIU.GetHeight() ) / 2.0 );
1045  }
1046 
1047  /* Always set scrollbar pixels per unit to 1 unless you want the zoom
1048  * around cursor to jump around. This reported problem occurs when the
1049  * zoom point is not on a pixel per unit increment. If you set the
1050  * pixels per unit to 10, you have potential for the zoom point to
1051  * jump around +/-5 pixels from the nearest grid point.
1052  */
1053  screen->m_ScrollPixelsPerUnitX = screen->m_ScrollPixelsPerUnitY = 1;
1054 
1055  // Number of scroll bar units for the given zoom level in device units.
1056  double unitsX = virtualSizeIU.x * scale;
1057  double unitsY = virtualSizeIU.y * scale;
1058 
1059  // Store the requested center position for later use
1060  SetScrollCenterPosition( aCenterPositionIU );
1061 
1062  // Calculate the scroll bar position in internal units to place the
1063  // center position at the center of client rectangle.
1064  double posX = centerPositionIU.x - clientRectIU.GetWidth() / 2.0 - screen->m_DrawOrg.x;
1065  double posY = centerPositionIU.y - clientRectIU.GetHeight() / 2.0 - screen->m_DrawOrg.y;
1066 
1067  // Convert scroll bar position to device units.
1068  posX = KiROUND( posX * scale );
1069  posY = KiROUND( posY * scale );
1070 
1071  if( posX < 0 )
1072  {
1073  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1074  posX = 0;
1075  }
1076 
1077  if( posX > unitsX )
1078  {
1079  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar X position %.10g" ), posX );
1080  posX = unitsX;
1081  }
1082 
1083  if( posY < 0 )
1084  {
1085  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1086  posY = 0;
1087  }
1088 
1089  if( posY > unitsY )
1090  {
1091  wxLogTrace( traceScrollSettings, wxT( "Required scroll bar Y position %.10g" ), posY );
1092  posY = unitsY;
1093  }
1094 
1095  screen->m_ScrollbarPos = wxPoint( KiROUND( posX ), KiROUND( posY ) );
1096  screen->m_ScrollbarNumber = wxSize( KiROUND( unitsX ), KiROUND( unitsY ) );
1097 
1098  wxLogTrace( traceScrollSettings,
1099  wxT( "Drawing = (%.10g, %.10g), Client = (%.10g, %.10g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)" ),
1100  virtualSizeIU.x, virtualSizeIU.y, clientSizeIU.x, clientSizeIU.y,
1101  screen->m_DrawOrg.x, screen->m_DrawOrg.y,
1103  screen->m_ScrollbarNumber.x, screen->m_ScrollbarNumber.y,
1104  screen->m_ScrollbarPos.x, screen->m_ScrollbarPos.y );
1105 
1106  bool noRefresh = true;
1107 
1108  m_canvas->SetScrollbars( screen->m_ScrollPixelsPerUnitX,
1109  screen->m_ScrollPixelsPerUnitY,
1110  screen->m_ScrollbarNumber.x,
1111  screen->m_ScrollbarNumber.y,
1112  screen->m_ScrollbarPos.x,
1113  screen->m_ScrollbarPos.y, noRefresh );
1114 }
1115 
1116 
1117 void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
1118 {
1119  KIGFX::VIEW* view = GetGalCanvas()->GetView();
1120  KIGFX::GAL* gal = GetGalCanvas()->GetGAL();
1121 
1122  // Display the same view after canvas switching
1123  if( aEnable )
1124  {
1125  // Switch to GAL renderer from legacy
1126  if( !m_galCanvasActive )
1127  {
1128  // Set up viewport
1129  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1130  double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
1131  view->SetScale( zoom );
1133  }
1134 
1135  // Set up grid settings
1136  gal->SetGridVisibility( IsGridVisible() );
1137  gal->SetGridSize( VECTOR2D( GetScreen()->GetGridSize() ) );
1138  gal->SetGridOrigin( VECTOR2D( GetGridOrigin() ) );
1139 
1140  // Transfer EDA_DRAW_PANEL settings
1143  }
1144  else if( m_galCanvasActive )
1145  {
1146  // Switch to legacy renderer from GAL
1147  double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
1148  // TODO replace it with EDA_DRAW_PANEL_GAL::GetLegacyZoom
1149  m_canvas->SetZoom( 1.0 / ( zoomFactor * view->GetScale() ) );
1150  VECTOR2D center = view->GetCenter();
1151  AdjustScrollBars( wxPoint( center.x, center.y ) );
1152  }
1153 
1154  m_canvas->SetEvtHandlerEnabled( !aEnable );
1155  GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
1156 
1157  // Switch panes
1158  m_auimgr.GetPane( wxT( "DrawFrame" ) ).Show( !aEnable );
1159  m_auimgr.GetPane( wxT( "DrawFrameGal" ) ).Show( aEnable );
1160  m_auimgr.Update();
1161 
1162  // Reset current tool on switch();
1164 
1165  m_galCanvasActive = aEnable;
1166 }
1167 
1168 //-----< BASE_SCREEN API moved here >--------------------------------------------
1169 
1171 {
1172  // subject to change, borrow from old BASE_SCREEN for now.
1173  if( IsGalCanvasActive() )
1174  {
1176 
1177  return wxPoint( cursor.x, cursor.y );
1178  }
1179  else
1180  {
1181  BASE_SCREEN* screen = GetScreen(); // virtual call
1182  return screen->getCrossHairPosition( aInvertY );
1183  }
1184 }
1185 
1186 
1187 void EDA_DRAW_FRAME::SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid )
1188 {
1189  BASE_SCREEN* screen = GetScreen(); // virtual call
1190  screen->setCrossHairPosition( aPosition, GetGridOrigin(), aSnapToGrid );
1191 }
1192 
1193 
1194 wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize ) const
1195 {
1196  BASE_SCREEN* screen = GetScreen(); // virtual call
1197  return screen->getCursorPosition( aOnGrid, GetGridOrigin(), aGridSize );
1198 }
1199 
1200 
1201 wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
1202 {
1203  BASE_SCREEN* screen = GetScreen(); // virtual call
1204  return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
1205 }
1206 
1207 
1209 {
1210  BASE_SCREEN* screen = GetScreen(); // virtual call
1211  return screen->getCrossHairScreenPosition();
1212 }
1213 
1214 
1216 {
1217  BASE_SCREEN* screen = GetScreen(); // virtual call
1218  screen->setMousePosition( aPosition );
1219 }
1220 
1221 
1222 wxPoint EDA_DRAW_FRAME::RefPos( bool useMouse ) const
1223 {
1224  BASE_SCREEN* screen = GetScreen(); // virtual call
1225  return screen->refPos( useMouse );
1226 }
1227 
1228 
1230 {
1231  BASE_SCREEN* screen = GetScreen(); // virtual call
1232  return screen->getScrollCenterPosition();
1233 }
1234 
1235 
1237 {
1238  BASE_SCREEN* screen = GetScreen(); // virtual call
1239  screen->setScrollCenterPosition( aPoint );
1240 }
1241 
1242 //-----</BASE_SCREEN API moved here >--------------------------------------------
1243 
1245  const wxPoint &aEvtPos,
1246  wxDC* aDC )
1247 {
1248  wxPoint newpos = GetCrossHairPosition();
1249 
1250  // Redraw the crosshair if it moved
1251  if( aOldPos != newpos )
1252  {
1253  SetCrossHairPosition( aOldPos, false );
1254  m_canvas->CrossHairOff( aDC );
1255  SetCrossHairPosition( newpos, false );
1256  m_canvas->CrossHairOn( aDC );
1257 
1258  if( m_canvas->IsMouseCaptured() )
1259  {
1260 #ifdef USE_WX_OVERLAY
1261  wxDCOverlay oDC( m_overlay, (wxWindowDC*)aDC );
1262  oDC.Clear();
1263  m_canvas->CallMouseCapture( aDC, aEvtPos, false );
1264 #else
1265  m_canvas->CallMouseCapture( aDC, aEvtPos, true );
1266 #endif
1267  }
1268 #ifdef USE_WX_OVERLAY
1269  else
1270  {
1271  m_overlay.Reset();
1272  }
1273 #endif
1274  }
1275 }
1276 
1278  bool aSnapToGrid )
1279 {
1280 
1281  // If requested snap the current position to the grid
1282  if( aSnapToGrid )
1283  *aPos = GetNearestGridPosition( *aPos );
1284 
1285  switch( aHotKey )
1286  {
1287  // All these keys have almost the same treatment
1288  case GR_KB_CTRL | WXK_NUMPAD8:
1289  case GR_KB_CTRL | WXK_UP:
1290  case GR_KB_CTRL | WXK_NUMPAD2:
1291  case GR_KB_CTRL | WXK_DOWN:
1292  case GR_KB_CTRL | WXK_NUMPAD4:
1293  case GR_KB_CTRL | WXK_LEFT:
1294  case GR_KB_CTRL | WXK_NUMPAD6:
1295  case GR_KB_CTRL | WXK_RIGHT:
1296  case WXK_NUMPAD8:
1297  case WXK_UP:
1298  case WXK_NUMPAD2:
1299  case WXK_DOWN:
1300  case WXK_NUMPAD4:
1301  case WXK_LEFT:
1302  case WXK_NUMPAD6:
1303  case WXK_RIGHT:
1304  {
1305  /* Here's a tricky part: when doing cursor key movement, the
1306  * 'previous' point should be taken from memory, *not* from the
1307  * freshly computed position in the event. Otherwise you can't do
1308  * sub-pixel movement. The m_movingCursorWithKeyboard oneshot 'eats'
1309  * the automatic motion event generated by cursor warping */
1310  wxRealPoint gridSize = GetScreen()->GetGridSize();
1311  *aPos = GetCrossHairPosition();
1312 
1313  // Bonus: ^key moves faster (x10)
1314  switch( aHotKey )
1315  {
1316  case GR_KB_CTRL|WXK_NUMPAD8:
1317  case GR_KB_CTRL|WXK_UP:
1318  aPos->y -= KiROUND( 10 * gridSize.y );
1319  break;
1320 
1321  case GR_KB_CTRL|WXK_NUMPAD2:
1322  case GR_KB_CTRL|WXK_DOWN:
1323  aPos->y += KiROUND( 10 * gridSize.y );
1324  break;
1325 
1326  case GR_KB_CTRL|WXK_NUMPAD4:
1327  case GR_KB_CTRL|WXK_LEFT:
1328  aPos->x -= KiROUND( 10 * gridSize.x );
1329  break;
1330 
1331  case GR_KB_CTRL|WXK_NUMPAD6:
1332  case GR_KB_CTRL|WXK_RIGHT:
1333  aPos->x += KiROUND( 10 * gridSize.x );
1334  break;
1335 
1336  case WXK_NUMPAD8:
1337  case WXK_UP:
1338  aPos->y -= KiROUND( gridSize.y );
1339  break;
1340 
1341  case WXK_NUMPAD2:
1342  case WXK_DOWN:
1343  aPos->y += KiROUND( gridSize.y );
1344  break;
1345 
1346  case WXK_NUMPAD4:
1347  case WXK_LEFT:
1348  aPos->x -= KiROUND( gridSize.x );
1349  break;
1350 
1351  case WXK_NUMPAD6:
1352  case WXK_RIGHT:
1353  aPos->x += KiROUND( gridSize.x );
1354  break;
1355 
1356  default: /* Can't happen since we entered the statement */
1357  break;
1358  }
1359  m_canvas->MoveCursor( *aPos );
1361  }
1362  break;
1363 
1364  default:
1365  break;
1366  }
1367 }
1368 
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:907
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:904
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:903
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.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
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 ...)
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
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:901
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.
virtual COLOR4D GetGridColor() const
Function GetGridColor() , virtual.
Definition: draw_frame.h:448
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:69
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.