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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2018 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 
25 #include <fctsys.h>
26 #include <kiface_i.h>
27 #include <pgm_base.h>
28 #include <eda_base_frame.h>
29 #include <class_drawpanel.h>
30 #include <build_version.h>
31 #include <trigo.h>
32 #include <base_units.h>
33 #include <gbr_layer_box_selector.h>
34 #include <msgpanel.h>
35 #include <bitmaps.h>
37 
38 #include <gerbview.h>
39 #include <gerbview_frame.h>
40 #include <gerbview_id.h>
41 #include <hotkeys.h>
42 #include <gerber_file_image.h>
43 #include <gerber_file_image_list.h>
44 #include <dialog_helpers.h>
45 #include <DCodeSelectionbox.h>
46 #include <gerbview_layer_widget.h>
47 
50 #include <tool/tool_manager.h>
51 #include <tool/tool_dispatcher.h>
52 #include <tools/gerbview_actions.h>
53 #include <view/view.h>
54 #include <gerbview_painter.h>
55 
56 
57 // Config keywords
58 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
59 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
60 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
61 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
62 static const wxString IconScaleEntry = "GvIconScale";
63 
64 // Colors for layers and items
66 
67 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
68  EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
69  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME )
70 {
71  m_auxiliaryToolBar = NULL;
73  m_gerberLayout = NULL;
74  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
75  // when the screen shows a 1:1 image
76  // obviously depends on the monitor,
77  // but this is an acceptable value
78 
79  PAGE_INFO pageInfo( wxT( "GERBER" ) );
80  SetPageSettings( pageInfo );
81 
83 
84  m_showAxis = true; // true to show X and Y axis on screen
85  m_showBorderAndTitleBlock = false; // true for reference drawings.
87  m_SelLayerBox = NULL;
88  m_DCodeSelector = NULL;
89  m_SelComponentBox = nullptr;
90  m_SelNetnameBox = nullptr;
91  m_SelAperAttributesBox = nullptr;
92  m_displayMode = 0;
96 
97  EDA_DRAW_PANEL_GAL* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
101 
102  SetGalCanvas( galCanvas );
103 
104  // GerbView requires draw priority for rendering negative objects
105  galCanvas->GetView()->UseDrawPriority( true );
106 
107  if( m_canvas )
109 
110  // Give an icon
111  wxIcon icon;
112  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
113  SetIcon( icon );
114 
115  SetLayout( new GBR_LAYOUT() );
116 
117  SetVisibleLayers( -1 ); // All draw layers visible.
118 
119  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
120 
121  // Create the PCB_LAYER_WIDGET *after* SetLayout():
122  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
123  int pointSize = font.GetPointSize();
124  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
125 
126  if( screenHeight <= 900 )
127  pointSize = (pointSize * 8) / 10;
128 
129  m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize );
130 
131  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
132  // initialize parameters in m_LayersManager
133  LoadSettings( config() );
134 
135  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
136 
137  if( m_LastGridSizeId < 0 )
138  m_LastGridSizeId = 0;
141  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
142 
143  m_auimgr.SetManagedWindow( this );
144 
145  ReCreateMenuBar();
149 
150  EDA_PANEINFO horiz;
151  horiz.HorizontalToolbarPane();
152 
153  EDA_PANEINFO vert;
154  vert.VerticalToolbarPane();
155 
156  EDA_PANEINFO mesg;
157  mesg.MessageToolbarPane();
158 
159  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
160  // the Layers Manager is floatable, but initially docked at far right
161  EDA_PANEINFO lyrs;
162  lyrs.LayersToolbarPane();
163  lyrs.MinSize( m_LayersManager->GetBestSize() );
164  lyrs.BestSize( m_LayersManager->GetBestSize() );
165  lyrs.Caption( _( "Visibles" ) );
166  lyrs.TopDockable( false ).BottomDockable( false );
167 
168 
169  if( m_mainToolBar )
170  m_auimgr.AddPane( m_mainToolBar,
171  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
172 
173  if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows component and netname lists
174  {
175  m_auimgr.AddPane( m_auxiliaryToolBar,
176  wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
177  }
178 
179  if( m_drawToolBar )
180  m_auimgr.AddPane( m_drawToolBar,
181  wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
182 
183  m_auimgr.AddPane( m_LayersManager,
184  lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) );
185 
186  if( m_optionsToolBar )
187  m_auimgr.AddPane( m_optionsToolBar,
188  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
189 
190  if( m_canvas )
191  m_auimgr.AddPane( m_canvas,
192  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
193 
194  if( GetGalCanvas() )
195  m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
196  wxAuiPaneInfo().Name( wxT( "DrawFrameGal" ) ).CentrePane().Hide() );
197 
198  if( m_messagePanel )
199  m_auimgr.AddPane( m_messagePanel,
200  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) );
201 
202  ReFillLayerWidget(); // this is near end because contents establish size
203  m_auimgr.Update();
204 
205  setupTools();
206 
207  SetActiveLayer( 0, true );
208  Zoom_Automatique( false ); // Gives a default zoom value
210 
212 
213  // Nudge user to switch to OpenGL if they are on legacy or Cairo
214  if( m_firstRunDialogSetting < 1 )
215  {
216  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
217  {
218  wxString msg = _( "KiCad can use your graphics card to give you a smoother "
219  "and faster experience. This option is turned off by "
220  "default since it is not compatible with all computers.\n\n"
221  "Would you like to try enabling graphics acceleration?\n\n"
222  "If you'd like to choose later, select Modern Toolset "
223  "(Accelerated) in the Preferences menu." );
224 
225  wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ),
226  wxYES_NO );
227 
228  dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
229 
230  if( dlg.ShowModal() == wxID_YES )
231  {
232  // Save Cairo as default in case OpenGL crashes
234 
235  // Switch to OpenGL, which will save the new setting if successful
236  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL );
237  auto handler = GetEventHandler();
238  handler->ProcessEvent( evt );
239  }
240  else
241  {
242  // If they were on legacy, switch them to Cairo
243 
244  if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
245  {
246  wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
247  auto handler = GetEventHandler();
248  handler->ProcessEvent( evt );
249  }
250  }
251  }
252 
254  SaveSettings( config() );
255  }
256 
257  // Canvas may have been updated by the dialog
258  canvasType = loadCanvasTypeSetting();
259 
260  if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
261  {
262  if( GetGalCanvas()->SwitchBackend( canvasType ) )
263  UseGalCanvas( true );
264 
265  wxUpdateUIEvent e;
267  }
268  else
269  {
271  m_canvas->Refresh();
272  }
273 
274  // Enable the axes to match legacy draw style
275  auto& galOptions = GetGalDisplayOptions();
276  galOptions.m_axesEnabled = true;
277  galOptions.NotifyChanged();
278 
280  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
281 }
282 
283 
285 {
287  delete m_gerberLayout;
288 }
289 
290 
291 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
292 {
293  if( m_toolManager )
295 
296  if( IsGalCanvasActive() )
297  {
298  GetGalCanvas()->GetView()->Clear();
299  // Be sure any OpenGL event cannot be fired after frame deletion:
300  GetGalCanvas()->SetEvtHandlerEnabled( false );
301  }
302 
304 
305  Destroy();
306 }
307 
308 
309 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
310 {
311  // The current project path is also a valid command parameter. Check if a single path
312  // rather than a file name was passed to GerbView and use it as the initial MRU path.
313  if( aFileSet.size() > 0 )
314  {
315  wxString path = aFileSet[0];
316 
317  // For some reason wxApp appears to leave the trailing double quote on quoted
318  // parameters which are required for paths with spaces. Maybe this should be
319  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
320  // We can't buy a break!
321  if( path.Last() == wxChar( '\"' ) )
322  path.RemoveLast();
323 
324  if( !wxFileExists( path ) && wxDirExists( path ) )
325  {
326  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
327  m_mruPath = path;
328  return true;
329  }
330 
331  const unsigned limit = std::min( unsigned( aFileSet.size() ),
332  unsigned( GERBER_DRAWLAYERS_COUNT ) );
333 
334  int layer = 0;
335 
336  for( unsigned i=0; i<limit; ++i, ++layer )
337  {
338  SetActiveLayer( layer );
339 
340  // Try to guess the type of file by its ext
341  // if it is .drl (Kicad files), it is a drill file
342  wxFileName fn( aFileSet[i] );
343  wxString ext = fn.GetExt();
344 
345  if( ext == DrillFileExtension ) // In Excellon format
346  LoadExcellonFiles( aFileSet[i] );
347  else if( ext == GerberJobFileExtension )
348  LoadGerberJobFile( aFileSet[i] );
349  else
350  LoadGerberFiles( aFileSet[i] );
351  }
352  }
353 
354  Zoom_Automatique( true ); // Zoom fit in frame
355 
357 
358  return true;
359 }
360 
361 
363 {
364  double defaultGerberZoom = 1.0;
366 
367  if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
368  {
369  SetScrollCenterPosition( wxPoint( 0, 0 ) );
370  return defaultGerberZoom;
371  }
372 
373  double sizeX = (double) bbox.GetWidth();
374  double sizeY = (double) bbox.GetHeight();
375  wxPoint centre = bbox.Centre();
376 
377  // Reserve no margin because GetGerberLayout()->ComputeBoundingBox() builds one in.
378  double margin_scale_factor = 1.0;
379 
380  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
381 }
382 
383 
384 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
385 {
387 
388  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
390 
391  PAGE_INFO pageInfo( wxT( "GERBER" ) );
392 
394 
396  {
397  wxString pageType;
398  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
399  pageInfo.SetType( pageType );
400  }
401 
402  SetPageSettings( pageInfo );
403 
404  GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
405 
406  bool tmp;
407  aCfg->Read( cfgShowDCodes, &tmp, true );
409  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
411 
412  // because we have more than one file history, we must read this one
413  // using a specific path
414  aCfg->SetPath( wxT( "drl_files" ) );
415  m_drillFileHistory.Load( *aCfg );
416  aCfg->SetPath( wxT( ".." ) );
417 
418  // because we have more than one file history, we must read this one
419  // using a specific path
420  aCfg->SetPath( wxT( "zip_files" ) );
421  m_zipFileHistory.Load( *aCfg );
422  aCfg->SetPath( wxT( ".." ) );
423 
424  // because we have more than one file history, we must read this one
425  // using a specific path
426  aCfg->SetPath( "job_files" );
427  m_jobFileHistory.Load( *aCfg );
428  aCfg->SetPath( wxT( ".." ) );
429 }
430 
431 
432 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
433 {
435 
436  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
438 
439  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
441  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
442  aCfg->Write( cfgShowNegativeObjects,
444 
445  // Save the drill file history list.
446  // Because we have more than one file history, we must save this one
447  // in a specific path
448  aCfg->SetPath( wxT( "drl_files" ) );
449  m_drillFileHistory.Save( *aCfg );
450  aCfg->SetPath( wxT( ".." ) );
451 
452  // Save the zip file history list.
453  aCfg->SetPath( wxT( "zip_files" ) );
454  m_zipFileHistory.Save( *aCfg );
455  aCfg->SetPath( wxT( ".." ) );
456 
457  // Save the job file history list.
458  aCfg->SetPath( "job_files" );
459  m_jobFileHistory.Save( *aCfg );
460  aCfg->SetPath( ".." );
461 }
462 
463 
465 {
469 
470  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
471 
472  wxSize bestz = m_LayersManager->GetBestSize();
473  bestz.x += 5; // gives a little margin
474 
475  lyrs.MinSize( bestz );
476  lyrs.BestSize( bestz );
477  lyrs.FloatingSize( bestz );
478 
479  if( lyrs.IsDocked() )
480  m_auimgr.Update();
481  else
482  m_LayersManager->SetSize( bestz );
483 
484  syncLayerWidget();
485 }
486 
487 
489  bool aNewState )
490 {
491  bool dcodes_changed = false;
492 
493  switch( aItemIdVisible )
494  {
495  case LAYER_DCODES:
496  dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
497  m_DisplayOptions.m_DisplayDCodes = aNewState;
498  break;
499 
502  break;
503 
504  case LAYER_GERBVIEW_GRID:
505  SetGridVisibility( aNewState );
506  break;
507 
508  default:
509  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aItemIdVisible );
510  }
511 
512  if( dcodes_changed )
513  {
514  auto view = GetGalCanvas()->GetView();
515 
516  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
517  {
518  int layer = GERBER_DRAW_LAYER( i );
519  int dcode_layer = GERBER_DCODE_LAYER( layer );
520  view->SetLayerVisible( dcode_layer,
521  aNewState && view->IsLayerVisible( layer ) );
522  }
523  }
524 
526  m_LayersManager->SetRenderState( aItemIdVisible, aNewState );
527 }
528 
529 
531 {
532  auto view = GetGalCanvas()->GetView();
533  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
534  auto settings = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( painter->GetSettings() );
535  settings->LoadDisplayOptions( &m_DisplayOptions );
536 
537  settings->ImportLegacyColors( m_colorsSettings );
538 
539  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
540 }
541 
542 
544 {
545  int layer = aLayer;
546 
547  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
548  {
549  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
550 
551  if( gerber == NULL ) // this graphic layer is available: use it
552  return layer;
553 
554  ++layer; // try next graphic layer
555 
556  if( layer >= (int)ImagesMaxCount() )
557  layer = 0;
558  }
559 
560  return NO_AVAILABLE_LAYERS;
561 }
562 
563 
565 {
568 }
569 
570 
571 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
572 {
573  if( aRebuildLayerBox )
575 
576  m_SelLayerBox->SetSelection( GetActiveLayer() );
577 
578  int dcodeSelected = -1;
580 
581  if( gerber )
582  dcodeSelected = gerber->m_Selected_Tool;
583 
584  if( m_DCodeSelector )
585  {
587  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
588  m_DCodeSelector->Enable( gerber != NULL );
589  }
590 
592 }
593 
594 
596 {
597  int ii, jj;
598  wxString Line;
599  wxArrayString list;
600  double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
601  int curr_layer = GetActiveLayer();
602 
603  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
604  {
605  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
606 
607  if( gerber == NULL )
608  continue;
609 
610  if( gerber->GetDcodesCount() == 0 )
611  continue;
612 
613  if( layer == curr_layer )
614  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
615  else
616  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
617 
618  list.Add( Line );
619 
620  const char* units = g_UserUnit == INCHES ? "\"" : "mm";
621 
622  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
623  {
624  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
625 
626  if( pt_D_code == NULL )
627  continue;
628 
629  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
630  continue;
631 
632  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
633  jj,
634  pt_D_code->m_Num_Dcode,
635  pt_D_code->m_Size.y / scale, units,
636  pt_D_code->m_Size.x / scale, units,
637  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
638  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
639  );
640 
641  if( !pt_D_code->m_Defined )
642  Line += wxT( " (not defined)" );
643 
644  if( pt_D_code->m_InUse )
645  Line += wxT( " (in use)" );
646 
647  list.Add( Line );
648  jj++;
649  }
650  }
651 
652  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
653  wxCHOICEDLG_STYLE & ~wxCANCEL );
654 
655  dlg.ShowModal();
656 }
657 
658 
660 {
662 
663  // Display the gerber filename
664  if( gerber == NULL )
665  {
666  SetTitle( "GerbView" );
667 
668  SetStatusText( wxEmptyString, 0 );
669 
670  wxString info;
671  info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
672  m_TextInfo->SetValue( info );
673 
674  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
675  m_auimgr.Update();
676 
677  ClearMsgPanel();
678  return;
679  }
680  else
681  {
682  wxString title;
683  title.Printf( L"GerbView \u2014 %s%s",
684  gerber->m_FileName,
685  gerber->m_IsX2_file
686  ? " " + _( "(with X2 attributes)" )
687  : wxString( wxEmptyString ) );
688  SetTitle( title );
689 
690  gerber->DisplayImageInfo( this );
691 
692  // Display Image Name and Layer Name (from the current gerber data):
693  wxString status;
694  status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
695  GetChars( gerber->m_ImageName ),
696  GetChars( gerber->GetLayerParams().m_LayerName ) );
697  SetStatusText( status, 0 );
698 
699  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
700  wxString info;
701  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
702  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
703  gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x,
704  gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y,
705  gerber->m_NoTrailingZeros ? 'T' : 'L' );
706 
707  if( gerber->m_IsX2_file )
708  info << wxT(" ") << _( "X2 attr" );
709 
710  m_TextInfo->SetValue( info );
711 
712  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
713  m_auimgr.Update();
714  }
715 }
716 
717 
719 {
720  switch( aItemIdVisible )
721  {
722  case LAYER_DCODES:
724  break;
725 
728  break;
729 
730  case LAYER_GERBVIEW_GRID:
731  return IsGridVisible();
732  break;
733 
734  default:
735  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aItemIdVisible );
736  }
737 
738  return true;
739 }
740 
741 
743 {
744  long layerMask = 0;
745 
746  if( auto canvas = GetGalCanvas() )
747  {
748  // NOTE: This assumes max 32 drawlayers!
749  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
750  {
751  if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) )
752  layerMask |= ( 1 << i );
753  }
754 
755  return layerMask;
756  }
757  else
758  {
759  return -1;
760  }
761 }
762 
763 
764 void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
765 {
766  if( auto canvas = GetGalCanvas() )
767  {
768  // NOTE: This assumes max 32 drawlayers!
769  for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
770  {
771  bool v = ( aLayerMask & ( 1 << i ) );
772  int layer = GERBER_DRAW_LAYER( i );
773  canvas->GetView()->SetLayerVisible( layer, v );
774  canvas->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
776  }
777  }
778 }
779 
780 
781 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
782 {
784  {
785  if( IsGalCanvasActive() )
786  aLayer = GERBER_DRAW_LAYER( aLayer );
787 
788  return m_LayersManager->IsLayerVisible( aLayer );
789  }
790  else
791  return GetGerberLayout()->IsLayerPrintable( aLayer );
792 }
793 
794 
796 {
797  COLOR4D color = COLOR4D::UNSPECIFIED;
798 
799  switch( aItemIdVisible )
800  {
802  case LAYER_DCODES:
803  color = m_colorsSettings->GetItemColor( aItemIdVisible );
804  break;
805 
806  case LAYER_GERBVIEW_GRID:
807  color = GetGridColor();
808  break;
809 
810  default:
811  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
812  (int)aItemIdVisible );
813  }
814 
815  return color;
816 }
817 
818 
820 {
823 }
824 
825 
827  COLOR4D aColor )
828 {
829  switch( aItemIdVisible )
830  {
832  case LAYER_DCODES:
833  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
834  break;
835 
836  case LAYER_GERBVIEW_GRID:
837  // Ensure grid always has low alpha
838  aColor.a = 0.8;
839  SetGridColor( aColor );
840  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
841  break;
842 
843  default:
844  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ),
845  (int) aItemIdVisible );
846  }
847 }
848 
850 {
853  else
854  return GetDrawBgColor();
855 }
856 
857 
859 {
860  return m_colorsSettings->GetLayerColor( aLayer );
861 }
862 
863 
864 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
865 {
866  m_colorsSettings->SetLayerColor( aLayer, aColor );
868 }
869 
870 
872 {
873  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
874 }
875 
876 
877 void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
878 {
879  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
880 
881  if( doLayerWidgetUpdate )
883 
884  if( IsGalCanvasActive() )
885  {
886  m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
887  GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
888 
889  // NOTE(JE) The next two calls are slow (scales with number of items)
892 
893  GetGalCanvas()->Refresh();
894  }
895 }
896 
897 
898 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
899 {
900  m_paper = aPageSettings;
901 
902  if( GetScreen() )
903  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
904 }
905 
906 
908 {
909  return m_paper;
910 }
911 
912 
913 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
914 {
915  // this function is only needed because EDA_DRAW_FRAME is not compiled
916  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
917  // into an application specific source file.
918  return GetPageSettings().GetSizeIU();
919 }
920 
921 
923 {
924  wxASSERT( m_gerberLayout );
925  return m_gerberLayout->GetTitleBlock();
926 }
927 
928 
929 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
930 {
931  wxASSERT( m_gerberLayout );
932  m_gerberLayout->SetTitleBlock( aTitleBlock );
933 }
934 
935 
937 {
938  wxASSERT( m_gerberLayout );
939  return m_gerberLayout->GetAuxOrigin();
940 }
941 
942 
943 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
944 {
945  wxASSERT( m_gerberLayout );
946  m_gerberLayout->SetAuxOrigin( aPosition );
947 }
948 
949 
950 void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
951 {
952  GetScreen()->SetCurItem( aItem );
953 
954  if( aItem )
955  {
956  if( aDisplayInfo )
957  {
958  MSG_PANEL_ITEMS items;
959  aItem->GetMsgPanelInfo( items );
960  SetMsgPanel( items );
961  }
962  }
963  else
964  {
965  EraseMsgBox();
966  }
967 }
968 
969 
971 {
972  if( IsGalCanvasActive() )
973  {
974  GetGalCanvas()->GetGAL()->SetGridColor( aColor );
975  }
976 
977  m_gridColor = aColor;
978 }
979 
980 
982 {
984  return GetGerberLayout()->GetBoundingBox();
985 }
986 
988 {
990 
991  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
992 
993  if( !screen )
994  return;
995 
996  int dx;
997  int dy;
998  double dXpos;
999  double dYpos;
1000  wxString line;
1001  wxString locformatter;
1002 
1003  if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
1004  {
1005  double theta, ro;
1006 
1007  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1008  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1009 
1010  // atan2 in the 0,0 case returns 0
1011  theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
1012 
1013  ro = hypot( dx, dy );
1014  wxString formatter;
1015  switch( g_UserUnit )
1016  {
1017  case INCHES:
1018  formatter = wxT( "Ro %.6f Th %.1f" );
1019  break;
1020 
1021  case MILLIMETRES:
1022  formatter = wxT( "Ro %.5f Th %.1f" );
1023  break;
1024 
1025  case UNSCALED_UNITS:
1026  formatter = wxT( "Ro %f Th %f" );
1027  break;
1028 
1029  case DEGREES:
1030  wxASSERT( false );
1031  break;
1032  }
1033 
1034  line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
1035 
1036  SetStatusText( line, 3 );
1037  }
1038 
1039  // Display absolute coordinates:
1042 
1043  wxString absformatter;
1044 
1045  switch( g_UserUnit )
1046  {
1047  case INCHES:
1048  absformatter = wxT( "X %.6f Y %.6f" );
1049  locformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
1050  break;
1051 
1052  case MILLIMETRES:
1053  absformatter = wxT( "X %.5f Y %.5f" );
1054  locformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
1055  break;
1056 
1057  case UNSCALED_UNITS:
1058  absformatter = wxT( "X %f Y %f" );
1059  locformatter = wxT( "dx %f dy %f dist %f" );
1060  break;
1061 
1062  case DEGREES:
1063  wxASSERT( false );
1064  break;
1065  }
1066 
1067  line.Printf( absformatter, dXpos, dYpos );
1068  SetStatusText( line, 2 );
1069 
1070  if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
1071  {
1072  // Display relative coordinates:
1073  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
1074  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
1075  dXpos = To_User_Unit( g_UserUnit, dx );
1076  dYpos = To_User_Unit( g_UserUnit, dy );
1077 
1078  // We already decided the formatter above
1079  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
1080  SetStatusText( line, 3 );
1081  }
1082 }
1083 
1084 
1086 {
1088 }
1089 
1091 {
1092  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1093 }
1094 
1096 {
1098 }
1099 
1100 
1102 { // Called on units change (see EDA_DRAW_FRAME)
1105 }
1106 
1107 
1108 void GERBVIEW_FRAME::UseGalCanvas( bool aEnable )
1109 {
1110  EDA_DRAW_FRAME::UseGalCanvas( aEnable );
1111 
1112  EDA_DRAW_PANEL_GAL* galCanvas = GetGalCanvas();
1113 
1114  if( m_toolManager )
1116  GetGalCanvas()->GetViewControls(), this );
1117 
1118  if( aEnable )
1119  {
1120  if( m_toolManager )
1122 
1123  m_colorsSettings->SetLegacyMode( false );
1124 
1126 
1127  galCanvas->GetView()->RecacheAllItems();
1128  galCanvas->SetEventDispatcher( m_toolDispatcher );
1129  galCanvas->StartDrawing();
1130  }
1131  else
1132  {
1133  if( m_toolManager )
1135 
1136  galCanvas->StopDrawing();
1137 
1138  // Redirect all events to the legacy canvas
1139  galCanvas->SetEventDispatcher( NULL );
1140 
1142  m_canvas->Refresh();
1143  }
1144 
1147 
1149 }
1150 
1151 
1153 {
1154  // Create the manager and dispatcher & route draw panel events to the dispatcher
1157  GetGalCanvas()->GetViewControls(), this );
1158  m_actions = new GERBVIEW_ACTIONS();
1160 
1161  // Register tools
1164 
1165  // Run the selection tool, it is supposed to be always active
1166  m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1167 }
1168 
1169 
1171 {
1172  int scale = 0;
1173  Kiface().KifaceSettings()->Read( IconScaleEntry, &scale, 0 );
1174  return scale;
1175 }
1176 
1177 
1179 {
1180  Kiface().KifaceSettings()->Write( IconScaleEntry, aScale );
1181  ReCreateMenuBar();
1182  ReCreateHToolbar();
1185  Layout();
1186  SendSizeEvent();
1187 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:95
Class GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
Definition: gbr_layout.h:53
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
wxString m_LayerName
static const wxString cfgShowBorderAndTitleBlock(wxT("ShowBorderAndTitleBlock"))
static TOOL_ACTION layerChanged
virtual void SetHighContrastLayer(int aLayer)
Function SetHighContrastLayer Takes care of display settings for the given layer to be displayed in h...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox.
Definition: gbr_layout.h:105
wxString m_mruPath
Most recently used path.
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum PCB_L...
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
void SetIconScale(int aScale) override
Function SetIconScale.
D_CODE * GetDCODE(int aDCODE) const
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE...
COLORS_DESIGN_SETTINGS g_ColorsSettings(FRAME_GERBER)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:903
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:103
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:694
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:339
void DeleteAllImages()
remove all loaded data in list, and delete all images.
bool IsLayerPrintable(int aLayer) const
Function IsLayerPrintable tests whether a given layer is visible.
Definition: gbr_layout.cpp:56
EDA_RECT GetGerberLayoutBoundingBox()
Function GetGerberLayoutBoundingBox calculates the bounding box containing all gerber items...
Implementation of conversion functions that require both schematic and board internal units...
COLOR4D GetNegativeItemsColor()
Function GetNegativeItemsColor.
TOOL_DISPATCHER * m_toolDispatcher
Definition: draw_frame.h:96
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:94
void SetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible, COLOR4D aColor)
void syncLayerBox(bool aRebuildLayerBox=false)
Function syncLayerBox updates the currently "selected" layer within m_SelLayerBox The currently activ...
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
Definition: zoom.cpp:86
void SetAuxOrigin(const wxPoint &aPoint) override
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:102
void SetCurItem(GERBER_DRAW_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
Definition: dcode.h:95
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:150
static const wxString IconScaleEntry
const wxPoint & GetAuxOrigin() const override
Function GetAuxOrigin returns the origin of the axis used for plotting and various exports...
void SetScrollCenterPosition(const wxPoint &aPoint)
const wxPoint & GetAuxOrigin() const
Definition: gbr_layout.h:75
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
int color
Definition: DXF_plotter.cpp:62
void UseDrawPriority(bool aFlag)
Function UseDrawPriority()
Definition: view.h:628
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1250
double RAD2DEG(double rad)
Definition: trigo.h:200
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Class GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters ...
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
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
int GetHeight() const
Definition: eda_rect.h:118
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetAuxOrigin(const wxPoint &aPosition)
Definition: gbr_layout.h:80
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:125
static const wxString cfgShowNegativeObjects(wxT("ShowNegativeObjectsOpt"))
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer.
void SetGalCanvas(EDA_DRAW_PANEL_GAL *aPanel)
Definition: draw_frame.h:883
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
wxFileHistory m_drillFileHistory
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
static const wxString cfgShowDCodes(wxT("ShowDCodesOpt"))
wxSize GetBestSize() const
Function GetBestSize returns the preferred minimum size, taking into consideration the dynamic conten...
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
void SetVisibleLayers(long aLayerMask)
Function SetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:39
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
COLOR4D m_gridColor
Grid color.
Definition: draw_frame.h:83
virtual void UseGalCanvas(bool aEnable)
Function UseGalCanvas used to switch between standard and GAL-based canvas.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:751
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
GERBVIEW_LAYER_ID
GerbView draw layers.
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
Specialization of the wxAuiPaneInfo class for KiCad panels.
EDA_RECT ComputeBoundingBox() const
Function ComputeBoundingBox calculates the bounding box containing all Gerber items.
Definition: gbr_layout.cpp:68
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:486
wxChoice * m_SelNetnameBox
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
int getNextAvailableLayer(int aLayer=0) const
Function getNextAvailableLayer finds the next empty layer starting at aLayer and returns it to the ca...
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)
Class GERBVIEW_ACTIONS.
long GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
Auxiliary rendering target (noncached)
Definition: definitions.h:42
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
#define GERBER_DCODE_LAYER(x)
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
Class TOOL_MANAGER.
Definition: tool_manager.h:49
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:102
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
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.
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
double a
Alpha component.
Definition: color4d.h:294
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:352
COLOR4D GetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible)
Function GetVisibleElementColor returns the color of a gerber visible element.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:129
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString)
Function EnsureTextCtrlWidth sets the minimum pixel width on a text control in order to make a text s...
Definition: common.cpp:108
unsigned ImagesMaxCount() const
The max number of file images.
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:329
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:77
virtual void unitsChangeRefresh() override
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
#define GERBER_DRAWLAYERS_COUNT
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:790
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void EraseMsgBox()
Definition: draw_frame.cpp:264
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.
#define FIRST_DCODE
Definition: dcode.h:71
#define NO_AVAILABLE_LAYERS
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:966
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:132
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:49
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:113
Definition: common.h:145
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:96
COLORS_DESIGN_SETTINGS * m_colorsSettings
GBR_DISPLAY_OPTIONS m_DisplayOptions
virtual void SetTopLayer(int aLayer)
Function SetTopLayer Moves the selected layer to the top, so it is displayed above all others...
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
const wxString DrillFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:85
The common library.
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:95
double BestZoom() override
Return the zoom level which displays the full page on screen.
Helper dialog and control classes.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
GBR_LAYOUT * m_gerberLayout
wxFileHistory m_jobFileHistory
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool IsGalCanvasActive() const
Function IsGalCanvasActive is used to check which canvas (GAL-based or standard) is currently in use...
Definition: draw_frame.h:874
virtual void SetFocus() override
GBR_LAYOUT * GetGerberLayout() const
bool m_DisplayPolarCood
Option to display coordinates in status bar in X,Y or Polar coords.
virtual void UseGalCanvas(bool aEnable) override
>
Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be t...
#define KICAD_DEFAULT_DRAWFRAME_STYLE
wxPoint Centre() const
Definition: eda_rect.h:60
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
void OnCloseWindow(wxCloseEvent &Event)
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
int m_LastGridSizeId
Definition: draw_frame.h:78
virtual COLOR4D GetGridColor()
Function GetGridColor() , virtual.
Definition: draw_frame.h:505
#define GERBVIEW_FRAME_NAME
Class GERBVIEW_FRAME is the main window used in GerbView.
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:126
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
void StartDrawing()
Function StartDrawing() Begins drawing if it was stopped previously.
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:719
#define ZOOM_FACTOR(x)
Definition: pcb_screen.cpp:42
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting() const
Returns the canvas type stored in the application settings.
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
const wxString GerberJobFileExtension
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
Class TOOL_DISPATCHER.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE ...
Definition: dcode.h:105
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
wxTextCtrl * m_TextInfo
DCODE_SELECTION_BOX * m_DCodeSelector
wxAuiToolBar * m_auxiliaryToolBar
Auxiliary tool bar typically shown below the main tool bar at the top of the main window...
wxFileHistory m_zipFileHistory
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
bool IsLayerVisible(LAYER_NUM aLayer)
Function IsLayerVisible returns the visible state of the layer ROW associated with aLayer id...
COLOR4D GetLayerColor(int aLayer) const
Function GetLayerColor gets a layer color for any valid layer.
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:86
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
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:92
see class PGM_BASE
Class D_CODE holds a gerber DCODE (also called Aperture) definition.
Definition: dcode.h:82
void OnUpdateSwitchCanvas(wxUpdateUIEvent &aEvent)
Update UI called when switches currently used canvas (default / Cairo / OpenGL).
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Function GetConfigurationSettings Populates the GerbView applications settings list.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools...
void SetElementVisibility(GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:50
int GetIconScale() override
Function GetIconScale.
bool IsElementVisible(GERBVIEW_LAYER_ID aItemIdVisible) const
Function IsElementVisible tests whether a given element category is visible.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
#define TOOLS_MAX_COUNT
Definition: dcode.h:73
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
int GetWidth() const
Definition: eda_rect.h:117
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
virtual void SetGridColor(COLOR4D aColor) override
>
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
void SetEnableBlockCommands(bool aEnable)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
double To_User_Unit(EDA_UNITS_T aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:91
void SetLegacyMode(bool aMode)
Enables or disables legacy color mode.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
bool LoadExcellonFiles(const wxString &aFileName)
function LoadExcellonFiles Load a drill (EXCELLON) file or many files.
virtual void SetGridVisibility(bool aVisible)
Function SetGridVisibility() , virtual It may be overloaded by derived classes.
Definition: draw_frame.h:496
#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.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
virtual void unitsChangeRefresh()
Function unitsChangeRefresh is called when when the units setting has changed to allow for any derive...
Definition: draw_frame.cpp:257
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
virtual void RegisterAllTools(TOOL_MANAGER *aToolManager)=0
Registers all valid tools for an application with the tool manager
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...
ACTIONS * m_actions
Definition: draw_frame.h:97
bool m_IsPrinting
true when printing a page, false when drawing on screen
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
Rendering engine changes.
Definition: tool_base.h:84
void wxConfigLoadSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigLoadSetups uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
void SelectLayer(LAYER_NUM aLayer)
Function SelectLayer changes the row selection in the layer list to aLayer provided.
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:683
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void Liste_D_Codes()
Set Size Items (Lines, Flashes) from DCodes List.
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:781
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
Key to control whether first run dialog is shown on startup.
Definition: draw_frame.h:116
static const wxString cfgShowPageSizeOption(wxT("PageSizeOpt"))
GERBER_LAYER & GetLayerParams()
Function GetLayerParams.
#define min(a, b)
Definition: auxiliary.h:85
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:90
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39