22 #include <QMouseEvent>
30 if (QSysInfo::productType() ==
"osx")
36 if (QSysInfo::productType() ==
"osx")
41 const float rot_speed_h = 0.4f;
42 const float rot_speed_v = 0.4f;
45 const float cameraDefaultPosY = -200.0f;
46 const float cameraDefaultPosZ = 120.0f;
60 , m_isInitializedGL(false)
131 connect(context(), &QOpenGLContext::aboutToBeDestroyed,
this, &
Canvas::cleanup);
133 initializeOpenGLFunctions();
134 glEnable(GL_DEPTH_TEST);
135 glEnable(GL_CULL_FACE);
141 int w1 = qMax(1, w), h1 = qMax(1, h);
150 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
164 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
172 QMatrix4x4 matObject3DAxes;
173 matObject3DAxes.setToIdentity();
177 std::unique_ptr<Buffer3DAxes> buf3DAxes(
new Buffer3DAxes());
178 buf3DAxes->draw3DAxes();
187 float x = p.x(), y =
viewport.height() - p.y();
193 switch (e->button()) {
197 case Qt::RightButton:
215 float delta_x = e->pos().x() -
e_last.x();
216 float delta_y = e->pos().y() -
e_last.y();
253 if (e->angleDelta().y() < 0) {
275 for (
auto b :
buffers.values())
391 float theta = angle *
static_cast<float>(
M_PI / 180.0);
404 v_up3DAxes * (1 - std::cos(theta)) *
dot(v_axis3DAxes, v_eye3DAxes)
405 + v_eye3DAxes * std::cos(theta) +
cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
407 Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
422 + v_eye * std::cos(theta)
423 +
cross(v_axis, v_eye) * std::sin(theta);
437 float theta = angle *
static_cast<float>(
M_PI / 180.0);
451 v_up3DAxes * (1 - std::cos(theta)) *
dot(v_axis3DAxes, v_eye3DAxes)
452 + v_eye3DAxes * std::cos(theta) +
cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
454 Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
469 + v_eye * std::cos(theta)
470 +
cross(v_axis, v_eye) * std::sin(theta);
Defines the macro ASSERT.
#define ASSERT(condition)
const Position & getPos3DAxes() const
const Position & getPos() const
void lookAt(const Position &)
void lookAt3DAxes(const Position &)
void endTransform(bool keep)
QMatrix4x4 matModel3DAxes
void setAspectRatio(float)
void setBgColor(QColor const &)
enum RealSpace::Canvas::@2 mouseButton
void wheelEvent(QWheelEvent *)
void setProgram(Program *)
QMetaObject::Connection modelUpdated
QVector3D unproject(QPoint const &)
QHash< Geometry const *, Buffer * > buffers
void mouseMoveEvent(QMouseEvent *)
bool isInitialized() const
void mousePressEvent(QMouseEvent *)
void mouseReleaseEvent(QMouseEvent *)
void releaseBuffer(Geometry const *)
void horizontalCameraTurn(float angle)
void draw(QColor const &, QMatrix4x4 const &, Geometry const &)
void verticalCameraTurn(float angle)
void deletingGeometry(Geometry const *)
void updated(bool withEye)
Camera::Position defCamPos
void draw(Canvas &) const
void drawBlend(Canvas &) const
void setMatModel(QMatrix4x4 const &)
void setAxis(bool const &)
float dot(const Vector3D &v1, const Vector3D &v2)
Vector3D cross(const Vector3D &v1, const Vector3D &v2)
GeometryStore & geometryStore()
Vector3D normalized() const