KiCad PCB EDA Suite
pcb_base_edit_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) 2014 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 <pcb_base_edit_frame.h>
26 #include <tool/tool_manager.h>
27 #include <pcb_draw_panel_gal.h>
29 #include <class_board.h>
30 #include <view/view.h>
31 #include "footprint_info_impl.h"
32 #include <project.h>
33 #include <tools/pcb_actions.h>
34 
35 PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
36  FRAME_T aFrameType, const wxString& aTitle,
37  const wxPoint& aPos, const wxSize& aSize, long aStyle,
38  const wxString& aFrameName ) :
39  PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ),
40  m_rotationAngle( 900 ), m_undoRedoBlocked( false )
41 {
42  if( !GFootprintList.GetCount() )
43  {
44  wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
45  GFootprintList.ReadCacheFromFile( &footprintInfoCache );
46  }
47 }
48 
50 {
51  wxTextFile footprintInfoCache( Prj().GetProjectPath() + "fp-info-cache" );
52  GFootprintList.WriteCacheToFile( &footprintInfoCache );
53 
54  GetCanvas()->GetView()->Clear();
55 }
56 
57 
58 void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
59 {
60  wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900,
61  wxT( "Invalid rotation angle, defaulting to 90." ) );
62 
63  m_rotationAngle = aRotationAngle;
64 }
65 
66 
68 {
70 
72 }
73 
74 
76 {
77  bool new_board = ( aBoard != m_Pcb );
78 
79  if( new_board )
80  {
81  if( m_toolManager )
83 
84  GetCanvas()->GetView()->Clear();
85  }
86 
87  PCB_BASE_FRAME::SetBoard( aBoard );
88 
89  GetCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) );
90 
91  // update the tool manager with the new board and its view.
92  if( m_toolManager )
93  {
94  GetCanvas()->DisplayBoard( aBoard );
95  GetCanvas()->UseColorScheme( &Settings().Colors() );
96  m_toolManager->SetEnvironment( aBoard, GetCanvas()->GetView(),
97  GetCanvas()->GetViewControls(), this );
98 
99  if( new_board )
101  }
102 }
103 
104 
106 {
108 
110 
111  if( m_toolManager )
113 }
114 
115 
void WriteCacheToFile(wxTextFile *aFile) override
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD.
PCB_BASE_EDIT_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName)
virtual void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
void ActivateGalCanvas() override
Model changes (required full reload)
Definition: tool_base.h:82
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static TOOL_ACTION updateUnits
Definition: pcb_actions.h:404
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
FOOTPRINT_LIST_IMPL GFootprintList
The global footprint info table.
Definition: pcbnew.cpp:308
unsigned GetCount() const
virtual void ActivateGalCanvas() override
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
void DisplayBoard(BOARD *aBoard)
Function DisplayBoard adds all items from the current board to the VIEW, so they can be displayed by ...
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:1111
PCB_GENERAL_SETTINGS & Settings()
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
void SyncLayersVisibility(const BOARD *aBoard)
Function SyncLayersVisibility Updates "visibility" property of each layer of a given BOARD.
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
const wxPoint & GetGridOrigin() const
Definition: class_board.h:370
void UseColorScheme(const COLORS_DESIGN_SETTINGS *aSettings)
Function UseColorScheme Applies layer color settings.
int m_rotationAngle
User defined rotation angle (in tenths of a degree).
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
virtual void SetBoard(BOARD *aBoard) override
void ReadCacheFromFile(wxTextFile *aFile) override
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
virtual void ReCreateAuxiliaryToolbar()
TOOL_MANAGER * m_toolManager
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.