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-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <pgm_base.h>
32 #include <wxstruct.h>
33 #include <class_drawpanel.h>
34 #include <build_version.h>
35 #include <trigo.h>
36 #include <base_units.h>
37 #include <colors_selection.h>
39 #include <msgpanel.h>
40 #include <bitmaps.h>
41 
42 #include <gerbview.h>
43 #include <gerbview_frame.h>
44 #include <gerbview_id.h>
45 #include <hotkeys.h>
48 #include <dialog_helpers.h>
51 
52 
53 // Config keywords
54 static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
55 static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
56 static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
57 static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
58 
59 
60 GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
61  EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
62  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME )
63 {
64  m_auxiliaryToolBar = NULL;
66  m_gerberLayout = NULL;
67  m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
68  // when the screen shows a 1:1 image
69  // obviously depends on the monitor,
70  // but this is an acceptable value
71 
72  PAGE_INFO pageInfo( wxT( "GERBER" ) );
73  SetPageSettings( pageInfo );
74 
76 
77  m_showAxis = true; // true to show X and Y axis on screen
78  m_showBorderAndTitleBlock = false; // true for reference drawings.
80  m_SelLayerBox = NULL;
81  m_DCodeSelector = NULL;
82  m_displayMode = 0;
85 
86  if( m_canvas )
88 
89  // Give an icon
90  wxIcon icon;
91  icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
92  SetIcon( icon );
93 
94  SetLayout( new GBR_LAYOUT() );
95 
96  SetVisibleLayers( -1 ); // All draw layers visible.
97 
98  SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
99 
100  // Create the PCB_LAYER_WIDGET *after* SetLayout():
101  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
102  int pointSize = font.GetPointSize();
103  int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y );
104 
105  if( screenHeight <= 900 )
106  pointSize = (pointSize * 8) / 10;
107 
108  m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize );
109 
110  // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
111  // initialize parameters in m_LayersManager
112  LoadSettings( config() );
113 
114  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
115 
116  if( m_LastGridSizeId < 0 )
117  m_LastGridSizeId = 0;
120  GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
121 
122  ReCreateMenuBar();
126 
127  m_auimgr.SetManagedWindow( this );
128 
129  EDA_PANEINFO horiz;
130  horiz.HorizontalToolbarPane();
131 
132  EDA_PANEINFO vert;
133  vert.VerticalToolbarPane();
134 
135  EDA_PANEINFO mesg;
136  mesg.MessageToolbarPane();
137 
138  // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template.
139  // the Layers Manager is floatable, but initially docked at far right
140  EDA_PANEINFO lyrs;
141  lyrs.LayersToolbarPane();
142  lyrs.MinSize( m_LayersManager->GetBestSize() );
143  lyrs.BestSize( m_LayersManager->GetBestSize() );
144  lyrs.Caption( _( "Visibles" ) );
145  lyrs.TopDockable( false ).BottomDockable( false );
146 
147 
148  if( m_mainToolBar )
149  m_auimgr.AddPane( m_mainToolBar,
150  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
151 
152  if( m_auxiliaryToolBar ) // the auxiliary horizontal toolbar, that shows component and netname lists
153  {
154  m_auimgr.AddPane( m_auxiliaryToolBar,
155  wxAuiPaneInfo( horiz ).Name( wxT( "m_auxiliaryToolBar" ) ).Top().Row( 1 ) );
156  }
157 
158  if( m_drawToolBar )
159  m_auimgr.AddPane( m_drawToolBar,
160  wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
161 
162  m_auimgr.AddPane( m_LayersManager,
163  lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) );
164 
165  if( m_optionsToolBar )
166  m_auimgr.AddPane( m_optionsToolBar,
167  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
168 
169  if( m_canvas )
170  m_auimgr.AddPane( m_canvas,
171  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
172 
173  if( m_messagePanel )
174  m_auimgr.AddPane( m_messagePanel,
175  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) );
176 
177  ReFillLayerWidget(); // this is near end because contents establish size
178  m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
179  m_auimgr.Update();
180 
181  setActiveLayer( 0, true );
182  Zoom_Automatique( false ); // Gives a default zoom value
184 }
185 
186 
188 {
189 }
190 
191 
192 void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
193 {
194  Destroy();
195 }
196 
197 
198 bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
199 {
200  // The current project path is also a valid command parameter. Check if a single path
201  // rather than a file name was passed to GerbView and use it as the initial MRU path.
202  if( aFileSet.size() > 0 )
203  {
204  wxString path = aFileSet[0];
205 
206  // For some reason wxApp appears to leave the trailing double quote on quoted
207  // parameters which are required for paths with spaces. Maybe this should be
208  // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
209  // We can't buy a break!
210  if( path.Last() == wxChar( '\"' ) )
211  path.RemoveLast();
212 
213  if( !wxFileExists( path ) && wxDirExists( path ) )
214  {
215  wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
216  m_mruPath = path;
217  return true;
218  }
219 
220  const unsigned limit = std::min( unsigned( aFileSet.size() ),
221  unsigned( GERBER_DRAWLAYERS_COUNT ) );
222 
223  int layer = 0;
224 
225  for( unsigned i=0; i<limit; ++i, ++layer )
226  {
227  setActiveLayer( layer );
228 
229  // Try to guess the type of file by its ext
230  // if it is .drl (Kicad files), it is a drill file
231  wxFileName fn( aFileSet[i] );
232  wxString ext = fn.GetExt();
233 
234  if( ext == "drl" )
235  LoadExcellonFiles( aFileSet[i] );
236  else
237  LoadGerberFiles( aFileSet[i] );
238  }
239  }
240 
241  Zoom_Automatique( true ); // Zoom fit in frame
242 
244 
245  return true;
246 }
247 
248 
250 {
252 
253  // gives a size to bbox (current page size), if no item in list
254  if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
255  {
256  wxSize pagesize = GetPageSettings().GetSizeMils();
257  bbox.SetSize( wxSize( Mils2iu( pagesize.x ), Mils2iu( pagesize.y ) ) );
258  }
259 
260  // Compute best zoom:
261  wxSize size = m_canvas->GetClientSize();
262  double x = (double) bbox.GetWidth() / (double) size.x;
263  double y = (double) bbox.GetHeight() / (double) size.y;
264  double best_zoom = std::max( x, y ) * 1.1;
265 
267 
268  return best_zoom;
269 }
270 
271 
272 void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
273 {
275 
276  // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
278 
279  PAGE_INFO pageInfo( wxT( "GERBER" ) );
280 
282 
284  {
285  wxString pageType;
286  aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
287  pageInfo.SetType( pageType );
288  }
289 
290  SetPageSettings( pageInfo );
291 
292  GetScreen()->InitDataPoints( pageInfo.GetSizeIU() );
293 
294  bool tmp;
295  aCfg->Read( cfgShowDCodes, &tmp, true );
297  aCfg->Read( cfgShowNegativeObjects, &tmp, false );
299 
300  // because we have more than one file history, we must read this one
301  // using a specific path
302  aCfg->SetPath( wxT( "drl_files" ) );
303  m_drillFileHistory.Load( *aCfg );
304  aCfg->SetPath( wxT( ".." ) );
305 
306  // because we have more than one file history, we must read this one
307  // using a specific path
308  aCfg->SetPath( wxT( "zip_files" ) );
309  m_zipFileHistory.Load( *aCfg );
310  aCfg->SetPath( wxT( ".." ) );
311 }
312 
313 
314 void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
315 {
317 
318  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
320 
321  aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
323  aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
324  aCfg->Write( cfgShowNegativeObjects,
326 
327  // Save the drill file history list.
328  // Because we have more than one file history, we must save this one
329  // in a specific path
330  aCfg->SetPath( wxT( "drl_files" ) );
331  m_drillFileHistory.Save( *aCfg );
332  aCfg->SetPath( wxT( ".." ) );
333 
334  // Save the zip file history list.
335  aCfg->SetPath( wxT( "zip_files" ) );
336  m_zipFileHistory.Save( *aCfg );
337  aCfg->SetPath( wxT( ".." ) );
338 }
339 
340 
342 {
346 
347  wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
348 
349  wxSize bestz = m_LayersManager->GetBestSize();
350  bestz.x += 5; // gives a little margin
351 
352  lyrs.MinSize( bestz );
353  lyrs.BestSize( bestz );
354  lyrs.FloatingSize( bestz );
355 
356  if( lyrs.IsDocked() )
357  m_auimgr.Update();
358  else
359  m_LayersManager->SetSize( bestz );
360 
361  syncLayerWidget();
362 }
363 
364 
366  bool aNewState )
367 {
368  switch( aItemIdVisible )
369  {
370  case LAYER_DCODES:
371  m_DisplayOptions.m_DisplayDCodes = aNewState;
372  break;
373 
376  break;
377 
378  case LAYER_GERBVIEW_GRID:
379  SetGridVisibility( aNewState );
380  break;
381 
382  default:
383  wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aItemIdVisible );
384  }
385 
386  m_LayersManager->SetRenderState( aItemIdVisible, aNewState );
387 }
388 
389 
391 {
392  int layer = aLayer;
393 
394  for( unsigned i = 0; i < ImagesMaxCount(); ++i )
395  {
396  const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
397 
398  if( gerber == NULL ) // this graphic layer is available: use it
399  return layer;
400 
401  ++layer; // try next graphic layer
402 
403  if( layer >= (int)ImagesMaxCount() )
404  layer = 0;
405  }
406 
407  return NO_AVAILABLE_LAYERS;
408 }
409 
410 
412 {
415 }
416 
417 
418 void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
419 {
420  if( aRebuildLayerBox )
422 
423  m_SelLayerBox->SetSelection( getActiveLayer() );
424 
425  int dcodeSelected = -1;
427 
428  if( gerber )
429  dcodeSelected = gerber->m_Selected_Tool;
430 
431  if( m_DCodeSelector )
432  {
434  m_DCodeSelector->SetDCodeSelection( dcodeSelected );
435  m_DCodeSelector->Enable( gerber != NULL );
436  }
437 
439 }
440 
441 
443 {
444  int ii, jj;
445  wxString Line;
446  wxArrayString list;
447  double scale = g_UserUnit == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
448  int curr_layer = getActiveLayer();
449 
450  for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
451  {
452  GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
453 
454  if( gerber == NULL )
455  continue;
456 
457  if( gerber->GetDcodesCount() == 0 )
458  continue;
459 
460  if( layer == curr_layer )
461  Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
462  else
463  Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
464 
465  list.Add( Line );
466 
467  const char* units = g_UserUnit == INCHES ? "\"" : "mm";
468 
469  for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
470  {
471  D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE, false );
472 
473  if( pt_D_code == NULL )
474  continue;
475 
476  if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
477  continue;
478 
479  Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
480  jj,
481  pt_D_code->m_Num_Dcode,
482  pt_D_code->m_Size.y / scale, units,
483  pt_D_code->m_Size.x / scale, units,
484  D_CODE::ShowApertureType( pt_D_code->m_Shape ),
485  pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
486  );
487 
488  if( !pt_D_code->m_Defined )
489  Line += wxT( " (not defined)" );
490 
491  if( pt_D_code->m_InUse )
492  Line += wxT( " (in use)" );
493 
494  list.Add( Line );
495  jj++;
496  }
497  }
498 
499  wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
500  wxCHOICEDLG_STYLE & ~wxCANCEL );
501 
502  dlg.ShowModal();
503 }
504 
505 
507 {
509 
510  // Display the gerber filename
511  if( gerber == NULL )
512  {
513  SetTitle( "GerbView" );
514 
515  SetStatusText( wxEmptyString, 0 );
516 
517  wxString info;
518  info.Printf( _( "Drawing layer %d not in use" ), getActiveLayer() + 1 );
519  m_TextInfo->SetValue( info );
520 
521  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
522  m_auimgr.Update();
523 
524  ClearMsgPanel();
525  return;
526  }
527  else
528  {
529  wxString title;
530  title.Printf( L"GerbView \u2014 %s%s",
531  gerber->m_FileName,
532  gerber->m_IsX2_file
533  ? " " + _( "(with X2 attributes)" )
534  : wxString( wxEmptyString ) );
535  SetTitle( title );
536 
537  gerber->DisplayImageInfo( this );
538 
539  // Display Image Name and Layer Name (from the current gerber data):
540  wxString status;
541  status.Printf( _( "Image name: '%s' Layer name: '%s'" ),
542  GetChars( gerber->m_ImageName ),
543  GetChars( gerber->GetLayerParams().m_LayerName ) );
544  SetStatusText( status, 0 );
545 
546  // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
547  wxString info;
548  info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
549  gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
550  gerber->m_FmtLen.x - gerber->m_FmtScale.x, gerber->m_FmtScale.x,
551  gerber->m_FmtLen.y - gerber->m_FmtScale.y, gerber->m_FmtScale.y,
552  gerber->m_NoTrailingZeros ? 'T' : 'L' );
553 
554  if( gerber->m_IsX2_file )
555  info << wxT(" ") << _( "X2 attr" );
556 
557  m_TextInfo->SetValue( info );
558 
559  if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
560  m_auimgr.Update();
561  }
562 }
563 
564 
566 {
567  switch( aItemIdVisible )
568  {
569  case LAYER_DCODES:
571  break;
572 
575  break;
576 
577  case LAYER_GERBVIEW_GRID:
578  return IsGridVisible();
579  break;
580 
581  default:
582  wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aItemIdVisible );
583  }
584 
585  return true;
586 }
587 
588 
590 {
591  return -1; // TODO
592 }
593 
594 
595 void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
596 {
597 // GetGerberLayout()->SetVisibleLayers( aLayerMask );
598 }
599 
600 
601 bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
602 {
604  return m_LayersManager->IsLayerVisible( aLayer );
605  else
606  return GetGerberLayout()->IsLayerPrintable( aLayer );
607 }
608 
609 
611 {
612  COLOR4D color = COLOR4D::UNSPECIFIED;
613 
614  switch( aItemIdVisible )
615  {
617  case LAYER_DCODES:
618  color = m_colorsSettings->GetItemColor( aItemIdVisible );
619  break;
620 
621  case LAYER_GERBVIEW_GRID:
622  color = GetGridColor();
623  break;
624 
625  default:
626  wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
627  (int)aItemIdVisible );
628  }
629 
630  return color;
631 }
632 
633 
635 {
638 }
639 
640 
642  COLOR4D aColor )
643 {
644  switch( aItemIdVisible )
645  {
647  case LAYER_DCODES:
648  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
649  break;
650 
651  case LAYER_GERBVIEW_GRID:
652  SetGridColor( aColor );
653  m_colorsSettings->SetItemColor( aItemIdVisible, aColor );
654  break;
655 
656  default:
657  wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ),
658  (int) aItemIdVisible );
659  }
660 }
661 
663 {
666  else
667  return GetDrawBgColor();
668 }
669 
670 
672 {
673  return m_colorsSettings->GetLayerColor( aLayer );
674 }
675 
676 
677 void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
678 {
679  m_colorsSettings->SetLayerColor( aLayer, aColor );
680 }
681 
682 
684 {
685  return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
686 }
687 
688 
689 void GERBVIEW_FRAME::setActiveLayer( int aLayer, bool doLayerWidgetUpdate )
690 {
691  ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
692 
693  if( doLayerWidgetUpdate )
695 }
696 
697 
698 void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
699 {
700  m_paper = aPageSettings;
701 
702  if( GetScreen() )
703  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
704 }
705 
706 
708 {
709  return m_paper;
710 }
711 
712 
713 const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
714 {
715  // this function is only needed because EDA_DRAW_FRAME is not compiled
716  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
717  // into an application specific source file.
718  return GetPageSettings().GetSizeIU();
719 }
720 
721 
723 {
724  wxASSERT( m_gerberLayout );
725  return m_gerberLayout->GetTitleBlock();
726 }
727 
728 
729 void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
730 {
731  wxASSERT( m_gerberLayout );
732  m_gerberLayout->SetTitleBlock( aTitleBlock );
733 }
734 
735 
737 {
738  wxASSERT( m_gerberLayout );
739  return m_gerberLayout->GetAuxOrigin();
740 }
741 
742 
743 void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
744 {
745  wxASSERT( m_gerberLayout );
746  m_gerberLayout->SetAuxOrigin( aPosition );
747 }
748 
749 
750 void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo )
751 {
752  GetScreen()->SetCurItem( aItem );
753 
754  if( aItem )
755  {
756  if( aDisplayInfo )
757  {
758  MSG_PANEL_ITEMS items;
759  aItem->GetMsgPanelInfo( items );
760  SetMsgPanel( items );
761  }
762  }
763  else
764  {
765  EraseMsgBox();
766  }
767 }
768 
769 
771 {
773  return GetGerberLayout()->GetBoundingBox();
774 }
775 
777 {
779 
780  GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
781 
782  if( !screen )
783  return;
784 
785  int dx;
786  int dy;
787  double dXpos;
788  double dYpos;
789  wxString line;
790  wxString locformatter;
791 
792  if( m_DisplayOptions.m_DisplayPolarCood ) // display relative polar coordinates
793  {
794  double theta, ro;
795 
796  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
797  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
798 
799  // atan2 in the 0,0 case returns 0
800  theta = RAD2DEG( atan2( (double) -dy, (double) dx ) );
801 
802  ro = hypot( dx, dy );
803  wxString formatter;
804  switch( g_UserUnit )
805  {
806  case INCHES:
807  formatter = wxT( "Ro %.6f Th %.1f" );
808  break;
809 
810  case MILLIMETRES:
811  formatter = wxT( "Ro %.5f Th %.1f" );
812  break;
813 
814  case UNSCALED_UNITS:
815  formatter = wxT( "Ro %f Th %f" );
816  break;
817 
818  case DEGREES:
819  wxASSERT( false );
820  break;
821  }
822 
823  line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta );
824 
825  SetStatusText( line, 3 );
826  }
827 
828  // Display absolute coordinates:
831 
832  wxString absformatter;
833 
834  switch( g_UserUnit )
835  {
836  case INCHES:
837  absformatter = wxT( "X %.6f Y %.6f" );
838  locformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
839  break;
840 
841  case MILLIMETRES:
842  absformatter = wxT( "X %.5f Y %.5f" );
843  locformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
844  break;
845 
846  case UNSCALED_UNITS:
847  absformatter = wxT( "X %f Y %f" );
848  locformatter = wxT( "dx %f dy %f dist %f" );
849  break;
850 
851  case DEGREES:
852  wxASSERT( false );
853  break;
854  }
855 
856  line.Printf( absformatter, dXpos, dYpos );
857  SetStatusText( line, 2 );
858 
859  if( !m_DisplayOptions.m_DisplayPolarCood ) // display relative cartesian coordinates
860  {
861  // Display relative coordinates:
862  dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
863  dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
864  dXpos = To_User_Unit( g_UserUnit, dx );
865  dYpos = To_User_Unit( g_UserUnit, dy );
866 
867  // We already decided the formatter above
868  line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
869  SetStatusText( line, 3 );
870  }
871 }
872 
873 
875 {
877 }
878 
880 {
881  return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
882 }
883 
885 {
887 }
888 
889 
891 { // Called on units change (see EDA_DRAW_FRAME)
894 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:475
Class GBR_LAYOUT holds list of GERBER_DRAW_ITEM currently loaded.
GERBER_FILE_IMAGE_LIST * GetImagesList()
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
static const wxString cfgShowBorderAndTitleBlock(wxT("ShowBorderAndTitleBlock"))
wxString m_mruPath
Most recently used path.
Definition: wxstruct.h:156
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...
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:102
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:680
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
bool IsLayerPrintable(int aLayer) const
Function IsLayerPrintable tests whether a given layer is visible.
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...
wxSize m_Size
Horizontal and vertical dimensions.
Definition: dcode.h:98
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's internal state for displ...
void SetAuxOrigin(const wxPoint &aPoint) override
bool m_InUse
false if the aperure (previously defined) is not used to draw something
Definition: dcode.h:106
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:99
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:140
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
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
#define ZOOM_FACTOR(x)
Definition: classpcb.cpp:48
double RAD2DEG(double rad)
Definition: trigo.h:192
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 ...
int GetHeight() const
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void SetAuxOrigin(const wxPoint &aPosition)
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
D_CODE * GetDCODE(int aDCODE, bool aCreateIfNoExist=true)
Function GetDCODE returns a pointer to the D_CODE within this GERBER for the given aDCODE...
static const wxString cfgShowNegativeObjects(wxT("ShowNegativeObjectsOpt"))
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:361
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer which is one of the layer indices given in pcbstruct...
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
wxAuiManager m_auimgr
Definition: wxstruct.h:140
wxFileHistory m_drillFileHistory
virtual void SetGridColor(COLOR4D aColor)
Function SetGridColor() , virtual.
Definition: draw_frame.h:457
EDA_RECT ComputeBoundingBox()
Function ComputeBoundingBox calculates the bounding box containing all Gerber items.
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:53
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:527
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.
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:735
GERBVIEW_LAYER_ID
GerbView draw layers.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:466
virtual bool IsGridVisible() const
Function IsGridVisible() , virtual.
Definition: draw_frame.h:429
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)
long GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
const wxSize & GetSizeMils() const
void ReCreateHToolbar() override
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:36
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:493
bool m_Defined
false if the aperture is not defined in the header
Definition: dcode.h:108
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Function DisplayImageInfo has knowledge about the frame and how and where to put status information a...
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:309
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:125
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:286
PAGE_INFO m_paper
void ReCreateAuxiliaryToolbar() override
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:76
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:773
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void EraseMsgBox()
Definition: draw_frame.cpp:250
#define FIRST_DCODE
Definition: dcode.h:70
#define NO_AVAILABLE_LAYERS
bool LoadGerberFiles(const wxString &aFileName)
function LoadGerberFiles Load a photoplot (Gerber) file or many files.
Base window classes and related definitions.
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:128
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:112
Definition: common.h:145
int m_Num_Dcode
D code value ( >= 10 )
Definition: dcode.h:100
COLORS_DESIGN_SETTINGS * m_colorsSettings
GBR_DISPLAY_OPTIONS m_DisplayOptions
TITLE_BLOCK & GetTitleBlock()
static const wxChar * ShowApertureType(APERTURE_T aType)
Function ShowApertureType returns a character string telling what type of aperture type aType is...
Definition: dcode.cpp:94
double BestZoom() override
Return the zoom level which displays the full page on screen.
Helper dialog and control classes.
GBR_LAYOUT * m_gerberLayout
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
GBR_LAYOUT * GetGerberLayout() const
bool m_DisplayPolarCood
Option to display coordinates in status bar in X,Y or Polar coords.
wxPoint m_FramePos
Definition: wxstruct.h:130
Class GERBER_LAYER_WIDGET is here to implement the abtract functions of LAYER_WIDGET so they may be t...
bool SetType(const wxString &aStandardPageDescriptionName, bool IsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
wxPoint Centre() const
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.
int m_LastGridSizeId
Definition: draw_frame.h:77
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
#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:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:136
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:705
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
COLOR4D GetVisibleElementColor(GERBVIEW_LAYER_ID aItemIdVisible) const
Function GetVisibleElementColor returns the color of a gerber visible element.
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE ...
Definition: dcode.h:109
void setActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function setActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
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...
COLOR4D GetNegativeItemsColor() const
Function GetNegativeItemsColor.
wxFileHistory m_zipFileHistory
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
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.
void SetSize(const wxSize &size)
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:512
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:85
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
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:81
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Function GetConfigurationSettings Populates the GerbView applications settings list.
#define max(a, b)
Definition: auxiliary.h:86
void SetElementVisibility(GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
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.
int getActiveLayer()
Function getActiveLayer returns the active layer.
#define TOOLS_MAX_COUNT
Definition: dcode.h:72
struct EDA_HOTKEY_CONFIG GerbviewHokeysDescr[]
void SetLayerColor(int aLayer, COLOR4D aColor)
Function SetLayerColor changes a layer color for any valid layer.
int GetWidth() const
virtual COLOR4D GetGridColor() const
Function GetGridColor() , virtual.
Definition: draw_frame.h:448
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void syncLayerWidget()
Function syncLayerWidget updates the currently "selected" layer within the GERBER_LAYER_WIDGET.
void SetEnableBlockCommands(bool aEnable)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
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:90
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:439
wxSize m_FrameSize
Definition: wxstruct.h:131
EDA_RECT GetBoundingBox() const
Function GetBoundingBox may be called soon after ComputeBoundingBox() to return the same EDA_RECT...
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:243
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
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 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.
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:669
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:764
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...
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)
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