KiCad PCB EDA Suite
NL_SCHEMATIC_PLUGIN_IMPL Class Reference

The class that implements the accessors and mutators required for 3D navigation in an PCB_DRAW_PANEL_GAL using a SpaceMouse. More...

#include <nl_schematic_plugin_impl.h>

Inheritance diagram for NL_SCHEMATIC_PLUGIN_IMPL:

Public Member Functions

 NL_SCHEMATIC_PLUGIN_IMPL ()
 Initializes a new instance of the NL_SCHEMATIC_PLUGIN_IMPL. More...
 
virtual ~NL_SCHEMATIC_PLUGIN_IMPL ()
 
void SetCanvas (EDA_DRAW_PANEL_GAL *aViewport)
 Sets the viewport controlled by the SpaceMouse. More...
 
void SetFocus (bool aFocus)
 Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed here. More...
 

Private Member Functions

void exportCommandsAndImages ()
 Export the invocable actions and images to the 3Dconnexion UI. More...
 
long GetCameraMatrix (navlib::matrix_t &aMatrix) const override
 
long GetPointerPosition (navlib::point_t &aPosition) const override
 
long GetViewExtents (navlib::box_t &aExtents) const override
 
long GetViewFOV (double &aFov) const override
 
long GetViewFrustum (navlib::frustum_t &aFrustum) const override
 
long GetIsViewPerspective (navlib::bool_t &aPerspective) const override
 
long SetCameraMatrix (const navlib::matrix_t &aMatrix) override
 
long SetViewExtents (const navlib::box_t &aExtents) override
 
long SetViewFOV (double aFov) override
 
long SetViewFrustum (const navlib::frustum_t &aFrustum) override
 
long GetModelExtents (navlib::box_t &aExtents) const override
 
long GetSelectionExtents (navlib::box_t &aExtents) const override
 
long GetSelectionTransform (navlib::matrix_t &aTransform) const override
 
long GetIsSelectionEmpty (navlib::bool_t &aEmpty) const override
 
long SetSelectionTransform (const navlib::matrix_t &aMatrix) override
 
long GetPivotPosition (navlib::point_t &aPosition) const override
 
long IsUserPivot (navlib::bool_t &aUserPivot) const override
 
long SetPivotPosition (const navlib::point_t &aPosition) override
 
long GetPivotVisible (navlib::bool_t &aVisible) const override
 
long SetPivotVisible (bool aVisible) override
 
long GetHitLookAt (navlib::point_t &aPosition) const override
 
long SetHitAperture (double aAperture) override
 
long SetHitDirection (const navlib::vector_t &aDirection) override
 
long SetHitLookFrom (const navlib::point_t &aPosition) override
 
long SetHitSelectionOnly (bool aSelectionOnly) override
 
long SetActiveCommand (std::string aCommandId) override
 
long SetSettingsChanged (long aChangeNumber) override
 
long SetMotionFlag (bool aValue) override
 
long SetTransaction (long aValue) override
 
long SetCameraTarget (const navlib::point_t &aPosition) override
 
long GetFrontView (navlib::matrix_t &aMatrix) const override
 
long GetCoordinateSystem (navlib::matrix_t &aMatrix) const override
 
long GetIsViewRotatable (navlib::bool_t &isRotatable) const override
 

Private Attributes

EDA_DRAW_PANEL_GALm_viewport2D
 
KIGFX::SCH_VIEWm_view
 
bool m_isMoving
 
double m_viewportWidth
 
VECTOR2D m_viewPosition
 

Static Private Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_NL_SCHEMATIC_PLUGIN" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Detailed Description

The class that implements the accessors and mutators required for 3D navigation in an PCB_DRAW_PANEL_GAL using a SpaceMouse.

Definition at line 61 of file nl_schematic_plugin_impl.h.

Constructor & Destructor Documentation

◆ NL_SCHEMATIC_PLUGIN_IMPL()

NL_SCHEMATIC_PLUGIN_IMPL::NL_SCHEMATIC_PLUGIN_IMPL ( )

Initializes a new instance of the NL_SCHEMATIC_PLUGIN_IMPL.

Definition at line 55 of file nl_schematic_plugin_impl.cpp.

