KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <kiface_base.h>
22#include <base_units.h>
23#include <pgm_base.h>
24#include <bitmaps.h>
27#include <gerbview_frame.h>
28#include <gerbview_id.h>
29#include <gerber_file_image.h>
31#include <excellon_image.h>
33#include <gerbview_settings.h>
35#include <lset.h>
37#include <toolbars_gerber.h>
38#include <tool/tool_manager.h>
39#include <tool/action_toolbar.h>
41#include <tool/common_control.h>
42#include <tool/common_tools.h>
44#include <tool/zoom_tool.h>
50#include <trigo.h>
51#include <view/view.h>
52#include <view/view_controls.h>
53#include <base_screen.h>
54#include <gerbview_painter.h>
55#include <wx/wupdlock.h>
56
61#include <zoom_defines.h>
62
64#include <wx/log.h>
65
66GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
67 EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
70 m_TextInfo( nullptr ),
72 ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
74 ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
76 ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
77 m_activeLayer( 0 )
78{
80 m_gerberLayout = nullptr;
82 m_showBorderAndTitleBlock = false; // true for reference drawings.
83 m_SelLayerBox = nullptr;
84 m_DCodeSelector = nullptr;
85 m_SelComponentBox = nullptr;
86 m_SelNetnameBox = nullptr;
87 m_SelAperAttributesBox = nullptr;
88 m_cmpText = nullptr;
89 m_netText = nullptr;
90 m_apertText = nullptr;
91 m_dcodeText = nullptr;
92 m_aboutTitle = _HKI( "KiCad Gerber Viewer" );
93
94 SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
95 // some methods in code and avoid link errors
96
97 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
98 m_drillFileHistory.SetMaxFiles( fileHistorySize );
99 m_zipFileHistory.SetMaxFiles( fileHistorySize );
100 m_jobFileHistory.SetMaxFiles( fileHistorySize );
101
102 auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
105
106 SetCanvas( galCanvas );
107
108 // GerbView requires draw priority for rendering negative objects
109 galCanvas->GetView()->UseDrawPriority( true );
110
111 // Give an icon
112 wxIcon icon;
113 wxIconBundle icon_bundle;
114
115 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 48 ) );
116 icon_bundle.AddIcon( icon );
117 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 128 ) );
118 icon_bundle.AddIcon( icon );
119 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 256 ) );
120 icon_bundle.AddIcon( icon );
121 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
122 icon_bundle.AddIcon( icon );
123 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
124 icon_bundle.AddIcon( icon );
125
126 SetIcons( icon_bundle );
127
128 // Be sure a page info is set. this default value will be overwritten later.
129 PAGE_INFO pageInfo( wxT( "GERBER" ) );
130 SetLayout( new GBR_LAYOUT() );
131 SetPageSettings( pageInfo );
132
133 SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
134
136
137 // Create the PCB_LAYER_WIDGET *after* SetLayout():
139
140 // Update the minimum string length in the layer panel with the length of the last default layer
141 wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
142 false, true );
144
145 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
146 // initialize parameters in m_LayersManager
147 LoadSettings( config() );
148
149 setupTools();
152
156
157 m_auimgr.SetManagedWindow( this );
158
159 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer( 6 ) );
160 m_auimgr.AddPane( m_tbTopAux, EDA_PANE().HToolbar().Name( "TopAuxToolbar" ).Top()
161 .Layer(4) );
162 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
163 .Layer( 6 ) );
164 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "LeftToolbar" ).Left()
165 .Layer( 3 ) );
166 m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
167 .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
168 .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
169
170 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
171
172 ReFillLayerWidget(); // this is near end because contents establish size
173 m_auimgr.Update();
174
175 SetActiveLayer( 0, true );
177
179
181
182 setupUnits( config() );
183
184 // Enable the axes to match legacy draw style
185 auto& galOptions = GetGalDisplayOptions();
186 galOptions.m_axesEnabled = true;
187 galOptions.NotifyChanged();
188
190 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
191
192 // Drag and drop
193 // Note that all gerber files are aliased as GerberFileExtension
197 DragAcceptFiles( true );
198
200
201 // Ensure the window is on top
202 Raise();
203
204 // Register a call to update the toolbar sizes. It can't be done immediately because
205 // it seems to require some sizes calculated that aren't yet (at least on GTK).
206 CallAfter( [this]()
207 {
208 // Ensure the controls on the toolbars all are correctly sized
210 } );
211}
212
213
215{
216 // Ensure m_canvasType is up to date, to save it in config
218
219 // Shutdown all running tools
220 if( m_toolManager )
222
223 GetCanvas()->GetView()->Clear();
224
226 delete m_gerberLayout;
227}
228
229
231{
232 // No more vetos
233 m_isClosing = true;
235
236 if( m_toolManager )
238
239 // Be sure any OpenGL event cannot be fired after frame deletion:
240 GetCanvas()->SetEvtHandlerEnabled( false );
241
242 Destroy();
243}
244
245
246bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
247{
248 // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
249 // when trying to change the view if it is not fully initialized.
250 // It happens when starting GerbView with a gerber job file to load
251 if( !IsShownOnScreen() )
252 Show();
253
254 // The current project path is also a valid command parameter. Check if a single path
255 // rather than a file name was passed to GerbView and use it as the initial MRU path.
256 if( aFileSet.size() > 0 )
257 {
258 wxString path = aFileSet[0];
259
260 // For some reason wxApp appears to leave the trailing double quote on quoted
261 // parameters which are required for paths with spaces. Maybe this should be
262 // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
263 // We can't buy a break!
264 if( path.Last() == wxChar( '\"' ) )
265 path.RemoveLast();
266
267 if( !wxFileExists( path ) && wxDirExists( path ) )
268 {
269 m_mruPath = path;
270 return true;
271 }
272
273 const unsigned limit = std::min( unsigned( aFileSet.size() ),
274 unsigned( GERBER_DRAWLAYERS_COUNT ) );
275
276 for( unsigned i = 0; i < limit; ++i )
277 {
278 wxString ext = wxFileName( aFileSet[i] ).GetExt().Lower();
279
281 LoadZipArchiveFile( aFileSet[i] );
282 else if( ext == FILEEXT::GerberJobFileExtension )
283 LoadGerberJobFile( aFileSet[i] );
284 else
285 {
286 GERBER_ORDER_ENUM fnameLayer;
287 wxString fnameExtensionMatched;
288
290 fnameExtensionMatched );
291
292 switch( fnameLayer )
293 {
294 case GERBER_ORDER_ENUM::GERBER_DRILL:
295 LoadExcellonFiles( aFileSet[i] );
296 break;
297 case GERBER_ORDER_ENUM::GERBER_LAYER_UNKNOWN:
298 LoadAutodetectedFiles( aFileSet[i] );
299 break;
300 default:
301 LoadGerberFiles( aFileSet[i] );
302 }
303 }
304 }
305 }
306
307 Zoom_Automatique( true ); // Zoom fit in frame
308
309 return true;
310}
311
312
314{
315 return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
316}
317
318
320{
322
323 if( aCfg->m_Window.grid.grids.empty() )
324 {
325 aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
326 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
327 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
328 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
329 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
330 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
331 GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) },
332 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
333 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
334 GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) },
335 GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) },
336 GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) },
337 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
338 GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) },
339 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
340 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
341 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
342 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
343 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
344 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) },
345 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) },
346 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } };
347 }
348
349 if( aCfg->m_Window.zoom_factors.empty() )
350 {
352 }
353
354 GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
355 wxCHECK( cfg, /*void*/ );
356
361
362 PAGE_INFO pageInfo( wxT( "GERBER" ) );
363 pageInfo.SetType( cfg->m_Appearance.page_type );
364 SetPageSettings( pageInfo );
365
368
372}
373
374
376{
378
379 GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
380 wxCHECK( cfg, /*void*/ );
381
383
387
389 Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
390}
391
392
394{
396 GERBVIEW_SETTINGS* cfg = mgr.GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
397 wxString currentTheme = cfg->m_ColorTheme;
398 return mgr.GetColorSettings( currentTheme );
399}
400
401
403{
404 wxWindowUpdateLocker no_update( m_LayersManager );
405
408
409 // Re-build the various boxes in the toolbars
410 // TODO: Could this be made more precise instead of just blowing away all the toolbars?
412
413 wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
414 wxSize bestz = m_LayersManager->GetBestSize();
415 bestz.x += 5; // gives a little margin
416
417 lyrs.MinSize( bestz );
418 lyrs.BestSize( bestz );
419 lyrs.FloatingSize( bestz );
420
421 if( lyrs.IsDocked() )
422 m_auimgr.Update();
423 else
424 m_LayersManager->SetSize( bestz );
425
427}
428
429
430void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
431{
432 KIGFX::VIEW* view = GetCanvas()->GetView();
433
434 switch( aLayerID )
435 {
436 case LAYER_DCODES:
437 gvconfig()->m_Appearance.show_dcodes = aNewState;
438
439 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
440 {
441 int layer = GERBER_DRAW_LAYER( i );
442 int dcode_layer = GERBER_DCODE_LAYER( layer );
443 view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
444 }
445
446 break;
447
449 {
451
453 []( KIGFX::VIEW_ITEM* aItem )
454 {
455 GERBER_DRAW_ITEM* item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
456
457 // GetLayerPolarity() returns true for negative items
458 return ( item && item->GetLayerPolarity() );
459 } );
460
461 break;
462 }
463
466
468
469 // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
470 // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
472 break;
473
475 SetGridVisibility( aNewState );
476 break;
477
481 break;
482
483 default:
484 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ),
485 aLayerID ) );
486 }
487
489 m_LayersManager->SetRenderState( aLayerID, aNewState );
490}
491
492
494{
495 auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
496 KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
498 settings->LoadColors( GetColorSettings() );
499
501}
502
503
505{
506 for( int i = 0; i < (int) ImagesMaxCount(); ++i )
507 {
508 const GERBER_FILE_IMAGE* gerber = GetGbrImage( i );
509
510 if( gerber == nullptr ) // this graphic layer is available: use it
511 return i;
512 }
513
514 return NO_AVAILABLE_LAYERS;
515}
516
517
519{
521}
522
523
524void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
525{
526 if( aRebuildLayerBox )
528
529 m_SelLayerBox->SetSelection( GetActiveLayer() );
530
531 int dcodeSelected = -1;
533
534 if( gerber )
535 dcodeSelected = gerber->m_Selected_Tool;
536
537 if( m_DCodeSelector )
538 {
540 m_DCodeSelector->SetDCodeSelection( dcodeSelected );
541 m_DCodeSelector->Enable( gerber != nullptr );
542 }
543}
544
545
547{
548 RemapLayers( GetImagesList()->SortImagesByFileExtension() );
549}
550
551
553{
554 RemapLayers( GetImagesList()->SortImagesByZOrder() );
555}
556
557
558void GERBVIEW_FRAME::RemapLayers( const std::unordered_map<int, int>& remapping )
559{
560 // Save the visibility of each existing gerber layer, in order to be able
561 // to restore this visibility after layer reorder.
562 // Note: the visibility of other objects (D_CODE, negative objects ... )
563 // must be not modified
564 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
565 {
566 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
567
568 if( gerber )
569 {
570 if( IsLayerVisible( currlayer ) )
571 gerber->SetFlags( CANDIDATE );
572 else
573 gerber->ClearFlags( CANDIDATE );
574 }
575
576 }
577
578 std::unordered_map<int, int> view_remapping;
579
580 for( const std::pair<const int, int>& entry : remapping )
581 {
582 view_remapping[ GERBER_DRAW_LAYER( entry.first ) ] = GERBER_DRAW_LAYER( entry.second );
583 view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second );
584 }
585
586 GetCanvas()->GetView()->ReorderLayerData( view_remapping );
587
588 // Restore visibility of gerber layers
589 LSET newVisibility = GetVisibleLayers();
590
591 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
592 {
593 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
594
595 if( gerber )
596 {
597 if( gerber->HasFlag( CANDIDATE ) )
598 newVisibility.set( currlayer );
599 else
600 newVisibility.set( currlayer, false );
601
602 gerber->ClearFlags( CANDIDATE );
603 }
604 }
605
606 SetVisibleLayers( newVisibility );
607
609 syncLayerBox( true );
610
611 // Reordering draw layers need updating the view items
615
616 GetCanvas()->Refresh();
617}
618
619
621{
622 // Adjust draw params: draw offset and draw rotation for a gerber file image
624
625 if( !gerber )
626 return;
627
628 DIALOG_DRAW_LAYERS_SETTINGS dlg( this );
629
630 if( dlg.ShowModal() != wxID_OK )
631 return;
632
633 KIGFX::VIEW* view = GetCanvas()->GetView();
634
635 view->RecacheAllItems();
636 view->MarkDirty();
637 view->UpdateAllItems( KIGFX::ALL );
638
639 GetCanvas()->Refresh();
640}
641
642
644{
648 KIGFX::VIEW* view = GetCanvas()->GetView();
649
650 int lastVisibleLayer = -1;
651
652 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
653 {
654 view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_XORMode );
655
656 // Caching doesn't work with layered rendering of XOR'd layers
657 if( gvconfig()->m_Display.m_XORMode )
659 else
660 view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
661
662 // We want the last visible layer, but deprioritize the active layer unless it's the
663 // only layer
664 if( ( lastVisibleLayer == -1 )
665 || ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
666 {
667 lastVisibleLayer = i;
668 }
669 }
670
671 //We don't want to diff the last visible layer onto the background, etc.
672 if( lastVisibleLayer != -1 )
673 {
674 view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
675 view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
676 }
677
678 view->RecacheAllItems();
679 view->MarkDirty();
680 view->UpdateAllItems( KIGFX::ALL );
681}
682
683
685{
687
688 // Display the gerber filename
689 if( gerber == nullptr )
690 {
691 SetTitle( _("Gerber Viewer") );
692
693 SetStatusText( wxEmptyString, 0 );
694
695 wxString info;
696 info.Printf( _( "Drawing layer not in use" ) );
697 m_TextInfo->SetValue( info );
698
699 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
700 m_auimgr.Update();
701
703 return;
704 }
705 else
706 {
707 wxString title;
708 wxFileName filename( gerber->m_FileName );
709
710 title = filename.GetFullName();
711
712 if( gerber->m_IsX2_file )
713 title += wxS( " " ) + _( "(with X2 attributes)" );
714
715 title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
716 SetTitle( title );
717
718 gerber->DisplayImageInfo( this );
719
720 // Display Image Name and Layer Name (from the current gerber data):
721 wxString status;
722 status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
723 gerber->m_ImageName,
724 gerber->GetLayerParams().m_LayerName );
725 SetStatusText( status, 0 );
726
727 // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
728 wxString info;
729 info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
730 gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
731 gerber->m_FmtLen.x - gerber->m_FmtScale.x,
732 gerber->m_FmtScale.x,
733 gerber->m_FmtLen.y - gerber->m_FmtScale.y,
734 gerber->m_FmtScale.y,
735 gerber->m_NoTrailingZeros ? 'T' : 'L' );
736
737 if( gerber->m_IsX2_file )
738 info << wxT(" ") << _( "X2 attr" );
739
740 m_TextInfo->SetValue( info );
741
742 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
743 m_auimgr.Update();
744 }
745}
746
747
748bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
749{
750 switch( aLayerID )
751 {
754 case LAYER_GERBVIEW_GRID: return IsGridVisible();
757 case LAYER_GERBVIEW_BACKGROUND: return true;
758
759 default:
760 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ),
761 aLayerID ) );
762 }
763
764 return true;
765}
766
767
769{
770 LSET visible = LSET::AllLayersMask();
771
772 if( GetCanvas() )
773 {
774 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
775 visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
776 }
777
778 return visible;
779}
780
781
782void GERBVIEW_FRAME::SetVisibleLayers( const LSET& aLayerMask )
783{
784 if( GetCanvas() )
785 {
786 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
787 {
788 bool v = aLayerMask[i];
789 int layer = GERBER_DRAW_LAYER( i );
790 GetCanvas()->GetView()->SetLayerVisible( layer, v );
792 gvconfig()->m_Appearance.show_dcodes && v );
793 }
794 }
795}
796
797
798bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
799{
800 return m_LayersManager->IsLayerVisible( aLayer );
801}
802
803
805{
806 COLOR4D color = COLOR4D::UNSPECIFIED;
807 COLOR_SETTINGS* settings = GetColorSettings();
808
809 switch( aLayerID )
810 {
812 case LAYER_DCODES:
816 color = settings->GetColor( aLayerID );
817 break;
818
821 break;
822
823 default:
824 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
825 aLayerID ) );
826 }
827
828 return color;
829}
830
831
833{
836}
837
838
839void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
840{
841 COLOR_SETTINGS* settings = GetColorSettings();
842
843 settings->SetColor( aLayerID, aColor );
844
845 switch( aLayerID )
846 {
850 break;
851
853 SetGridColor( aColor );
854 break;
855
857 SetDrawBgColor( aColor );
858 break;
859
860 default:
861 break;
862 }
863}
864
865
867{
868 return GetColorSettings()->GetColor( aLayer );
869}
870
871
872void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
873{
874 GetColorSettings()->SetColor( aLayer, aColor );
876}
877
878
879void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
880{
881 m_activeLayer = aLayer;
882
883 if( gvconfig()->m_Display.m_XORMode )
885
886 if( doLayerWidgetUpdate )
887 {
888 m_LayersManager->SelectLayer( aLayer );
890 }
891
893
895 GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
896
898 GetCanvas()->Refresh();
899}
900
901
902void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
903{
904 m_paper = aPageSettings;
905
906 if( GetScreen() )
908
909 GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
910
911 // Prepare drawing-sheet template
913 &Prj(), &GetTitleBlock(), nullptr );
914
915 if( GetScreen() )
916 {
917 drawingSheet->SetPageNumber( "1" );
918 drawingSheet->SetSheetCount( 1 );
919 }
920
923
924 // Draw panel takes ownership of the drawing-sheet
925 drawPanel->SetDrawingSheet( drawingSheet );
926}
927
928
930{
931 return m_paper;
932}
933
934
936{
937 // this function is only needed because EDA_DRAW_FRAME is not compiled
938 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
939 // into an application specific source file.
941}
942
943
945{
946 wxASSERT( m_gerberLayout );
948}
949
950
952{
953 wxASSERT( m_gerberLayout );
954 m_gerberLayout->SetTitleBlock( aTitleBlock );
955}
956
957
959{
961}
962
963
965{
967 GetCanvas()->GetGAL()->SetGridColor( aColor );
968 m_gridColor = aColor;
969}
970
971
973{
974 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
975 wxString line;
976
977 line.Printf( wxT( "grid X %s Y %s" ),
978 MessageTextFromValue( gridSize.x, false ),
979 MessageTextFromValue( gridSize.y, false ) );
980
981 SetStatusText( line, 4 );
982 SetStatusText( line, 4 );
983}
984
985
987{
989
990 if( !GetScreen() )
991 return;
992
993 wxString line;
995
996 if( GetShowPolarCoords() ) // display relative polar coordinates
997 {
998 VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
999 EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
1000 double ro = hypot( v.x, v.y );
1001
1002 line.Printf( wxT( "r %s theta %s" ),
1003 MessageTextFromValue( ro, false ),
1004 MessageTextFromValue( theta, false ) );
1005
1006 SetStatusText( line, 3 );
1007 }
1008
1009 // Display absolute coordinates:
1010 line.Printf( wxT( "X %s Y %s" ),
1011 MessageTextFromValue( cursorPos.x, false ),
1012 MessageTextFromValue( cursorPos.y, false ) );
1013 SetStatusText( line, 2 );
1014
1015 if( !GetShowPolarCoords() )
1016 {
1017 // Display relative cartesian coordinates:
1018 double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
1019 double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
1020
1021 line.Printf( wxT( "dx %s dy %s dist %s" ),
1022 MessageTextFromValue( dXpos, false ),
1023 MessageTextFromValue( dYpos,false ),
1024 MessageTextFromValue( hypot( dXpos, dYpos ), false ) );
1025 SetStatusText( line, 3 );
1026 }
1027
1029}
1030
1031
1033{
1034 return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1035}
1036
1037
1039{
1041}
1042
1043
1045{
1046 // Called on units change (see EDA_DRAW_FRAME)
1050}
1051
1052
1054{
1056
1057 EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1058
1059 if( m_toolManager )
1060 {
1062 GetCanvas()->GetViewControls(), config(), this );
1064 }
1065
1067
1069
1070 galCanvas->GetView()->RecacheAllItems();
1072 galCanvas->StartDrawing();
1073
1076
1079
1080 try
1081 {
1082 if( !m_spaceMouse )
1083 m_spaceMouse = std::make_unique<NL_GERBVIEW_PLUGIN>();
1084
1085 m_spaceMouse->SetCanvas( galCanvas );
1086 }
1087 catch( const std::system_error& e )
1088 {
1089 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1090 }
1091}
1092
1093
1095{
1096 // Create the manager and dispatcher & route draw panel events to the dispatcher
1099 GetCanvas()->GetViewControls(), config(), this );
1102
1103 // Register tools
1111
1112 // Run the selection tool, it is supposed to be always active
1113 m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1114}
1115
1116
1118{
1120
1122 EDITOR_CONDITIONS cond( this );
1123
1124 wxASSERT( mgr );
1125
1126#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1127#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1128
1132
1136
1137 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MM ) ) );
1138 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCH ) ) );
1139 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1140
1141 auto flashedDisplayOutlinesCond =
1142 [this] ( const SELECTION& )
1143 {
1145 };
1146
1147 auto linesFillCond =
1148 [this] ( const SELECTION& )
1149 {
1151 };
1152
1153 auto polygonsFilledCond =
1154 [this] ( const SELECTION& )
1155 {
1157 };
1158
1159 auto negativeObjectsCond =
1160 [this] ( const SELECTION& )
1161 {
1163 };
1164
1165 auto dcodeCond =
1166 [this] ( const SELECTION& )
1167 {
1169 };
1170
1171 auto forceOpacityModeCond =
1172 [this] ( const SELECTION& )
1173 {
1175 };
1176
1177 auto xorModeCond =
1178 [this] ( const SELECTION& )
1179 {
1180 return gvconfig()->m_Display.m_XORMode;
1181 };
1182
1183 auto highContrastModeCond =
1184 [this] ( const SELECTION& )
1185 {
1187 };
1188
1189 auto flipGerberCond =
1190 [this] ( const SELECTION& )
1191 {
1193 };
1194
1195 auto layersManagerShownCondition =
1196 [this] ( const SELECTION& aSel )
1197 {
1199 };
1200
1201 mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1203 mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1204 mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1206 mgr->SetConditions( GERBVIEW_ACTIONS::toggleForceOpacityMode, CHECK( forceOpacityModeCond ) );
1207 mgr->SetConditions( GERBVIEW_ACTIONS::toggleXORMode, CHECK( xorModeCond ) );
1208 mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1209 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1210 mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, CHECK( layersManagerShownCondition ) );
1211
1212#undef CHECK
1213#undef ENABLE
1214}
1215
1216
1218{
1220
1221 // Update gal display options like cursor shape, grid options:
1223 GERBVIEW_SETTINGS* cfg = mgr.GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" );
1224
1226
1227 SetPageSettings( PAGE_INFO( gvconfig()->m_Appearance.page_type ) );
1228
1230
1231 SetElementVisibility( LAYER_DCODES, gvconfig()->m_Appearance.show_dcodes );
1232
1236
1238 ReFillLayerWidget(); // Update the layers list
1239 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
1240
1241 Layout();
1242 SendSizeEvent();
1243}
1244
1245
1247{
1248 return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1249}
1250
1251
1253{
1255
1256 // show/hide auxiliary Vertical layers and visibility manager toolbar
1257 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1258 m_auimgr.Update();
1259}
1260
1261void GERBVIEW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1262{
1264
1265 if( m_spaceMouse )
1266 m_spaceMouse->SetFocus( aEvent.GetActive() );
1267}
1268
1269void GERBVIEW_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
1270{
1272
1273 if( m_spaceMouse )
1274 m_spaceMouse->SetFocus( false );
1275}
int color
Definition: DXF_plotter.cpp:60
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE gerbIUScale
Definition: base_units.h:107
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:104
static TOOL_ACTION toggleGrid
Definition: actions.h:191
static TOOL_ACTION millimetersUnits
Definition: actions.h:199
static TOOL_ACTION togglePolarCoords
Definition: actions.h:202
static TOOL_ACTION milsUnits
Definition: actions.h:198
static TOOL_ACTION inchesUnits
Definition: actions.h:197
static TOOL_ACTION highContrastMode
Definition: actions.h:145
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:144
static TOOL_ACTION measureTool
Definition: actions.h:207
static TOOL_ACTION selectionTool
Definition: actions.h:206
static TOOL_ACTION zoomFitScreen
Definition: actions.h:134
static TOOL_ACTION zoomTool
Definition: actions.h:138
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
WINDOW_SETTINGS m_Window
Definition: app_settings.h:213
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:216
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:41
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:90
void InitDataPoints(const VECTOR2I &aPageSizeInternalUnits)
Definition: base_screen.cpp:46
BASE_SET & set(size_t pos)
Definition: base_set.h:116
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) const
Handle actions that are shared between different applications.
Handles action that are shared between different applications.
Definition: common_tools.h:38
void SetDCodeSelection(int aDCodeId)
int ShowModal() override
void SetSheetCount(int aSheetCount)
Change the sheet-count number displayed in the title block.
void SetPageNumber(const std::string &aPageNumber)
Change the page number displayed in the title block.
void SetPageBorderColorLayer(int aLayerId)
Override the layer used to pick the color of the page border (normally LAYER_GRID)
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for drawing sheet item colors.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
TOOLBAR_SETTINGS * m_toolbarSettings
wxAuiManager m_auimgr
virtual void RecreateToolbars()
ACTION_TOOLBAR * m_tbLeft
ACTION_TOOLBAR * m_tbTopAux
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
ACTION_TOOLBAR * m_tbTopMain
wxString m_aboutTitle
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
wxString m_mruPath
void ReCreateMenuBar()
Recreate the menu bar.
The base class for create windows for drawing purpose.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
The current canvas type.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void setupUnits(APP_SETTINGS_BASE *aCfg)
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
EDA_MSG_PANEL * m_messagePanel
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
virtual void SetScreen(BASE_SCREEN *aScreen)
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.
virtual void SetGridVisibility(bool aVisible)
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
virtual void SetDrawBgColor(const COLOR4D &aColor)
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
bool IsGridVisible() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
bool m_showBorderAndTitleBlock
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetFocus() override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void StartDrawing()
Begin drawing if it was stopped previously.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:131
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:133
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:135
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class that groups generic conditions for editor states.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_XORMode
Display layers in exclusive-or mode.
bool m_FlipGerberView
Display as a mirror image.
bool m_ForceOpacityMode
Display layers in transparency (alpha channel) forced mode.
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition: gbr_layout.h:46
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
Definition: gbr_layout.h:64
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Definition: gbr_layout.cpp:41
TITLE_BLOCK & GetTitleBlock()
Definition: gbr_layout.h:63
bool GetLayerPolarity() const
static void GetGerberLayerFromFilename(const wxString &filename, enum GERBER_ORDER_ENUM &order, wxString &matchedExtension)
Utility function to guess which PCB layer of a gerber/drill file corresponds to based on its file ext...
const wxString GetDisplayName(int aIdx, bool aNameOnly=false, bool aFullName=false)
Get the display name for the layer at aIdx.
void DeleteAllImages()
Remove all loaded data in list, and delete all images, freeing the memory.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
Hold the image data and parameters for one gerber file and layer parameters.
wxSize m_FmtScale
Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
wxString m_FileName
Full File Name for this layer.
wxString m_ImageName
Image name, from IN <name>* command.
bool m_IsX2_file
True if a X2 gerber attribute was found in file.
wxSize m_FmtLen
Nb chars per coord. ex fmt 2.3, m_FmtLen = 5.
bool m_GerbMetric
false = Inches, true = metric
bool m_NoTrailingZeros
true: remove tailing zeros.
GERBER_LAYER & GetLayerParams()
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Display information about image parameters in the status bar.
Abstract functions of LAYER_WIDGET so they may be tied into the GERBVIEW_FRAME's data and we can add ...
bool OnLayerSelected()
Ensure the active layer is visible, and other layers not visible when m_alwaysShowActiveLayer is true...
void ReFillRender()
Rebuild Render for instance after the config is read.
void ReFill()
Rebuild Render for instance after the config is read.
wxString m_LayerName
Gather all the actions that are shared by tools.
static TOOL_ACTION dcodeDisplay
static TOOL_ACTION negativeObjectDisplay
static TOOL_ACTION flashedDisplayOutlines
static TOOL_ACTION toggleXORMode
static TOOL_ACTION loadZipFile
static TOOL_ACTION toggleLayerManager
static TOOL_ACTION flipGerberView
static TOOL_ACTION toggleForceOpacityMode
static TOOL_ACTION linesDisplayOutlines
static TOOL_ACTION polygonsDisplayOutlines
static TOOL_ACTION layerChanged
static TOOL_ACTION loadGerbFiles
Handle actions that are shared between different frames in Pcbnew.
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update the drawing-sheet (borders and title block) used by the draw panel.
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
wxStaticText * m_dcodeText
wxChoice * m_SelAperAttributesBox
void UpdateXORLayers()
Update each layers' differential option.
void UpdateStatusBar() override
Update the status bar information.
void configureToolbars() override
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
GERBVIEW_SETTINGS * gvconfig() const
const PAGE_INFO & GetPageSettings() const override
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void SortLayersByX2Attributes()
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
bool m_show_layer_manager_tools
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
GBR_LAYOUT * m_gerberLayout
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void ApplyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
PAGE_INFO m_paper
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
wxStaticText * m_cmpText
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
GBR_LAYOUT * GetGerberLayout() const
bool LoadGerberFiles(const wxString &aFileName)
Load a given Gerber file or selected file(s), if the filename is empty.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void doCloseWindow() override
wxChoice * m_SelComponentBox
FILE_HISTORY m_jobFileHistory
std::unique_ptr< NL_GERBVIEW_PLUGIN > m_spaceMouse
wxChoice * m_SelNetnameBox
int GetActiveLayer() const
Return the active layer.
wxTextCtrl * m_TextInfo
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
DCODE_SELECTION_BOX * m_DCodeSelector
GERBER_LAYER_WIDGET * m_LayersManager
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
wxStaticText * m_netText
void SetVisibleLayers(const LSET &aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void syncLayerWidget()
Update the currently "selected" layer within the GERBER_LAYER_WIDGET.
void SetVisibleElementColor(int aLayerID, const COLOR4D &aColor)
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
unsigned ImagesMaxCount() const
The max number of file images.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
wxStaticText * m_apertText
COLOR4D GetLayerColor(int aLayer) const
void SortLayersByFileExtension()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
void SetGridVisibility(bool aVisible) override
void CommonSettingsChanged(int aFlags) override
Called after the preferences dialog is run.
const TITLE_BLOCK & GetTitleBlock() const override
bool LoadAutodetectedFiles(const wxString &aFileName)
Load a given file or selected file(s), if the filename is empty.
void RemapLayers(const std::unordered_map< int, int > &remapping)
Takes a layer remapping and reorders the layers.
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
FILE_HISTORY m_zipFileHistory
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
int getNextAvailableLayer() const
Find the next empty layer.
bool LoadZipArchiveFile(const wxString &aFileName)
Load a zipped archive file.
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
virtual void SetGridColor(const COLOR4D &aColor) override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
FILE_HISTORY m_drillFileHistory
bool LoadExcellonFiles(const wxString &aFileName)
Load a drill (EXCELLON) file or many files.
COLOR4D GetGridColor() override
Selection tool for GerbView, based on the one in Pcbnew.
std::vector< wxString > m_JobFileHistory
std::vector< wxString > m_DrillFileHistory
GBR_DISPLAY_OPTIONS m_Display
std::vector< wxString > m_ZipFileHistory
Toolbar configuration for gerbview.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
const VECTOR2D & GetGridSize() const
Return the grid size.
Methods for drawing GerbView specific items.
Store GerbView specific render settings.
void LoadColors(const COLOR_SETTINGS *aSettings) override
void SetHighContrast(bool aEnabled)
Turns on/off high contrast display mode.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:86
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition: view.h:434
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
Definition: view.h:493
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:396
void Clear()
Remove all items from the view.
Definition: view.cpp:1131
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1439
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1549
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:655
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:418
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:216
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:635
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1559
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:670
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:285
void SetRenderState(int aId, bool isSet)
Set the state of the checkbox associated with aId within the Render tab group of the widget.
void SelectLayer(int aLayer)
Change the row selection in the layer list to aLayer provided.
bool IsLayerVisible(int aLayer)
Return the visible state of the layer ROW associated with aLayer id.
wxSize GetBestSize() const
Return the preferred minimum size, taking into consideration the dynamic content.
void SetSmallestLayerString(const wxString &aString)
Set the string that is used for determining the smallest string displayed in the layer's tab.
Definition: layer_widget.h:141
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
static LSET AllLayersMask()
Definition: lset.cpp:601
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:59
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition: page_info.h:171
const wxString & GetType() const
Definition: page_info.h:99
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:121
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:687
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve a color settings object that applications can read colors from.
T * GetToolbarSettings(const wxString &aFilename)
Return a handle to the given toolbar settings.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
Represent a set of closed polygons.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:41
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:171
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:173
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:172
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:82
Master controller class:
Definition: tool_manager.h:62
void DeactivateTool()
Deactivate the currently active tool.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:306
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Reset all tools (i.e.
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
void InitTools()
Initialize all registered tools.
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
#define CHECK(x)
#define _HKI(x)
#define _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define CANDIDATE
flag indicating that the structure is connected
@ FRAME_GERBER
Definition: frame_type.h:57
#define NO_AVAILABLE_LAYERS
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
@ ID_GERBVIEW_JOB_FILE_LIST_CLEAR
Definition: gerbview_id.h:62
@ ID_GERBVIEW_DRILL_FILE1
Definition: gerbview_id.h:54
@ ID_GERBVIEW_ZIP_FILE_LIST_CLEAR
Definition: gerbview_id.h:68
@ ID_GERBVIEW_JOB_FILE1
Definition: gerbview_id.h:60
@ ID_GERBVIEW_ZIP_FILE1
Definition: gerbview_id.h:66
@ ID_GERBVIEW_DRILL_FILE_LIST_CLEAR
Definition: gerbview_id.h:56
static const std::string GerberJobFileExtension
static const std::string GerberFileExtension
static const std::string DrillFileExtension
static const std::string ArchiveFileExtension
#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:67
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:521
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:520
@ LAYER_DCODES
Definition: layer_ids.h:516
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:517
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition: layer_ids.h:522
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:518
#define GERBER_DCODE_LAYER(x)
Definition: layer_ids.h:529
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition: layer_ids.h:277
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
Definition: layer_ids.h:506
#define GERBER_DRAW_LAYER(x)
Definition: layer_ids.h:527
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:58
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:59
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:38
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:37
KICOMMON_API bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Definition: ui_common.cpp:168
Declaration of the NL_GERBVIEW_PLUGIN class.
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
see class PGM_BASE
std::vector< FAB_LAYER_COLOR > dummy
const double IU_PER_MILS
Definition: base_units.h:77
std::vector< GRID > grids
Definition: grid_settings.h:66
Common grid settings, available to every frame.
Definition: grid_settings.h:34
GRID_SETTINGS grid
Definition: app_settings.h:81
std::vector< double > zoom_factors
Definition: app_settings.h:78
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694
Definition of file extensions used in Kicad.
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29