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-2021 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 
34 #include <wx/treebook.h>
35 
36 
38  PCB_EDIT_FRAME* aFrame, PAGED_DIALOG* aParent )
39  : PANEL_PCBNEW_DISPLAY_ORIGIN_BASE( aParent->GetTreebook() ),
40  m_Frame( aFrame )
41 {
42 }
43 
44 
46 {
47  const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
48 
49  int origin = 0;
50 
51  switch( displ_opts.m_DisplayOrigin )
52  {
53  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE: origin = 0; break;
54  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX: origin = 1; break;
55  case PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID: origin = 2; break;
56  }
57 
58  m_DisplayOrigin->SetSelection( origin );
59  m_XAxisDirection->SetSelection( displ_opts.m_DisplayInvertXAxis ? 1 : 0 );
60  m_YAxisDirection->SetSelection( displ_opts.m_DisplayInvertYAxis ? 0 : 1 );
61 
62  return true;
63 }
64 
65 
67 {
69 
70  switch( m_DisplayOrigin->GetSelection() )
71  {
72  case 0: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_PAGE; break;
73  case 1: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_AUX; break;
74  case 2: displ_opts.m_DisplayOrigin = PCB_DISPLAY_OPTIONS::PCB_ORIGIN_GRID; break;
75  }
76 
77  displ_opts.m_DisplayInvertXAxis = m_XAxisDirection->GetSelection() != 0;
78  displ_opts.m_DisplayInvertYAxis = m_YAxisDirection->GetSelection() == 0;
79 
80  m_Frame->SetDisplayOptions( displ_opts );
81 
82  return true;
83 }
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.