diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2018-06-11 14:48:02 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2018-06-11 14:48:02 +0300 |
commit | 085110c4d987ee46f2c4d982469677f41aba3dd3 (patch) | |
tree | 4ab23d25c276b7b8189071c427da0150076e377f /xs | |
parent | efe6a290324fc2261ab592be412daeddb445767b (diff) |
Removed 3DScene volumes from perl
Diffstat (limited to 'xs')
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.cpp | 19 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/3DScene.hpp | 5 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3D.cpp | 55 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3D.hpp | 5 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3DManager.cpp | 25 | ||||
-rw-r--r-- | xs/src/slic3r/GUI/GLCanvas3DManager.hpp | 5 | ||||
-rw-r--r-- | xs/xsp/GUI_3DScene.xsp | 38 |
7 files changed, 129 insertions, 23 deletions
diff --git a/xs/src/slic3r/GUI/3DScene.cpp b/xs/src/slic3r/GUI/3DScene.cpp index 21204b0ff..4f95f4ba6 100644 --- a/xs/src/slic3r/GUI/3DScene.cpp +++ b/xs/src/slic3r/GUI/3DScene.cpp @@ -1802,9 +1802,9 @@ bool _3DScene::is_shown_on_screen(wxGLCanvas* canvas) return s_canvas_mgr.is_shown_on_screen(canvas); } -void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes) +unsigned int _3DScene::get_volumes_count(wxGLCanvas* canvas) { - s_canvas_mgr.set_volumes(canvas, volumes); + return s_canvas_mgr.get_volumes_count(canvas); } void _3DScene::reset_volumes(wxGLCanvas* canvas) @@ -1827,6 +1827,21 @@ void _3DScene::update_volumes_selection(wxGLCanvas* canvas, const std::vector<in s_canvas_mgr.update_volumes_selection(canvas, selections); } +bool _3DScene::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) +{ + return s_canvas_mgr.check_volumes_outside_state(canvas, config); +} + +bool _3DScene::move_volume_up(wxGLCanvas* canvas, unsigned int id) +{ + return s_canvas_mgr.move_volume_up(canvas, id); +} + +bool _3DScene::move_volume_down(wxGLCanvas* canvas, unsigned int id) +{ + return s_canvas_mgr.move_volume_down(canvas, id); +} + void _3DScene::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections) { s_canvas_mgr.set_objects_selections(canvas, selections); diff --git a/xs/src/slic3r/GUI/3DScene.hpp b/xs/src/slic3r/GUI/3DScene.hpp index 8e82849e8..1f179b009 100644 --- a/xs/src/slic3r/GUI/3DScene.hpp +++ b/xs/src/slic3r/GUI/3DScene.hpp @@ -558,11 +558,14 @@ public: static bool is_shown_on_screen(wxGLCanvas* canvas); - static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + static unsigned int get_volumes_count(wxGLCanvas* canvas); static void reset_volumes(wxGLCanvas* canvas); static void deselect_volumes(wxGLCanvas* canvas); static void select_volume(wxGLCanvas* canvas, unsigned int id); static void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections); + static bool check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config); + static bool move_volume_up(wxGLCanvas* canvas, unsigned int id); + static bool move_volume_down(wxGLCanvas* canvas, unsigned int id); static void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections); diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index e5f352bf7..7d39d97d3 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -24,10 +24,6 @@ #include <iostream> #include <float.h> -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ -#include "SVG.hpp" -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - static const float TRACKBALLSIZE = 0.8f; static const float GIMBALL_LOCK_THETA_MAX = 180.0f; static const float GROUND_Z = -0.02f; @@ -661,7 +657,6 @@ bool GLCanvas3D::Bed::_are_equal(const Pointfs& bed_1, const Pointfs& bed_2) return true; } -//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ GLCanvas3D::Axes::Axes() : length(0.0f) @@ -1212,15 +1207,18 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context) , m_reload_delayed(false) { if (m_canvas != nullptr) + { m_timer = new wxTimer(m_canvas); + m_volumes = new GLVolumeCollection; + } } GLCanvas3D::~GLCanvas3D() { if (m_volumes != nullptr) { - set_current(); - m_volumes->release_geometry(); + reset_volumes(); + delete m_volumes; } if (m_timer != nullptr) @@ -1317,9 +1315,9 @@ bool GLCanvas3D::is_shown_on_screen() const return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false; } -void GLCanvas3D::set_volumes(GLVolumeCollection* volumes) +unsigned int GLCanvas3D::get_volumes_count() const { - m_volumes = volumes; + return (m_volumes != nullptr) ? (unsigned int)m_volumes->volumes.size() : 0; } void GLCanvas3D::reset_volumes() @@ -1372,6 +1370,45 @@ void GLCanvas3D::update_volumes_selection(const std::vector<int>& selections) } } +bool GLCanvas3D::check_volumes_outside_state(const DynamicPrintConfig* config) const +{ + return (m_volumes != nullptr) ? m_volumes->check_outside_state(config) : false; +} + +bool GLCanvas3D::move_volume_up(unsigned int id) +{ + if (m_volumes != nullptr) + { + if ((id > 0) && (id < (unsigned int)m_volumes->volumes.size())) + { + std::swap(m_volumes->volumes[id - 1], m_volumes->volumes[id]); + std::swap(m_volumes->volumes[id - 1]->composite_id, m_volumes->volumes[id]->composite_id); + std::swap(m_volumes->volumes[id - 1]->select_group_id, m_volumes->volumes[id]->select_group_id); + std::swap(m_volumes->volumes[id - 1]->drag_group_id, m_volumes->volumes[id]->drag_group_id); + return true; + } + } + + return false; +} + +bool GLCanvas3D::move_volume_down(unsigned int id) +{ + if (m_volumes != nullptr) + { + if ((id >= 0) && (id + 1 < (unsigned int)m_volumes->volumes.size())) + { + std::swap(m_volumes->volumes[id + 1], m_volumes->volumes[id]); + std::swap(m_volumes->volumes[id + 1]->composite_id, m_volumes->volumes[id]->composite_id); + std::swap(m_volumes->volumes[id + 1]->select_group_id, m_volumes->volumes[id]->select_group_id); + std::swap(m_volumes->volumes[id + 1]->drag_group_id, m_volumes->volumes[id]->drag_group_id); + return true; + } + } + + return false; +} + void GLCanvas3D::set_objects_selections(const std::vector<int>& selections) { m_objects_selections = selections; diff --git a/xs/src/slic3r/GUI/GLCanvas3D.hpp b/xs/src/slic3r/GUI/GLCanvas3D.hpp index dde96ff41..2bdf9e692 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.hpp @@ -419,11 +419,14 @@ public: bool is_shown_on_screen() const; - void set_volumes(GLVolumeCollection* volumes); + unsigned int get_volumes_count() const; void reset_volumes(); void deselect_volumes(); void select_volume(unsigned int id); void update_volumes_selection(const std::vector<int>& selections); + bool check_volumes_outside_state(const DynamicPrintConfig* config) const; + bool move_volume_up(unsigned int id); + bool move_volume_down(unsigned int id); void set_objects_selections(const std::vector<int>& selections); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp index e01f85396..54bd54ba8 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -226,11 +226,10 @@ bool GLCanvas3DManager::is_shown_on_screen(wxGLCanvas* canvas) const return (it != m_canvases.end()) ? it->second->is_shown_on_screen() : false; } -void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes) +unsigned int GLCanvas3DManager::get_volumes_count(wxGLCanvas* canvas) const { - CanvasesMap::iterator it = _get_canvas(canvas); - if (it != m_canvases.end()) - it->second->set_volumes(volumes); + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->get_volumes_count() : 0; } void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas) @@ -261,6 +260,24 @@ void GLCanvas3DManager::update_volumes_selection(wxGLCanvas* canvas, const std:: it->second->update_volumes_selection(selections); } +bool GLCanvas3DManager::check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->check_volumes_outside_state(config) : false; +} + +bool GLCanvas3DManager::move_volume_up(wxGLCanvas* canvas, unsigned int id) +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->move_volume_up(id) : false; +} + +bool GLCanvas3DManager::move_volume_down(wxGLCanvas* canvas, unsigned int id) +{ + CanvasesMap::const_iterator it = _get_canvas(canvas); + return (it != m_canvases.end()) ? it->second->move_volume_down(id) : false; +} + void GLCanvas3DManager::set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections) { CanvasesMap::iterator it = _get_canvas(canvas); diff --git a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp index 76f8ffcb5..435993acd 100644 --- a/xs/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/xs/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -53,11 +53,14 @@ public: bool is_shown_on_screen(wxGLCanvas* canvas) const; - void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes); + unsigned int get_volumes_count(wxGLCanvas* canvas) const; void reset_volumes(wxGLCanvas* canvas); void deselect_volumes(wxGLCanvas* canvas); void select_volume(wxGLCanvas* canvas, unsigned int id); void update_volumes_selection(wxGLCanvas* canvas, const std::vector<int>& selections); + bool check_volumes_outside_state(wxGLCanvas* canvas, const DynamicPrintConfig* config) const; + bool move_volume_up(wxGLCanvas* canvas, unsigned int id); + bool move_volume_down(wxGLCanvas* canvas, unsigned int id); void set_objects_selections(wxGLCanvas* canvas, const std::vector<int>& selections); diff --git a/xs/xsp/GUI_3DScene.xsp b/xs/xsp/GUI_3DScene.xsp index f8d22843e..8deb6419d 100644 --- a/xs/xsp/GUI_3DScene.xsp +++ b/xs/xsp/GUI_3DScene.xsp @@ -199,12 +199,13 @@ is_shown_on_screen(canvas) OUTPUT: RETVAL -void -set_volumes(canvas, volumes) - SV *canvas; - GLVolumeCollection *volumes; +unsigned int +get_volumes_count(canvas) + SV *canvas; CODE: - _3DScene::set_volumes((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), volumes); + RETVAL = _3DScene::get_volumes_count((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas")); + OUTPUT: + RETVAL void reset_volumes(canvas) @@ -232,6 +233,33 @@ update_volumes_selection(canvas, selections) CODE: _3DScene::update_volumes_selection((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), selections); +bool +check_volumes_outside_state(canvas, config) + SV *canvas; + DynamicPrintConfig *config; + CODE: + RETVAL = _3DScene::check_volumes_outside_state((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), config); + OUTPUT: + RETVAL + +bool +move_volume_up(canvas, id) + SV *canvas; + unsigned int id; + CODE: + RETVAL = _3DScene::move_volume_up((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id); + OUTPUT: + RETVAL + +bool +move_volume_down(canvas, id) + SV *canvas; + unsigned int id; + CODE: + RETVAL = _3DScene::move_volume_down((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), id); + OUTPUT: + RETVAL + void set_objects_selections(canvas, selections) SV *canvas; |