16 #include "Base/Util/Assert.h"
22 #include <QMouseEvent>
31 if (QSysInfo::productType() ==
"osx")
37 if (QSysInfo::productType() ==
"osx")
42 const float rot_speed_h = 0.4f;
43 const float rot_speed_v = 0.4f;
46 const float cameraDefaultPosY = -200.0f;
47 const float cameraDefaultPosZ = 120.0f;
62 , m_isInitializedGL(false)
133 connect(context(), &QOpenGLContext::aboutToBeDestroyed,
this, &
Canvas::cleanup);
135 initializeOpenGLFunctions();
136 glEnable(GL_DEPTH_TEST);
137 glEnable(GL_CULL_FACE);
143 int w1 = qMax(1, w), h1 = qMax(1, h);
152 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
166 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
174 QMatrix4x4 matObject3DAxes;
175 matObject3DAxes.setToIdentity();
179 std::unique_ptr<Buffer3DAxes> buf3DAxes(
new Buffer3DAxes());
180 buf3DAxes->draw3DAxes();
189 float x = p.x(), y =
viewport.height() - p.y();
195 switch (e->button()) {
199 case Qt::RightButton:
217 float delta_x = e->pos().x() -
e_last.x();
218 float delta_y = e->pos().y() -
e_last.y();
255 if (e->angleDelta().y() < 0) {
277 for (
auto* b :
buffers.values())
394 float theta = angle *
static_cast<float>(M_PI / 180.0);
407 v_up3DAxes * (1 - std::cos(theta)) *
dot(v_axis3DAxes, v_eye3DAxes)
408 + v_eye3DAxes * std::cos(theta) +
cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
410 Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
425 + v_eye * std::cos(theta)
426 +
cross(v_axis, v_eye) * std::sin(theta);
439 float theta = angle *
static_cast<float>(M_PI / 180.0);
453 v_up3DAxes * (1 - std::cos(theta)) *
dot(v_axis3DAxes, v_eye3DAxes)
454 + v_eye3DAxes * std::cos(theta) +
cross(v_axis3DAxes, v_eye3DAxes) * std::sin(theta);
456 Camera::Position rotated_pos3DAxes(v_rot_eye3DAxes, v_ctr3DAxes, v_up3DAxes);
472 + v_eye * std::cos(theta)
473 +
cross(v_axis, v_eye) * std::sin(theta);
Buffer for drawing 3D Coordinate Axes on canvas.
void endTransform(bool keep)
void lookAt(const Position &)
camera position for 3D object
QMatrix4x4 matModel3DAxes
const Position & getPos() const
void lookAt3DAxes(const Position &)
camera position for 3D axes
const Position & getPos3DAxes() const
void setAspectRatio(float)
void mouseMoveEvent(QMouseEvent *) override
void mouseReleaseEvent(QMouseEvent *) override
void wheelEvent(QWheelEvent *) override
QVector3D unproject(QPoint const &)
QHash< Geometry const *, Buffer * > buffers
void draw(QColor const &, QMatrix4x4 const &, Geometry const &)
enum GUI::RealSpace::Canvas::@0 mouseButton
void mousePressEvent(QMouseEvent *) override
void initializeGL() override
void releaseBuffer(Geometry const *)
bool isInitialized() const
QMetaObject::Connection modelUpdated
void setBgColor(QColor const &)
void setProgram(Program *)
void verticalCameraTurn(float angle)
void horizontalCameraTurn(float angle)
void resizeGL(int, int) override
void deletingGeometry(Geometry const *)
void draw(Canvas &) const
void drawBlend(Canvas &) const
void updated(bool withEye)
Camera::Position defCamPos
default camera params
void setAxis(bool const &)
void setMatModel(QMatrix4x4 const &)
Vector3D cross(const Vector3D &v1, const Vector3D &v2)
float dot(const Vector3D &v1, const Vector3D &v2)
GeometryStore & geometryStore()
Vector3D normalized() const