OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::TransformHelper Class Reference

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

Collaboration diagram for Slic3r::GUI::TransformHelper:

Classes

struct  Cache

Static Public Member Functions

static Vec3d model_to_world (const Vec3d &model, const Transform3d &world_matrix)
static Vec4d world_to_clip (const Vec3d &world, const Matrix4d &projection_view_matrix)
static Vec3d clip_to_ndc (const Vec4d &clip)
static Vec2d ndc_to_ss (const Vec3d &ndc, const std::array< int, 4 > &viewport)
static Vec4d model_to_clip (const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix)
static Vec3d model_to_ndc (const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix)
static Vec2d model_to_ss (const Vec3d &model, const Transform3d &world_matrix, const Matrix4d &projection_view_matrix, const std::array< int, 4 > &viewport)
static Vec2d world_to_ss (const Vec3d &world, const Matrix4d &projection_view_matrix, const std::array< int, 4 > &viewport)
static const Matrix4d & ndc_to_ss_matrix (const std::array< int, 4 > &viewport)
static const Transform3d ndc_to_ss_matrix_inverse (const std::array< int, 4 > &viewport)

Static Private Member Functions

static void update (const std::array< int, 4 > &viewport)

Static Private Attributes

static Cache s_cache = { { 0, 0, 0, 0 }, Matrix4d::Identity(), Transform3d::Identity() }

Detailed Description


Class Documentation

◆ Slic3r::GUI::TransformHelper::Cache

struct Slic3r::GUI::TransformHelper::Cache
Collaboration diagram for Slic3r::GUI::TransformHelper::Cache:
Class Members
Matrix4d ndc_to_ss_matrix
Transform3d ndc_to_ss_matrix_inverse
array< int, 4 > viewport

Member Function Documentation

◆ clip_to_ndc()

Vec3d Slic3r::GUI::TransformHelper::clip_to_ndc ( const Vec4d & clip)
static
170 {
171 return Vec3d(clip.x(), clip.y(), clip.z()) / clip.w();
172}
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

Referenced by model_to_ndc(), model_to_ss(), and world_to_ss().

Here is the caller graph for this function:

◆ model_to_clip()

Vec4d Slic3r::GUI::TransformHelper::model_to_clip ( const Vec3d & model,
const Transform3d & world_matrix,
const Matrix4d & projection_view_matrix )
static
182{
183 return world_to_clip(model_to_world(model, world_matrix), projection_view_matrix);
184}
static Vec4d world_to_clip(const Vec3d &world, const Matrix4d &projection_view_matrix)
Definition GLGizmoMeasure.cpp:165
static Vec3d model_to_world(const Vec3d &model, const Transform3d &world_matrix)
Definition GLGizmoMeasure.cpp:161

References model_to_world(), and world_to_clip().

Here is the call graph for this function:

◆ model_to_ndc()

Vec3d Slic3r::GUI::TransformHelper::model_to_ndc ( const Vec3d & model,
const Transform3d & world_matrix,
const Matrix4d & projection_view_matrix )
static
187{
188 return clip_to_ndc(world_to_clip(model_to_world(model, world_matrix), projection_view_matrix));
189}
static Vec3d clip_to_ndc(const Vec4d &clip)
Definition GLGizmoMeasure.cpp:170

References clip_to_ndc(), model_to_world(), and world_to_clip().

Here is the call graph for this function:

◆ model_to_ss()

Vec2d Slic3r::GUI::TransformHelper::model_to_ss ( const Vec3d & model,
const Transform3d & world_matrix,
const Matrix4d & projection_view_matrix,
const std::array< int, 4 > & viewport )
static
192{
193 return ndc_to_ss(clip_to_ndc(world_to_clip(model_to_world(model, world_matrix), projection_view_matrix)), viewport);
194}
static Vec2d ndc_to_ss(const Vec3d &ndc, const std::array< int, 4 > &viewport)
Definition GLGizmoMeasure.cpp:174

References clip_to_ndc(), model_to_world(), ndc_to_ss(), and world_to_clip().

Here is the call graph for this function:

◆ model_to_world()

Vec3d Slic3r::GUI::TransformHelper::model_to_world ( const Vec3d & model,
const Transform3d & world_matrix )
static
161 {
162 return world_matrix * model;
163}

Referenced by model_to_clip(), model_to_ndc(), and model_to_ss().

Here is the caller graph for this function:

◆ ndc_to_ss()

Vec2d Slic3r::GUI::TransformHelper::ndc_to_ss ( const Vec3d & ndc,
const std::array< int, 4 > & viewport )
static
175{
176 const double half_w = 0.5 * double(viewport[2]);
177 const double half_h = 0.5 * double(viewport[3]);
178 return { half_w * ndc.x() + double(viewport[0]) + half_w, half_h * ndc.y() + double(viewport[1]) + half_h };
179};

Referenced by model_to_ss(), and world_to_ss().

Here is the caller graph for this function:

◆ ndc_to_ss_matrix()

const Matrix4d & Slic3r::GUI::TransformHelper::ndc_to_ss_matrix ( const std::array< int, 4 > & viewport)
static
202{
203 update(viewport);
204 return s_cache.ndc_to_ss_matrix;
205}
static Cache s_cache
Definition GLGizmoMeasure.hpp:72
static void update(const std::array< int, 4 > &viewport)
Definition GLGizmoMeasure.cpp:213

References s_cache, and update().

Here is the call graph for this function:

◆ ndc_to_ss_matrix_inverse()

const Transform3d Slic3r::GUI::TransformHelper::ndc_to_ss_matrix_inverse ( const std::array< int, 4 > & viewport)
static
208{
209 update(viewport);
210 return s_cache.ndc_to_ss_matrix_inverse;
211}

References s_cache, and update().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning().

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

◆ update()

void Slic3r::GUI::TransformHelper::update ( const std::array< int, 4 > & viewport)
staticprivate
214{
215 if (s_cache.viewport == viewport)
216 return;
217
218 const double half_w = 0.5 * double(viewport[2]);
219 const double half_h = 0.5 * double(viewport[3]);
220 s_cache.ndc_to_ss_matrix << half_w, 0.0, 0.0, double(viewport[0]) + half_w,
221 0.0, half_h, 0.0, double(viewport[1]) + half_h,
222 0.0, 0.0, 1.0, 0.0,
223 0.0, 0.0, 0.0, 1.0;
224
225 s_cache.ndc_to_ss_matrix_inverse = s_cache.ndc_to_ss_matrix.inverse();
226 s_cache.viewport = viewport;
227}

References s_cache.

Referenced by ndc_to_ss_matrix(), and ndc_to_ss_matrix_inverse().

Here is the caller graph for this function:

◆ world_to_clip()

Vec4d Slic3r::GUI::TransformHelper::world_to_clip ( const Vec3d & world,
const Matrix4d & projection_view_matrix )
static
166{
167 return projection_view_matrix * Vec4d(world.x(), world.y(), world.z(), 1.0);
168}
Eigen::Matrix< double, 4, 1, Eigen::DontAlign > Vec4d
Definition Point.hpp:69

Referenced by model_to_clip(), model_to_ndc(), model_to_ss(), and world_to_ss().

Here is the caller graph for this function:

◆ world_to_ss()

Vec2d Slic3r::GUI::TransformHelper::world_to_ss ( const Vec3d & world,
const Matrix4d & projection_view_matrix,
const std::array< int, 4 > & viewport )
static
197{
198 return ndc_to_ss(clip_to_ndc(world_to_clip(world, projection_view_matrix)), viewport);
199}

References clip_to_ndc(), ndc_to_ss(), and world_to_clip().

Referenced by Slic3r::GUI::GLGizmoMeasure::render_dimensioning().

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

Member Data Documentation

◆ s_cache

TransformHelper::Cache Slic3r::GUI::TransformHelper::s_cache = { { 0, 0, 0, 0 }, Matrix4d::Identity(), Transform3d::Identity() }
staticprivate

The documentation for this class was generated from the following files: