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 
32 
33 void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle )
34 {
35  wxCHECK2_MSG( aRotationAngle > 0 && aRotationAngle <= 900, aRotationAngle = 900,
36  wxT( "Invalid rotation angle, defaulting to 90." ) );
37 
38  m_rotationAngle = aRotationAngle;
39 }
40 
41 
43 {
45 
46  // No matter what, reenable undo/redo on switching to the legacy canvas
47  if( !aEnable )
48  UndoRedoBlock( false );
49  else
50  static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
51 }
52 
53 
55 {
56  bool new_board = ( aBoard != m_Pcb );
57 
58  // The active tool might store a reference to the BOARD that is about to be deleted.
59  if( m_toolManager )
61 
62  // It has to be done before the previous board is destroyed by SetBoard()
63  if( new_board )
64  GetGalCanvas()->GetView()->Clear();
65 
66  PCB_BASE_FRAME::SetBoard( aBoard );
67 
69 
70  // update the tool manager with the new board and its view.
71  if( m_toolManager )
72  {
73  PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
74 
75  drawPanel->DisplayBoard( aBoard );
76  m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(),
77  drawPanel->GetViewControls(), this );
78 
79  if( new_board )
81  }
82 }
TOOL_MANAGER * m_toolManager
Definition: draw_frame.h:94
virtual void SetBoard(BOARD *aBoard)
Function SetBoard sets the m_Pcb member in such as way as to ensure deleting any previous BOARD...
void DisplayBoard(const BOARD *aBoard)
Function DisplayBoard adds all items from the current board to the VIEW, so they can be displayed by ...
const wxPoint & GetGridOrigin() const
Definition: class_board.h:342
Model changes (required full reload)
Definition: tool_base.h:83
Class BOARD to handle a board.
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetGridOrigin(const VECTOR2D &aGridOrigin)
Set the origin point for the grid.
void DeactivateTool()
Function DeactivateTool() Deactivates the currently active tool.
void UseGalCanvas(bool aEnable) override
>
virtual void UseGalCanvas(bool aEnable) override
>
KIGFX::GAL * GetGAL() const
Function GetGAL() Returns a pointer to the GAL instance used in the panel.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, wxWindow *aFrame)
Sets the work environment (model, view, view controls and the parent window).
void Clear()
Function Clear() Removes all items from the view.
Definition: view.cpp:982
void ResetTools(TOOL_BASE::RESET_REASON aReason)
Function ResetTools() Resets all tools (i.e.
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:169
virtual void SetBoard(BOARD *aBoard) override
>
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel...
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:817
void SetRotationAngle(int aRotationAngle)
Function SetRotationAngle() Sets the angle used for rotate operations.