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 along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <kiface_base.h>
22#include <base_units.h>
23#include <pgm_base.h>
24#include <bitmaps.h>
27#include <gerbview_frame.h>
28#include <gerbview_id.h>
29#include <gerber_file_image.h>
31#include <excellon_image.h>
33#include <gerbview_settings.h>
35#include <lset.h>
37#include <toolbars_gerber.h>
38#include <tool/tool_manager.h>
39#include <tool/action_toolbar.h>
41#include <tool/common_control.h>
42#include <tool/common_tools.h>
44#include <tool/zoom_tool.h>
50#include <trigo.h>
51#include <view/view.h>
52#include <view/view_controls.h>
53#include <base_screen.h>
54#include <gerbview_painter.h>
55#include <wx/wupdlock.h>
56
61
62#ifndef __linux__
64#else
66#endif
67
68#include <wx/log.h>
69
70GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
71 EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
74 m_TextInfo( nullptr ),
76 ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
78 ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
80 ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
81 m_activeLayer( 0 )
82{
84 m_gerberLayout = nullptr;
86 m_showBorderAndTitleBlock = false; // true for reference drawings.
87 m_SelLayerBox = nullptr;
88 m_DCodeSelector = nullptr;
89 m_SelComponentBox = nullptr;
90 m_SelNetnameBox = nullptr;
91 m_SelAperAttributesBox = nullptr;
92 m_cmpText = nullptr;
93 m_netText = nullptr;
94 m_apertText = nullptr;
95 m_dcodeText = nullptr;
96 m_aboutTitle = _HKI( "KiCad Gerber Viewer" );
97
98 SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
99 // some methods in code and avoid link errors
100
101 int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
102 m_drillFileHistory.SetMaxFiles( fileHistorySize );
103 m_zipFileHistory.SetMaxFiles( fileHistorySize );
104 m_jobFileHistory.SetMaxFiles( fileHistorySize );
105
106 auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
109
110 SetCanvas( galCanvas );
111
112 // GerbView requires draw priority for rendering negative objects
113 galCanvas->GetView()->UseDrawPriority( true );
114
115 // Give an icon
116 wxIcon icon;
117 wxIconBundle icon_bundle;
118
119 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 48 ) );
120 icon_bundle.AddIcon( icon );
121 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 128 ) );
122 icon_bundle.AddIcon( icon );
123 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview, 256 ) );
124 icon_bundle.AddIcon( icon );
125 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_32 ) );
126 icon_bundle.AddIcon( icon );
127 icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_gerbview_16 ) );
128 icon_bundle.AddIcon( icon );
129
130 SetIcons( icon_bundle );
131
132 // Be sure a page info is set. this default value will be overwritten later.
134 SetLayout( new GBR_LAYOUT() );
135 SetPageSettings( pageInfo );
136
137 SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
138
139 SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS ) ) );
140
141 // Create the PCB_LAYER_WIDGET *after* SetLayout():
143
144 // Update the minimum string length in the layer panel with the length of the last default layer
145 wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
146 false, true );
147 m_LayersManager->SetSmallestLayerString( lyrName );
148
149 // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
150 // initialize parameters in m_LayersManager
151 LoadSettings( config() );
152
153 setupTools();
156
160
161 m_auimgr.SetManagedWindow( this );
162
163 m_auimgr.AddPane( m_tbTopMain, EDA_PANE().HToolbar().Name( "TopMainToolbar" ).Top().Layer( 6 ) );
164 m_auimgr.AddPane( m_tbTopAux, EDA_PANE().HToolbar().Name( "TopAuxToolbar" ).Top().Layer(4) );
165 m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer( 6 ) );
166 m_auimgr.AddPane( m_tbLeft, EDA_PANE().VToolbar().Name( "LeftToolbar" ).Left().Layer( 3 ) );
167 m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer( 3 )
168 .Caption( _( "Layers Manager" ) ).PaneBorder( false )
169 .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
170
171 m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
172
173 ReFillLayerWidget(); // this is near end because contents establish size
174 m_auimgr.Update();
175
176 SetActiveLayer( 0, true );
178
180
182
183 setupUnits( config() );
184
185 // Enable the axes to match legacy draw style
186 auto& galOptions = GetGalDisplayOptions();
187 galOptions.m_axesEnabled = true;
188 galOptions.NotifyChanged();
189
190 m_LayersManager->ReFill();
191 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
192
193 // Drag and drop
194 // Note that all gerber files are aliased as GerberFileExtension
198 DragAcceptFiles( true );
199
201
202 // Ensure the window is on top
203 Raise();
204
205 // Register a call to update the toolbar sizes. It can't be done immediately because
206 // it seems to require some sizes calculated that aren't yet (at least on GTK).
207 CallAfter( [this]()
208 {
209 // Ensure the controls on the toolbars all are correctly sized
211 } );
212}
213
214
216{
217 // Ensure m_canvasType is up to date, to save it in config
219
220 // Shutdown all running tools
221 if( m_toolManager )
222 m_toolManager->ShutdownAllTools();
223
224 GetCanvas()->GetView()->Clear();
225
227 delete m_gerberLayout;
228}
229
230
232{
233 // No more vetos
234 m_isClosing = true;
236
237 if( m_toolManager )
238 m_toolManager->DeactivateTool();
239
240 // Be sure any OpenGL event cannot be fired after frame deletion:
241 GetCanvas()->SetEvtHandlerEnabled( false );
242
243 Destroy();
244}
245
246
247bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
248{
249 // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
250 // when trying to change the view if it is not fully initialized.
251 // It happens when starting GerbView with a gerber job file to load
252 if( !IsShownOnScreen() )
253 Show();
254
255 // The current project path is also a valid command parameter. Check if a single path
256 // rather than a file name was passed to GerbView and use it as the initial MRU path.
257 if( aFileSet.size() > 0 )
258 {
259 wxString path = aFileSet[0];
260
261 // For some reason wxApp appears to leave the trailing double quote on quoted
262 // parameters which are required for paths with spaces. Maybe this should be
263 // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
264 // We can't buy a break!
265 if( path.Last() == wxChar( '\"' ) )
266 path.RemoveLast();
267
268 if( !wxFileExists( path ) && wxDirExists( path ) )
269 {
270 m_mruPath = path;
271 return true;
272 }
273
274 const unsigned limit = std::min( unsigned( aFileSet.size() ),
275 unsigned( GERBER_DRAWLAYERS_COUNT ) );
276
277 for( unsigned i = 0; i < limit; ++i )
278 {
279 wxString ext = wxFileName( aFileSet[i] ).GetExt().Lower();
280
282 LoadZipArchiveFile( aFileSet[i] );
283 else if( ext == FILEEXT::GerberJobFileExtension )
284 LoadGerberJobFile( aFileSet[i] );
285 else
286 {
287 GERBER_ORDER_ENUM fnameLayer;
288 wxString fnameExtensionMatched;
289
291 fnameExtensionMatched );
292
293 switch( fnameLayer )
294 {
296 LoadExcellonFiles( aFileSet[i] );
297 break;
299 LoadAutodetectedFiles( aFileSet[i] );
300 break;
301 default:
302 LoadGerberFiles( aFileSet[i] );
303 }
304 }
305 }
306 }
307
308 Zoom_Automatique( true ); // Zoom fit in frame
309
310 return true;
311}
312
313
315{
316 return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
317}
318
319
341
342
344{
346
347 if( GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg ) )
348 {
349 cfg->m_Appearance.page_type = GetPageSettings().GetTypeAsString();
350
351 m_drillFileHistory.Save( &cfg->m_DrillFileHistory );
352 m_zipFileHistory.Save( &cfg->m_ZipFileHistory );
353 m_jobFileHistory.Save( &cfg->m_JobFileHistory );
354 }
355
357}
358
359
361{
363 return ::GetColorSettings( cfg ? cfg->m_ColorTheme : DEFAULT_THEME );
364}
365
366
368{
369 wxWindowUpdateLocker no_update( m_LayersManager );
370
371 m_LayersManager->ReFill();
372 m_SelLayerBox->Resync();
373
374 // Re-build the various boxes in the toolbars
375 // TODO: Could this be made more precise instead of just blowing away all the toolbars?
377
378 wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
379 wxSize bestz = m_LayersManager->GetBestSize();
380 bestz.x += 5; // gives a little margin
381
382 lyrs.MinSize( bestz );
383 lyrs.BestSize( bestz );
384 lyrs.FloatingSize( bestz );
385
386 if( lyrs.IsDocked() )
387 m_auimgr.Update();
388 else
389 m_LayersManager->SetSize( bestz );
390
392}
393
394
395void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
396{
397 KIGFX::VIEW* view = GetCanvas()->GetView();
398
399 switch( aLayerID )
400 {
401 case LAYER_DCODES:
402 gvconfig()->m_Appearance.show_dcodes = aNewState;
403
404 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
405 {
406 int layer = GERBER_DRAW_LAYER( i );
407 int dcode_layer = GERBER_DCODE_LAYER( layer );
408 view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
409 }
410
411 break;
412
414 {
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 }
428
431
433
434 // NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
435 // LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
437 break;
438
440 SetGridVisibility( aNewState );
441 break;
442
446 break;
447
448 default:
449 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ),
450 aLayerID ) );
451 }
452
454 m_LayersManager->SetRenderState( aLayerID, aNewState );
455}
456
457
459{
460 auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
461 KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
462 settings->SetHighContrast( gvconfig()->m_Display.m_HighContrastMode );
463 settings->LoadColors( GetColorSettings() );
464
466}
467
468
470{
471 for( int i = 0; i < (int) ImagesMaxCount(); ++i )
472 {
473 const GERBER_FILE_IMAGE* gerber = GetGbrImage( i );
474
475 if( gerber == nullptr ) // this graphic layer is available: use it
476 return i;
477 }
478
479 return NO_AVAILABLE_LAYERS;
480}
481
482
484{
485 m_LayersManager->SelectLayer( GetActiveLayer() );
486}
487
488
489void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
490{
491 if( aRebuildLayerBox )
492 m_SelLayerBox->Resync();
493
494 m_SelLayerBox->SetSelection( GetActiveLayer() );
495
496 int dcodeSelected = -1;
498
499 if( gerber )
500 dcodeSelected = gerber->m_Selected_Tool;
501
502 if( m_DCodeSelector )
503 {
505 m_DCodeSelector->SetDCodeSelection( dcodeSelected );
506 m_DCodeSelector->Enable( gerber != nullptr );
507 }
508}
509
510
512{
513 RemapLayers( GetImagesList()->SortImagesByFileExtension() );
514}
515
516
518{
519 RemapLayers( GetImagesList()->SortImagesByZOrder() );
520}
521
522
523void GERBVIEW_FRAME::RemapLayers( const std::unordered_map<int, int>& remapping )
524{
525 // Save the visibility of each existing gerber layer, in order to be able
526 // to restore this visibility after layer reorder.
527 // Note: the visibility of other objects (D_CODE, negative objects ... )
528 // must be not modified
529 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
530 {
531 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
532
533 if( gerber )
534 {
535 if( IsLayerVisible( currlayer ) )
536 gerber->SetFlags( CANDIDATE );
537 else
538 gerber->ClearFlags( CANDIDATE );
539 }
540
541 }
542
543 std::unordered_map<int, int> view_remapping;
544
545 for( const std::pair<const int, int>& entry : remapping )
546 {
547 view_remapping[ GERBER_DRAW_LAYER( entry.first ) ] = GERBER_DRAW_LAYER( entry.second );
548 view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second );
549 }
550
551 GetCanvas()->GetView()->ReorderLayerData( view_remapping );
552
553 // Restore visibility of gerber layers
554 LSET newVisibility = GetVisibleLayers();
555
556 for( int currlayer = GERBER_DRAWLAYERS_COUNT-1; currlayer >= 0; --currlayer )
557 {
558 GERBER_FILE_IMAGE* gerber = GetImagesList()->GetGbrImage( currlayer );
559
560 if( gerber )
561 {
562 if( gerber->HasFlag( CANDIDATE ) )
563 newVisibility.set( currlayer );
564 else
565 newVisibility.set( currlayer, false );
566
567 gerber->ClearFlags( CANDIDATE );
568 }
569 }
570
571 SetVisibleLayers( newVisibility );
572
574 syncLayerBox( true );
575
576 // Reordering draw layers need updating the view items
580
581 GetCanvas()->Refresh();
582}
583
584
586{
587 // Adjust draw params: draw offset and draw rotation for a gerber file image
589
590 if( !gerber )
591 return;
592
593 DIALOG_DRAW_LAYERS_SETTINGS dlg( this );
594
595 if( dlg.ShowModal() != wxID_OK )
596 return;
597
598 KIGFX::VIEW* view = GetCanvas()->GetView();
599
600 view->RecacheAllItems();
601 view->MarkDirty();
602 view->UpdateAllItems( KIGFX::ALL );
603
604 GetCanvas()->Refresh();
605}
606
607
609{
613 KIGFX::VIEW* view = GetCanvas()->GetView();
614
615 int lastVisibleLayer = -1;
616
617 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
618 {
619 view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_XORMode );
620
621 // Caching doesn't work with layered rendering of XOR'd layers
622 if( gvconfig()->m_Display.m_XORMode )
624 else
625 view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
626
627 // We want the last visible layer, but deprioritize the active layer unless it's the
628 // only layer
629 if( ( lastVisibleLayer == -1 )
630 || ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
631 {
632 lastVisibleLayer = i;
633 }
634 }
635
636 //We don't want to diff the last visible layer onto the background, etc.
637 if( lastVisibleLayer != -1 )
638 {
639 view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
640 view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
641 }
642
643 view->RecacheAllItems();
644 view->MarkDirty();
645 view->UpdateAllItems( KIGFX::ALL );
646}
647
648
650{
652
653 // Display the gerber filename
654 if( gerber == nullptr )
655 {
656 SetTitle( _("Gerber Viewer") );
657
658 SetStatusText( wxEmptyString, 0 );
659
660 wxString info = _( "Drawing layer not in use" );
661 m_TextInfo->SetValue( info );
662
663 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
664 m_auimgr.Update();
665
667 return;
668 }
669 else
670 {
671 wxString title;
672 wxFileName filename( gerber->m_FileName );
673
674 title = filename.GetFullName();
675
676 if( gerber->m_IsX2_file )
677 title += wxS( " " ) + _( "(with X2 attributes)" );
678
679 title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
680 SetTitle( title );
681
682 gerber->DisplayImageInfo( this );
683
684 // Display Image Name and Layer Name (from the current gerber data):
685 wxString status;
686 status.Printf( _( "Image name: '%s' Layer name: '%s'" ),
687 gerber->m_ImageName,
688 gerber->GetLayerParams().m_LayerName );
689 SetStatusText( status, 0 );
690
691 // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
692 wxString info;
693 info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
694 gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
695 gerber->m_FmtLen.x - gerber->m_FmtScale.x,
696 gerber->m_FmtScale.x,
697 gerber->m_FmtLen.y - gerber->m_FmtScale.y,
698 gerber->m_FmtScale.y,
699 gerber->m_NoTrailingZeros ? 'T' : 'L' );
700
701 if( gerber->m_IsX2_file )
702 info << wxT(" ") << _( "X2 attr" );
703
704 m_TextInfo->SetValue( info );
705
706 if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
707 m_auimgr.Update();
708 }
709}
710
711
712bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
713{
714 switch( aLayerID )
715 {
718 case LAYER_GERBVIEW_GRID: return IsGridVisible();
721 case LAYER_GERBVIEW_BACKGROUND: return true;
722
723 default:
724 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ),
725 aLayerID ) );
726 }
727
728 return true;
729}
730
731
733{
734 LSET visible = LSET::AllLayersMask();
735
736 if( GetCanvas() )
737 {
738 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
739 visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
740 }
741
742 return visible;
743}
744
745
746void GERBVIEW_FRAME::SetVisibleLayers( const LSET& aLayerMask )
747{
748 if( GetCanvas() )
749 {
750 for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
751 {
752 bool v = aLayerMask[i];
753 int layer = GERBER_DRAW_LAYER( i );
754 GetCanvas()->GetView()->SetLayerVisible( layer, v );
756 gvconfig()->m_Appearance.show_dcodes && v );
757 }
758 }
759}
760
761
762bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
763{
764 return m_LayersManager->IsLayerVisible( aLayer );
765}
766
767
769{
771 COLOR_SETTINGS* settings = GetColorSettings();
772
773 switch( aLayerID )
774 {
776 case LAYER_DCODES:
780 color = settings->GetColor( aLayerID );
781 break;
782
785 break;
786
787 default:
788 wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
789 aLayerID ) );
790 }
791
792 return color;
793}
794
795
797{
799 m_LayersManager->SetRenderState( LAYER_GERBVIEW_GRID, aVisible );
800}
801
802
803void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
804{
805 COLOR_SETTINGS* settings = GetColorSettings();
806
807 settings->SetColor( aLayerID, aColor );
808
809 switch( aLayerID )
810 {
814 break;
815
817 SetGridColor( aColor );
818 break;
819
821 SetDrawBgColor( aColor );
822 break;
823
824 default:
825 break;
826 }
827}
828
829
831{
832 return GetColorSettings()->GetColor( aLayer );
833}
834
835
836void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
837{
838 GetColorSettings()->SetColor( aLayer, aColor );
840}
841
842
843void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
844{
845 m_activeLayer = aLayer;
846
847 if( gvconfig()->m_Display.m_XORMode )
849
850 if( doLayerWidgetUpdate )
851 {
852 m_LayersManager->SelectLayer( aLayer );
853 m_LayersManager->OnLayerSelected();
854 }
855
857
858 m_toolManager->PostAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
859 GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
860
862 GetCanvas()->Refresh();
863}
864
865
866void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
867{
868 m_paper = aPageSettings;
869
870 if( GetScreen() )
871 GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( gerbIUScale.IU_PER_MILS ) );
872
873 GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
874
875 // Prepare drawing-sheet template
877 &Prj(), &GetTitleBlock(), nullptr );
878
879 if( GetScreen() )
880 {
881 drawingSheet->SetPageNumber( "1" );
882 drawingSheet->SetSheetCount( 1 );
883 }
884
887
888 // Draw panel takes ownership of the drawing-sheet
889 drawPanel->SetDrawingSheet( drawingSheet );
890}
891
892
894{
895 return m_paper;
896}
897
898
900{
901 // this function is only needed because EDA_DRAW_FRAME is not compiled
902 // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
903 // into an application specific source file.
904 return GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS );
905}
906
907
909{
910 wxASSERT( m_gerberLayout );
911 return m_gerberLayout->GetTitleBlock();
912}
913
914
916{
917 wxASSERT( m_gerberLayout );
918 m_gerberLayout->SetTitleBlock( aTitleBlock );
919}
920
921
926
927
929{
931 GetCanvas()->GetGAL()->SetGridColor( aColor );
932 m_gridColor = aColor;
933}
934
935
937{
938 VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
939 wxString line;
940
941 line.Printf( wxT( "grid X %s Y %s" ),
942 MessageTextFromValue( gridSize.x, false ),
943 MessageTextFromValue( gridSize.y, false ) );
944
945 SetStatusText( line, 4 );
946 SetStatusText( line, 4 );
947}
948
949
951{
953
954 if( !GetScreen() )
955 return;
956
957 wxString line;
959
960 if( GetShowPolarCoords() ) // display relative polar coordinates
961 {
962 VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
963 EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
964 double ro = hypot( v.x, v.y );
965
966 line.Printf( wxT( "r %s theta %s" ),
967 MessageTextFromValue( ro, false ),
968 MessageTextFromValue( theta, false ) );
969
970 SetStatusText( line, 3 );
971 }
972
973 // Display absolute coordinates:
974 line.Printf( wxT( "X %s Y %s" ),
975 MessageTextFromValue( cursorPos.x, false ),
976 MessageTextFromValue( cursorPos.y, false ) );
977 SetStatusText( line, 2 );
978
979 if( !GetShowPolarCoords() )
980 {
981 // Display relative cartesian coordinates:
982 double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
983 double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
984
985 line.Printf( wxT( "dx %s dy %s dist %s" ),
986 MessageTextFromValue( dXpos, false ),
987 MessageTextFromValue( dYpos,false ),
988 MessageTextFromValue( hypot( dXpos, dYpos ), false ) );
989 SetStatusText( line, 3 );
990 }
991
993}
994
995
997{
998 return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
999}
1000
1001
1003{
1004 return m_gerberLayout->GetImagesList()->ImagesMaxCount();
1005}
1006
1007
1009{
1010 // Called on units change (see EDA_DRAW_FRAME)
1014}
1015
1016
1018{
1020
1021 EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
1022
1023 if( m_toolManager )
1024 {
1025 m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
1026 GetCanvas()->GetViewControls(), config(), this );
1027 m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
1028 }
1029
1031
1033
1034 galCanvas->GetView()->RecacheAllItems();
1036 galCanvas->StartDrawing();
1037
1038 m_LayersManager->ReFill();
1039 m_LayersManager->ReFillRender();
1040
1043
1044 try
1045 {
1046 if( !m_spaceMouse )
1047 {
1048#ifndef __linux__
1049 m_spaceMouse = std::make_unique<NL_GERBVIEW_PLUGIN>();
1050#else
1051 m_spaceMouse = std::make_unique<SPNAV_2D_PLUGIN>( galCanvas );
1052 m_spaceMouse->SetScale( gerbIUScale.IU_PER_MILS / pcbIUScale.IU_PER_MILS );
1053#endif
1054 }
1055
1056 m_spaceMouse->SetCanvas( galCanvas );
1057 }
1058 catch( const std::system_error& e )
1059 {
1060 wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
1061 }
1062}
1063
1064
1066{
1067 // Create the manager and dispatcher & route draw panel events to the dispatcher
1069 m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
1070 GetCanvas()->GetViewControls(), config(), this );
1073
1074 // Register tools
1075 m_toolManager->RegisterTool( new COMMON_CONTROL );
1076 m_toolManager->RegisterTool( new COMMON_TOOLS );
1077 m_toolManager->RegisterTool( new GERBVIEW_SELECTION_TOOL );
1078 m_toolManager->RegisterTool( new GERBVIEW_CONTROL );
1079 m_toolManager->RegisterTool( new GERBVIEW_INSPECTION_TOOL );
1080 m_toolManager->RegisterTool( new ZOOM_TOOL );
1081 m_toolManager->InitTools();
1082
1083 // Run the selection tool, it is supposed to be always active
1084 m_toolManager->InvokeTool( "common.InteractiveSelection" );
1085}
1086
1087
1089{
1091
1092 ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
1093 EDITOR_CONDITIONS cond( this );
1094
1095 wxASSERT( mgr );
1096
1097#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
1098#define CHECK( x ) ACTION_CONDITIONS().Check( x )
1099
1103
1109
1113
1114 auto flashedDisplayOutlinesCond =
1115 [this] ( const SELECTION& )
1116 {
1118 };
1119
1120 auto linesFillCond =
1121 [this] ( const SELECTION& )
1122 {
1124 };
1125
1126 auto polygonsFilledCond =
1127 [this] ( const SELECTION& )
1128 {
1130 };
1131
1132 auto negativeObjectsCond =
1133 [this] ( const SELECTION& )
1134 {
1136 };
1137
1138 auto dcodeCond =
1139 [this] ( const SELECTION& )
1140 {
1142 };
1143
1144 auto forceOpacityModeCond =
1145 [this] ( const SELECTION& )
1146 {
1148 };
1149
1150 auto xorModeCond =
1151 [this] ( const SELECTION& )
1152 {
1153 return gvconfig()->m_Display.m_XORMode;
1154 };
1155
1156 auto highContrastModeCond =
1157 [this] ( const SELECTION& )
1158 {
1160 };
1161
1162 auto flipGerberCond =
1163 [this] ( const SELECTION& )
1164 {
1166 };
1167
1168 auto layersManagerShownCondition =
1169 [this] ( const SELECTION& aSel )
1170 {
1172 };
1173
1174 mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
1176 mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
1177 mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
1179 mgr->SetConditions( GERBVIEW_ACTIONS::toggleForceOpacityMode, CHECK( forceOpacityModeCond ) );
1180 mgr->SetConditions( GERBVIEW_ACTIONS::toggleXORMode, CHECK( xorModeCond ) );
1181 mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
1182 mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
1183 mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, CHECK( layersManagerShownCondition ) );
1184
1185#undef CHECK
1186#undef ENABLE
1187}
1188
1189
1191{
1193
1194 // Update gal display options like cursor shape, grid options:
1195 if( GERBVIEW_SETTINGS* cfg = GetAppSettings<GERBVIEW_SETTINGS>( "gerbview" ) )
1196 {
1197 GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
1198
1199 PAGE_INFO pgInfo;
1200 pgInfo.SetType( cfg->m_Appearance.page_type );
1201
1202 SetPageSettings( pgInfo );
1203 SetElementVisibility( LAYER_DCODES, cfg->m_Appearance.show_dcodes );
1204 }
1205
1207
1211
1213 ReFillLayerWidget(); // Update the layers list
1214 m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
1215
1216 Layout();
1217 SendSizeEvent();
1218}
1219
1220
1222{
1223 return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
1224}
1225
1226
1228{
1230
1231 // show/hide auxiliary Vertical layers and visibility manager toolbar
1232 m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
1233 m_auimgr.Update();
1234}
1235
1236void GERBVIEW_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
1237{
1239
1240 if( m_spaceMouse )
1241 m_spaceMouse->SetFocus( aEvent.GetActive() );
1242}
1243
1244void GERBVIEW_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
1245{
1247
1248 if( m_spaceMouse )
1249 m_spaceMouse->SetFocus( false );
1250}
int color
BASE_SCREEN class implementation.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr EDA_IU_SCALE gerbIUScale
Definition base_units.h:111
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
@ icon_gerbview_16
@ icon_gerbview_32
static TOOL_ACTION toggleGrid
Definition actions.h:197
static TOOL_ACTION millimetersUnits
Definition actions.h:205
static TOOL_ACTION cursorSmallCrosshairs
Definition actions.h:151
static TOOL_ACTION togglePolarCoords
Definition actions.h:208
static TOOL_ACTION milsUnits
Definition actions.h:204
static TOOL_ACTION inchesUnits
Definition actions.h:203
static TOOL_ACTION highContrastMode
Definition actions.h:154
static TOOL_ACTION measureTool
Definition actions.h:251
static TOOL_ACTION selectionTool
Definition actions.h:250
static TOOL_ACTION zoomFitScreen
Definition actions.h:141
static TOOL_ACTION zoomTool
Definition actions.h:145
static TOOL_ACTION cursor45Crosshairs
Definition actions.h:153
static TOOL_ACTION cursorFullCrosshairs
Definition actions.h:152
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.
wxString m_ColorTheme
Active color theme name.
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)
BASE_SET & set(size_t pos)
Definition base_set.h:116
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:398
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 setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void UpdateToolbarControlSizes()
Update the sizes of any controls in the toolbars of the frame.
TOOLBAR_SETTINGS * m_toolbarSettings
wxAuiManager m_auimgr
virtual void RecreateToolbars()
ACTION_TOOLBAR * m_tbLeft
ACTION_TOOLBAR * m_tbTopAux
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
ACTION_TOOLBAR * m_tbTopMain
wxString m_aboutTitle
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
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.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
EDA_MSG_PANEL * m_messagePanel
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
virtual void SetScreen(BASE_SCREEN *aScreen)
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 ...
bool IsGridVisible() const
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
bool m_showBorderAndTitleBlock
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
void SetFocus() override
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void StartDrawing()
Begin drawing if it was stopped previously.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:142
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:144
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:146
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 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:46
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:104
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
const VECTOR2D & GetGridSize() const
Return the grid size.
Methods for drawing GerbView specific items.
Store GerbView specific render settings.
void LoadColors(const COLOR_SETTINGS *aSettings) override
void SetHighContrast(bool aEnabled)
Turns on/off high contrast display mode.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:86
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
void SetLayerDiff(int aLayer, bool aDiff=true)
Set the whether the layer should drawn differentially.
Definition view.h:438
void SetLayerTarget(int aLayer, RENDER_TARGET aTarget)
Change the rendering target for a particular layer.
Definition view.h:497
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
Definition view.h:400
void Clear()
Remove all items from the view.
Definition view.cpp:1143
void RecacheAllItems()
Rebuild GAL display lists.
Definition view.cpp:1451
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition view.cpp:1561
void MarkDirty()
Force redraw of view on the next rendering.
Definition view.h:659
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition view.h:422
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:220
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
Definition view.h:639
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:1571
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:286
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & AllLayersMask()
Definition lset.cpp:624
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition page_info.h:79
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:177
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition pgm_base.cpp:576
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:125
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:41
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:82
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: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:60
@ ID_GERBVIEW_DRILL_FILE1
Definition gerbview_id.h:52
@ ID_GERBVIEW_ZIP_FILE_LIST_CLEAR
Definition gerbview_id.h:66
@ ID_GERBVIEW_JOB_FILE1
Definition gerbview_id.h:58
@ ID_GERBVIEW_ZIP_FILE1
Definition gerbview_id.h:64
@ ID_GERBVIEW_DRILL_FILE_LIST_CLEAR
Definition gerbview_id.h:54
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:49
@ LAYER_GERBVIEW_DRAWINGSHEET
Definition layer_ids.h:531
@ LAYER_GERBVIEW_BACKGROUND
Definition layer_ids.h:530
@ LAYER_DCODES
Definition layer_ids.h:526
@ LAYER_NEGATIVE_OBJECTS
Definition layer_ids.h:527
@ LAYER_GERBVIEW_PAGE_LIMITS
Definition layer_ids.h:532
@ LAYER_GERBVIEW_GRID
Definition layer_ids.h:528
#define GERBER_DCODE_LAYER(x)
Definition layer_ids.h:539
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition layer_ids.h:277
#define GERBER_DRAWLAYERS_COUNT
Number of draw layers in Gerbview.
Definition layer_ids.h:516
#define GERBER_DRAW_LAYER(x)
Definition layer_ids.h:537
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:58
@ ALL
All except INITIAL_ADD.
Definition view_item.h:59
@ TARGET_NONCACHED
Auxiliary rendering target (noncached)
Definition definitions.h:38
@ TARGET_CACHED
Main rendering target (cached)
Definition definitions.h:37
KICOMMON_API bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=nullptr)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
Declaration of the NL_GERBVIEW_PLUGIN class.
#define _HKI(x)
Definition page_info.cpp:44
PGM_BASE & Pgm()
The global program "get" accessor.
Definition pgm_base.cpp:913
see class PGM_BASE
#define DEFAULT_THEME
T * GetToolbarSettings(const wxString &aFilename)
T * GetAppSettings(const char *aFilename)
std::vector< FAB_LAYER_COLOR > dummy
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694
Definition of file extensions used in Kicad.