diff --git a/ApplicationComponents/CMakeLists.txt b/ApplicationComponents/CMakeLists.txt index 0d73917bf55112535b90df219248149a639883aa..2530060dcab226311263cca86896cb1ce63e80cf 100644 --- a/ApplicationComponents/CMakeLists.txt +++ b/ApplicationComponents/CMakeLists.txt @@ -32,6 +32,11 @@ add_library(lqApplicationComponents SaveAndLoadLidarState/lqLoadLidarStateReaction.h SaveAndLoadLidarState/lqLidarStateDialog.cxx SaveAndLoadLidarState/lqLidarStateDialog.h + LidarCameraToolbar/lqLidarCameraReaction.cxx + LidarCameraToolbar/lqLidarCameraReaction.h + LidarCameraToolbar/lqLidarCameraToolbar.cxx + LidarCameraToolbar/lqLidarCameraToolbar.h + LidarCameraToolbar/lqLidarCameraToolbar.ui lqResources.qrc ) target_include_directories(lqApplicationComponents PUBLIC @@ -39,6 +44,7 @@ target_include_directories(lqApplicationComponents PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ctk/ ${CMAKE_CURRENT_SOURCE_DIR}/SaveAndLoadLidarState/ + ${CMAKE_CURRENT_SOURCE_DIR}/LidarCameraToolbar/ ${CMAKE_CURRENT_BINARY_DIR} ) target_sources(lqApplicationComponents PUBLIC diff --git a/ApplicationComponents/Icons/pqResetCamera.png b/ApplicationComponents/Icons/pqResetCamera.png new file mode 100644 index 0000000000000000000000000000000000000000..26fd199b247575f2411a1013e181b977f9f078da Binary files /dev/null and b/ApplicationComponents/Icons/pqResetCamera.png differ diff --git a/ApplicationComponents/Icons/pqRotateCameraCCW.png b/ApplicationComponents/Icons/pqRotateCameraCCW.png new file mode 100644 index 0000000000000000000000000000000000000000..f2567f6822440f4640a9806ef963d3ad05cc9db9 Binary files /dev/null and b/ApplicationComponents/Icons/pqRotateCameraCCW.png differ diff --git a/ApplicationComponents/Icons/pqRotateCameraCW.png b/ApplicationComponents/Icons/pqRotateCameraCW.png new file mode 100644 index 0000000000000000000000000000000000000000..9c2555f2088605baad75251d7930935c3f87329a Binary files /dev/null and b/ApplicationComponents/Icons/pqRotateCameraCW.png differ diff --git a/ApplicationComponents/Icons/pqXMinus.png b/ApplicationComponents/Icons/pqXMinus.png new file mode 100644 index 0000000000000000000000000000000000000000..c6ef7ce3881eb402384efbde55dd7601e2ed95d1 Binary files /dev/null and b/ApplicationComponents/Icons/pqXMinus.png differ diff --git a/ApplicationComponents/Icons/pqXPlus.png b/ApplicationComponents/Icons/pqXPlus.png new file mode 100644 index 0000000000000000000000000000000000000000..b8f46e28e1370aff7babe8e6ffbca3033c874982 Binary files /dev/null and b/ApplicationComponents/Icons/pqXPlus.png differ diff --git a/ApplicationComponents/Icons/pqYMinus.png b/ApplicationComponents/Icons/pqYMinus.png new file mode 100644 index 0000000000000000000000000000000000000000..7216239eb4e2d03769cabb77fa6b9b7f749f23b0 Binary files /dev/null and b/ApplicationComponents/Icons/pqYMinus.png differ diff --git a/ApplicationComponents/Icons/pqYPlus.png b/ApplicationComponents/Icons/pqYPlus.png new file mode 100644 index 0000000000000000000000000000000000000000..76393488b07567caf8bcfb059635d9b17fd7390b Binary files /dev/null and b/ApplicationComponents/Icons/pqYPlus.png differ diff --git a/ApplicationComponents/Icons/pqZMinus.png b/ApplicationComponents/Icons/pqZMinus.png new file mode 100644 index 0000000000000000000000000000000000000000..71852198301762fbc9191bfadbd41176b4962cbf Binary files /dev/null and b/ApplicationComponents/Icons/pqZMinus.png differ diff --git a/ApplicationComponents/Icons/pqZPlus.png b/ApplicationComponents/Icons/pqZPlus.png new file mode 100644 index 0000000000000000000000000000000000000000..53c4f4ec1e19c55022813c1098c6b9aef01a54be Binary files /dev/null and b/ApplicationComponents/Icons/pqZPlus.png differ diff --git a/ApplicationComponents/Icons/pqZoomToData.png b/ApplicationComponents/Icons/pqZoomToData.png new file mode 100644 index 0000000000000000000000000000000000000000..454ec3f2f9616fccda87e81b427bd004bb7a70a1 Binary files /dev/null and b/ApplicationComponents/Icons/pqZoomToData.png differ diff --git a/ApplicationComponents/Icons/pqZoomToSelection.png b/ApplicationComponents/Icons/pqZoomToSelection.png new file mode 100644 index 0000000000000000000000000000000000000000..ec6af6c0d1d16ab8366493eda941e6a3097f6359 Binary files /dev/null and b/ApplicationComponents/Icons/pqZoomToSelection.png differ diff --git a/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.cxx b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.cxx new file mode 100644 index 0000000000000000000000000000000000000000..b1adfbf3c9d8e05e8dbafca45e4f8bb96166d897 --- /dev/null +++ b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.cxx @@ -0,0 +1,109 @@ +#include "lqLidarCameraReaction.h" + +#include <pqActiveObjects.h> +#include <pqApplicationCore.h> +#include <pqRenderView.h> + +//----------------------------------------------------------------------------- +lqLidarCameraReaction::lqLidarCameraReaction(QAction *action, pqCameraReaction::Mode mode) + : Superclass(action, mode) +{ + this->ReactionMode = mode; +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::onTriggered() +{ + switch (this->ReactionMode) + { + case RESET_CAMERA: + this->resetCamera(); + break; + + case pqCameraReaction::Mode::RESET_POSITIVE_X: + this->ResetLidarPositiveX(); + break; + + case pqCameraReaction::Mode::RESET_POSITIVE_Y: + this->ResetLidarPositiveY(); + break; + + case pqCameraReaction::Mode::RESET_POSITIVE_Z: + this->ResetLidarPositiveZ(); + break; + + case pqCameraReaction::Mode::RESET_NEGATIVE_X: + this->ResetLidarNegativeX(); + break; + + case pqCameraReaction::Mode::RESET_NEGATIVE_Y: + this->ResetLidarNegativeY(); + break; + + case pqCameraReaction::Mode::RESET_NEGATIVE_Z: + this->ResetLidarNegativeZ(); + break; + + case pqCameraReaction::Mode::ZOOM_TO_DATA: + this->zoomToData(); + break; + + case pqCameraReaction::Mode::ROTATE_CAMERA_CW: + this->rotateCamera(-90.0); + break; + + case pqCameraReaction::Mode::ROTATE_CAMERA_CCW: + this->rotateCamera(90.0); + break; + } +} + +void lqLidarCameraReaction::ResetCenterOfRotationOnLidarCenter() +{ + pqRenderView* rm = qobject_cast<pqRenderView*>(pqActiveObjects::instance().activeView()); + double center[3] = {0, 0, 0}; + rm->setCenterOfRotation(center); + rm->render(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarPositiveX() +{ + pqCameraReaction::resetDirection(1, 0, 0, 0, 0, 1); + this->ResetCenterOfRotationOnLidarCenter(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarNegativeX() +{ + pqCameraReaction::resetDirection(-1, 0, 0, 0, 0, 1); + this->ResetCenterOfRotationOnLidarCenter(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarPositiveY() +{ + pqCameraReaction::resetDirection(0, 1, 0, 0, 0, 1); + this->ResetCenterOfRotationOnLidarCenter(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarNegativeY() +{ + pqCameraReaction::resetDirection(0, -1, 0, 0, 0, 1); + this->ResetCenterOfRotationOnLidarCenter(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarPositiveZ() +{ + pqCameraReaction::resetDirection(0, 0, 1, 0, 1, 0); + this->ResetCenterOfRotationOnLidarCenter(); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraReaction::ResetLidarNegativeZ() +{ + pqCameraReaction::resetDirection(0, 0, -1, 0, 1, 0); + this->ResetCenterOfRotationOnLidarCenter(); +} diff --git a/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.h b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.h new file mode 100644 index 0000000000000000000000000000000000000000..1468a28093204781f54265ebb61f0eac2a763fae --- /dev/null +++ b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraReaction.h @@ -0,0 +1,38 @@ +#ifndef lqLidarCameraReaction_h +#define lqLidarCameraReaction_h + +#include <pqReaction.h> +#include <pqCameraReaction.h> +#include "lqapplicationcomponents_export.h" + +class LQAPPLICATIONCOMPONENTS_EXPORT lqLidarCameraReaction : public pqCameraReaction +{ + Q_OBJECT + typedef pqCameraReaction Superclass; + +public: + lqLidarCameraReaction(QAction* action, pqCameraReaction::Mode mode); + +public slots: + /** + * Called when the action is triggered. + */ + void onTriggered() override; + + void ResetLidarPositiveX(); + void ResetLidarPositiveY(); + void ResetLidarPositiveZ(); + void ResetLidarNegativeX(); + void ResetLidarNegativeY(); + void ResetLidarNegativeZ(); + +private: + Q_DISABLE_COPY(lqLidarCameraReaction) + + void ResetCenterOfRotationOnLidarCenter(); + + pqCameraReaction::Mode ReactionMode; + +}; + +#endif // lqLidarCameraReaction_h diff --git a/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.cxx b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3fdd3e233a6e64d0972b15d029664965b9dbceef --- /dev/null +++ b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.cxx @@ -0,0 +1,43 @@ +#include "lqLidarCameraToolbar.h" +#include "ui_lqLidarCameraToolbar.h" + +#include "pqActiveObjects.h" +#include "pqRenderViewSelectionReaction.h" + +#include "lqLidarCameraReaction.h" + +//----------------------------------------------------------------------------- +void lqLidarCameraToolbar::constructor() +{ + Ui::lqLidarCameraToolbar ui; + ui.setupUi(this); + new lqLidarCameraReaction(ui.actionLidarResetCamera, pqCameraReaction::RESET_CAMERA); + new lqLidarCameraReaction(ui.actionLidarZoomToData, pqCameraReaction::ZOOM_TO_DATA); + new lqLidarCameraReaction(ui.actionLidarPositiveX, pqCameraReaction::RESET_POSITIVE_X); + new lqLidarCameraReaction(ui.actionLidarNegativeX, pqCameraReaction::RESET_NEGATIVE_X); + new lqLidarCameraReaction(ui.actionLidarPositiveY, pqCameraReaction::RESET_POSITIVE_Y); + new lqLidarCameraReaction(ui.actionLidarNegativeY, pqCameraReaction::RESET_NEGATIVE_Y); + new lqLidarCameraReaction(ui.actionLidarPositiveZ, pqCameraReaction::RESET_POSITIVE_Z); + new lqLidarCameraReaction(ui.actionLidarNegativeZ, pqCameraReaction::RESET_NEGATIVE_Z); + new lqLidarCameraReaction(ui.actionLidarRotate90degCW, pqCameraReaction::ROTATE_CAMERA_CW); + new lqLidarCameraReaction(ui.actionLidarRotate90degCCW, pqCameraReaction::ROTATE_CAMERA_CCW); + + new pqRenderViewSelectionReaction( + ui.actionLidarZoomToBox, NULL, pqRenderViewSelectionReaction::ZOOM_TO_BOX); + + this->ZoomToDataAction = ui.actionLidarZoomToData; + this->ZoomToDataAction->setEnabled(pqActiveObjects::instance().activeSource() != 0); + + QObject::connect( + &pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)), this, SLOT(updateEnabledState())); + QObject::connect(&pqActiveObjects::instance(), SIGNAL(sourceChanged(pqPipelineSource*)), this, + SLOT(updateEnabledState())); +} + +//----------------------------------------------------------------------------- +void lqLidarCameraToolbar::updateEnabledState() +{ + pqView* view = pqActiveObjects::instance().activeView(); + pqPipelineSource* source = pqActiveObjects::instance().activeSource(); + this->ZoomToDataAction->setEnabled(source && view); +} diff --git a/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.h b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.h new file mode 100644 index 0000000000000000000000000000000000000000..07117c093137bea6b48f26022dc7e32bc1a84372 --- /dev/null +++ b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.h @@ -0,0 +1,43 @@ +#ifndef lqLidarCameraToolbar_h +#define lqLidarCameraToolbar_h + +#include "lqapplicationcomponents_export.h" +#include <QToolBar> + +/** +* lqLidarCameraToolbar is the toolbar that has icons for resetting camera +* orientations as well as zoom-to-data and zoom-to-box. +* This class is a rewrite of the paraview class "pqCameraToolbar" +* more specific to the use of lidar data +* +* As an example : +* At the "set direction to x" the center of rotation was reset the the center of the data +* In case of lidar data we prefer to let he center at (0, 0, 0) = the center of the lidar +*/ +class LQAPPLICATIONCOMPONENTS_EXPORT lqLidarCameraToolbar : public QToolBar +{ + Q_OBJECT + typedef QToolBar Superclass; + +public: + lqLidarCameraToolbar(const QString& title, QWidget* parentObject = nullptr) + : Superclass(title, parentObject) + { + this->constructor(); + } + lqLidarCameraToolbar(QWidget* parentObject = nullptr) + : Superclass(parentObject) + { + this->constructor(); + } + +private slots: + void updateEnabledState(); + +private: + Q_DISABLE_COPY(lqLidarCameraToolbar) + void constructor(); + QAction* ZoomToDataAction; +}; + +#endif // lqLidarCameraToolbar_h diff --git a/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.ui b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.ui new file mode 100644 index 0000000000000000000000000000000000000000..e77751c7b71536339daf092d80128a68761ce16d --- /dev/null +++ b/ApplicationComponents/LidarCameraToolbar/lqLidarCameraToolbar.ui @@ -0,0 +1,248 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>lqLidarCameraToolbar</class> + <widget class="QToolBar" name="lqLidarCameraToolbar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>336</width> + <height>42</height> + </rect> + </property> + <property name="windowTitle"> + <string>Camera Controls</string> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <action name="actionLidarResetCamera"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqResetCamera.png</normaloff>:/lqResources/Icons/pqResetCamera.png</iconset> + </property> + <property name="text"> + <string>&Reset</string> + </property> + <property name="iconText"> + <string>Reset Camera</string> + </property> + <property name="statusTip"> + <string>Reset Camera</string> + </property> + </action> + <action name="actionLidarPositiveX"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqXPlus.png</normaloff>:/lqResources/Icons/pqXPlus.png</iconset> + </property> + <property name="text"> + <string>+X</string> + </property> + <property name="toolTip"> + <string>Set view direction to +X</string> + </property> + <property name="statusTip"> + <string>Set view direction to +X</string> + </property> + <property name="whatsThis"> + <string>Set view direction to +X</string> + </property> + </action> + <action name="actionLidarNegativeX"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqXMinus.png</normaloff>:/lqResources/Icons/pqXMinus.png</iconset> + </property> + <property name="text"> + <string>-X</string> + </property> + <property name="toolTip"> + <string>Set view direction to -X</string> + </property> + <property name="statusTip"> + <string>Set view direction to -X</string> + </property> + <property name="whatsThis"> + <string>Set view direction to -X</string> + </property> + </action> + <action name="actionLidarPositiveY"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqYPlus.png</normaloff>:/lqResources/Icons/pqYPlus.png</iconset> + </property> + <property name="text"> + <string>+Y</string> + </property> + <property name="toolTip"> + <string>Set view direction to +Y</string> + </property> + <property name="statusTip"> + <string>Set view direction to +Y</string> + </property> + <property name="whatsThis"> + <string>Set view direction to +Y</string> + </property> + </action> + <action name="actionLidarNegativeY"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqYMinus.png</normaloff>:/lqResources/Icons/pqYMinus.png</iconset> + </property> + <property name="text"> + <string>-Y</string> + </property> + <property name="toolTip"> + <string>Set view direction to -Y</string> + </property> + <property name="statusTip"> + <string>Set view direction to -Y</string> + </property> + <property name="whatsThis"> + <string>Set view direction to -Y</string> + </property> + </action> + <action name="actionLidarPositiveZ"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqZPlus.png</normaloff>:/lqResources/Icons/pqZPlus.png</iconset> + </property> + <property name="text"> + <string>+Z</string> + </property> + <property name="toolTip"> + <string>Set view direction to +Z</string> + </property> + <property name="statusTip"> + <string>Set view direction to +Z</string> + </property> + <property name="whatsThis"> + <string>Set view direction to +Z</string> + </property> + </action> + <action name="actionLidarNegativeZ"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqZMinus.png</normaloff>:/lqResources/Icons/pqZMinus.png</iconset> + </property> + <property name="text"> + <string>-Z</string> + </property> + <property name="toolTip"> + <string>Set view direction to -Z</string> + </property> + <property name="statusTip"> + <string>Set view direction to -Z</string> + </property> + <property name="whatsThis"> + <string>Set view direction to -Z</string> + </property> + </action> + <action name="actionLidarRotate90degCW"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqRotateCameraCW.png</normaloff>:/lqResources/Icons/pqRotateCameraCW.png</iconset> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip"> + <string>Rotate 90° clockwise</string> + </property> + <property name="statusTip"> + <string>Rotate 90° clockwise</string> + </property> + <property name="whatsThis"> + <string>Rotate 90° clockwise</string> + </property> + </action> + <action name="actionLidarRotate90degCCW"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqRotateCameraCCW.png</normaloff>:/lqResources/Icons/pqRotateCameraCCW.png</iconset> + </property> + <property name="text"> + <string></string> + </property> + <property name="toolTip"> + <string>Rotate 90° counterclockwise</string> + </property> + <property name="statusTip"> + <string>Rotate 90° counterclockwise</string> + </property> + <property name="whatsThis"> + <string>Rotate 90° counterclockwise</string> + </property> + </action> + <action name="actionLidarZoomToBox"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqZoomToSelection.png</normaloff>:/lqResources/Icons/pqZoomToSelection.png</iconset> + </property> + <property name="text"> + <string>Zoom to Box</string> + </property> + <property name="statusTip"> + <string>Zoom to Box</string> + </property> + </action> + <action name="actionLidarZoomToData"> + <property name="text"> + <string>ZTD</string> + </property> + <property name="toolTip"> + <string>Zoom To Data</string> + </property> + <property name="icon"> + <iconset resource="../lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqZoomToData.png</normaloff>:/lqResources/Icons/pqZoomToData.png</iconset> + </property> + </action> + <addaction name="actionLidarResetCamera"/> + <addaction name="actionLidarZoomToData"/> + <addaction name="actionLidarZoomToBox"/> + <addaction name="actionLidarPositiveX"/> + <addaction name="actionLidarNegativeX"/> + <addaction name="actionLidarPositiveY"/> + <addaction name="actionLidarNegativeY"/> + <addaction name="actionLidarPositiveZ"/> + <addaction name="actionLidarNegativeZ"/> + <addaction name="actionLidarRotate90degCW"/> + <addaction name="actionLidarRotate90degCCW"/> + </widget> + <resources> + <include location="../lqResources.qrc"/> + </resources> + <connections/> +</ui> diff --git a/ApplicationComponents/lqResources.qrc b/ApplicationComponents/lqResources.qrc index c8b901724c37b363bb68f22c4c448c96f62579ce..4f936c2a5623658f87cec9b105a28ec947bdfdf3 100644 --- a/ApplicationComponents/lqResources.qrc +++ b/ApplicationComponents/lqResources.qrc @@ -2,5 +2,16 @@ <qresource prefix="/lqResources"> <file>Icons/pqSaveState.png</file> <file>Icons/pqLoadState.png</file> + <file>Icons/pqXMinus.png</file> + <file>Icons/pqXPlus.png</file> + <file>Icons/pqYMinus.png</file> + <file>Icons/pqYPlus.png</file> + <file>Icons/pqZMinus.png</file> + <file>Icons/pqZPlus.png</file> + <file>Icons/pqResetCamera.png</file> + <file>Icons/pqRotateCameraCCW.png</file> + <file>Icons/pqRotateCameraCW.png</file> + <file>Icons/pqZoomToData.png</file> + <file>Icons/pqZoomToSelection.png</file> </qresource> </RCC>