KiCad PCB EDA Suite
panel_edit_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) 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 <class_board.h>
27 #include <panel_edit_options.h>
28 #include <pcb_edit_frame.h>
29 #include <pcb_painter.h>
30 #include <pcb_view.h>
31 #include <pcbnew_settings.h>
32 #include <widgets/paged_dialog.h>
33 #include <footprint_edit_frame.h>
34 
36  PANEL_EDIT_OPTIONS_BASE( aParent->GetTreebook() ),
37  m_Frame( aFrame )
38 {
39  m_MagneticPads->Show( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_Frame ) != nullptr );
40  m_FlipLeftRight->Show( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) != nullptr );\
41 
42  m_optionsBook->SetSelection( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) ? 1 : 0 );
43 }
44 
45 
47 {
48  const PCB_DISPLAY_OPTIONS& displ_opts = m_Frame->GetDisplayOptions();
49  const PCBNEW_SETTINGS& general_opts = m_Frame->Settings();
50 
51  m_Segments_45_Only_Ctrl->SetValue( general_opts.m_Use45DegreeGraphicSegments );
52 
53  wxString rotationAngle;
54  rotationAngle = AngleToStringDegrees( (double)m_Frame->GetRotationAngle() );
55  m_RotationAngle->SetValue( rotationAngle );
56 
57  if( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) )
58  {
59  /* Set display options */
61  m_showSelectedRatsnest->SetValue( displ_opts.m_ShowModuleRatsnest );
62 
63  m_magneticPadChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.pads ) );
64  m_magneticTrackChoice->SetSelection( static_cast<int>( general_opts.m_MagneticItems.tracks ) );
65  m_magneticGraphicsChoice->SetSelection( !general_opts.m_MagneticItems.graphics );
66  m_FlipLeftRight->SetValue( general_opts.m_FlipLeftRight );
67 
69 
70  switch( general_opts.m_TrackDragAction )
71  {
72  case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break;
73  case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break;
74  case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break;
75  }
76  }
77  else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_Frame ) )
78  {
79  m_MagneticPads->SetValue(
81  }
82 
83  return true;
84 }
85 
86 
88 {
90 
91  m_Frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );
92 
94 
95  if( dynamic_cast<PCB_EDIT_FRAME*>( m_Frame ) )
96  {
97  PCBNEW_SETTINGS& pcbnewSettings = m_Frame->Settings();
98 
100  displ_opts.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
101 
103  static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
105  static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
107 
110 
111  if( m_rbTrackDragMove->GetValue() )
113  else if( m_rbTrackDrag45->GetValue() )
115  else if( m_rbTrackDragFree->GetValue() )
117  }
118  else if( dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_Frame ) )
119  {
120  if( m_MagneticPads->GetValue() )
122  else
124  }
125 
126  // Apply changes to the GAL
127  KIGFX::VIEW* view = m_Frame->GetCanvas()->GetView();
128  KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
129  KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
130 
131  m_Frame->SetDisplayOptions( displ_opts );
132  settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() );
133  view->RecacheAllItems();
135 
136  m_Frame->GetCanvas()->Refresh();
137 
138  return true;
139 }
140 
141 
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS &aOptions)
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
PANEL_EDIT_OPTIONS(PCB_BASE_EDIT_FRAME *aFrame, PAGED_DIALOG *aWindow)
PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:260
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions Display options control the way tracks, vias, outlines and other things ar...
PCB_BASE_EDIT_FRAME * m_Frame
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
bool ShowPageLimits() const
Auxiliary rendering target (noncached)
Definition: definitions.h:49
PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:64
bool m_Use45DegreeGraphicSegments
wxCheckBox * m_OptDisplayCurvedRatsnestLines
PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
TRACK_DRAG_ACTION m_TrackDragAction
virtual PCB_RENDER_SETTINGS * GetSettings() override
Definition: pcb_painter.h:272
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:571
wxString AngleToStringDegrees(double aAngle)
Function AngleToStringDegrees is a helper to convert the double aAngle (in internal unit) to a string...
Definition: base_units.cpp:456
virtual KIGFX::PCB_VIEW * GetView() const override
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...
int GetRotationAngle() const
Function GetRotationAngle() Returns the angle used for rotate operations.
Common, abstract interface for edit frames.
Class PANEL_EDIT_OPTIONS_BASE.
MAGNETIC_OPTIONS pads
PCBNEW_SETTINGS & Settings()
void SetShowPageLimits(bool aShow)
VIEW.
Definition: view.h:63
MAGNETIC_SETTINGS m_MagneticItems
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.
MAGNETIC_OPTIONS tracks