mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-10 23:35:13 -06:00
3DScene timer and _variable_layer_thickness_action method moved to c++
This commit is contained in:
parent
2f773a89df
commit
30a3b2179b
11 changed files with 389 additions and 136 deletions
|
@ -184,6 +184,10 @@ public:
|
|||
|
||||
void reset_layer_height_profile();
|
||||
|
||||
//############################################################################################################################################
|
||||
void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action);
|
||||
//############################################################################################################################################
|
||||
|
||||
// Collect the slicing parameters, to be used by variable layer thickness algorithm,
|
||||
// by the interactive layer height editor and by the printing process itself.
|
||||
// The slicing parameters are dependent on various configuration values
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
#include "Geometry.hpp"
|
||||
#include "SupportMaterial.hpp"
|
||||
#include "Surface.hpp"
|
||||
//############################################################################################################################################
|
||||
#include "Slicing.hpp"
|
||||
//############################################################################################################################################
|
||||
|
||||
#include <utility>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
@ -1961,4 +1964,14 @@ void PrintObject::reset_layer_height_profile()
|
|||
this->model_object()->layer_height_profile_valid = false;
|
||||
}
|
||||
|
||||
//############################################################################################################################################
|
||||
void PrintObject::adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action)
|
||||
{
|
||||
update_layer_height_profile(_model_object->layer_height_profile);
|
||||
Slic3r::adjust_layer_height_profile(slicing_parameters(), _model_object->layer_height_profile, z, layer_thickness_delta, band_width, LayerHeightEditActionType(action));
|
||||
_model_object->layer_height_profile_valid = true;
|
||||
layer_height_profile_valid = false;
|
||||
}
|
||||
//############################################################################################################################################
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -2015,6 +2015,16 @@ unsigned int _3DScene::get_layers_editing_z_texture_id(wxGLCanvas* canvas)
|
|||
return s_canvas_mgr.get_layers_editing_z_texture_id(canvas);
|
||||
}
|
||||
|
||||
unsigned int _3DScene::get_layers_editing_state(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_layers_editing_state(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::set_layers_editing_state(wxGLCanvas* canvas, unsigned int state)
|
||||
{
|
||||
s_canvas_mgr.set_layers_editing_state(canvas, state);
|
||||
}
|
||||
|
||||
float _3DScene::get_layers_editing_band_width(wxGLCanvas* canvas)
|
||||
{
|
||||
return s_canvas_mgr.get_layers_editing_band_width(canvas);
|
||||
|
@ -2140,6 +2150,21 @@ void _3DScene::render_texture(wxGLCanvas* canvas, unsigned int tex_id, float lef
|
|||
s_canvas_mgr.render_texture(canvas, tex_id, left, right, bottom, top);
|
||||
}
|
||||
|
||||
void _3DScene::start_timer(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.start_timer(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::stop_timer(wxGLCanvas* canvas)
|
||||
{
|
||||
s_canvas_mgr.stop_timer(canvas);
|
||||
}
|
||||
|
||||
void _3DScene::perform_layer_editing_action(wxGLCanvas* canvas, int y, bool shift_down, bool right_down)
|
||||
{
|
||||
s_canvas_mgr.perform_layer_editing_action(canvas, y, shift_down, right_down);
|
||||
}
|
||||
|
||||
void _3DScene::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
s_canvas_mgr.register_on_viewport_changed_callback(canvas, callback);
|
||||
|
|
|
@ -619,6 +619,9 @@ public:
|
|||
|
||||
static unsigned int get_layers_editing_z_texture_id(wxGLCanvas* canvas);
|
||||
|
||||
static unsigned int get_layers_editing_state(wxGLCanvas* canvas);
|
||||
static void set_layers_editing_state(wxGLCanvas* canvas, unsigned int state);
|
||||
|
||||
static float get_layers_editing_band_width(wxGLCanvas* canvas);
|
||||
static void set_layers_editing_band_width(wxGLCanvas* canvas, float band_width);
|
||||
|
||||
|
@ -655,6 +658,10 @@ public:
|
|||
static void render_volumes(wxGLCanvas* canvas, bool fake_colors);
|
||||
static void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top);
|
||||
|
||||
static void start_timer(wxGLCanvas* canvas);
|
||||
static void stop_timer(wxGLCanvas* canvas);
|
||||
static void perform_layer_editing_action(wxGLCanvas* canvas, int y, bool shift_down, bool right_down);
|
||||
|
||||
static void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
// static void _glew_init();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <wx/glcanvas.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <float.h>
|
||||
|
@ -589,7 +590,8 @@ GLCanvas3D::LayersEditing::GLTextureData::GLTextureData(unsigned int id, int wid
|
|||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::LayersEditing()
|
||||
: m_use_legacy_opengl(false)
|
||||
: m_state(Unknown)
|
||||
, m_use_legacy_opengl(false)
|
||||
, m_enabled(false)
|
||||
, m_z_texture_id(0)
|
||||
, m_band_width(2.0f)
|
||||
|
@ -638,6 +640,16 @@ bool GLCanvas3D::LayersEditing::init(const std::string& vertex_shader_filename,
|
|||
return true;
|
||||
}
|
||||
|
||||
GLCanvas3D::LayersEditing::EState GLCanvas3D::LayersEditing::get_state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
void GLCanvas3D::LayersEditing::set_state(GLCanvas3D::LayersEditing::EState state)
|
||||
{
|
||||
m_state = state;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::is_allowed() const
|
||||
{
|
||||
return m_use_legacy_opengl && m_shader.is_initialized();
|
||||
|
@ -718,8 +730,8 @@ void GLCanvas3D::LayersEditing::render(const GLCanvas3D& canvas, const PrintObje
|
|||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
const Rect& bar_rect = _get_bar_rect_viewport(canvas);
|
||||
const Rect& reset_rect = _get_reset_rect_viewport(canvas);
|
||||
const Rect& bar_rect = get_bar_rect_viewport(canvas);
|
||||
const Rect& reset_rect = get_reset_rect_viewport(canvas);
|
||||
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
@ -747,13 +759,13 @@ const GLShader* GLCanvas3D::LayersEditing::get_shader() const
|
|||
float GLCanvas3D::LayersEditing::get_cursor_z_relative(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Point& mouse_pos = canvas.get_local_mouse_position();
|
||||
const Rect& bar_rect = _get_bar_rect_screen(canvas);
|
||||
const Rect& rect = get_bar_rect_screen(canvas);
|
||||
float x = (float)mouse_pos.x;
|
||||
float y = (float)mouse_pos.y;
|
||||
float t = bar_rect.get_top();
|
||||
float b = bar_rect.get_bottom();
|
||||
float t = rect.get_top();
|
||||
float b = rect.get_bottom();
|
||||
|
||||
return ((bar_rect.get_left() <= x) && (x <= bar_rect.get_right()) && (t <= y) && (y <= b)) ?
|
||||
return ((rect.get_left() <= x) && (x <= rect.get_right()) && (t <= y) && (y <= b)) ?
|
||||
// Inside the bar.
|
||||
(b - y - 1.0f) / (b - t - 1.0f) :
|
||||
// Outside the bar.
|
||||
|
@ -777,16 +789,59 @@ int GLCanvas3D::LayersEditing::get_first_selected_object_id(const GLVolumeCollec
|
|||
|
||||
bool GLCanvas3D::LayersEditing::bar_rect_contains(const GLCanvas3D& canvas, float x, float y)
|
||||
{
|
||||
const Rect& rect = _get_bar_rect_screen(canvas);
|
||||
const Rect& rect = get_bar_rect_screen(canvas);
|
||||
return (rect.get_left() <= x) && (x <= rect.get_right()) && (rect.get_top() <= y) && (y <= rect.get_bottom());
|
||||
}
|
||||
|
||||
bool GLCanvas3D::LayersEditing::reset_rect_contains(const GLCanvas3D& canvas, float x, float y)
|
||||
{
|
||||
const Rect& rect = _get_reset_rect_screen(canvas);
|
||||
const Rect& rect = get_reset_rect_screen(canvas);
|
||||
return (rect.get_left() <= x) && (x <= rect.get_right()) && (rect.get_top() <= y) && (y <= rect.get_bottom());
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::get_bar_rect_screen(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float w = (float)cnv_size.get_width();
|
||||
float h = (float)cnv_size.get_height();
|
||||
|
||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, 0.0f, w, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::get_reset_rect_screen(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float w = (float)cnv_size.get_width();
|
||||
float h = (float)cnv_size.get_height();
|
||||
|
||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT, w, h);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||
float half_h = 0.5f * (float)cnv_size.get_height();
|
||||
|
||||
float zoom = canvas.get_camera_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::get_reset_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||
float half_h = 0.5f * (float)cnv_size.get_height();
|
||||
|
||||
float zoom = canvas.get_camera_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
||||
}
|
||||
|
||||
|
||||
bool GLCanvas3D::LayersEditing::_is_initialized() const
|
||||
{
|
||||
return m_shader.is_initialized();
|
||||
|
@ -969,48 +1024,6 @@ GLCanvas3D::LayersEditing::GLTextureData GLCanvas3D::LayersEditing::_load_textur
|
|||
return GLTextureData((unsigned int)tex_id, width, height);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::_get_bar_rect_screen(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float w = (float)cnv_size.get_width();
|
||||
float h = (float)cnv_size.get_height();
|
||||
|
||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, 0.0f, w, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::_get_reset_rect_screen(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float w = (float)cnv_size.get_width();
|
||||
float h = (float)cnv_size.get_height();
|
||||
|
||||
return Rect(w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH, h - VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT, w, h);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::_get_bar_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||
float half_h = 0.5f * (float)cnv_size.get_height();
|
||||
|
||||
float zoom = canvas.get_camera_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, half_h * inv_zoom, half_w * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom);
|
||||
}
|
||||
|
||||
Rect GLCanvas3D::LayersEditing::_get_reset_rect_viewport(const GLCanvas3D& canvas)
|
||||
{
|
||||
const Size& cnv_size = canvas.get_canvas_size();
|
||||
float half_w = 0.5f * (float)cnv_size.get_width();
|
||||
float half_h = 0.5f * (float)cnv_size.get_height();
|
||||
|
||||
float zoom = canvas.get_camera_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
|
||||
return Rect((half_w - VARIABLE_LAYER_THICKNESS_BAR_WIDTH) * inv_zoom, (-half_h + VARIABLE_LAYER_THICKNESS_RESET_BUTTON_HEIGHT) * inv_zoom, half_w * inv_zoom, -half_h * inv_zoom);
|
||||
}
|
||||
|
||||
GLCanvas3D::Mouse::Mouse()
|
||||
: m_dragging(false)
|
||||
{
|
||||
|
@ -1039,6 +1052,7 @@ void GLCanvas3D::Mouse::set_position(const Pointf& position)
|
|||
GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
||||
: m_canvas(canvas)
|
||||
, m_context(context)
|
||||
, m_timer(nullptr)
|
||||
, m_volumes(nullptr)
|
||||
, m_config(nullptr)
|
||||
, m_print(nullptr)
|
||||
|
@ -1051,10 +1065,18 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, wxGLContext* context)
|
|||
, m_shader_enabled(false)
|
||||
, m_multisample_allowed(false)
|
||||
{
|
||||
if (m_canvas != nullptr)
|
||||
m_timer = new wxTimer(m_canvas);
|
||||
}
|
||||
|
||||
GLCanvas3D::~GLCanvas3D()
|
||||
{
|
||||
if (m_timer != nullptr)
|
||||
{
|
||||
delete m_timer;
|
||||
m_timer = nullptr;
|
||||
}
|
||||
|
||||
_deregister_callbacks();
|
||||
}
|
||||
|
||||
|
@ -1585,6 +1607,17 @@ unsigned int GLCanvas3D::get_layers_editing_z_texture_id() const
|
|||
return m_layers_editing.get_z_texture_id();
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3D::get_layers_editing_state() const
|
||||
{
|
||||
return (unsigned int)m_layers_editing.get_state();
|
||||
}
|
||||
|
||||
void GLCanvas3D::set_layers_editing_state(unsigned int state)
|
||||
{
|
||||
if (state < (unsigned int)LayersEditing::Num_States)
|
||||
m_layers_editing.set_state((LayersEditing::EState)state);
|
||||
}
|
||||
|
||||
float GLCanvas3D::get_layers_editing_band_width() const
|
||||
{
|
||||
return m_layers_editing.get_band_width();
|
||||
|
@ -1833,6 +1866,14 @@ void GLCanvas3D::on_mouse_wheel(wxMouseEvent& evt)
|
|||
_refresh_if_shown_on_screen();
|
||||
}
|
||||
|
||||
void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
||||
{
|
||||
if (get_layers_editing_state() != 1)
|
||||
return;
|
||||
|
||||
_perform_layer_editing_action();
|
||||
}
|
||||
|
||||
Size GLCanvas3D::get_canvas_size() const
|
||||
{
|
||||
int w = 0;
|
||||
|
@ -1853,6 +1894,28 @@ Point GLCanvas3D::get_local_mouse_position() const
|
|||
return Point(mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
|
||||
void GLCanvas3D::start_timer()
|
||||
{
|
||||
if (m_timer != nullptr)
|
||||
m_timer->Start(100, wxTIMER_CONTINUOUS);
|
||||
}
|
||||
|
||||
void GLCanvas3D::stop_timer()
|
||||
{
|
||||
if (m_timer != nullptr)
|
||||
m_timer->Stop();
|
||||
}
|
||||
|
||||
void GLCanvas3D::perform_layer_editing_action(int y, bool shift_down, bool right_down)
|
||||
{
|
||||
wxMouseEvent evt;
|
||||
evt.m_y = (wxCoord)y;
|
||||
evt.SetShiftDown(shift_down);
|
||||
evt.SetRightDown(right_down);
|
||||
|
||||
_perform_layer_editing_action(&evt);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_zoom_to_bounding_box(const BoundingBoxf3& bbox)
|
||||
{
|
||||
// Calculate the zoom factor needed to adjust viewport to bounding box.
|
||||
|
@ -2238,5 +2301,53 @@ void GLCanvas3D::_render_layer_editing_overlay() const
|
|||
m_layers_editing.render(*this, *print_object, *volume);
|
||||
}
|
||||
|
||||
void GLCanvas3D::_perform_layer_editing_action(wxMouseEvent* evt)
|
||||
{
|
||||
int object_idx_selected = get_layers_editing_last_object_id();
|
||||
if (object_idx_selected == -1)
|
||||
return;
|
||||
|
||||
if ((m_volumes == nullptr) || (m_print == nullptr))
|
||||
return;
|
||||
|
||||
PrintObject* selected_obj = m_print->get_object(object_idx_selected);
|
||||
if (selected_obj == nullptr)
|
||||
return;
|
||||
|
||||
// A volume is selected. Test, whether hovering over a layer thickness bar.
|
||||
if (evt != nullptr)
|
||||
{
|
||||
const Rect& rect = LayersEditing::get_bar_rect_screen(*this);
|
||||
float b = rect.get_bottom();
|
||||
set_layers_editing_last_z(unscale(selected_obj->size.z) * (b - evt->GetY() - 1.0f) / (b - rect.get_top()));
|
||||
set_layers_editing_last_action(evt->ShiftDown() ? (evt->RightIsDown() ? 3 : 2) : (evt->RightIsDown() ? 0 : 1));
|
||||
}
|
||||
|
||||
// Mark the volume as modified, so Print will pick its layer height profile ? Where to mark it ?
|
||||
// Start a timer to refresh the print ? schedule_background_process() ?
|
||||
// The PrintObject::adjust_layer_height_profile() call adjusts the profile of its associated ModelObject, it does not modify the profile of the PrintObject itself.
|
||||
selected_obj->adjust_layer_height_profile(get_layers_editing_last_z(), get_layers_editing_strength(), get_layers_editing_band_width(), get_layers_editing_last_action());
|
||||
|
||||
// searches the id of the first volume of the selected object
|
||||
int volume_idx = 0;
|
||||
for (int i = 0; i < object_idx_selected; ++i)
|
||||
{
|
||||
PrintObject* obj = m_print->get_object(i);
|
||||
if (obj != nullptr)
|
||||
{
|
||||
for (int j = 0; j < (int)obj->region_volumes.size(); ++j)
|
||||
{
|
||||
volume_idx += (int)obj->region_volumes[j].size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_volumes->volumes[volume_idx]->generate_layer_height_texture(selected_obj, 1);
|
||||
_refresh_if_shown_on_screen();
|
||||
|
||||
// Automatic action on mouse down with the same coordinate.
|
||||
start_timer();
|
||||
}
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
class wxGLCanvas;
|
||||
class wxGLContext;
|
||||
class wxTimer;
|
||||
class wxSizeEvent;
|
||||
class wxIdleEvent;
|
||||
class wxKeyEvent;
|
||||
class wxMouseEvent;
|
||||
class wxTimerEvent;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -202,6 +204,16 @@ public:
|
|||
|
||||
class LayersEditing
|
||||
{
|
||||
public:
|
||||
enum EState : unsigned char
|
||||
{
|
||||
Unknown,
|
||||
Editing,
|
||||
Completed,
|
||||
Num_States
|
||||
};
|
||||
|
||||
private:
|
||||
struct GLTextureData
|
||||
{
|
||||
unsigned int id;
|
||||
|
@ -212,6 +224,7 @@ public:
|
|||
GLTextureData(unsigned int id, int width, int height);
|
||||
};
|
||||
|
||||
EState m_state;
|
||||
bool m_use_legacy_opengl;
|
||||
bool m_enabled;
|
||||
Shader m_shader;
|
||||
|
@ -230,6 +243,9 @@ public:
|
|||
|
||||
bool init(const std::string& vertex_shader_filename, const std::string& fragment_shader_filename);
|
||||
|
||||
EState get_state() const;
|
||||
void set_state(EState state);
|
||||
|
||||
bool is_allowed() const;
|
||||
void set_use_legacy_opengl(bool use_legacy_opengl);
|
||||
|
||||
|
@ -261,6 +277,10 @@ public:
|
|||
static int get_first_selected_object_id(const GLVolumeCollection& volumes, unsigned int objects_count);
|
||||
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
||||
static bool reset_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
||||
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
||||
static Rect get_reset_rect_screen(const GLCanvas3D& canvas);
|
||||
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
||||
static Rect get_reset_rect_viewport(const GLCanvas3D& canvas);
|
||||
|
||||
private:
|
||||
bool _is_initialized() const;
|
||||
|
@ -269,10 +289,6 @@ public:
|
|||
void _render_active_object_annotations(const GLCanvas3D& canvas, const GLVolume& volume, const PrintObject& print_object, const Rect& bar_rect) const;
|
||||
void _render_profile(const PrintObject& print_object, const Rect& bar_rect) const;
|
||||
static GLTextureData _load_texture_from_file(const std::string& filename);
|
||||
static Rect _get_bar_rect_screen(const GLCanvas3D& canvas);
|
||||
static Rect _get_reset_rect_screen(const GLCanvas3D& canvas);
|
||||
static Rect _get_bar_rect_viewport(const GLCanvas3D& canvas);
|
||||
static Rect _get_reset_rect_viewport(const GLCanvas3D& canvas);
|
||||
};
|
||||
|
||||
class Mouse
|
||||
|
@ -293,6 +309,7 @@ public:
|
|||
private:
|
||||
wxGLCanvas* m_canvas;
|
||||
wxGLContext* m_context;
|
||||
wxTimer* m_timer;
|
||||
Camera m_camera;
|
||||
Bed m_bed;
|
||||
Axes m_axes;
|
||||
|
@ -402,6 +419,9 @@ public:
|
|||
|
||||
unsigned int get_layers_editing_z_texture_id() const;
|
||||
|
||||
unsigned int get_layers_editing_state() const;
|
||||
void set_layers_editing_state(unsigned int state);
|
||||
|
||||
float get_layers_editing_band_width() const;
|
||||
void set_layers_editing_band_width(float band_width);
|
||||
|
||||
|
@ -444,10 +464,15 @@ public:
|
|||
void on_idle(wxIdleEvent& evt);
|
||||
void on_char(wxKeyEvent& evt);
|
||||
void on_mouse_wheel(wxMouseEvent& evt);
|
||||
void on_timer(wxTimerEvent& evt);
|
||||
|
||||
Size get_canvas_size() const;
|
||||
Point get_local_mouse_position() const;
|
||||
|
||||
void start_timer();
|
||||
void stop_timer();
|
||||
void perform_layer_editing_action(int y, bool shift_down, bool right_down);
|
||||
|
||||
private:
|
||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||
|
@ -466,6 +491,8 @@ private:
|
|||
void _render_warning_texture() const;
|
||||
void _render_legend_texture() const;
|
||||
void _render_layer_editing_overlay() const;
|
||||
|
||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <boost/algorithm/string/classification.hpp>
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
@ -76,6 +77,7 @@ bool GLCanvas3DManager::add(wxGLCanvas* canvas, wxGLContext* context)
|
|||
canvas->Bind(wxEVT_IDLE, [canvas3D](wxIdleEvent& evt) { canvas3D->on_idle(evt); });
|
||||
canvas->Bind(wxEVT_CHAR, [canvas3D](wxKeyEvent& evt) { canvas3D->on_char(evt); });
|
||||
canvas->Bind(wxEVT_MOUSEWHEEL, [canvas3D](wxMouseEvent& evt) { canvas3D->on_mouse_wheel(evt); });
|
||||
canvas->Bind(wxEVT_TIMER, [canvas3D](wxTimerEvent& evt) { canvas3D->on_timer(evt); });
|
||||
|
||||
m_canvases.insert(CanvasesMap::value_type(canvas, canvas3D));
|
||||
|
||||
|
@ -481,6 +483,19 @@ unsigned int GLCanvas3DManager::get_layers_editing_z_texture_id(wxGLCanvas* canv
|
|||
return (it != m_canvases.end()) ? it->second->get_layers_editing_z_texture_id() : 0;
|
||||
}
|
||||
|
||||
unsigned int GLCanvas3DManager::get_layers_editing_state(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
return (it != m_canvases.end()) ? it->second->get_layers_editing_state() : 0;
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::set_layers_editing_state(wxGLCanvas* canvas, unsigned int state)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->set_layers_editing_state(state);
|
||||
}
|
||||
|
||||
float GLCanvas3DManager::get_layers_editing_band_width(wxGLCanvas* canvas) const
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
|
@ -649,6 +664,27 @@ void GLCanvas3DManager::render_texture(wxGLCanvas* canvas, unsigned int tex_id,
|
|||
it->second->render_texture(tex_id, left, right, bottom, top);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::start_timer(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->start_timer();
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::stop_timer(wxGLCanvas* canvas)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->stop_timer();
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::perform_layer_editing_action(wxGLCanvas* canvas, int y, bool shift_down, bool right_down)
|
||||
{
|
||||
CanvasesMap::const_iterator it = _get_canvas(canvas);
|
||||
if (it != m_canvases.end())
|
||||
it->second->perform_layer_editing_action(y, shift_down, right_down);
|
||||
}
|
||||
|
||||
void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback)
|
||||
{
|
||||
CanvasesMap::iterator it = _get_canvas(canvas);
|
||||
|
|
|
@ -119,6 +119,9 @@ public:
|
|||
|
||||
unsigned int get_layers_editing_z_texture_id(wxGLCanvas* canvas) const;
|
||||
|
||||
unsigned int get_layers_editing_state(wxGLCanvas* canvas) const;
|
||||
void set_layers_editing_state(wxGLCanvas* canvas, unsigned int state);
|
||||
|
||||
float get_layers_editing_band_width(wxGLCanvas* canvas) const;
|
||||
void set_layers_editing_band_width(wxGLCanvas* canvas, float band_width);
|
||||
|
||||
|
@ -155,6 +158,10 @@ public:
|
|||
void render_volumes(wxGLCanvas* canvas, bool fake_colors) const;
|
||||
void render_texture(wxGLCanvas* canvas, unsigned int tex_id, float left, float right, float bottom, float top) const;
|
||||
|
||||
void start_timer(wxGLCanvas* canvas);
|
||||
void stop_timer(wxGLCanvas* canvas);
|
||||
void perform_layer_editing_action(wxGLCanvas* canvas, int y, bool shift_down, bool right_down);
|
||||
|
||||
void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback);
|
||||
|
||||
private:
|
||||
|
|
|
@ -578,6 +578,21 @@ get_layers_editing_z_texture_id(canvas)
|
|||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
unsigned int
|
||||
get_layers_editing_state(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
RETVAL = _3DScene::get_layers_editing_state((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
set_layers_editing_state(canvas, state)
|
||||
SV *canvas;
|
||||
unsigned int state;
|
||||
CODE:
|
||||
_3DScene::set_layers_editing_state((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), state);
|
||||
|
||||
float
|
||||
get_layers_editing_band_width(canvas)
|
||||
SV *canvas;
|
||||
|
@ -768,6 +783,27 @@ render_texture(canvas, tex_id, left, right, bottom, top)
|
|||
CODE:
|
||||
_3DScene::render_texture((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), tex_id, left, right, bottom, top);
|
||||
|
||||
void
|
||||
start_timer(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
_3DScene::start_timer((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
|
||||
void
|
||||
stop_timer(canvas)
|
||||
SV *canvas;
|
||||
CODE:
|
||||
_3DScene::stop_timer((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"));
|
||||
|
||||
void
|
||||
perform_layer_editing_action(canvas, y, shift_down, right_down)
|
||||
SV *canvas;
|
||||
int y;
|
||||
bool shift_down;
|
||||
bool right_down;
|
||||
CODE:
|
||||
_3DScene::perform_layer_editing_action((wxGLCanvas*)wxPli_sv_2_object(aTHX_ canvas, "Wx::GLCanvas"), y, shift_down, right_down);
|
||||
|
||||
void
|
||||
register_on_viewport_changed_callback(canvas, callback)
|
||||
SV *canvas;
|
||||
|
|
|
@ -122,14 +122,16 @@ _constant()
|
|||
RETVAL.push_back(slicing_params.layer_height);
|
||||
%};
|
||||
|
||||
void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action)
|
||||
%code%{
|
||||
THIS->update_layer_height_profile(THIS->model_object()->layer_height_profile);
|
||||
adjust_layer_height_profile(
|
||||
THIS->slicing_parameters(), THIS->model_object()->layer_height_profile, z, layer_thickness_delta, band_width, LayerHeightEditActionType(action));
|
||||
THIS->model_object()->layer_height_profile_valid = true;
|
||||
THIS->layer_height_profile_valid = false;
|
||||
%};
|
||||
//###################################################################################################################################################################
|
||||
// void adjust_layer_height_profile(coordf_t z, coordf_t layer_thickness_delta, coordf_t band_width, int action)
|
||||
// %code%{
|
||||
// THIS->update_layer_height_profile(THIS->model_object()->layer_height_profile);
|
||||
// adjust_layer_height_profile(
|
||||
// THIS->slicing_parameters(), THIS->model_object()->layer_height_profile, z, layer_thickness_delta, band_width, LayerHeightEditActionType(action));
|
||||
// THIS->model_object()->layer_height_profile_valid = true;
|
||||
// THIS->layer_height_profile_valid = false;
|
||||
// %};
|
||||
//###################################################################################################################################################################
|
||||
|
||||
void reset_layer_height_profile();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue