diff --git a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx index 9b92f6f4b32c9acc2433a7075bb9845e560579dc..45565356e0b74fd3a573ca11d690decce2145ade 100644 --- a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx +++ b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.cxx @@ -30,16 +30,6 @@ lqLoadLidarStateReaction::lqLoadLidarStateReaction(QAction *action) //----------------------------------------------------------------------------- void lqLoadLidarStateReaction::onTriggered() { - // Get the Lidar state file - QString LidarStateFile = QFileDialog::getOpenFileName(nullptr, - QString("Choose the lidar state file to load on the first lidar"), - "", QString("json (*.json)")); - - if(LidarStateFile.isEmpty()) - { - return; - } - // Get the first lidar source std::vector<vtkSMProxy*> lidarProxys = GetLidarsProxy(); @@ -54,7 +44,21 @@ void lqLoadLidarStateReaction::onTriggered() QMessageBox::warning(nullptr, tr(""), tr("Multiple lidars sources found, only the first one will be updated") ); } - vtkSMProxy * lidarCurrentProxy = lidarProxys[0]; + lqLoadLidarStateReaction::LoadLidarState(lidarProxys[0]); +} + +//----------------------------------------------------------------------------- +void lqLoadLidarStateReaction::LoadLidarState(vtkSMProxy * lidarCurrentProxy) +{ + // Get the Lidar state file + QString LidarStateFile = QFileDialog::getOpenFileName(nullptr, + QString("Choose the lidar state file to load on the first lidar"), + "", QString("json (*.json)")); + + if(LidarStateFile.isEmpty()) + { + return; + } // Read and get information of the JSON file Json::Value contents; @@ -73,7 +77,7 @@ void lqLoadLidarStateReaction::onTriggered() std::vector<propertyInfo> propertyInfo; try { - this->ParseJsonContent(contents, "",propertyInfo); + ParseJsonContent(contents, "",propertyInfo); } catch(std::exception e) { diff --git a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.h b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.h index db64744050fde76714cd6ccc9b672577ff090dc4..ba5bc72998609c07951da4cbba289d52ddca612e 100644 --- a/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.h +++ b/ApplicationComponents/SaveAndLoadLidarState/lqLoadLidarStateReaction.h @@ -25,6 +25,8 @@ class LQAPPLICATIONCOMPONENTS_EXPORT lqLoadLidarStateReaction : public pqReactio public: lqLoadLidarStateReaction(QAction* action); + static void LoadLidarState(vtkSMProxy * lidarCurrentProxy); + /** * @brief UpdateProxyProperty set the values to the property "propNameToFind" of the proxy * If the property is not found in the proxy, a message is displayed but nothing is done. @@ -55,7 +57,7 @@ private: * @param ObjectName name of the current proxy * @param propertyInfo vector to write information (name, value) of the found properties */ - void ParseJsonContent(Json::Value contents, std::string ObjectName, std::vector<propertyInfo>& propertyInfo); + static void ParseJsonContent(Json::Value contents, std::string ObjectName, std::vector<propertyInfo>& propertyInfo); }; diff --git a/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.cxx b/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.cxx index 95ca07cd6425e24b2eb7f57dff3f8d0ef60108d9..ec506124b182a90a571242b28b43aad14de79d66 100644 --- a/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.cxx +++ b/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.cxx @@ -28,17 +28,6 @@ lqSaveLidarStateReaction::lqSaveLidarStateReaction(QAction *action) //----------------------------------------------------------------------------- void lqSaveLidarStateReaction::onTriggered() { - // Save Lidar Save information file - QString defaultFileName = QString("SaveLidarInformation.json"); - QString StateFile = QFileDialog::getSaveFileName(nullptr, - QString("File to save the first lidar information:"), - defaultFileName, QString("json (*.json)")); - - if(StateFile.isEmpty()) - { - return; - } - // Get the first lidar source pqServerManagerModel* smmodel = pqApplicationCore::instance()->getServerManagerModel(); if(smmodel == nullptr) @@ -67,6 +56,23 @@ void lqSaveLidarStateReaction::onTriggered() return; } + lqSaveLidarStateReaction::SaveLidarState(lidarProxy); + +} + +//----------------------------------------------------------------------------- +void lqSaveLidarStateReaction::SaveLidarState(vtkSMProxy * lidarProxy) +{ + // Save Lidar Save information file + QString defaultFileName = QString("SaveLidarInformation.json"); + QString StateFile = QFileDialog::getSaveFileName(nullptr, + QString("File to save the first lidar information:"), + defaultFileName, QString("json (*.json)")); + + if(StateFile.isEmpty()) + { + return; + } std::vector<propertyInfo> propertiesInfo; constructPropertiesInfo(lidarProxy, propertiesInfo); @@ -174,7 +180,7 @@ void lqSaveLidarStateReaction::constructPropertiesInfo(vtkSMProxy * lidarProxy, // We want all specific properties of a proxy stick together for(unsigned int p = 0; p < proxysToCompute.size(); p++) { - this->constructPropertiesInfo(proxysToCompute[p], propertiesVector); + constructPropertiesInfo(proxysToCompute[p], propertiesVector); } } diff --git a/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.h b/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.h index 23981b5b5ad355b2357f0c08cc165fb13323635a..4f5d69356e2b0faf5fd26671bbe37a90b416bc13 100644 --- a/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.h +++ b/ApplicationComponents/SaveAndLoadLidarState/lqSaveLidarStateReaction.h @@ -25,6 +25,9 @@ class LQAPPLICATIONCOMPONENTS_EXPORT lqSaveLidarStateReaction : public pqReactio public: lqSaveLidarStateReaction(QAction* action); + static void SaveLidarState(vtkSMProxy * lidarProxy); + + public slots: /** * Called when the action is triggered. @@ -40,7 +43,7 @@ private: * @param lidarProxy proxy to extract the properties * @param propertiesVector contains all the properties (names, value) of the current proxy and ots sub-proxy. */ - void constructPropertiesInfo(vtkSMProxy * lidarProxy, std::vector<propertyInfo>& propertiesVector); + static void constructPropertiesInfo(vtkSMProxy * lidarProxy, std::vector<propertyInfo>& propertiesVector); /** * @brief getValueOfPropAsString get the values of a property @@ -48,7 +51,7 @@ private: * @return The std::vector containing the values of the property prop. * If the property is a not an array, only the first element is fill */ - std::vector<std::string> getValueOfPropAsString(vtkSMProperty * prop); + static std::vector<std::string> getValueOfPropAsString(vtkSMProperty * prop); }; diff --git a/ApplicationComponents/SensorWidget/lqSensorWidget.cxx b/ApplicationComponents/SensorWidget/lqSensorWidget.cxx index a0b7b6348ce653df3d621e82c775750b5f9451d3..88552c795b6230f253561fc74c94ac7d36483982 100644 --- a/ApplicationComponents/SensorWidget/lqSensorWidget.cxx +++ b/ApplicationComponents/SensorWidget/lqSensorWidget.cxx @@ -1,6 +1,9 @@ #include "lqSensorWidget.h" #include "ui_lqSensorWidget.h" +#include "lqLoadLidarStateReaction.h" +#include "lqSaveLidarStateReaction.h" + #include <pqApplicationCore.h> #include <pqPipelineSource.h> #include <pqObjectBuilder.h> @@ -34,6 +37,9 @@ lqSensorWidget::lqSensorWidget(QWidget *parent) : // create all connection this->connect(UI->close, SIGNAL(clicked()), this, SLOT(onClose())); this->connect(UI->calibrate, SIGNAL(clicked()), this, SLOT(onCalibrate())); + this->connect(UI->SaveLidarState, SIGNAL(clicked()), this, SLOT(onSaveLidarState())); + this->connect(UI->LoadLidarState, SIGNAL(clicked()), this, SLOT(onLoadLidarState())); + } //----------------------------------------------------------------------------- @@ -144,6 +150,24 @@ void lqSensorWidget::onShowHide() } } +//----------------------------------------------------------------------------- +void lqSensorWidget::onLoadLidarState() +{ + if (this->LidarSource) + { + lqLoadLidarStateReaction::LoadLidarState(this->LidarSource->getProxy()); + } +} + +//----------------------------------------------------------------------------- +void lqSensorWidget::onSaveLidarState() +{ + if (this->LidarSource) + { + lqSaveLidarStateReaction::SaveLidarState(this->LidarSource->getProxy()); + } +} + //----------------------------------------------------------------------------- void lqSensorWidget::deleteSource(pqPipelineSource *src) { diff --git a/ApplicationComponents/SensorWidget/lqSensorWidget.h b/ApplicationComponents/SensorWidget/lqSensorWidget.h index bd548970f161d4997662769a37477f78b5477fb0..860644d719315393d5b34ddaa507dfb58e29244d 100644 --- a/ApplicationComponents/SensorWidget/lqSensorWidget.h +++ b/ApplicationComponents/SensorWidget/lqSensorWidget.h @@ -44,7 +44,8 @@ class LQAPPLICATIONCOMPONENTS_EXPORT lqSensorWidget : public QWidget void onCalibrate(); void onClose(); void onShowHide(); - + void onSaveLidarState(); + void onLoadLidarState(); protected: Q_DISABLE_COPY(lqSensorWidget) diff --git a/ApplicationComponents/SensorWidget/lqSensorWidget.ui b/ApplicationComponents/SensorWidget/lqSensorWidget.ui index 534f2951370c1c96007ca7b50472a5494daf545f..e1921efc3313bf6737c53d5826694fb8989bfd0a 100644 --- a/ApplicationComponents/SensorWidget/lqSensorWidget.ui +++ b/ApplicationComponents/SensorWidget/lqSensorWidget.ui @@ -416,6 +416,28 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="SaveLidarState"> + <property name="icon"> + <iconset resource="../LVCore/ApplicationComponents/lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqSaveState.png</normaloff>:/lqResources/Icons/pqSaveState.png</iconset> + </property> + <property name="toolTip"> + <string>Save Lidar state</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="LoadLidarState"> + <property name="icon"> + <iconset resource="../LVCore/ApplicationComponents/lqResources.qrc"> + <normaloff>:/lqResources/Icons/pqLoadState.png</normaloff>:/lqResources/Icons/pqLoadState.png</iconset> + </property> + <property name="toolTip"> + <string>Load Lidar state</string> + </property> + </widget> + </item> <item> <spacer name="horizontalSpacer_2"> <property name="orientation">