KiCad PCB EDA Suite
pcb_base_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) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
31 #include <fctsys.h>
32 #include <kiface_i.h>
33 #include <eda_base_frame.h>
34 #include <confirm.h>
35 #include <kiface_i.h>
36 #include <dialog_helpers.h>
37 #include <kicad_device_context.h>
38 #include <pcb_base_frame.h>
39 #include <base_units.h>
40 #include <msgpanel.h>
41 #include <pgm_base.h>
42 #include <3d_viewer/eda_3d_viewer.h> // To include VIEWER3D_FRAMENAME
43 
44 #include <pcbnew.h>
45 #include <fp_lib_table.h>
46 #include <pcbnew_id.h>
47 #include <class_board.h>
48 #include <class_track.h>
49 #include <class_module.h>
50 #include <class_drawsegment.h>
51 
52 #include <collectors.h>
53 #include <class_drawpanel.h>
54 #include <pcb_draw_panel_gal.h>
55 #include <pcb_view.h>
56 #include <math/vector2d.h>
57 #include <trigo.h>
58 #include <pcb_painter.h>
59 
60 #include <tool/tool_manager.h>
61 #include <tool/tool_dispatcher.h>
62 #include <tools/pcb_actions.h>
63 
64 const wxChar PCB_BASE_FRAME::AUTO_ZOOM_KEY[] = wxT( "AutoZoom" );
65 const wxChar PCB_BASE_FRAME::ZOOM_KEY[] = wxT( "Zoom" );
66 
67 // Configuration entry names.
68 static const wxChar UserGridSizeXEntry[] = wxT( "PcbUserGrid_X" );
69 static const wxChar UserGridSizeYEntry[] = wxT( "PcbUserGrid_Y" );
70 static const wxChar UserGridUnitsEntry[] = wxT( "PcbUserGrid_Unit" );
71 static const wxChar DisplayPadFillEntry[] = wxT( "DiPadFi" );
72 static const wxChar DisplayViaFillEntry[] = wxT( "DiViaFi" );
73 static const wxChar DisplayPadNumberEntry[] = wxT( "DiPadNu" );
74 static const wxChar DisplayModuleEdgeEntry[] = wxT( "DiModEd" );
75 static const wxChar DisplayModuleTextEntry[] = wxT( "DiModTx" );
76 static const wxChar FastGrid1Entry[] = wxT( "FastGrid1" );
77 static const wxChar FastGrid2Entry[] = wxT( "FastGrid2" );
78 
79 
80 BEGIN_EVENT_TABLE( PCB_BASE_FRAME, EDA_DRAW_FRAME )
82  PCB_BASE_FRAME::ProcessItemSelection )
83 
86  EVT_TOOL( ID_TB_OPTIONS_SHOW_GRAPHIC_SKETCH, PCB_BASE_FRAME::OnToggleGraphicDrawMode )
89 
95  EVT_UPDATE_UI( ID_ON_GRID_SELECT, PCB_BASE_FRAME::OnUpdateSelectGrid )
96  EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, PCB_BASE_FRAME::OnUpdateSelectZoom )
97  // Switching canvases
98  EVT_UPDATE_UI( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
99  EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
100  EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::OnUpdateSwitchCanvas )
101 
103 END_EVENT_TABLE()
104 
105 
106 PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
107  const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
108  long aStyle, const wxString & aFrameName ) :
109  EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
110  m_Pcb( nullptr ),
111  m_configSettings( aFrameType )
112 {
113  m_UserGridSize = wxPoint( (int) 10 * IU_PER_MILS, (int) 10 * IU_PER_MILS );
114  m_Collector = new GENERAL_COLLECTOR();
115 
116  m_FastGrid1 = 0;
117  m_FastGrid2 = 0;
118 
119  m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1
120  // when the screen shows a 1:1 image
121  // obviously depends on the monitor,
122  // but this is an acceptable value
123 }
124 
125 
127 {
128  // Ensure m_canvasType is up to date, to save it in config
129  if( !GetGalCanvas() )
131  else
133 
134  delete m_Collector;
135  delete m_Pcb;
136 }
137 
138 
140 {
141  // return the 3D viewer frame, when exists, or NULL
142  return static_cast<EDA_3D_VIEWER*>
143  ( wxWindow::FindWindowByName( VIEWER3D_FRAMENAME ) );
144 }
145 
146 
147 bool PCB_BASE_FRAME::Update3DView( const wxString* aTitle )
148 {
149  // Update the 3D view only if the viewer is opened by this frame
150  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
151 
152  if( draw3DFrame == NULL )
153  return false;
154 
155  // Ensure the viewer was created by me, and not by another editor:
156  PCB_BASE_FRAME* owner = draw3DFrame->Parent();
157 
158  // if I am not the owner, do not use the current viewer instance
159  if( this != owner )
160  return false;
161 
162  if( aTitle )
163  draw3DFrame->SetTitle( *aTitle );
164 
165  // The 3D view update can be time consumming to rebuild a board 3D view.
166  // So do not use a immediate update in the board editor
167  bool immediate_update = true;
168 
169  if( IsType( FRAME_PCB ) )
170  immediate_update = false;
171 
172  draw3DFrame->NewDisplay( immediate_update );
173 
174  return true;
175 }
176 
177 
179 {
180  // This is a lazy loading function, it loads the project specific table when
181  // that table is asked for, not before.
182 
184 
185  // its gotta be NULL or a FP_LIB_TABLE, or a bug.
186  wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
187 
188  if( !tbl )
189  {
190  // Stack the project specific FP_LIB_TABLE overlay on top of the global table.
191  // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
192  // stack this way, all using the same global fallback table.
193  tbl = new FP_LIB_TABLE( &GFootprintTable );
194 
195  SetElem( ELEM_FPTBL, tbl );
196 
197  wxString projectFpLibTableFileName = FootprintLibTblName();
198 
199  try
200  {
201  tbl->Load( projectFpLibTableFileName );
202  }
203  catch( const IO_ERROR& ioe )
204  {
205  DisplayErrorMessage( nullptr,
206  _( "Error loading project footprint libraries" ),
207  ioe.What() );
208  }
209  }
210 
211  return tbl;
212 }
213 
214 
216 {
217  if( m_Pcb != aBoard )
218  {
219  delete m_Pcb;
220  m_Pcb = aBoard;
221  m_Pcb->SetColorsSettings( &Settings().Colors() );
222  }
223 }
224 
225 
227 {
228  if( module )
229  {
230  GetBoard()->Add( module, ADD_APPEND );
231 
232  module->SetFlags( IS_NEW );
233 
234  if( IsGalCanvasActive() )
235  module->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
236  else
237  module->SetPosition( GetCrossHairPosition() );
238 
239  module->SetTimeStamp( GetNewTimeStamp() );
240  GetBoard()->m_Status_Pcb = 0;
241 
242  // Put it on FRONT layer,
243  // (Can be stored flipped if the lib is an archive built from a board)
244  if( module->IsFlipped() )
245  module->Flip( module->GetPosition() );
246 
247  // Place it in orientation 0,
248  // even if it is not saved with orientation 0 in lib
249  // (Can happen if the lib is an archive built from a board)
250  module->SetOrientation( 0 );
251  }
252 }
253 
254 
255 void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
256 {
257  wxASSERT( m_Pcb );
258  m_Pcb->SetPageSettings( aPageSettings );
259 
260  if( GetScreen() )
261  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
262 }
263 
264 
266 {
267  wxASSERT( m_Pcb );
268  return m_Pcb->GetPageSettings();
269 }
270 
271 
272 const wxSize PCB_BASE_FRAME::GetPageSizeIU() const
273 {
274  wxASSERT( m_Pcb );
275 
276  // this function is only needed because EDA_DRAW_FRAME is not compiled
277  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
278  // into an application specific source file.
279  return m_Pcb->GetPageSettings().GetSizeIU();
280 }
281 
282 
283 const wxPoint& PCB_BASE_FRAME::GetAuxOrigin() const
284 {
285  wxASSERT( m_Pcb );
286  return m_Pcb->GetAuxOrigin();
287 }
288 
289 
290 void PCB_BASE_FRAME::SetAuxOrigin( const wxPoint& aPoint )
291 {
292  wxASSERT( m_Pcb );
293  m_Pcb->SetAuxOrigin( aPoint );
294 }
295 
296 
297 const wxPoint& PCB_BASE_FRAME::GetGridOrigin() const
298 {
299  wxASSERT( m_Pcb );
300  return m_Pcb->GetGridOrigin();
301 }
302 
303 
304 void PCB_BASE_FRAME::SetGridOrigin( const wxPoint& aPoint )
305 {
306  wxASSERT( m_Pcb );
307  m_Pcb->SetGridOrigin( aPoint );
308 }
309 
310 
312 {
313  wxASSERT( m_Pcb );
314  return m_Pcb->GetTitleBlock();
315 }
316 
317 
318 void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
319 {
320  wxASSERT( m_Pcb );
321  m_Pcb->SetTitleBlock( aTitleBlock );
322 }
323 
324 
326 {
327  wxASSERT( m_Pcb );
328  return m_Pcb->GetDesignSettings();
329 }
330 
331 
333 {
334  wxASSERT( m_Pcb );
335  m_Pcb->SetDesignSettings( aSettings );
336 }
337 
338 
340 {
341  m_drawBgColor= aColor;
342  m_auimgr.Update();
343 }
344 
345 
347 {
348  wxASSERT( m_Pcb );
349  return m_Pcb->GetZoneSettings();
350 }
351 
352 
354 {
355  wxASSERT( m_Pcb );
356  m_Pcb->SetZoneSettings( aSettings );
357 }
358 
359 
361 {
362  wxASSERT( m_Pcb );
363  return m_Pcb->GetPlotOptions();
364 }
365 
366 
368 {
369  wxASSERT( m_Pcb );
370  m_Pcb->SetPlotOptions( aSettings );
371 }
372 
373 
374 EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
375 {
376  wxASSERT( m_Pcb );
377 
378  EDA_RECT area = aBoardEdgesOnly ? m_Pcb->GetBoardEdgesBoundingBox() : m_Pcb->GetBoundingBox();
379 
380  if( area.GetWidth() == 0 && area.GetHeight() == 0 )
381  {
382  wxSize pageSize = GetPageSizeIU();
383 
385  {
386  area.SetOrigin( 0, 0 );
387  area.SetEnd( pageSize.x, pageSize.y );
388  }
389  else
390  {
391  area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
392  area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
393  }
394  }
395 
396  return area;
397 }
398 
399 
401 {
402  EDA_RECT ibbbox = GetBoardBoundingBox();
403 
404  double sizeX = (double) ibbbox.GetWidth();
405  double sizeY = (double) ibbbox.GetHeight();
406  wxPoint centre = ibbbox.Centre();
407 
408  // Reserve a 10% margin around board bounding box.
409  double margin_scale_factor = 1.1;
410 
411  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
412 }
413 
414 
415 // Virtual function
417 {
418 }
419 
420 
422 {
423  // call my base class
425 
426  // tooltips in toolbars
431 
432  // status bar
433  UpdateMsgPanel();
434 }
435 
436 
437 // Virtual functions: Do nothing for PCB_BASE_FRAME window
438 void PCB_BASE_FRAME::Show3D_Frame( wxCommandEvent& event )
439 {
440 }
441 
442 
443 bool PCB_BASE_FRAME::CreateAndShow3D_Frame( bool aForceRecreateIfNotOwner )
444 {
445  EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
446 
447  // Ensure the viewer was created by me, and not by another editor:
448  PCB_BASE_FRAME* owner = draw3DFrame ? draw3DFrame->Parent() : nullptr;
449 
450  // if I am not the owner, do not use the current viewer instance
451  if( draw3DFrame && this != owner )
452  {
453  if( aForceRecreateIfNotOwner )
454  {
455  draw3DFrame->Destroy();
456  draw3DFrame = nullptr;
457  }
458  else
459  return false;
460  }
461 
462  if( !draw3DFrame )
463  {
464  draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
465  draw3DFrame->Raise(); // Needed with some Window Managers
466  draw3DFrame->Show( true );
467  return true;
468  }
469 
470  // Raising the window does not show the window on Windows if iconized.
471  // This should work on any platform.
472  if( draw3DFrame->IsIconized() )
473  draw3DFrame->Iconize( false );
474 
475  draw3DFrame->Raise();
476 
477  // Raising the window does not set the focus on Linux. This should work on any platform.
478  if( wxWindow::FindFocus() != draw3DFrame )
479  draw3DFrame->SetFocus();
480 
481  return true;
482 }
483 
484 
485 // Note: virtual, overridden in PCB_EDIT_FRAME;
487 {
488  PCB_LAYER_ID preslayer = GetActiveLayer();
489  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
490 
491  // Check if the specified layer matches the present layer
492  if( layer == preslayer )
493  return;
494 
495  // Copper layers cannot be selected unconditionally; how many
496  // of those layers are currently enabled needs to be checked.
497  if( IsCopperLayer( layer ) )
498  {
499  // If only one copper layer is enabled, the only such layer
500  // that can be selected to is the "Copper" layer (so the
501  // selection of any other copper layer is disregarded).
502  if( m_Pcb->GetCopperLayerCount() < 2 )
503  {
504  if( layer != B_Cu )
505  {
506  return;
507  }
508  }
509 
510  // If more than one copper layer is enabled, the "Copper"
511  // and "Component" layers can be selected, but the total
512  // number of copper layers determines which internal
513  // layers are also capable of being selected.
514  else
515  {
516  if( ( layer != B_Cu ) && ( layer != F_Cu )
517  && ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
518  {
519  return;
520  }
521  }
522  }
523 
524  // Is yet more checking required? E.g. when the layer to be selected
525  // is a non-copper layer, or when switching between a copper layer
526  // and a non-copper layer, or vice-versa?
527  // ...
528 
529  GetScreen()->m_Active_Layer = layer;
530 
531  if( displ_opts->m_ContrastModeDisplay )
532  m_canvas->Refresh();
533 }
534 
535 
536 void PCB_BASE_FRAME::OnTogglePolarCoords( wxCommandEvent& aEvent )
537 {
538  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
539  SetStatusText( wxEmptyString );
540 
541  displ_opts->m_DisplayPolarCood = !displ_opts->m_DisplayPolarCood;
542 
543  UpdateStatusBar();
544 }
545 
546 
547 void PCB_BASE_FRAME::OnTogglePadDrawMode( wxCommandEvent& aEvent )
548 {
549  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
550 
551  displ_opts->m_DisplayPadFill = !displ_opts->m_DisplayPadFill;
553 
554  if( gal )
555  {
556  // Apply new display options to the GAL canvas
557  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
558  view->UpdateDisplayOptions( displ_opts );
559 
560  // Update pads
561  BOARD* board = GetBoard();
562  for( MODULE* module = board->m_Modules; module; module = module->Next() )
563  {
564  for( auto pad : module->Pads() )
565  view->Update( pad, KIGFX::GEOMETRY );
566  }
567  }
568 
569  m_canvas->Refresh();
570 }
571 
572 
573 void PCB_BASE_FRAME::OnToggleGraphicDrawMode( wxCommandEvent& aEvent )
574 {
575  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
576  displ_opts->m_DisplayDrawItemsFill = !displ_opts->m_DisplayDrawItemsFill;
577  m_canvas->Refresh();
578 }
579 
580 
581 void PCB_BASE_FRAME::OnToggleEdgeDrawMode( wxCommandEvent& aEvent )
582 {
583  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
584  displ_opts->m_DisplayModEdgeFill = !displ_opts->m_DisplayModEdgeFill;
586 
587  if( gal )
588  {
589  // Apply new display options to the GAL canvas
590  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
591  view->UpdateDisplayOptions( displ_opts );
592  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
593  }
594 
595  m_canvas->Refresh();
596 }
597 
598 
599 void PCB_BASE_FRAME::OnToggleTextDrawMode( wxCommandEvent& aEvent )
600 {
601  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
602  displ_opts->m_DisplayModTextFill = !displ_opts->m_DisplayModTextFill;
604 
605  if( gal )
606  {
607  // Apply new display options to the GAL canvas
608  auto view = static_cast<KIGFX::PCB_VIEW*>( gal->GetView() );
609  view->UpdateDisplayOptions( displ_opts );
610  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
611  }
612 
613  m_canvas->Refresh();
614 }
615 
616 
617 void PCB_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
618 {
619  switch( aEvent.GetId() )
620  {
623  break;
624 
627  break;
628 
631  break;
632  }
633 }
634 
635 
636 void PCB_BASE_FRAME::OnUpdateCoordType( wxUpdateUIEvent& aEvent )
637 {
638  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
639 
640  aEvent.Check( displ_opts->m_DisplayPolarCood );
642  displ_opts->m_DisplayPolarCood ?
643  _( "Display rectangular coordinates" ) :
644  _( "Display polar coordinates" ) );
645 }
646 
647 
648 void PCB_BASE_FRAME::OnUpdatePadDrawMode( wxUpdateUIEvent& aEvent )
649 {
650  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
651 
652  aEvent.Check( !displ_opts->m_DisplayPadFill );
654  displ_opts->m_DisplayPadFill ?
655  _( "Show pads in outline mode" ) :
656  _( "Show pads in fill mode" ) );
657 }
658 
659 
660 void PCB_BASE_FRAME::OnUpdateGraphicDrawMode( wxUpdateUIEvent& aEvent )
661 {
662  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
663  aEvent.Check( !displ_opts->m_DisplayDrawItemsFill);
664 }
665 
666 
667 void PCB_BASE_FRAME::OnUpdateEdgeDrawMode( wxUpdateUIEvent& aEvent )
668 {
669  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
670  aEvent.Check( !displ_opts->m_DisplayModEdgeFill );
671 
672  wxString msgEdgesFill[2] = { _( "Show outlines in filled mode" ),
673  _( "Show outlines in sketch mode" ) };
674 
675  unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
676  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] );
677 }
678 
679 
680 void PCB_BASE_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
681 {
682  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
683  aEvent.Check( !displ_opts->m_DisplayModTextFill );
684 
685  wxString msgTextsFill[2] = { _( "Show texts in filled mode" ),
686  _( "Show texts in sketch mode" ) };
687  unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
688  m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] );
689 }
690 
691 
692 void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
693 {
694  if( m_zoomSelectBox == NULL || m_zoomSelectBox->GetParent() == NULL )
695  return;
696 
697  int current = 0; // display Auto if no match found
698 
699  // check for a match within 1%
700  double zoom = IsGalCanvasActive() ? GetGalCanvas()->GetLegacyZoom() : GetScreen()->GetZoom();
701 
702  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
703  {
704  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
705  {
706  current = i + 1;
707  break;
708  }
709  }
710 
711  if( current != m_zoomSelectBox->GetSelection() )
712  m_zoomSelectBox->SetSelection( current );
713 }
714 
715 
716 void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
717 {
718  int id = aEvent.GetId();
719 
720  // index into the collector list:
721  int itemNdx = id - ID_POPUP_PCB_ITEM_SELECTION_START;
722 
724  {
725  BOARD_ITEM* item = (*m_Collector)[itemNdx];
726  m_canvas->SetAbortRequest( false );
727 
728 #if 0 && defined (DEBUG)
729  item->Show( 0, std::cout );
730 #endif
731 
732  SetCurItem( item );
733  }
734 }
735 
736 
737 void PCB_BASE_FRAME::SetCurItem( BOARD_ITEM* aItem, bool aDisplayInfo )
738 {
739  GetScreen()->SetCurItem( aItem );
740 
741  if( aDisplayInfo )
742  UpdateMsgPanel();
743 }
744 
745 
747 {
748  BOARD_ITEM* item = GetScreen()->GetCurItem();
749  MSG_PANEL_ITEMS items;
750 
751  if( item )
752  {
753  item->GetMsgPanelInfo( m_UserUnits, items );
754  }
755  else // show general information about the board
756  {
757  if( IsGalCanvasActive() )
759  else
760  m_Pcb->GetMsgPanelInfo( m_UserUnits, items );
761  }
762 
763  SetMsgPanel( items );
764 }
765 
766 
768 {
769  return GetScreen()->GetCurItem();
770 }
771 
772 
774 {
776  GetGalCanvas()->GetView() );
777 
778  // account for the globals
780  guide.SetIgnoreMTextsOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_BK ) );
781  guide.SetIgnoreMTextsOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_TEXT_FR ) );
782  guide.SetIgnoreModulesOnBack( ! m_Pcb->IsElementVisible( LAYER_MOD_BK ) );
783  guide.SetIgnoreModulesOnFront( ! m_Pcb->IsElementVisible( LAYER_MOD_FR ) );
784  guide.SetIgnorePadsOnBack( ! m_Pcb->IsElementVisible( LAYER_PAD_BK ) );
785  guide.SetIgnorePadsOnFront( ! m_Pcb->IsElementVisible( LAYER_PAD_FR ) );
786  guide.SetIgnoreThroughHolePads( ! m_Pcb->IsElementVisible( LAYER_PADS_TH ) );
787  guide.SetIgnoreModulesVals( ! m_Pcb->IsElementVisible( LAYER_MOD_VALUES ) );
788  guide.SetIgnoreModulesRefs( ! m_Pcb->IsElementVisible( LAYER_MOD_REFERENCES ) );
789  guide.SetIgnoreThroughVias( ! m_Pcb->IsElementVisible( LAYER_VIA_THROUGH ) );
790  guide.SetIgnoreBlindBuriedVias( ! m_Pcb->IsElementVisible( LAYER_VIA_BBLIND ) );
791  guide.SetIgnoreMicroVias( ! m_Pcb->IsElementVisible( LAYER_VIA_MICROVIA ) );
792  guide.SetIgnoreTracks( ! m_Pcb->IsElementVisible( LAYER_TRACKS ) );
793 
794  return guide;
795 }
796 
797 void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
798 {
799  bool redraw = false;
800 
801  EDA_DRAW_FRAME::SetToolID( aId, aCursor, aToolMsg );
802 
803  if( aId < 0 )
804  return;
805 
806  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
807 
808  // handle color changes for transitions in and out of ID_TRACK_BUTT
809  if( ( GetToolId() == ID_TRACK_BUTT && aId != ID_TRACK_BUTT )
810  || ( GetToolId() != ID_TRACK_BUTT && aId == ID_TRACK_BUTT ) )
811  {
812  if( displ_opts->m_ContrastModeDisplay )
813  redraw = true;
814  }
815 
816  // must do this after the tool has been set, otherwise pad::Draw() does
817  // not show proper color when GetDisplayOptions().ContrastModeDisplay is true.
818  if( redraw && m_canvas )
819  m_canvas->Refresh();
820 }
821 
822 
823 /*
824  * Update the status bar information.
825  */
827 {
828  PCB_SCREEN* screen = GetScreen();
829 
830  if( !screen )
831  return;
832 
833  wxString line;
834  wxString locformatter;
835  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
836 
838 
839  if( displ_opts->m_DisplayPolarCood ) // display polar coordinates
840  {
841  double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
842  double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
843 
844  double theta = ArcTangente( -dy, dx ) / 10;
845  double ro = hypot( dx, dy );
846 
847  wxString formatter;
848  switch( GetUserUnits() )
849  {
850  case INCHES:
851  formatter = "r %.6f theta %.1f";
852  break;
853 
854  case MILLIMETRES:
855  formatter = "r %.6f theta %.1f";
856  break;
857 
858  case UNSCALED_UNITS:
859  formatter = "r %f theta %f";
860  break;
861 
862  case DEGREES:
863  wxASSERT( false );
864  break;
865  }
866 
867  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
868 
869  SetStatusText( line, 3 );
870  }
871 
872  // Display absolute coordinates:
873  double dXpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().x );
874  double dYpos = To_User_Unit( GetUserUnits(), GetCrossHairPosition().y );
875 
876  // The following sadly is an if Eeschema/if Pcbnew
877  wxString absformatter;
878 
879  switch( GetUserUnits() )
880  {
881  case INCHES:
882  absformatter = "X %.6f Y %.6f";
883  locformatter = "dx %.6f dy %.6f dist %.4f";
884  break;
885 
886  case MILLIMETRES:
887  absformatter = "X %.6f Y %.6f";
888  locformatter = "dx %.6f dy %.6f dist %.3f";
889  break;
890 
891  case UNSCALED_UNITS:
892  absformatter = "X %f Y %f";
893  locformatter = "dx %f dy %f dist %f";
894  break;
895 
896  case DEGREES:
897  wxASSERT( false );
898  break;
899  }
900 
901  line.Printf( absformatter, dXpos, dYpos );
902  SetStatusText( line, 2 );
903 
904  if( !displ_opts->m_DisplayPolarCood ) // display relative cartesian coordinates
905  {
906  // Display relative coordinates:
907  double dx = (double)GetCrossHairPosition().x - (double)screen->m_O_Curseur.x;
908  double dy = (double)GetCrossHairPosition().y - (double)screen->m_O_Curseur.y;
909  dXpos = To_User_Unit( GetUserUnits(), dx );
910  dYpos = To_User_Unit( GetUserUnits(), dy );
911 
912  // We already decided the formatter above
913  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
914  SetStatusText( line, 3 );
915  }
916 }
917 
918 
920 {
921  EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
922 
924 }
925 
926 
927 void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
928 {
930 
931  // Ensure grid id is an existent grid id:
932  if( (m_LastGridSizeId <= 0) ||
935 
936  wxString baseCfgName = GetName();
937 
938  EDA_UNITS_T userGridUnits;
939  aCfg->Read( baseCfgName + UserGridUnitsEntry, ( int* )&userGridUnits, ( int )INCHES );
940 
941  double tmp;
942  aCfg->Read( baseCfgName + UserGridSizeXEntry, &tmp, 0.01 );
943  m_UserGridSize.x = From_User_Unit( userGridUnits, tmp );
944 
945  aCfg->Read( baseCfgName + UserGridSizeYEntry, &tmp, 0.01 );
946  m_UserGridSize.y = From_User_Unit( userGridUnits, tmp );
947 
948  aCfg->Read( baseCfgName + DisplayPadFillEntry, &m_DisplayOptions.m_DisplayPadFill, true );
949  aCfg->Read( baseCfgName + DisplayViaFillEntry, &m_DisplayOptions.m_DisplayViaFill, true );
950  aCfg->Read( baseCfgName + DisplayPadNumberEntry, &m_DisplayOptions.m_DisplayPadNum, true );
951  aCfg->Read( baseCfgName + DisplayModuleEdgeEntry, &m_DisplayOptions.m_DisplayModEdgeFill, true );
952 
953  long itmp;
954  aCfg->Read( baseCfgName + FastGrid1Entry, &itmp, ( long )0);
955  m_FastGrid1 = itmp;
956  aCfg->Read( baseCfgName + FastGrid2Entry, &itmp, ( long )0);
957  m_FastGrid2 = itmp;
958 
959  aCfg->Read( baseCfgName + DisplayModuleTextEntry, &m_DisplayOptions.m_DisplayModTextFill, true );
960 }
961 
962 
963 void PCB_BASE_FRAME::SaveSettings( wxConfigBase* aCfg )
964 {
966 
967  wxString baseCfgName = GetName();
968 
969  aCfg->Write( baseCfgName + UserGridSizeXEntry, To_User_Unit( m_UserUnits, m_UserGridSize.x ) );
970  aCfg->Write( baseCfgName + UserGridSizeYEntry, To_User_Unit( m_UserUnits, m_UserGridSize.y ) );
971  aCfg->Write( baseCfgName + UserGridUnitsEntry, ( long )m_UserUnits );
972  aCfg->Write( baseCfgName + DisplayPadFillEntry, m_DisplayOptions.m_DisplayPadFill );
973  aCfg->Write( baseCfgName + DisplayViaFillEntry, m_DisplayOptions.m_DisplayViaFill );
974  aCfg->Write( baseCfgName + DisplayPadNumberEntry, m_DisplayOptions.m_DisplayPadNum );
975  aCfg->Write( baseCfgName + DisplayModuleEdgeEntry, m_DisplayOptions.m_DisplayModEdgeFill );
976  aCfg->Write( baseCfgName + DisplayModuleTextEntry, m_DisplayOptions.m_DisplayModTextFill );
977  aCfg->Write( baseCfgName + FastGrid1Entry, ( long )m_FastGrid1 );
978  aCfg->Write( baseCfgName + FastGrid2Entry, ( long )m_FastGrid2 );
979 }
980 
981 
983 {
985 
990 
991  EDA_3D_VIEWER* viewer = Get3DViewerFrame();
992 
993  if( viewer )
994  {
995  bool option;
996  Pgm().CommonSettings()->Read( ENBL_MOUSEWHEEL_PAN_KEY, &option );
997  viewer->GetSettings().SetFlag( FL_MOUSEWHEEL_PANNING, option );
998  }
999 }
1000 
1001 
1003 {
1004  GetScreen()->SetModify();
1005  GetScreen()->SetSave();
1006 
1007  if( IsGalCanvasActive() )
1008  {
1009  UpdateStatusBar();
1010  UpdateMsgPanel();
1011  }
1012 }
1013 
1014 
1016 {
1018 }
1019 
1020 
1022 {
1023  UpdateStatusBar();
1024  DisplayUnitsMsg();
1025 
1026  if( m_gridSelectBox == NULL )
1027  return;
1028 
1029  // Update grid values with the current units setting.
1030  m_gridSelectBox->Clear();
1031  wxArrayString gridsList;
1032  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
1033 
1034  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1035  {
1036  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1037  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1038  }
1039 
1040  m_gridSelectBox->Append( wxT( "---" ) );
1041  m_gridSelectBox->Append( _( "Edit user grid..." ) );
1042 
1043  m_gridSelectBox->SetSelection( icurr );
1044 }
1045 
1046 
1048 {
1049  if( m_zoomSelectBox == NULL )
1050  return;
1051 
1052  wxString msg;
1053 
1054  m_zoomSelectBox->Clear();
1055  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1056  m_zoomSelectBox->SetSelection( 0 );
1057 
1058  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1059  {
1060  msg = _( "Zoom " );
1061 
1062  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1063  wxString value = wxString::Format( wxT( "%.2f" ), level );
1064  msg += value;
1065 
1066  m_zoomSelectBox->Append( msg );
1067 
1068  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1069  m_zoomSelectBox->SetSelection( i + 1 );
1070  }
1071 }
1072 
1073 
1075 {
1076  if( m_FastGrid1 >= (int)GetScreen()->GetGridCount() )
1077  return;
1078 
1079  int cmdId = GetScreen()->GetGrids()[m_FastGrid1].m_CmdId;
1081 
1082  if( m_gridSelectBox )
1083  {
1084  wxCommandEvent cmd( wxEVT_CHOICE );
1085  cmd.SetEventObject( this );
1086  OnSelectGrid( cmd );
1087  }
1088  else
1089  GetCanvas()->Refresh();
1090 }
1091 
1092 
1094 {
1095  if( m_FastGrid2 >= (int)GetScreen()->GetGridCount() )
1096  return;
1097 
1098  int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId;
1100 
1101  if( m_gridSelectBox )
1102  {
1103  wxCommandEvent cmd( wxEVT_CHOICE );
1104  cmd.SetEventObject( this );
1105  OnSelectGrid( cmd );
1106  }
1107  else
1108  GetCanvas()->Refresh();
1109 }
1110 
1112 {
1114 
1115  if( m_gridSelectBox )
1116  {
1117  wxCommandEvent cmd( wxEVT_CHOICE );
1118  cmd.SetEventObject( this );
1119  OnSelectGrid( cmd );
1120  }
1121  else
1122  GetCanvas()->Refresh();
1123 }
1124 
1125 
1127 {
1129 
1130  if( m_gridSelectBox )
1131  {
1132  wxCommandEvent cmd( wxEVT_CHOICE );
1133  cmd.SetEventObject( this );
1134  OnSelectGrid( cmd );
1135  }
1136  else
1137  GetCanvas()->Refresh();
1138 }
1139 
1140 
1141 void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
1142 {
1143  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1144 
1145  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1146 
1147  if( m_toolManager )
1149  GetGalCanvas()->GetViewControls(), this );
1150 
1151  if( aEnable )
1152  {
1153  SetBoard( m_Pcb );
1154 
1155  if( m_toolManager )
1157 
1158  // Transfer latest current display options from legacy to GAL canvas:
1159  auto painter = static_cast<KIGFX::PCB_PAINTER*>( galCanvas->GetView()->GetPainter() );
1160  auto settings = painter->GetSettings();
1161  auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
1162  settings->LoadDisplayOptions( displ_opts, ShowPageLimits() );
1163 
1164  galCanvas->GetView()->RecacheAllItems();
1165  galCanvas->SetEventDispatcher( m_toolDispatcher );
1166  galCanvas->StartDrawing();
1167  }
1168  else
1169  {
1170  if( m_toolManager )
1172 
1173  // Redirect all events to the legacy canvas
1174  galCanvas->SetEventDispatcher( NULL );
1175  }
1176 }
1177 
1178 
1179 void PCB_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
1180 {
1181  wxMenuBar* menuBar = GetMenuBar();
1182  EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
1184 
1185  if( IsGalCanvasActive() && gal_canvas )
1186  canvasType = gal_canvas->GetBackend();
1187 
1188  struct { int menuId; int galType; } menuList[] =
1189  {
1193  };
1194 
1195  for( auto ii: menuList )
1196  {
1197  wxMenuItem* item = menuBar->FindItem( ii.menuId );
1198  if( ii.galType == canvasType )
1199  item->Check( true );
1200  }
1201 }
void SetColorsSettings(COLORS_DESIGN_SETTINGS *aColorsSettings)
Function SetColorsSettings.
Definition: class_board.h:578
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:128
virtual void ReCreateVToolbar()=0
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: class_board.h:798
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
Definition: class_board.h:564
to draw blind/buried vias
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
void SetCurItem(BOARD_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: pcb_screen.h:82
virtual void ShowChangedLanguage() override
Function ShowChangedLanguage redraws the menus and what not in current language.
const PAGE_INFO & GetPageSettings() const
Definition: class_board.h:554
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
void OnTogglePadDrawMode(wxCommandEvent &aEvent)
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar 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_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_MODEDIT_INSERT_MODULE_IN_BOARD
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: class_board.h:557
virtual void Show3D_Frame(wxCommandEvent &event)
Shows the 3D view frame.
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
void SetGridOrigin(const wxPoint &aPoint)
Function SetGridOrigin sets the origin point of the grid.
Definition: class_board.h:356
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:257
void OnToggleTextDrawMode(wxCommandEvent &aEvent)
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
void SetGridOrigin(const wxPoint &aPoint) override
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
virtual void AddModuleToBoard(MODULE *module)
Adds the given module to the board.
void SetSave()
Definition: base_screen.h:326
bool IsFlipped() const
function IsFlipped
Definition: class_module.h:258
multilayer pads, usually with holes
CINFO3D_VISU & GetSettings()
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:129
static const wxChar DisplayViaFillEntry[]
static const wxChar UserGridSizeYEntry[]
BOARD_ITEM * GetCurItem() const
Function GetCurItem returns the currently selected BOARD_ITEM, overriding BASE_SCREEN::GetCurItem().
Definition: pcb_screen.h:72
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: class_board.h:561
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
void OnUpdateCoordType(wxUpdateUIEvent &aEvent)
const EDA_RECT GetBoardEdgesBoundingBox() const
Function GetBoardEdgesBoundingBox Returns the board bounding box calculated using exclusively the boa...
Definition: class_board.h:810
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
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:340
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
Definition: draw_frame.h:179
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
static const wxChar DisplayModuleEdgeEntry[]
void OnToggleEdgeDrawMode(wxCommandEvent &aEvent)
Class BOARD to handle a board.
void SetFastGrid2()
Function SetFastGrid2()
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:935
void SetPageSettings(const PAGE_INFO &aPageSettings)
Definition: class_board.h:555
static const wxChar DisplayModuleTextEntry[]
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1401
Definition: id.h:241
const wxPoint & GetGridOrigin() const override
Return the absolute coordinates of the origin of the snap grid.
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
int GetWidth() const
Definition: eda_rect.h:117
void OnToggleGraphicDrawMode(wxCommandEvent &aEvent)
void OnUpdatePadDrawMode(wxUpdateUIEvent &aEvent)
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
show modules values (when texts are visibles)
virtual void ReCreateOptToolbar()
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:417
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void OnUpdateEdgeDrawMode(wxUpdateUIEvent &aEvent)
wxAuiManager m_auimgr
void SetDrawBgColor(COLOR4D aColor) override
double From_User_Unit(EDA_UNITS_T aUnits, double aValue, bool aUseMils)
Return in internal units the value "val" given in a real unit such as "in", "mm" or "deg".
Definition: base_units.cpp:278
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:205
static const wxChar FastGrid2Entry[]
void SetNextGrid() override
Virtual function SetNextGrid() changes the grid size settings to the next one available.
virtual void SetPrevGrid()
Change the grid size settings to the previous one available.
The base class for create windows for drawing purpose.
Definition: draw_frame.h:81
virtual const PCB_PLOT_PARAMS & GetPlotSettings() const
Function GetPlotSettings returns the PCB_PLOT_PARAMS for the BOARD owned by this frame.
COLOR4D m_drawBgColor
the background color of the draw canvas BLACK for Pcbnew, BLACK or WHITE for eeschema
Definition: draw_frame.h:116
PCB_LAYER_ID m_Active_Layer
Definition: pcb_screen.h:44
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
wxChoice * m_gridSelectBox
Definition: draw_frame.h:151
virtual void OnSwitchCanvas(wxCommandEvent &aEvent)
virtual void UseGalCanvas(bool aEnable)
Use to switch between standard and GAL-based canvas.
void SetAuxOrigin(const wxPoint &aPoint)
Function SetAuxOrigin sets the origin point used for plotting.
Definition: class_board.h:349
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file.
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
static const wxChar AUTO_ZOOM_KEY[]
Key in KifaceSettings to store the canvas type.
Functions relatives to tracks, vias and segments used to fill zones.
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
bool ShowPageLimits() const
Definition: draw_frame.h:392
Auxiliary rendering target (noncached)
Definition: definitions.h:49
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: pcbnew.cpp:326
virtual void UseGalCanvas(bool aEnable) override
void DisplayUnitsMsg()
Display current unit pane on the status bar.
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:217
Classes used in Pcbnew, CvPcb and GerbView.
GENERAL_COLLECTOR * m_Collector
show modules on front
void SetFastGrid1()
Function SetFastGrid1()
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use.
Definition: draw_frame.h:928
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:72
timestamp_t GetNewTimeStamp()
Definition: common.cpp:216
void OnUpdateTextDrawMode(wxUpdateUIEvent &aEvent)
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void CommonSettingsChanged() override
Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have ...
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:163
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void OnTogglePolarCoords(wxCommandEvent &aEvent)
GAL not used (the legacy wxDC engine is used)
PCB_GENERAL_SETTINGS & Settings()
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:146
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar FOOTPRINT_EDIT_FRAME::ProcessPreferences FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::Process_Special_Functions FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard EVT_UPDATE_UI_RANGE(ID_MODEDIT_PAD_TOOL, ID_MODEDIT_MEASUREMENT_TOOL, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar) EVT_UPDATE_UI(ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:291
void SetEnd(int x, int y)
Definition: eda_rect.h:134
Definition: common.h:161
wxChoice * m_zoomSelectBox
Definition: draw_frame.h:152
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
to draw usual through hole vias
const ZONE_SETTINGS & GetZoneSettings() const
const GRIDS & GetGrids() const
Function GetGrids().
Definition: base_screen.h:472
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
EVT_MENU_RANGE(ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END, PCB_BASE_FRAME::ProcessItemSelection) PCB_BASE_FRAME
void OnUpdateSwitchCanvas(wxUpdateUIEvent &aEvent)
Update UI called when switches currently used canvas (default / Cairo / OpenGL).
#define ENBL_MOUSEWHEEL_PAN_KEY
Definition: pgm_base.h:49
Base window classes and related definitions.
static const wxChar UserGridSizeXEntry[]
virtual void ReCreateAuxiliaryToolbar()
Helper dialog and control classes.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
static const wxChar DisplayPadNumberEntry[]
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
virtual void SetPlotSettings(const PCB_PLOT_PARAMS &aSettings)
EDA_RECT GetBoardBoundingBox(bool aBoardEdgesOnly=false) const
Function GetBoardBoundingBox calculates the bounding box containing all board items (or board edge se...
void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aDesignSettings)
Function SetDesignSettings.
Definition: class_board.h:549
virtual bool SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
void SetPresetGrid(int aIndex)
Change the grid size to one of the preset values.
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:395
EVT_TOOL(ID_FOOTPRINT_WIZARD_SELECT_WIZARD, FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard) EVT_TOOL(ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT
void SetPosition(const wxPoint &aPos) override
const wxPoint & GetAuxOrigin() const
Definition: class_board.h:350
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
Definition: class_board.h:558
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
virtual void GetMsgPanelInfo(EDA_UNITS_T aUnits, 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:297
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file.
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:547
wxPoint m_UserGridSize
virtual void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
int m_LastGridSizeId
Definition: draw_frame.h:110
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
Class PCB_PLOT_PARAMS handles plot parameters and options when plotting/printing a board.
virtual bool CreateAndShow3D_Frame(bool aForceRecreateIfNotOwner)
Shows the 3D view frame.
VTBL_ENTRY wxConfigBase * CommonSettings() const
Definition: pgm_base.h:189
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void SetAbortRequest(bool aAbortRequest)
KICAD_T Type() override
Definition: fp_lib_table.h:108
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
int GetHeight() const
Definition: eda_rect.h:118
const wxPoint & GetGridOrigin() const
Definition: class_board.h:357
virtual double BestZoom() override
Function BestZoom.
PCB_DISPLAY_OPTIONS m_DisplayOptions
virtual void SetNextGrid()
Change the grid size settings to the next one available.
static const wxChar FastGrid1Entry[]
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
virtual void SwitchLayer(wxDC *DC, PCB_LAYER_ID layer)
Class ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:48
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:126
void OnUpdateGraphicDrawMode(wxUpdateUIEvent &aEvent)
const TITLE_BLOCK & GetTitleBlock() const override
static const wxChar UserGridUnitsEntry[]
virtual void OnModify()
Function OnModify Virtual Must be called after a change in order to set the "modify" flag of the curr...
virtual void UpdateStatusBar() override
Update the status bar information.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:118
virtual void ReCreateHToolbar()=0
smd pads, front layer
TITLE_BLOCK & GetTitleBlock()
Definition: class_board.h:560
see class PGM_BASE
virtual void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
Declaration of the eda_3d_viewer class.
static const wxChar DisplayPadFillEntry[]
bool IsType(FRAME_T aType) const
Class to handle a graphic segment.
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
Class GRID_TYPE is for grid arrays.
Definition: base_screen.h:45
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:171
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
DLIST< MODULE > m_Modules
Definition: class_board.h:249
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetOrientation(double newangle)
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:245
virtual void SetDesignSettings(const BOARD_DESIGN_SETTINGS &aSettings)
size_t i
Definition: json11.cpp:597
int GetCopperLayerCount() const
Function GetCopperLayerCount.
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:457
PCB_BASE_FRAME * Parent() const
Definition: eda_3d_viewer.h:60
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
const PAGE_INFO & GetPageSettings() const override
#define IU_PER_MILS
Definition: plotter.cpp:134
const ZONE_SETTINGS & GetZoneSettings() const
Definition: class_board.h:563
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
wxPoint Centre() const
Definition: eda_rect.h:60
virtual void SetPageSettings(const PAGE_INFO &aPageSettings) override
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetZoneSettings(const ZONE_SETTINGS &aSettings)
void SetAuxOrigin(const wxPoint &aPoint) override
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:49
GAL_TYPE GetBackend() const
Function GetBackend Returns the type of backend currently used by GAL canvas.
Module description (excepted pads)
BOARD * GetBoard() const
virtual void unitsChangeRefresh()
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void UpdateMsgPanel() override
void SetModify()
Definition: base_screen.h:324
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:391
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
int m_CmdId
Definition: base_screen.h:48
Message panel definition file.
BOARD_ITEM * GetCurItem()
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:123
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
Rendering engine changes.
Definition: tool_base.h:84
EDA_3D_VIEWER * Get3DViewerFrame()
virtual void UpdateStatusBar()
Update the status bar information.
void ProcessItemSelection(wxCommandEvent &event)
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
const wxPoint GetPosition() const override
Definition: class_module.h:183
#define VIEWER3D_FRAMENAME
Definition: eda_3d_viewer.h:44
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS_T
Definition: common.h:160
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table,...
Definition: project.cpp:120
show modules references (when texts are visibles)
static const wxChar ZOOM_KEY[]
int GetToolId() const
Definition: draw_frame.h:526
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:219
bool Update3DView(const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
Color has changed.
Definition: view_item.h:57
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int m_Status_Pcb
Flags used in ratsnest calculation and update.
Definition: class_board.h:241
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void SetPrevGrid() override
Virtual function SetPrevGrid() changes the grid size settings to the previous one available.