55 :
56 CNavigation3D( false, false ), m_viewport2D( nullptr ), m_isMoving( false )
57{
58 PutProfileHint( "KiCAD Eeschema" );
59}

◆ ~NL_SCHEMATIC_PLUGIN_IMPL()

NL_SCHEMATIC_PLUGIN_IMPL::~NL_SCHEMATIC_PLUGIN_IMPL ( )
virtual

Definition at line 62 of file nl_schematic_plugin_impl.cpp.

63{
64 EnableNavigation( false );
65}

Member Function Documentation

◆ exportCommandsAndImages()

void NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages ( )
private

Export the invocable actions and images to the 3Dconnexion UI.

Definition at line 144 of file nl_schematic_plugin_impl.cpp.

145{
146 wxLogTrace( m_logTrace, wxT( "NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages" ) );
147
148 std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
149
150 if( actions.size() == 0 )
151 {
152 return;
153 }
154
155 using TDx::SpaceMouse::CCommand;
156 using TDx::SpaceMouse::CCommandSet;
157
158 // The root action set node
159 CCommandSet commandSet( "SCHEMATIC_EDITOR", "Schematic Editor" );
160
161 // Activate the command set
162 NAV_3D::PutActiveCommands( commandSet.GetId() );
163
164 // temporary store for the categories
165 CATEGORY_STORE categoryStore;
166
167 std::vector<TDx::CImage> vImages;
168
169 // add the action set to the category_store
170 categoryStore.insert( categoryStore.end(), CATEGORY_STORE::value_type( ".", &commandSet ) );
171
172 std::list<TOOL_ACTION*>::const_iterator it;
173
174 for( it = actions.begin(); it != actions.end(); ++it )
175 {
176 const TOOL_ACTION* action = *it;
177 std::string label = action->GetLabel().ToStdString();
178
179 if( label.empty() )
180 {
181 continue;
182 }
183
184 std::string name = action->GetName();
185
186 // Do no export commands for the 3DViewer app.
187
188 if( name.rfind( "3DViewer.", 0 ) == 0 )
189 {
190 continue;
191 }
192
193 std::string strCategory = action->GetToolName();
194 CATEGORY_STORE::iterator iter = categoryStore.find( strCategory );
195
196 if( iter == categoryStore.end() )
197 {
198 iter = add_category( std::move( strCategory ), categoryStore );
199 }
200
201 std::string description = action->GetDescription().ToStdString();
202
203 // Arbitrary 8-bit data stream
204 wxMemoryOutputStream imageStream;
205
206 if( action->GetIcon() != BITMAPS::INVALID_BITMAP )
207 {
208 wxImage image = KiBitmap( action->GetIcon() ).ConvertToImage();
209 image.SaveFile( imageStream, wxBitmapType::wxBITMAP_TYPE_PNG );
210 image.Destroy();
211
212 if( imageStream.GetSize() )
213 {
214 wxStreamBuffer* streamBuffer = imageStream.GetOutputStreamBuffer();
215 TDx::CImage tdxImage = TDx::CImage::FromData( "", 0, name.c_str() );
216 tdxImage.AssignImage( std::string( reinterpret_cast<const char*>(
217 streamBuffer->GetBufferStart() ),
218 streamBuffer->GetBufferSize() ),
219 0 );
220
221 wxLogTrace( m_logTrace, wxT( "Adding image for : %s" ), name );
222 vImages.push_back( std::move( tdxImage ) );
223 }
224 }
225
226 wxLogTrace( m_logTrace, wxT( "Inserting command: %s, description: %s, in category: %s" ),
227 name, description, iter->first );
228
229 iter->second->push_back(
230 CCommand( std::move( name ), std::move( label ), std::move( description ) ) );
231 }
232
233 NAV_3D::AddCommandSet( commandSet );
234 NAV_3D::AddImages( vImages );
235}
const char * name
Definition: DXF_plotter.cpp:56
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:106
@ INVALID_BITMAP
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
Represent a single user action.
Definition: tool_action.h:68
wxString GetLabel() const
Definition: tool_action.cpp:83
std::string GetToolName() const
Return name of the tool associated with the action.
const BITMAPS GetIcon() const
Return an icon associated with the action.
Definition: tool_action.h:192
wxString GetDescription(bool aIncludeHotkey=true) const
Definition: tool_action.cpp:97
const std::string & GetName() const
Return name of the action.
Definition: tool_action.h:101
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
std::map< std::string, TDx::CCommandTreeNode * > CATEGORY_STORE
static CATEGORY_STORE::iterator add_category(std::string aCategoryPath, CATEGORY_STORE &aCategoryStore)
Add a category to the store.

References add_category(), ACTION_MANAGER::GetActionList(), TOOL_ACTION::GetDescription(), TOOL_ACTION::GetIcon(), TOOL_ACTION::GetLabel(), TOOL_ACTION::GetName(), TOOL_ACTION::GetToolName(), image, INVALID_BITMAP, KiBitmap(), m_logTrace, and name.

Referenced by SetCanvas().

◆ GetCameraMatrix()

long NL_SCHEMATIC_PLUGIN_IMPL::GetCameraMatrix ( navlib::matrix_t &  aMatrix) const
overrideprivate

Definition at line 238 of file nl_schematic_plugin_impl.cpp.

239{
240 if( m_view == nullptr )
241 {
242 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
243 }
244
246
247 double x = m_view->IsMirroredX() ? -1 : 1;
248 double y = m_view->IsMirroredY() ? 1 : -1;
249
250 // x * y * z = 1 for a right-handed coordinate system.
251 double z = x * y;
252
253 // Note: the connexion has been configured as row vectors, the coordinate system is defined in
254 // NL_SCHEMATIC_PLUGIN_IMPL::GetCoordinateSystem and the front view in NL_SCHEMATIC_PLUGIN_IMPL::GetFrontView.
255 matrix = { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, m_viewPosition.x, m_viewPosition.y, 0, 1 };
256 return 0;
257}
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:339
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:243
bool IsMirroredY() const
Return true if view is flipped across the Y axis.
Definition: view.h:251

References KIGFX::VIEW::GetCenter(), KIGFX::VIEW::IsMirroredX(), KIGFX::VIEW::IsMirroredY(), m_view, m_viewPosition, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetCoordinateSystem()

long NL_SCHEMATIC_PLUGIN_IMPL::GetCoordinateSystem ( navlib::matrix_t &  aMatrix) const
overrideprivate

Definition at line 403 of file nl_schematic_plugin_impl.cpp.

404{
405 // The coordinate system is defined as x to the right, y down and z into the screen.
406 matrix = { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 };
407 return 0;
408}

◆ GetFrontView()

long NL_SCHEMATIC_PLUGIN_IMPL::GetFrontView ( navlib::matrix_t &  aMatrix) const
overrideprivate

Definition at line 411 of file nl_schematic_plugin_impl.cpp.

412{
413 matrix = { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 };
414 return 0;
415}

◆ GetHitLookAt()

long NL_SCHEMATIC_PLUGIN_IMPL::GetHitLookAt ( navlib::point_t &  aPosition) const
overrideprivate

Definition at line 575 of file nl_schematic_plugin_impl.cpp.

576{
577 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
578}

◆ GetIsSelectionEmpty()

long NL_SCHEMATIC_PLUGIN_IMPL::GetIsSelectionEmpty ( navlib::bool_t &  aEmpty) const
overrideprivate

Definition at line 418 of file nl_schematic_plugin_impl.cpp.

419{
420 empty = true;
421 return 0;
422}
static bool empty(const wxTextEntryBase *aCtrl)

References empty().

◆ GetIsViewPerspective()

long NL_SCHEMATIC_PLUGIN_IMPL::GetIsViewPerspective ( navlib::bool_t &  aPerspective) const
overrideprivate

Definition at line 299 of file nl_schematic_plugin_impl.cpp.

300{
301 perspective = false;
302
303 return 0;
304}

◆ GetIsViewRotatable()

long NL_SCHEMATIC_PLUGIN_IMPL::GetIsViewRotatable ( navlib::bool_t &  isRotatable) const
overrideprivate

Definition at line 425 of file nl_schematic_plugin_impl.cpp.

