OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::Camera Struct Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Camera.hpp>

Collaboration diagram for Slic3r::GUI::Camera:

Public Types

enum class  EType : unsigned char { Unknown , Ortho , Perspective , Num_types }
enum class  ViewAngleType : unsigned char {
  Iso = 0 , Top_Front , Left , Right ,
  Top , Bottom , Front , Rear ,
  Count_ViewAngleType , Top_Plate
}

Public Member Functions

 Camera ()
EType get_type () const
std::string get_type_as_string () const
void set_type (EType type)
void set_type (const std::string &type)
void select_next_type ()
void auto_type (EType preferred_type)
void enable_update_config_on_type_change (bool enable)
void translate (const Vec3d &displacement)
const Vec3d & get_target ()
void set_target (const Vec3d &target)
double get_distance ()
double get_gui_scale () const
float get_zenit () const
double get_zoom () const
double get_inv_zoom () const
void update_zoom (double delta_zoom)
void set_zoom (double zoom)
const BoundingBoxf3 & get_scene_box () const
void set_scene_box (const BoundingBoxf3 &box)
void select_view (const std::string &direction)
void select_view (ViewAngleType type)
const std::array< int, 4 > & get_viewport () const
const Transform3d & get_view_matrix () const
const Transform3d & get_projection_matrix () const
const Eigen::Quaterniond & get_view_rotation () const
Vec3d get_dir_right () const
Vec3d get_dir_up () const
Vec3d get_dir_forward () const
Vec3d get_position () const
double get_near_z () const
double get_far_z () const
const std::pair< double, double > & get_z_range () const
double get_near_left () const
double get_near_right () const
double get_near_top () const
double get_near_bottom () const
double get_near_width () const
double get_near_height () const
double get_fov () const
void set_viewport (int x, int y, unsigned int w, unsigned int h)
void apply_viewport () const
void apply_projection (const BoundingBoxf3 &box, double near_z=-1.0, double far_z=-1.0)
void apply_projection (double left, double right, double bottom, double top, double near_z, double far_z)
void zoom_to_box (const BoundingBoxf3 &box, double margin_factor=DefaultZoomToBoxMarginFactor)
void zoom_to_volumes (const GLVolumePtrs &volumes, double margin_factor=DefaultZoomToVolumesMarginFactor)
void translate_world (const Vec3d &displacement)
void rotate_on_sphere_with_target (double delta_azimut_rad, double delta_zenit_rad, bool apply_limits, Vec3d target)
void rotate_local_with_target (const Vec3d &rotation_rad, Vec3d target)
void rotate_on_sphere (double delta_azimut_rad, double delta_zenit_rad, bool apply_limits)
void rotate_local_around_target (const Vec3d &rotation_rad)
void set_rotation (const Transform3d &rotation)
bool is_looking_downward () const
bool is_looking_front () const
void recover_from_free_camera ()
void load_camera_view (Camera &cam)
void look_at (const Vec3d &position, const Vec3d &target, const Vec3d &up)
double max_zoom () const
double min_zoom () const

Public Attributes

bool requires_zoom_to_bed { false }
bool requires_zoom_to_volumes { false }
int requires_zoom_to_plate { REQUIRES_ZOOM_TO_PLATE_IDLE }

Static Public Attributes

static const double DefaultDistance = 1000.0
static const double DefaultZoomToBoxMarginFactor = 1.025
static const double DefaultZoomToVolumesMarginFactor = 1.025
static double FrustrumMinZRange = 50.0
static double FrustrumMinNearZ = 100.0
static double FrustrumZMargin = 10.0
static double MaxFovDeg = 60.0
static double ZoomUnit = 0.1

Private Member Functions

std::pair< double, double > calc_tight_frustrum_zs_around (const BoundingBoxf3 &box)
double calc_zoom_to_bounding_box_factor (const BoundingBoxf3 &box, double margin_factor=DefaultZoomToBoxMarginFactor) const
double calc_zoom_to_volumes_factor (const GLVolumePtrs &volumes, Vec3d &center, double margin_factor=DefaultZoomToVolumesMarginFactor) const
void set_distance (double distance)
void set_default_orientation ()
Vec3d validate_target (const Vec3d &target) const
void update_zenit ()
void update_target ()

Private Attributes

bool m_prevent_auto_type = true
EType m_type { EType::Perspective }
bool m_update_config_on_type_change_enabled { false }
Vec3d m_target { Vec3d::Zero() }
float m_zenit { 45.0f }
double m_zoom { 1.0 }
double m_distance { DefaultDistance }
double m_gui_scale { 1.0 }
std::array< int, 4 > m_viewport
Transform3d m_view_matrix { Transform3d::Identity() }
Eigen::Quaterniond m_view_rotation { 1.0, 0.0, 0.0, 0.0 }
Transform3d m_projection_matrix { Transform3d::Identity() }
std::pair< double, double > m_frustrum_zs
BoundingBoxf3 m_scene_box

Detailed Description

Member Enumeration Documentation

◆ EType

enum class Slic3r::GUI::Camera::EType : unsigned char
strong
Enumerator
Unknown 
Ortho 
Perspective 
Num_types 
37 {
38 Unknown,
39 Ortho,
40 Perspective,
41 Num_types
42 };
@ Unknown
Definition PresetBundle.hpp:42

◆ ViewAngleType

enum class Slic3r::GUI::Camera::ViewAngleType : unsigned char
strong
Enumerator
Iso 
Top_Front 
Left 
Right 
Top 
Bottom 
Front 
Rear 
Count_ViewAngleType 
Top_Plate 
43 : unsigned char {
44 Iso = 0,
45 Top_Front,
46 Left,
47 Right,
48 Top,
49 Bottom,
50 Front,
51 Rear,
52 Count_ViewAngleType,
53 Top_Plate,//for 3mf and Skip parts
54 };
@ Right
Definition GLToolbar.hpp:462
@ Left
Definition GLToolbar.hpp:462
@ Bottom
Definition GeometryEngine.hpp:16
@ Top
Definition GeometryEngine.hpp:16

Constructor & Destructor Documentation

◆ Camera()

Slic3r::GUI::Camera::Camera ( )
inline
void set_default_orientation()
Definition Camera.cpp:739

References set_default_orientation().

Referenced by load_camera_view().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ apply_projection() [1/2]

void Slic3r::GUI::Camera::apply_projection ( const BoundingBoxf3 & box,
double near_z = -1.0,
double far_z = -1.0 )
293{
294 double w = 0.0;
295 double h = 0.0;
296
298
299 if (near_z > 0.0)
300 m_frustrum_zs.first = std::max(std::min(m_frustrum_zs.first, near_z), FrustrumMinNearZ);
301
302 if (far_z > 0.0)
303 m_frustrum_zs.second = std::max(m_frustrum_zs.second, far_z);
304
305 w = 0.5 * (double)m_viewport[2];
306 h = 0.5 * (double)m_viewport[3];
307
308 const double inv_zoom = get_inv_zoom();
309 w *= inv_zoom;
310 h *= inv_zoom;
311
312 switch (m_type)
313 {
314 default:
315 case EType::Ortho:
316 {
317 m_gui_scale = 1.0;
318 break;
319 }
321 {
322 // scale near plane to keep w and h constant on the plane at z = m_distance
323 const double scale = m_frustrum_zs.first / m_distance;
324 w *= scale;
325 h *= scale;
327 break;
328 }
329 }
330
331 apply_projection(-w, w, -h, h, m_frustrum_zs.first, m_frustrum_zs.second);
332}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
double m_distance
Definition Camera.hpp:68
std::array< int, 4 > m_viewport
Definition Camera.hpp:71
EType m_type
Definition Camera.hpp:62
@ Ortho
Definition Camera.hpp:39
@ Perspective
Definition Camera.hpp:40
void apply_projection(const BoundingBoxf3 &box, double near_z=-1.0, double far_z=-1.0)
Definition Camera.cpp:292
std::pair< double, double > calc_tight_frustrum_zs_around(const BoundingBoxf3 &box)
Definition Camera.cpp:520
double m_gui_scale
Definition Camera.hpp:69
double get_inv_zoom() const
Definition Camera.hpp:104
std::pair< double, double > m_frustrum_zs
Definition Camera.hpp:76
static double FrustrumMinNearZ
Definition Camera.hpp:31

References apply_projection(), calc_tight_frustrum_zs_around(), FrustrumMinNearZ, get_inv_zoom(), m_distance, m_frustrum_zs, m_gui_scale, m_type, m_viewport, Ortho, Perspective, and scale().

Referenced by Slic3r::GUI::GLCanvas3D::_rectangular_selection_picking_pass(), and apply_projection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_projection() [2/2]

void Slic3r::GUI::Camera::apply_projection ( double left,
double right,
double bottom,
double top,
double near_z,
double far_z )
335{
336 assert(left != right && bottom != top && near_z != far_z);
337 const double inv_dx = 1.0 / (right - left);
338 const double inv_dy = 1.0 / (top - bottom);
339 const double inv_dz = 1.0 / (far_z - near_z);
340
341 switch (m_type)
342 {
343 default:
344 case EType::Ortho:
345 {
346 m_projection_matrix.matrix() << 2.0 * inv_dx, 0.0, 0.0, -(left + right) * inv_dx,
347 0.0, 2.0 * inv_dy, 0.0, -(bottom + top) * inv_dy,
348 0.0, 0.0, -2.0 * inv_dz, -(near_z + far_z) * inv_dz,
349 0.0, 0.0, 0.0, 1.0;
350 break;
351 }
353 {
354 m_projection_matrix.matrix() << 2.0 * near_z * inv_dx, 0.0, (left + right) * inv_dx, 0.0,
355 0.0, 2.0 * near_z * inv_dy, (bottom + top) * inv_dy, 0.0,
356 0.0, 0.0, -(near_z + far_z) * inv_dz, -2.0 * near_z * far_z * inv_dz,
357 0.0, 0.0, -1.0, 0.0;
358 break;
359 }
360 }
361}
@ right
Definition MarchingSquares.hpp:190
@ left
Definition MarchingSquares.hpp:188
Transform3d m_projection_matrix
Definition Camera.hpp:75

References m_projection_matrix, m_type, Ortho, and Perspective.

◆ apply_viewport()

void Slic3r::GUI::Camera::apply_viewport ( ) const
288{
290}
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
#define glViewport
Definition gl.h:5333

References glsafe, glViewport, and m_viewport.

Referenced by Slic3r::GUI::GLCanvas3D::_rectangular_selection_picking_pass().

Here is the caller graph for this function:

◆ auto_type()

void Slic3r::GUI::Camera::auto_type ( EType preferred_type)
72{
73 if (wxApp::GetInstance() == nullptr || wxGetApp().app_config == nullptr)
74 return;
75 if (!wxGetApp().app_config->get_bool("auto_perspective"))
76 return;
77 if (preferred_type == EType::Perspective) {
79 set_type(preferred_type);
80 m_prevent_auto_type = false;
81 }
82 } else {
83 set_type(preferred_type);
84 m_prevent_auto_type = false;
85 }
86}
bool m_prevent_auto_type
Definition Camera.hpp:61
void set_type(EType type)
Definition Camera.cpp:51

References m_prevent_auto_type, Perspective, and set_type().

Referenced by Slic3r::GUI::Mouse3DController::State::apply(), Slic3r::GUI::select_iso_view(), and select_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_tight_frustrum_zs_around()

std::pair< double, double > Slic3r::GUI::Camera::calc_tight_frustrum_zs_around ( const BoundingBoxf3 & box)
private
521{
522 std::pair<double, double> ret;
523 auto& [near_z, far_z] = ret;
524
525 // box in eye space
526 const BoundingBoxf3 eye_box = box.transformed(m_view_matrix);
527 near_z = -eye_box.max.z();
528 far_z = -eye_box.min.z();
529
530 // apply margin
531 near_z -= FrustrumZMargin;
532 far_z += FrustrumZMargin;
533
534 // ensure min size
535 if (far_z - near_z < FrustrumMinZRange) {
536 const double mid_z = 0.5 * (near_z + far_z);
537 const double half_size = 0.5 * FrustrumMinZRange;
538 near_z = mid_z - half_size;
539 far_z = mid_z + half_size;
540 }
541
542 if (near_z < FrustrumMinNearZ) {
543 const double delta = FrustrumMinNearZ - near_z;
544 set_distance(m_distance + delta);
545 near_z += delta;
546 far_z += delta;
547 }
548// The following is commented out because it causes flickering of the 3D scene GUI
549// when the bounding box of the scene gets large enough
550// We need to introduce some smarter code to move the camera back and forth in such case
551// else if (near_z > 2.0 * FrustrumMinNearZ && m_distance > DefaultDistance) {
552// float delta = m_distance - DefaultDistance;
553// set_distance(DefaultDistance);
554// near_z -= delta;
555// far_z -= delta;
556// }
557
558 return ret;
559}
Transform3d m_view_matrix
Definition Camera.hpp:72
void set_distance(double distance)
Definition Camera.cpp:676
static double FrustrumMinZRange
Definition Camera.hpp:30
static double FrustrumZMargin
Definition Camera.hpp:32

References FrustrumMinNearZ, FrustrumMinZRange, FrustrumZMargin, m_distance, m_view_matrix, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, set_distance(), and Slic3r::BoundingBoxf3::transformed().

Referenced by apply_projection().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_zoom_to_bounding_box_factor()

double Slic3r::GUI::Camera::calc_zoom_to_bounding_box_factor ( const BoundingBoxf3 & box,
double margin_factor = DefaultZoomToBoxMarginFactor ) const
private
562{
563 const double max_bb_size = box.max_size();
564 if (max_bb_size == 0.0)
565 return -1.0;
566
567 // project the box vertices on a plane perpendicular to the camera forward axis
568 // then calculates the vertices coordinate on this plane along the camera xy axes
569
570 const Vec3d right = get_dir_right();
571 const Vec3d up = get_dir_up();
572 const Vec3d forward = get_dir_forward();
573 const Vec3d bb_center = box.center();
574
575 // box vertices in world space
576 const std::vector<Vec3d> vertices = {
577 box.min,
578 { box.max(0), box.min(1), box.min(2) },
579 { box.max(0), box.max(1), box.min(2) },
580 { box.min(0), box.max(1), box.min(2) },
581 { box.min(0), box.min(1), box.max(2) },
582 { box.max(0), box.min(1), box.max(2) },
583 box.max,
584 { box.min(0), box.max(1), box.max(2) }
585 };
586
587 double min_x = DBL_MAX;
588 double min_y = DBL_MAX;
589 double max_x = -DBL_MAX;
590 double max_y = -DBL_MAX;
591
592 for (const Vec3d& v : vertices) {
593 // project vertex on the plane perpendicular to camera forward axis
594 const Vec3d pos = v - bb_center;
595 const Vec3d proj_on_plane = pos - pos.dot(forward) * forward;
596
597 // calculates vertex coordinate along camera xy axes
598 const double x_on_plane = proj_on_plane.dot(right);
599 const double y_on_plane = proj_on_plane.dot(up);
600
601 min_x = std::min(min_x, x_on_plane);
602 min_y = std::min(min_y, y_on_plane);
603 max_x = std::max(max_x, x_on_plane);
604 max_y = std::max(max_y, y_on_plane);
605 }
606
607 double dx = max_x - min_x;
608 double dy = max_y - min_y;
609 if (dx <= 0.0 || dy <= 0.0)
610 return -1.0f;
611
612 dx *= margin_factor;
613 dy *= margin_factor;
614
615 return std::min((double)m_viewport[2] / dx, (double)m_viewport[3] / dy);
616}
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
@ up
Definition MarchingSquares.hpp:192
Vec3d get_dir_forward() const
Definition Camera.hpp:123
Vec3d get_dir_right() const
Definition Camera.hpp:121
Vec3d get_dir_up() const
Definition Camera.hpp:122

References Slic3r::BoundingBox3Base< PointType >::center(), get_dir_forward(), get_dir_right(), get_dir_up(), m_viewport, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBox3Base< PointType >::max_size(), and Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min.

Referenced by min_zoom(), and zoom_to_box().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_zoom_to_volumes_factor()

double Slic3r::GUI::Camera::calc_zoom_to_volumes_factor ( const GLVolumePtrs & volumes,
Vec3d & center,
double margin_factor = DefaultZoomToVolumesMarginFactor ) const
private
619{
620 if (volumes.empty())
621 return -1.0;
622
623 // project the volumes vertices on a plane perpendicular to the camera forward axis
624 // then calculates the vertices coordinate on this plane along the camera xy axes
625
626 const Vec3d right = get_dir_right();
627 const Vec3d up = get_dir_up();
628 const Vec3d forward = get_dir_forward();
629
630 BoundingBoxf3 box;
631 for (const GLVolume* volume : volumes) {
632 box.merge(volume->transformed_bounding_box());
633 }
634 center = box.center();
635
636 double min_x = DBL_MAX;
637 double min_y = DBL_MAX;
638 double max_x = -DBL_MAX;
639 double max_y = -DBL_MAX;
640
641 for (const GLVolume* volume : volumes) {
642 const Transform3d& transform = volume->world_matrix();
643 const TriangleMesh* hull = volume->convex_hull();
644 if (hull == nullptr)
645 continue;
646
647 for (const Vec3f& vertex : hull->its.vertices) {
648 const Vec3d v = transform * vertex.cast<double>();
649
650 // project vertex on the plane perpendicular to camera forward axis
651 const Vec3d pos = v - center;
652 const Vec3d proj_on_plane = pos - pos.dot(forward) * forward;
653
654 // calculates vertex coordinate along camera xy axes
655 const double x_on_plane = proj_on_plane.dot(right);
656 const double y_on_plane = proj_on_plane.dot(up);
657
658 min_x = std::min(min_x, x_on_plane);
659 min_y = std::min(min_y, y_on_plane);
660 max_x = std::max(max_x, x_on_plane);
661 max_y = std::max(max_y, y_on_plane);
662 }
663 }
664
665 center += 0.5 * (max_x + min_x) * right + 0.5 * (max_y + min_y) * up;
666
667 const double dx = margin_factor * (max_x - min_x);
668 const double dy = margin_factor * (max_y - min_y);
669
670 if (dx <= 0.0 || dy <= 0.0)
671 return -1.0f;
672
673 return std::min((double)m_viewport[2] / dx, (double)m_viewport[3] / dy);
674}
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
Linef3 transform(const Linef3 &line, const Transform3d &t)
Definition Line.cpp:15

References Slic3r::BoundingBox3Base< PointType >::center(), Slic3r::center(), Slic3r::TriangleMesh::convex_hull(), get_dir_forward(), get_dir_right(), get_dir_up(), Slic3r::TriangleMesh::its, m_viewport, Slic3r::BoundingBox3Base< PointType >::merge(), and Slic3r::transform().

Referenced by zoom_to_volumes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable_update_config_on_type_change()

void Slic3r::GUI::Camera::enable_update_config_on_type_change ( bool enable)
inline
bool m_update_config_on_type_change_enabled
Definition Camera.hpp:63

References m_update_config_on_type_change_enabled.

◆ get_dir_forward()

Vec3d Slic3r::GUI::Camera::get_dir_forward ( ) const
inline
123{ return -m_view_matrix.matrix().block(0, 0, 3, 3).row(2); }

References m_view_matrix.

Referenced by calc_zoom_to_bounding_box_factor(), calc_zoom_to_volumes_factor(), Slic3r::GUI::face_selected_volume_to_camera(), Slic3r::GUI::MeshRaycaster::get_unobscured_idxs(), Slic3r::GUI::SceneRaycaster::hit(), is_looking_downward(), Slic3r::GUI::GLGizmoCut3D::is_looking_forward(), Slic3r::GUI::pan_camera(), Slic3r::GUI::CameraUtils::ray_from_ortho_screen_pos(), Slic3r::GUI::GLGizmoCut3D::PartSelection::render(), Slic3r::GUI::DesignSketchTool::render_base_pick(), Slic3r::GUI::DesignSketchTool::render_body_edges(), Slic3r::GUI::DesignSketchTool::render_cut_gizmo(), Slic3r::GUI::DesignSketchTool::render_datum_gizmo(), Slic3r::GUI::DesignSketchTool::render_datum_planes(), Slic3r::GUI::DesignSketchTool::render_extrude_gizmo(), Slic3r::GUI::DesignSketchTool::render_face_outline(), Slic3r::GUI::DesignSketchTool::render_fillet_gizmo(), Slic3r::GUI::DesignSketchTool::render_helix_gizmo(), Slic3r::GUI::DesignSketchTool::render_hole_gizmo(), Slic3r::GUI::DesignSketchTool::render_mate_connectors(), Slic3r::GUI::DesignSketchTool::render_mate_face(), Slic3r::GUI::DesignSketchTool::render_move_gizmo(), Slic3r::GUI::DesignSketchTool::render_reference_axes(), Slic3r::GUI::DesignSketchTool::render_rib_gizmo(), Slic3r::GUI::DesignSketchTool::render_shell_gizmo(), Slic3r::GUI::DesignSketchTool::render_solid_sel(), Slic3r::GUI::DesignSketchTool::render_thread_gizmo(), Slic3r::GUI::DesignSketchTool::render_view_helpers(), Slic3r::GUI::GLGizmoTextureDisplacement::select_visible_faces(), set_distance(), update_target(), and update_zenit().

Here is the caller graph for this function:

◆ get_dir_right()

◆ get_dir_up()

◆ get_distance()

double Slic3r::GUI::Camera::get_distance ( )
inline
99{ return (get_position() - get_target()).norm(); }
const Vec3d & get_target()
Definition Camera.hpp:94
Vec3d get_position() const
Definition Camera.hpp:126

References get_position(), and get_target().

Referenced by Slic3r::GUI::select_iso_view(), and Slic3r::GUI::DesignCanvas::view_normal_to_sketch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_far_z()

double Slic3r::GUI::Camera::get_far_z ( ) const
inline
129{ return m_frustrum_zs.second; }

References m_frustrum_zs.

Referenced by Slic3r::GUI::GCodeViewer::render_shells().

Here is the caller graph for this function:

◆ get_fov()

double Slic3r::GUI::Camera::get_fov ( ) const
271{
272 switch (m_type)
273 {
275 return 2.0 * Geometry::rad2deg(std::atan(1.0 / m_projection_matrix.matrix()(1, 1)));
276 default:
277 case EType::Ortho:
278 return 0.0;
279 };
280}
T rad2deg(T angle)
Definition Geometry.hpp:310

References m_projection_matrix, m_type, Ortho, Perspective, and Slic3r::Geometry::rad2deg().

Here is the call graph for this function:

◆ get_gui_scale()

double Slic3r::GUI::Camera::get_gui_scale ( ) const
inline
100{ return m_gui_scale; }

References m_gui_scale.

◆ get_inv_zoom()

double Slic3r::GUI::Camera::get_inv_zoom ( ) const
inline
104{ assert(m_zoom != 0.0); return 1.0 / m_zoom; }
double m_zoom
Definition Camera.hpp:66

References m_zoom.

Referenced by apply_projection(), Slic3r::GUI::GLGizmoMeasure::on_render(), Slic3r::GUI::pan_camera(), Slic3r::GUI::GLGizmoMeasure::render_dimensioning(), and Slic3r::GUI::GCodeViewer::render_toolpaths().

Here is the caller graph for this function:

◆ get_near_bottom()

double Slic3r::GUI::Camera::get_near_bottom ( ) const
235{
236 switch (m_type)
237 {
239 return m_frustrum_zs.first * (m_projection_matrix.matrix()(1, 2) - 1.0) / m_projection_matrix.matrix()(1, 1);
240 default:
241 case EType::Ortho:
242 return -1.0 / m_projection_matrix.matrix()(1, 1) - 0.5 * m_projection_matrix.matrix()(1, 1) * m_projection_matrix.matrix()(1, 3);
243 }
244}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_height()

double Slic3r::GUI::Camera::get_near_height ( ) const
259{
260 switch (m_type)
261 {
263 return 2.0 * m_frustrum_zs.first / m_projection_matrix.matrix()(1, 1);
264 default:
265 case EType::Ortho:
266 return 2.0 / m_projection_matrix.matrix()(1, 1);
267 }
268}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_left()

double Slic3r::GUI::Camera::get_near_left ( ) const
199{
200 switch (m_type)
201 {
203 return m_frustrum_zs.first * (m_projection_matrix.matrix()(0, 2) - 1.0) / m_projection_matrix.matrix()(0, 0);
204 default:
205 case EType::Ortho:
206 return -1.0 / m_projection_matrix.matrix()(0, 0) - 0.5 * m_projection_matrix.matrix()(0, 0) * m_projection_matrix.matrix()(0, 3);
207 }
208}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_right()

double Slic3r::GUI::Camera::get_near_right ( ) const
211{
212 switch (m_type)
213 {
215 return m_frustrum_zs.first * (m_projection_matrix.matrix()(0, 2) + 1.0) / m_projection_matrix.matrix()(0, 0);
216 default:
217 case EType::Ortho:
218 return 1.0 / m_projection_matrix.matrix()(0, 0) - 0.5 * m_projection_matrix.matrix()(0, 0) * m_projection_matrix.matrix()(0, 3);
219 }
220}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_top()

double Slic3r::GUI::Camera::get_near_top ( ) const
223{
224 switch (m_type)
225 {
227 return m_frustrum_zs.first * (m_projection_matrix.matrix()(1, 2) + 1.0) / m_projection_matrix.matrix()(1, 1);
228 default:
229 case EType::Ortho:
230 return 1.0 / m_projection_matrix.matrix()(1, 1) - 0.5 * m_projection_matrix.matrix()(1, 1) * m_projection_matrix.matrix()(1, 3);
231 }
232}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_width()

double Slic3r::GUI::Camera::get_near_width ( ) const
247{
248 switch (m_type)
249 {
251 return 2.0 * m_frustrum_zs.first / m_projection_matrix.matrix()(0, 0);
252 default:
253 case EType::Ortho:
254 return 2.0 / m_projection_matrix.matrix()(0, 0);
255 }
256}

References m_frustrum_zs, m_projection_matrix, m_type, Ortho, and Perspective.

◆ get_near_z()

double Slic3r::GUI::Camera::get_near_z ( ) const
inline
128{ return m_frustrum_zs.first; }

References m_frustrum_zs.

Referenced by Slic3r::GUI::GCodeViewer::render_shells().

Here is the caller graph for this function:

◆ get_position()

◆ get_projection_matrix()

const Transform3d & Slic3r::GUI::Camera::get_projection_matrix ( ) const
inline
116{ return m_projection_matrix; }

References m_projection_matrix.

Referenced by Slic3r::GUI::GLGizmoTextureDisplacement::apply_projection_frame(), Slic3r::GUI::DesignSketchTool::hit_test_base_pick(), load_camera_view(), Slic3r::GUI::GLGizmoFlatten::on_render(), Slic3r::GUI::GLGizmoMeasure::on_render(), Slic3r::GUI::GLGizmoMove3D::on_render(), Slic3r::GUI::GLGizmoRotate::on_render(), Slic3r::GUI::GLGizmoScale3D::on_render(), Slic3r::GUI::GLGizmoSimplify::on_render(), Slic3r::GUI::pan_camera(), Slic3r::GUI::CameraUtils::project(), Slic3r::GUI::CameraUtils::ray_from_ortho_screen_pos(), Slic3r::GUI::CameraUtils::ray_from_persp_screen_pos(), Slic3r::GLVolume::SinkingContours::render(), Slic3r::GUI::Bed3D::Axes::render(), Slic3r::GUI::DesignSketchTool::render(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render(), Slic3r::GUI::GLGizmoBase::Grabber::render(), Slic3r::GUI::GLGizmoCut3D::PartSelection::render(), Slic3r::GUI::TextLinesModel::render(), Slic3r::GUI::GLGizmoTextureDisplacement::render_adjust_texture_gizmo(), Slic3r::GUI::GLGizmoMove3D::render_align_preview(), Slic3r::GUI::Selection::render_bounding_box(), Slic3r::GUI::MeshClipper::render_contour(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_height_range(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_sphere(), Slic3r::GUI::MeshClipper::render_cut(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane(), Slic3r::GUI::GLGizmoMeasure::render_dimensioning(), Slic3r::GUI::Bed3D::render_gravity_arrow(), Slic3r::GUI::PartPlate::render_grid(), Slic3r::GUI::PartPlate::render_icons(), Slic3r::GUI::GLGizmoTextureDisplacement::render_island_overlay(), Slic3r::GUI::PartPlate::render_logo_texture(), Slic3r::GUI::GCodeViewer::render_markers(), Slic3r::GUI::Bed3D::render_model(), Slic3r::GUI::PartPlate::render_only_numbers(), Slic3r::GUI::TriangleSelectorGUI::render_paint_contour(), Slic3r::GUI::GLGizmoTextureDisplacement::render_paint_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::render_painted_colors(), Slic3r::GUI::GLGizmoTextureDisplacement::render_preview_mesh(), Slic3r::GUI::GLGizmoCut3D::render_rotation_snapping(), Slic3r::GUI::GLGizmoTextureDisplacement::render_seam_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::render_shaded_preview_mesh(), Slic3r::GUI::GCodeViewer::render_shells(), Slic3r::GUI::Selection::render_sidebar_layers_hints(), Slic3r::GUI::Selection::render_sidebar_position_hints(), Slic3r::GUI::Selection::render_sidebar_rotation_hints(), Slic3r::GUI::Selection::render_sidebar_scale_hints(), Slic3r::GUI::GLGizmoTextureDisplacement::render_subdivide_preview(), Slic3r::GUI::GCodeViewer::render_toolpaths(), Slic3r::GUI::GCodeViewer::render_translucent_toolpaths(), Slic3r::GUI::GLGizmoPainterBase::render_triangles(), Slic3r::GUI::GLGizmoTextureDisplacement::render_uvcheck_mesh(), Slic3r::GUI::GLGizmoTextureDisplacement::render_wireframe_overlay(), and Slic3r::GUI::world_to_screen_px().

◆ get_scene_box()

const BoundingBoxf3 & Slic3r::GUI::Camera::get_scene_box ( ) const
inline
108{ return m_scene_box; }
BoundingBoxf3 m_scene_box
Definition Camera.hpp:78

References m_scene_box.

Referenced by load_camera_view().

Here is the caller graph for this function:

◆ get_target()

const Vec3d & Slic3r::GUI::Camera::get_target ( )
inline
94 {
96 return m_target; }
void update_target()
Definition Camera.cpp:771
Vec3d m_target
Definition Camera.hpp:64

References m_target, and update_target().

Referenced by Slic3r::GUI::Mouse3DController::State::apply(), get_distance(), load_camera_view(), Slic3r::GUI::select_iso_view(), and Slic3r::GUI::PartPlateList::select_plate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_type()

◆ get_type_as_string()

std::string Slic3r::GUI::Camera::get_type_as_string ( ) const
41{
42 switch (m_type)
43 {
44 case EType::Unknown: return "unknown";
45 case EType::Perspective: return "perspective";
46 default:
47 case EType::Ortho: return "orthographic";
48 };
49}
@ Unknown
Definition Camera.hpp:38

References m_type, Ortho, Perspective, and Unknown.

Referenced by Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::on_first_frame().

Here is the caller graph for this function:

◆ get_view_matrix()

const Transform3d & Slic3r::GUI::Camera::get_view_matrix ( ) const
inline
115{ return m_view_matrix; }

References m_view_matrix.

Referenced by Slic3r::GUI::GLGizmoTextureDisplacement::apply_projection_frame(), Slic3r::GUI::GLGizmoTextureDisplacement::capture_view_projection(), Slic3r::GUI::DesignSketchTool::hit_test_base_pick(), load_camera_view(), Slic3r::GUI::GLGizmoFlatten::on_render(), Slic3r::GUI::GLGizmoMeasure::on_render(), Slic3r::GUI::GLGizmoMove3D::on_render(), Slic3r::GUI::GLGizmoRotate::on_render(), Slic3r::GUI::GLGizmoScale3D::on_render(), Slic3r::GUI::GLGizmoSimplify::on_render(), Slic3r::GUI::CameraUtils::project(), Slic3r::GUI::CameraUtils::ray_from_ortho_screen_pos(), Slic3r::GUI::CameraUtils::ray_from_persp_screen_pos(), Slic3r::GLVolume::SinkingContours::render(), Slic3r::GUI::Bed3D::Axes::render(), Slic3r::GUI::DesignSketchTool::render(), Slic3r::GUI::GCodeViewer::SequentialView::Marker::render(), Slic3r::GUI::GLGizmoBase::Grabber::render(), Slic3r::GUI::GLGizmoCut3D::PartSelection::render(), Slic3r::GUI::TextLinesModel::render(), Slic3r::GUI::GLGizmoTextureDisplacement::render_adjust_texture_gizmo(), Slic3r::GUI::GLGizmoMove3D::render_align_preview(), Slic3r::GUI::Selection::render_bounding_box(), Slic3r::GUI::GLGizmoCut3D::render_connectors(), Slic3r::GUI::MeshClipper::render_contour(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_height_range(), Slic3r::GUI::GLGizmoPainterBase::render_cursor_sphere(), Slic3r::GUI::MeshClipper::render_cut(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane(), Slic3r::GUI::GLGizmoMeasure::render_dimensioning(), Slic3r::GUI::Bed3D::render_gravity_arrow(), Slic3r::GUI::PartPlate::render_grid(), Slic3r::GUI::PartPlate::render_icons(), Slic3r::GUI::GLGizmoTextureDisplacement::render_island_overlay(), Slic3r::GUI::PartPlate::render_logo_texture(), Slic3r::GUI::GCodeViewer::render_markers(), Slic3r::GUI::Bed3D::render_model(), Slic3r::GUI::PartPlate::render_only_numbers(), Slic3r::GUI::TriangleSelectorGUI::render_paint_contour(), Slic3r::GUI::GLGizmoTextureDisplacement::render_paint_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::render_painted_colors(), Slic3r::GUI::GLGizmoTextureDisplacement::render_preview_mesh(), Slic3r::GUI::GLGizmoCut3D::render_rotation_snapping(), Slic3r::GUI::GLGizmoTextureDisplacement::render_seam_overlay(), Slic3r::GUI::GLGizmoTextureDisplacement::render_shaded_preview_mesh(), Slic3r::GUI::GCodeViewer::render_shells(), Slic3r::GUI::Selection::render_sidebar_layers_hints(), Slic3r::GUI::Selection::render_sidebar_position_hints(), Slic3r::GUI::Selection::render_sidebar_rotation_hints(), Slic3r::GUI::Selection::render_sidebar_scale_hints(), Slic3r::GUI::GLGizmoTextureDisplacement::render_subdivide_preview(), Slic3r::GUI::GCodeViewer::render_toolpaths(), Slic3r::GUI::GCodeViewer::render_translucent_toolpaths(), Slic3r::GUI::GLGizmoPainterBase::render_triangles(), Slic3r::GUI::GLGizmoTextureDisplacement::render_uvcheck_mesh(), Slic3r::GUI::GLGizmoTextureDisplacement::render_wireframe_overlay(), and Slic3r::GUI::world_to_screen_px().

◆ get_view_rotation()

const Eigen::Quaterniond & Slic3r::GUI::Camera::get_view_rotation ( ) const
inline
119{return m_view_rotation; }
Eigen::Quaterniond m_view_rotation
Definition Camera.hpp:74

References m_view_rotation.

Referenced by load_camera_view().

Here is the caller graph for this function:

◆ get_viewport()

◆ get_z_range()

const std::pair< double, double > & Slic3r::GUI::Camera::get_z_range ( ) const
inline
130{ return m_frustrum_zs; }

References m_frustrum_zs.

Referenced by load_camera_view().

Here is the caller graph for this function:

◆ get_zenit()

float Slic3r::GUI::Camera::get_zenit ( ) const
inline
101{ return m_zenit; }
float m_zenit
Definition Camera.hpp:65

References m_zenit.

Referenced by load_camera_view().

Here is the caller graph for this function:

◆ get_zoom()

double Slic3r::GUI::Camera::get_zoom ( ) const
inline
103{ return m_zoom; }

References m_zoom.

Referenced by Slic3r::GUI::Mouse3DController::State::apply(), Slic3r::GUI::DesignSketchTool::hit_test_cut_arrow(), Slic3r::GUI::DesignSketchTool::hit_test_datum_handle(), Slic3r::GUI::DesignSketchTool::hit_test_draft_handle(), Slic3r::GUI::DesignSketchTool::hit_test_extrude_arrow(), Slic3r::GUI::DesignSketchTool::hit_test_fillet_arrow(), Slic3r::GUI::DesignSketchTool::hit_test_helix_handle(), Slic3r::GUI::DesignSketchTool::hit_test_hole_handle(), Slic3r::GUI::DesignSketchTool::hit_test_move_arc(), Slic3r::GUI::DesignSketchTool::hit_test_move_arrow(), Slic3r::GUI::DesignSketchTool::hit_test_pattern_handle(), Slic3r::GUI::DesignSketchTool::hit_test_revolve_handle(), Slic3r::GUI::DesignSketchTool::hit_test_rib_handle(), Slic3r::GUI::DesignSketchTool::hit_test_shell_arrow(), Slic3r::GUI::DesignSketchTool::hit_test_thread_handle(), load_camera_view(), Slic3r::GUI::DesignSketchTool::move_gizmo_arm(), Slic3r::GUI::DesignSketchTool::render(), Slic3r::GUI::DesignSketchTool::render_body_edges(), Slic3r::GUI::DesignSketchTool::render_cut_gizmo(), Slic3r::GUI::DesignSketchTool::render_datum_gizmo(), Slic3r::GUI::DesignSketchTool::render_datum_planes(), Slic3r::GUI::DesignSketchTool::render_draft_gizmo(), Slic3r::GUI::DesignSketchTool::render_extrude_gizmo(), Slic3r::GUI::DesignSketchTool::render_face_outline(), Slic3r::GUI::DesignSketchTool::render_fillet_gizmo(), Slic3r::GUI::DesignSketchTool::render_helix_gizmo(), Slic3r::GUI::DesignSketchTool::render_hole_gizmo(), Slic3r::GUI::DesignSketchTool::render_mate_connectors(), Slic3r::GUI::DesignSketchTool::render_move_gizmo(), Slic3r::GUI::DesignSketchTool::render_pattern_gizmo(), Slic3r::GUI::DesignSketchTool::render_reference_axes(), Slic3r::GUI::DesignSketchTool::render_revolve_gizmo(), Slic3r::GUI::DesignSketchTool::render_rib_gizmo(), Slic3r::GUI::DesignSketchTool::render_shell_gizmo(), Slic3r::GUI::DesignSketchTool::render_solid_sel(), Slic3r::GUI::DesignSketchTool::render_thread_gizmo(), Slic3r::GUI::DesignSketchTool::render_view_helpers(), and Slic3r::GUI::DesignSketchTool::render_xform_gizmo().

Here is the caller graph for this function:

◆ is_looking_downward()

bool Slic3r::GUI::Camera::is_looking_downward ( ) const
inline
174{ return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }

References get_dir_forward().

Referenced by Slic3r::GUI::SceneRaycaster::hit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_looking_front()

bool Slic3r::GUI::Camera::is_looking_front ( ) const
inline
175{ return abs(get_dir_up().dot(Vec3d::UnitZ())-1) < 0.001; }
T dot(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:154

References Slic3r::dot(), and get_dir_up().

Here is the call graph for this function:

◆ load_camera_view()

void Slic3r::GUI::Camera::load_camera_view ( Camera & cam)
690{
691 m_target = cam.get_target();
692 m_zoom = cam.get_zoom();
693 m_scene_box = cam.get_scene_box();
694 m_viewport = cam.get_viewport();
695 m_view_matrix = cam.get_view_matrix();
696 m_projection_matrix = cam.get_projection_matrix();
697 m_view_rotation = cam.get_view_rotation();
698 m_frustrum_zs = cam.get_z_range();
699 m_zenit = cam.get_zenit();
700}

References Camera(), get_projection_matrix(), get_scene_box(), get_target(), get_view_matrix(), get_view_rotation(), get_viewport(), get_z_range(), get_zenit(), get_zoom(), m_frustrum_zs, m_projection_matrix, m_scene_box, m_target, m_view_matrix, m_view_rotation, m_viewport, m_zenit, and m_zoom.

Referenced by Slic3r::GUI::Plater::priv::set_current_panel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ look_at()

void Slic3r::GUI::Camera::look_at ( const Vec3d & position,
const Vec3d & target,
const Vec3d & up )
703{
704 const Vec3d unit_z = (position - target).normalized();
705 const Vec3d unit_x = up.cross(unit_z).normalized();
706 const Vec3d unit_y = unit_z.cross(unit_x).normalized();
707
708 m_target = target;
709 m_distance = (position - target).norm();
710 const Vec3d new_position = m_target + m_distance * unit_z;
711
712 m_view_matrix(0, 0) = unit_x.x();
713 m_view_matrix(0, 1) = unit_x.y();
714 m_view_matrix(0, 2) = unit_x.z();
715 m_view_matrix(0, 3) = -unit_x.dot(new_position);
716
717 m_view_matrix(1, 0) = unit_y.x();
718 m_view_matrix(1, 1) = unit_y.y();
719 m_view_matrix(1, 2) = unit_y.z();
720 m_view_matrix(1, 3) = -unit_y.dot(new_position);
721
722 m_view_matrix(2, 0) = unit_z.x();
723 m_view_matrix(2, 1) = unit_z.y();
724 m_view_matrix(2, 2) = unit_z.z();
725 m_view_matrix(2, 3) = -unit_z.dot(new_position);
726
727 m_view_matrix(3, 0) = 0.0;
728 m_view_matrix(3, 1) = 0.0;
729 m_view_matrix(3, 2) = 0.0;
730 m_view_matrix(3, 3) = 1.0;
731
732 // Initialize the rotation quaternion from the rotation submatrix of of m_view_matrix.
733 m_view_rotation = Eigen::Quaterniond(m_view_matrix.matrix().template block<3, 3>(0, 0));
734 m_view_rotation.normalize();
735
736 update_zenit();
737}
void update_zenit()
Definition Camera.cpp:766

References m_distance, m_target, m_view_matrix, m_view_rotation, and update_zenit().

Referenced by Slic3r::GUI::GLCanvas3D::_rectangular_selection_picking_pass(), recover_from_free_camera(), Slic3r::GUI::select_iso_view(), select_view(), Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::set_camera(), and Slic3r::GUI::DesignCanvas::view_normal_to_sketch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_zoom()

double Slic3r::GUI::Camera::max_zoom ( ) const
inline
187{ return 250.0; }

Referenced by set_zoom().

Here is the caller graph for this function:

◆ min_zoom()

double Slic3r::GUI::Camera::min_zoom ( ) const
inline
double calc_zoom_to_bounding_box_factor(const BoundingBoxf3 &box, double margin_factor=DefaultZoomToBoxMarginFactor) const
Definition Camera.cpp:561

References calc_zoom_to_bounding_box_factor(), and m_scene_box.

Referenced by Slic3r::GUI::Mouse3DController::State::apply(), and set_zoom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recover_from_free_camera()

void Slic3r::GUI::Camera::recover_from_free_camera ( )
inline
177 {
178 if (std::abs(get_dir_right()(2)) > EPSILON)
179 look_at(get_position(), m_target, Vec3d::UnitZ());
180 }
#define EPSILON
Definition ColorUtils.cpp:64
void look_at(const Vec3d &position, const Vec3d &target, const Vec3d &up)
Definition Camera.cpp:702

References EPSILON, get_dir_right(), get_position(), look_at(), and m_target.

Here is the call graph for this function:

◆ rotate_local_around_target()

void Slic3r::GUI::Camera::rotate_local_around_target ( const Vec3d & rotation_rad)
499{
500 const double angle = rotation_rad.norm();
501 if (std::abs(angle) > EPSILON) {
502 const Vec3d translation = m_view_matrix.translation() + m_view_rotation * m_target;
503 const Vec3d axis = m_view_rotation.conjugate() * rotation_rad.normalized();
504 m_view_rotation *= Eigen::Quaterniond(Eigen::AngleAxisd(angle, axis));
505 m_view_rotation.normalize();
506 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-m_target) + translation, m_view_rotation, Vec3d(1., 1., 1.));
507 update_zenit();
508 }
509}
double angle(const Eigen::MatrixBase< Derived > &v1, const Eigen::MatrixBase< Derived2 > &v2)
Definition Point.hpp:138

References Slic3r::angle(), EPSILON, m_target, m_view_matrix, m_view_rotation, and update_zenit().

Referenced by Slic3r::GUI::Mouse3DController::State::apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_local_with_target()

void Slic3r::GUI::Camera::rotate_local_with_target ( const Vec3d & rotation_rad,
Vec3d target )
485{
486 double angle = rotation_rad.norm();
487 if (std::abs(angle) > EPSILON) {
488 Vec3d translation = m_view_matrix.translation() + m_view_rotation * target;
489 Vec3d axis = m_view_rotation.conjugate() * rotation_rad.normalized();
490 m_view_rotation *= Eigen::Quaterniond(Eigen::AngleAxisd(angle, axis));
491 m_view_rotation.normalize();
492 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-target) + translation, m_view_rotation, Vec3d(1., 1., 1.));
493 update_zenit();
494 }
495}

References Slic3r::angle(), EPSILON, m_view_matrix, m_view_rotation, and update_zenit().

Here is the call graph for this function:

◆ rotate_on_sphere()

void Slic3r::GUI::Camera::rotate_on_sphere ( double delta_azimut_rad,
double delta_zenit_rad,
bool apply_limits )
463{
464 m_zenit += Geometry::rad2deg(delta_zenit_rad);
465 if (apply_limits) {
466 if (m_zenit > 90.0f) {
467 delta_zenit_rad -= Geometry::deg2rad(m_zenit - 90.0f);
468 m_zenit = 90.0f;
469 }
470 else if (m_zenit < -90.0f) {
471 delta_zenit_rad -= Geometry::deg2rad(m_zenit + 90.0f);
472 m_zenit = -90.0f;
473 }
474 }
475
476 const Vec3d translation = m_view_matrix.translation() + m_view_rotation * m_target;
477 const auto rot_z = Eigen::AngleAxisd(delta_azimut_rad, Vec3d::UnitZ());
478 m_view_rotation *= rot_z * Eigen::AngleAxisd(delta_zenit_rad, rot_z.inverse() * get_dir_right());
479 m_view_rotation.normalize();
480 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (- m_target) + translation, m_view_rotation, Vec3d(1., 1., 1.));
481}
constexpr T deg2rad(const T angle)
Definition Geometry.hpp:312

References Slic3r::Geometry::deg2rad(), get_dir_right(), m_target, m_view_matrix, m_view_rotation, m_zenit, and Slic3r::Geometry::rad2deg().

Here is the call graph for this function:

◆ rotate_on_sphere_with_target()

void Slic3r::GUI::Camera::rotate_on_sphere_with_target ( double delta_azimut_rad,
double delta_zenit_rad,
bool apply_limits,
Vec3d target )
441{
442 m_zenit += Geometry::rad2deg(delta_zenit_rad);
443 if (apply_limits) {
444 if (m_zenit > 90.0f) {
445 delta_zenit_rad -= Geometry::deg2rad(m_zenit - 90.0f);
446 m_zenit = 90.0f;
447 }
448 else if (m_zenit < -90.0f) {
449 delta_zenit_rad -= Geometry::deg2rad(m_zenit + 90.0f);
450 m_zenit = -90.0f;
451 }
452 }
453
454 Vec3d translation = m_view_matrix.translation() + m_view_rotation * target;
455 auto rot_z = Eigen::AngleAxisd(delta_azimut_rad, Vec3d::UnitZ());
456 m_view_rotation *= rot_z * Eigen::AngleAxisd(delta_zenit_rad, rot_z.inverse() * get_dir_right());
457 m_view_rotation.normalize();
458 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-target) + translation, m_view_rotation, Vec3d(1., 1., 1.));
459}

References Slic3r::Geometry::deg2rad(), get_dir_right(), m_view_matrix, m_view_rotation, m_zenit, and Slic3r::Geometry::rad2deg().

Here is the call graph for this function:

◆ select_next_type()

void Slic3r::GUI::Camera::select_next_type ( )
63{
64 unsigned char next = (unsigned char)m_type + 1;
65 if (next == (unsigned char)EType::Num_types)
66 next = 1;
67
68 set_type((EType)next);
69}
EType
Definition Camera.hpp:37
@ Num_types
Definition Camera.hpp:41

References m_type, Num_types, and set_type().

Here is the call graph for this function:

◆ select_view() [1/2]

void Slic3r::GUI::Camera::select_view ( const std::string & direction)
120{
121 if (direction == "iso") {
124 }
125 else if (direction == "left") {
126 look_at(m_target - m_distance * Vec3d::UnitX(), m_target, Vec3d::UnitZ());
128 }
129 else if (direction == "right") {
130 look_at(m_target + m_distance * Vec3d::UnitX(), m_target, Vec3d::UnitZ());
132 }
133 else if (direction == "top") {
134 look_at(m_target + m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY());
136 }
137 else if (direction == "bottom") {
138 look_at(m_target - m_distance * Vec3d::UnitZ(), m_target, -Vec3d::UnitY());
140 }
141 else if (direction == "front") {
142 look_at(m_target - m_distance * Vec3d::UnitY(), m_target, Vec3d::UnitZ());
144 }
145 else if (direction == "rear") {
146 look_at(m_target + m_distance * Vec3d::UnitY(), m_target, Vec3d::UnitZ());
148 }
149 else if (direction == "topfront") {
150 look_at(m_target - 0.707 * m_distance * Vec3d::UnitY() + 0.707 * m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY() + Vec3d::UnitZ());
152 }
153 else if (direction == "plate") {
154 look_at(m_target - 0.707 * m_distance * Vec3d::UnitY() + 0.707 * m_distance * Vec3d::UnitZ(), m_target, Vec3d::UnitY() + Vec3d::UnitZ());
156 }
157}
void auto_type(EType preferred_type)
Definition Camera.cpp:71

References auto_type(), look_at(), m_distance, m_target, Ortho, Perspective, and set_default_orientation().

Referenced by select_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_view() [2/2]

void Slic3r::GUI::Camera::select_view ( ViewAngleType type)
159{
160 switch (type) {
162 select_view("iso");
163 break;
164 }
166 select_view("topfront");
167 break;
168 }
170 select_view("left");
171 break;
172 }
174 select_view("right");
175 break;
176 }
179 select_view("top");
180 break;
181 }
183 select_view("bottom");
184 break;
185 }
187 select_view("front");
188 break;
189 }
191 select_view("rear");
192 break;
193 }
194 default: break;
195 }
196}
void select_view(const std::string &direction)
Definition Camera.cpp:119
@ Bottom
Definition Camera.hpp:49
@ Iso
Definition Camera.hpp:44
@ Front
Definition Camera.hpp:50
@ Right
Definition Camera.hpp:47
@ Left
Definition Camera.hpp:46
@ Top
Definition Camera.hpp:48
@ Rear
Definition Camera.hpp:51
@ Top_Front
Definition Camera.hpp:45
@ Top_Plate
Definition Camera.hpp:53

References Bottom, Front, Iso, Left, Rear, Right, select_view(), Top, Top_Front, and Top_Plate.

Here is the call graph for this function:

◆ set_default_orientation()

void Slic3r::GUI::Camera::set_default_orientation ( )
private
740{
741 m_zenit = 45.0f;
742 const double theta_rad = Geometry::deg2rad(-(double)m_zenit);
743 const double phi_rad = Geometry::deg2rad(45.0);
744 const double sin_theta = ::sin(theta_rad);
745 const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad));
746 m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ());
747 m_view_rotation.normalize();
748 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());
749}

References Slic3r::Geometry::deg2rad(), m_distance, m_target, m_view_matrix, m_view_rotation, and m_zenit.

Referenced by Camera(), and select_view().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_distance()

void Slic3r::GUI::Camera::set_distance ( double distance)
private
677{
678 if(distance < EPSILON || distance > 1.0e6)
679 return;
680
681 if (m_distance != distance) {
682 m_view_matrix.translate((distance - m_distance) * get_dir_forward());
684
686 }
687}
float distance(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b)
Definition SpiralVase.cpp:19

References get_dir_forward(), m_distance, m_view_matrix, and update_target().

Referenced by calc_tight_frustrum_zs_around().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_rotation()

void Slic3r::GUI::Camera::set_rotation ( const Transform3d & rotation)
512{
513 const Vec3d translation = m_view_matrix.translation() + m_view_rotation * m_target;
514 m_view_rotation = Eigen::Quaterniond(rotation.matrix().template block<3, 3>(0, 0));
515 m_view_rotation.normalize();
516 m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-m_target) + translation, m_view_rotation, Vec3d(1., 1., 1.));
517 update_zenit();
518}

References m_target, m_view_matrix, m_view_rotation, and update_zenit().

Here is the call graph for this function:

◆ set_scene_box()

void Slic3r::GUI::Camera::set_scene_box ( const BoundingBoxf3 & box)
inline
109{ m_scene_box = box; }

References m_scene_box.

◆ set_target()

void Slic3r::GUI::Camera::set_target ( const Vec3d & target)
96{
97 //BBS do not check validation
98 //const Vec3d new_target = validate_target(target);
100 const Vec3d new_target = target;
101 const Vec3d new_displacement = new_target - m_target;
102 if (!new_displacement.isApprox(Vec3d::Zero())) {
103 m_target = new_target;
104 m_view_matrix.translate(-new_displacement);
105 }
106}

References m_target, m_view_matrix, and update_target().

Referenced by Slic3r::GUI::Mouse3DController::State::apply(), Slic3r::GUI::PartPlateList::select_plate(), translate_world(), zoom_to_box(), and zoom_to_volumes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_type() [1/2]

void Slic3r::GUI::Camera::set_type ( const std::string & type)
inline
87{ set_type((type == "true") ? EType::Perspective : EType::Ortho); }

References Ortho, Perspective, and set_type().

Referenced by set_type().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_type() [2/2]

void Slic3r::GUI::Camera::set_type ( EType type)
52{
53 if (m_type != type && (type == EType::Ortho || type == EType::Perspective)) {
54 m_type = type;
57 wxGetApp().app_config->set_bool("use_perspective_camera", m_type == EType::Perspective);
58 }
59 }
60}

References m_prevent_auto_type, m_type, m_update_config_on_type_change_enabled, Ortho, and Perspective.

Referenced by Slic3r::GUI::GLCanvas3D::_rectangular_selection_picking_pass(), auto_type(), and select_next_type().

Here is the caller graph for this function:

◆ set_viewport()

void Slic3r::GUI::Camera::set_viewport ( int x,
int y,
unsigned int w,
unsigned int h )
283{
284 m_viewport = { 0, 0, int(w), int(h) };
285}

References m_viewport.

Referenced by Slic3r::GUI::GLCanvas3D::_rectangular_selection_picking_pass().

Here is the caller graph for this function:

◆ set_zoom()

void Slic3r::GUI::Camera::set_zoom ( double zoom)
109{
110 // Don't allow to zoom too far outside the scene.
111 const double zoom_min = min_zoom();
112 if (zoom_min > 0.0)
113 zoom = std::max(zoom, zoom_min);
114
115 // Don't allow to zoom too close to the scene.
116 m_zoom = std::min(zoom, max_zoom());
117}
double min_zoom() const
Definition Camera.hpp:188
double max_zoom() const
Definition Camera.hpp:187

References m_zoom, max_zoom(), and min_zoom().

Referenced by Slic3r::GUI::anonymous_namespace{SceneBenchmark.cpp}::SceneBenchmarkDialog::set_camera(), and update_zoom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate()

void Slic3r::GUI::Camera::translate ( const Vec3d & displacement)
88 {
89 if (!displacement.isApprox(Vec3d::Zero())) {
90 m_view_matrix.translate(-displacement);
92 }
93}

References m_view_matrix, and update_target().

Referenced by Slic3r::GUI::pan_camera().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ translate_world()

void Slic3r::GUI::Camera::translate_world ( const Vec3d & displacement)
inline
157{ set_target(m_target + displacement); }
void set_target(const Vec3d &target)
Definition Camera.cpp:95

References m_target, and set_target().

Here is the call graph for this function:

◆ update_target()

void Slic3r::GUI::Camera::update_target ( )
private
771 {
772 Vec3d temptarget = get_position() + m_distance * get_dir_forward();
773 if (!(temptarget-m_target).isApprox(Vec3d::Zero())){
774 m_target = temptarget;
775 }
776}

References get_dir_forward(), get_position(), m_distance, and m_target.

Referenced by get_target(), set_distance(), set_target(), and translate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_zenit()

void Slic3r::GUI::Camera::update_zenit ( )
private
767{
768 m_zenit = Geometry::rad2deg(0.5 * M_PI - std::acos(std::clamp(-get_dir_forward().dot(Vec3d::UnitZ()), -1.0, 1.0)));
769}
#define M_PI
Definition ExtrusionSimulator.cpp:31

References Slic3r::dot(), get_dir_forward(), M_PI, m_zenit, and Slic3r::Geometry::rad2deg().

Referenced by look_at(), rotate_local_around_target(), rotate_local_with_target(), and set_rotation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_zoom()

void Slic3r::GUI::Camera::update_zoom ( double delta_zoom)
inline
105{ set_zoom(m_zoom / (1.0 - std::max(std::min(delta_zoom, 4.0), -4.0) * ZoomUnit)); }
void set_zoom(double zoom)
Definition Camera.cpp:108
static double ZoomUnit
Definition Camera.hpp:34

References m_zoom, set_zoom(), and ZoomUnit.

Referenced by Slic3r::GUI::Mouse3DController::State::apply().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_target()

Vec3d Slic3r::GUI::Camera::validate_target ( const Vec3d & target) const
private
752{
753 BoundingBoxf3 test_box = m_scene_box;
754 test_box.translate(-m_scene_box.center());
755 // We may let this factor be customizable
756 //BBS enlarge scene box factor
757 static const double ScaleFactor = 3.0;
758 test_box.scale(ScaleFactor);
759 test_box.translate(m_scene_box.center());
760
761 return { std::clamp(target(0), test_box.min(0), test_box.max(0)),
762 std::clamp(target(1), test_box.min(1), test_box.max(1)),
763 std::clamp(target(2), test_box.min(2), test_box.max(2)) };
764}

References m_scene_box, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::scale(), and Slic3r::BoundingBox3Base< PointType >::translate().

Here is the call graph for this function:

◆ zoom_to_box()

void Slic3r::GUI::Camera::zoom_to_box ( const BoundingBoxf3 & box,
double margin_factor = DefaultZoomToBoxMarginFactor )
364{
365 // Calculate the zoom factor needed to adjust the view around the given box.
366 const double zoom = calc_zoom_to_bounding_box_factor(box, margin_factor);
367 if (zoom > 0.0) {
368 m_zoom = zoom;
369 // center view around box center
370 set_target(box.center());
371 }
372}

References calc_zoom_to_bounding_box_factor(), Slic3r::BoundingBox3Base< PointType >::center(), m_zoom, and set_target().

Here is the call graph for this function:

◆ zoom_to_volumes()

void Slic3r::GUI::Camera::zoom_to_volumes ( const GLVolumePtrs & volumes,
double margin_factor = DefaultZoomToVolumesMarginFactor )
375{
377 const double zoom = calc_zoom_to_volumes_factor(volumes, center, margin_factor);
378 if (zoom > 0.0) {
379 m_zoom = zoom;
380 // center view around the calculated center
382 }
383}
double calc_zoom_to_volumes_factor(const GLVolumePtrs &volumes, Vec3d &center, double margin_factor=DefaultZoomToVolumesMarginFactor) const
Definition Camera.cpp:618

References calc_zoom_to_volumes_factor(), Slic3r::center(), m_zoom, and set_target().

Here is the call graph for this function:

Member Data Documentation

◆ DefaultDistance

const double Slic3r::GUI::Camera::DefaultDistance = 1000.0
static

◆ DefaultZoomToBoxMarginFactor

const double Slic3r::GUI::Camera::DefaultZoomToBoxMarginFactor = 1.025
static

◆ DefaultZoomToVolumesMarginFactor

const double Slic3r::GUI::Camera::DefaultZoomToVolumesMarginFactor = 1.025
static

◆ FrustrumMinNearZ

double Slic3r::GUI::Camera::FrustrumMinNearZ = 100.0
static

◆ FrustrumMinZRange

double Slic3r::GUI::Camera::FrustrumMinZRange = 50.0
static

◆ FrustrumZMargin

double Slic3r::GUI::Camera::FrustrumZMargin = 10.0
static

◆ m_distance

double Slic3r::GUI::Camera::m_distance { DefaultDistance }
private

◆ m_frustrum_zs

◆ m_gui_scale

double Slic3r::GUI::Camera::m_gui_scale { 1.0 }
private
69{ 1.0 };

Referenced by apply_projection(), and get_gui_scale().

◆ m_prevent_auto_type

bool Slic3r::GUI::Camera::m_prevent_auto_type = true
private

Referenced by auto_type(), and set_type().

◆ m_projection_matrix

Transform3d Slic3r::GUI::Camera::m_projection_matrix { Transform3d::Identity() }
private

◆ m_scene_box

BoundingBoxf3 Slic3r::GUI::Camera::m_scene_box
private

◆ m_target

◆ m_type

◆ m_update_config_on_type_change_enabled

bool Slic3r::GUI::Camera::m_update_config_on_type_change_enabled { false }
private
63{ false };

Referenced by enable_update_config_on_type_change(), and set_type().

◆ m_view_matrix

◆ m_view_rotation

Eigen::Quaterniond Slic3r::GUI::Camera::m_view_rotation { 1.0, 0.0, 0.0, 0.0 }
private

◆ m_viewport

◆ m_zenit

float Slic3r::GUI::Camera::m_zenit { 45.0f }
private

◆ m_zoom

double Slic3r::GUI::Camera::m_zoom { 1.0 }
private

◆ MaxFovDeg

double Slic3r::GUI::Camera::MaxFovDeg = 60.0
static

◆ requires_zoom_to_bed

bool Slic3r::GUI::Camera::requires_zoom_to_bed { false }
55{ false };

◆ requires_zoom_to_plate

int Slic3r::GUI::Camera::requires_zoom_to_plate { REQUIRES_ZOOM_TO_PLATE_IDLE }
#define REQUIRES_ZOOM_TO_PLATE_IDLE
Definition Camera.hpp:22

◆ requires_zoom_to_volumes

bool Slic3r::GUI::Camera::requires_zoom_to_volumes { false }
57{ false };

◆ ZoomUnit

double Slic3r::GUI::Camera::ZoomUnit = 0.1
static

Referenced by update_zoom().


The documentation for this struct was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Camera.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Camera.cpp