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 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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <kiface_base.h>
23#include <base_units.h>
24#include <pgm_base.h>
25#include <bitmaps.h>
28#include <gerbview_frame.h>
29#include <gerbview_id.h>
30#include <gerber_file_image.h>
32#include <excellon_image.h>
34#include <gerbview_settings.h>
36#include <lset.h>
38#include <toolbars_gerber.h>
39#include <tool/tool_manager.h>
40#include <tool/action_toolbar.h>
42#include <tool/common_control.h>
43#include <tool/common_tools.h>
45#include <tool/zoom_tool.h>
51#include <trigo.h>
52#include <view/view.h>
53#include <view/view_controls.h>
54#include <base_screen.h>
55#include <gerbview_painter.h>
56#include <wx/wupdlock.h>
57
62
63#if defined(__linux__) || defined(__FreeBSD__)
65#else
67#endif
68
69#include <wx/log.h>
70
71GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
72 EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
75 m_TextInfo( nullptr ),
77 ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
79 ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
81 ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
82 m_activeLayer( 0 )
83{
85 m_gerberLayout = nullptr;
87 m_showBorderAndTitleBlock = false; // true for reference drawings.
88 m_SelLayerBox = nullptr;
89 m_DCodeSelector = nullptr;
90 m_SelComponentBox = nullptr;
91 m_SelNetnameBox = nullptr;
92 m_SelAperAttributesBox = nullptr;
93 m_cmpText = nullptr;
94 m_netText = nullptr;
95 m_apertText = nullptr;
96 m_dcodeText = nullptr;
97 m_aboutTitle = _HKI( "KiCad Gerber Viewer" );
98
99 SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
100 // some methods in code and avoid link errors
101
102 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
103 m_drillFileHistory.SetMaxFiles( fileHistorySize );
104 m_zipFileHistory.SetMaxFiles( fileHistorySize );
105 m_jobFileHistory.SetMaxFiles( fileHistorySize );
106
107 auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
110
111 SetCanvas( galCanvas );
112
113 // GerbView requires draw priority for rendering negative objects
114 galCanvas->GetView()->UseDrawPriority( true );
115
116 // Give an icon
117 wxIcon icon;
118 wxIconBundle icon_bundle;
119
120 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 48 ) );
121 icon_bundle.AddIcon( icon );
122 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 128 ) );
123 icon_bundle.AddIcon( icon );
124 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 256 ) );
125 icon_bundle.AddIcon( icon );
126 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
127 icon_bundle.AddIcon( icon );
128 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
129 icon_bundle.AddIcon( icon );
130
131 SetIcons( icon_bundle );
132
133 // Be sure a page info is set. this default value will be overwritten later.
135 SetLayout( new GBR_LAYOUT() );
136 SetPageSettings( pageInfo );
137
138 SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
139
140 SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS ) ) );
141
142 // Create the PCB_LAYER_WIDGET *after* SetLayout():
144
145 // Update the minimum string length in the layer panel with the length of the last default layer
146 wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
147 false, true );
148 m_LayersManager->SetSmallestLayerString( lyrName );
149
150 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
151 // initialize parameters in m_LayersManager
152 LoadSettings( config() );
153
154 setupTools();
157
161
162 m_auimgr.SetManagedWindow( this );
163
164 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer( 6 ) );
165 m_auimgr.AddPane( m_tbTopAux, EDA_PANE().HToolbar().Name( "TopAuxToolbar" ).Top().Layer(4) );
166 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer( 6 ) );
167 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "LeftToolbar" ).Left().Layer( 3 ) );
168 m_auimgr.AddPane( m_LayersManager,
169 EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer( 3 )
170 .Caption( _( "Layers Manager" ) ).PaneBorder( false )
171 .MinSize( FromDIP( 80 ), FromDIP( 80 ) )
172 .BestSize( m_LayersManager->GetBestSize() ) );
173
174 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
175
176 ReFillLayerWidget(); // this is near end because contents establish size
177 m_auimgr.Update();
178
179 SetActiveLayer( 0, true );
181
183
184 setupUnits( config() );
185
186 // Enable the axes to match legacy draw style
187 auto& galOptions = GetGalDisplayOptions();
188 galOptions.m_axesEnabled = true;
189 galOptions.NotifyChanged();
190
191 m_LayersManager->ReFill();
192 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
193
194 // Drag and drop
195 // Note that all gerber files are aliased as GerberFileExtension
199 DragAcceptFiles( true );
200
202
203 // Ensure the window is on top
204 Raise();
205
206 // Register a call to update the toolbar sizes. It can't be done immediately because
207 // it seems to require some sizes calculated that aren't yet (at least on GTK).
208 CallAfter( [this]()
209 {
210 // Ensure the controls on the toolbars all are correctly sized
212 } );
213}
214
215
217{
218 // Ensure m_canvasType is up to date, to save it in config
220
221 // Shutdown all running tools
222 if( m_toolManager )
223 m_toolManager->ShutdownAllTools();
224
225 GetCanvas()->GetView()->Clear();
226
228 delete m_gerberLayout;
229}
230
231
233{
234 // No more vetos
235 m_isClosing = true;
237
238 if( m_toolManager )
239 m_toolManager->DeactivateTool();
240
241 // Be sure any OpenGL event cannot be fired after frame deletion:
242 GetCanvas()->SetEvtHandlerEnabled( false );
243
244 Destroy();
245}
246
247
248bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
249{
250 // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
251 // when trying to change the view if it is not fully initialized.
252 // It happens when starting GerbView with a gerber job file to load
253 if( !IsShownOnScreen() )
254 Show();
255
256 // The current project path is also a valid command parameter. Check if a single path
257 // rather than a file name was passed to GerbView and use it as the initial MRU path.
258 if( aFileSet.size() > 0 )
259 {
260 wxString path = aFileSet[0];
261
262 // For some reason wxApp appears to leave the trailing double quote on quoted
263 // parameters which are required for paths with spaces. Maybe this should be
264 // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
265 // We can't buy a break!
266 if( path.Last() == wxChar( '\"' ) )
267 path.RemoveLast();
268
269 if( !wxFileExists( path ) && wxDirExists( path ) )
270 {
271 m_mruPath = path;
272 return true;
273 }
274
275 const unsigned limit = std::min( unsigned( aFileSet.size() ),
276 unsigned( GERBER_DRAWLAYERS_COUNT ) );
277
278 for( unsigned i = 0; i < limit; ++i )
279 {
280 wxString ext = wxFileName( aFileSet[i] ).GetExt().Lower();
281
283 LoadZipArchiveFile( aFileSet[i] );
284 else if( ext == FILEEXT::GerberJobFileExtension )
285 LoadGerberJobFile( aFileSet[i] );
286 else
287 {
288 GERBER_ORDER_ENUM fnameLayer;
289 wxString fnameExtensionMatched;
290
292 fnameExtensionMatched );
293
294 switch( fnameLayer )
295 {
297 LoadExcellonFiles( aFileSet[i] );
298 break;
300 LoadAutodetectedFiles( aFileSet[i] );
301 break;
302 default:
303 LoadGerberFiles( aFileSet[i] );
304 }
305 }
306 }
307 }
308
309 Zoom_Automatique( true ); // Zoom fit in frame
310
311 return true;
312}
313
314
316{
317 return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
318}
319
320
342
343
345{
347
348 if( GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg ) )
349 {
350 cfg->m_Appearance.page_type = GetPageSettings().GetTypeAsString();
351
352 m_drillFileHistory.Save( &cfg->m_DrillFileHistory );
353 m_zipFileHistory.Save( &cfg->m_ZipFileHistory );
354 m_jobFileHistory.Save( &cfg->m_JobFileHistory );
355 }
356
358}
359
360
362{
364 return ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
365}
366
367
369{
370 wxWindowUpdateLocker no_update( m_LayersManager );
371
372 m_LayersManager->ReFill();
373 m_SelLayerBox->Resync();
374
375 // Re-build the various boxes in the toolbars
376 // TODO: Could this be made more precise instead of just blowing away all the toolbars?
378
379 wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
380 wxSize bestz = m_LayersManager->GetBestSize();
381 bestz.x += 5; // gives a little margin
382
383 lyrs.MinSize( bestz );
384 lyrs.BestSize( bestz );
385 lyrs.FloatingSize( bestz );
386
387 if( lyrs.IsDocked() )
388 m_auimgr.Update();
389 else
390 m_LayersManager->SetSize( bestz );
391
393}
394
395
396void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
397{
398 KIGFX::VIEW* view = GetCanvas()->GetView();
399
400 switch( aLayerID )
401 {
402 case LAYER_DCODES:
403 gvconfig()->m_Appearance.show_dcodes = aNewState;
404
405 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
406 {
407 int layer = GERBER_DRAW_LAYER( i );
408 int dcode_layer = GERBER_DCODE_LAYER( layer );
409 view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
410 }
411
412 break;
413
416
418 []( KIGFX::VIEW_ITEM* aItem )
419 {
420 GERBER_DRAW_ITEM* item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
421
422 // GetLayerPolarity() returns true for negative items
423 return ( item && item->GetLayerPolarity() );
424 } );
425
426 break;
427
430
432
433 // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
434 // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
436 break;
437
439 SetGridVisibility( aNewState );
440 break;
441
445 break;
446
447 default:
448 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ),
449 aLayerID ) );
450 }
451
453 m_LayersManager->SetRenderState( aLayerID, aNewState );
454}
455
456
458{
459 auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
460 KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
461 settings->SetHighContrast( gvconfig()->m_Display.m_HighContrastMode );
462 settings->LoadColors( GetColorSettings() );
463
465}
466
467
469{
470 for( int i = 0; i < (int) ImagesMaxCount(); ++i )
471 {
472 const GERBER_FILE_IMAGE* gerber = GetGbrImage( i );
473
474 if( gerber == nullptr ) // this graphic layer is available: use it
475 return i;
476 }
477
478 return NO_AVAILABLE_LAYERS;
479}
480
481
483{
484 m_LayersManager->SelectLayer( GetActiveLayer() );
485}
486
487
488void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
489{
490 if( aRebuildLayerBox )
491 m_SelLayerBox->Resync();
492
493 m_SelLayerBox->SetSelection( GetActiveLayer() );
494
495 int dcodeSelected = -1;
497
498 if( gerber )
499 dcodeSelected = gerber->m_Selected_Tool;
500
501 if( m_DCodeSelector )
502 {
504 m_DCodeSelector->SetDCodeSelection( dcodeSelected );
505 m_DCodeSelector->Enable( gerber != nullptr );
506 }
507}
508
509
511{
512 RemapLayers( GetImagesList()->SortImagesByFileExtension() );
513}
514
515
517{
518 RemapLayers( GetImagesList()->SortImagesByZOrder() );
519}
520
521
522void GERBVIEW_FRAME::RemapLayers( const std::unordered_map<int, int>& remapping )
523{
524 // Save the visibility of each existing gerber layer, in order to be able
525 // to restore this visibility after layer reorder.
526 // Note: the visibility of other objects (D_CODE, negative objects ... )
527 // must be not modified
528 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
529 {
530 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
531
532 if( gerber )
533 {
534 if( IsLayerVisible( currlayer ) )
535 gerber->SetFlags( CANDIDATE );
536 else
537 gerber->ClearFlags( CANDIDATE );
538 }
539
540 }
541
542 std::unordered_map<int, int> view_remapping;
543
544 for( const std::pair<const int, int>& entry : remapping )
545 {
546 view_remapping[ GERBER_DRAW_LAYER( entry.first ) ] = GERBER_DRAW_LAYER( entry.second );
547 view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second );
548 }
549
550 GetCanvas()->GetView()->ReorderLayerData( view_remapping );
551
552 // Restore visibility of gerber layers
553 LSET newVisibility = GetVisibleLayers();
554
555 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
556 {
557 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
558
559 if( gerber )
560 {
561 if( gerber->HasFlag( CANDIDATE ) )
562 newVisibility.set( currlayer );
563 else
564 newVisibility.set( currlayer, false );
565
566 gerber->ClearFlags( CANDIDATE );
567 }
568 }
569
570 SetVisibleLayers( newVisibility );
571
573 syncLayerBox( true );
574
575 // Reordering draw layers need updating the view items
579
580 GetCanvas()->Refresh();
581}
582
583
585{
586 // Adjust draw params: draw offset and draw rotation for a gerber file image
588
589 if( !gerber )
590 return;
591
592 DIALOG_DRAW_LAYERS_SETTINGS dlg( this );
593
594 if( dlg.ShowModal() != wxID_OK )
595 return;
596
597 KIGFX::VIEW* view = GetCanvas()->GetView();
598
599 view->RecacheAllItems();
600 view->MarkDirty();
601 view->UpdateAllItems( KIGFX::ALL );
602
603 GetCanvas()->Refresh();
604}
605
606
608{
612 KIGFX::VIEW* view = GetCanvas()->GetView();
613
614 int lastVisibleLayer = -1;
615
616 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
617 {
618 view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_XORMode );
619
620 // Caching doesn't work with layered rendering of XOR'd layers
621 if( gvconfig()->m_Display.m_XORMode )
623 else
624 view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
625
626 // We want the last visible layer, but deprioritize the active layer unless it's the
627 // only layer. We must check visibility first to avoid selecting hidden layers.
628 if( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) )
629 {
630 if( lastVisibleLayer == -1 || i != GetActiveLayer() )
631 lastVisibleLayer = i;
632 }
633 }
634
635 // We don't want to diff the last visible layer onto the background, etc.
636 // In XOR mode, we must keep TARGET_NONCACHED for all layers including the last one.
637 // This is because OpenGL's cached items are flushed at the end of the frame, which
638 // occurs after XOR compositing. If we used TARGET_CACHED for the last layer, its
639 // items would be drawn on top of the XOR result instead of being included in the
640 // XOR calculation.
641 if( lastVisibleLayer != -1 )
642 {
643 if( gvconfig()->m_Display.m_XORMode )
644 view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), KIGFX::TARGET_NONCACHED );
645 else
646 view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
647
648 view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
649 }
650
651 view->RecacheAllItems();
652 view->MarkDirty();
653 view->UpdateAllItems( KIGFX::ALL );
654}
655
656
658{
660
661 // Display the gerber filename
662 if( gerber == nullptr )
663 {
664 SetTitle( _("Gerber Viewer") );
665
666 SetStatusText( wxEmptyString, 0 );
667
668 wxString info = _( "Drawing layer not in use" );
669 m_TextInfo->SetValue( info );
670
671 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
672 m_auimgr.Update();
673
675 return;
676 }
677 else
678 {
679 wxString title;
680 wxFileName filename( gerber->m_FileName );
681
682 title = filename.GetFullName();
683
684 if( gerber->m_IsX2_file )
685 title += wxS( " " ) + _( "(with X2 attributes)" );
686
687 title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
688 SetTitle( title );
689
690 gerber->DisplayImageInfo( this );
691
692 // Display Image Name and Layer Name (from the current gerber data):
693 wxString status;
694 status.Printf( _( "Image name: '%s' Layer name: '%s'" ),
695 gerber->m_ImageName,
696 gerber->GetLayerParams().m_LayerName );
697 SetStatusText( status, 0 );
698
699 // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
700 wxString info;
701 info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
702 gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
703 gerber->m_FmtLen.x - gerber->m_FmtScale.x,
704 gerber->m_FmtScale.x,
705 gerber->m_FmtLen.y - gerber->m_FmtScale.y,
706 gerber->m_FmtScale.y,
707 gerber->m_NoTrailingZeros ? 'T' : 'L' );
708
709 if( gerber->m_IsX2_file )
710 info << wxT(" ") << _( "X2 attr" );
711
712 m_TextInfo->SetValue( info );
713
714 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
715 m_auimgr.Update();
716 }
717}
718
719
720bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
721{
722 switch( aLayerID )
723 {
729 case LAYER_GERBVIEW_BACKGROUND: return true;
730
731 default:
732 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID ) );
733 }
734
735 return true;
736}
737
738
740{
741 LSET visible = LSET::AllLayersMask();
742
743 if( GetCanvas() )
744 {
745 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
746 visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
747 }
748
749 return visible;
750}
751
752
753void GERBVIEW_FRAME::SetVisibleLayers( const LSET& aLayerMask )
754{
755 if( GetCanvas() )
756 {
757 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
758 {
759 bool v = aLayerMask[i];
760 int layer = GERBER_DRAW_LAYER( i );
761 GetCanvas()->GetView()->SetLayerVisible( layer, v );
763 gvconfig()->m_Appearance.show_dcodes && v );
764 }
765 }
766
767 if( gvconfig()->m_Display.m_XORMode )
769}
770
771
772bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
773{
774 return m_LayersManager->IsLayerVisible( aLayer );
775}
776
777
779{
781 COLOR_SETTINGS* settings = GetColorSettings();
782
783 switch( aLayerID )
784 {
786 case LAYER_DCODES:
790 color = settings->GetColor( aLayerID );
791 break;
792
794 color = GetGridColor();
795 break;
796
797 default:
798 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
799 aLayerID ) );
800 }
801
802 return color;
803}
804
805
807{
809 m_LayersManager->SetRenderState( LAYER_GERBVIEW_GRID, aVisible );
810}
811
812
813void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
814{
815 COLOR_SETTINGS* settings = GetColorSettings();
816
817 settings->SetColor( aLayerID, aColor );
818
819 switch( aLayerID )
820 {
824 break;
825
827 SetGridColor( aColor );
828 break;
829
831 SetDrawBgColor( aColor );
832 break;
833
834 default:
835 break;
836 }
837}
838
839
841{
842 return GetColorSettings()->GetColor( aLayer );
843}
844
845
846void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
847{
848 GetColorSettings()->SetColor( aLayer, aColor );
850}
851
852
853void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
854{
855 m_activeLayer = aLayer;
856
857 if( gvconfig()->m_Display.m_XORMode )
859
860 if( doLayerWidgetUpdate )
861 {
862 m_LayersManager->SelectLayer( aLayer );
863 m_LayersManager->OnLayerSelected();
864 }
865
867
868 m_toolManager->PostAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
869 GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
870
872 GetCanvas()->Refresh();
873}
874
875
876void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
877{
878 m_paper = aPageSettings;
879
880 if( GetScreen() )
881 GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( gerbIUScale.IU_PER_MILS ) );
882
883 GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
884
885 // Prepare drawing-sheet template
887 &Prj(), &GetTitleBlock(), nullptr );
888
889 if( GetScreen() )
890 {
891 drawingSheet->SetPageNumber( "1" );
892 drawingSheet->SetSheetCount( 1 );
893 }
894
897
898 // Draw panel takes ownership of the drawing-sheet
899 drawPanel->SetDrawingSheet( drawingSheet );
900}
901
902
904{
905 return m_paper;
906}
907
908
910{
911 // this function is only needed because EDA_DRAW_FRAME is not compiled
912 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
913 // into an application specific source file.
914 return GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS );
915}
916
917
919{
920 wxASSERT( m_gerberLayout );
921 return m_gerberLayout->GetTitleBlock();
922}
923
924
926{
927 wxASSERT( m_gerberLayout );
928 m_gerberLayout->SetTitleBlock( aTitleBlock );
929}
930
931
936
937
939{
941 GetCanvas()->GetGAL()->SetGridColor( aColor );
942 m_gridColor = aColor;
943}
944
945
947{
948 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
949 wxString line;
950
951 line.Printf( wxT( "grid X %s Y %s" ),
952 MessageTextFromValue( gridSize.x, false ),
953 MessageTextFromValue( gridSize.y, false ) );
954
955 SetStatusText( line, 4 );
956 SetStatusText( line, 4 );
957}
958
959
961{
963
964 if( !GetScreen() )
965 return;
966
967 wxString line;
969
970 if( GetShowPolarCoords() ) // display relative polar coordinates
971 {
972 VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
973 EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
974 double ro = hypot( v.x, v.y );
975
976 line.Printf( wxT( "r %s theta %s" ),
977 MessageTextFromValue( ro, false ),
978 MessageTextFromValue( theta, false ) );
979
980 SetStatusText( line, 3 );
981 }
982
983 // Display absolute coordinates:
984 line.Printf( wxT( "X %s Y %s" ),
985 MessageTextFromValue( cursorPos.x, false ),
986 MessageTextFromValue( cursorPos.y, false ) );
987 SetStatusText( line, 2 );
988
989 if( !GetShowPolarCoords() )
990 {
991 // Display relative cartesian coordinates:
992 double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
993 double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
994
995 line.Printf( wxT( "dx %s dy %s dist %s" ),
996 MessageTextFromValue( dXpos, false ),
997 MessageTextFromValue( dYpos,false ),
998 MessageTextFromValue( hypot( dXpos, dYpos ), false ) );
999 SetStatusText( line, 3 );
1000 }
1001
1003}
1004
1005
1007{
1008 return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
1009}
1010
1011
1013{
1014 return m_gerberLayout->GetImagesList()->ImagesMaxCount();
1015}
1016
1017
1019{
1020 // Called on units change (see EDA_DRAW_FRAME)
1024}
1025
1026
1028{
1030
1031 EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1032
1033 if( m_toolManager )
1034 {
1035 m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
1036 GetCanvas()->GetViewControls(), config(), this );
1037 m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
1038 }
1039
1041
1043
1044 galCanvas->GetView()->RecacheAllItems();
1046 galCanvas->StartDrawing();
1047
1048 m_LayersManager->ReFill();
1049 m_LayersManager->ReFillRender();
1050
1053
1054 try
1055 {
1056 if( !m_spaceMouse )
1057 {
1058#if defined(__linux__) || defined(__FreeBSD__)
1059 m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( galCanvas );
1060 m_spaceMouse->SetScale( gerbIUScale.IU_PER_MILS / pcbIUScale.IU_PER_MILS );
1061#else
1062 m_spaceMouse = std::make_unique<NL_GERBVIEW_PLUGIN>();
1063#endif
1064 }
1065
1066 m_spaceMouse->SetCanvas( galCanvas );
1067 }
1068 catch( const std::exception& e )
1069 {
1070 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), wxS( "%s" ), e.what() );
1071 }
1072 catch( ... )
1073 {
1074 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ),
1075 wxT( "Unknown exception during SpaceMouse initialization" ) );
1076 }
1077}
1078
1079
1081{
1082 // Create the manager and dispatcher & route draw panel events to the dispatcher
1084 m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
1085 GetCanvas()->GetViewControls(), config(), this );
1088
1089 // Register tools
1090 m_toolManager->RegisterTool( new COMMON_CONTROL );
1091 m_toolManager->RegisterTool( new COMMON_TOOLS );
1092 m_toolManager->RegisterTool( new GERBVIEW_SELECTION_TOOL );
1093 m_toolManager->RegisterTool( new GERBVIEW_CONTROL );
1094 m_toolManager->RegisterTool( new GERBVIEW_INSPECTION_TOOL );
1095 m_toolManager->RegisterTool( new ZOOM_TOOL );
1096 m_toolManager->InitTools();
1097
1098 // Run the selection tool, it is supposed to be always active
1099 m_toolManager->InvokeTool( "common.InteractiveSelection" );
1100}
1101
1102
1104{
1106
1107 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
1108 EDITOR_CONDITIONS cond( this );
1109
1110 wxASSERT( mgr );
1111
1112#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1113#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1114
1118
1124
1125 auto flashedDisplayOutlinesCond =
1126 [this] ( const SELECTION& )
1127 {
1129 };
1130
1131 auto linesFillCond =
1132 [this] ( const SELECTION& )
1133 {
1135 };
1136
1137 auto polygonsFilledCond =
1138 [this] ( const SELECTION& )
1139 {
1141 };
1142
1143 auto negativeObjectsCond =
1144 [this] ( const SELECTION& )
1145 {
1147 };
1148
1149 auto dcodeCond =
1150 [this] ( const SELECTION& )
1151 {
1153 };
1154
1155 auto forceOpacityModeCond =
1156 [this] ( const SELECTION& )
1157 {
1159 };
1160
1161 auto xorModeCond =
1162 [this] ( const SELECTION& )
1163 {
1164 return gvconfig()->m_Display.m_XORMode;
1165 };
1166
1167 auto highContrastModeCond =
1168 [this] ( const SELECTION& )
1169 {
1171 };
1172
1173 auto flipGerberCond =
1174 [this] ( const SELECTION& )
1175 {
1177 };
1178
1179 auto layersManagerShownCondition =
1180 [this] ( const SELECTION& aSel )
1181 {
1183 };
1184
1185 mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1187 mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1188 mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1190 mgr->SetConditions( GERBVIEW_ACTIONS::toggleForceOpacityMode, CHECK( forceOpacityModeCond ) );
1191 mgr->SetConditions( GERBVIEW_ACTIONS::toggleXORMode, CHECK( xorModeCond ) );
1192 mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1193 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1194 mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, CHECK( layersManagerShownCondition ) );
1195
1196#undef CHECK
1197#undef ENABLE
1198}
1199
1200
1202{
1204
1205 // Update gal display options like cursor shape, grid options:
1206 if( GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" ) )
1207 {
1208 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1209
1210 PAGE_INFO pgInfo;
1211 pgInfo.SetType( cfg->m_Appearance.page_type );
1212
1213 SetPageSettings( pgInfo );
1214 SetElementVisibility( LAYER_DCODES, cfg->m_Appearance.show_dcodes );
1215 }
1216
1218
1222
1224 ReFillLayerWidget(); // Update the layers list
1225 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
1226
1227 Layout();
1228 SendSizeEvent();
1229}
1230
1231
1233{
1234 return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1235}
1236
1237
1239{
1241
1242 // show/hide auxiliary Vertical layers and visibility manager toolbar
1243 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1244 m_auimgr.Update();
1245}
1246
1247void GERBVIEW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1248{
1250
1251 if( m_spaceMouse )
1252 m_spaceMouse->SetFocus( aEvent.GetActive() );
1253}
1254
1255void GERBVIEW_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
1256{
1258
1259 if( m_spaceMouse )
1260 m_spaceMouse->SetFocus( false );
1261}
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:121
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:120
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:100
@ icon_gerbview_16
@ icon_gerbview_32
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:148
static TOOL_ACTION togglePolarCoords
Definition actions.h:205
static TOOL_ACTION highContrastMode
Definition actions.h:151
static TOOL_ACTION measureTool
Definition actions.h:248
static TOOL_ACTION selectionTool
Definition actions.h:247
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION zoomTool
Definition actions.h:142
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:150
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:149
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.
WINDOW_SETTINGS m_Window
wxString m_ColorTheme
Active color theme name.
Handles how to draw a screen (a board, a schematic ...)
Definition base_screen.h:37
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition base_screen.h:86
void InitDataPoints(const VECTOR2I &aPageSizeInternalUnits)
BASE_SET & set(size_t pos)
Definition base_set.h:126
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:399
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.
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 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.
void ReCreateMenuBar()
Recreate the menu bar.
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.
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)
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
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 ...
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
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:158
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:160
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:168
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 CursorSmallCrosshairs()
Create a functor testing if the cursor is full screen in a frame.
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 Cursor45Crosshairs()
SELECTION_CONDITION CursorFullCrosshairs()
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:42
GERBER_FILE_IMAGE_LIST * GetImagesList() const
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 ...
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.
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
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
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:82
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition view.h:450
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
Definition view.h:509
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:405
void Clear()
Remove all items from the view.
Definition view.cpp:1234
void RecacheAllItems()
Rebuild GAL display lists.
Definition view.cpp:1569
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1703
void MarkDirty()
Force redraw of view on the next rendering.
Definition view.h:679
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition view.h:427
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:225
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:659
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:1719
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
Definition view.cpp:766
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:340
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:637
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:75
wxString GetTypeAsString() const
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
Definition page_info.h:173
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:546
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:123
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save 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:38
TOOL_MANAGER * m_toolManager
TOOL_DISPATCHER * m_toolDispatcher
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
ACTIONS * m_actions
@ GAL_SWITCH
Rendering engine changes.
Definition tool_base.h:78
Master controller class:
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
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 _(s)
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define CANDIDATE
flag indicating that the structure is connected
@ FRAME_GERBER
Definition frame_type.h:53
#define NO_AVAILABLE_LAYERS
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
@ ID_GERBVIEW_JOB_FILE_LIST_CLEAR
Definition gerbview_id.h:56
@ ID_GERBVIEW_DRILL_FILE1
Definition gerbview_id.h:48
@ ID_GERBVIEW_ZIP_FILE_LIST_CLEAR
Definition gerbview_id.h:62
@ ID_GERBVIEW_JOB_FILE1
Definition gerbview_id.h:54
@ ID_GERBVIEW_ZIP_FILE1
Definition gerbview_id.h:60
@ ID_GERBVIEW_DRILL_FILE_LIST_CLEAR
Definition gerbview_id.h:50
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:45
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition layer_ids.h:556
@ LAYER_GERBVIEW_BACKGROUND
Definition layer_ids.h:555
@ LAYER_DCODES
Definition layer_ids.h:551
@ LAYER_NEGATIVE_OBJECTS
Definition layer_ids.h:552
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition layer_ids.h:557
@ LAYER_GERBVIEW_GRID
Definition layer_ids.h:553
#define GERBER_DCODE_LAYER(x)
Definition layer_ids.h:564
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:274
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
Definition layer_ids.h:541
#define GERBER_DRAW_LAYER(x)
Definition layer_ids.h:562
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ ALL
All except INITIAL_ADD.
Definition view_item.h:55
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:34
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:33
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 ...
Declaration of the NL_GERBVIEW_PLUGIN class.
#define _HKI(x)
Definition page_info.cpp:40
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
#define DEFAULT_THEME
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
GRID_SETTINGS grid
std::string path
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682
Definition of file extensions used in Kicad.