KiCad PCB EDA Suite
3d_controller.h
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) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef _3D_VIEWER_CONTROL_H
25 #define _3D_VIEWER_CONTROL_H
26 
27 #include <tool/tool_interactive.h>
28 
29 class EDA_3D_VIEWER;
30 class BOARD_ADAPTER;
31 
32 
40 {
41 public:
43  : TOOL_INTERACTIVE( "3DViewer.Control" ),
44  m_canvas( nullptr ),
45  m_boardAdapter( nullptr ),
46  m_camera( nullptr ),
47  m_rotationIncrement( 10.0 )
48  { }
49 
50  ~EDA_3D_CONTROLLER() override { }
51 
53  bool Init() override;
54 
56  void Reset( RESET_REASON aReason ) override;
57 
58  int UpdateMenu( const TOOL_EVENT& aEvent );
59 
60  int Main( const TOOL_EVENT& aEvent );
61 
67  void SetRotationIncrement( double aRotIncrement )
68  {
69  m_rotationIncrement = aRotIncrement;
70  }
71 
78  {
79  return m_rotationIncrement;
80  }
81 
82  // View controls
83  int ZoomRedraw( const TOOL_EVENT& aEvent );
84  int ZoomInOut( const TOOL_EVENT& aEvent );
85  int ZoomInOutCenter( const TOOL_EVENT& aEvent );
86  int ZoomFitScreen( const TOOL_EVENT& aEvent );
87 
88  int PanControl( const TOOL_EVENT& aEvent );
89  int ViewControl( const TOOL_EVENT& aEvent );
90  int RotateView( const TOOL_EVENT& aEvent );
91 
92  int On3DGridSelection( const TOOL_EVENT& aEvent );
93 
94  int SetMaterial( const TOOL_EVENT& aEvent );
95 
96  int ToggleOrtho( const TOOL_EVENT& aEvent );
97  int ToggleVisibility( const TOOL_EVENT& aEvent );
98 
99 private:
101  void setTransitions() override;
102 
103  int doZoomInOut( bool aDirection, bool aCenterOnCursor );
104 
105 private:
110 };
111 
112 #endif
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int ToggleOrtho(const TOOL_EVENT &aEvent)
double m_rotationIncrement
Rotation increment for the rotate actions (degrees)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
~EDA_3D_CONTROLLER() override
Definition: 3d_controller.h:50
void SetRotationIncrement(double aRotIncrement)
Set the increment used by the RotateView actions.
Definition: 3d_controller.h:67
int SetMaterial(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
int ZoomRedraw(const TOOL_EVENT &aEvent)
int UpdateMenu(const TOOL_EVENT &aEvent)
int On3DGridSelection(const TOOL_EVENT &aEvent)
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
void setTransitions() override
< Sets up handlers for various events.
A class used to derive camera objects from.
Definition: camera.h:77
int ViewControl(const TOOL_EVENT &aEvent)
EDA_3D_CONTROLLER.
Definition: 3d_controller.h:39
Generic, UI-independent tool event.
Definition: tool_event.h:173
int ZoomInOut(const TOOL_EVENT &aEvent)
int PanControl(const TOOL_EVENT &aEvent)
double GetRotationIncrement()
Get the increment used by the RotateView actions.
Definition: 3d_controller.h:77
EDA_3D_CANVAS * m_canvas
int ToggleVisibility(const TOOL_EVENT &aEvent)
int Main(const TOOL_EVENT &aEvent)
int RotateView(const TOOL_EVENT &aEvent)
BOARD_ADAPTER * m_boardAdapter
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
Definition: eda_3d_viewer.h:66
Helper class to handle information needed to display 3D board.
Definition: board_adapter.h:67
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.