KiCad PCB EDA Suite
panel_pcbnew_display_origin.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) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2019 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 
25 #include <board_design_settings.h>
26 #include <board.h>
28 #include <pcb_edit_frame.h>
29 #include <pcb_painter.h>
30 #include <pcb_view.h>
31 #include <pcbnew_id.h>
32 #include <widgets/paged_dialog.h>
33 
35  PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent )
36  : PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent->GetTreebook() ),
37  m_Frame( aFrame )
38 {
39 }
40 
41 
43 {
44  const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
45 
46  int origin = 0;
47 
48  switch( displ_opts.m_DisplayOrigin )
49  {
50  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE: origin = 0; break;
51  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = 1; break;
52  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = 2; break;
53  }
54 
55  m_DisplayOrigin->SetSelection( origin );
56  m_XAxisDirection->SetSelection( displ_opts.m_DisplayInvertXAxis ? 1 : 0 );
57  m_YAxisDirection->SetSelection( displ_opts.m_DisplayInvertYAxis ? 0 : 1 );
58 
59  return true;
60 }
61 
62 
64 {
66 
67  switch( m_DisplayOrigin->GetSelection() )
68  {
69  case 0: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE; break;
70  case 1: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX; break;
71  case 2: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID; break;
72  }
73 
74  displ_opts.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
75  displ_opts.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
76 
77  m_Frame->SetDisplayOptions( displ_opts );
78 
79  return true;
80 }
Class PANEL_PCBNEW_DISPLAY_ORIGIN_BASE.
PANEL_PCBNEW_DISPLAY_ORIGIN(PCB_EDIT_FRAME *aFrame, PAGED_DIALOG *aWindow)
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions, bool aRefresh=true)
Updates the current display options from the given options struct.
Container for display options like enable/disable some optional drawings.
PCB_DISPLAY_ORIGIN_OPTIONS_T m_DisplayOrigin
Which origin is used for display transforms.
The main frame for Pcbnew.