Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::opengl2::TranslateWidget Class Reference

#include <src/libigl/igl/opengl2/TranslateWidget.h>

Public Types

enum  DownType {
  DOWN_TYPE_X = 0 , DOWN_TYPE_Y = 1 , DOWN_TYPE_Z = 2 , DOWN_TYPE_CENTER = 3 ,
  DOWN_TYPE_NONE = 4 , NUM_DOWN_TYPES = 5
}
 

Public Member Functions

 TranslateWidget (const Eigen::Vector3d &pos=Eigen::Vector3d(0, 0, 0))
 
bool down (const int x, const int y)
 
bool drag (const int x, const int y)
 
bool up (const int x, const int y)
 
bool is_down () const
 
void draw () const
 

Public Attributes

Eigen::Vector3d m_pos
 
Eigen::Vector3d m_trans
 
Eigen::Vector3d m_down_trans
 
Eigen::Vector2d m_down_xy
 
Eigen::Vector2d m_drag_xy
 
bool m_is_enabled
 
double m_len
 
enum igl::opengl2::TranslateWidget::DownType m_down_type
 
enum igl::opengl2::TranslateWidget::DownType m_selected_type
 
 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 

Detailed Description

Member Enumeration Documentation

◆ DownType

Enumerator
DOWN_TYPE_X 
DOWN_TYPE_Y 
DOWN_TYPE_Z 
DOWN_TYPE_CENTER 
DOWN_TYPE_NONE 
NUM_DOWN_TYPES 
32 {
33 DOWN_TYPE_X = 0,
34 DOWN_TYPE_Y = 1,
35 DOWN_TYPE_Z = 2,
@ DOWN_TYPE_Z
Definition TranslateWidget.h:35
@ DOWN_TYPE_X
Definition TranslateWidget.h:33
@ DOWN_TYPE_CENTER
Definition TranslateWidget.h:36
@ DOWN_TYPE_NONE
Definition TranslateWidget.h:37
@ NUM_DOWN_TYPES
Definition TranslateWidget.h:38
@ DOWN_TYPE_Y
Definition TranslateWidget.h:34
enum igl::opengl2::TranslateWidget::DownType m_down_type
enum igl::opengl2::TranslateWidget::DownType m_selected_type

Constructor & Destructor Documentation

◆ TranslateWidget()

igl::opengl2::TranslateWidget::TranslateWidget ( const Eigen::Vector3d &  pos = Eigen::Vector3d(0,0,0))
inline
57 :
58 m_pos(pos),
59 m_trans(0,0,0),
60 m_down_xy(-1,-1),
61 m_drag_xy(-1,-1),
62 m_is_enabled(true),
63 m_len(50),
66{
67}
bool m_is_enabled
Definition TranslateWidget.h:29
Eigen::Vector2d m_down_xy
Definition TranslateWidget.h:28
Eigen::Vector3d m_trans
Definition TranslateWidget.h:27
Eigen::Vector2d m_drag_xy
Definition TranslateWidget.h:28
Eigen::Vector3d m_pos
Definition TranslateWidget.h:27
double m_len
Definition TranslateWidget.h:30

Member Function Documentation

◆ down()

bool igl::opengl2::TranslateWidget::down ( const int  x,
const int  y 
)
inline
70{
71 using namespace Eigen;
72 using namespace std;
73 if(!m_is_enabled)
74 {
75 return false;
76 }
78 m_down_xy = Vector2d(x,y);
82 Vector3d ppos = project((m_pos+m_trans).eval());
83 const double r = (ppos.head(2) - m_down_xy).norm();
84 const double center_thresh = 10;
85 if(r < center_thresh)
86 {
89 return true;
90 }else if(r < m_len)
91 {
92 // Might be hit on lines
93 }
94 return false;
95}
Eigen::Vector3d m_down_trans
Definition TranslateWidget.h:27
Definition LDLT.h:16
IGL_INLINE int project(const double objX, const double objY, const double objZ, double *winX, double *winY, double *winZ)
Definition project.cpp:14
STL namespace.

References igl::opengl2::project().

+ Here is the call graph for this function:

◆ drag()

bool igl::opengl2::TranslateWidget::drag ( const int  x,
const int  y 
)
inline
98{
99 using namespace std;
100 using namespace Eigen;
101 if(!m_is_enabled)
102 {
103 return false;
104 }
105 m_drag_xy = Vector2d(x,y);
106 switch(m_down_type)
107 {
108 case DOWN_TYPE_NONE:
109 return false;
110 default:
111 {
112 Vector3d ppos = project((m_pos+m_trans).eval());
113 Vector3d drag3(m_drag_xy(0),m_drag_xy(1),ppos(2));
114 Vector3d down3(m_down_xy(0),m_down_xy(1),ppos(2));
115 m_trans = m_down_trans + unproject(drag3)-unproject(down3);
116 return true;
117 }
118 }
119}
IGL_INLINE void unproject(const double winX, const double winY, const double winZ, double *objX, double *objY, double *objZ)
Definition unproject.cpp:16

References igl::opengl2::project(), and igl::opengl2::unproject().

+ Here is the call graph for this function:

◆ draw()

void igl::opengl2::TranslateWidget::draw ( ) const
inline
134{
135 using namespace Eigen;
136 using namespace std;
137 glPushAttrib(GL_ENABLE_BIT | GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT | GL_LINE_BIT);
138 glDisable(GL_LIGHTING);
139 glDisable(GL_DEPTH_TEST);
140 glLineWidth(2.0);
141 auto draw_axes = [&]()
142 {
143 glBegin(GL_LINES);
144 glColor3f(1,0,0);
145 glVertex3f(0,0,0);
146 glVertex3f(1,0,0);
147 glColor3f(0,1,0);
148 glVertex3f(0,0,0);
149 glVertex3f(0,1,0);
150 glColor3f(0,0,1);
151 glVertex3f(0,0,0);
152 glVertex3f(0,0,1);
153 glEnd();
154 };
155 auto draw_cube = []
156 {
157 glBegin(GL_LINES);
158 glVertex3f(-1.0f, 1.0f, 1.0f);
159 glVertex3f(1.0f, 1.0f, 1.0f);
160 glVertex3f(1.0f, 1.0f, 1.0f);
161 glVertex3f(1.0f, -1.0f, 1.0f);
162 glVertex3f(1.0f, -1.0f, 1.0f);
163 glVertex3f(-1.0f, -1.0f, 1.0f);
164 glVertex3f(-1.0f, -1.0f, 1.0f);
165 glVertex3f(-1.0f, 1.0f, 1.0f);
166 glVertex3f(1.0f, 1.0f, 1.0f);
167 glVertex3f(1.0f, 1.0f, -1.0f);
168 glVertex3f(1.0f, 1.0f, -1.0f);
169 glVertex3f(1.0f, -1.0f, -1.0f);
170 glVertex3f(1.0f, -1.0f, -1.0f);
171 glVertex3f(1.0f, -1.0f, 1.0f);
172 glVertex3f(1.0f, 1.0f, -1.0f);
173 glVertex3f(-1.0f, 1.0f, -1.0f);
174 glVertex3f(-1.0f, -1.0f, -1.0f);
175 glVertex3f(1.0f, -1.0f, -1.0f);
176 glVertex3f(-1.0f, -1.0f, -1.0f);
177 glVertex3f(-1.0f, 1.0f, -1.0f);
178 glVertex3f(-1.0f, 1.0f, -1.0f);
179 glVertex3f(-1.0f, 1.0f, 1.0f);
180 glVertex3f(-1.0f, -1.0f, 1.0f);
181 glVertex3f(-1.0f, -1.0f, -1.0f);
182 glEnd();
183 };
184 glPushMatrix();
185 glTranslated( m_pos(0)+m_trans(0), m_pos(1)+m_trans(1), m_pos(2)+m_trans(2));
186
187 {
188 Vector3d off,ppos,ppos_off,pos_off;
189 project((m_pos+m_trans).eval(),ppos);
190 ppos_off = ppos;
191 ppos_off(0) += m_len;
192 unproject(ppos_off,pos_off);
193 const double r = (m_pos+m_trans-pos_off).norm();
194 glScaled(r,r,r);
195 }
196
197 draw_axes();
198 glScaled(0.05,0.05,0.05);
200 {
201 glColor3fv(MAYA_YELLOW.data());
202 }else
203 {
204 glColor3fv(MAYA_GREY.data());
205 }
206 draw_cube();
207 glPopMatrix();
208 glPopAttrib();
209}
const Eigen::Vector4f MAYA_YELLOW(255./255., 247./255., 50./255., 1.)
const Eigen::Vector4f MAYA_GREY(0.5, 0.5, 0.5, 1.0)

References igl::MAYA_GREY(), igl::MAYA_YELLOW(), igl::opengl2::project(), and igl::opengl2::unproject().

+ Here is the call graph for this function:

◆ is_down()

bool igl::opengl2::TranslateWidget::is_down ( ) const
inline
129{
130 return m_down_type != DOWN_TYPE_NONE;
131}

Referenced by igl::opengl2::MouseController::is_trans_widget_down().

+ Here is the caller graph for this function:

◆ up()

bool igl::opengl2::TranslateWidget::up ( const int  x,
const int  y 
)
inline
122{
123 // even if disabled process up
125 return false;
126}

Member Data Documentation

◆ EIGEN_MAKE_ALIGNED_OPERATOR_NEW

igl::opengl2::TranslateWidget::EIGEN_MAKE_ALIGNED_OPERATOR_NEW

◆ m_down_trans

Eigen::Vector3d igl::opengl2::TranslateWidget::m_down_trans

◆ m_down_type

enum igl::opengl2::TranslateWidget::DownType igl::opengl2::TranslateWidget::m_down_type

◆ m_down_xy

Eigen::Vector2d igl::opengl2::TranslateWidget::m_down_xy

◆ m_drag_xy

Eigen::Vector2d igl::opengl2::TranslateWidget::m_drag_xy

◆ m_is_enabled

bool igl::opengl2::TranslateWidget::m_is_enabled

◆ m_len

double igl::opengl2::TranslateWidget::m_len

◆ m_pos

Eigen::Vector3d igl::opengl2::TranslateWidget::m_pos

◆ m_selected_type

enum igl::opengl2::TranslateWidget::DownType igl::opengl2::TranslateWidget::m_selected_type

◆ m_trans

Eigen::Vector3d igl::opengl2::TranslateWidget::m_trans

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