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
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2019-06-24 16:27:43 +0300
committerbubnikv <bubnikv@gmail.com>2019-06-24 16:27:43 +0300
commit5320ed9374d4559ac0fcc5a299bd79018ed9a1cb (patch)
treea130db0c7adfed8b5cf2ce63645387da36cf5927 /src/slic3r/GUI/Camera.hpp
parent198600543dd707a51f29660c2583459ae2b34933 (diff)
parente737f15bfa68236d184dfba5861a3389fb903986 (diff)
Merge branch 'master' of https://github.com/Prusa3d/PrusaSlicer
Diffstat (limited to 'src/slic3r/GUI/Camera.hpp')
-rw-r--r--src/slic3r/GUI/Camera.hpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp
index 1c75ef4b6..bd2541ce2 100644
--- a/src/slic3r/GUI/Camera.hpp
+++ b/src/slic3r/GUI/Camera.hpp
@@ -9,44 +9,64 @@ namespace GUI {
struct Camera
{
+ static const double DefaultDistance;
+ static double FrustrumMinZSize;
+ static double FrustrumZMargin;
+ static double FovMinDeg;
+ static double FovMaxDeg;
+
enum EType : unsigned char
{
Unknown,
-// Perspective,
Ortho,
+ Perspective,
Num_types
};
- EType type;
- float zoom;
float phi;
-// float distance;
bool requires_zoom_to_bed;
bool inverted_phi;
private:
+ EType m_type;
Vec3d m_target;
float m_theta;
+ double m_zoom;
+ // Distance between camera position and camera target measured along the camera Z axis
+ mutable double m_distance;
+ mutable double m_gui_scale;
mutable std::array<int, 4> m_viewport;
mutable Transform3d m_view_matrix;
mutable Transform3d m_projection_matrix;
+ mutable std::pair<double, double> m_frustrum_zs;
BoundingBoxf3 m_scene_box;
public:
Camera();
+ EType get_type() const { return m_type; }
std::string get_type_as_string() const;
+ void set_type(EType type);
+ void set_type(const std::string& type);
+ void select_next_type();
const Vec3d& get_target() const { return m_target; }
void set_target(const Vec3d& target);
+ double get_distance() const { return m_distance; }
+ double get_gui_scale() const { return m_gui_scale; }
+
float get_theta() const { return m_theta; }
void set_theta(float theta, bool apply_limit);
+ double get_zoom() const { return m_zoom; }
+ void set_zoom(double zoom, const BoundingBoxf3& max_box, int canvas_w, int canvas_h);
+ void set_zoom(double zoom) { m_zoom = zoom; }
+
const BoundingBoxf3& get_scene_box() const { return m_scene_box; }
- void set_scene_box(const BoundingBoxf3& box);
+ void set_scene_box(const BoundingBoxf3& box) { m_scene_box = box; }
bool select_view(const std::string& direction);
@@ -60,9 +80,26 @@ public:
Vec3d get_position() const { return m_view_matrix.matrix().inverse().block(0, 3, 3, 1); }
+ double get_near_z() const { return m_frustrum_zs.first; }
+ double get_far_z() const { return m_frustrum_zs.second; }
+
+ double get_fov() const;
+
void apply_viewport(int x, int y, unsigned int w, unsigned int h) const;
void apply_view_matrix() const;
- void apply_ortho_projection(float x_min, float x_max, float y_min, float y_max, float z_min, float z_max) const;
+ void apply_projection(const BoundingBoxf3& box) const;
+
+ void zoom_to_box(const BoundingBoxf3& box, int canvas_w, int canvas_h);
+
+#if ENABLE_CAMERA_STATISTICS
+ void debug_render() const;
+#endif // ENABLE_CAMERA_STATISTICS
+
+private:
+ // returns tight values for nearZ and farZ plane around the given bounding box
+ // the camera MUST be outside of the bounding box in eye coordinate of the given box
+ std::pair<double, double> calc_tight_frustrum_zs_around(const BoundingBoxf3& box) const;
+ double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int canvas_w, int canvas_h) const;
};
} // GUI