PrusaSlicer-NonPlainar/xs/src/slic3r/GUI/GLGizmo.hpp

116 lines
2.7 KiB
C++
Raw Normal View History

2018-06-13 07:12:16 +00:00
#ifndef slic3r_GLGizmo_hpp_
#define slic3r_GLGizmo_hpp_
#include "../../slic3r/GUI/GLTexture.hpp"
namespace Slic3r {
2018-06-13 13:44:04 +00:00
class BoundingBoxf3;
class Pointf3;
2018-06-13 07:12:16 +00:00
namespace GUI {
class GLGizmoBase
{
2018-06-14 08:00:59 +00:00
protected:
static const float BaseColor[3];
static const float HighlightColor[3];
static const float GrabberHalfSize;
2018-06-14 13:32:26 +00:00
static const float HoverOffset;
2018-06-14 08:00:59 +00:00
2018-06-13 07:12:16 +00:00
public:
enum EState
{
Off,
Hover,
On,
Num_States
};
protected:
EState m_state;
2018-06-13 08:49:59 +00:00
// textures are assumed to be square and all with the same size in pixels
2018-06-13 07:12:16 +00:00
// no internal check is done
GLTexture m_textures[Num_States];
2018-06-14 13:32:26 +00:00
int m_hover_id;
2018-06-13 07:12:16 +00:00
public:
GLGizmoBase();
virtual ~GLGizmoBase();
bool init();
EState get_state() const;
2018-06-13 08:49:59 +00:00
void set_state(EState state);
2018-06-13 07:12:16 +00:00
unsigned int get_textures_id() const;
2018-06-13 08:49:59 +00:00
int get_textures_size() const;
2018-06-13 07:12:16 +00:00
2018-06-14 13:32:26 +00:00
void set_hover_id(int id);
2018-06-13 13:44:04 +00:00
void render(const BoundingBoxf3& box) const;
2018-06-14 13:32:26 +00:00
void render_for_picking(const BoundingBoxf3& box) const;
2018-06-13 07:12:16 +00:00
protected:
virtual bool on_init() = 0;
2018-06-13 13:44:04 +00:00
virtual void on_render(const BoundingBoxf3& box) const = 0;
2018-06-14 13:32:26 +00:00
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
2018-06-14 08:00:59 +00:00
2018-06-14 13:32:26 +00:00
void render_grabber(const Pointf3& center, bool hover) const;
2018-06-13 07:12:16 +00:00
};
class GLGizmoRotate : public GLGizmoBase
{
2018-06-14 08:00:59 +00:00
static const float Offset;
static const unsigned int CircleResolution;
static const unsigned int ScaleStepsCount;
static const float ScaleStepRad;
static const unsigned int ScaleLongEvery;
static const float ScaleLongTooth;
static const float ScaleShortTooth;
static const unsigned int SnapRegionsCount;
static const float GrabberOffset;
2018-06-13 07:12:16 +00:00
float m_angle_x;
float m_angle_y;
float m_angle_z;
public:
GLGizmoRotate();
protected:
virtual bool on_init();
2018-06-13 13:44:04 +00:00
virtual void on_render(const BoundingBoxf3& box) const;
2018-06-14 13:32:26 +00:00
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
2018-06-14 08:00:59 +00:00
private:
void _render_circle(const Pointf3& center, float radius) const;
void _render_scale(const Pointf3& center, float radius) const;
void _render_snap_radii(const Pointf3& center, float radius) const;
void _render_reference_radius(const Pointf3& center, float radius) const;
void _render_grabber(const Pointf3& center, float radius) const;
2018-06-13 07:12:16 +00:00
};
class GLGizmoScale : public GLGizmoBase
{
2018-06-13 13:44:04 +00:00
static const float Offset;
2018-06-13 07:12:16 +00:00
float m_scale_x;
float m_scale_y;
float m_scale_z;
public:
GLGizmoScale();
protected:
virtual bool on_init();
2018-06-13 13:44:04 +00:00
virtual void on_render(const BoundingBoxf3& box) const;
2018-06-14 13:32:26 +00:00
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
2018-06-13 07:12:16 +00:00
};
} // namespace GUI
} // namespace Slic3r
#endif // slic3r_GLGizmo_hpp_