43#include <wx/mstream.h> 
   58    PutProfileHint( 
"KiCAD Datasheet Editor" );
 
 
   64    std::error_code m_errCode;
 
   65    EnableNavigation( 
false, m_errCode );
 
   66    if( m_errCode.value() != 0 )
 
   68        wxLogTrace( wxT( 
"KI_TRACE_NAVLIB" ),
 
   69                    wxT( 
"Error occured when calling EnableNavigation. Error code: %d" ),
 
 
   97        EnableNavigation( 
true );
 
  100        PutFrameTimingSource( TimingSource::SpaceMouse );
 
 
  109    wxLogTrace( 
m_logTrace, wxT( 
"NL_PL_EDITOR_PLUGIN_IMPL::SetFocus %d" ), aFocus );
 
  110    NAV_3D::Write( navlib::focus_k, aFocus );
 
 
  114using CATEGORY_STORE = std::map<std::string, TDx::CCommandTreeNode*, std::less<>>;
 
  127    using TDx::SpaceMouse::CCategory;
 
  129    auto parent_iter = aCategoryStore.begin();
 
  130    std::string::size_type pos = aCategoryPath.find_last_of( 
'.' );
 
  132    if( pos != std::string::npos )
 
  134        std::string parentPath = aCategoryPath.substr( 0, pos );
 
  136        if( !aCategoryStore.contains( parentPath ) )
 
  139            parent_iter = aCategoryStore.find( parentPath );
 
  143    std::string 
name = aCategoryPath.substr( pos + 1 );
 
  144    auto categoryNode = std::make_unique<CCategory>( aCategoryPath.c_str(), 
name.c_str() );
 
  146    aCategoryStore.try_emplace( aCategoryStore.end(), aCategoryPath, categoryNode.get() );
 
  148    if( parent_iter != aCategoryStore.end() )
 
  149        parent_iter->second->push_back( std::move( categoryNode ) );
 
 
  163    if( !aCategoryStore.contains( aCategoryPath ) )
 
 
  172    wxLogTrace( 
m_logTrace, wxT( 
"NL_PL_EDITOR_PLUGIN_IMPL::exportCommandsAndImages" ) );
 
  176    if( actions.empty() )
 
  179    using TDx::SpaceMouse::CCommand;
 
  180    using TDx::SpaceMouse::CCommandSet;
 
  183    CCommandSet commandSet( 
"PL_EDITOR", 
"Drawing Sheet Editor" );
 
  186    NAV_3D::PutActiveCommands( commandSet.GetId() );
 
  189    CATEGORY_STORE categoryStore{ CATEGORY_STORE::value_type( 
".", &commandSet ) };
 
  191    std::vector<TDx::CImage> vImages;
 
  193    for( 
const auto action : actions )
 
  195        std::string label = action->GetMenuLabel().ToStdString();
 
  200        std::string 
name = action->GetName();
 
  204        if( 
name.rfind( 
"3DViewer.", 0 ) == 0 )
 
  207        std::string strCategory = action->GetToolName();
 
  208        std::string description = action->GetDescription().ToStdString();
 
  211        CATEGORY_STORE::iterator iter = categoryStore.find( strCategory );
 
  213        wxCHECK2( iter != categoryStore.end(), 
continue );
 
  216        wxMemoryOutputStream imageStream;
 
  220            wxImage 
image = 
KiBitmap( action->GetIcon() ).ConvertToImage();
 
  221            image.SaveFile( imageStream, wxBitmapType::wxBITMAP_TYPE_PNG );
 
  224            if( imageStream.GetSize() )
 
  226                const wxStreamBuffer* streamBuffer = imageStream.GetOutputStreamBuffer();
 
  227                TDx::CImage tdxImage = TDx::CImage::FromData( 
"", 0, 
name.c_str() );
 
  228                tdxImage.AssignImage(
 
  229                        std::string( std::bit_cast<const char*>( streamBuffer->GetBufferStart() ),
 
  230                                     streamBuffer->GetBufferSize() ),
 
  234                vImages.push_back( std::move( tdxImage ) );
 
  238        wxLogTrace( 
m_logTrace, wxT( 
"Inserting command: %s,  description: %s,  in category:  %s" ),
 
  239                    name, description, iter->first );
 
  241        iter->second->push_back( CCommand( std::move( 
name ), std::move( label ),
 
  242                                           std::move( description ) ) );
 
  245    NAV_3D::AddCommandSet( commandSet );
 
  246    NAV_3D::AddImages( vImages );
 
 
  253        return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
  257    double x = 
m_view->IsMirroredX() ? -1 : 1;
 
  258    double y = 
m_view->IsMirroredY() ? 1 : -1;
 
  265    matrix = { { { x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 
m_viewPosition.x, 
m_viewPosition.y, 0,
 
 
  274        return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
  278    position.x = mouse_pointer.
x;
 
  279    position.y = mouse_pointer.
y;
 
 
  289        return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
  296    extents.min_x = -box.
GetWidth() / 2.0;
 
  299    extents.max_x = box.
GetWidth() / 2.0;
 
 
  317        return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
  320    VECTOR2D viewPos( matrix.m4x4[3][0], matrix.m4x4[3][1] );
 
  326        result = navlib::make_result_code( navlib::navlib_errc::error );
 
  330        m_view->SetCenter( viewPos );
 
 
  342        return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
  347        result = navlib::make_result_code( navlib::navlib_errc::error );
 
  356        result = navlib::make_result_code( navlib::navlib_errc::error );
 
 
  364    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  370    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  377        return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
  382    double half_depth = 0.1 / 
m_viewport2D->GetGAL()->GetWorldScale();
 
  387    extents.min_x = 
static_cast<double>( box.
GetOrigin().x );
 
  388    extents.min_y = 
static_cast<double>( box.
GetOrigin().y );
 
  389    extents.min_z = -half_depth;
 
  390    extents.max_x = 
static_cast<double>( box.
GetEnd().x );
 
  391    extents.max_y = 
static_cast<double>( box.
GetEnd().y );
 
  392    extents.max_z = half_depth;
 
 
  401    matrix = { { { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 } } };
 
 
  408    matrix = { { { 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1 } } };
 
 
  429    if( commandId.empty() )
 
  433        return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
  439    if( !parent || !parent->IsEnabled() )
 
  440        return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
  447        return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
  451        if( action == 
nullptr )
 
  454        if( commandId == action->GetName() )
 
  461            if( aCond == 
nullptr )
 
  462                return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  499    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  505    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  511    return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
 
  517    return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
 
  523    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  529    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  535    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  541    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  547    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  553    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  559    return navlib::make_result_code( navlib::navlib_errc::no_data_available );
 
 
  565    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  571    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  577    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  583    return navlib::make_result_code( navlib::navlib_errc::invalid_operation );
 
 
  589    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
 
long SetViewExtents(const navlib::box_t &aExtents) override
 
long GetPivotPosition(navlib::point_t &aPosition) const override
 
long GetViewFOV(double &aFov) const override
 
virtual ~NL_PL_EDITOR_PLUGIN_IMPL()
 
EDA_DRAW_PANEL_GAL * m_viewport2D
 
long SetCameraTarget(const navlib::point_t &aPosition) override
 
long SetPivotPosition(const navlib::point_t &aPosition) override
 
long GetCameraMatrix(navlib::matrix_t &aMatrix) const override
 
long GetViewFrustum(navlib::frustum_t &aFrustum) const override
 
long SetHitDirection(const navlib::vector_t &aDirection) override
 
long SetHitLookFrom(const navlib::point_t &aPosition) override
 
long SetHitSelectionOnly(bool aSelectionOnly) override
 
long SetPivotVisible(bool aVisible) override
 
void SetCanvas(EDA_DRAW_PANEL_GAL *aViewport)
Sets the viewport controlled by the SpaceMouse.
 
long SetActiveCommand(std::string aCommandId) override
 
long SetCameraMatrix(const navlib::matrix_t &aMatrix) override
 
long SetSelectionTransform(const navlib::matrix_t &aMatrix) override
 
long GetViewExtents(navlib::box_t &aExtents) const override
 
long SetSettingsChanged(long aChangeNumber) override
 
long SetHitAperture(double aAperture) override
 
long GetHitLookAt(navlib::point_t &aPosition) const override
 
long GetPointerPosition(navlib::point_t &aPosition) const override
 
void exportCommandsAndImages()
Export the invocable actions and images to the 3Dconnexion UI.
 
void SetFocus(bool aFocus)
Set the connection to the 3Dconnexion driver to the focus state so that 3DMouse data is routed here.
 
long SetViewFrustum(const navlib::frustum_t &aFrustum) override
 
long GetIsSelectionEmpty(navlib::bool_t &aEmpty) const override
 
long GetIsViewRotatable(navlib::bool_t &isRotatable) const override
 
long GetFrontView(navlib::matrix_t &aMatrix) const override
 
long SetViewFOV(double aFov) override
 
long SetMotionFlag(bool aValue) override
 
long GetSelectionTransform(navlib::matrix_t &aTransform) const override
 
long IsUserPivot(navlib::bool_t &aUserPivot) const override
 
long GetModelExtents(navlib::box_t &aExtents) const override
 
long GetCoordinateSystem(navlib::matrix_t &aMatrix) const override
 
long GetPivotVisible(navlib::bool_t &aVisible) const override
 
long SetTransaction(long aValue) override
 
long GetSelectionExtents(navlib::box_t &aExtents) const override
 
NL_PL_EDITOR_PLUGIN_IMPL()
Initializes a new instance of the NL_PL_EDITOR_PLUGIN_IMPL.
 
long GetIsViewPerspective(navlib::bool_t &aPerspective) const override
 
The main window used in the drawing sheet editor.
 
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box of document with option to not include some items.
 
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.
 
std::map< std::string, TDx::CCommandTreeNode * > CATEGORY_STORE
 
static void try_add_category(const std::string &aCategoryPath, CATEGORY_STORE &aCategoryStore)
add_category wrapper.
 
static void try_add_category(const std::string &aCategoryPath, CATEGORY_STORE &aCategoryStore)
add_category wrapper.
 
static void add_category(const std::string &aCategoryPath, CATEGORY_STORE &aCategoryStore)
Add a category to the store.
 
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
 
SELECTION_CONDITION enableCondition
Returns true if the UI control should be enabled.
 
wxString result
Test unit parsing edge cases and error handling.
 
VECTOR2< double > VECTOR2D
 
WX_VIEW_CONTROLS class definition.