Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/xs
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2018-09-11 13:40:42 +0300
committerEnrico Turri <enricoturri@seznam.cz>2018-09-11 13:40:42 +0300
commita97df55592f524eb73bd7d04ef8b7c1b3525d27d (patch)
tree10134ade414eda4dfa4b09d6804de7b718bcdc57 /xs
parent4479c5444a26f5ad77a16b26ed18bd61e24db592 (diff)
Temporary remove not yet supported transformations from 3D gizmos
Diffstat (limited to 'xs')
-rw-r--r--xs/src/slic3r/GUI/GLCanvas3D.cpp17
-rw-r--r--xs/src/slic3r/GUI/GLGizmo.cpp68
-rw-r--r--xs/src/slic3r/GUI/GLGizmo.hpp18
3 files changed, 86 insertions, 17 deletions
diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp
index b98826a80..fdee693ee 100644
--- a/xs/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp
@@ -1140,6 +1140,9 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
if (!gizmo->init())
return false;
+ // temporary disable z grabber
+ gizmo->disable_grabber(2);
+
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
gizmo = new GLGizmoScale3D(parent);
@@ -1149,6 +1152,16 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
if (!gizmo->init())
return false;
+ // temporary disable x grabbers
+ gizmo->disable_grabber(0);
+ gizmo->disable_grabber(1);
+ // temporary disable y grabbers
+ gizmo->disable_grabber(2);
+ gizmo->disable_grabber(3);
+ // temporary disable z grabbers
+ gizmo->disable_grabber(4);
+ gizmo->disable_grabber(5);
+
m_gizmos.insert(GizmosMap::value_type(Scale, gizmo));
gizmo = new GLGizmoRotate3D(parent);
@@ -1164,6 +1177,10 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
return false;
}
+ // temporary disable x and y grabbers
+ gizmo->disable_grabber(0);
+ gizmo->disable_grabber(1);
+
m_gizmos.insert(GizmosMap::value_type(Rotate, gizmo));
gizmo = new GLGizmoFlatten(parent);
diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp
index 17c69749b..4aa5ab32f 100644
--- a/xs/src/slic3r/GUI/GLGizmo.cpp
+++ b/xs/src/slic3r/GUI/GLGizmo.cpp
@@ -110,6 +110,7 @@ GLGizmoBase::Grabber::Grabber()
: center(Vec3d::Zero())
, angles(Vec3d::Zero())
, dragging(false)
+ , enabled(true)
{
color[0] = 1.0f;
color[1] = 1.0f;
@@ -234,6 +235,22 @@ void GLGizmoBase::set_highlight_color(const float* color)
::memcpy((void*)m_highlight_color, (const void*)color, 3 * sizeof(float));
}
+void GLGizmoBase::enable_grabber(unsigned int id)
+{
+ if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
+ m_grabbers[id].enabled = true;
+
+ on_enable_grabber(id);
+}
+
+void GLGizmoBase::disable_grabber(unsigned int id)
+{
+ if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
+ m_grabbers[id].enabled = false;
+
+ on_disable_grabber(id);
+}
+
void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
{
m_dragging = true;
@@ -278,7 +295,8 @@ void GLGizmoBase::render_grabbers() const
{
for (int i = 0; i < (int)m_grabbers.size(); ++i)
{
- m_grabbers[i].render(m_hover_id == i);
+ if (m_grabbers[i].enabled)
+ m_grabbers[i].render(m_hover_id == i);
}
}
@@ -286,10 +304,13 @@ void GLGizmoBase::render_grabbers_for_picking() const
{
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
{
- m_grabbers[i].color[0] = 1.0f;
- m_grabbers[i].color[1] = 1.0f;
- m_grabbers[i].color[2] = picking_color_component(i);
- m_grabbers[i].render_for_picking();
+ if (m_grabbers[i].enabled)
+ {
+ m_grabbers[i].color[0] = 1.0f;
+ m_grabbers[i].color[1] = 1.0f;
+ m_grabbers[i].color[2] = picking_color_component(i);
+ m_grabbers[i].render_for_picking();
+ }
}
}
@@ -386,6 +407,9 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
{
+ if (!m_grabbers[0].enabled)
+ return;
+
if (m_dragging)
set_tooltip(format(m_angle * 180.0f / (float)PI, 4));
else
@@ -789,12 +813,21 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
::glColor3fv(m_base_color);
render_box(m_box);
// draw connections
- ::glColor3fv(m_grabbers[0].color);
- render_grabbers_connection(0, 1);
- ::glColor3fv(m_grabbers[2].color);
- render_grabbers_connection(2, 3);
- ::glColor3fv(m_grabbers[4].color);
- render_grabbers_connection(4, 5);
+ if (m_grabbers[0].enabled && m_grabbers[1].enabled)
+ {
+ ::glColor3fv(m_grabbers[0].color);
+ render_grabbers_connection(0, 1);
+ }
+ if (m_grabbers[2].enabled && m_grabbers[3].enabled)
+ {
+ ::glColor3fv(m_grabbers[2].color);
+ render_grabbers_connection(2, 3);
+ }
+ if (m_grabbers[4].enabled && m_grabbers[5].enabled)
+ {
+ ::glColor3fv(m_grabbers[4].color);
+ render_grabbers_connection(4, 5);
+ }
// draw grabbers
render_grabbers();
}
@@ -1074,11 +1107,14 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
// draw axes
for (unsigned int i = 0; i < 3; ++i)
{
- ::glColor3fv(AXES_COLOR[i]);
- ::glBegin(GL_LINES);
- ::glVertex3f(center(0), center(1), center(2));
- ::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), (GLfloat)m_grabbers[i].center(2));
- ::glEnd();
+ if (m_grabbers[i].enabled)
+ {
+ ::glColor3fv(AXES_COLOR[i]);
+ ::glBegin(GL_LINES);
+ ::glVertex3f(center(0), center(1), center(2));
+ ::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), (GLfloat)m_grabbers[i].center(2));
+ ::glEnd();
+ }
}
// draw grabbers
diff --git a/xs/src/slic3r/GUI/GLGizmo.hpp b/xs/src/slic3r/GUI/GLGizmo.hpp
index a7c688531..8760b1c7d 100644
--- a/xs/src/slic3r/GUI/GLGizmo.hpp
+++ b/xs/src/slic3r/GUI/GLGizmo.hpp
@@ -28,6 +28,7 @@ protected:
Vec3d center;
Vec3d angles;
float color[3];
+ bool enabled;
bool dragging;
Grabber();
@@ -80,9 +81,12 @@ public:
int get_hover_id() const { return m_hover_id; }
void set_hover_id(int id);
-
+
void set_highlight_color(const float* color);
+ void enable_grabber(unsigned int id);
+ void disable_grabber(unsigned int id);
+
void start_dragging(const BoundingBoxf3& box);
void stop_dragging();
bool is_dragging() const { return m_dragging; }
@@ -96,6 +100,8 @@ protected:
virtual bool on_init() = 0;
virtual void on_set_state() {}
virtual void on_set_hover_id() {}
+ virtual void on_enable_grabber(unsigned int id) {}
+ virtual void on_disable_grabber(unsigned int id) {}
virtual void on_start_dragging(const BoundingBoxf3& box) {}
virtual void on_stop_dragging() {}
virtual void on_update(const Linef3& mouse_ray) = 0;
@@ -196,6 +202,16 @@ protected:
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
}
}
+ virtual void on_enable_grabber(unsigned int id)
+ {
+ if ((0 <= id) && (id < 3))
+ m_gizmos[id].enable_grabber(0);
+ }
+ virtual void on_disable_grabber(unsigned int id)
+ {
+ if ((0 <= id) && (id < 3))
+ m_gizmos[id].disable_grabber(0);
+ }
virtual void on_start_dragging(const BoundingBoxf3& box);
virtual void on_stop_dragging();
virtual void on_update(const Linef3& mouse_ray)