426{
427 isRotatable = false;
428 return 0;
429}

◆ GetModelExtents()

long NL_SCHEMATIC_PLUGIN_IMPL::GetModelExtents ( navlib::box_t &  aExtents) const
overrideprivate

Definition at line 375 of file nl_schematic_plugin_impl.cpp.

376{
377 if( m_view == nullptr )
378 {
379 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
380 }
381
382 BOX2I box = static_cast<SCH_BASE_FRAME*>( m_viewport2D->GetParent() )->GetDocumentExtents();
383 box.Normalize();
384
385 double half_depth = 0.1 / m_viewport2D->GetGAL()->GetWorldScale();
386
387 if( box.GetWidth() == 0 && box.GetHeight() == 0 )
388 {
389 half_depth = 0;
390 }
391
392 extents = { static_cast<double>( box.GetOrigin().x ),
393 static_cast<double>( box.GetOrigin().y ),
394 -half_depth,
395 static_cast<double>( box.GetEnd().x ),
396 static_cast<double>( box.GetEnd().y ),
397 half_depth };
398
399 return 0;
400}
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
const Vec GetEnd() const
Definition: box2.h:185
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
double GetWorldScale() const
Get the world scale.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...

References BOX2< Vec >::GetEnd(), EDA_DRAW_PANEL_GAL::GetGAL(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), KIGFX::GAL::GetWorldScale(), m_view, m_viewport2D, BOX2< Vec >::Normalize(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetPivotPosition()

long NL_SCHEMATIC_PLUGIN_IMPL::GetPivotPosition ( navlib::point_t &  aPosition) const
overrideprivate

Definition at line 545 of file nl_schematic_plugin_impl.cpp.

546{
547 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
548}

◆ GetPivotVisible()

long NL_SCHEMATIC_PLUGIN_IMPL::GetPivotVisible ( navlib::bool_t &  aVisible) const
overrideprivate

Definition at line 563 of file nl_schematic_plugin_impl.cpp.

564{
565 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
566}

◆ GetPointerPosition()

long NL_SCHEMATIC_PLUGIN_IMPL::GetPointerPosition ( navlib::point_t &  aPosition) const
overrideprivate

Definition at line 260 of file nl_schematic_plugin_impl.cpp.

261{
262 if( m_view == nullptr )
263 {
264 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
265 }
266
268
269 position.x = mouse_pointer.x;
270 position.y = mouse_pointer.y;
271 position.z = 0;
272
273 return 0;
274}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.

References KIGFX::VIEW_CONTROLS::GetMousePosition(), EDA_DRAW_PANEL_GAL::GetViewControls(), m_view, m_viewport2D, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GetSelectionExtents()

long NL_SCHEMATIC_PLUGIN_IMPL::GetSelectionExtents ( navlib::box_t &  aExtents) const
overrideprivate

Definition at line 527 of file nl_schematic_plugin_impl.cpp.

528{
529 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
530}

◆ GetSelectionTransform()

long NL_SCHEMATIC_PLUGIN_IMPL::GetSelectionTransform ( navlib::matrix_t &  aTransform) const
overrideprivate

Definition at line 533 of file nl_schematic_plugin_impl.cpp.

534{
535 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
536}

◆ GetViewExtents()

long NL_SCHEMATIC_PLUGIN_IMPL::GetViewExtents ( navlib::box_t &  aExtents) const
overrideprivate

Definition at line 277 of file nl_schematic_plugin_impl.cpp.

278{
279 if( m_view == nullptr )
280 {
281 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
282 }
283
284 double scale = m_viewport2D->GetGAL()->GetWorldScale();
285 BOX2D box = m_view->GetViewport();
286
288
289 extents = navlib::box_t{ -box.GetWidth() / 2.0,
290 -box.GetHeight() / 2.0,
292 box.GetWidth() / 2.0,
293 box.GetHeight() / 2.0,
295 return 0;
296}
double GetMaxDepth() const
double GetMinDepth() const
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:511
const int scale

References EDA_DRAW_PANEL_GAL::GetGAL(), BOX2< Vec >::GetHeight(), KIGFX::GAL::GetMaxDepth(), KIGFX::GAL::GetMinDepth(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), KIGFX::GAL::GetWorldScale(), m_view, m_viewport2D, m_viewportWidth, and scale.

◆ GetViewFOV()

long NL_SCHEMATIC_PLUGIN_IMPL::GetViewFOV ( double &  aFov) const
overrideprivate

Definition at line 515 of file nl_schematic_plugin_impl.cpp.

516{
517 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
518}

◆ GetViewFrustum()

long NL_SCHEMATIC_PLUGIN_IMPL::GetViewFrustum ( navlib::frustum_t &  aFrustum) const
overrideprivate

Definition at line 521 of file nl_schematic_plugin_impl.cpp.

522{
523 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
524}

◆ IsUserPivot()

long NL_SCHEMATIC_PLUGIN_IMPL::IsUserPivot ( navlib::bool_t &  aUserPivot) const
overrideprivate

Definition at line 551 of file nl_schematic_plugin_impl.cpp.

552{
553 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
554}

◆ SetActiveCommand()

long NL_SCHEMATIC_PLUGIN_IMPL::SetActiveCommand ( std::string  aCommandId)
overrideprivate

Definition at line 432 of file nl_schematic_plugin_impl.cpp.

433{
434 if( commandId.empty() )
435 {
436 return 0;
437 }
438
439 std::list<TOOL_ACTION*> actions = ACTION_MANAGER::GetActionList();
440 TOOL_ACTION* context = nullptr;
441
442 for( std::list<TOOL_ACTION*>::const_iterator it = actions.begin(); it != actions.end(); it++ )
443 {
444 TOOL_ACTION* action = *it;
445 std::string nm = action->GetName();
446
447 if( commandId == nm )
448 {
449 context = action;
450 }
451 }
452
453 if( context != nullptr )
454 {
455 wxWindow* parent = m_viewport2D->GetParent();
456
457 // Only allow command execution if the window is enabled. i.e. there is not a modal dialog
458 // currently active.
459
460 if( parent->IsEnabled() )
461 {
462 TOOL_MANAGER* tool_manager = static_cast<SCH_BASE_FRAME*>( parent )->GetToolManager();
463
464 // Get the selection to use to test if the action is enabled
465 SELECTION& sel = tool_manager->GetToolHolder()->GetCurrentSelection();
466
467 bool runAction = true;
468
469 if( const ACTION_CONDITIONS* aCond =
470 tool_manager->GetActionManager()->GetCondition( *context ) )
471 {
472 runAction = aCond->enableCondition( sel );
473 }
474
475 if( runAction )
476 {
477 tool_manager->RunAction( *context, true );
478 }
479 }
480 else
481 {
482 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
483 }
484 }
485
486 return 0;
487}
const ACTION_CONDITIONS * GetCondition(const TOOL_ACTION &aAction) const
Get the conditions to use for a specific tool action.
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition: tools_holder.h:101
Master controller class:
Definition: tool_manager.h:55
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:196
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...

References ACTION_MANAGER::GetActionList(), TOOL_MANAGER::GetActionManager(), ACTION_MANAGER::GetCondition(), TOOLS_HOLDER::GetCurrentSelection(), TOOL_ACTION::GetName(), TOOL_MANAGER::GetToolHolder(), m_viewport2D, and TOOL_MANAGER::RunAction().

◆ SetCameraMatrix()

long NL_SCHEMATIC_PLUGIN_IMPL::SetCameraMatrix ( const navlib::matrix_t &  aMatrix)
overrideprivate

Definition at line 307 of file nl_schematic_plugin_impl.cpp.

308{
309 if( m_view == nullptr )
310 {
311 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
312 }
313
314 long result = 0;
315 VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
316
318 static_cast<VECTOR2D::coord_type>( FLT_EPSILON ) ) )
319 {
321 result = navlib::make_result_code( navlib::navlib_errc::error );
322 }
323 else
324 {
325 m_view->SetCenter( viewPos );
326 }
327
328 m_viewPosition = viewPos;
329
330 return result;
331}
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:577
double coord_type
Definition: vector2d.h:73
bool equals(glm::mat< L, C, T, Q > const &aFirst, glm::mat< L, C, T, Q > const &aSecond, T aEpsilon=static_cast< T >(FLT_EPSILON *10))
Template to compare two glm::mat<T> values for equality within a required epsilon.

References equals(), KIGFX::VIEW::GetCenter(), m_view, m_viewPosition, and KIGFX::VIEW::SetCenter().

◆ SetCameraTarget()

long NL_SCHEMATIC_PLUGIN_IMPL::SetCameraTarget ( const navlib::point_t &  aPosition)
overrideprivate

Definition at line 605 of file nl_schematic_plugin_impl.cpp.

606{
607 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
608}

◆ SetCanvas()

void NL_SCHEMATIC_PLUGIN_IMPL::SetCanvas ( EDA_DRAW_PANEL_GAL aViewport)

Sets the viewport controlled by the SpaceMouse.

Parameters
aViewportis the viewport to be navigated.

Definition at line 68 of file nl_schematic_plugin_impl.cpp.

69{
70 bool init = m_viewport2D == nullptr;
71
72 m_viewport2D = aViewport;
73
74 if( m_viewport2D != nullptr )
75 {
76 m_view = static_cast<KIGFX::SCH_VIEW*>( m_viewport2D->GetView() );
78
79 if( init )
80 {
81 // Use the default settings for the connexion to the 3DMouse navigation
82 // They are use a single-threaded threading model and row vectors.
83 EnableNavigation( true );
84
85 // Use the SpaceMouse internal timing source for the frame rate.
86 PutFrameTimingSource( TimingSource::SpaceMouse );
87
89 }
90 }
91}
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
const BOX2D & GetBoundary() const
Definition: view.h:298
void exportCommandsAndImages()
Export the invocable actions and images to the 3Dconnexion UI.

