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 
36 #include <gerbview.h>
37 #include <gerbview_frame.h>
39 
40 
41 /*******************************************/
42 /* Dialog frame to select display options */
43 /*******************************************/
45 {
46 private:
48 
49 public:
50 
53 
54 private:
55  void OnOKBUttonClick( wxCommandEvent& event ) override;
56  void OnCancelButtonClick( wxCommandEvent& event ) override;
57  void initOptDialog( );
58 };
59 
60 
61 void GERBVIEW_FRAME::InstallGerberOptionsDialog( wxCommandEvent& event )
62 {
63  DIALOG_DISPLAY_OPTIONS dlg( this );
64  int opt = dlg.ShowModal();
65 
66  if( opt > 0 )
67  m_canvas->Refresh();
68 }
69 
70 
72  DIALOG_DISPLAY_OPTIONS_BASE( parent, wxID_ANY )
73 {
74  m_Parent = parent;
75  SetFocus();
76  initOptDialog( );
77 
78  GetSizer()->Fit( this );
79  GetSizer()->SetSizeHints( this );
80  Center();
81  m_sdbSizer1OK->SetDefault();
82 }
83 
84 
85 void DIALOG_DISPLAY_OPTIONS::OnCancelButtonClick( wxCommandEvent& event )
86 {
87  EndModal( 0 );
88 }
89 
90 
92 {
94  m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
95 
96  // @todo: LEGACY: Cursor shape can be set using the GAL options
97  // widget, when that is added to gerbview. For now, access the
98  // setting via the frame's GAL options object directly
99 
100  // Cursor shape cannot be implemented on OS X
101 #ifdef __APPLE__
102  m_CursorShape->Hide();
103 #else
104  {
105  auto& galOpts = m_Parent->GetGalDisplayOptions();
106  m_CursorShape->SetSelection( galOpts.m_fullscreenCursor ? 1 : 0 );
107  }
108 #endif // __APPLE__
109 
110  // Show Option Draw Lines. We use DisplayPcbTrackFill as Lines draw option
113 
114  // Show Option Draw polygons
116 
117  m_ShowPageLimits->SetSelection(0);
118 
120  {
121  wxString curPaperType = m_Parent->GetPageSettings().GetType();
122 
123  for( unsigned i = 1; i < DIM( g_GerberPageSizeList ); ++i )
124  {
125  if( g_GerberPageSizeList[i] == curPaperType )
126  {
127  m_ShowPageLimits->SetSelection( i );
128  break;
129  }
130  }
131  }
132 
134 
135 
138 }
139 
140 
141 void DIALOG_DISPLAY_OPTIONS::OnOKBUttonClick( wxCommandEvent& event )
142 {
144  (m_PolarDisplay->GetSelection() == 0) ? false : true;
145  g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
146 
147  // @todo LEGACY: as above, this should be via the GAL display widget
148 #ifndef __APPLE__
149  {
150  auto& galOpts = m_Parent->GetGalDisplayOptions();
151  galOpts.m_fullscreenCursor = m_CursorShape->GetSelection();
152  }
153 #endif // !__APPLE__
154 
155  if( m_OptDisplayLines->GetSelection() == 1 )
157  else
159 
160  if( m_OptDisplayFlashedItems->GetSelection() == 1 )
161  {
163  }
164  else
165  {
167  }
168 
169 
170  if( m_OptDisplayPolygons->GetSelection() == 0 )
172  else
174 
176 
177  int idx = m_ShowPageLimits->GetSelection();
178 
179  m_Parent->SetShowBorderAndTitleBlock( idx > 0 ? true : false );
180 
181  PAGE_INFO pageInfo( g_GerberPageSizeList[idx] );
182 
183  m_Parent->SetPageSettings( pageInfo );
184 
187 
188  m_Parent->GetCanvas()->Refresh();
189 
190  EndModal( 1 );
191 }
192 
#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:838
void OnOKBUttonClick(wxCommandEvent &event) override
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
void SetEnableZoomNoCenter(bool aEnable)
Definition: draw_panel.cpp:657
EDA_DRAW_PANEL * GetCanvas()
Definition: draw_frame.h:299
void SetPageSettings(const PAGE_INFO &aPageSettings) override
bool GetShowBorderAndTitleBlock() const
Definition: draw_frame.h:293
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
This file contains miscellaneous commonly used macros and functions.
void OnCancelButtonClick(wxCommandEvent &event) override
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.
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:92
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:648
The common library.
void InstallGerberOptionsDialog(wxCommandEvent &event)
const wxString & GetType() const
bool m_fullscreenCursor
Fullscreen crosshair or small cross
void SetShowBorderAndTitleBlock(bool aShow)
Definition: draw_frame.h:295
const wxChar * g_GerberPageSizeList[]
List of page sizes.
Definition: gerbview.cpp:42