ENABLE_3DCONNEXION_DEVICES - 1st installment of support for 3Dconnexion devices

Implemented using hidapi library (https://github.com/libusb/hidapi) and https://github.com/koenieee/CrossplatformSpacemouseDriver/tree/master/SpaceMouseDriver as reference

Unsolved issues:

- When manipulating the SpaceNavigator wxWidgets generates a mouse wheel event that needs to be filtered out

- wxWidgets does not detect devices being connected/disconnected to the pc

- Current state forces a continuous rendering

- Current state misses dependence on camera zoom

- Non intuitive movement limits

- Translation and rotation speed factors are hardcoded

- Number of device buttons hardcoded
This commit is contained in:
Enrico Turri 2019-09-27 14:52:19 +02:00
parent c1e3be9b27
commit f958cfd2ff
14 changed files with 3805 additions and 1 deletions

View file

@ -61,6 +61,9 @@
#include "GUI_Preview.hpp"
#include "3DBed.hpp"
#include "Camera.hpp"
#if ENABLE_3DCONNEXION_DEVICES
#include "Mouse3DController.hpp"
#endif // ENABLE_3DCONNEXION_DEVICES
#include "Tab.hpp"
#include "PresetBundle.hpp"
#include "BackgroundSlicingProcess.hpp"
@ -1367,6 +1370,9 @@ struct Plater::priv
Sidebar *sidebar;
Bed3D bed;
Camera camera;
#if ENABLE_3DCONNEXION_DEVICES
Mouse3DController mouse3d_controller;
#endif // ENABLE_3DCONNEXION_DEVICES
View3D* view3D;
GLToolbar view_toolbar;
Preview *preview;
@ -2094,12 +2100,20 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
// updates camera type from .ini file
camera.set_type(get_config("use_perspective_camera"));
#if ENABLE_3DCONNEXION_DEVICES
mouse3d_controller.init();
#endif // ENABLE_3DCONNEXION_DEVICES
// Initialize the Undo / Redo stack with a first snapshot.
this->take_snapshot(_(L("New Project")));
}
Plater::priv::~priv()
{
#if ENABLE_3DCONNEXION_DEVICES
mouse3d_controller.shutdown();
#endif // ENABLE_3DCONNEXION_DEVICES
if (config != nullptr)
delete config;
}
@ -3248,6 +3262,11 @@ void Plater::priv::set_current_panel(wxPanel* panel)
} else
view3D->reload_scene(true);
}
#if ENABLE_3DCONNEXION_DEVICES
mouse3d_controller.set_canvas(view3D->get_canvas3d());
#endif // ENABLE_3DCONNEXION_DEVICES
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
view3D->set_as_dirty();
view_toolbar.select_item("3D");
@ -3262,6 +3281,11 @@ void Plater::priv::set_current_panel(wxPanel* panel)
this->q->reslice();
// keeps current gcode preview, if any
preview->reload_print(true);
#if ENABLE_3DCONNEXION_DEVICES
mouse3d_controller.set_canvas(preview->get_canvas3d());
#endif // ENABLE_3DCONNEXION_DEVICES
preview->set_canvas_as_dirty();
view_toolbar.select_item("Preview");
}
@ -5020,6 +5044,18 @@ const Camera& Plater::get_camera() const
return p->camera;
}
#if ENABLE_3DCONNEXION_DEVICES
const Mouse3DController& Plater::get_mouse3d_controller() const
{
return p->mouse3d_controller;
}
Mouse3DController& Plater::get_mouse3d_controller()
{
return p->mouse3d_controller;
}
#endif // ENABLE_3DCONNEXION_DEVICES
bool Plater::can_delete() const { return p->can_delete(); }
bool Plater::can_delete_all() const { return p->can_delete_all(); }
bool Plater::can_increase_instances() const { return p->can_increase_instances(); }