mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
3DScene reset_object method moved to c++
This commit is contained in:
parent
5fc8fdee11
commit
a7fc57a176
12 changed files with 135 additions and 31 deletions
|
@ -1772,6 +1772,11 @@ void _3DScene::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes)
|
|||
s_canvas_mgr.set_volumes(canvas, volumes);
|
||||
}
|
||||
|
||||
void _3DScene::reset_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.reset_volumes(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||
{
|
||||
return s_canvas_mgr.set_bed_shape(canvas, shape);
|
||||
|
@ -1887,6 +1892,11 @@ void _3DScene::set_camera_target(wxGLCanvas* canvas, const Pointf3* target)
|
|||
{
|
||||
s_canvas_mgr.set_camera_target(canvas, target);
|
||||
}
|
||||
|
||||
bool _3DScene::is_layers_editing_enabled(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.is_layers_editing_enabled(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
|
|
|
@ -552,6 +552,8 @@ public:
|
|||
static GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||
static void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||
|
||||
static void reset_volumes(wxGLCanvas* canvas);
|
||||
|
||||
static void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
static void set_auto_bed_shape(wxGLCanvas* canvas);
|
||||
|
||||
|
@ -586,6 +588,8 @@ public:
|
|||
static Pointf3 get_camera_target(wxGLCanvas* canvas);
|
||||
static void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
||||
|
||||
static bool is_layers_editing_enabled(wxGLCanvas* canvas);
|
||||
|
||||
static void zoom_to_bed(wxGLCanvas* canvas);
|
||||
static void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
static void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||
|
|
|
@ -395,6 +395,16 @@ void GLCanvas3D::CuttingPlane::render_contour()
|
|||
::glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::LayersEditing()
|
||||
: m_enabled(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_enabled() const
|
||||
{
|
||||
return m_enabled;
|
||||
}
|
||||
|
||||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
||||
: m_canvas(canvas)
|
||||
, m_context(context)
|
||||
|
@ -409,10 +419,15 @@ GLCanvas3D::~GLCanvas3D()
|
|||
_deregister_callbacks();
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_current()
|
||||
bool GLCanvas3D::set_current()
|
||||
{
|
||||
if ((m_canvas != nullptr) && (m_context != nullptr))
|
||||
{
|
||||
m_canvas->SetCurrent(*m_context);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_dirty() const
|
||||
|
@ -507,6 +522,16 @@ void GLCanvas3D::set_volumes(GLVolumeCollection* volumes)
|
|||
m_volumes = volumes;
|
||||
}
|
||||
|
||||
void GLCanvas3D::reset_volumes()
|
||||
{
|
||||
if (set_current() && (m_volumes != nullptr))
|
||||
{
|
||||
m_volumes->release_geometry();
|
||||
m_volumes->clear();
|
||||
set_dirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_bed_shape(const Pointfs& shape)
|
||||
{
|
||||
m_bed.set_shape(shape);
|
||||
|
@ -652,6 +677,11 @@ BoundingBoxf3 GLCanvas3D::max_bounding_box() const
|
|||
return bb;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::is_layers_editing_enabled() const
|
||||
{
|
||||
return m_layers_editing.is_enabled();
|
||||
}
|
||||
|
||||
void GLCanvas3D::zoom_to_bed()
|
||||
{
|
||||
_zoom_to_bounding_box(bed_bounding_box());
|
||||
|
|
|
@ -128,6 +128,16 @@ public:
|
|||
void render_contour();
|
||||
};
|
||||
|
||||
class LayersEditing
|
||||
{
|
||||
bool m_enabled;
|
||||
|
||||
public:
|
||||
LayersEditing();
|
||||
|
||||
bool is_enabled() const;
|
||||
};
|
||||
|
||||
private:
|
||||
wxGLCanvas* m_canvas;
|
||||
wxGLContext* m_context;
|
||||
|
@ -135,6 +145,7 @@ private:
|
|||
Bed m_bed;
|
||||
Axes m_axes;
|
||||
CuttingPlane m_cutting_plane;
|
||||
LayersEditing m_layers_editing;
|
||||
|
||||
GLVolumeCollection* m_volumes;
|
||||
|
||||
|
@ -147,7 +158,7 @@ public:
|
|||
GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context);
|
||||
~GLCanvas3D();
|
||||
|
||||
void set_current();
|
||||
bool set_current();
|
||||
|
||||
bool is_dirty() const;
|
||||
void set_dirty(bool dirty);
|
||||
|
@ -159,6 +170,8 @@ public:
|
|||
GLVolumeCollection* get_volumes();
|
||||
void set_volumes(GLVolumeCollection* volumes);
|
||||
|
||||
void reset_volumes();
|
||||
|
||||
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
||||
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
||||
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
||||
|
@ -198,6 +211,8 @@ public:
|
|||
BoundingBoxf3 volumes_bounding_box() const;
|
||||
BoundingBoxf3 max_bounding_box() const;
|
||||
|
||||
bool is_layers_editing_enabled() const;
|
||||
|
||||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
void select_view(const std::string& direction);
|
||||
|
|
|
@ -187,6 +187,13 @@ void GLCanvas3DManager::set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volu
|
|||
it->second->set_volumes(volumes);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::reset_volumes(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->reset_volumes();
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
@ -342,6 +349,12 @@ void GLCanvas3DManager::set_camera_target(wxGLCanvas* canvas, const Pointf3* tar
|
|||
it->second->set_camera_target(*target);
|
||||
}
|
||||
|
||||
bool GLCanvas3DManager::is_layers_editing_enabled(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->is_layers_editing_enabled() : false;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::zoom_to_bed(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
GLVolumeCollection* get_volumes(wxGLCanvas* canvas);
|
||||
void set_volumes(wxGLCanvas* canvas, GLVolumeCollection* volumes);
|
||||
|
||||
void reset_volumes(wxGLCanvas* canvas);
|
||||
|
||||
void set_bed_shape(wxGLCanvas* canvas, const Pointfs& shape);
|
||||
void set_auto_bed_shape(wxGLCanvas* canvas);
|
||||
|
||||
|
@ -96,6 +98,8 @@ public:
|
|||
Pointf3 get_camera_target(wxGLCanvas* canvas) const;
|
||||
void set_camera_target(wxGLCanvas* canvas, const Pointf3* target);
|
||||
|
||||
bool is_layers_editing_enabled(wxGLCanvas* canvas) const;
|
||||
|
||||
void zoom_to_bed(wxGLCanvas* canvas);
|
||||
void zoom_to_volumes(wxGLCanvas* canvas);
|
||||
void select_view(wxGLCanvas* canvas, const std::string& direction);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue