KiCad PCB EDA Suite
eda_3d_viewer_frame.cpp File Reference
#include <wx/filename.h>
#include <wx/msgdlg.h>
#include <wx/string.h>
#include <wx/wupdlock.h>
#include <wx/clipbrd.h>
#include <wx/filedlg.h>
#include <wx/treebook.h>
#include "eda_3d_viewer_frame.h"
#include <eda_3d_viewer_settings.h>
#include <3d_viewer_id.h>
#include <3d_viewer/tools/eda_3d_actions.h>
#include <3d_viewer/tools/eda_3d_controller.h>
#include <3d_viewer/tools/eda_3d_conditions.h>
#include <bitmaps.h>
#include <board_design_settings.h>
#include <core/arraydim.h>
#include <gal/dpi_scaling.h>
#include <pgm_base.h>
#include <project.h>
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <tool/action_manager.h>
#include <tool/common_control.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tool/action_toolbar.h>
#include <widgets/infobar.h>
#include <widgets/paged_dialog.h>
#include <dialogs/panel_3D_display_options.h>
#include <dialogs/panel_3D_opengl_options.h>
#include <dialogs/panel_3D_raytracing_options.h>
#include <dialogs/panel_3D_colors.h>
#include <panel_hotkeys_editor.h>
#include <wildcards_and_files_ext.h>

Go to the source code of this file.

Macros

#define FlagCheck(x)   ACTION_CONDITIONS().Check( cond.Flag( x ) )
 
#define GridSizeCheck(x)   ACTION_CONDITIONS().Check( cond.GridSize( x ) )
 
#define TRANSFER_SETTING(flag, field)   m_boardAdapter.SetFlag( flag, cfg->m_Render.field )
 
#define TRANSFER_SETTING(field, flag)   cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
 

Functions

 EVT_TOOL_RANGE (ID_START_COMMAND_3D, ID_MENU_COMMAND_END, EDA_3D_VIEWER_FRAME::Process_Special_Functions) EDA_3D_VIEWER_FRAME
 

Macro Definition Documentation

◆ FlagCheck

#define FlagCheck (   x)    ACTION_CONDITIONS().Check( cond.Flag( x ) )

◆ GridSizeCheck

#define GridSizeCheck (   x)    ACTION_CONDITIONS().Check( cond.GridSize( x ) )

◆ TRANSFER_SETTING [1/2]

#define TRANSFER_SETTING (   flag,
  field 
)    m_boardAdapter.SetFlag( flag, cfg->m_Render.field )

◆ TRANSFER_SETTING [2/2]

#define TRANSFER_SETTING (   field,
  flag 
)    cfg->m_Render.field = m_boardAdapter.GetFlag( flag )

Function Documentation

◆ EVT_TOOL_RANGE()

Definition at line 75 of file eda_3d_viewer_frame.cpp.

87  :
88  KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition,
89  wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ),
90  m_mainToolBar( nullptr ),
91  m_canvas( nullptr ),
92  m_currentCamera( m_trackBallCamera ),
93  m_trackBallCamera( 2 * RANGE_SCALE_3D )
94 {
95  wxLogTrace( m_logTrace, wxT( "EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME %s" ), aTitle );
96 
97  m_disable_ray_tracing = false;
98  m_aboutTitle = _( "KiCad 3D Viewer" );
99 
100  // Give it an icon
101  wxIcon icon;
102  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_3d ) );
103  SetIcon( icon );
104 
105  // Create the status line
106  static const int status_dims[4] = { -1, 170, 130, 130 };
107 
108  wxStatusBar *status_bar = CreateStatusBar( arrayDim( status_dims ) );
109  SetStatusWidths( arrayDim( status_dims ), status_dims );
110 
111  m_canvas = new EDA_3D_CANVAS( this,
112  OGL_ATT_LIST::GetAttributesList( m_boardAdapter.GetAntiAliasingMode() ),
113  m_boardAdapter, m_currentCamera,
114  Prj().Get3DCacheManager() );
115 
116  auto config = Pgm().GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>();
117  LoadSettings( config );
118 
119  // Some settings need the canvas
120  loadCommonSettings();
121 
122  // Create the manager
123  m_toolManager = new TOOL_MANAGER;
124  m_toolManager->SetEnvironment( GetBoard(), nullptr, nullptr, config, this );
125 
126  m_actions = new EDA_3D_ACTIONS();
127  m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
128  m_canvas->SetEventDispatcher( m_toolDispatcher );
129 
130  // Register tools
131  m_toolManager->RegisterTool( new COMMON_CONTROL );
132  m_toolManager->RegisterTool( new EDA_3D_CONTROLLER );
133  m_toolManager->InitTools();
134 
135  setupUIConditions();
136 
137  if( EDA_3D_CONTROLLER* ctrlTool = GetToolManager()->GetTool<EDA_3D_CONTROLLER>() )
138  ctrlTool->SetRotationIncrement( config->m_Camera.rotation_increment );
139 
140  // Run the viewer control tool, it is supposed to be always active
141  m_toolManager->InvokeTool( "3DViewer.Control" );
142 
143  CreateMenuBar();
144  ReCreateMainToolbar();
145 
146  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
147 
148  m_auimgr.SetManagedWindow( this );
149 
150  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
151  m_auimgr.AddPane( m_infoBar, EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
152  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
153 
154  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
155  // hiding it.
156  m_auimgr.Update();
157 
158  // We don't want the infobar displayed right away
159  m_auimgr.GetPane( "InfoBar" ).Hide();
160  m_auimgr.Update();
161 
162  m_canvas->SetInfoBar( m_infoBar );
163  m_canvas->SetStatusBar( status_bar );
164 
165  // Fixes bug in Windows (XP and possibly others) where the canvas requires the focus
166  // in order to receive mouse events. Otherwise, the user has to click somewhere on
167  // the canvas before it will respond to mouse wheel events.
168  m_canvas->SetFocus();
169 }
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
PROJECT & Prj()
Definition: kicad.cpp:403
EDA_3D_ACTIONS.
Implement a canvas based on a wxGLCanvas.
Definition: eda_3d_canvas.h:48
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
static const int * GetAttributesList(ANTIALIASING_MODE aAntiAliasingMode)
Get a list of attributes to pass to wxGLCanvas.
Master controller class:
Definition: tool_manager.h:54
EDA_3D_CONTROLLER.
#define _(s)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
Handle actions that are shared between different applications.
Specialization of the wxAuiPaneInfo class for KiCad panels.
BOARD * GetBoard()
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
#define QUALIFIED_VIEWER3D_FRAMENAME(parent)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:62

References _, arrayDim(), PCAD2KICAD::Center, config, OGL_ATT_LIST::GetAttributesList(), GetBoard(), icon_3d, KiBitmap(), Pgm(), Prj(), and TOOL_MANAGER::SetEnvironment().