References exportCommandsAndImages(), KIGFX::VIEW::GetBoundary(), EDA_DRAW_PANEL_GAL::GetView(), BOX2< Vec >::GetWidth(), m_view, m_viewport2D, and m_viewportWidth.

◆ SetFocus()

void NL_SCHEMATIC_PLUGIN_IMPL::SetFocus ( bool  aFocus)

Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed here.

Parameters
aFocusis true to set the connection active.

Definition at line 94 of file nl_schematic_plugin_impl.cpp.

95{
96 wxLogTrace( m_logTrace, wxT( "NL_SCHEMATIC_PLUGIN_IMPL::SetFocus %d" ), aFocus );
97 NAV_3D::Write( navlib::focus_k, aFocus );
98}

References m_logTrace.

◆ SetHitAperture()

long NL_SCHEMATIC_PLUGIN_IMPL::SetHitAperture ( double  aAperture)
overrideprivate

Definition at line 581 of file nl_schematic_plugin_impl.cpp.

582{
583 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
584}

◆ SetHitDirection()

long NL_SCHEMATIC_PLUGIN_IMPL::SetHitDirection ( const navlib::vector_t &  aDirection)
overrideprivate

Definition at line 587 of file nl_schematic_plugin_impl.cpp.

588{
589 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
590}

◆ SetHitLookFrom()

long NL_SCHEMATIC_PLUGIN_IMPL::SetHitLookFrom ( const navlib::point_t &  aPosition)
overrideprivate

Definition at line 593 of file nl_schematic_plugin_impl.cpp.

594{
595 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
596}

◆ SetHitSelectionOnly()

long NL_SCHEMATIC_PLUGIN_IMPL::SetHitSelectionOnly ( bool  aSelectionOnly)
overrideprivate

Definition at line 599 of file nl_schematic_plugin_impl.cpp.

600{
601 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
602}

◆ SetMotionFlag()

long NL_SCHEMATIC_PLUGIN_IMPL::SetMotionFlag ( bool  aValue)
overrideprivate

Definition at line 496 of file nl_schematic_plugin_impl.cpp.

497{
498 m_isMoving = value;
499
500 return 0;
501}

References m_isMoving.

◆ SetPivotPosition()

long NL_SCHEMATIC_PLUGIN_IMPL::SetPivotPosition ( const navlib::point_t &  aPosition)
overrideprivate

Definition at line 557 of file nl_schematic_plugin_impl.cpp.

558{
559 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
560}

◆ SetPivotVisible()

long NL_SCHEMATIC_PLUGIN_IMPL::SetPivotVisible ( bool  aVisible)
overrideprivate

Definition at line 569 of file nl_schematic_plugin_impl.cpp.

570{
571 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
572}

◆ SetSelectionTransform()

long NL_SCHEMATIC_PLUGIN_IMPL::SetSelectionTransform ( const navlib::matrix_t &  aMatrix)
overrideprivate

Definition at line 539 of file nl_schematic_plugin_impl.cpp.

540{
541 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
542}

◆ SetSettingsChanged()

long NL_SCHEMATIC_PLUGIN_IMPL::SetSettingsChanged ( long  aChangeNumber)
overrideprivate

Definition at line 490 of file nl_schematic_plugin_impl.cpp.

491{
492 return 0;
493}

◆ SetTransaction()

long NL_SCHEMATIC_PLUGIN_IMPL::SetTransaction ( long  aValue)
overrideprivate

Definition at line 504 of file nl_schematic_plugin_impl.cpp.

505{
506 if( value == 0L )
507 {
509 }
510
511 return 0;
512}
void ForceRefresh()
Force a redraw.

References EDA_DRAW_PANEL_GAL::ForceRefresh(), and m_viewport2D.

◆ SetViewExtents()

long NL_SCHEMATIC_PLUGIN_IMPL::SetViewExtents ( const navlib::box_t &  aExtents)
overrideprivate

Definition at line 334 of file nl_schematic_plugin_impl.cpp.

335{
336 if( m_view == nullptr )
337 {
338 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
339 }
340
341 long result = 0;
342
344 {
345 result = navlib::make_result_code( navlib::navlib_errc::error );
346 }
347
348 double width = m_viewportWidth;
349 m_viewportWidth = extents.max_x - extents.min_x;
350
351 double scale = width / m_viewportWidth * m_view->GetScale();
353
354 if( !equals( m_view->GetScale(), scale, static_cast<double>( FLT_EPSILON ) ) )
355 {
356 result = navlib::make_result_code( navlib::navlib_errc::error );
357 }
358
359 return result;
360}
void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 }) override
Set the scaling factor, zooming around a given anchor point.
Definition: sch_view.cpp:73
double GetScale() const
Definition: view.h:269

References equals(), KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScale(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), m_view, m_viewportWidth, scale, and KIGFX::SCH_VIEW::SetScale().

◆ SetViewFOV()

long NL_SCHEMATIC_PLUGIN_IMPL::SetViewFOV ( double  aFov)
overrideprivate

Definition at line 363 of file nl_schematic_plugin_impl.cpp.

364{
365 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
366}

◆ SetViewFrustum()

long NL_SCHEMATIC_PLUGIN_IMPL::SetViewFrustum ( const navlib::frustum_t &  aFrustum)
overrideprivate

Definition at line 369 of file nl_schematic_plugin_impl.cpp.

370{
371 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
372}

Member Data Documentation

◆ m_isMoving

bool NL_SCHEMATIC_PLUGIN_IMPL::m_isMoving
private

Definition at line 134 of file nl_schematic_plugin_impl.h.

Referenced by SetMotionFlag().

◆ m_view

KIGFX::SCH_VIEW* NL_SCHEMATIC_PLUGIN_IMPL::m_view
private

◆ m_viewport2D

EDA_DRAW_PANEL_GAL* NL_SCHEMATIC_PLUGIN_IMPL::m_viewport2D
private

◆ m_viewportWidth

double NL_SCHEMATIC_PLUGIN_IMPL::m_viewportWidth
mutableprivate

Definition at line 135 of file nl_schematic_plugin_impl.h.

Referenced by GetViewExtents(), SetCanvas(), and SetViewExtents().

◆ m_viewPosition

VECTOR2D NL_SCHEMATIC_PLUGIN_IMPL::m_viewPosition
mutableprivate

Definition at line 136 of file nl_schematic_plugin_impl.h.

Referenced by GetCameraMatrix(), and SetCameraMatrix().


The documentation for this class was generated from the following files: