16 #ifndef QGSCAMERACONTROLLER_H 17 #define QGSCAMERACONTROLLER_H 21 #include <Qt3DCore/QEntity> 38 Q_PROPERTY( Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged )
39 Q_PROPERTY( QRect viewport READ viewport WRITE setViewport NOTIFY viewportChanged )
53 void addTerrainPicker( Qt3DRender::QObjectPicker *picker );
55 void setCamera( Qt3DRender::QCamera *camera );
57 void setViewport(
const QRect &viewport );
59 void frameTriggered(
float dt );
62 void resetView(
float distance );
65 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
73 QDomElement writeXml( QDomDocument &doc )
const;
75 void readXml(
const QDomElement &elem );
78 void setCameraData(
float x,
float y,
float dist,
float pitch = 0,
float yaw = 0 );
84 void viewportChanged();
87 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
88 void onPickerMousePressed( Qt3DRender::QPickEvent *pick );
92 Qt3DRender::QCamera *mCamera =
nullptr;
96 float mLastPressedHeight = 0;
105 bool operator==(
const CameraData &other )
const 107 return x == other.x && y == other.y && dist == other.dist && pitch == other.pitch && yaw == other.yaw;
109 bool operator!=(
const CameraData &other )
const 114 void setCamera( Qt3DRender::QCamera *camera )
121 camera->setUpVector( QVector3D( 0, 0, -1 ) );
122 camera->setPosition( QVector3D( x, dist, y ) );
123 camera->setViewCenter( QVector3D( x, 0, y ) );
124 camera->rotateAboutViewCenter( QQuaternion::fromEulerAngles( pitch, yaw, 0 ) );
129 CameraData mCameraData;
134 QPoint mLastMousePos;
137 Qt3DInput::QMouseDevice *mMouseDevice =
nullptr;
139 Qt3DInput::QKeyboardDevice *mKeyboardDevice =
nullptr;
141 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
147 Qt3DInput::QLogicalDevice *mLogicalDevice =
nullptr;
149 Qt3DInput::QAction *mLeftMouseButtonAction =
nullptr;
150 Qt3DInput::QActionInput *mLeftMouseButtonInput =
nullptr;
152 Qt3DInput::QAction *mMiddleMouseButtonAction =
nullptr;
153 Qt3DInput::QActionInput *mMiddleMouseButtonInput =
nullptr;
155 Qt3DInput::QAction *mRightMouseButtonAction =
nullptr;
156 Qt3DInput::QActionInput *mRightMouseButtonInput =
nullptr;
158 Qt3DInput::QAction *mShiftAction =
nullptr;
159 Qt3DInput::QActionInput *mShiftInput =
nullptr;
161 Qt3DInput::QAction *mCtrlAction =
nullptr;
162 Qt3DInput::QActionInput *mCtrlInput =
nullptr;
164 Qt3DInput::QAxis *mWheelAxis =
nullptr;
165 Qt3DInput::QAnalogAxisInput *mMouseWheelInput =
nullptr;
167 Qt3DInput::QAxis *mTxAxis =
nullptr;
168 Qt3DInput::QAxis *mTyAxis =
nullptr;
169 Qt3DInput::QButtonAxisInput *mKeyboardTxPosInput =
nullptr;
170 Qt3DInput::QButtonAxisInput *mKeyboardTyPosInput =
nullptr;
171 Qt3DInput::QButtonAxisInput *mKeyboardTxNegInput =
nullptr;
172 Qt3DInput::QButtonAxisInput *mKeyboardTyNegInput =
nullptr;
175 #endif // QGSCAMERACONTROLLER_H 3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QRect viewport() const
Returns viewport rectangle.
3 Object that controls camera movement based on user input