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 <fctsys.h>
22 #include <common.h>
23 #include <gerbview.h>
24 #include <gerbview_frame.h>
25 #include <class_draw_panel_gal.h>
26 #include <view/view.h>
27 #include <gerbview_painter.h>
31 
32 
34  wxWindow* aWindow ) :
35  PANEL_GERBVIEW_DISPLAY_OPTIONS_BASE( aWindow, wxID_ANY ),
36  m_Parent( aFrame )
37 {
39  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
40  m_galOptionsSizer->Add( m_galOptsPanel, 0, wxEXPAND | wxLEFT, 5 );
41 }
42 
43 
45 {
47 
48  // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
51 
52  // Show Option Draw polygons
54 
56 
57  return true;
58 }
59 
60 
62 {
64 
65  bool needs_repaint = false, option;
66 
67  option = !m_OptDisplayLines->GetValue();
68 
69  if( option != displayOptions.m_DisplayLinesFill )
70  needs_repaint = true;
71 
72  displayOptions.m_DisplayLinesFill = option;
73 
74  option = !m_OptDisplayFlashedItems->GetValue();
75 
77  needs_repaint = true;
78 
79  displayOptions.m_DisplayFlashedItemsFill = option;
80 
81  option = !m_OptDisplayPolygons->GetValue();
82 
83  if( option != displayOptions.m_DisplayPolygonsFill )
84  needs_repaint = true;
85 
86  displayOptions.m_DisplayPolygonsFill = option;
87 
89 
91 
92  // Apply changes to the GAL
93  auto view = m_Parent->GetCanvas()->GetView();
94  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
95  auto settings = painter->GetSettings();
96  settings->LoadDisplayOptions( displayOptions );
98 
99  if( needs_repaint )
100  view->UpdateAllItems( KIGFX::REPAINT );
101 
102  m_Parent->GetCanvas()->Refresh();
103 
104  return true;
105 }
106 
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
Function GetDisplayOptions returns the display options current in use.
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:60
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:585
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...
The common library.
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.