KiCad PCB EDA Suite
gerbview_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, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <kiface_i.h>
22 #include <pgm_base.h>
23 #include <eda_base_frame.h>
24 #include <base_units.h>
25 #include <bitmaps.h>
27 #include <gerbview.h>
28 #include <gerbview_frame.h>
29 #include <gerbview_id.h>
30 #include <gerber_file_image.h>
31 #include <gerber_file_image_list.h>
33 #include <gerbview_settings.h>
38 #include <tool/tool_manager.h>
39 #include <tool/action_toolbar.h>
40 #include <tool/tool_dispatcher.h>
41 #include <tool/common_control.h>
42 #include <tool/common_tools.h>
43 #include <tool/editor_conditions.h>
44 #include <tool/zoom_tool.h>
45 #include <tools/gerbview_actions.h>
49 #include <tools/gerbview_control.h>
50 #include <trigo.h>
51 #include <view/view.h>
52 #include <base_screen.h>
53 #include <gerbview_painter.h>
54 #include <widgets/msgpanel.h>
55 #include <widgets/paged_dialog.h>
58 #include <panel_hotkeys_editor.h>
59 #include <wx/wupdlock.h>
60 
64 #include <zoom_defines.h>
65 
66 
67 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
68  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
70  m_TextInfo( nullptr ),
72  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
74  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
76  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
77  m_activeLayer( 0 )
78 {
79  m_maximizeByDefault = true;
80  m_gerberLayout = nullptr;
82  m_showBorderAndTitleBlock = false; // true for reference drawings.
83  m_SelLayerBox = nullptr;
84  m_DCodeSelector = nullptr;
85  m_SelComponentBox = nullptr;
86  m_SelNetnameBox = nullptr;
87  m_SelAperAttributesBox = nullptr;
88  m_cmpText = nullptr;
89  m_netText = nullptr;
90  m_apertText = nullptr;
91  m_dcodeText = nullptr;
92  m_displayMode = 0;
93  m_aboutTitle = _( "KiCad Gerber Viewer" );
94 
95  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
96  // some methods in code and avoid link errors
97 
98  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
99  m_drillFileHistory.SetMaxFiles( fileHistorySize );
100  m_zipFileHistory.SetMaxFiles( fileHistorySize );
101  m_jobFileHistory.SetMaxFiles( fileHistorySize );
102 
103  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
106 
107  SetCanvas( galCanvas );
108 
109  // GerbView requires draw priority for rendering negative objects
110  galCanvas->GetView()->UseDrawPriority( true );
111 
112  // Give an icon
113  wxIcon icon;
114  wxIconBundle icon_bundle;
115 
116  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
117  icon_bundle.AddIcon( icon );
118  icon.CopyFromBitmap( KiBitmap( icon_gerbview_32_xpm ) );
119  icon_bundle.AddIcon( icon );
120  icon.CopyFromBitmap( KiBitmap( icon_gerbview_16_xpm ) );
121  icon_bundle.AddIcon( icon );
122 
123  SetIcons( icon_bundle );
124 
125  // Be sure a page info is set. this default value will be overwritten later.
126  PAGE_INFO pageInfo( wxT( "GERBER" ) );
127  SetLayout( new GBR_LAYOUT() );
128  SetPageSettings( pageInfo );
129 
130  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
131 
132  SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU() ) );
133 
134  // Create the PCB_LAYER_WIDGET *after* SetLayout():
136 
137  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
138  // initialize parameters in m_LayersManager
139  LoadSettings( config() );
140 
141  setupTools();
143  ReCreateMenuBar();
147 
148  m_auimgr.SetManagedWindow( this );
149 
150  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
151  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
152  .Layer(4) );
153  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
154  .Layer( 6 ) );
155  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
156  .Layer( 3 ) );
157  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
158  .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
159  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
160 
161  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
162 
163  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
164  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
165  m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
166  wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
167 
168  ReFillLayerWidget(); // this is near end because contents establish size
169  m_auimgr.Update();
170 
171  SetActiveLayer( 0, true );
173 
175 
177 
178  setupUnits( config() );
179 
180  // Enable the axes to match legacy draw style
181  auto& galOptions = GetGalDisplayOptions();
182  galOptions.m_axesEnabled = true;
183  galOptions.NotifyChanged();
184 
186  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
187 
189 
190  // Ensure the window is on top
191  Raise();
192 }
193 
194 
196 {
197  // Shutdown all running tools
198  if( m_toolManager )
200 
201  GetCanvas()->GetView()->Clear();
202 
204  delete m_gerberLayout;
205 }
206 
207 
209 {
210  // No more vetos
211  m_isClosing = true;
212  GetCanvas()->StopDrawing();
213  GetCanvas()->GetView()->Clear();
214 
215  if( m_toolManager )
217 
218  // Be sure any OpenGL event cannot be fired after frame deletion:
219  GetCanvas()->SetEvtHandlerEnabled( false );
220 
221  Destroy();
222 }
223 
224 
225 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
226 {
227  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
228  // when trying to change the view if it is not fully initialized.
229  // It happens when starting GerbView with a gerber job file to load
230  if( !IsShown() )
231  Show();
232 
233  // The current project path is also a valid command parameter. Check if a single path
234  // rather than a file name was passed to GerbView and use it as the initial MRU path.
235  if( aFileSet.size() > 0 )
236  {
237  wxString path = aFileSet[0];
238 
239  // For some reason wxApp appears to leave the trailing double quote on quoted
240  // parameters which are required for paths with spaces. Maybe this should be
241  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
242  // We can't buy a break!
243  if( path.Last() == wxChar( '\"' ) )
244  path.RemoveLast();
245 
246  if( !wxFileExists( path ) && wxDirExists( path ) )
247  {
248  m_mruPath = path;
249  return true;
250  }
251 
252  const unsigned limit = std::min( unsigned( aFileSet.size() ),
253  unsigned( GERBER_DRAWLAYERS_COUNT ) );
254 
255  int layer = 0;
256 
257  for( unsigned i = 0; i < limit; ++i, ++layer )
258  {
259  SetActiveLayer( layer );
260 
261  // Try to guess the type of file by its ext
262  // if it is .drl (KiCad files), .nc or .xnc it is a drill file
263  wxFileName fn( aFileSet[i] );
264  wxString ext = fn.GetExt();
265 
266  if( ext == DrillFileExtension || // our Excellon format
267  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
268  LoadExcellonFiles( aFileSet[i] );
269  else if( ext == GerberJobFileExtension )
270  LoadGerberJobFile( aFileSet[i] );
271  else
272  LoadGerberFiles( aFileSet[i] );
273  }
274  }
275 
276  Zoom_Automatique( true ); // Zoom fit in frame
277 
278  return true;
279 }
280 
281 
283 {
285 
286  if( aCfg->m_Window.grid.sizes.empty() )
287  {
288  aCfg->m_Window.grid.sizes = { "100 mil",
289  "50 mil",
290  "25 mil",
291  "20 mil",
292  "10 mil",
293  "5 mil",
294  "2.5 mil",
295  "2 mil",
296  "1 mil",
297  "0.5 mil",
298  "0.2 mil",
299  "0.1 mil",
300  "5.0 mm",
301  "2.5 mm",
302  "1.0 mm",
303  "0.5 mm",
304  "0.25 mm",
305  "0.2 mm",
306  "0.1 mm",
307  "0.05 mm",
308  "0.025 mm",
309  "0.01 mm" };
310  }
311 
312  if( aCfg->m_Window.zoom_factors.empty() )
313  {
315  }
316 
317  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
318  wxCHECK( cfg, /*void*/ );
319 
321 
322  PAGE_INFO pageInfo( wxT( "GERBER" ) );
323  pageInfo.SetType( cfg->m_Appearance.page_type );
324  SetPageSettings( pageInfo );
325 
328 
332 }
333 
334 
336 {
338 
339  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
340  wxCHECK( cfg, /*void*/ );
341 
346 
350 
351  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
352  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
353 }
354 
355 
357 {
358  wxWindowUpdateLocker no_update( m_LayersManager );
359 
363 
364  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
365  wxSize bestz = m_LayersManager->GetBestSize();
366  bestz.x += 5; // gives a little margin
367 
368  lyrs.MinSize( bestz );
369  lyrs.BestSize( bestz );
370  lyrs.FloatingSize( bestz );
371 
372  if( lyrs.IsDocked() )
373  m_auimgr.Update();
374  else
375  m_LayersManager->SetSize( bestz );
376 
377  syncLayerWidget();
378 }
379 
380 
381 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
382 {
383  bool dcodes_changed = false;
384 
385  switch( aLayerID )
386  {
387  case LAYER_DCODES:
388  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
389  m_DisplayOptions.m_DisplayDCodes = aNewState;
390  break;
391 
393  {
395 
396  auto view = GetCanvas()->GetView();
397 
399  {
400  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
401 
402  // GetLayerPolarity() returns true for negative items
403  return ( item && item->GetLayerPolarity() );
404  } );
405  break;
406  }
407 
409  m_showBorderAndTitleBlock = aNewState;
410  // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
411  // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
413  break;
414 
415  case LAYER_GERBVIEW_GRID:
416  SetGridVisibility( aNewState );
417  break;
418 
419  default:
420  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
421  aLayerID ) );
422  }
423 
424  if( dcodes_changed )
425  {
426  auto view = GetCanvas()->GetView();
427 
428  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
429  {
430  int layer = GERBER_DRAW_LAYER( i );
431  int dcode_layer = GERBER_DCODE_LAYER( layer );
432  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
433  }
434  }
435 
437  m_LayersManager->SetRenderState( aLayerID, aNewState );
438 }
439 
440 
442 {
443  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
444  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
447 
449 }
450 
451 
453 {
454  int layer = aLayer;
455 
456  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
457  {
458  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
459 
460  if( gerber == NULL ) // this graphic layer is available: use it
461  return layer;
462 
463  ++layer; // try next graphic layer
464 
465  if( layer >= (int)ImagesMaxCount() )
466  layer = 0;
467  }
468 
469  return NO_AVAILABLE_LAYERS;
470 }
471 
472 
474 {
476 }
477 
478 
479 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
480 {
481  if( aRebuildLayerBox )
483 
484  m_SelLayerBox->SetSelection( GetActiveLayer() );
485 
486  int dcodeSelected = -1;
488 
489  if( gerber )
490  dcodeSelected = gerber->m_Selected_Tool;
491 
492  if( m_DCodeSelector )
493  {
495  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
496  m_DCodeSelector->Enable( gerber != NULL );
497  }
498 }
499 
500 
502 {
503  auto remapping = GetImagesList()->SortImagesByZOrder();
504 
506  syncLayerBox( true );
507 
508  std::unordered_map<int, int> view_remapping;
509 
510  for( auto it : remapping )
511  {
512  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
513  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
514  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
515  }
516 
517  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
518  GetCanvas()->Refresh();
519 }
520 
521 
523 {
524  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
525  aOptions.m_DisplayFlashedItemsFill );
526  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
527  aOptions.m_DisplayLinesFill );
528  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
529  aOptions.m_DisplayPolygonsFill );
530 
531  m_DisplayOptions = aOptions;
532 
534 
535  auto view = GetCanvas()->GetView();
536 
537  if( update_flashed )
538  {
540  {
541  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
542 
543  switch( item->m_Shape )
544  {
545  case GBR_SPOT_CIRCLE:
546  case GBR_SPOT_RECT:
547  case GBR_SPOT_OVAL:
548  case GBR_SPOT_POLY:
549  case GBR_SPOT_MACRO:
550  return true;
551 
552  default:
553  return false;
554  }
555  } );
556  }
557  else if( update_lines )
558  {
559  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
560  {
561  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
562 
563  switch( item->m_Shape )
564  {
565  case GBR_CIRCLE:
566  case GBR_ARC:
567  case GBR_SEGMENT:
568  return true;
569 
570  default:
571  return false;
572  }
573  } );
574  }
575  else if( update_polygons )
576  {
577  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
578  {
579  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
580 
581  return ( item->m_Shape == GBR_POLYGON );
582  } );
583  }
584 
585  view->UpdateAllItems( KIGFX::COLOR );
586  GetCanvas()->Refresh();
587 }
588 
589 
591 {
593 
594  // Display the gerber filename
595  if( gerber == NULL )
596  {
597  SetTitle( "GerbView" );
598 
599  SetStatusText( wxEmptyString, 0 );
600 
601  wxString info;
602  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
603  m_TextInfo->SetValue( info );
604 
605  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
606  m_auimgr.Update();
607 
608  ClearMsgPanel();
609  return;
610  }
611  else
612  {
613  wxString title;
614  wxFileName filename( gerber->m_FileName );
615 
616  title.Printf( wxT( "%s%s \u2014 " ) + _( "Gerber Viewer" ),
617  filename.GetFullName(),
618  gerber->m_IsX2_file ? wxS( " " ) + _( "(with X2 attributes)" )
619  : wxString( wxEmptyString ) );
620  SetTitle( title );
621 
622  gerber->DisplayImageInfo( this );
623 
624  // Display Image Name and Layer Name (from the current gerber data):
625  wxString status;
626  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
627  gerber->m_ImageName,
628  gerber->GetLayerParams().m_LayerName );
629  SetStatusText( status, 0 );
630 
631  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
632  wxString info;
633  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
634  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
635  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
636  gerber->m_FmtScale.x,
637  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
638  gerber->m_FmtScale.y,
639  gerber->m_NoTrailingZeros ? 'T' : 'L' );
640 
641  if( gerber->m_IsX2_file )
642  info << wxT(" ") << _( "X2 attr" );
643 
644  m_TextInfo->SetValue( info );
645 
646  if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
647  m_auimgr.Update();
648  }
649 }
650 
651 
652 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
653 {
654  switch( aLayerID )
655  {
658  case LAYER_GERBVIEW_GRID: return IsGridVisible();
660  case LAYER_GERBVIEW_BACKGROUND: return true;
661 
662  default:
663  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d", aLayerID ) );
664  }
665 
666  return true;
667 }
668 
669 
671 {
672  LSET visible = LSET::AllLayersMask();
673 
674  if( GetCanvas() )
675  {
676  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
677  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
678  }
679 
680  return visible;
681 }
682 
683 
685 {
686  if( GetCanvas() )
687  {
688  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
689  {
690  bool v = aLayerMask[i];
691  int layer = GERBER_DRAW_LAYER( i );
692  GetCanvas()->GetView()->SetLayerVisible( layer, v );
695  }
696  }
697 }
698 
699 
700 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
701 {
702  return m_LayersManager->IsLayerVisible( aLayer );
703 }
704 
705 
707 {
708  COLOR4D color = COLOR4D::UNSPECIFIED;
709  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
710 
711  switch( aLayerID )
712  {
714  case LAYER_DCODES:
717  color = settings->GetColor( aLayerID );
718  break;
719 
720  case LAYER_GERBVIEW_GRID:
721  color = GetGridColor();
722  break;
723 
724  default:
725  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
726  aLayerID ) );
727  }
728 
729  return color;
730 }
731 
732 
734 {
737 }
738 
739 
741 {
742  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
743 
744  switch( aLayerID )
745  {
747  case LAYER_DCODES:
748  settings->SetColor( aLayerID, aColor );
749  break;
750 
752  settings->SetColor( LAYER_GERBVIEW_DRAWINGSHEET, aColor );
753  // LAYER_DRAWINGSHEET color is also used to draw the drawing-sheet
754  // FIX ME: why LAYER_DRAWINGSHEET must be set, although LAYER_GERBVIEW_DRAWINGSHEET
755  // is used to initialize the drawing-sheet color layer.
756  settings->SetColor( LAYER_DRAWINGSHEET, aColor );
757  break;
758 
759  case LAYER_GERBVIEW_GRID:
760  SetGridColor( aColor );
761  settings->SetColor( aLayerID, aColor );
762  break;
763 
765  SetDrawBgColor( aColor );
766  settings->SetColor( aLayerID, aColor );
767  break;
768 
769  default:
770  wxFAIL_MSG( wxString::Format( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
771  aLayerID ) );
772  }
773 }
774 
775 
777 {
780  else
781  return GetDrawBgColor();
782 }
783 
784 
786 {
787  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
788 }
789 
790 
791 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
792 {
793  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
795 }
796 
797 
798 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
799 {
800  m_activeLayer = aLayer;
801 
802  if( doLayerWidgetUpdate )
803  m_LayersManager->SelectLayer( aLayer );
804 
806 
807  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
808  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
809 
811  GetCanvas()->Refresh();
812 }
813 
814 
815 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
816 {
817  m_paper = aPageSettings;
818 
819  if( GetScreen() )
820  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
821 
822  GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
823 
824  // Prepare drawing-sheet template
826  &Prj(), &GetTitleBlock() );
827 
828  if( GetScreen() )
829  {
830  drawingSheet->SetPageNumber( "1" );
831  drawingSheet->SetSheetCount( 1 );
832  }
833 
835 
836  // Draw panel takes ownership of the drawing-sheet
837  drawPanel->SetDrawingSheet( drawingSheet );
838 }
839 
840 
842 {
843  return m_paper;
844 }
845 
846 
847 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
848 {
849  // this function is only needed because EDA_DRAW_FRAME is not compiled
850  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
851  // into an application specific source file.
852  return GetPageSettings().GetSizeIU();
853 }
854 
855 
857 {
858  wxASSERT( m_gerberLayout );
859  return m_gerberLayout->GetTitleBlock();
860 }
861 
862 
863 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
864 {
865  wxASSERT( m_gerberLayout );
866  m_gerberLayout->SetTitleBlock( aTitleBlock );
867 }
868 
869 
871 {
872  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_GRID );
873 }
874 
875 
877 {
878  Pgm().GetSettingsManager().GetColorSettings()->SetColor( LAYER_GRID, aColor );
879  GetCanvas()->GetGAL()->SetGridColor( aColor );
880  m_gridColor = aColor;
881 }
882 
883 
884 /*
885  * Display the grid status.
886  */
888 {
889  wxString line;
890 
891  line.Printf( "grid X %s Y %s",
892  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ),
893  MessageTextFromValue( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().y ) );
894 
895  SetStatusText( line, 4 );
896 }
897 
898 
900 {
902 
903  if( !GetScreen() )
904  return;
905 
906  wxString line;
908 
909  if( GetShowPolarCoords() ) // display relative polar coordinates
910  {
911  double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
912  double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
913  double theta = RAD2DEG( atan2( -dy, dx ) );
914  double ro = hypot( dx, dy );
915 
916  line.Printf( wxT( "r %s theta %s" ),
917  MessageTextFromValue( GetUserUnits(), ro, false ),
918  MessageTextFromValue( EDA_UNITS::DEGREES, theta, false ) );
919 
920  SetStatusText( line, 3 );
921  }
922 
923  // Display absolute coordinates:
924  line.Printf( wxT( "X %s Y %s" ),
925  MessageTextFromValue( GetUserUnits(), cursorPos.x, false ),
926  MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) );
927  SetStatusText( line, 2 );
928 
929  if( !GetShowPolarCoords() )
930  {
931  // Display relative cartesian coordinates:
932  double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
933  double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
934 
935  line.Printf( wxT( "dx %s dy %s dist %s" ),
936  MessageTextFromValue( GetUserUnits(), dXpos, false ),
937  MessageTextFromValue( GetUserUnits(), dYpos, false ),
938  MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) );
939  SetStatusText( line, 3 );
940  }
941 
942  DisplayGridMsg();
943 }
944 
945 
947 {
948  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
949 }
950 
951 
953 {
955 }
956 
957 
959 {
960  // Called on units change (see EDA_DRAW_FRAME)
964 }
965 
966 
968 {
970 
971  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
972 
973  if( m_toolManager )
974  {
976  GetCanvas()->GetViewControls(), config(), this );
978  }
979 
981 
983 
984  galCanvas->GetView()->RecacheAllItems();
985  galCanvas->SetEventDispatcher( m_toolDispatcher );
986  galCanvas->StartDrawing();
987 
990 
992  ReCreateMenuBar();
993 }
994 
995 
997  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
998 {
999  wxTreebook* book = aParent->GetTreebook();
1000 
1001  book->AddPage( new wxPanel( book ), _( "GerbView" ) );
1002  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1003  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1004 
1005  aHotkeysPanel->AddHotKeys( GetToolManager() );
1006 }
1007 
1008 
1009 
1011 {
1012  // Create the manager and dispatcher & route draw panel events to the dispatcher
1015  GetCanvas()->GetViewControls(), config(), this );
1016  m_actions = new GERBVIEW_ACTIONS();
1018 
1019  // Register tools
1027 
1028  // Run the selection tool, it is supposed to be always active
1029  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1030 }
1031 
1032 
1034 {
1036 
1038  EDITOR_CONDITIONS cond( this );
1039 
1040  wxASSERT( mgr );
1041 
1042 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1043 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
1044 
1046  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
1050  CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
1051 
1055 
1057  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1059  CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1061  CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1062 
1063  auto flashedDisplayOutlinesCond =
1064  [this] ( const SELECTION& )
1065  {
1067  };
1068 
1069  auto linesFillCond =
1070  [this] ( const SELECTION& )
1071  {
1073  };
1074 
1075  auto polygonsFilledCond =
1076  [this] ( const SELECTION& )
1077  {
1079  };
1080 
1081  auto negativeObjectsCond =
1082  [this] ( const SELECTION& )
1083  {
1085  };
1086 
1087  auto dcodeCond =
1088  [this] ( const SELECTION& )
1089  {
1090  return IsElementVisible( LAYER_DCODES );
1091  };
1092 
1093  auto diffModeCond =
1094  [this] ( const SELECTION& )
1095  {
1097  };
1098 
1099  auto highContrastModeCond =
1100  [this] ( const SELECTION& )
1101  {
1103  };
1104 
1105  auto flipGerberCond =
1106  [this] ( const SELECTION& )
1107  {
1109  };
1110 
1111  auto layersManagerShownCondition =
1112  [this] ( const SELECTION& aSel )
1113  {
1115  };
1116 
1118  CHECK( flashedDisplayOutlinesCond ) );
1120  mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1121  mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1122  mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
1123  mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1124  mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1125  mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1127  CHECK( layersManagerShownCondition ) );
1128 
1129 #undef CHECK
1130 #undef ENABLE
1131 }
1132 
1133 
1134 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1135 {
1136  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1137 
1138  RecreateToolbars();
1139  Layout();
1140  SendSizeEvent();
1141 }
1142 
1143 
1145 {
1146  return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1147 }
1148 
1149 
1151 {
1153 
1154  // show/hide auxiliary Vertical layers and visibility manager toolbar
1155  m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1156  m_auimgr.Update();
1157 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition: gbr_layout.h:45
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:125
wxString m_LayerName
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static TOOL_ACTION layerChanged
void SetVisibleElementColor(int aLayerID, COLOR4D aColor)
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1426
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for worksheet item colors.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
This is usually the background color, but can be another color in order to see negative objects.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
const BITMAP_OPAQUE icon_gerbview_32_xpm[1]
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
static TOOL_ACTION zoomTool
Definition: actions.h:102
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
int color
Definition: DXF_plotter.cpp:60
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1372
double RAD2DEG(double rad)
Definition: trigo.h:232
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:67
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
Hold the image data and parameters for one gerber file and layer parameters.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:119
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
static TOOL_ACTION millimetersUnits
Definition: actions.h:149
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
void AddHotKeys(TOOL_MANAGER *aToolMgr)
static TOOL_ACTION toggleLayerManager
const wxString & GetType() const
Definition: page_info.h:94
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
Color has changed.
Definition: view_item.h:53
The base class for create windows for drawing purpose.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:40
wxSize m_FmtScale
< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
Class that groups generic conditions for editor states.
std::vector< double > zoom_factors
Definition: app_settings.h:86
void DeactivateTool()
Deactivate the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
static TOOL_ACTION dcodeDisplay
static TOOL_ACTION negativeObjectDisplay
wxChoice * m_SelNetnameBox
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
Gather all the actions that are shared by tools.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
static TOOL_ACTION toggleDiffMode
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
bool m_IsX2_file
< True if a X2 gerber attribute was found in file.
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:52
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
#define GERBER_DCODE_LAYER(x)
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:47
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
Master controller class:
Definition: tool_manager.h:52
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
static TOOL_ACTION measureTool
Definition: actions.h:157
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
static TOOL_ACTION flipGerberView
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Display information about image parameters in the status bar.
bool m_DiffMode
Display layers in diff mode.
Item needs to be redrawn.
Definition: view_item.h:57
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Update the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
std::vector< wxString > sizes
Definition: app_settings.h:52
unsigned ImagesMaxCount() const
The max number of file images.
COLOR4D GetGridColor() override
std::vector< wxString > m_DrillFileHistory
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
PAGE_INFO m_paper
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
void ReCreateAuxiliaryToolbar() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define NULL
#define GERBER_DRAWLAYERS_COUNT
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:574
bool IsGridVisible() const
#define NO_AVAILABLE_LAYERS
void Clear()
Remove all items from the view.
Definition: view.cpp:1083
static TOOL_ACTION toggleGrid
Definition: actions.h:143
GRID_SETTINGS grid
Definition: app_settings.h:89
bool LoadGerberFiles(const wxString &aFileName)
Load a photoplot (Gerber) file or many files.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow Gerbview to install its preferences panels into the preferences dialog.
Represent a set of closed polygons.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:53
bool m_showBorderAndTitleBlock
static TOOL_ACTION inchesUnits
Definition: actions.h:147
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
static TOOL_ACTION linesDisplayOutlines
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
static TOOL_ACTION togglePolarCoords
Definition: actions.h:152
ACTIONS * m_actions
Definition: tools_holder.h:158
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:68
Definition of file extensions used in Kicad.
Base window classes and related definitions.
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
GBR_LAYOUT * m_gerberLayout
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:787
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:387
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:681
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void doCloseWindow() override
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
Handle actions that are shared between different applications.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=NULL)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:73
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void StartDrawing()
Begin drawing if it was stopped previously.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
static TOOL_ACTION milsUnits
Definition: actions.h:148
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:159
Handles action that are shared between different applications.
Definition: common_tools.h:37
static TOOL_ACTION flashedDisplayOutlines
GBR_LAYOUT * GetGerberLayout() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id.
COLOR4D GetColor(int aLayer) const
WINDOW_SETTINGS m_Window
Definition: app_settings.h:181
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:85
wxStaticText * m_cmpText
int GetActiveLayer() const
Return the active layer.
Selection tool for GerbView, based on the one in Pcbnew.
wxChoice * m_SelAperAttributesBox
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:157
see class PGM_BASE
void LoadColors(const COLOR_SETTINGS *aSettings) override
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
std::vector< wxString > m_ZipFileHistory
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
ACTION_MANAGER * GetActionManager()
Definition: tool_manager.h:197
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update the drawing-sheet (borders and title block) used by the draw panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
void setupUnits(APP_SETTINGS_BASE *aCfg)
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
Definition: id.h:69
static TOOL_ACTION polygonsDisplayOutlines
COLOR4D GetLayerColor(int aLayer) const
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
#define IU_PER_MILS
Definition: plotter.cpp:137
void SetLayerColor(int aLayer, COLOR4D aColor)
wxStaticText * m_dcodeText
bool m_FlipGerberView
Display as a mirror image.
virtual void SetGridColor(COLOR4D aColor) override
void syncLayerWidget()
Update the currently "selected" layer within the GERBER_LAYER_WIDGET.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
#define CHECK(x)
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
bool LoadExcellonFiles(const wxString &aFileName)
Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
wxStaticText * m_netText
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:105
drawingsheet frame and titleblock
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
#define GERBER_DRAW_LAYER(x)
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void InitTools()
Initializes all registered tools.
void ReFillRender()
Function ReFillRender Rebuild Render for instance after the config is read.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
wxStaticText * m_apertText
int getNextAvailableLayer(int aLayer=0) const
Find the next empty layer starting at aLayer and returns it to the caller.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
BASE_SCREEN class implementation.
Message panel definition file.
void SetRenderState(int aId, bool isSet)
Function SetRenderState sets the state of the checkbox associated with aId within the Render tab grou...
const BITMAP_OPAQUE icon_gerbview_16_xpm[1]
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static TOOL_ACTION highContrastMode
Definition: actions.h:106
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
Rendering engine changes.
Definition: tool_base.h:82
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
wxString m_aboutTitle
static TOOL_ACTION selectionTool
Definition: actions.h:156
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:94
GERBER_LAYER & GetLayerParams()
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
const std::string DrillFileExtension
Handle actions that are shared between different frames in Pcbnew.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:69
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:98
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)