KiCad PCB EDA Suite
gerbview_dialog_display_options_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) 2010-2014 Jean-Pierre Charras jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU 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, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
31 #include <fctsys.h>
32 #include <common.h>
33 #include <macros.h>
34 #include <class_drawpanel.h>
35 #include <config_map.h>
36 
37 #include <gerbview.h>
38 #include <gerbview_frame.h>
40 
41 #include <class_draw_panel_gal.h>
42 #include <view/view.h>
43 #include <gerbview_painter.h>
46 
47 
48 /*******************************************/
49 /* Dialog frame to select display options */
50 /*******************************************/
52 {
53 private:
56 
57 public:
58 
61 
62 private:
63  void OnOKBUttonClick( wxCommandEvent& event ) override;
64  void OnCancelButtonClick( wxCommandEvent& event ) override;
65  void initOptDialog( );
66 };
67 
68 
69 void GERBVIEW_FRAME::InstallGerberOptionsDialog( wxCommandEvent& event )
70 {
71  DIALOG_DISPLAY_OPTIONS dlg( this );
72  int opt = dlg.ShowModal();
73 
74  if( opt > 0 )
75  m_canvas->Refresh();
76 }
77 
78 
80  DIALOG_DISPLAY_OPTIONS_BASE( parent, wxID_ANY )
81 {
82  m_Parent = parent;
83  SetFocus();
84  initOptDialog( );
85 
86  GetSizer()->Fit( this );
87  GetSizer()->SetSizeHints( this );
88  Center();
89  m_sdbSizer1OK->SetDefault();
90 
92 }
93 
94 
95 void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
96 {
97  EndModal( 0 );
98 }
99 
100 
102 {
104  m_galOptsPanel = new GAL_OPTIONS_PANEL( this, galOptions );
105  m_UpperSizer->Add( m_galOptsPanel, 0, wxEXPAND, 0 );
107 
109  m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
110 
111  // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
114 
115  // Show Option Draw polygons
117 
118  m_ShowPageLimits->SetSelection(0);
119 
121  {
122  wxString curPaperType = m_Parent->GetPageSettings().GetType();
123 
124  for( unsigned i = 1; i < DIM( g_GerberPageSizeList ); ++i )
125  {
126  if( g_GerberPageSizeList[i] == curPaperType )
127  {
128  m_ShowPageLimits->SetSelection( i );
129  break;
130  }
131  }
132  }
133 
137 }
138 
139 
140 void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
141 {
142  auto displayOptions = (GBR_DISPLAY_OPTIONS*) m_Parent->GetDisplayOptions();
143 
145  (m_PolarDisplay->GetSelection() == 0) ? false : true;
146  g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
147 
148  if( m_OptDisplayLines->GetSelection() == 1 )
150  else
152 
153  if( m_OptDisplayFlashedItems->GetSelection() == 1 )
154  {
156  }
157  else
158  {
160  }
161 
162  if( m_OptDisplayPolygons->GetSelection() == 0 )
164  else
166 
168 
169  int idx = m_ShowPageLimits->GetSelection();
170 
171  m_Parent->SetShowBorderAndTitleBlock( idx > 0 ? true : false );
172 
173  PAGE_INFO pageInfo( g_GerberPageSizeList[idx] );
174 
175  m_Parent->SetPageSettings( pageInfo );
176 
179 
181 
182  // Apply changes to the GAL
183  auto view = m_Parent->GetGalCanvas()->GetView();
184  auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( view->GetPainter() );
185  auto settings = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( painter->GetSettings() );
186  settings->LoadDisplayOptions( displayOptions );
187  view->RecacheAllItems();
188  view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
189 
190  m_Parent->GetCanvas()->Refresh();
191 
192  EndModal( 1 );
193 }
194 
#define DIM(x)
of elements in an array
Definition: macros.h:98
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Function GetGalDisplayOptions Returns a reference to the gal rendering options used by GAL for render...
Definition: draw_frame.h:891
void OnOKBUttonClick(wxCommandEvent &event) override
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:656
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:337
void SetPageSettings(const PAGE_INFO &aPageSettings) override
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
bool GetShowBorderAndTitleBlock() const
Definition: draw_frame.h:331
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
This file contains miscellaneous commonly used macros and functions.
void OnCancelButtonClick(wxCommandEvent &event) override
bool TransferDataToWindow() override
Load the panel controls from the given opt.
Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: common.h:145
GBR_DISPLAY_OPTIONS m_DisplayOptions
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool GetEnableZoomNoCenter() const
bool m_DisplayPolarCood
Option to display coordinates in status bar in X,Y or Polar coords.
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:56
const PAGE_INFO & GetPageSettings() const override
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void SetElementVisibility(GERBVIEW_LAYER_ID aItemIdVisible, bool aNewState)
Function SetElementVisibility changes the visibility of an element category.
bool GetEnableMousewheelPan() const
bool IsElementVisible(GERBVIEW_LAYER_ID aItemIdVisible) const
Function IsElementVisible tests whether a given element category is visible.
void SetEnableMousewheelPan(bool aEnable)
Definition: draw_panel.cpp:647
The common library.
void InstallGerberOptionsDialog(wxCommandEvent &event)
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
const wxString & GetType() const
void SetShowBorderAndTitleBlock(bool aShow)
Definition: draw_frame.h:333
virtual void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_frame.h:885
const wxChar * g_GerberPageSizeList[]
List of page sizes.
Definition: gerbview.cpp:38
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.