Skip to content
Snippets Groups Projects
Commit 52f07527 authored by MelanieCarriere's avatar MelanieCarriere
Browse files

Merge branch 'AddLidarCameraToolbar' into 'master'

Add lidar camera toolbar

See merge request !139
parents f6480607 018b5c80
No related branches found
No related tags found
1 merge request!139Add lidar camera toolbar
Pipeline #199307 canceled
Pipeline: LidarView

#199308

    Showing
    with 498 additions and 0 deletions
    ...@@ -32,6 +32,11 @@ add_library(lqApplicationComponents ...@@ -32,6 +32,11 @@ add_library(lqApplicationComponents
    SaveAndLoadLidarState/lqLoadLidarStateReaction.h SaveAndLoadLidarState/lqLoadLidarStateReaction.h
    SaveAndLoadLidarState/lqLidarStateDialog.cxx SaveAndLoadLidarState/lqLidarStateDialog.cxx
    SaveAndLoadLidarState/lqLidarStateDialog.h SaveAndLoadLidarState/lqLidarStateDialog.h
    LidarCameraToolbar/lqLidarCameraReaction.cxx
    LidarCameraToolbar/lqLidarCameraReaction.h
    LidarCameraToolbar/lqLidarCameraToolbar.cxx
    LidarCameraToolbar/lqLidarCameraToolbar.h
    LidarCameraToolbar/lqLidarCameraToolbar.ui
    lqResources.qrc lqResources.qrc
    ) )
    target_include_directories(lqApplicationComponents PUBLIC target_include_directories(lqApplicationComponents PUBLIC
    ...@@ -39,6 +44,7 @@ target_include_directories(lqApplicationComponents PUBLIC ...@@ -39,6 +44,7 @@ target_include_directories(lqApplicationComponents PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/ctk/ ${CMAKE_CURRENT_SOURCE_DIR}/ctk/
    ${CMAKE_CURRENT_SOURCE_DIR}/SaveAndLoadLidarState/ ${CMAKE_CURRENT_SOURCE_DIR}/SaveAndLoadLidarState/
    ${CMAKE_CURRENT_SOURCE_DIR}/LidarCameraToolbar/
    ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
    ) )
    target_sources(lqApplicationComponents PUBLIC target_sources(lqApplicationComponents PUBLIC
    ......
    ApplicationComponents/Icons/pqResetCamera.png

    1.61 KiB

    ApplicationComponents/Icons/pqRotateCameraCCW.png

    1.8 KiB

    ApplicationComponents/Icons/pqRotateCameraCW.png

    1.86 KiB

    ApplicationComponents/Icons/pqXMinus.png

    1.67 KiB

    ApplicationComponents/Icons/pqXPlus.png

    1.68 KiB

    ApplicationComponents/Icons/pqYMinus.png

    1.58 KiB

    ApplicationComponents/Icons/pqYPlus.png

    1.65 KiB

    ApplicationComponents/Icons/pqZMinus.png

    1.6 KiB

    ApplicationComponents/Icons/pqZPlus.png

    1.65 KiB

    ApplicationComponents/Icons/pqZoomToData.png

    1.83 KiB

    ApplicationComponents/Icons/pqZoomToSelection.png

    1.68 KiB

    #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();
    }
    #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
    #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);
    }
    #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
    <?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>&amp;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>
    ...@@ -2,5 +2,16 @@ ...@@ -2,5 +2,16 @@
    <qresource prefix="/lqResources"> <qresource prefix="/lqResources">
    <file>Icons/pqSaveState.png</file> <file>Icons/pqSaveState.png</file>
    <file>Icons/pqLoadState.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> </qresource>
    </RCC> </RCC>
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment