43#include <wx/mstream.h>
57 CNavigation3D( false, false ),
63 PutProfileHint(
"KiCAD Eeschema" );
69 EnableNavigation(
false );
88 EnableNavigation(
true );
91 PutFrameTimingSource( TimingSource::SpaceMouse );
101 wxLogTrace(
m_logTrace, wxT(
"NL_SCHEMATIC_PLUGIN_IMPL::SetFocus %d" ), aFocus );
102 NAV_3D::Write( navlib::focus_k, aFocus );
119 using TDx::SpaceMouse::CCategory;
121 CATEGORY_STORE::iterator parent_iter = aCategoryStore.begin();
122 std::string::size_type pos = aCategoryPath.find_last_of(
'.' );
124 if( pos != std::string::npos )
126 std::string parentPath = aCategoryPath.substr( 0, pos );
127 parent_iter = aCategoryStore.find( parentPath );
129 if( parent_iter == aCategoryStore.end() )
132 parent_iter = aCategoryStore.find( parentPath );
136 std::string
name = aCategoryPath.substr( pos + 1 );
137 auto categoryNode = std::make_unique<CCategory>( aCategoryPath.c_str(),
name.c_str() );
139 aCategoryStore.insert( aCategoryStore.end(), { aCategoryPath, categoryNode.get() } );
141 if( parent_iter != aCategoryStore.end() )
142 parent_iter->second->push_back( std::move( categoryNode ) );
148 wxLogTrace(
m_logTrace, wxT(
"NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages" ) );
152 if( actions.size() == 0 )
155 using TDx::SpaceMouse::CCommand;
156 using TDx::SpaceMouse::CCommandSet;
159 CCommandSet commandSet(
"SCHEMATIC_EDITOR",
"Schematic Editor" );
162 NAV_3D::PutActiveCommands( commandSet.GetId() );
167 std::vector<TDx::CImage> vImages;
170 categoryStore.insert( categoryStore.end(), CATEGORY_STORE::value_type(
".", &commandSet ) );
172 std::list<TOOL_ACTION*>::const_iterator it;
174 for( it = actions.begin(); it != actions.end(); ++it )
177 std::string label = action->
GetMenuLabel().ToStdString();
186 if(
name.rfind(
"3DViewer.", 0 ) == 0 )
190 CATEGORY_STORE::iterator iter = categoryStore.find( strCategory );
192 if( iter == categoryStore.end() )
195 iter = categoryStore.find( strCategory );
201 wxMemoryOutputStream imageStream;
206 image.SaveFile( imageStream, wxBitmapType::wxBITMAP_TYPE_PNG );
209 if( imageStream.GetSize() )
211 wxStreamBuffer* streamBuffer = imageStream.GetOutputStreamBuffer();
212 TDx::CImage tdxImage = TDx::CImage::FromData(
"", 0,
name.c_str() );
213 tdxImage.AssignImage( std::string(
reinterpret_cast<const char*
>(
214 streamBuffer->GetBufferStart() ),
215 streamBuffer->GetBufferSize() ),
219 vImages.push_back( std::move( tdxImage ) );
223 if( iter != categoryStore.end() )
225 wxLogTrace(
m_logTrace, wxT(
"Inserting command: %s, description: %s, in category: %s" ),
226 name, description, iter->first );
228 iter->second->push_back( CCommand(
name, label, description ) );
232 NAV_3D::AddCommandSet( commandSet );
233 NAV_3D::AddImages( vImages );
240 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
244 double x =
m_view->IsMirroredX() ? -1 : 1;
245 double y =
m_view->IsMirroredY() ? 1 : -1;
252 matrix = { { { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0,
m_viewPosition.x,
m_viewPosition.y, 0, 1 } } };
260 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
264 position.x = mouse_pointer.
x;
265 position.y = mouse_pointer.
y;
275 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
282 extents.min_x = -box.
GetWidth() / 2.0;
285 extents.max_x = box.
GetWidth() / 2.0;
303 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
306 VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
311 result = navlib::make_result_code( navlib::navlib_errc::error );
315 m_view->SetCenter( viewPos );
327 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
332 result = navlib::make_result_code( navlib::navlib_errc::error );
341 result = navlib::make_result_code( navlib::navlib_errc::error );
349 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
355 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
362 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
367 double half_depth = 0.1 /
m_viewport2D->GetGAL()->GetWorldScale();
372 extents.min_x =
static_cast<double>( box.
GetOrigin().x );
373 extents.min_y =
static_cast<double>( box.
GetOrigin().y );
374 extents.min_z = -half_depth;
375 extents.max_x =
static_cast<double>( box.
GetEnd().x );
376 extents.max_y =
static_cast<double>( box.
GetEnd().y );
377 extents.max_z = half_depth;
386 matrix = { { { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 } } };
393 matrix = { { { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 } } };
414 if( commandId.empty() )
420 for( std::list<TOOL_ACTION*>::const_iterator it = actions.begin(); it != actions.end(); it++ )
423 std::string nm = action->
GetName();
425 if( commandId == nm )
435 if( parent && parent->IsEnabled() )
442 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
447 bool runAction =
true;
450 runAction = aCond->enableCondition( sel );
457 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
490 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
496 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
502 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
508 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
514 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
520 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
526 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
532 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
538 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
544 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
550 return navlib::make_result_code( navlib::navlib_errc::no_data_available );
556 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
562 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
568 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
574 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
580 return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
const ACTION_CONDITIONS * GetCondition(const TOOL_ACTION &aAction) const
Get the conditions to use for a specific tool action.
static std::list< TOOL_ACTION * > & GetActionList()
Return list of TOOL_ACTIONs.
constexpr const Vec GetEnd() const
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr const Vec & GetOrigin() const
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Return bounding box of document with option to not include some items.
long GetHitLookAt(navlib::point_t &aPosition) const override
long GetSelectionExtents(navlib::box_t &aExtents) const override
long GetCoordinateSystem(navlib::matrix_t &aMatrix) const override
long SetViewFOV(double aFov) override
virtual ~NL_SCHEMATIC_PLUGIN_IMPL()
long GetSelectionTransform(navlib::matrix_t &aTransform) const override
long GetPivotPosition(navlib::point_t &aPosition) const override
long SetPivotPosition(const navlib::point_t &aPosition) override
long SetViewFrustum(const navlib::frustum_t &aFrustum) override
long GetFrontView(navlib::matrix_t &aMatrix) const override
long GetViewFOV(double &aFov) const override
long SetHitAperture(double aAperture) override
long SetSelectionTransform(const navlib::matrix_t &aMatrix) override
void SetFocus(bool aFocus)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed here.
long SetViewExtents(const navlib::box_t &aExtents) override
void SetCanvas(EDA_DRAW_PANEL_GAL *aViewport)
Sets the viewport controlled by the SpaceMouse.
long GetCameraMatrix(navlib::matrix_t &aMatrix) const override
long GetPointerPosition(navlib::point_t &aPosition) const override
long GetPivotVisible(navlib::bool_t &aVisible) const override
void exportCommandsAndImages()
Export the invocable actions and images to the 3Dconnexion UI.
long SetTransaction(long aValue) override
long GetIsViewPerspective(navlib::bool_t &aPerspective) const override
long SetHitSelectionOnly(bool aSelectionOnly) override
NL_SCHEMATIC_PLUGIN_IMPL()
Initializes a new instance of the NL_SCHEMATIC_PLUGIN_IMPL.
long SetHitLookFrom(const navlib::point_t &aPosition) override
long SetActiveCommand(std::string aCommandId) override
EDA_DRAW_PANEL_GAL * m_viewport2D
long GetViewExtents(navlib::box_t &aExtents) const override
long SetCameraTarget(const navlib::point_t &aPosition) override
long GetIsSelectionEmpty(navlib::bool_t &aEmpty) const override
long SetCameraMatrix(const navlib::matrix_t &aMatrix) override
long GetIsViewRotatable(navlib::bool_t &isRotatable) const override
long SetMotionFlag(bool aValue) override
long SetHitDirection(const navlib::vector_t &aDirection) override
long GetModelExtents(navlib::box_t &aExtents) const override
long IsUserPivot(navlib::bool_t &aUserPivot) const override
long SetSettingsChanged(long aChangeNumber) override
long GetViewFrustum(navlib::frustum_t &aFrustum) const override
long SetPivotVisible(bool aVisible) override
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
static bool empty(const wxTextEntryBase *aCtrl)
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
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.
CATEGORY_STORE::iterator add_category(std::string aCategoryPath, CATEGORY_STORE &aCategoryStore)
Add a category to the store.
std::map< std::string, TDx::CCommandTreeNode * > CATEGORY_STORE
static void add_category(const std::string &aCategoryPath, CATEGORY_STORE &aCategoryStore)
Add a category to the store.
Declaration of the NL_SCHEMATIC_PLUGIN_IMPL class.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< double > VECTOR2D
WX_VIEW_CONTROLS class definition.