KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerbview_frame.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 1992-2024 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>
36#include <tool/tool_manager.h>
37#include <tool/action_toolbar.h>
39#include <tool/common_control.h>
40#include <tool/common_tools.h>
42#include <tool/zoom_tool.h>
48#include <trigo.h>
49#include <view/view.h>
50#include <base_screen.h>
51#include <gerbview_painter.h>
52#include <wx/wupdlock.h>
53
58#include <zoom_defines.h>
59
60
61GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
62 : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
65 m_TextInfo( nullptr ),
67 ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
69 ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
71 ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
72 m_activeLayer( 0 )
73{
75 m_gerberLayout = nullptr;
77 m_showBorderAndTitleBlock = false; // true for reference drawings.
78 m_SelLayerBox = nullptr;
79 m_DCodeSelector = nullptr;
80 m_SelComponentBox = nullptr;
81 m_SelNetnameBox = nullptr;
82 m_SelAperAttributesBox = nullptr;
83 m_cmpText = nullptr;
84 m_netText = nullptr;
85 m_apertText = nullptr;
86 m_dcodeText = nullptr;
87 m_displayMode = 0;
88 m_aboutTitle = _HKI( "KiCad Gerber Viewer" );
89
90 SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
91 // some methods in code and avoid link errors
92
93 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
94 m_drillFileHistory.SetMaxFiles( fileHistorySize );
95 m_zipFileHistory.SetMaxFiles( fileHistorySize );
96 m_jobFileHistory.SetMaxFiles( fileHistorySize );
97
98 auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
101
102 SetCanvas( galCanvas );
103
104 // GerbView requires draw priority for rendering negative objects
105 galCanvas->GetView()->UseDrawPriority( true );
106
107 // Give an icon
108 wxIcon icon;
109 wxIconBundle icon_bundle;
110
111 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 48 ) );
112 icon_bundle.AddIcon( icon );
113 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 128 ) );
114 icon_bundle.AddIcon( icon );
115 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 256 ) );
116 icon_bundle.AddIcon( icon );
117 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
118 icon_bundle.AddIcon( icon );
119 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
120 icon_bundle.AddIcon( icon );
121
122 SetIcons( icon_bundle );
123
124 // Be sure a page info is set. this default value will be overwritten later.
125 PAGE_INFO pageInfo( wxT( "GERBER" ) );
126 SetLayout( new GBR_LAYOUT() );
127 SetPageSettings( pageInfo );
128
129 SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
130
132
133 // Create the PCB_LAYER_WIDGET *after* SetLayout():
135
136 // Update the minimum string length in the layer panel with the length of the last default layer
137 wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
138 false, true );
140
141 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
142 // initialize parameters in m_LayersManager
143 LoadSettings( config() );
144
145 setupTools();
151
152 m_auimgr.SetManagedWindow( this );
153
154 m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
155 m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
156 .Layer(4) );
157 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
158 .Layer( 6 ) );
159 m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
160 .Layer( 3 ) );
161 m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
162 .Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
163 .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
164
165 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
166
167 ReFillLayerWidget(); // this is near end because contents establish size
168 m_auimgr.Update();
169
170 SetActiveLayer( 0, true );
172
174
176
177 setupUnits( config() );
178
179 // Enable the axes to match legacy draw style
180 auto& galOptions = GetGalDisplayOptions();
181 galOptions.m_axesEnabled = true;
182 galOptions.NotifyChanged();
183
185 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
186
187 // Drag and drop
188 // Note that all gerber files are aliased as GerberFileExtension
192 DragAcceptFiles( true );
193
195
196 // Ensure the window is on top
197 Raise();
198
199 // Register a call to update the toolbar sizes. It can't be done immediately because
200 // it seems to require some sizes calculated that aren't yet (at least on GTK).
201 CallAfter( [this]()
202 {
203 // Ensure the controls on the toolbars all are correctly sized
205 } );
206}
207
208
210{
211 // Ensure m_canvasType is up to date, to save it in config
213
214 // Shutdown all running tools
215 if( m_toolManager )
217
218 GetCanvas()->GetView()->Clear();
219
221 delete m_gerberLayout;
222}
223
224
226{
227 // No more vetos
228 m_isClosing = true;
230 GetCanvas()->GetView()->Clear();
231
232 if( m_toolManager )
234
235 // Be sure any OpenGL event cannot be fired after frame deletion:
236 GetCanvas()->SetEvtHandlerEnabled( false );
237
238 Destroy();
239}
240
241
242bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
243{
244 // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
245 // when trying to change the view if it is not fully initialized.
246 // It happens when starting GerbView with a gerber job file to load
247 if( !IsShownOnScreen() )
248 Show();
249
250 // The current project path is also a valid command parameter. Check if a single path
251 // rather than a file name was passed to GerbView and use it as the initial MRU path.
252 if( aFileSet.size() > 0 )
253 {
254 wxString path = aFileSet[0];
255
256 // For some reason wxApp appears to leave the trailing double quote on quoted
257 // parameters which are required for paths with spaces. Maybe this should be
258 // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
259 // We can't buy a break!
260 if( path.Last() == wxChar( '\"' ) )
261 path.RemoveLast();
262
263 if( !wxFileExists( path ) && wxDirExists( path ) )
264 {
265 m_mruPath = path;
266 return true;
267 }
268
269 const unsigned limit = std::min( unsigned( aFileSet.size() ),
270 unsigned( GERBER_DRAWLAYERS_COUNT ) );
271
272 for( unsigned i = 0; i < limit; ++i )
273 {
274 wxString ext = wxFileName( aFileSet[i] ).GetExt().Lower();
275
277 LoadZipArchiveFile( aFileSet[i] );
278 else if( ext == FILEEXT::GerberJobFileExtension )
279 LoadGerberJobFile( aFileSet[i] );
280 else
281 {
282 GERBER_ORDER_ENUM fnameLayer;
283 wxString fnameExtensionMatched;
284
286 fnameExtensionMatched );
287
288 switch( fnameLayer )
289 {
290 case GERBER_ORDER_ENUM::GERBER_DRILL:
291 LoadExcellonFiles( aFileSet[i] );
292 break;
293 case GERBER_ORDER_ENUM::GERBER_LAYER_UNKNOWN:
294 LoadAutodetectedFiles( aFileSet[i] );
295 break;
296 default:
297 LoadGerberFiles( aFileSet[i] );
298 }
299 }
300 }
301 }
302
303 Zoom_Automatique( true ); // Zoom fit in frame
304
305 return true;
306}
307
308
310{
311 return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
312}
313
314
316{
318
319 if( aCfg->m_Window.grid.grids.empty() )
320 {
321 aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
322 GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
323 GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
324 GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
325 GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
326 GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
327 GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) },
328 GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
329 GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
330 GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) },
331 GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) },
332 GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) },
333 GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
334 GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) },
335 GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
336 GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
337 GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
338 GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
339 GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
340 GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) },
341 GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) },
342 GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } };
343 }
344
345 if( aCfg->m_Window.zoom_factors.empty() )
346 {
348 }
349
350 GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
351 wxCHECK( cfg, /*void*/ );
352
357
358 PAGE_INFO pageInfo( wxT( "GERBER" ) );
359 pageInfo.SetType( cfg->m_Appearance.page_type );
360 SetPageSettings( pageInfo );
361
364
368}
369
370
372{
374
375 GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
376 wxCHECK( cfg, /*void*/ );
377
379
383
385 Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
386}
387
388
390{
393 wxString currentTheme = cfg->m_ColorTheme;
394 return mgr.GetColorSettings( currentTheme );
395}
396
397
399{
400 wxWindowUpdateLocker no_update( m_LayersManager );
401
405
406 wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
407 wxSize bestz = m_LayersManager->GetBestSize();
408 bestz.x += 5; // gives a little margin
409
410 lyrs.MinSize( bestz );
411 lyrs.BestSize( bestz );
412 lyrs.FloatingSize( bestz );
413
414 if( lyrs.IsDocked() )
415 m_auimgr.Update();
416 else
417 m_LayersManager->SetSize( bestz );
418
420}
421
422
423void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
424{
425 KIGFX::VIEW* view = GetCanvas()->GetView();
426
427 switch( aLayerID )
428 {
429 case LAYER_DCODES:
430 gvconfig()->m_Appearance.show_dcodes = aNewState;
431
432 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
433 {
434 int layer = GERBER_DRAW_LAYER( i );
435 int dcode_layer = GERBER_DCODE_LAYER( layer );
436 view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
437 }
438
439 break;
440
442 {
444
446 []( KIGFX::VIEW_ITEM* aItem )
447 {
448 GERBER_DRAW_ITEM* item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
449
450 // GetLayerPolarity() returns true for negative items
451 return ( item && item->GetLayerPolarity() );
452 } );
453
454 break;
455 }
456
459
461
462 // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
463 // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
465 break;
466
468 SetGridVisibility( aNewState );
469 break;
470
474 break;
475
476 default:
477 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ),
478 aLayerID ) );
479 }
480
482 m_LayersManager->SetRenderState( aLayerID, aNewState );
483}
484
485
487{
488 auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
489 KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
491 settings->LoadColors( GetColorSettings() );
492
494}
495
496
498{
499 for( int i = 0; i < (int) ImagesMaxCount(); ++i )
500 {
501 const GERBER_FILE_IMAGE* gerber = GetGbrImage( i );
502
503 if( gerber == nullptr ) // this graphic layer is available: use it
504 return i;
505 }
506
507 return NO_AVAILABLE_LAYERS;
508}
509
510
512{
514}
515
516
517void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
518{
519 if( aRebuildLayerBox )
521
522 m_SelLayerBox->SetSelection( GetActiveLayer() );
523
524 int dcodeSelected = -1;
526
527 if( gerber )
528 dcodeSelected = gerber->m_Selected_Tool;
529
530 if( m_DCodeSelector )
531 {
533 m_DCodeSelector->SetDCodeSelection( dcodeSelected );
534 m_DCodeSelector->Enable( gerber != nullptr );
535 }
536}
537
538
540{
541 RemapLayers( GetImagesList()->SortImagesByFileExtension() );
542}
543
544
546{
547 RemapLayers( GetImagesList()->SortImagesByZOrder() );
548}
549
550
551void GERBVIEW_FRAME::RemapLayers( const std::unordered_map<int, int>& remapping )
552{
553 // Save the visibility of each existing gerber layer, in order to be able
554 // to restore this visibility after layer reorder.
555 // Note: the visibility of other objects (D_CODE, negative objects ... )
556 // must be not modified
557 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
558 {
559 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
560
561 if( gerber )
562 {
563 if( IsLayerVisible( currlayer ) )
564 gerber->SetFlags( CANDIDATE );
565 else
566 gerber->ClearFlags( CANDIDATE );
567 }
568
569 }
570
571 std::unordered_map<int, int> view_remapping;
572
573 for( const std::pair<const int, int>& entry : remapping )
574 {
575 view_remapping[ GERBER_DRAW_LAYER( entry.first ) ] = GERBER_DRAW_LAYER( entry.second );
576 view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second );
577 }
578
579 GetCanvas()->GetView()->ReorderLayerData( view_remapping );
580
581 // Restore visibility of gerber layers
582 LSET newVisibility = GetVisibleLayers();
583
584 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
585 {
586 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
587
588 if( gerber )
589 {
590 if( gerber->HasFlag( CANDIDATE ) )
591 newVisibility.set( currlayer );
592 else
593 newVisibility.set( currlayer, false );
594
595 gerber->ClearFlags( CANDIDATE );
596 }
597 }
598
599 SetVisibleLayers( newVisibility );
600
602 syncLayerBox( true );
603
604 // Reordering draw layers need updating the view items
608
609 GetCanvas()->Refresh();
610}
611
612
614{
615 // Adjust draw params: draw offset and draw rotation for a gerber file image
617
618 if( !gerber )
619 return;
620
621 DIALOG_DRAW_LAYERS_SETTINGS dlg( this );
622
623 if( dlg.ShowModal() != wxID_OK )
624 return;
625
626 KIGFX::VIEW* view = GetCanvas()->GetView();
627
628 view->RecacheAllItems();
629 view->MarkDirty();
630 view->UpdateAllItems( KIGFX::ALL );
631
632 GetCanvas()->Refresh();
633}
634
635
637{
641 KIGFX::VIEW* view = GetCanvas()->GetView();
642
643 int lastVisibleLayer = -1;
644
645 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
646 {
647 view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_XORMode );
648
649 // Caching doesn't work with layered rendering of XOR'd layers
650 if( gvconfig()->m_Display.m_XORMode )
652 else
653 view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
654
655 // We want the last visible layer, but deprioritize the active layer unless it's the
656 // only layer
657 if( ( lastVisibleLayer == -1 )
658 || ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
659 {
660 lastVisibleLayer = i;
661 }
662 }
663
664 //We don't want to diff the last visible layer onto the background, etc.
665 if( lastVisibleLayer != -1 )
666 {
667 view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
668 view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
669 }
670
671 view->RecacheAllItems();
672 view->MarkDirty();
673 view->UpdateAllItems( KIGFX::ALL );
674}
675
676
678{
680
681 // Display the gerber filename
682 if( gerber == nullptr )
683 {
684 SetTitle( _("Gerber Viewer") );
685
686 SetStatusText( wxEmptyString, 0 );
687
688 wxString info;
689 info.Printf( _( "Drawing layer not in use" ) );
690 m_TextInfo->SetValue( info );
691
692 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
693 m_auimgr.Update();
694
696 return;
697 }
698 else
699 {
700 wxString title;
701 wxFileName filename( gerber->m_FileName );
702
703 title = filename.GetFullName();
704
705 if( gerber->m_IsX2_file )
706 title += wxS( " " ) + _( "(with X2 attributes)" );
707
708 title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
709 SetTitle( title );
710
711 gerber->DisplayImageInfo( this );
712
713 // Display Image Name and Layer Name (from the current gerber data):
714 wxString status;
715 status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
716 gerber->m_ImageName,
717 gerber->GetLayerParams().m_LayerName );
718 SetStatusText( status, 0 );
719
720 // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
721 wxString info;
722 info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
723 gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
724 gerber->m_FmtLen.x - gerber->m_FmtScale.x,
725 gerber->m_FmtScale.x,
726 gerber->m_FmtLen.y - gerber->m_FmtScale.y,
727 gerber->m_FmtScale.y,
728 gerber->m_NoTrailingZeros ? 'T' : 'L' );
729
730 if( gerber->m_IsX2_file )
731 info << wxT(" ") << _( "X2 attr" );
732
733 m_TextInfo->SetValue( info );
734
735 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
736 m_auimgr.Update();
737 }
738}
739
740
741bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
742{
743 switch( aLayerID )
744 {
747 case LAYER_GERBVIEW_GRID: return IsGridVisible();
750 case LAYER_GERBVIEW_BACKGROUND: return true;
751
752 default:
753 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ),
754 aLayerID ) );
755 }
756
757 return true;
758}
759
760
762{
763 LSET visible = LSET::AllLayersMask();
764
765 if( GetCanvas() )
766 {
767 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
768 visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
769 }
770
771 return visible;
772}
773
774
776{
777 if( GetCanvas() )
778 {
779 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
780 {
781 bool v = aLayerMask[i];
782 int layer = GERBER_DRAW_LAYER( i );
783 GetCanvas()->GetView()->SetLayerVisible( layer, v );
785 gvconfig()->m_Appearance.show_dcodes && v );
786 }
787 }
788}
789
790
791bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
792{
793 return m_LayersManager->IsLayerVisible( aLayer );
794}
795
796
798{
799 COLOR4D color = COLOR4D::UNSPECIFIED;
800 COLOR_SETTINGS* settings = GetColorSettings();
801
802 switch( aLayerID )
803 {
805 case LAYER_DCODES:
809 color = settings->GetColor( aLayerID );
810 break;
811
814 break;
815
816 default:
817 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
818 aLayerID ) );
819 }
820
821 return color;
822}
823
824
826{
829}
830
831
832void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
833{
834 COLOR_SETTINGS* settings = GetColorSettings();
835
836 settings->SetColor( aLayerID, aColor );
837
838 switch( aLayerID )
839 {
843 break;
844
846 SetGridColor( aColor );
847 break;
848
850 SetDrawBgColor( aColor );
851 break;
852
853 default:
854 break;
855 }
856}
857
858
860{
861 return GetColorSettings()->GetColor( aLayer );
862}
863
864
865void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
866{
867 GetColorSettings()->SetColor( aLayer, aColor );
869}
870
871
872void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
873{
874 m_activeLayer = aLayer;
875
876 if( gvconfig()->m_Display.m_XORMode )
878
879 if( doLayerWidgetUpdate )
880 m_LayersManager->SelectLayer( aLayer );
881
883
885 GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
886
888 GetCanvas()->Refresh();
889}
890
891
892void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
893{
894 m_paper = aPageSettings;
895
896 if( GetScreen() )
898
899 GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
900
901 // Prepare drawing-sheet template
903 &Prj(), &GetTitleBlock(), nullptr );
904
905 if( GetScreen() )
906 {
907 drawingSheet->SetPageNumber( "1" );
908 drawingSheet->SetSheetCount( 1 );
909 }
910
913
914 // Draw panel takes ownership of the drawing-sheet
915 drawPanel->SetDrawingSheet( drawingSheet );
916}
917
918
920{
921 return m_paper;
922}
923
924
926{
927 // this function is only needed because EDA_DRAW_FRAME is not compiled
928 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
929 // into an application specific source file.
931}
932
933
935{
936 wxASSERT( m_gerberLayout );
938}
939
940
942{
943 wxASSERT( m_gerberLayout );
944 m_gerberLayout->SetTitleBlock( aTitleBlock );
945}
946
947
949{
951}
952
953
955{
957 GetCanvas()->GetGAL()->SetGridColor( aColor );
958 m_gridColor = aColor;
959}
960
961
963{
964 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
965 wxString line;
966
967 line.Printf( wxT( "grid X %s Y %s" ),
968 MessageTextFromValue( gridSize.x, false ),
969 MessageTextFromValue( gridSize.y, false ) );
970
971 SetStatusText( line, 4 );
972 SetStatusText( line, 4 );
973}
974
975
977{
979
980 if( !GetScreen() )
981 return;
982
983 wxString line;
985
986 if( GetShowPolarCoords() ) // display relative polar coordinates
987 {
988 VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
989 EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
990 double ro = hypot( v.x, v.y );
991
992 line.Printf( wxT( "r %s theta %s" ),
993 MessageTextFromValue( ro, false ),
994 MessageTextFromValue( theta, false ) );
995
996 SetStatusText( line, 3 );
997 }
998
999 // Display absolute coordinates:
1000 line.Printf( wxT( "X %s Y %s" ),
1001 MessageTextFromValue( cursorPos.x, false ),
1002 MessageTextFromValue( cursorPos.y, false ) );
1003 SetStatusText( line, 2 );
1004
1005 if( !GetShowPolarCoords() )
1006 {
1007 // Display relative cartesian coordinates:
1008 double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
1009 double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
1010
1011 line.Printf( wxT( "dx %s dy %s dist %s" ),
1012 MessageTextFromValue( dXpos, false ),
1013 MessageTextFromValue( dYpos,false ),
1014 MessageTextFromValue( hypot( dXpos, dYpos ), false ) );
1015 SetStatusText( line, 3 );
1016 }
1017
1019}
1020
1021
1023{
1024 return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1025}
1026
1027
1029{
1031}
1032
1033
1035{
1036 // Called on units change (see EDA_DRAW_FRAME)
1040}
1041
1042
1044{
1046
1047 EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1048
1049 if( m_toolManager )
1050 {
1052 GetCanvas()->GetViewControls(), config(), this );
1054 }
1055
1057
1059
1060 galCanvas->GetView()->RecacheAllItems();
1062 galCanvas->StartDrawing();
1063
1066
1069}
1070
1071
1073{
1074 // Create the manager and dispatcher & route draw panel events to the dispatcher
1077 GetCanvas()->GetViewControls(), config(), this );
1080
1081 // Register tools
1089
1090 // Run the selection tool, it is supposed to be always active
1091 m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
1092}
1093
1094
1096{
1098
1100 EDITOR_CONDITIONS cond( this );
1101
1102 wxASSERT( mgr );
1103
1104#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1105#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1106
1110
1114
1115 mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
1116 mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
1117 mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
1118
1119 auto flashedDisplayOutlinesCond =
1120 [this] ( const SELECTION& )
1121 {
1123 };
1124
1125 auto linesFillCond =
1126 [this] ( const SELECTION& )
1127 {
1129 };
1130
1131 auto polygonsFilledCond =
1132 [this] ( const SELECTION& )
1133 {
1135 };
1136
1137 auto negativeObjectsCond =
1138 [this] ( const SELECTION& )
1139 {
1141 };
1142
1143 auto dcodeCond =
1144 [this] ( const SELECTION& )
1145 {
1147 };
1148
1149 auto diffModeCond =
1150 [this] ( const SELECTION& )
1151 {
1152 return gvconfig()->m_Display.m_DiffMode;
1153 };
1154
1155 auto xorModeCond =
1156 [this] ( const SELECTION& )
1157 {
1158 return gvconfig()->m_Display.m_XORMode;
1159 };
1160
1161 auto highContrastModeCond =
1162 [this] ( const SELECTION& )
1163 {
1165 };
1166
1167 auto flipGerberCond =
1168 [this] ( const SELECTION& )
1169 {
1171 };
1172
1173 auto layersManagerShownCondition =
1174 [this] ( const SELECTION& aSel )
1175 {
1177 };
1178
1179 mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1181 mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1182 mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1184 mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
1185 mgr->SetConditions( GERBVIEW_ACTIONS::toggleXORMode, CHECK( xorModeCond ) );
1186 mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1187 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1188 mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, CHECK( layersManagerShownCondition ) );
1189
1190#undef CHECK
1191#undef ENABLE
1192}
1193
1194
1195void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1196{
1197 EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1198
1199 // Update gal display options like cursor shape, grid options:
1202
1203 SetPageSettings( PAGE_INFO( gvconfig()->m_Appearance.page_type ) );
1204
1206
1207 SetElementVisibility( LAYER_DCODES, gvconfig()->m_Appearance.show_dcodes );
1208
1212
1214 ReFillLayerWidget(); // Update the layers list
1215 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
1216
1217 Layout();
1218 SendSizeEvent();
1219}
1220
1221
1223{
1224 return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1225}
1226
1227
1229{
1231
1232 // show/hide auxiliary Vertical layers and visibility manager toolbar
1233 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1234 m_auimgr.Update();
1235}
int color
Definition: DXF_plotter.cpp:58
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:172
static TOOL_ACTION millimetersUnits
Definition: actions.h:180
static TOOL_ACTION togglePolarCoords
Definition: actions.h:183
static TOOL_ACTION milsUnits
Definition: actions.h:179
static TOOL_ACTION inchesUnits
Definition: actions.h:178
static TOOL_ACTION highContrastMode
Definition: actions.h:133
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:132
static TOOL_ACTION measureTool
Definition: actions.h:188
static TOOL_ACTION selectionTool
Definition: actions.h:187
static TOOL_ACTION zoomFitScreen
Definition: actions.h:124
static TOOL_ACTION zoomTool
Definition: actions.h:127
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:170
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:173
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
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)
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
void SetPageBorderColorLayer(int aLayerId)
Overrides 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
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
wxAuiManager m_auimgr
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associates files extensions with action to execute.
wxString m_aboutTitle
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
wxString m_mruPath
void ReCreateMenuBar()
Recreates 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
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void setupUnits(APP_SETTINGS_BASE *aCfg)
ACTION_TOOLBAR * m_optionsToolBar
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)
Changes 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()
Determines 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)
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
ACTION_TOOLBAR * m_mainToolBar
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 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 ...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
bool IsGridVisible() const
bool m_showBorderAndTitleBlock
ACTION_TOOLBAR * m_auxiliaryToolBar
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:123
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:125
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:127
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_DiffMode
Display layers in diff mode.
bool m_XORMode
Display layers in exclusive-or mode.
bool m_FlipGerberView
Display as a mirror image.
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 ...
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 toggleDiffMode
static TOOL_ACTION flipGerberView
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)
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
wxStaticText * m_dcodeText
wxChoice * m_SelAperAttributesBox
void UpdateXORLayers()
Update each layers' differential option.
void UpdateStatusBar() override
Update the status bar information.
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.
void ReCreateHToolbar() override
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
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 ReCreateAuxiliaryToolbar() override
void doCloseWindow() override
wxChoice * m_SelComponentBox
FILE_HISTORY m_jobFileHistory
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 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.
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
wxStaticText * m_apertText
COLOR4D GetLayerColor(int aLayer) const
void SortLayersByFileExtension()
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
void SetGridVisibility(bool aVisible) override
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.
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
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:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition: view.h:426
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
Definition: view.h:471
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition: view.h:395
void Clear()
Remove all items from the view.
Definition: view.cpp:1124
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1418
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1521
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:643
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:412
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition: view.h:619
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:1531
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition: view.cpp:680
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:279
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: layer_ids.h:573
static LSET AllLayersMask()
Definition: lset.cpp:898
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:122
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:650
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:137
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
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:167
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:169
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
ACTIONS * m_actions
Definition: tools_holder.h:168
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:82
Master controller class:
Definition: tool_manager.h:57
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:145
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:289
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
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()
Initializes 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:69
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition: layer_ids.h:431
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:430
@ LAYER_DCODES
Definition: layer_ids.h:426
@ LAYER_NEGATIVE_OBJECTS
Definition: layer_ids.h:427
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition: layer_ids.h:432
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:428
#define GERBER_DCODE_LAYER(x)
Definition: layer_ids.h:439
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:220
#define GERBER_DRAWLAYERS_COUNT
Definition: layer_ids.h:416
#define GERBER_DRAW_LAYER(x)
Definition: layer_ids.h:437
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:58
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition: definitions.h:49
@ TARGET_CACHED
Main rendering target (cached)
Definition: definitions.h:48
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:163
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1031
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:587
Definition of file extensions used in Kicad.
#define ZOOM_LIST_GERBVIEW
Definition: zoom_defines.h:29