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 #include <gerbview.h>
22 #include <gerbview_frame.h>
23 #include <class_draw_panel_gal.h>
24 #include <view/view.h>
25 #include <gerbview_painter.h>
29 
30 
32  wxWindow* aWindow ) :
33  PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aWindow, wxID_ANY ),
34  m_Parent( aFrame )
35 {
37  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
38  m_galOptionsSizer->Add( m_galOptsPanel, 0, wxEXPAND | wxLEFT, 5 );
39 }
40 
41 
43 {
45 
46  // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
49 
50  // Show Option Draw polygons
52 
54 
55  return true;
56 }
57 
58 
60 {
62 
63  bool needs_repaint = false, option;
64 
65  option = !m_OptDisplayLines->GetValue();
66 
67  if( option != displayOptions.m_DisplayLinesFill )
68  needs_repaint = true;
69 
70  displayOptions.m_DisplayLinesFill = option;
71 
72  option = !m_OptDisplayFlashedItems->GetValue();
73 
75  needs_repaint = true;
76 
77  displayOptions.m_DisplayFlashedItemsFill = option;
78 
79  option = !m_OptDisplayPolygons->GetValue();
80 
81  if( option != displayOptions.m_DisplayPolygonsFill )
82  needs_repaint = true;
83 
84  displayOptions.m_DisplayPolygonsFill = option;
85 
87 
89 
90  // Apply changes to the GAL
91  auto view = m_Parent->GetCanvas()->GetView();
92  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
93  auto settings = painter->GetSettings();
94  settings->LoadDisplayOptions( displayOptions );
96 
97  if( needs_repaint )
98  view->UpdateAllItems( KIGFX::REPAINT );
99 
100  m_Parent->GetCanvas()->Refresh();
101 
102  return true;
103 }
104 
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
const GBR_DISPLAY_OPTIONS & GetDisplayOptions() const
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
Auxiliary rendering target (noncached)
Definition: definitions.h:49
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:62
bool TransferDataToWindow() override
Load the panel controls from the given opt.
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:571
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool IsElementVisible(int aLayerID) const
Function IsElementVisible tests whether a given element category is visible.
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetElementVisibility(int aLayerID, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.