22 #include <Qt3DCore/QEntity>
23 #include <Qt3DExtras/Qt3DWindow>
24 #include <Qt3DExtras/QText2DEntity>
25 #include <Qt3DRender/QCamera>
26 #include <Qt3DRender/QViewport>
27 #include <Qt3DRender/QPickEvent>
28 #include <Qt3DRender/QScreenRayCaster>
32 #include <Qt3DRender/QLayer>
33 #include <Qt3DRender/QBuffer>
34 #include <Qt3DRender/QGeometryRenderer>
36 #include <QtWidgets/QMenu>
69 Qgs3DAxis( Qt3DExtras::Qt3DWindow *parentWindow, Qt3DCore::QEntity *parent3DScene,
101 void setAxisViewportPosition(
int axisViewportSize, Qt::AnchorPoint axisViewportVertPos, Qt::AnchorPoint axisViewportHorizPos );
129 QVector3D from3dTo2dLabelPosition(
const QVector3D &sourcePos,
130 Qt3DRender::QCamera *sourceCamera, Qt3DRender::QViewport *sourceViewport,
131 Qt3DRender::QCamera *destCamera, Qt3DRender::QViewport *destViewport,
132 const QSize &destSize );
136 void onCameraUpdate( );
137 void onAxisViewportSizeUpdate(
int val = 0 );
140 void onTouchedByRay(
const Qt3DRender::QAbstractRayCaster::Hits &hits );
142 void onAxisHorizPositionChanged( Qt::AnchorPoint pos );
143 void onAxisVertPositionChanged( Qt::AnchorPoint pos );
144 void onCameraViewChange(
float pitch,
float yaw );
146 void onCameraViewChangeHome( ) { onCameraViewChange( 45.0, 45.0 ); }
147 void onCameraViewChangeTop( ) {onCameraViewChange( 0.0, 90.0 );}
148 void onCameraViewChangeNorth( ) {onCameraViewChange( 90.0, 180.0 );}
149 void onCameraViewChangeEast( ) {onCameraViewChange( 90.0, 90.0 );}
150 void onCameraViewChangeSouth( ) {onCameraViewChange( 90.0, 0.0 );}
151 void onCameraViewChangeWest( ) {onCameraViewChange( 90.0, -90.0 );}
152 void onCameraViewChangeBottom() {onCameraViewChange( 180.0, 0.0 );}
157 void createAxisScene();
158 void createAxis( Qt::Axis axis );
160 void setEnableCube(
bool show );
161 void setEnableAxis(
bool show );
162 void updateAxisLabelPosition();
164 Qt3DRender::QViewport *constructAxisViewport( Qt3DCore::QEntity *parent3DScene );
165 Qt3DRender::QViewport *constructLabelViewport( Qt3DCore::QEntity *parent3DScene,
const QRectF &parentViewportSize );
167 Qt3DExtras::QText2DEntity *addCubeText(
const QString &text,
float textHeight,
float textWidth,
const QFont &f,
const QMatrix4x4 &rotation,
const QVector3D &translation );
170 void init3DObjectPicking( );
171 bool eventFilter( QObject *watched, QEvent *event )
override;
174 void displayMenuAt(
const QPoint &position );
177 Qt3DExtras::Qt3DWindow *mParentWindow =
nullptr;
181 float mCylinderLength = 40.0f;
182 int mAxisViewportSize = 4.0 * mCylinderLength;
183 Qt::AnchorPoint mAxisViewportVertPos = Qt::AnchorPoint::AnchorTop;
184 Qt::AnchorPoint mAxisViewportHorizPos = Qt::AnchorPoint::AnchorRight;
187 Qt3DCore::QEntity *mAxisSceneEntity =
nullptr;
188 Qt3DRender::QLayer *mAxisSceneLayer =
nullptr;
189 Qt3DRender::QCamera *mAxisCamera =
nullptr;
190 Qt3DRender::QViewport *mAxisViewport =
nullptr;
193 Qt3DCore::QEntity *mAxisRoot =
nullptr;
194 Qt3DCore::QEntity *mCubeRoot =
nullptr;
195 QList<Qt3DExtras::QText2DEntity *> mCubeLabels;
197 Qt3DExtras::QText2DEntity *mTextX =
nullptr;
198 Qt3DExtras::QText2DEntity *mTextY =
nullptr;
199 Qt3DExtras::QText2DEntity *mTextZ =
nullptr;
200 QVector3D mTextCoordX;
201 QVector3D mTextCoordY;
202 QVector3D mTextCoordZ;
203 Qt3DCore::QTransform *mTextTransformX =
nullptr;
204 Qt3DCore::QTransform *mTextTransformY =
nullptr;
205 Qt3DCore::QTransform *mTextTransformZ =
nullptr;
207 QVector3D mPreviousVector;
209 Qt3DRender::QCamera *mTwoDLabelCamera =
nullptr;
210 Qt3DCore::QEntity *mTwoDLabelSceneEntity =
nullptr;
211 Qt3DRender::QViewport *mTwoDLabelViewport =
nullptr;
214 Qt3DRender::QScreenRayCaster *mScreenRayCaster =
nullptr;
215 QPoint mLastClickedPos;
216 Qt::MouseButton mLastClickedButton;
217 QCursor mPreviousCursor = Qt::ArrowCursor;
218 QMenu *mMenu =
nullptr;
243 void setVertices(
const QList<QVector3D> &vertices );
246 Qt3DRender::QGeometry *mGeom =
nullptr;
247 Qt3DRender::QAttribute *mPositionAttribute =
nullptr;
248 Qt3DRender::QBuffer *mVertexBuffer =
nullptr;
251 #endif // QGS3DAXIS_H