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-2019 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 <fctsys.h>
22 #include <kiface_i.h>
23 #include <pgm_base.h>
24 #include <eda_base_frame.h>
25 #include <trigo.h>
26 #include <base_units.h>
27 #include <gbr_layer_box_selector.h>
28 #include <msgpanel.h>
29 #include <bitmaps.h>
31 #include <gerbview.h>
32 #include <gerbview_frame.h>
33 #include <gerbview_id.h>
34 #include <gerber_file_image.h>
35 #include <gerber_file_image_list.h>
36 #include <DCodeSelectionbox.h>
37 #include <gerbview_layer_widget.h>
39 #include <gerbview_settings.h>
43 #include <tool/tool_manager.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/tool_dispatcher.h>
46 #include <tool/common_control.h>
47 #include <tool/common_tools.h>
48 #include <tool/zoom_tool.h>
49 #include <tools/gerbview_actions.h>
51 #include <tools/gerbview_control.h>
52 #include <view/view.h>
53 #include <gerbview_painter.h>
55 #include <widgets/paged_dialog.h>
58 #include <panel_hotkeys_editor.h>
59 
60 
61 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
62  : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
65  ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
67  ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
69  ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) )
70 {
72  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
73  // when the screen shows a 1:1 image
74  // obviously depends on the monitor,
75  // but this is an acceptable value
76 
78 
79  m_showBorderAndTitleBlock = false; // true for reference drawings.
82  m_SelComponentBox = nullptr;
83  m_SelNetnameBox = nullptr;
84  m_SelAperAttributesBox = nullptr;
85  m_displayMode = 0;
86  m_AboutTitle = "GerbView";
87 
88  SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
89  // some methods in code and avoid link errors
90 
91  int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
92  m_drillFileHistory.SetMaxFiles( fileHistorySize );
93  m_zipFileHistory.SetMaxFiles( fileHistorySize );
94  m_jobFileHistory.SetMaxFiles( fileHistorySize );
95 
96  auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
99 
100  SetCanvas( galCanvas );
101 
102  // GerbView requires draw priority for rendering negative objects
103  galCanvas->GetView()->UseDrawPriority( true );
104 
105  // Give an icon
106  wxIcon icon;
107  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
108  SetIcon( icon );
109 
110  // Be sure a page info is set. this default value will be overwritten later.
111  PAGE_INFO pageInfo( wxT( "GERBER" ) );
112  SetLayout( new GBR_LAYOUT() );
113  SetPageSettings( pageInfo );
114 
115  SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
116 
117  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
118 
119  // Create the PCB_LAYER_WIDGET *after* SetLayout():
121 
122  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
123  // initialize parameters in m_LayersManager
124  LoadSettings( config() );
125 
126  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
127 
128  if( m_LastGridSizeId < 0 )
129  m_LastGridSizeId = 0;
130 
133 
134  setupTools();
135  ReCreateMenuBar();
139 
140  m_auimgr.SetManagedWindow( this );
141 
142  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
143  m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
144  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
145 
146  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
147  m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
148  .Caption( _( "Layers Manager" ) ).PaneBorder( false )
149  .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
150 
151  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
152 
153  ReFillLayerWidget(); // this is near end because contents establish size
154  m_auimgr.Update();
155 
156  SetActiveLayer( 0, true );
158 
160 
161  // Nudge user to switch to OpenGL if they are on legacy or Cairo
162  if( m_firstRunDialogSetting < 1 )
163  {
164  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
165  {
166  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
167  "and faster experience. This option is turned off by "
168  "default since it is not compatible with all computers.\n\n"
169  "Would you like to try enabling graphics acceleration?\n\n"
170  "If you'd like to choose later, select Accelerated Graphics "
171  "in the Preferences menu." );
172 
173  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
174 
175  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
176 
177  if( dlg.ShowModal() == wxID_YES )
178  {
179  // Save Cairo as default in case OpenGL crashes
181 
182  // Switch to OpenGL, which will save the new setting if successful
184 
185  // Switch back to Cairo if OpenGL is not supported
186  if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
188  }
189  else
190  {
191  // If they were on legacy, switch to Cairo
193  }
194  }
195 
197  SaveSettings( config() );
198  }
199 
200  SwitchCanvas( canvasType );
201 
202  // Enable the axes to match legacy draw style
203  auto& galOptions = GetGalDisplayOptions();
204  galOptions.m_axesEnabled = true;
205  galOptions.NotifyChanged();
206 
208  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
209 
212 
213  if( GetCanvas() )
215 
216  // Update the checked state of tools
217  SyncToolbars();
218 }
219 
220 
222 {
223  // Shutdown all running tools
224  if( m_toolManager )
226 
227  GetCanvas()->GetView()->Clear();
228 
230  delete m_gerberLayout;
231 }
232 
233 
234 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
235 {
236  GetCanvas()->StopDrawing();
237  GetCanvas()->GetView()->Clear();
238 
239  if( m_toolManager )
241 
242  // Be sure any OpenGL event cannot be fired after frame deletion:
243  GetCanvas()->SetEvtHandlerEnabled( false );
244 
245  Destroy();
246 }
247 
248 
249 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
250 {
251  // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
252  // when trying to change the view if it is not fully initialized.
253  // It happens when starting Gerbview with a gerber job file to load
254  if( !IsShown() )
255  Show();
256 
257  // The current project path is also a valid command parameter. Check if a single path
258  // rather than a file name was passed to GerbView and use it as the initial MRU path.
259  if( aFileSet.size() > 0 )
260  {
261  wxString path = aFileSet[0];
262 
263  // For some reason wxApp appears to leave the trailing double quote on quoted
264  // parameters which are required for paths with spaces. Maybe this should be
265  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
266  // We can't buy a break!
267  if( path.Last() == wxChar( '\"' ) )
268  path.RemoveLast();
269 
270  if( !wxFileExists( path ) && wxDirExists( path ) )
271  {
272  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
273  m_mruPath = path;
274  return true;
275  }
276 
277  const unsigned limit = std::min( unsigned( aFileSet.size() ),
278  unsigned( GERBER_DRAWLAYERS_COUNT ) );
279 
280  int layer = 0;
281 
282  for( unsigned i = 0; i < limit; ++i, ++layer )
283  {
284  SetActiveLayer( layer );
285 
286  // Try to guess the type of file by its ext
287  // if it is .drl (Kicad files), .nc or .xnc it is a drill file
288  wxFileName fn( aFileSet[i] );
289  wxString ext = fn.GetExt();
290 
291  if( ext == DrillFileExtension || // our Excellon format
292  ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
293  LoadExcellonFiles( aFileSet[i] );
294  else if( ext == GerberJobFileExtension )
295  LoadGerberJobFile( aFileSet[i] );
296  else
297  LoadGerberFiles( aFileSet[i] );
298  }
299  }
300 
301  Zoom_Automatique( true ); // Zoom fit in frame
302 
303  return true;
304 }
305 
306 
308 {
310 
311  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
312 
314 
315  PAGE_INFO pageInfo( wxT( "GERBER" ) );
316  pageInfo.SetType( cfg->m_Appearance.page_type );
317  SetPageSettings( pageInfo );
318 
321 
325 }
326 
327 
329 {
331 
332  GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
333 
338 
342 
343  COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
344  Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
345 }
346 
347 
349 {
353  // Update the checked state of tools
354  SyncToolbars();
355 
356  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
357  wxSize bestz = m_LayersManager->GetBestSize();
358  bestz.x += 5; // gives a little margin
359 
360  lyrs.MinSize( bestz );
361  lyrs.BestSize( bestz );
362  lyrs.FloatingSize( bestz );
363 
364  if( lyrs.IsDocked() )
365  m_auimgr.Update();
366  else
367  m_LayersManager->SetSize( bestz );
368 
369  syncLayerWidget();
370 }
371 
372 
373 void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
374 {
375  bool dcodes_changed = false;
376 
377  switch( aLayerID )
378  {
379  case LAYER_DCODES:
380  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
381  m_DisplayOptions.m_DisplayDCodes = aNewState;
382  break;
383 
385  {
387 
388  auto view = GetCanvas()->GetView();
389 
391  {
392  auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
393 
394  // GetLayerPolarity() returns true for negative items
395  return ( item && item->GetLayerPolarity() );
396  } );
397  break;
398  }
399 
401  m_showBorderAndTitleBlock = aNewState;
402  // NOTE: LAYER_WORKSHEET always used for visibility, but the layer manager passes
403  // LAYER_GERBVIEW_WORKSHEET because of independent color control
404  GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
405  break;
406 
407  case LAYER_GERBVIEW_GRID:
408  SetGridVisibility( aNewState );
409  break;
410 
411  default:
412  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
413  }
414 
415  if( dcodes_changed )
416  {
417  auto view = GetCanvas()->GetView();
418 
419  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
420  {
421  int layer = GERBER_DRAW_LAYER( i );
422  int dcode_layer = GERBER_DCODE_LAYER( layer );
423  view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
424  }
425  }
426 
428  m_LayersManager->SetRenderState( aLayerID, aNewState );
429 }
430 
431 
433 {
434  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
435  KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
438 
440 }
441 
442 
444 {
445  int layer = aLayer;
446 
447  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
448  {
449  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
450 
451  if( gerber == NULL ) // this graphic layer is available: use it
452  return layer;
453 
454  ++layer; // try next graphic layer
455 
456  if( layer >= (int)ImagesMaxCount() )
457  layer = 0;
458  }
459 
460  return NO_AVAILABLE_LAYERS;
461 }
462 
463 
465 {
467 }
468 
469 
470 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
471 {
472  if( aRebuildLayerBox )
474 
475  m_SelLayerBox->SetSelection( GetActiveLayer() );
476 
477  int dcodeSelected = -1;
479 
480  if( gerber )
481  dcodeSelected = gerber->m_Selected_Tool;
482 
483  if( m_DCodeSelector )
484  {
486  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
487  m_DCodeSelector->Enable( gerber != NULL );
488  }
489 }
490 
491 
493 {
494  int ii, jj;
495  wxString Line;
496  wxArrayString list;
497  double scale = GetUserUnits() == EDA_UNITS::INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
498  int curr_layer = GetActiveLayer();
499 
500  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
501  {
502  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
503 
504  if( gerber == NULL )
505  continue;
506 
507  if( gerber->GetDcodesCount() == 0 )
508  continue;
509 
510  if( layer == curr_layer )
511  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
512  else
513  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
514 
515  list.Add( Line );
516 
517  const char* units = GetUserUnits() == EDA_UNITS::INCHES ? "\"" : "mm";
518 
519  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
520  {
521  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
522 
523  if( pt_D_code == NULL )
524  continue;
525 
526  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
527  continue;
528 
529  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
530  jj,
531  pt_D_code->m_Num_Dcode,
532  pt_D_code->m_Size.y / scale, units,
533  pt_D_code->m_Size.x / scale, units,
534  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
535  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
536  );
537 
538  if( !pt_D_code->m_Defined )
539  Line += wxT( " (not defined)" );
540 
541  if( pt_D_code->m_InUse )
542  Line += wxT( " (in use)" );
543 
544  list.Add( Line );
545  jj++;
546  }
547  }
548 
549  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
550  wxCHOICEDLG_STYLE & ~wxCANCEL );
551 
552  dlg.ShowModal();
553 }
554 
555 
557 {
558  auto remapping = GetImagesList()->SortImagesByZOrder();
559 
561  syncLayerBox( true );
562 
563  std::unordered_map<int, int> view_remapping;
564 
565  for( auto it : remapping )
566  {
567  view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
568  view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
569  GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
570  }
571 
572  GetCanvas()->GetView()->ReorderLayerData( view_remapping );
573  GetCanvas()->Refresh();
574 }
575 
576 
578 {
579  bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
580  aOptions.m_DisplayFlashedItemsFill );
581  bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
582  aOptions.m_DisplayLinesFill );
583  bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
584  aOptions.m_DisplayPolygonsFill );
585 
586  m_DisplayOptions = aOptions;
587 
589 
590  auto view = GetCanvas()->GetView();
591 
592  if( update_flashed )
593  {
595  {
596  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
597 
598  switch( item->m_Shape )
599  {
600  case GBR_SPOT_CIRCLE:
601  case GBR_SPOT_RECT:
602  case GBR_SPOT_OVAL:
603  case GBR_SPOT_POLY:
604  case GBR_SPOT_MACRO:
605  return true;
606 
607  default:
608  return false;
609  }
610  } );
611  }
612  else if( update_lines )
613  {
614  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
615  {
616  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
617 
618  switch( item->m_Shape )
619  {
620  case GBR_CIRCLE:
621  case GBR_ARC:
622  case GBR_SEGMENT:
623  return true;
624 
625  default:
626  return false;
627  }
628  } );
629  }
630  else if( update_polygons )
631  {
632  view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
633  {
634  auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
635 
636  return ( item->m_Shape == GBR_POLYGON );
637  } );
638  }
639 
640  view->UpdateAllItems( KIGFX::COLOR );
641  GetCanvas()->Refresh();
642 }
643 
644 
646 {
648 
649  // Display the gerber filename
650  if( gerber == NULL )
651  {
652  SetTitle( "GerbView" );
653 
654  SetStatusText( wxEmptyString, 0 );
655 
656  wxString info;
657  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
658  m_TextInfo->SetValue( info );
659 
660  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
661  m_auimgr.Update();
662 
663  ClearMsgPanel();
664  return;
665  }
666  else
667  {
668  wxString title;
669  title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
670  gerber->m_FileName,
671  gerber->m_IsX2_file ? _( " (with X2 attributes)" )
672  : wxString( wxEmptyString ) );
673  SetTitle( title );
674 
675  gerber->DisplayImageInfo( this );
676 
677  // Display Image Name and Layer Name (from the current gerber data):
678  wxString status;
679  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
680  gerber->m_ImageName,
681  gerber->GetLayerParams().m_LayerName );
682  SetStatusText( status, 0 );
683 
684  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
685  wxString info;
686  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
687  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
688  gerber->m_FmtLen.x - gerber->m_FmtScale.x,
689  gerber->m_FmtScale.x,
690  gerber->m_FmtLen.y - gerber->m_FmtScale.y,
691  gerber->m_FmtScale.y,
692  gerber->m_NoTrailingZeros ? 'T' : 'L' );
693 
694  if( gerber->m_IsX2_file )
695  info << wxT(" ") << _( "X2 attr" );
696 
697  m_TextInfo->SetValue( info );
698 
699  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
700  m_auimgr.Update();
701  }
702 }
703 
704 
705 bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
706 {
707  switch( aLayerID )
708  {
711  case LAYER_GERBVIEW_GRID: return IsGridVisible();
713  case LAYER_GERBVIEW_BACKGROUND: return true;
714 
715  default:
716  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
717  }
718 
719  return true;
720 }
721 
722 
724 {
725  LSET visible = LSET::AllLayersMask();
726 
727  if( GetCanvas() )
728  {
729  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
730  visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
731  }
732 
733  return visible;
734 }
735 
736 
738 {
739  if( GetCanvas() )
740  {
741  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
742  {
743  bool v = aLayerMask[i];
744  int layer = GERBER_DRAW_LAYER( i );
745  GetCanvas()->GetView()->SetLayerVisible( layer, v );
748  }
749  }
750 }
751 
752 
753 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
754 {
755  return m_LayersManager->IsLayerVisible( aLayer );
756 }
757 
758 
760 {
761  COLOR4D color = COLOR4D::UNSPECIFIED;
762 
763  switch( aLayerID )
764  {
766  case LAYER_DCODES:
769  color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayerID );
770  break;
771 
772  case LAYER_GERBVIEW_GRID:
773  color = GetGridColor();
774  break;
775 
776  default:
777  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
778  }
779 
780  return color;
781 }
782 
783 
785 {
788 }
789 
790 
792 {
793  COLOR_SETTINGS* settings = Pgm().GetSettingsManager().GetColorSettings();
794 
795  switch( aLayerID )
796  {
798  case LAYER_DCODES:
800  settings->SetColor( aLayerID, aColor );
801  break;
802 
803  case LAYER_GERBVIEW_GRID:
804  SetGridColor( aColor );
805  settings->SetColor( aLayerID, aColor );
806  break;
807 
809  SetDrawBgColor( aColor );
810  settings->SetColor( aLayerID, aColor );
811  break;
812 
813  default:
814  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
815  }
816 }
817 
818 
820 {
823  else
824  return GetDrawBgColor();
825 }
826 
827 
829 {
830  return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
831 }
832 
833 
834 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
835 {
836  Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
838 }
839 
840 
842 {
843  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
844 }
845 
846 
847 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
848 {
849  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
850 
851  if( doLayerWidgetUpdate )
853 
855 
856  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
857  GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
858 
860  GetCanvas()->Refresh();
861 }
862 
863 
864 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
865 {
866  m_paper = aPageSettings;
867  GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
868 
869  if( screen )
870  screen->InitDataPoints( aPageSettings.GetSizeIU() );
871 
872  auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
873 
874  // Prepare worksheet template
875  auto worksheet =
877 
878  if( screen != NULL )
879  {
880  worksheet->SetSheetNumber( 1 );
881  worksheet->SetSheetCount( 1 );
882  }
883 
884  worksheet->SetColorLayer( LAYER_GERBVIEW_WORKSHEET );
885 
886  // Draw panel takes ownership of the worksheet
887  drawPanel->SetWorksheet( worksheet );
888 }
889 
890 
892 {
893  return m_paper;
894 }
895 
896 
897 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
898 {
899  // this function is only needed because EDA_DRAW_FRAME is not compiled
900  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
901  // into an application specific source file.
902  return GetPageSettings().GetSizeIU();
903 }
904 
905 
907 {
908  wxASSERT( m_gerberLayout );
909  return m_gerberLayout->GetTitleBlock();
910 }
911 
912 
913 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
914 {
915  wxASSERT( m_gerberLayout );
916  m_gerberLayout->SetTitleBlock( aTitleBlock );
917 }
918 
919 
921 {
922  wxASSERT( m_gerberLayout );
923  return m_gerberLayout->GetAuxOrigin();
924 }
925 
926 
927 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
928 {
929  wxASSERT( m_gerberLayout );
930  m_gerberLayout->SetAuxOrigin( aPosition );
931 }
932 
933 
935 {
936  GetCanvas()->GetGAL()->SetGridColor( aColor );
937  m_gridColor = aColor;
938 }
939 
940 
941 /*
942  * Display the grid status.
943  */
945 {
946  wxString line;
947  wxString gridformatter;
948 
949  switch( m_userUnits )
950  {
951  case EDA_UNITS::INCHES:
952  gridformatter = "grid X %.6f Y %.6f";
953  break;
954 
956  gridformatter = "grid X %.6f Y %.6f";
957  break;
958 
959  default:
960  gridformatter = "grid X %f Y %f";
961  break;
962  }
963 
964  BASE_SCREEN* screen = GetScreen();
965  wxArrayString gridsList;
966 
967  int icurr = screen->BuildGridsChoiceList( gridsList, m_userUnits != EDA_UNITS::INCHES );
968  GRID_TYPE& grid = screen->GetGrid( icurr );
969  double grid_x = To_User_Unit( m_userUnits, grid.m_Size.x );
970  double grid_y = To_User_Unit( m_userUnits, grid.m_Size.y );
971  line.Printf( gridformatter, grid_x, grid_y );
972 
973  SetStatusText( line, 4 );
974 }
975 
976 
978 {
980 
981  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
982 
983  if( !screen )
984  return;
985 
986  wxString line;
988 
989  if( GetShowPolarCoords() ) // display relative polar coordinates
990  {
991  double dx = cursorPos.x - screen->m_LocalOrigin.x;
992  double dy = cursorPos.y - screen->m_LocalOrigin.y;
993  double theta = RAD2DEG( atan2( -dy, dx ) );
994  double ro = hypot( dx, dy );
995  wxString formatter;
996 
997  switch( GetUserUnits() )
998  {
999  case EDA_UNITS::INCHES:
1000  formatter = wxT( "r %.6f theta %.1f" );
1001  break;
1003  formatter = wxT( "r %.5f theta %.1f" );
1004  break;
1005  case EDA_UNITS::UNSCALED:
1006  formatter = wxT( "r %f theta %f" );
1007  break;
1008  default: wxASSERT( false ); break;
1009  }
1010 
1011  line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
1012 
1013  SetStatusText( line, 3 );
1014  }
1015 
1016  // Display absolute coordinates:
1017  double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
1018  double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
1019 
1020  wxString absformatter;
1021  wxString relformatter;
1022 
1023  switch( GetUserUnits() )
1024  {
1025  case EDA_UNITS::INCHES:
1026  absformatter = wxT( "X %.6f Y %.6f" );
1027  relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1028  break;
1029 
1031  absformatter = wxT( "X %.5f Y %.5f" );
1032  relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1033  break;
1034 
1035  case EDA_UNITS::UNSCALED:
1036  absformatter = wxT( "X %f Y %f" );
1037  relformatter = wxT( "dx %f dy %f dist %f" );
1038  break;
1039 
1040  default:
1041  wxASSERT( false );
1042  break;
1043  }
1044 
1045  line.Printf( absformatter, dXpos, dYpos );
1046  SetStatusText( line, 2 );
1047 
1048  if( !GetShowPolarCoords() ) // display relative cartesian coordinates
1049  {
1050  // Display relative coordinates:
1051  dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - screen->m_LocalOrigin.x );
1052  dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - screen->m_LocalOrigin.y );
1053 
1054  // We already decided the formatter above
1055  line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1056  SetStatusText( line, 3 );
1057  }
1058 
1059  DisplayGridMsg();
1060 }
1061 
1062 
1064 {
1066 }
1067 
1068 
1070 {
1071  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1072 }
1073 
1074 
1076 {
1078 }
1079 
1080 
1082 {
1083  // Called on units change (see EDA_DRAW_FRAME)
1087 }
1088 
1089 
1091 {
1093 
1094  EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1095 
1096  if( m_toolManager )
1097  {
1099  GetCanvas()->GetViewControls(), this );
1101  }
1102 
1104 
1106 
1107  galCanvas->GetView()->RecacheAllItems();
1108  galCanvas->SetEventDispatcher( m_toolDispatcher );
1109  galCanvas->StartDrawing();
1110 
1113 
1115  ReCreateMenuBar();
1116 
1117  // Update the checked state of tools
1118  SyncToolbars();
1119 }
1120 
1121 
1123  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
1124 {
1125  wxTreebook* book = aParent->GetTreebook();
1126 
1127  book->AddPage( new wxPanel( book ), _( "Gerbview" ) );
1128  book->AddSubPage( new PANEL_GERBVIEW_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
1129  book->AddSubPage( new PANEL_GERBVIEW_SETTINGS( this, book ), _( "Editing Options" ) );
1130 
1131  aHotkeysPanel->AddHotKeys( GetToolManager() );
1132 }
1133 
1134 
1135 
1137 {
1138  // Create the manager and dispatcher & route draw panel events to the dispatcher
1141  GetCanvas()->GetViewControls(), this );
1142  m_actions = new GERBVIEW_ACTIONS();
1144 
1145  // Register tools
1152 
1153  // Run the selection tool, it is supposed to be always active
1154  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1155 }
1156 
1157 
1159 {
1160  UpdateStatusBar();
1161  DisplayUnitsMsg();
1162 
1163  if( m_gridSelectBox == NULL )
1164  return;
1165 
1166  // Update grid values with the current units setting.
1167  m_gridSelectBox->Clear();
1168  wxArrayString gridsList;
1169  int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != EDA_UNITS::INCHES );
1170 
1171  for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
1172  {
1173  GRID_TYPE& grid = GetScreen()->GetGrid( i );
1174  m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
1175  }
1176 
1177  m_gridSelectBox->SetSelection( icurr );
1178 }
1179 
1180 
1182 {
1183  if( m_zoomSelectBox == NULL )
1184  return;
1185 
1186  wxString msg;
1187 
1188  m_zoomSelectBox->Clear();
1189  m_zoomSelectBox->Append( _( "Zoom Auto" ) );
1190  m_zoomSelectBox->SetSelection( 0 );
1191 
1192  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
1193  {
1194  msg = _( "Zoom " );
1195 
1196  double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
1197  wxString value = wxString::Format( wxT( "%.2f" ), level );
1198  msg += value;
1199 
1200  m_zoomSelectBox->Append( msg );
1201 
1202  if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
1203  m_zoomSelectBox->SetSelection( i + 1 );
1204  }
1205 }
1206 
1207 
1208 void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
1209 {
1211  return;
1212 
1213  int current = 0; // display Auto if no match found
1214 
1215  // check for a match within 1%
1216  double zoom = GetCanvas()->GetLegacyZoom();
1217 
1218  for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
1219  {
1220  if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
1221  {
1222  current = i + 1;
1223  break;
1224  }
1225  }
1226 
1227  if( current != m_zoomSelectBox->GetSelection() )
1228  m_zoomSelectBox->SetSelection( current );
1229 }
1230 
1231 
1232 void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1233 {
1234  EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1235 
1236  RecreateToolbars();
1237  Layout();
1238  SendSizeEvent();
1239 }
1240 
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
double To_User_Unit(EDA_UNITS 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:95
GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:47
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
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
Saves 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)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxString m_mruPath
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Updates items in the view according to the given flags and condition.
Definition: view.cpp:1458
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.
SETTINGS_MANAGER * GetSettingsManager() const
int BuildGridsChoiceList(wxArrayString &aGridsList, bool aMmFirst) const
Function BuildGridsChoiceList().
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()
Function GetNegativeItemsColor.
TOOL_DISPATCHER * m_toolDispatcher
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
virtual void SetScreen(BASE_SCREEN *aScreen)
void SetAuxOrigin(const wxPoint &aPoint) override
COLOR4D GetVisibleElementColor(int aLayerID)
Function GetVisibleElementColor returns the color of a gerber visible element.
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
const wxPoint & GetAuxOrigin() const override
Return the origin of the axis used for plotting and various exports.
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
virtual bool IsGridVisible() const
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
int color
Definition: DXF_plotter.cpp:61
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()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
double RAD2DEG(double rad)
Definition: trigo.h:215
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
Definition: filehistory.cpp:65
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE.
GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters (TODO:...
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
ACTIONS * m_actions
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck tools.
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:68
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static TOOL_ACTION standardGraphics
Definition: actions.h:159
wxString m_AboutTitle
EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
const GRID_TYPE & GetGrid() const
Return the grid object of the currently selected grid.
Definition: base_screen.h:286
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
Definition: filehistory.cpp:45
void AddHotKeys(TOOL_MANAGER *aToolMgr)
const wxString & GetType() const
Definition: page_info.h:97
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
ACTION_TOOLBAR * m_mainToolBar
#define ZOOM_FACTOR(x)
Definition: sch_screen.cpp:74
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Visibility flag has changed.
Definition: view_item.h:56
The base class for create windows for drawing purpose.
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout,...
Definition: title_block.h:40
wxChoice * m_gridSelectBox
COLOR4D m_gridColor
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
wxChoice * m_SelNetnameBox
void ActivateGalCanvas() override
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
Function SetGridVisibility(), virtual from EDA_DRAW_FRAME It may be overloaded by derived classes.
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
GERBVIEW_ACTIONS.
Auxiliary rendering target (noncached)
Definition: definitions.h:49
void DisplayUnitsMsg()
Display current unit pane on the status bar.
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:65
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
TOOL_MANAGER.
Definition: tool_manager.h:50
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
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.
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:104
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
Item is being added to the view.
Definition: view_item.h:60
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Updates the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
unsigned ImagesMaxCount() const
The max number of file images.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: common.cpp:278
static TOOL_ACTION gridPreset
Definition: actions.h:134
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:75
PAGE_INFO m_paper
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
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1111
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allows Gerbview to install its preferences panels into the preferences dialog.
SHAPE_POLY_SET.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
PAGE_INFO describes the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
bool m_showBorderAndTitleBlock
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
wxChoice * m_zoomSelectBox
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
double GetLegacyZoom() const
Function GetLegacyZoom() Returns current view scale converted to zoom value used by the legacy canvas...
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
const wxPoint & GetAuxOrigin() const
Definition: gbr_layout.h:67
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:70
Definition of file extensions used in Kicad.
Base window classes and related definitions.
static const wxChar * ShowApertureType(APERTURE_T aType)
Function ShowApertureType returns a character string telling what type of aperture type aType is.
Definition: dcode.cpp:93
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
GBR_LAYOUT * m_gerberLayout
wxRealPoint m_Size
Definition: base_screen.h:47
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
Definition: lset.cpp:723
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remaps the data between layer ids without invalidating that data.
Definition: view.cpp:706
GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be tied in...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void OnCloseWindow(wxCloseEvent &Event)
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
COMMON_CONTROL.
virtual COLOR4D GetGridColor()
virtual void ClearMsgPanel()
Clear all messages from the message panel.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
GERBVIEW_FRAME is the main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
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...
COMMON_TOOLS.
Definition: common_tools.h:38
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
TOOL_DISPATCHER.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
Definition: dcode.h:105
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
GBR_LAYOUT * GetGerberLayout() const
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
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.
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
Definition: filehistory.cpp:83
GERBVIEW_SELECTION_TOOL.
double m_zoomLevelCoeff
wxChoice * m_SelAperAttributesBox
const int scale
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:101
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
void SyncToolbars() override
Update the toolbars (mostly settings/check buttons/checkboxes) with the current controller state.
D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
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
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
GRID_TYPE is for grid arrays.
Definition: base_screen.h:43
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
#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
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
size_t GetGridCount() const
Function GetGridCount().
Definition: base_screen.h:324
static TOOL_ACTION acceleratedGraphics
Definition: actions.h:158
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:44
EDA_UNITS m_userUnits
#define IU_PER_MILS
Definition: plotter.cpp:137
void DisplayGridMsg()
Function DisplayGridMsg()
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
virtual COLOR_SETTINGS * GetColorSettings()
Returns a pointer to the active color theme settings.
virtual void SetGridColor(COLOR4D aColor) override
void SetGridVisibility(bool aVisibility)
Sets the visibility setting of the grid.
void syncLayerWidget()
Function syncLayerWidget updates 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 CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
virtual void SetGridVisibility(bool aVisible)
TOOL_MANAGER * m_toolManager
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
#define GERBER_DRAW_LAYER(x)
void InitTools()
Function 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.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
int m_CmdId
Definition: base_screen.h:46
virtual APP_SETTINGS_BASE * config()
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
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...
void SetLayout(GBR_LAYOUT *aLayout)
Function SetLayout sets the m_gerberLayout member in such as way as to ensure deleting any previous G...
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
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.
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
void ReFillLayerWidget()
Function ReFillLayerWidget changes out all the layers in m_Layers and may be called upon loading new ...
void UpdateTitleAndInfo()
Function UpdateTitleAndInfo displays the short filename (if exists) of the selected layer on the capt...
void StopDrawing()
Function StopDrawing() Prevents the GAL canvas from further drawing till it is recreated or StartDraw...
long m_firstRunDialogSetting
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
std::vector< double > m_ZoomList
standard zoom (i.e. scale) coefficients.
Definition: base_screen.h:138
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:114
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
const std::string DrillFileExtension
PCBNEW_CONTROL.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:71
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar.