KiCad PCB EDA Suite
panel_gerbview_display_options.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) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2018 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 
22 #include <fctsys.h>
23 #include <common.h>
24 #include <class_drawpanel.h>
25 
26 #include <gerbview.h>
27 #include <gerbview_frame.h>
28 #include <class_draw_panel_gal.h>
29 #include <view/view.h>
30 #include <gerbview_painter.h>
34 
35 
37  wxWindow* aWindow ) :
38  PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aWindow, wxID_ANY ),
39  m_Parent( aFrame )
40 {
42  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
43  m_galOptionsSizer->Add( m_galOptsPanel, 0, wxEXPAND | wxLEFT, 5 );
44 }
45 
46 
48 {
50 
51  // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
54 
55  // Show Option Draw polygons
57 
59 
60  return true;
61 }
62 
63 
65 {
66  auto displayOptions = (GBR_DISPLAY_OPTIONS*) m_Parent->GetDisplayOptions();
67 
68  bool needs_repaint = false, option;
69 
70  option = !m_OptDisplayLines->GetValue();
71 
73  needs_repaint = true;
74 
76 
77  option = !m_OptDisplayFlashedItems->GetValue();
78 
80  needs_repaint = true;
81 
83 
84  option = !m_OptDisplayPolygons->GetValue();
85 
87  needs_repaint = true;
88 
90 
92 
94 
95  // Apply changes to the GAL
96  auto view = m_Parent->GetGalCanvas()->GetView();
97  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
98  auto settings = painter->GetSettings();
99  settings->LoadDisplayOptions( displayOptions );
100  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
101 
102  if( needs_repaint )
103  view->UpdateAllItems( KIGFX::REPAINT );
104 
105  m_Parent->GetCanvas()->Refresh();
106 
107  return true;
108 }
109 
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
virtual EDA_DRAW_PANEL * GetCanvas() const
Definition: draw_frame.h:388
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
Definition: draw_frame.h:936
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
Auxiliary rendering target (noncached)
Definition: definitions.h:42
PANEL_GERBVIEW_DISPLAY_OPTIONS(GERBVIEW_FRAME *aFrame, wxWindow *aWindow)
Class PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE.
Item is being added to the view.
Definition: view_item.h:60
bool TransferDataToWindow() override
Load the panel controls from the given opt.
Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.
GBR_DISPLAY_OPTIONS m_DisplayOptions
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
The common library.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:918
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
virtual void * GetDisplayOptions()
A way to pass info to draw functions.
Definition: draw_frame.h:931
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.