mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-24 23:23:59 -06:00
Refactoring and cleanup
This commit is contained in:
parent
2bccb43122
commit
364134515b
9 changed files with 371 additions and 2101 deletions
|
@ -81,46 +81,32 @@ public:
|
|||
class GLCanvas3D
|
||||
{
|
||||
public:
|
||||
class Camera
|
||||
struct Camera
|
||||
{
|
||||
public:
|
||||
enum EType : unsigned char
|
||||
{
|
||||
CT_Unknown,
|
||||
CT_Perspective,
|
||||
CT_Ortho,
|
||||
CT_Count
|
||||
Unknown,
|
||||
Perspective,
|
||||
Ortho,
|
||||
Num_types
|
||||
};
|
||||
|
||||
EType type;
|
||||
float zoom;
|
||||
float phi;
|
||||
float distance;
|
||||
Pointf3 target;
|
||||
|
||||
private:
|
||||
EType m_type;
|
||||
float m_zoom;
|
||||
float m_phi;
|
||||
float m_theta;
|
||||
float m_distance;
|
||||
Pointf3 m_target;
|
||||
|
||||
public:
|
||||
Camera();
|
||||
|
||||
Camera::EType get_type() const;
|
||||
void set_type(Camera::EType type);
|
||||
std::string get_type_as_string() const;
|
||||
|
||||
float get_zoom() const;
|
||||
void set_zoom(float zoom);
|
||||
|
||||
float get_phi() const;
|
||||
void set_phi(float phi);
|
||||
|
||||
float get_theta() const;
|
||||
void set_theta(float theta);
|
||||
|
||||
float get_distance() const;
|
||||
void set_distance(float distance);
|
||||
|
||||
const Pointf3& get_target() const;
|
||||
void set_target(const Pointf3& target);
|
||||
};
|
||||
|
||||
class Bed
|
||||
|
@ -147,20 +133,13 @@ public:
|
|||
void _calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
||||
};
|
||||
|
||||
class Axes
|
||||
struct Axes
|
||||
{
|
||||
Pointf3 m_origin;
|
||||
float m_length;
|
||||
Pointf3 origin;
|
||||
float length;
|
||||
|
||||
public:
|
||||
Axes();
|
||||
|
||||
const Pointf3& get_origin() const;
|
||||
void set_origin(const Pointf3& origin);
|
||||
|
||||
float get_length() const;
|
||||
void set_length(float length);
|
||||
|
||||
void render() const;
|
||||
};
|
||||
|
||||
|
@ -226,28 +205,26 @@ public:
|
|||
GLTextureData(unsigned int id, int width, int height);
|
||||
};
|
||||
|
||||
EState m_state;
|
||||
bool m_use_legacy_opengl;
|
||||
bool m_enabled;
|
||||
Shader m_shader;
|
||||
unsigned int m_z_texture_id;
|
||||
mutable GLTextureData m_tooltip_texture;
|
||||
mutable GLTextureData m_reset_texture;
|
||||
float m_band_width;
|
||||
float m_strength;
|
||||
int m_last_object_id;
|
||||
float m_last_z;
|
||||
unsigned int m_last_action;
|
||||
|
||||
public:
|
||||
EState state;
|
||||
float band_width;
|
||||
float strength;
|
||||
int last_object_id;
|
||||
float last_z;
|
||||
unsigned int last_action;
|
||||
|
||||
LayersEditing();
|
||||
~LayersEditing();
|
||||
|
||||
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);
|
||||
|
||||
|
@ -256,24 +233,9 @@ public:
|
|||
|
||||
unsigned int get_z_texture_id() const;
|
||||
|
||||
float get_band_width() const;
|
||||
void set_band_width(float band_width);
|
||||
|
||||
float get_strength() const;
|
||||
void set_strength(float strength);
|
||||
|
||||
int get_last_object_id() const;
|
||||
void set_last_object_id(int id);
|
||||
|
||||
float get_last_z() const;
|
||||
void set_last_z(float z);
|
||||
|
||||
unsigned int get_last_action() const;
|
||||
void set_last_action(unsigned int action);
|
||||
|
||||
void render(const GLCanvas3D& canvas, const PrintObject& print_object, const GLVolume& volume) const;
|
||||
|
||||
const GLShader* get_shader() const;
|
||||
int get_shader_program_id() const;
|
||||
|
||||
static float get_cursor_z_relative(const GLCanvas3D& canvas);
|
||||
static int get_first_selected_object_id(const GLVolumeCollection& volumes, unsigned int objects_count);
|
||||
|
@ -293,45 +255,33 @@ public:
|
|||
static GLTextureData _load_texture_from_file(const std::string& filename);
|
||||
};
|
||||
|
||||
class Mouse
|
||||
struct Mouse
|
||||
{
|
||||
bool m_dragging;
|
||||
Pointf m_position;
|
||||
struct Drag
|
||||
{
|
||||
static const Point Invalid_2D_Point;
|
||||
static const Pointf3 Invalid_3D_Point;
|
||||
|
||||
Point start_position_2D;
|
||||
Pointf3 start_position_3D;
|
||||
Vectorf3 volume_center_offset;
|
||||
int volume_idx;
|
||||
|
||||
public:
|
||||
Drag();
|
||||
};
|
||||
|
||||
bool dragging;
|
||||
Pointf position;
|
||||
Drag drag;
|
||||
|
||||
public:
|
||||
Mouse();
|
||||
|
||||
bool is_dragging() const;
|
||||
void set_dragging(bool dragging);
|
||||
|
||||
const Pointf& get_position() const;
|
||||
void set_position(const Pointf& position);
|
||||
};
|
||||
|
||||
class Drag
|
||||
{
|
||||
Point m_start_position_2D;
|
||||
Pointf3 m_start_position_3D;
|
||||
Vectorf3 m_volume_center_offset;
|
||||
int m_volume_idx;
|
||||
|
||||
public:
|
||||
Drag();
|
||||
|
||||
const Point& get_start_position_2D() const;
|
||||
void set_start_position_2D(const Point& position);
|
||||
|
||||
const Pointf3& get_start_position_3D() const;
|
||||
void set_start_position_3D(const Pointf3& position);
|
||||
void set_start_position_2D_as_invalid();
|
||||
void set_start_position_3D_as_invalid();
|
||||
|
||||
bool is_start_position_2D_defined() const;
|
||||
bool is_start_position_3D_defined() const;
|
||||
|
||||
const Vectorf3& get_volume_center_offset() const;
|
||||
void set_volume_center_offset(const Vectorf3& offset);
|
||||
|
||||
int get_volume_idx() const;
|
||||
void set_volume_idx(int idx);
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -345,7 +295,6 @@ private:
|
|||
LayersEditing m_layers_editing;
|
||||
Shader m_shader;
|
||||
Mouse m_mouse;
|
||||
Drag m_drag;
|
||||
|
||||
GLVolumeCollection* m_volumes;
|
||||
DynamicPrintConfig* m_config;
|
||||
|
@ -376,14 +325,8 @@ public:
|
|||
|
||||
bool set_current();
|
||||
|
||||
bool is_dirty() const;
|
||||
void set_dirty(bool dirty);
|
||||
|
||||
bool is_shown_on_screen() const;
|
||||
|
||||
void resize(unsigned int w, unsigned int h);
|
||||
|
||||
GLVolumeCollection* get_volumes();
|
||||
void set_volumes(GLVolumeCollection* volumes);
|
||||
void reset_volumes();
|
||||
void deselect_volumes();
|
||||
|
@ -400,42 +343,16 @@ public:
|
|||
// Used by ObjectCutDialog and ObjectPartsPanel to generate a rectangular ground plane to support the scene objects.
|
||||
void set_auto_bed_shape();
|
||||
|
||||
const Pointf3& get_axes_origin() const;
|
||||
void set_axes_origin(const Pointf3& origin);
|
||||
|
||||
float get_axes_length() const;
|
||||
void set_axes_length(float length);
|
||||
|
||||
void set_cutting_plane(float z, const ExPolygons& polygons);
|
||||
|
||||
Camera::EType get_camera_type() const;
|
||||
void set_camera_type(Camera::EType type);
|
||||
std::string get_camera_type_as_string() const;
|
||||
|
||||
|
||||
float get_camera_zoom() const;
|
||||
void set_camera_zoom(float zoom);
|
||||
|
||||
float get_camera_phi() const;
|
||||
void set_camera_phi(float phi);
|
||||
|
||||
float get_camera_theta() const;
|
||||
void set_camera_theta(float theta);
|
||||
|
||||
float get_camera_distance() const;
|
||||
void set_camera_distance(float distance);
|
||||
|
||||
const Pointf3& get_camera_target() const;
|
||||
void set_camera_target(const Pointf3& target);
|
||||
|
||||
BoundingBoxf3 bed_bounding_box() const;
|
||||
BoundingBoxf3 volumes_bounding_box() const;
|
||||
BoundingBoxf3 max_bounding_box() const;
|
||||
|
||||
bool is_layers_editing_enabled() const;
|
||||
bool is_picking_enabled() const;
|
||||
bool is_moving_enabled() const;
|
||||
bool is_layers_editing_allowed() const;
|
||||
bool is_multisample_allowed() const;
|
||||
|
||||
void enable_layers_editing(bool enable);
|
||||
void enable_warning_texture(bool enable);
|
||||
|
@ -445,42 +362,6 @@ public:
|
|||
void enable_shader(bool enable);
|
||||
void allow_multisample(bool allow);
|
||||
|
||||
bool is_mouse_dragging() const;
|
||||
void set_mouse_dragging(bool dragging);
|
||||
|
||||
const Pointf& get_mouse_position() const;
|
||||
void set_mouse_position(const Pointf& position);
|
||||
|
||||
int get_hover_volume_id() const;
|
||||
void set_hover_volume_id(int id);
|
||||
|
||||
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);
|
||||
|
||||
float get_layers_editing_strength() const;
|
||||
void set_layers_editing_strength(float strength);
|
||||
|
||||
int get_layers_editing_last_object_id() const;
|
||||
void set_layers_editing_last_object_id(int id);
|
||||
|
||||
float get_layers_editing_last_z() const;
|
||||
void set_layers_editing_last_z(float z);
|
||||
|
||||
unsigned int get_layers_editing_last_action() const;
|
||||
void set_layers_editing_last_action(unsigned int action);
|
||||
|
||||
const GLShader* get_layers_editing_shader() const;
|
||||
|
||||
float get_layers_editing_cursor_z_relative() const;
|
||||
int get_layers_editing_first_selected_object_id(unsigned int objects_count) const;
|
||||
bool bar_rect_contains(float x, float y) const;
|
||||
bool reset_rect_contains(float x, float y) const;
|
||||
|
||||
void zoom_to_bed();
|
||||
void zoom_to_volumes();
|
||||
void select_view(const std::string& direction);
|
||||
|
@ -488,11 +369,7 @@ public:
|
|||
|
||||
void update_volumes_colors_by_extruder();
|
||||
|
||||
bool start_using_shader() const;
|
||||
void stop_using_shader() const;
|
||||
|
||||
void render(bool useVBOs) const;
|
||||
void render_volumes(bool fake_colors) const;
|
||||
void render_texture(unsigned int tex_id, float left, float right, float bottom, float top) const;
|
||||
|
||||
void register_on_viewport_changed_callback(void* callback);
|
||||
|
@ -512,11 +389,11 @@ public:
|
|||
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 _resize(unsigned int w, unsigned int h);
|
||||
|
||||
BoundingBoxf3 _max_bounding_box() const;
|
||||
|
||||
void _zoom_to_bounding_box(const BoundingBoxf3& bbox);
|
||||
float _get_zoom_to_bounding_box_factor(const BoundingBoxf3& bbox) const;
|
||||
|
||||
|
@ -535,12 +412,21 @@ private:
|
|||
void _render_warning_texture() const;
|
||||
void _render_legend_texture() const;
|
||||
void _render_layer_editing_overlay() const;
|
||||
void _render_volumes(bool fake_colors) const;
|
||||
|
||||
float _get_layers_editing_cursor_z_relative() const;
|
||||
int _get_layers_editing_first_selected_object_id(unsigned int objects_count) const;
|
||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||
|
||||
bool _bar_rect_contains(float x, float y) const;
|
||||
bool _reset_rect_contains(float x, float y) const;
|
||||
|
||||
// Convert the screen space coordinate to an object space coordinate.
|
||||
// If the Z screen space coordinate is not provided, a depth buffer value is substituted.
|
||||
Pointf3 _mouse_to_3d(const Point& mouse_pos, float* z = nullptr);
|
||||
|
||||
void _start_timer();
|
||||
void _stop_timer();
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue