diff --git a/.gitignore b/.gitignore index eb2142a9a074ee01d17168bf188fff7526f86339..fddd34687fb922092bbdce099e06f5cf4c3936ad 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ source/*/Test.h CMakeFiles CMakeCache.txt CMakeLists.txt.user* +*.autosave +*.orig *.o *.os diff --git a/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.cpp b/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.cpp index 755225ba5295711355c05192125ac32db5f60bb2..32f84fba31e1adb7cf859140c38925edc3e3c925 100644 --- a/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.cpp +++ b/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.cpp @@ -118,7 +118,7 @@ ArmarXMainWindow::ArmarXMainWindow(const armarx::ManagedIceObjectRegistryInterfa ui = new ::Ui::ArmarXMainWindow(); mutex3d.reset(new boost::recursive_mutex); - ArmarXWidgetInfoPtr viewerWidgetInfo(new ArmarXWidgetInfo(ArmarXWidgetController::createInstance<Viewer3DWidget>, Viewer3DWidget().getWidgetIcon(), QIcon())); + ArmarXWidgetInfoPtr viewerWidgetInfo(new ArmarXWidgetInfo(ArmarXWidgetController::createInstance<Viewer3DWidget>, Viewer3DWidget::GetWidgetIcon(), QIcon())); pluginCache.cacheWidget(ARMARX_VIEWER_NAME, viewerWidgetInfo); guiWindowBaseName = ARMARX_GUI_APPLICATION_NAME; @@ -134,14 +134,15 @@ ArmarXMainWindow::ArmarXMainWindow(const armarx::ManagedIceObjectRegistryInterfa tipDialog->setBlackListedStrings(mainSettings.value(CONFIG_BLACKLISTED_TIPS).toStringList()); ui->actionLoadLastConfig->setChecked(mainSettings.value(CONFIG_LOAD_LAST_CONFIG).toBool()); + addWidgetAction = new AddArmarXWidgetAction("", this, this); + connect(addWidgetAction, SIGNAL(clicked(QString, QString)), this, SLOT(createArmarXWidget(QString, QString)), Qt::UniqueConnection); + connect(ui->actionLoadPlugin, SIGNAL(triggered()), this, SLOT(pluginDialog())); connect(ui->actionSave_Gui, SIGNAL(triggered()), this, SLOT(saveGuiConfig())); connect(ui->actionLoad_Gui_Config, SIGNAL(triggered()), this, SLOT(loadGuiConfig())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionSave_Gui_as, SIGNAL(triggered()), this, SLOT(saveGuiConfigAs())); - // connect(ui->actionClear_tip_blacklist, SIGNAL(triggered()), this, SLOT(on_actionClear_tip_blacklist_triggered())); - // connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(on_actionAbout_triggered())); // EmergencyStop @@ -1090,7 +1091,7 @@ void ArmarXMainWindow::updateAvailableWidgetList() { ui->menuAdd_Widget->clear(); - QLineEdit* searchField = new QLineEdit(ui->menuAdd_Widget); + searchField = new QLineEdit(ui->menuAdd_Widget); searchField->setToolTip("Search and add a new widget from all loaded ArmarX Gui Plugins"); searchField->setMaximumWidth(250); searchField->setPlaceholderText("Widget Search"); @@ -1163,6 +1164,17 @@ void ArmarXMainWindow::updateAvailableWidgetList() ui->toolBar->addSeparator(); ui->toolBar->addWidget(searchField); + QIcon icon; + icon.addFile(QString::fromUtf8("://icons/edit-add.ico"), QSize(), QIcon::Normal, QIcon::Off); + openWidgetButton = new QToolButton(this); + openWidgetButton->setEnabled(false); + openWidgetButton->setIcon(icon); + openWidgetButton->setToolTip("Open selected widget"); + connect(openWidgetButton, SIGNAL(clicked()), this, SLOT(openWidgetButtonClicked()), Qt::UniqueConnection); + ui->toolBar->addWidget(openWidgetButton); + connect(searchField, SIGNAL(textChanged(QString)), this, SLOT(updateOpenWidgetButtonStatus(QString)), Qt::UniqueConnection); + + connect(searchField, SIGNAL(returnPressed()), this , SLOT(openWidgetButtonClicked()), Qt::UniqueConnection); auto favoriteWidgetNames = getFavoriteWidgets(); @@ -1173,8 +1185,6 @@ void ArmarXMainWindow::updateAvailableWidgetList() label->setToolTip("The favorites are generated from the usage frequency over the last X widget creations."); ui->toolBar->addWidget(label); } - - for (auto widgetName : favoriteWidgetNames) { if (actionList.contains(widgetName)) @@ -1288,6 +1298,14 @@ AddArmarXWidgetAction::~AddArmarXWidgetAction() void AddArmarXWidgetAction::triggered(QString widgetName) { + static std::chrono::high_resolution_clock::time_point lastTriggered {std::chrono::milliseconds{0}}; + static std::chrono::milliseconds triggerDeadTime {100}; + const auto now = std::chrono::high_resolution_clock::now(); + if (lastTriggered + triggerDeadTime > now) + { + return; + } + lastTriggered = now; if (widgetName.isEmpty()) { QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); @@ -1320,7 +1338,6 @@ void AddArmarXWidgetAction::addArmarXWidget() { dialogAccepted(); } - } void AddArmarXWidgetAction::dialogAccepted() @@ -1437,13 +1454,17 @@ void armarx::ArmarXMainWindow::on_actionOpen_Use_Case_triggered() } - -// Emergency Stop - - - - void armarx::ArmarXMainWindow::on_actionClear_plugin_cache_triggered() { pluginCache.clearCacheFile(); } + +void ArmarXMainWindow::updateOpenWidgetButtonStatus(QString widgetName) +{ + openWidgetButton->setEnabled(pluginCache.getAvailableWidgetNames().contains(widgetName)); +} + +void ArmarXMainWindow::openWidgetButtonClicked() +{ + addWidgetAction->triggered(searchField->text()); +} diff --git a/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.h b/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.h index e04ad8bbd18d4b9c9fdb644620b4b827e51697d3..180a6c93de5fcd88e0ae292cda23723b0b1ee901 100644 --- a/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.h +++ b/source/ArmarXGui/applications/ArmarXGui/ArmarXMainWindow.h @@ -54,6 +54,7 @@ class QScrollArea; class QSignalMapper; class QListWidgetItem; class QActionGroup; +class QLineEdit; namespace Ui { @@ -64,6 +65,7 @@ namespace Ui namespace armarx { class GuiUseCaseSelector; + class AddArmarXWidgetAction; class ArmarXDockWidget; @@ -161,6 +163,10 @@ namespace armarx void on_actionClear_plugin_cache_triggered(); + void updateOpenWidgetButtonStatus(QString widgetName); + + void openWidgetButtonClicked(); + private: /** * @brief updates the menu entry with the available widgets. @@ -231,7 +237,9 @@ namespace armarx QString splashscreenPrefix; GuiUseCaseSelector* guiUseCaseSelector; QStringList mainWidgets; - + QToolButton* openWidgetButton; + QLineEdit* searchField; + AddArmarXWidgetAction* addWidgetAction; boost::shared_ptr<boost::recursive_mutex> mutex3d; friend class WidgetNameDialog; diff --git a/source/ArmarXGui/applications/ArmarXGui/Widgets/EmergencyStopWidget.h b/source/ArmarXGui/applications/ArmarXGui/Widgets/EmergencyStopWidget.h index bd11a49269096e91c1ddddd6cc6024632e8b7636..0cc489653c6a03f341cda9817981e0f8229288fe 100644 --- a/source/ArmarXGui/applications/ArmarXGui/Widgets/EmergencyStopWidget.h +++ b/source/ArmarXGui/applications/ArmarXGui/Widgets/EmergencyStopWidget.h @@ -41,7 +41,7 @@ namespace armarx class ArmarXMainWindow; class EmergencyStopWidget : - public armarx::ArmarXComponentWidgetController, + public ArmarXComponentWidgetControllerTemplate<EmergencyStopWidget>, public armarx::EmergencyStopListener { Q_OBJECT @@ -71,10 +71,9 @@ namespace armarx EmergencyStopMasterInterfacePrx emergencyStopMasterPrx; - // ArmarXWidgetController interface public: - QString getWidgetName() const + static QString GetWidgetName() { return "EmergencyStopWidget"; } @@ -85,13 +84,6 @@ namespace armarx public: void reportEmergencyStopState(EmergencyStopState, const Ice::Current&); }; - typedef IceInternal::Handle <EmergencyStopWidget> EmergencyStopWidgetPtr; } - - - - - - #endif diff --git a/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.cpp b/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.cpp index 7fb5028b26db3846675a9bf25d7814389620a1ef..013708f506eb802e24da0923d54cf350131d1dd3 100644 --- a/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.cpp +++ b/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.cpp @@ -450,12 +450,6 @@ void Viewer3DWidget::configDialogLoadSettings() configDialogApplySettings(); } - -QIcon armarx::Viewer3DWidget::getWidgetIcon() const -{ - return QIcon(":icons/Outline-3D.png"); -} - QPointer<QWidget> Viewer3DWidget::getWidget() { if (!__widget) diff --git a/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.h b/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.h index f9e93c1bfb7219fac84419431b1954fbfabedd38..9cd0e99c2cd1b37e8202c6b21dfc123cd0369f4f 100644 --- a/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.h +++ b/source/ArmarXGui/applications/ArmarXGui/Widgets/ViewerWidget.h @@ -56,7 +56,11 @@ namespace armarx ~Viewer3DWidget(); // inherited from ArmarXWidgetController - QString getWidgetName() const + virtual QString getWidgetName() const override + { + return GetWidgetName(); + } + static QString GetWidgetName() { return ARMARX_VIEWER_NAME; } @@ -108,7 +112,14 @@ namespace armarx // ArmarXWidgetController interface public: - QIcon getWidgetIcon() const; + virtual QIcon getWidgetIcon() const override + { + return GetWidgetIcon(); + } + static QIcon GetWidgetIcon() + { + return QIcon(":icons/Outline-3D.png"); + } // ArmarXWidgetController interface public: diff --git a/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.cpp b/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.cpp index d0d879dce0e231c7c095520f1928a3bb5b760f8a..158b747dc1810d1d0eb8a3e7a0847b4f7046eae4 100644 --- a/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.cpp +++ b/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.cpp @@ -211,9 +211,3 @@ void ClockWidgetController::speedChanged(double newSpeed) timeServerPtr->setSpeed(newSpeed); } } - - -QIcon armarx::ClockWidgetController::getWidgetIcon() const -{ - return QIcon(":icons/Time-And-Date-Clock-icon.png"); -} diff --git a/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.h b/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.h index 2651f0d163f901a3a3296c600165872de055b9fc..84b3847e5d12f97844b8012cbe01db91c1201da4 100644 --- a/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.h +++ b/source/ArmarXGui/gui-plugins/ClockPlugin/ClockWidgetController.h @@ -59,7 +59,7 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT ClockWidgetController: - public armarx::ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<ClockWidgetController> { Q_OBJECT @@ -88,7 +88,7 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this class. */ - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Clock"; } @@ -137,7 +137,10 @@ namespace armarx // ArmarXWidgetController interface public: - QIcon getWidgetIcon() const; + static QIcon GetWidgetIcon() + { + return QIcon(":icons/Time-And-Date-Clock-icon.png"); + } }; } diff --git a/source/ArmarXGui/gui-plugins/ConditionViewerPlugin/ConditionViewerWidgetController.h b/source/ArmarXGui/gui-plugins/ConditionViewerPlugin/ConditionViewerWidgetController.h index 58f8ed8c6ce481ae1f61e6a3ed2292cf60892c64..7f49241e85e68740bb115101f2d157f5ce39962b 100644 --- a/source/ArmarXGui/gui-plugins/ConditionViewerPlugin/ConditionViewerWidgetController.h +++ b/source/ArmarXGui/gui-plugins/ConditionViewerPlugin/ConditionViewerWidgetController.h @@ -51,7 +51,7 @@ namespace armarx * \see ConditionViewerGuiPlugin */ class ARMARXCOMPONENT_IMPORT_EXPORT ConditionViewerWidgetController : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<ConditionViewerWidgetController> { Q_OBJECT public: @@ -65,7 +65,7 @@ namespace armarx // inherited from ArmarXWidget QPointer<QWidget> getWidget(); - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Observers.ConditionViewer"; } diff --git a/source/ArmarXGui/gui-plugins/IceProxy/IceProxyWidgetController.h b/source/ArmarXGui/gui-plugins/IceProxy/IceProxyWidgetController.h index f2ce1b6d45dbba82656830962d903a26ff187a86..c31101cc2e097e17593c48037420fea9fb3233ae 100644 --- a/source/ArmarXGui/gui-plugins/IceProxy/IceProxyWidgetController.h +++ b/source/ArmarXGui/gui-plugins/IceProxy/IceProxyWidgetController.h @@ -54,7 +54,7 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT IceProxyWidgetController: - public armarx::ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<IceProxyWidgetController> { Q_OBJECT @@ -72,18 +72,18 @@ namespace armarx /** * @see ArmarXWidgetController::loadSettings() */ - virtual void loadSettings(QSettings* settings){} + virtual void loadSettings(QSettings* settings) {} /** * @see ArmarXWidgetController::saveSettings() */ - virtual void saveSettings(QSettings* settings){} + virtual void saveSettings(QSettings* settings) {} /** * Returns the Widget name displayed in the ArmarXGui to create an * instance of this class. */ - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Meta.IceProxy"; } @@ -96,15 +96,15 @@ namespace armarx /** * \see armarx::Component::onConnectComponent() */ - virtual void onConnectComponent(){} + virtual void onConnectComponent() {} - void loadProxy(Ice::ObjectPrx prx); + void loadProxy(Ice::ObjectPrx prx); - private slots: - void on_pushButtonFinder_clicked(); - void on_pushButtonString_clicked(); + private slots: + void on_pushButtonFinder_clicked(); + void on_pushButtonString_clicked(); - private: + private: /** * Widget Form */ diff --git a/source/ArmarXGui/gui-plugins/LoggingPlugin/ArmarXLogViewer/LogViewer.h b/source/ArmarXGui/gui-plugins/LoggingPlugin/ArmarXLogViewer/LogViewer.h index 44f9ba18b7d425ffa08d29ac31704cd23fce4860..718adf3c05e484d864b0f101625c2daea59c793d 100644 --- a/source/ArmarXGui/gui-plugins/LoggingPlugin/ArmarXLogViewer/LogViewer.h +++ b/source/ArmarXGui/gui-plugins/LoggingPlugin/ArmarXLogViewer/LogViewer.h @@ -51,7 +51,7 @@ namespace armarx \see LoggingPlugin */ class ARMARXCOMPONENT_IMPORT_EXPORT LogViewer : - public ArmarXComponentWidgetController, + public ArmarXComponentWidgetControllerTemplate<LogViewer>, public Log { Q_OBJECT @@ -62,15 +62,15 @@ namespace armarx void loadSettings(QSettings* settings); void saveSettings(QSettings* settings); - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Meta.LogViewer"; } - virtual QIcon getWidgetIcon() const + static QIcon GetWidgetIcon() { return QIcon("://icons/papyrus.svg"); } - virtual QIcon getWidgetCategoryIcon() const + static QIcon GetWidgetCategoryIcon() { return QIcon("://icons/papyrus.svg"); } diff --git a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverItemModel.cpp b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverItemModel.cpp index 89ccb6f59eacb2af5c10905875e6793596e0bf14..0b40d3072739a11e79144df2bb004426ed3b2c42 100644 --- a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverItemModel.cpp +++ b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverItemModel.cpp @@ -102,7 +102,7 @@ QWidget* ObserverItemModel::getPropertiesWidget(const QModelIndex& index, QWidge // create widget DatafieldRefPtr ref = DatafieldRefPtr::dynamicCast(entry.identifier); - if (info && !entry.value->data || entry.value->data->ice_id() == "::armarx::VariantData") + if (info && (!entry.value->data || entry.value->data->ice_id() == "::armarx::VariantData")) { ARMARX_INFO << "Variant Factory for " << entry.typeName << " is missing - trying to load lib now"; auto lib = info->loadLibraryOfVariant(entry.typeName); diff --git a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverWidgetController.h b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverWidgetController.h index 74911a4c07257f485c8b29ee2ec828aef2fca7fc..041c05d21fbd0441ca114cd07afd671047e1f250 100644 --- a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverWidgetController.h +++ b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/ObserverWidgetController.h @@ -48,7 +48,7 @@ namespace armarx * Channels show their offered datafields with their type, current value and an live plot. * It is also possible to install filters for each datafield by right-clicking on the datafield and selecting * the desired filter. - * \see \ref Observers + * \see \ref Observers * \see \ref ObserverWidgetController */ @@ -56,7 +56,7 @@ namespace armarx * \class ObserverWidgetController */ class ARMARXCOMPONENT_IMPORT_EXPORT ObserverWidgetController : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<ObserverWidgetController> { Q_OBJECT public: @@ -69,15 +69,15 @@ namespace armarx // inherited from ArmarXWidget QPointer<QWidget> getWidget(); - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Observers.ObserverView"; } - virtual QIcon getWidgetIcon() const + static QIcon GetWidgetIcon() { return QIcon("://icons/binoculars.svg"); } - virtual QIcon getWidgetCategoryIcon() const + static QIcon GetWidgetCategoryIcon() { return QIcon("://icons/binoculars.svg"); } diff --git a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/widgets/VariantWidget.cpp b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/widgets/VariantWidget.cpp index 75bc6bf5f59286859e5a65adb05a31fe88657a4f..6f028ca3b9be8b05b84cfb1a459cfcc8e912f990 100644 --- a/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/widgets/VariantWidget.cpp +++ b/source/ArmarXGui/gui-plugins/ObserverPropertiesPlugin/widgets/VariantWidget.cpp @@ -44,12 +44,10 @@ void VariantWidget::setValue(const VariantPtr& variant) { VariantTypeId type = variant->getType(); QString valueString; - int valueEditWidth; if (variant->getInitialized()) { if (type == VariantType::Bool) { - valueEditWidth = 60; QString value("%1"); value = value.arg((variant->getBool() == 1)); valueString = value; @@ -57,7 +55,6 @@ void VariantWidget::setValue(const VariantPtr& variant) else if (type == VariantType::Float) { - valueEditWidth = 200; QString value("%1"); value = value.arg(variant->getFloat(), 0 , 'f', 2); valueString = value; @@ -65,7 +62,6 @@ void VariantWidget::setValue(const VariantPtr& variant) else if (type == VariantType::Double) { - valueEditWidth = 200; QString value("%1"); value = value.arg(variant->getDouble(), 0 , 'f', 2); valueString = value; @@ -73,7 +69,6 @@ void VariantWidget::setValue(const VariantPtr& variant) else if (type == VariantType::Int) { - valueEditWidth = 60; QString value("%1"); value = value.arg(variant->getInt()); valueString = value; @@ -81,7 +76,6 @@ void VariantWidget::setValue(const VariantPtr& variant) else if (type == VariantType::String) { - valueEditWidth = 200; QString value(variant->getString().c_str()); valueString = value; } diff --git a/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.cpp b/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.cpp index 57e253421f7eb6f107a4110425b1e33ed920d4f9..d156d3dfec696e6a7ffa552f719df72667e132e6 100644 --- a/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.cpp +++ b/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.cpp @@ -50,13 +50,9 @@ using namespace std; namespace armarx { - ArmarXPlotter::ArmarXPlotter() : - ArmarXComponentWidgetController(), startUpTime(QDateTime::currentDateTime()) { - - plotterController = QSharedPointer<PlotterController>::create(); setTag("Plotter"); ui.setupUi(getWidget()); @@ -66,7 +62,6 @@ namespace armarx plotterController->setGraphStyle(ui.CBgraphStyle->currentIndex()); ui.verticalLayout->insertWidget(0, plotterController->getPlotterWidget()); - } ArmarXPlotter::~ArmarXPlotter() @@ -74,19 +69,9 @@ namespace armarx // if(dialog && this->getState() == eManagedIceObjectInitialized) // getArmarXManager()->removeObjectNonBlocking(dialog); // delete dialog; - } - - - - - - - void ArmarXPlotter::onInitComponent() - { - - } + void ArmarXPlotter::onInitComponent() {} void ArmarXPlotter::onConnectComponent() { @@ -108,16 +93,12 @@ namespace armarx ARMARX_WARNING << "Failed to invoke setupCurves"; } - usingTopic("TopicReplayerListener"); - } - void ArmarXPlotter::onExitComponent() { // unsubscribeFromTopic("TopicReplayerListener"); - plotterController.clear(); } @@ -216,7 +197,7 @@ namespace armarx csvHeader = plotterController->getSelectedDatafieldsKeys(); logstream << "Timestamp"; - for (const auto & s : csvHeader) + for (const auto& s : csvHeader) { logstream << "," << s; } @@ -265,8 +246,6 @@ namespace armarx } } - - void ArmarXPlotter::saveSettings(QSettings* settings) { ScopedLock lock(dataMutex); @@ -292,8 +271,6 @@ namespace armarx ARMARX_VERBOSE << "Settings loaded"; } - - void ArmarXPlotter::logToFile(long timestamp, const std::map<std::string, VariantPtr>& dataMaptoAppend) { std::lock_guard<std::mutex> lock(fileMutex); @@ -313,10 +290,6 @@ namespace armarx logstream << dataMaptoAppend.at(f)->Variant::getOutputValueOnly(); } } - logstream << std::endl; } - - - } diff --git a/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.h b/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.h index d6a1d5e45cf9b60fa8d445b5a602fd63caf9fe82..450b57a008fa72a2498b46932551328ca8421714 100644 --- a/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.h +++ b/source/ArmarXGui/gui-plugins/PlotterPlugin/ArmarXPlotter.h @@ -61,9 +61,6 @@ class QwtPlotMarker; namespace armarx { - - - class ArmarXPlotterDialog; /*! * \page ArmarXGui-GuiPlugins-PlotterPlugin Live Plotter @@ -73,14 +70,12 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT ArmarXPlotter: - public ArmarXComponentWidgetController, + public ArmarXComponentWidgetControllerTemplate<ArmarXPlotter>, public TopicReplayerListenerInterface { Q_OBJECT public: - - void onStartReplay(const std::string& filename, const Ice::Current& c = Ice::Current()) { if (!syncDataLogging) @@ -116,7 +111,6 @@ namespace armarx } } - Ui::ArmarXPlotter ui; QPointer<ArmarXPlotterDialog> dialog; QTimer* timer; @@ -127,11 +121,11 @@ namespace armarx explicit ArmarXPlotter(); ~ArmarXPlotter(); //inherited from ArmarXWidget - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Observers.LivePlotter"; } - virtual QIcon getWidgetIcon() const + static QIcon GetWidgetIcon() { return QIcon("://icons/combo_chart.svg"); } @@ -139,14 +133,11 @@ namespace armarx void saveSettings(QSettings* settings); //for AbstractFactoryMethod class - // inherited from Component virtual void onInitComponent(); virtual void onConnectComponent(); virtual void onExitComponent(); - - /** * emits the closeRequest signal */ @@ -174,8 +165,6 @@ namespace armarx bool __plottingPaused; JSONObjectPtr json; - - Mutex dataMutex; bool syncDataLogging; std::vector<std::string> csvHeader; @@ -185,14 +174,9 @@ namespace armarx std::mutex mutex; - std::mutex fileMutex; QSharedPointer<PlotterController> plotterController; - - }; - } - #endif diff --git a/source/ArmarXGui/gui-plugins/PlotterPlugin/StaticPlotterWidgetController.h b/source/ArmarXGui/gui-plugins/PlotterPlugin/StaticPlotterWidgetController.h index 7be364273564737a661ad055915a09618bf428fb..727cedc2373900e3ac60e9d2aa7df1997c35ef1b 100644 --- a/source/ArmarXGui/gui-plugins/PlotterPlugin/StaticPlotterWidgetController.h +++ b/source/ArmarXGui/gui-plugins/PlotterPlugin/StaticPlotterWidgetController.h @@ -37,7 +37,7 @@ namespace armarx The GUI needs to be running before the plot is sent. */ class StaticPlotterWidgetController : - public ArmarXComponentWidgetController, + public ArmarXComponentWidgetControllerTemplate<StaticPlotterWidgetController>, public StaticPlotterInterface { Q_OBJECT @@ -59,7 +59,7 @@ namespace armarx void showCurve(QwtPlotItem* item, bool on); void clearPlots(); public: - QString getWidgetName() const override + static QString GetWidgetName() { return "Util.Plotter"; } @@ -70,15 +70,14 @@ namespace armarx private: QwtPlotCurve* createCurve(const QString& label, QColor color); - Ui::StaticPlotterWidget ui; QPointer<QwtPlot> plotter; std::map<QString, StringVector2fSeqDict > plotsMap; Mutex dataMutex; QToolBar* customToolbar; -// StaticPlotterInterfacePrx topicPrx ; -// armarx::SimpleRunningTask<>::pointer_type task; + // StaticPlotterInterfacePrx topicPrx ; + // armarx::SimpleRunningTask<>::pointer_type task; // StaticPlotterInterface interface public: diff --git a/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.cpp b/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.cpp index fa70a46971a281fbccb07c19886020b4c4525f3d..a51f33db346f0bdb0825e9caa07184ca842fb11b 100644 --- a/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.cpp +++ b/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.cpp @@ -23,6 +23,7 @@ #include "ScenarioManagerWidgetController.h" #include <QCoreApplication> +#include <QProgressDialog> #include <QToolBar> #include "gui/namelocationview.h" @@ -247,11 +248,15 @@ void ScenarioManagerWidgetController::reparsePackages() { QSettings settings("KIT", "ScenarioManager"); QStringList packages = settings.value("packages").toStringList(); - + QProgressDialog progress("Loading scenarios from " + QString::number(packages.size()) + " packages ...", "", 0, packages.size(), getWidget()); + progress.setWindowModality(Qt::WindowModal); PackageBuilder parser; for (int i = 0; i < packages.size(); i++) { string name = packages.at(i).toStdString(); + progress.setLabelText(QString("Loading scenarios from package ") + name.c_str()); + progress.setValue(i + 1); + qApp->processEvents(); QStringList openedScenarios = settings.value("scenarios").toStringList(); //remove duplicates @@ -307,8 +312,3 @@ void ScenarioManagerWidgetController::editMode(bool edit) widget.detailedApplicationView->setVisible(edit); widget.applicationDatabase->setVisible(edit); } - -QIcon armarx::ScenarioManagerWidgetController::getWidgetIcon() const -{ - return QIcon(":icons/ArmarX_Play_Store.svg"); -} diff --git a/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.h b/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.h index 394b1375aa7b2e4f23f42afc63d5452ca3601ce3..31217d321180a8108f1848a455867f3ed3ee56f7 100644 --- a/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.h +++ b/source/ArmarXGui/gui-plugins/ScenarioManager/ScenarioManagerWidgetController.h @@ -61,7 +61,7 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT ScenarioManagerWidgetController: - public armarx::ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<ScenarioManagerWidgetController> { Q_OBJECT @@ -90,7 +90,7 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this class. */ - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Meta.ScenarioManager"; } @@ -146,7 +146,10 @@ namespace armarx QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent); // ArmarXWidgetController interface public: - QIcon getWidgetIcon() const; + static QIcon GetWidgetIcon() + { + return QIcon(":icons/ArmarX_Play_Store.svg"); + } }; } diff --git a/source/ArmarXGui/gui-plugins/ScenarioManager/controller/openscenariocontroller.cpp b/source/ArmarXGui/gui-plugins/ScenarioManager/controller/openscenariocontroller.cpp index b14ec8930d67ca89d256eef93be5359e56529dcc..d200ae00dd6fe84d1069a63904e5ed3077835a5a 100644 --- a/source/ArmarXGui/gui-plugins/ScenarioManager/controller/openscenariocontroller.cpp +++ b/source/ArmarXGui/gui-plugins/ScenarioManager/controller/openscenariocontroller.cpp @@ -274,7 +274,7 @@ QStringList OpenScenarioController::getAllClosedScenarios() for (int i = 0; i < packages.size(); i++) { - CMakePackageFinder parser(packages.at(i).toStdString()); + CMakePackageFinder parser = CMakePackageFinderCache::GlobalCache.findPackage(packages.at(i).toStdString()); XMLScenarioParser scenarioParser; vector<string> packageScenarios = scenarioParser.getScenariosFromFolder(parser.getScenariosDir()); diff --git a/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.cpp b/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.cpp index 46614e9060c2b81856ad4cae648c1fecd3c7af00..7584d1178736fc5cd12363d423aebbff33b7d111 100644 --- a/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.cpp +++ b/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.cpp @@ -125,7 +125,7 @@ int OptionalVariantManager::attributeType(int propertyType, const QString& attri return QtVariantPropertyManager::attributeType(propertyType, attribute); } -QVariant OptionalVariantManager::attributeValue(const QtProperty* property, const QString& attribute) +QVariant OptionalVariantManager::attributeValue(const QtProperty* property, const QString& attribute) const { if (dataMap.contains(property)) { diff --git a/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.h b/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.h index 927b24b0cb9857db0d5df721626bac114275df15..a8546e54a6efb9d6d7f9d3a73b4c5dc0e9d2b1b7 100644 --- a/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.h +++ b/source/ArmarXGui/gui-plugins/ScenarioManager/gui/OptionalPropertyManager.h @@ -15,9 +15,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * @package - * @author - * @date + * @package + * @author + * @date * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ @@ -39,7 +39,7 @@ public: virtual QStringList attributes(int propertyType) const; virtual int attributeType(int propertyType, const QString& attribute) const; - virtual QVariant attributeValue(const QtProperty* property, const QString& attribute); + virtual QVariant attributeValue(const QtProperty* property, const QString& attribute) const; static int optionalProprtyTypeId(); diff --git a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateEditorController.cpp b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateEditorController.cpp index ede3272af674e378303519f37d9e05b4aa7a4590..e61f8e18fc0e20d4499611615e5b15cb18941e2c 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateEditorController.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateEditorController.cpp @@ -242,7 +242,7 @@ namespace armarx detach->setEnabled(false); } - QAction* setSupportPoint; + QAction* setSupportPoint {nullptr}; std::map<QAction*, int> bendMap; if (transition->sourceState && transition->destinationState) diff --git a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateTreeController.cpp b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateTreeController.cpp index 9ec97ab7ee07710a9889538cf8d107b34395628c..db3f59853bc8cf469b6dced6a425eb4df33d3b6a 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateTreeController.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StateTreeController.cpp @@ -135,17 +135,17 @@ StateTreeController::StateTreeController(Ice::CommunicatorPtr ic, VariantInfoPtr //stateActions.append(actionGenerateStateBaseClass); stateActions.append(actionGenerateStateCPP); - for (QAction * a : groupActions) + for (QAction* a : groupActions) { a->setIconVisibleInMenu(true); } - for (QAction * a : folderActions) + for (QAction* a : folderActions) { a->setIconVisibleInMenu(true); } - for (QAction * a : stateActions) + for (QAction* a : stateActions) { a->setIconVisibleInMenu(true); } @@ -1032,7 +1032,7 @@ void StateTreeController::onRenameState() auto groups = stateTreeModel->getGroups(); stateTreeModel->clear(); - for (const auto & c : rootNode->getChildren()) + for (const auto& c : rootNode->getChildren()) { if (c->isGroup()) { @@ -1042,7 +1042,7 @@ void StateTreeController::onRenameState() if (StateRenamer::RenameState(d.getInstanceRenameInfos(), node, d.getNewStateName(), group)) { - for (const StatechartGroupPtr & g : groups) + for (const StatechartGroupPtr& g : groups) { ARMARX_VERBOSE_S << "reloading " << g->getName(); auto loadedGroup = loadAndAddGroup(g->getDefinitionFilePath()); @@ -1233,7 +1233,15 @@ void StateTreeController::onExecuteGroup() void StateTreeController::onStatechartFinished(int exitCode) { - ARMARX_INFO_S << "Exited with code " << exitCode; + auto process = qobject_cast<QProcess*>(sender()); + if (process) + { + ARMARX_INFO_S << process->pid() << " exited with code " << exitCode; + } + else + { + ARMARX_INFO_S << "Exited with code " << exitCode; + } } /* void StateTreeController::onGenerateStateBaseClass() @@ -1315,7 +1323,7 @@ void StateTreeController::onCloneGroup() if (d.exec() == QDialog::Accepted) { - for (const auto & g : d.getGroupsToClone()) + for (const auto& g : d.getGroupsToClone()) { if (!g.first->existsCMakeLists()) { @@ -1374,7 +1382,7 @@ void StateTreeController::onRenameGroup() ARMARX_VERBOSE_S << "removing groups from tree view"; stateTreeModel->clear(); - for (const auto & c : rootNode->getChildren()) + for (const auto& c : rootNode->getChildren()) { if (c->isGroup()) { @@ -1382,7 +1390,7 @@ void StateTreeController::onRenameGroup() } } - for (const StatechartGroupPtr & g : d.getAllGroups()) + for (const StatechartGroupPtr& g : d.getAllGroups()) { if (g->getGroupPath() == group->getGroupPath()) { diff --git a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.cpp b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.cpp index b42cf0b3fab400416a92cb46154b1a72dc54774f..981ed255e47ce38c5bd85eb3ea3d5f7ec3ac9e74 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.cpp @@ -528,9 +528,15 @@ namespace armarx changeToWaiting = true; } } + catch (const Ice::Exception& e) + { + labelText = "Waiting for statechart group to start (ice-exception catched)"; + changeToWaiting = true; + } + catch (...) { - labelText = "Waiting for statechart group to start"; + labelText = "Waiting for statechart group to start (exception catched)"; changeToWaiting = true; } diff --git a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.h b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.h index 6312df1464d87552c30e443359ce20d77b156f3e..f86b55688d516a72edf4d4630032e9183f652a54 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.h +++ b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/StatechartEditorController.h @@ -133,7 +133,7 @@ namespace armarx \brief The StatechartEditorController class is the controller of the main widget of the Statechart Editor. */ class StatechartEditorController : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<StatechartEditorController> { Q_OBJECT @@ -169,15 +169,15 @@ namespace armarx void onExitComponent(); // inherited of ArmarXWidget - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Statecharts.StatechartEditor"; } - virtual QIcon getWidgetIcon() const + static QIcon GetWidgetIcon() { return QIcon(":/statechart-editor/states.svg"); } - virtual QIcon getWidgetCategoryIcon() const + static QIcon GetWidgetCategoryIcon() { return QIcon(":/statechart-editor/states.svg"); } diff --git a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/model/StateTreeModel.cpp b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/model/StateTreeModel.cpp index b84736f08997bd4a149e63171d2473a24c55e9f4..859e90074757239d55bc4fa50f4bd2130216beb3 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/model/StateTreeModel.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartEditorPlugin/model/StateTreeModel.cpp @@ -498,22 +498,21 @@ void StateTreeModel::generateBaseClasses(const StatechartGroupPtr& group) doxyFile /= group->getName().toStdString() + ".dox"; generateGroupDocString(group, QString::fromStdString(doxyFile.string())); - std::vector<std::string> proxies; - proxies.push_back("ArmarXCoreInterfaces.systemObserver"); - proxies.push_back("ArmarXCoreInterfaces.conditionHandler"); + std::set<std::string> proxies; + proxies.insert("ArmarXCoreInterfaces.systemObserver"); + proxies.insert("ArmarXCoreInterfaces.conditionHandler"); for (QString p : group->getProxies()) { - proxies.push_back(p.toUtf8().data()); + proxies.insert(p.toUtf8().data()); } - std::sort(proxies.begin(), proxies.end()); - std::unique(proxies.begin(), proxies.end()); + Ice::StringSeq proxyVec(proxies.begin(), proxies.end()); if (group->contextGenerationEnabled()) { std::set<std::string> innerVariantTypes = getVariantOfStatesWithNoCpp(group); StatechartGroupGenerator::generateStatechartContextFile(packageFinder.getBuildDir(), group->getPackageName().toUtf8().data(), group->getName().toUtf8().data(), - proxies, + proxyVec, variantInfo, innerVariantTypes, false); @@ -523,7 +522,7 @@ void StateTreeModel::generateBaseClasses(const StatechartGroupPtr& group) for (StateTreeNodePtr node : group->getRootNode()->getChildren()) { - generateBaseClass(node, packageFinder.getBuildDir(), variantInfo, proxies); + generateBaseClass(node, packageFinder.getBuildDir(), variantInfo, proxyVec); } } diff --git a/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.cpp b/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.cpp index 3e6273297a04cca58b4888e68204977bec62c278..f981676c39ffba882d8a6e0b57115edbfceb4a4a 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.cpp @@ -32,7 +32,6 @@ using namespace armarx; EventSenderOverview::EventSenderOverview() : - ArmarXComponentWidgetController(), ui(new Ui::EventSenderOverview()) { @@ -47,8 +46,6 @@ EventSenderOverview::~EventSenderOverview() delete ui; } - - void EventSenderOverview::loadSettings(QSettings* settings) { int size = settings->beginReadArray("EventSender"); @@ -86,10 +83,8 @@ void EventSenderOverview::saveSettings(QSettings* settings) } settings->endArray(); - } - void EventSenderOverview::onInitComponent() { int size = ui->scrollAreaWidgetContents->children().size(); @@ -187,10 +182,4 @@ void EventSenderOverview::sendEvent(const EventSenderConfig& config) { ARMARX_WARNING << "Cannot send event - caught exception:\n" << e.what(); } - - } - - - - diff --git a/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.h b/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.h index 8373cadc1fc9e781ed2fdeb2951e0b80dd62e06f..e345a9a2365639d7c44ccf4a6626470aa091a95d 100644 --- a/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.h +++ b/source/ArmarXGui/gui-plugins/StatechartEventSenderPlugin/EventSenderOverview.h @@ -127,7 +127,7 @@ namespace armarx * \see StatechartEventSenderPlugin */ class EventSenderOverview : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<EventSenderOverview> { Q_OBJECT @@ -138,7 +138,7 @@ namespace armarx ~EventSenderOverview(); //inherited from ArmarXWidget - QString getWidgetName() const + static QString GetWidgetName() { return "Statecharts.EventSender"; } @@ -147,7 +147,7 @@ namespace armarx void saveSettings(QSettings* settings); // inherited from Component virtual void onInitComponent(); - virtual void onConnectComponent() {}; + virtual void onConnectComponent() {} // end of inherited from Component // end of inherited from Component EventSenderComponent* addEventSender(const EventSenderConfig& config); diff --git a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/IceStateConverter.h b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/IceStateConverter.h index 731e8d4a7ef8309b513171f64c6b69ed14f48c08..dfa31c683a3b1715c5451a06308d140cd6cc12ca 100644 --- a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/IceStateConverter.h +++ b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/IceStateConverter.h @@ -45,7 +45,7 @@ namespace armarx ~IceStateConverter(); /** - * @brief convert Converts the given ice model into a statechartmodel. This is then accesible via + * @brief Converts the given ice model into a statechartmodel. This is then accesible via * getTopState(). * @param iceBase The StateIceBase that is the top state of the ice model that shall be converted */ diff --git a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.cpp b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.cpp index 5031b92ebe935f58d600630b78355b1365dc454b..efc73e9849c4b724183b48b2f9626697765e4889 100644 --- a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.cpp +++ b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.cpp @@ -95,8 +95,8 @@ namespace armarx { qRegisterMetaType<statechartmodel::TransitionCPtr>("statechartmodel::TransitionCPtr"); qRegisterMetaType<statechartmodel::SignalType>("statechartmodel::SignalType"); - watcher = ManagedIceObject::create<StateWatcher>("StateWatcher" + IceUtil::generateUUID()); - getArmarXManager()->addObject(watcher, false); + watcher = new StateWatcher; + getArmarXManager()->addObject(watcher, false, "StateWatcher" + IceUtil::generateUUID()); updateTask->start(); emit componentConnected(); proxyFinder->setIceManager(getIceManager()); diff --git a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.h b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.h index 36f831b92ee3bbbee1f4000fc519415a17dd1090..c6a3c2c3d527639fb46d83631bffbf76d6c8471b 100644 --- a/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.h +++ b/source/ArmarXGui/gui-plugins/StatechartViewerPlugin/StatechartViewerController.h @@ -54,7 +54,7 @@ namespace armarx \see StatechartViewerGuiPlugin */ class StatechartViewerController : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<StatechartViewerController> { Q_OBJECT @@ -68,11 +68,11 @@ namespace armarx void onExitComponent(); // inherited of ArmarXWidget - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Statecharts.StatechartViewer"; } - virtual QIcon getWidgetIcon() const + static QIcon GetWidgetIcon() { return QIcon("://icons/statechartviewer.svg"); } diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/CMakeLists.txt b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/CMakeLists.txt index fe86a9864af9011d2e0eacf3754f17e3acf15ce9..28de0a0e187d6f6f953d84111528d274f40527d0 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/CMakeLists.txt +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/CMakeLists.txt @@ -47,6 +47,9 @@ set(GUI_UIS SystemStateMonitorWidget.ui IceGridViewer/IceGridNodeView.ui ) +QT4_ADD_RESOURCES( QT_RC_SRCS icons.qrc ) +list(APPEND SOURCES ${QT_RC_SRCS}) + # Add more libraries you depend on here, e.g. ${QT_LIBRARIES}. set(COMPONENT_LIBS ArmarXCore ArmarXCoreStatechart ArmarXCoreObservers ArmarXGui ${QT_LIBRARIES}) diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/IceGridViewer/IceGridViewer.h b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/IceGridViewer/IceGridViewer.h index df0c7617e638d2c867abff5a60e6937f2f64fe7e..bf5116f7fdcf9ae627d8539b68f37d6372fe52c0 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/IceGridViewer/IceGridViewer.h +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/IceGridViewer/IceGridViewer.h @@ -56,7 +56,7 @@ namespace armarx * \class IceGridViewer */ class IceGridViewer : - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<IceGridViewer> { Q_OBJECT @@ -78,7 +78,7 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this. */ - QString getWidgetName() const + static QString GetWidgetName() { return "Meta.IceGridViewer"; } diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.cpp b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.cpp index 0d6e4b759c0684054cc1807adb9aaf936e943b2f..5c44e496f8bc10dfaf89249aebf81ec60ff06e1b 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.cpp +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.cpp @@ -113,13 +113,6 @@ SystemStateMonitorWidget::~SystemStateMonitorWidget() // delete stateUpdateTimer; } - -QString SystemStateMonitorWidget::getWidgetName() const -{ - return "Meta.SystemStateMonitor"; -} - - void SystemStateMonitorWidget::setupModel() { managerRepositoryModel = new ArmarXManagerModel(); @@ -362,8 +355,3 @@ void SystemStateMonitorWidget::delayedFilterExpansion() { InfixFilterModel::ExpandFilterResults(ui.monitoredManagersTree); } - -QIcon armarx::SystemStateMonitorWidget::getWidgetIcon() const -{ - return QIcon(":icons/activity_monitor.png"); -} diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.h b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.h index 2cec007fff34246d08c5ce6165a936e17b9814f6..a2fc22f6b6258f572f09822fdae8b52ab814f975 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.h +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/SystemStateMonitorWidget.h @@ -67,7 +67,7 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT SystemStateMonitorWidget: - public ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<SystemStateMonitorWidget> { Q_OBJECT @@ -100,7 +100,10 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this. */ - QString getWidgetName() const; + static QString GetWidgetName() + { + return "Meta.SystemStateMonitor"; + } /** * @see armarx::Component::onInitComponent() @@ -193,7 +196,10 @@ namespace armarx // ArmarXWidgetController interface public: - QIcon getWidgetIcon() const; + static QIcon GetWidgetIcon() + { + return QIcon(":icons/activity_monitor.png"); + } }; } diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.cpp b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.cpp index 1bae4ce97936a49c16f8be66b70156021de789c1..ad61461206e003763e6873e7f9d2e07b50537cda 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.cpp +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.cpp @@ -91,11 +91,6 @@ void ThreadViewer::saveSettings(QSettings* settings) { } -QString ThreadViewer::getWidgetName() const -{ - return "Meta.ThreadViewer"; -} - void ThreadViewer::onInitComponent() { diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.h b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.h index d8761ec784e7b5f0b06ed4410684c0dfcdec933c..2c9a1f4c50f81da3288afd639688df8b5b1d4af4 100644 --- a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.h +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/ThreadViewer/ThreadViewer.h @@ -54,7 +54,7 @@ namespace armarx * \class ThreadViewer * \brief The ThreadViewer displays all threads of an ArmarX application. */ - class ThreadViewer : public ArmarXComponentWidgetController + class ThreadViewer : public ArmarXComponentWidgetControllerTemplate<ThreadViewer> { Q_OBJECT @@ -76,7 +76,14 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this. */ - QString getWidgetName() const; + static QString GetWidgetName() + { + return "Meta.ThreadViewer"; + } + static QIcon GetWidgetIcon() + { + return QIcon {"://icons/thread_viewer.svg"}; + } /** * @see armarx::Component::onInitComponent() diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons.qrc b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons.qrc new file mode 100644 index 0000000000000000000000000000000000000000..e6c727d5d92879fe95e716a43e83afdb3e5569e7 --- /dev/null +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>icons/thread_viewer.svg</file> + </qresource> +</RCC> diff --git a/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons/thread_viewer.svg b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons/thread_viewer.svg new file mode 100644 index 0000000000000000000000000000000000000000..54543fcc442e0df73e63b26b9367edfd1d09088e --- /dev/null +++ b/source/ArmarXGui/gui-plugins/SystemStateMonitorPlugin/icons/thread_viewer.svg @@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 512 512" + height="512px" + id="Layer_1" + version="1.1" + viewBox="0 0 512 512" + width="512px" + xml:space="preserve" + inkscape:version="0.48.4 r9939" + sodipodi:docname="point_cloud_visu.svg"><metadata + id="metadata9"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs7"><marker + inkscape:stockid="Arrow1Mend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Mend" + style="overflow:visible;"><path + id="path4083" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;" + transform="scale(0.4) rotate(180) translate(10,0)" /></marker><marker + inkscape:stockid="Arrow1Send" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Send" + style="overflow:visible;"><path + id="path4089" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;" + transform="scale(0.2) rotate(180) translate(6,0)" /></marker><marker + inkscape:stockid="Arrow1Lend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lend" + style="overflow:visible;"><path + id="path4077" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;" + transform="scale(0.8) rotate(180) translate(12.5,0)" /></marker></defs><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview5" + showgrid="false" + inkscape:zoom="0.16296602" + inkscape:cx="-1463.3697" + inkscape:cy="7.7226371" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><path + d="M480,0H32C14.328,0,0,14.312,0,32v352c0,17.688,14.328,32,32,32h192v32h-96c-17.672,0-32,14.312-32,32v32h320v-32 c0-17.688-14.328-32-32-32h-96v-32h192c17.672,0,32-14.312,32-32V32C512,14.312,497.672,0,480,0z M448,352H64V64h384V352z" + id="path3" /><rect + style="fill:#000000;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke:#000000;stroke-opacity:1" + id="rect4050" + width="2.3010931" + height="265.39276" + x="112.61732" + y="74.792282" /><rect + y="74.792282" + x="206.61731" + height="265.39276" + width="2.3010931" + id="rect4052" + style="fill:#000000;stroke:#000000;stroke-width:4;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><rect + style="fill:#000000;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke:#000000;stroke-opacity:1" + id="rect4054" + width="2.3010931" + height="265.39276" + x="294.61731" + y="74.792282" /><rect + y="74.792282" + x="400.61731" + height="265.39276" + width="2.3010931" + id="rect4056" + style="fill:#000000;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke:#000000;stroke-opacity:1" /><rect + style="fill:#ffffff;stroke:#000000;stroke-width:3.81927109;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect4058" + width="46.435562" + height="88.622269" + x="89.919312" + y="83.406303" /><rect + y="163.94456" + x="184.26414" + height="88.622269" + width="46.435562" + id="rect4060" + style="fill:#ffffff;stroke:#000000;stroke-width:3.81927109;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><rect + style="fill:#ffffff;stroke:#000000;stroke-width:3.81927109;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect4062" + width="46.435562" + height="88.622269" + x="89.919312" + y="242.18173" /><rect + y="90.938721" + x="273.40295" + height="160.99896" + width="45.177273" + id="rect4064" + style="fill:#ffffff;stroke:#000000;stroke-width:5.07756186;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><rect + style="fill:#ffffff;stroke:#000000;stroke-width:4.01586294;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect4066" + width="46.238972" + height="98.397079" + x="378.25644" + y="234.60973" /><path + style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:none;marker-end:url(#Arrow1Mend)" + d="m 137.6644,168.94915 39.17087,0" + id="path4068" + inkscape:connector-type="polyline" + inkscape:connector-curvature="3" /><path + style="fill:none;stroke:#000000;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1Mend)" + d="m 183.18833,250.58711 -38.78344,-0.0217" + id="path5062" + inkscape:connector-type="polyline" + inkscape:connector-curvature="3" /><path + style="fill:none;stroke:#000000;stroke-width:3.8870542;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-end:url(#Arrow1Mend)" + d="m 318.69363,242.80649 52.3325,0.0819" + id="path5064" + inkscape:connector-type="polyline" + inkscape:connector-curvature="3" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/gui-plugins/TopicReplayerPlugin/TopicReplayerWidgetController.h b/source/ArmarXGui/gui-plugins/TopicReplayerPlugin/TopicReplayerWidgetController.h index 268e5960efdb75c510b92bfbb28e85da192480f2..e3cf83dbd7ea7932181a92cc9bf8c5e435fbac3f 100644 --- a/source/ArmarXGui/gui-plugins/TopicReplayerPlugin/TopicReplayerWidgetController.h +++ b/source/ArmarXGui/gui-plugins/TopicReplayerPlugin/TopicReplayerWidgetController.h @@ -62,7 +62,7 @@ namespace armarx */ class ARMARXCOMPONENT_IMPORT_EXPORT TopicReplayerWidgetController: - public armarx::ArmarXComponentWidgetController + public ArmarXComponentWidgetControllerTemplate<TopicReplayerWidgetController> { Q_OBJECT @@ -91,7 +91,7 @@ namespace armarx * Returns the Widget name displayed in the ArmarXGui to create an * instance of this class. */ - virtual QString getWidgetName() const + static QString GetWidgetName() { return "Meta.TopicReplayer"; } @@ -106,7 +106,6 @@ namespace armarx */ virtual void onConnectComponent(); - public slots: /* QT slot declarations */ diff --git a/source/ArmarXGui/interface/WidgetDescription.ice b/source/ArmarXGui/interface/WidgetDescription.ice index 72d8f650ff323557d0b10c73715a690083709728..c1797d8eb93a37c7943c320763ff6e8ee51729e5 100644 --- a/source/ArmarXGui/interface/WidgetDescription.ice +++ b/source/ArmarXGui/interface/WidgetDescription.ice @@ -31,6 +31,7 @@ module armarx { class Widget { + bool framed = false; }; sequence<Widget> WidgetSeq; dictionary<string,Widget> StringWidgetDictionary; @@ -38,15 +39,29 @@ module armarx //Layouts class HBoxLayout extends Widget { - WidgetSeq widgets; + WidgetSeq children; }; class VBoxLayout extends Widget { - WidgetSeq widgets; + WidgetSeq children; }; + class FormLayoutElement extends Widget + { + string label; + Widget labelWidget; + Widget child; + bool childIsSpanning = false; + }; + sequence<FormLayoutElement> FormLayoutElementSeq; + class FormLayout extends Widget { - StringWidgetDictionary widgets; + FormLayoutElementSeq children; + }; + class GroupBox extends Widget + { + string label; + Widget child; }; //static elements class HSpacer extends Widget @@ -55,6 +70,12 @@ module armarx class VSpacer extends Widget { }; + class HLine extends Widget + { + }; + class VLine extends Widget + { + }; class Label extends Widget { string text; @@ -103,15 +124,17 @@ module armarx { float min=0; float max=0; - double steps = 100; float defaultValue=0; + int steps = 100; + int decimals = 3; }; class DoubleSpinBox extends ConfigWidget { double min=0; double max=0; double defaultValue=0; - double steps = 100; + int steps = 100; + int decimals = 3; }; class IntSlider extends ConfigWidget { diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h index a7cd1ecef784a5b002823f3ba2267524edf0cfe7..47bed73d958bc607015f79c15b6077a8e208c72b 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h @@ -63,6 +63,25 @@ namespace armarx std::string uuid; }; typedef IceUtil::Handle<ArmarXComponentWidgetController> ArmarXComponentWidgetControllerPtr; + + template<class Derived> + class ArmarXComponentWidgetControllerTemplate: + public ArmarXComponentWidgetController + { + public: + virtual QString getWidgetName() const final + { + return Derived::GetWidgetName(); + } + virtual QIcon getWidgetIcon() const final + { + return Derived::GetWidgetIcon(); + } + virtual QIcon getWidgetCategoryIcon() const final + { + return Derived::GetWidgetCategoryIcon(); + } + }; } #endif diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h index 1c36d02b772acc3fa8076505656cd263d18edf6c..42528d9f6e889209f8184e20a7e70c68b7f1e8ea 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h @@ -28,6 +28,7 @@ #include "ArmarXComponentWidgetController.h" #include <ArmarXCore/core/exceptions/Exception.h> +#include <ArmarXCore/core/util/TemplateMetaProgramming.h> #include <boost/type_traits/is_base_of.hpp> @@ -51,8 +52,11 @@ namespace armarx Q_INTERFACES(ArmarXGuiInterface) public: - template<typename ArmarXWidgetType> - void addWidget() + + ARMARX_META_MAKE_HAS_MEMBER_FNC_CHECK(HasGetWidgetName, GetWidgetName, QString(*)()); + + template < typename ArmarXWidgetType> + typename std::enable_if < !HasGetWidgetName<ArmarXWidgetType>::value >::type addWidget() { BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ArmarXWidgetController, ArmarXWidgetType>::value), "The template parameter of addWidget, must be a class that derives from ArmarXWidget"); @@ -90,6 +94,40 @@ namespace armarx // ARMARX_VERBOSE_S << "Added new widget named " + creatorInstance->getWidgetName().toStdString() << std::endl; } + template <typename ArmarXWidgetType> + typename std::enable_if<HasGetWidgetName<ArmarXWidgetType>::value>::type addWidget() + { + BOOST_STATIC_ASSERT_MSG((boost::is_base_of<ArmarXWidgetController, ArmarXWidgetType>::value), "The template parameter of addWidget, must be a class that derives from ArmarXWidget"); + + try + { + if (__availableWidgets.find(ArmarXWidgetType::GetWidgetName()) != __availableWidgets.end()) + { + throw LocalException(QString("A widget with the name '" + + ArmarXWidgetType::GetWidgetName() + + "' already exists in a loaded plugin!").toStdString()); + } + + if (boost::is_base_of<ArmarXComponentWidgetController, ArmarXWidgetType>::value) + { + ArmarXWidgetInfoPtr widgetInfo(new ArmarXWidgetInfo(ArmarXComponentWidgetController::createInstance<ArmarXWidgetType>, + ArmarXWidgetType::GetWidgetIcon(), + ArmarXWidgetType::GetWidgetCategoryIcon())); + __availableWidgets[ArmarXWidgetType::GetWidgetName()] = widgetInfo; + } + else + { + ArmarXWidgetInfoPtr widgetInfo(new ArmarXWidgetInfo(ArmarXWidgetController::createInstance<ArmarXWidgetType>, + ArmarXWidgetType::GetWidgetIcon(), + ArmarXWidgetType::GetWidgetCategoryIcon())); + __availableWidgets[ArmarXWidgetType::GetWidgetName()] = widgetInfo; + } + } + catch (...) + { + ARMARX_ERROR_S << "Could not add widget!\n" << GetHandledExceptionString(); + } + } // template<typename ArmarXWidgetType> // typename boost::enable_if<boost::is_base_of<ArmarXComponentWidgetController, ArmarXWidgetType>, void >::type // addWidget(const QString & widgetName) diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXWidgetController.h b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXWidgetController.h index 788b2776a130d0bd22dc0e42b111707596d8408f..9343a580fc97dab1eb4df6df6f87dabfc63a9108 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXWidgetController.h +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/ArmarXWidgetController.h @@ -118,6 +118,21 @@ namespace armarx /** * @brief Implement this function to specify the default name of your Widget. + * + * Implement the function as: + * \code{.cpp} + * static QString GetWidgetName() + * { + * return "my_widget_category.my_widget_name" + * } + * virtual QString getWidgetName() const override + * { + * return GetWidgetName(); + * } + * \endcode + * If you implement the static GetWidgetName() function, the armarx gui does not need to instantiate + * this widget only to get the name. + * * Dot-Notation can be used to insert the widget in categories and subcategories * (e.g.: "Statecharts.StatechartEditor"). Categories must not collide with Widget names. * @return Default name of the implemented Widget. @@ -132,6 +147,25 @@ namespace armarx { return QIcon(); } + /** + * @brief Implement this function to supply an icon for the menu (if you implemented static QString GetWidgetName()). + * + * The implementation should look like this: + * \code{.cpp} + * static QIcon GetWidgetIcon() + * { + * return QIcon{"my_resource_path"}; + * } + * virtual QIcon getWidgetIcon() const override + * { + * return GetWidgetIcon(); + * } + * \endcode + */ + static QIcon GetWidgetIcon() + { + return QIcon(); + } /** * @brief Implement this function to supply an icon for the category. @@ -141,6 +175,25 @@ namespace armarx { return QIcon(); } + /** + * @brief Implement this function to supply an icon for the menu (if you implemented static QString GetWidgetName()). + * + * The implementation should look like this: + * \code{.cpp} + * static QIcon GetWidgetCategoryIcon() + * { + * return QIcon{"my_resource_path"}; + * } + * virtual QIcon getWidgetCategoryIcon() const override + * { + * return GetWidgetCategoryIcon(); + * } + * \endcode + */ + static QIcon GetWidgetCategoryIcon() + { + return QIcon(); + } /** * @brief Implement to load the settings that are part of the GUI configuration. diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt b/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt index 2779f8d08a6eda32c24aff3a3eb69234d2e7c17d..781109b98237d4b387f520d1a31c7763adc91e77 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/CMakeLists.txt @@ -32,6 +32,8 @@ set(LIB_FILES ArmarXWidgetController.cpp widgets/IceProxyFinder.cpp widgets/VariantItem.cpp widgets/JoystickControlWidget.cpp + widgets/EnhancedGraphicsView.cpp + widgets/EnhancedTreeWidget.cpp widgets/FilterableTreeView.cpp widgets/MarkdownEditor.cpp widgets/cpp-markdown/markdown.cpp @@ -45,13 +47,17 @@ set(LIB_FILES ArmarXWidgetController.cpp set(LIB_HEADERS ArmarXGuiInterface.h ArmarXGuiPlugin.h ArmarXWidgetController.h - PluginCache.h + PluginCache.h + ToQString.h + widgets/CoinViewer.h ArmarXComponentWidgetController.h widgets/editorfileopener.h widgets/IceProxyFinder.h widgets/VariantItem.h widgets/JoystickControlWidget.h + widgets/EnhancedGraphicsView.h + widgets/EnhancedTreeWidget.h widgets/FilterableTreeView.h widgets/MarkdownEditor.h widgets/cpp-markdown/markdown.h @@ -80,6 +86,8 @@ qt4_wrap_cpp(LIB_FILES widgets/FilterableTreeView.h widgets/IceProxyFinder.h widgets/JoystickControlWidget.h + widgets/EnhancedGraphicsView.h + widgets/EnhancedTreeWidget.h widgets/MarkdownEditor.h widgets/TipDialog.h widgets/InfixFilterModel.h diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/ToQString.h b/source/ArmarXGui/libraries/ArmarXGuiBase/ToQString.h new file mode 100644 index 0000000000000000000000000000000000000000..fb725249c4f61d3eb954c0cd325af2c1a44b122f --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/ToQString.h @@ -0,0 +1,157 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package ArmarXGui::ArmarXGuiBase + * @author Raphael Grimm ( raphael dot grimm at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#ifndef _ARMARX_ArmarXGuiBase_ToQString_H +#define _ARMARX_ArmarXGuiBase_ToQString_H + +#include <string> +#include <sstream> +#include <vector> + +#include <QString> + +//#include <ArmarXCore/core/util/TemplateMetaProgramming.h> + +namespace armarx +{ + inline QString ToQString(const char* str) + { + return {str}; + } + + inline QString ToQString(const std::string& s) + { + return QString::fromStdString(s); + } + + inline QString ToQString(float v) + { + return QString::number(v); + } + + inline QString ToQString(double v) + { + return QString::number(v); + } + + inline QString ToQString(char v) + { + return QString::number(v); + } + + inline QString ToQString(std::uint8_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::uint16_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::uint32_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::uint64_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::int8_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::int16_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::int32_t v) + { + return QString::number(v); + } + + inline QString ToQString(std::int64_t v) + { + return QString::number(v); + } + + inline QString ToQString(const std::stringstream& str) + { + return ToQString(str.str()); + } + + inline QString ToQString(bool b) + { + return b ? "true" : "false"; + } + + template<class T> + inline QString ToQString(const std::vector<T>& v) + { + if (v.empty()) + { + return ""; + } + std::stringstream str; + str << v.front(); + for (std::size_t i = 1; i < v.size(); ++i) + { + str << " " << v.at(i); + } + return ToQString(str); + } + + template<class T> + inline QString ToQString(const std::vector<std::vector<T>>& v) + { + if (v.empty()) + { + return ""; + } + std::stringstream str; + str << ToQString(v.front()).toStdString(); + for (std::size_t i = 1; i < v.size(); ++i) + { + str << "\n" << ToQString(v.at(i)).toStdString(); + } + return ToQString(str); + } + + // template<class T> + // inline QString ToQString(const T& t) + // // inline typename std::enable_if<meta::HasToString<T>::value, QString>::type ToQString(const T& t) + // { + // return ToQString(std::to_string(t)); + // } + + // template<class T> + // inline QString ToQString(const T& t) + // { + // std::stringstream str; + // str << t; + // return ToQString(str); + // } +} +#endif diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/armarxicons.qrc b/source/ArmarXGui/libraries/ArmarXGuiBase/armarxicons.qrc index 8971bb8e0dea133c1da21035eb1306599eddfb13..8a36debba9a3fb679e018184f4689023797f0a34 100644 --- a/source/ArmarXGui/libraries/ArmarXGuiBase/armarxicons.qrc +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/armarxicons.qrc @@ -72,5 +72,16 @@ <file>icons/Blank.svg</file> <file>icons/Trash.svg</file> <file>icons/tools.svg</file> + <file>icons/cpu.svg</file> + <file>icons/monitor.svg</file> + <file>icons/server.svg</file> + <file>icons/eye.svg</file> + <file>icons/monitor_and_remote.svg</file> + <file>icons/traffic_light_all_off.svg</file> + <file>icons/traffic_light_all_on.svg</file> + <file>icons/traffic_light_green.svg</file> + <file>icons/traffic_light_red.svg</file> + <file>icons/traffic_light_red_yellow.svg</file> + <file>icons/traffic_light_yellow.svg</file> </qresource> </RCC> diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/cpu.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/cpu.svg new file mode 100644 index 0000000000000000000000000000000000000000..6cfc52cb93c84f5c52e164a1593685c5f6457e1b --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/cpu.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><svg enable-background="new 0 0 52 52" id="Layer_1" version="1.1" viewBox="0 0 52 52" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><g><g><path d="M42,42H10V10h32V42z M12,40h28V12H12V40z"/></g></g><g><g><path d="M33,36.5H19c-1.6542969,0-3-1.3457031-3-3v-14c0-1.6542969,1.3457031-3,3-3h14c1.6542969,0,3,1.3457031,3,3v14 C36,35.1542969,34.6542969,36.5,33,36.5z M19,18.5c-0.5517578,0-1,0.4487305-1,1v14c0,0.5512695,0.4482422,1,1,1h14 c0.5517578,0,1-0.4487305,1-1v-14c0-0.5512695-0.4482422-1-1-1H19z"/></g></g><g><g><g><g><rect height="2" width="7" x="42" y="12.5"/></g></g><g><g><rect height="2" width="7" x="42" y="17.5"/></g></g><g><g><rect height="2" width="7" x="42" y="22.5"/></g></g><g><g><rect height="2" width="7" x="42" y="27.5"/></g></g><g><g><rect height="2" width="7" x="42" y="32.5"/></g></g><g><g><rect height="2" width="7" x="42" y="37.5"/></g></g></g><g><g><g><rect height="2" width="7" x="3" y="12.5"/></g></g><g><g><rect height="2" width="7" x="3" y="17.5"/></g></g><g><g><rect height="2" width="7" x="3" y="22.5"/></g></g><g><g><rect height="2" width="7" x="3" y="27.5"/></g></g><g><g><rect height="2" width="7" x="3" y="32.5"/></g></g><g><g><rect height="2" width="7" x="3" y="37.5"/></g></g></g></g><g><g><g><g><rect height="7" width="2" x="37.5" y="3"/></g></g><g><g><rect height="7" width="2" x="32.5" y="3"/></g></g><g><g><rect height="7" width="2" x="27.5" y="3"/></g></g><g><g><rect height="7" width="2" x="22.5" y="3"/></g></g><g><g><rect height="7" width="2" x="17.5" y="3"/></g></g><g><g><rect height="7" width="2" x="12.5" y="3"/></g></g></g><g><g><g><rect height="7" width="2" x="37.5" y="42"/></g></g><g><g><rect height="7" width="2" x="32.5" y="42"/></g></g><g><g><rect height="7" width="2" x="27.5" y="42"/></g></g><g><g><rect height="7" width="2" x="22.5" y="42"/></g></g><g><g><rect height="7" width="2" x="17.5" y="42"/></g></g><g><g><rect height="7" width="2" x="12.5" y="42"/></g></g></g></g><g><g><rect height="2.0229192" transform="matrix(0.7069861 -0.7072275 0.7072275 0.7069861 -6.0951171 14.718812)" width="1.9997864" x="13.7154388" y="13.7036285"/></g></g><g><g><rect height="2.0218835" transform="matrix(0.7071068 -0.7071068 0.7071068 0.7071068 -15.4440174 37.2851563)" width="1.9997864" x="36.2852631" y="36.2742157"/></g></g></g></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/eye.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/eye.svg new file mode 100644 index 0000000000000000000000000000000000000000..4bd51c7379031aed613cd21387bcc2fee77e4797 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/eye.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><svg height="16px" version="1.1" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><defs/><g fill="none" fill-rule="evenodd" id="Icons with numbers" stroke="none" stroke-width="1"><g fill="#000000" id="Group" transform="translate(-480.000000, -288.000000)"><path d="M488,299 C489.656854,299 491,297.656854 491,296 C491,294.343146 489.656854,293 488,293 C486.343146,293 485,294.343146 485,296 C485,297.656854 486.343146,299 488,299 Z M480,296 C480,296 482.997314,290.991516 488,290.991516 C493.002686,290.991516 496,296 496,296 C496,296 493.014404,301.029724 488,301.029724 C482.985596,301.029724 480,296 480,296 Z M487,296 C487,295.443865 487.447715,295 488,295 C488.556135,295 489,295.447715 489,296 C489,296.556135 488.552285,297 488,297 C487.443865,297 487,296.552285 487,296 Z M487,296" id="Rectangle 304"/></g></g></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor.svg new file mode 100644 index 0000000000000000000000000000000000000000..e4700f68f07fcda078126e2cb3ad330d29450a55 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg enable-background="new 0 0 512 512" height="512px" id="Layer_1" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M480,0H32C14.328,0,0,14.312,0,32v352c0,17.688,14.328,32,32,32h192v32h-96c-17.672,0-32,14.312-32,32v32h320v-32 c0-17.688-14.328-32-32-32h-96v-32h192c17.672,0,32-14.312,32-32V32C512,14.312,497.672,0,480,0z M448,352H64V64h384V352z"/></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor_and_remote.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor_and_remote.svg new file mode 100644 index 0000000000000000000000000000000000000000..2b0e3fababab2340c7dbe6206dd5f2382999aed8 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/monitor_and_remote.svg @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 512 512" + height="512px" + id="Layer_1" + version="1.1" + viewBox="0 0 512 512" + width="512px" + xml:space="preserve" + inkscape:version="0.48.4 r9939" + sodipodi:docname="monitor_and_remote.svg"><metadata + id="metadata9"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs7" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview5" + showgrid="false" + inkscape:zoom="1.3037281" + inkscape:cx="476.49348" + inkscape:cy="142.76077" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="g3785" /><path + d="M480,0H32C14.328,0,0,14.312,0,32v352c0,17.688,14.328,32,32,32h192v32h-96c-17.672,0-32,14.312-32,32v32h320v-32 c0-17.688-14.328-32-32-32h-96v-32h192c17.672,0,32-14.312,32-32V32C512,14.312,497.672,0,480,0z M448,352H64V64h384V352z" + id="path3" /><g + id="g3831" + transform="translate(121.13934,-11.273622)"><g + id="g3826" + transform="matrix(1.8617936,0,0,1.6531137,-341.75851,-157.48854)"><g + id="g3785"><g + id="g3805" + transform="matrix(0.74133042,-0.75586125,0.5959152,0.74133042,-68.385757,279.15927)"><rect + style="fill:#ffffff;stroke:none" + id="rect3851" + width="69.825142" + height="193.5741" + x="221.08743" + y="206.47925" + ry="12.795576" /><g + transform="matrix(0.53792037,0,0,0.60582445,490.10868,96.134099)" + id="g3793"><rect + style="fill:#000000;stroke:#000000;stroke-width:3.55005264;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect2986" + width="106.28555" + height="226.69232" + x="-488.35342" + y="264.23019" + ry="27.089022" /><g + id="g3771" + transform="translate(-690.66827,86.141336)"><path + transform="matrix(1.1133791,0,0,0.89070325,639.22655,98.511594)" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + sodipodi:ry="10.847458" + sodipodi:rx="8.6779661" + sodipodi:cy="176.81355" + sodipodi:cx="-323.25424" + id="path3756" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /><path + sodipodi:type="arc" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3769" + sodipodi:cx="-323.25424" + sodipodi:cy="176.81355" + sodipodi:rx="8.6779661" + sodipodi:ry="10.847458" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + transform="matrix(1.1133791,0,0,0.89070325,592.58248,98.511594)" /></g><g + id="g3775" + transform="translate(-690.66827,132.06223)"><path + sodipodi:type="arc" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3777" + sodipodi:cx="-323.25424" + sodipodi:cy="176.81355" + sodipodi:rx="8.6779661" + sodipodi:ry="10.847458" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + transform="matrix(1.1133791,0,0,0.89070325,639.22655,98.511594)" /><path + transform="matrix(1.1133791,0,0,0.89070325,592.58248,98.511594)" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + sodipodi:ry="10.847458" + sodipodi:rx="8.6779661" + sodipodi:cy="176.81355" + sodipodi:cx="-323.25424" + id="path3779" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /></g><g + id="g3781" + transform="translate(-692.29539,177.98314)"><path + transform="matrix(1.1133791,0,0,0.89070325,639.22655,98.511594)" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + sodipodi:ry="10.847458" + sodipodi:rx="8.6779661" + sodipodi:cy="176.81355" + sodipodi:cx="-323.25424" + id="path3783" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /><path + sodipodi:type="arc" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3785" + sodipodi:cx="-323.25424" + sodipodi:cy="176.81355" + sodipodi:rx="8.6779661" + sodipodi:ry="10.847458" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + transform="matrix(1.1133791,0,0,0.89070325,592.58248,98.511594)" /></g><g + id="g3787" + transform="translate(-690.1259,40.220436)"><path + sodipodi:type="arc" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3789" + sodipodi:cx="-323.25424" + sodipodi:cy="176.81355" + sodipodi:rx="8.6779661" + sodipodi:ry="10.847458" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + transform="matrix(1.1133791,0,0,0.89070325,639.22655,98.511594)" /><path + transform="matrix(1.1133791,0,0,0.89070325,592.58248,98.511594)" + d="m -314.57628,176.81355 c 0,5.99089 -3.88525,10.84746 -8.67796,10.84746 -4.79271,0 -8.67797,-4.85657 -8.67797,-10.84746 0,-5.99088 3.88526,-10.84746 8.67797,-10.84746 4.79271,0 8.67796,4.85658 8.67796,10.84746 z" + sodipodi:ry="10.847458" + sodipodi:rx="8.6779661" + sodipodi:cy="176.81355" + sodipodi:cx="-323.25424" + id="path3791" + style="fill:#ffffff;stroke:#ffffff;stroke-width:5.69999981;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /></g></g><path + sodipodi:type="arc" + style="fill:none;stroke:#000000;stroke-width:25.32207108;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3816" + sodipodi:cx="-418.79898" + sodipodi:cy="232.80069" + sodipodi:rx="134.99747" + sodipodi:ry="105.85029" + d="m -535.71022,179.87555 c 37.27852,-50.62741 119.84168,-67.97365 184.40997,-38.7439 20.52221,9.2903 37.564,22.65262 49.4125,38.74389" + sodipodi:start="3.6651914" + sodipodi:end="5.7595865" + sodipodi:open="true" + transform="matrix(0.42963432,0,0,0.47176785,435.93042,122.31526)" /><path + transform="matrix(0.41388369,0,0,0.81049941,429.33407,103.51927)" + sodipodi:open="true" + sodipodi:end="5.4105207" + sodipodi:start="4.0142573" + d="m -505.57368,151.71466 c 50.18619,-33.01901 123.36322,-33.01901 173.5494,1e-5" + sodipodi:ry="105.85029" + sodipodi:rx="134.99747" + sodipodi:cy="232.80069" + sodipodi:cx="-418.79898" + id="path3822" + style="fill:none;stroke:#000000;stroke-width:19.68327522;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="arc" /><path + sodipodi:type="arc" + style="fill:none;stroke:#000000;stroke-width:14.87527752;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3824" + sodipodi:cx="-418.79898" + sodipodi:cy="232.80069" + sodipodi:rx="134.99747" + sodipodi:ry="105.85029" + d="m -464.97084,133.33396 c 29.82421,-8.51141 62.5195,-8.51141 92.34371,-1e-5" + sodipodi:start="4.3633231" + sodipodi:end="5.0614548" + sodipodi:open="true" + transform="matrix(0.4427729,0,0,1.5148524,441.43285,40.407859)" /></g></g></g></g></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/server.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/server.svg new file mode 100644 index 0000000000000000000000000000000000000000..93bdbdc24386723725889a047ddb08e0e64926bd --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/server.svg @@ -0,0 +1 @@ +<?xml version="1.0" ?><svg enable-background="new 0 0 52 52" id="Layer_1" version="1.1" viewBox="0 0 52 52" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g><g><g><rect height="2" width="16" x="19" y="48"/></g></g><g><g><g><rect height="10.2807617" width="2" x="26" y="38.7192383"/></g></g><g><g><g><g><path d="M50,38.7539063H2V2h48V38.7539063z M4,36.7539063h44V4H4V36.7539063z"/></g></g><g><g><rect height="2" width="46" x="3" y="9.7231445"/></g></g><g><g><rect height="2" width="46" x="3" y="19.3769531"/></g></g><g><g><rect height="2" width="46" x="3" y="28.0654297"/></g></g></g><g><g><g><rect height="2" width="3" x="38" y="5.8613281"/></g></g><g><g><rect height="2" width="3" x="38" y="14.5498047"/></g></g><g><g><rect height="2" width="3" x="38" y="23.2382813"/></g></g><g><g><rect height="2" width="3" x="38" y="31.9267578"/></g></g></g><g><g><rect height="2" width="10" x="11.5" y="5.8613281"/></g></g><g><g><rect height="2" width="10" x="11.5" y="14.5498047"/></g></g><g><g><rect height="2" width="10" x="11.5" y="23.2382813"/></g></g><g><g><rect height="2" width="10" x="11.5" y="31.9267578"/></g></g></g></g></g></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_off.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_off.svg new file mode 100644 index 0000000000000000000000000000000000000000..49101de0736a732bbcc0367b38cbf20a913a8c13 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_off.svg @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light_all_off.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="41.7193" + inkscape:cx="31.52936" + inkscape:cy="29.058165" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29" + style="fill:#808080"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" + style="fill:#808080" /></g><g + id="g33" + style="fill:#808080"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" + style="fill:#808080" /></g><g + id="g37" + style="fill:#808080"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" + style="fill:#808080" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_on.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_on.svg new file mode 100644 index 0000000000000000000000000000000000000000..3ee57b04984d78771ef6c4ccc5f6f030698e81cf --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_all_on.svg @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="7.375" + inkscape:cx="25.645583" + inkscape:cy="34.533064" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="g5" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" /></g><g + id="g33"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" /></g><g + id="g37"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_green.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_green.svg new file mode 100644 index 0000000000000000000000000000000000000000..c46d0f3c48240399324a9b5dc8ae9c6af84ddda8 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_green.svg @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light_red.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="41.7193" + inkscape:cx="31.52936" + inkscape:cy="40.563632" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29" + style="fill:#808080"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" + style="fill:#808080" /></g><g + id="g33" + style="fill:#808080"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" + style="fill:#808080" /></g><g + id="g37"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red.svg new file mode 100644 index 0000000000000000000000000000000000000000..dbfa277c8a0860daa6686641b3e300394722c903 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red.svg @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="41.7193" + inkscape:cx="31.52936" + inkscape:cy="29.058165" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29" + style="fill:#808080"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" + style="fill:#808080" /></g><g + id="g33"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" /></g><g + id="g37"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" + style="fill:#808080" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red_yellow.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red_yellow.svg new file mode 100644 index 0000000000000000000000000000000000000000..25c70bd6f857d94e5e0e3b979e921e13203b15fc --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_red_yellow.svg @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light_all_off.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="41.7193" + inkscape:cx="31.52936" + inkscape:cy="29.058165" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" /></g><g + id="g33"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" /></g><g + id="g37" + style="fill:#808080"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" + style="fill:#808080" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_yellow.svg b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_yellow.svg new file mode 100644 index 0000000000000000000000000000000000000000..0a9715e709a7b23dc74c2ea5339d58f37f05abda --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/icons/traffic_light_yellow.svg @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + enable-background="new 0 0 64 64" + height="64px" + version="1.1" + viewBox="0 0 64 64" + width="64px" + xml:space="preserve" + id="svg2" + inkscape:version="0.48.4 r9939" + sodipodi:docname="traffic_light_green.svg"><metadata + id="metadata46"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs + id="defs44" /><sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1920" + inkscape:window-height="1028" + id="namedview42" + showgrid="false" + inkscape:zoom="41.7193" + inkscape:cx="31.52936" + inkscape:cy="29.058165" + inkscape:window-x="1280" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:current-layer="Layer_1" /><g + id="Layer_1"><g + id="g5" /><g + opacity="0.2" + id="g9"><path + d="M44,54c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V14c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V54z" + fill="#231F20" + id="path11" /></g><g + id="g13"><path + d="M44,52c0,1.657-1.343,3-3,3H23c-1.657,0-3-1.343-3-3V12c0-1.657,1.343-3,3-3h18c1.657,0,3,1.343,3,3V52z" + fill="#4F5D73" + id="path15" /></g><g + opacity="0.2" + id="g17"><circle + cx="32" + cy="34" + fill="#231F20" + r="5" + id="circle19" /></g><g + opacity="0.2" + id="g21"><circle + cx="32" + cy="21" + fill="#231F20" + r="5" + id="circle23" /></g><g + opacity="0.2" + id="g25"><circle + cx="32" + cy="47" + fill="#231F20" + r="5" + id="circle27" /></g><g + id="g29"><circle + cx="32" + cy="32" + fill="#F5CF87" + r="5" + id="circle31" /></g><g + id="g33" + style="fill:#808080"><circle + cx="32" + cy="19" + fill="#C75C5C" + r="5" + id="circle35" + style="fill:#808080" /></g><g + id="g37" + style="fill:#808080"><circle + cx="32" + cy="45" + fill="#76C2AF" + r="5" + id="circle39" + style="fill:#808080" /></g></g><g + id="Layer_2" /></svg> \ No newline at end of file diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.cpp b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d1f124f0f16b30418ecc1f31b9a93545ec639fb --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.cpp @@ -0,0 +1,188 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package ArmarXGui::EnhancedGraphicsView + * @author Raphael Grimm ( raphael dot grimm at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#include <QGraphicsItem> + +#include "EnhancedGraphicsView.h" + +namespace armarx +{ + + Qt::KeyboardModifier EnhancedGraphicsView::getRotationKeyboardModifier() const + { + return rotationModifier; + } + + qreal EnhancedGraphicsView::getRotationFactor() const + { + return rotationFactor; + } + + Qt::KeyboardModifier EnhancedGraphicsView::getZoomKeyboardModifier() const + { + return zoomModifier; + } + + qreal EnhancedGraphicsView::getZoomFactor() const + { + return zoomFacor; + } + + Qt::KeyboardModifier EnhancedGraphicsView::getDraggingKeyboardModifier() const + { + return draggingModifier; + } + + Qt::MouseButton EnhancedGraphicsView::getDraggingMouseButton() const + { + return draggingButton; + } + + void EnhancedGraphicsView::setRotationEnabled(bool enabled) + { + rotationEnabled = enabled; + } + + void EnhancedGraphicsView::setRotationDisabled(bool disabled) + { + rotationEnabled = !disabled; + } + + void EnhancedGraphicsView::setRotationKeyboardModifier(Qt::KeyboardModifier mod) + { + rotationModifier = mod; + } + + void EnhancedGraphicsView::setRotationFactor(qreal factor) + { + rotationFactor = factor; + } + + void EnhancedGraphicsView::setZoomEnabled(bool enabled) + { + zoomEnabled = enabled; + } + + void EnhancedGraphicsView::setZoomDisabled(bool disabled) + { + zoomEnabled = !disabled; + } + + void EnhancedGraphicsView::setZoomKeyboardModifier(Qt::KeyboardModifier mod) + { + zoomModifier = mod; + } + + void EnhancedGraphicsView::setZoomFactor(qreal factor) + { + zoomFacor = factor; + } + + void EnhancedGraphicsView::setDraggingEnabled(bool enabled) + { + draggingEnabled = enabled; + } + + void EnhancedGraphicsView::setDraggingDisabled(bool disabled) + { + draggingEnabled = !disabled; + } + + void EnhancedGraphicsView::setDraggingKeyboardModifier(Qt::KeyboardModifier mod) + { + draggingModifier = mod; + } + + void EnhancedGraphicsView::setDraggingMouseButton(Qt::MouseButton button) + { + draggingButton = button; + } + + void EnhancedGraphicsView::setAllVisible(bool visible) + { + for (QGraphicsItem* i : items()) + { + i->setVisible(visible); + } + } + + void EnhancedGraphicsView::mousePressEvent(QMouseEvent* e) + { + draggingStartPosition = mapToScene(e->pos()); + QGraphicsView::mousePressEvent(e); + } + + void EnhancedGraphicsView::mouseMoveEvent(QMouseEvent* e) + { + if ( + (e->modifiers() & draggingModifier) == draggingModifier && + (e->buttons() & draggingButton) == draggingButton + ) + { + const auto oldAnchor = transformationAnchor(); + setTransformationAnchor(QGraphicsView::NoAnchor); + + const QPointF vector = mapToScene(e->pos()) - draggingStartPosition; + translate(vector.x(), vector.y()); + draggingStartPosition = mapToScene(e->pos()); + e->accept(); + + setTransformationAnchor(oldAnchor); + return; + } + QGraphicsView::mouseMoveEvent(e); + } + + void EnhancedGraphicsView::wheelEvent(QWheelEvent* e) + { + bool used = false; + if ((e->modifiers() & zoomModifier) == zoomModifier) + { + const auto oldAnchor = transformationAnchor(); + setTransformationAnchor(QGraphicsView::NoAnchor); + + float factor = std::pow(zoomFacor, e->delta() < 0 ? -1 : +1); + scale(factor, factor); + used = true; + + setTransformationAnchor(oldAnchor); + } + if ((e->modifiers() & rotationModifier) == rotationModifier) + { + const auto oldAnchor = transformationAnchor(); + setTransformationAnchor(QGraphicsView::NoAnchor); + + rotate(e->delta() * rotationFactor); + used = true; + + setTransformationAnchor(oldAnchor); + } + if (used) + { + e->accept(); + } + else + { + QGraphicsView::wheelEvent(e); + } + } + +} diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.h b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.h new file mode 100644 index 0000000000000000000000000000000000000000..32c9b0b27bf4c37bf32cc91688af15275db46826 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedGraphicsView.h @@ -0,0 +1,94 @@ +/* + * This file is part of ArmarX. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @package ArmarXGui::EnhancedGraphicsView + * @author Raphael Grimm ( raphael dot grimm at student dot kit dot edu ) + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARX_ArmarXGui_EnhancedGraphicsView_H +#define _ARMARX_ArmarXGui_EnhancedGraphicsView_H + +#include <QGraphicsView> +#include <QPointF> +#include <QMouseEvent> +#include <QWheelEvent> +#include <cmath> +namespace armarx +{ + /** + * @brief The EnhancedGraphicsView is a QGraphicsView with some additional + * functions. + * + * Additional functions are: + * - Zooming (default ctrl+scroll) + * - Roatating (default shift+scroll) + * - Dragging the scene (default ctrl+left click+dragging) + */ + class EnhancedGraphicsView: public QGraphicsView + { + Q_OBJECT + public: + using QGraphicsView::QGraphicsView; + + Qt::KeyboardModifier getRotationKeyboardModifier() const; + qreal getRotationFactor() const; + + Qt::KeyboardModifier getZoomKeyboardModifier() const; + qreal setZoomFactor(); + qreal getZoomFactor() const; + + Qt::KeyboardModifier getDraggingKeyboardModifier() const; + Qt::MouseButton getDraggingMouseButton() const; + public slots: + void setRotationEnabled(bool enabled = true); + void setRotationDisabled(bool disabled = true); + void setRotationKeyboardModifier(Qt::KeyboardModifier mod); + void setRotationFactor(qreal factor); + + void setZoomEnabled(bool enabled = true); + void setZoomDisabled(bool disabled = true); + void setZoomKeyboardModifier(Qt::KeyboardModifier mod); + void setZoomFactor(qreal factor); + + void setDraggingEnabled(bool enabled = true); + void setDraggingDisabled(bool disabled = true); + void setDraggingKeyboardModifier(Qt::KeyboardModifier mod); + void setDraggingMouseButton(Qt::MouseButton button); + + void setAllVisible(bool visible); + + protected: + virtual void mousePressEvent(QMouseEvent* e) override; + virtual void mouseMoveEvent(QMouseEvent* e) override; + virtual void wheelEvent(QWheelEvent* e) override; + + bool rotationEnabled {true}; + Qt::KeyboardModifier rotationModifier {Qt::ShiftModifier}; + qreal rotationFactor {0.01}; + + bool zoomEnabled {true}; + Qt::KeyboardModifier zoomModifier {Qt::ControlModifier}; + qreal zoomFacor {1.05}; + + bool draggingEnabled {true}; + Qt::KeyboardModifier draggingModifier {Qt::ControlModifier}; + Qt::MouseButton draggingButton {Qt::LeftButton}; + QPointF draggingStartPosition; + }; +} +#endif diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.cpp b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..926c01d81434d75d78019b822201fbe25742e6b7 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.cpp @@ -0,0 +1,127 @@ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * @package ArmarX::RobotAPI + * @author Raphael Grimm <raphael dot grimm at student dot kit dot edu> + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "EnhancedTreeWidget.h" + +#include <QHeaderView> +#include <QWheelEvent> +#include <QScrollBar> + +namespace armarx +{ + + int EnhancedTreeWidget::getHeight() + { + int sz = 0; + for (int i = 0; i < topLevelItemCount(); ++i) + { + sz += calcHeight(topLevelItem(i)); + } + if (!isHeaderHidden()) + { + sz += header()->height(); + } + return sz + 2; + } + + void EnhancedTreeWidget::setWheelTicksPerScrollTick(int wheelTicksPerScrollTick) + { + this->wheelTicksPerScrollTick = wheelTicksPerScrollTick; + } + + void EnhancedTreeWidget::wheelEvent(QWheelEvent* event) + { + if (event->orientation() == Qt::Horizontal) + { + if (horizontalScrollMode() == QAbstractItemView::ScrollPerPixel) + { + hdelta += event->delta(); + horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (hdelta / wheelTicksPerScrollTick)); + hdelta = hdelta % wheelTicksPerScrollTick; + } + else + { + QTreeWidget::wheelEvent(event); + } + } + else + { + if (verticalScrollMode() == QAbstractItemView::ScrollPerPixel) + { + vdelta += event->delta(); + verticalScrollBar()->setValue(verticalScrollBar()->value() - (vdelta / wheelTicksPerScrollTick)); + vdelta = hdelta % wheelTicksPerScrollTick; + } + else + { + QTreeWidget::wheelEvent(event); + } + } + event->accept(); + } + + void EnhancedTreeWidget::expand() + { + setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed); + setFixedHeight(getHeight()); + } + + void EnhancedTreeWidget::setAutoExpand(bool active) + { + if (active) + { + expand(); + connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(expand())); + connect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand())); + } + else + { + disconnect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(expand())); + disconnect(this, SIGNAL(expanded(QModelIndex)), this, SLOT(expand())); + } + } + + int EnhancedTreeWidget::calcHeight(QTreeWidgetItem* it) + { + int sz = 0; + if (it->isHidden()) + { + return sz; + } + for (int i = 0; i < it->columnCount(); ++i) + { + sz = std::max(sz, rowHeight(indexFromItem(it, i))); + } + if (it->isExpanded()) + { + for (int i = 0; i < it->childCount(); ++i) + { + sz += calcHeight(it->child(i)); + } + } + return sz; + } + +} diff --git a/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.h b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..5397f9f08a4cd808b62332eb815d62c045465d30 --- /dev/null +++ b/source/ArmarXGui/libraries/ArmarXGuiBase/widgets/EnhancedTreeWidget.h @@ -0,0 +1,61 @@ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * ArmarX is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ArmarX is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * @package ArmarX::RobotAPI + * @author Raphael Grimm <raphael dot grimm at student dot kit dot edu> + * @date 2017 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#ifndef _ARMARXGUI_PLUGINS_EnhancedTreeWidget_H +#define _ARMARXGUI_PLUGINS_EnhancedTreeWidget_H + +#include <QTreeWidget> + +namespace armarx +{ + /** + * @brief The EnhancedTreeWidget is a QTreeWidget with some extra functionalities. + * + * This TreeWidget: + * - has working pixel wise scrolling + * - can expand its size to the size of its content (currently visible widgets) + * - can be set to auto expadn its size to its content + */ + class EnhancedTreeWidget : public QTreeWidget + { + Q_OBJECT + public: + using QTreeWidget::QTreeWidget; + int getHeight(); + protected: + virtual void wheelEvent(QWheelEvent* event) override; + public slots: + void expand(); + void setAutoExpand(bool active); + void setWheelTicksPerScrollTick(int wheelTicksPerScrollTick); + private: + int calcHeight(QTreeWidgetItem* it); + + int vdelta = 0; + int hdelta = 0; + int wheelTicksPerScrollTick = 8; + }; +} +#endif diff --git a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/CMakeLists.txt b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/CMakeLists.txt index 4c31ee7eeeb89b61b7cafb5b56acb3fec4bb0f07..5cc314eae0e57155334c0a1b21633c2bfd0c1c62 100644 --- a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/CMakeLists.txt +++ b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/CMakeLists.txt @@ -3,7 +3,7 @@ set(LIB_NAME DefaultWidgetDescriptions) armarx_component_set_name("${LIB_NAME}") armarx_set_target("Library: ${LIB_NAME}") -set(LIBS ArmarXGuiInterfaces) +set(LIBS ArmarXCore ArmarXGuiInterfaces) set(LIB_FILES DefaultWidgetDescriptions.cpp) set(LIB_HEADERS DefaultWidgetDescriptions.h ) diff --git a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.cpp b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.cpp index 419b1b1fdd9c5646200817bb3997fd1979d89884..1dde818bf17e922289b2fc1ce6858017fadf4d44 100644 --- a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.cpp +++ b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.cpp @@ -20,79 +20,271 @@ * GNU General Public License */ +#include <ArmarXCore/core/exceptions/local/ExpressionException.h> + #include "DefaultWidgetDescriptions.h" +namespace armarx +{ + namespace WidgetDescription + { + //base widgets + HBoxLayoutPtr makeHBoxLayout(std::vector<WidgetPtr> elements) + { + HBoxLayoutPtr w = new HBoxLayout; + w->children = std::move(elements); + return w; + } -using namespace armarx; + VBoxLayoutPtr makeVBoxLayout(std::vector<WidgetPtr> elements) + { + VBoxLayoutPtr w = new VBoxLayout; + w->children = std::move(elements); + return w; + } + FormLayoutElementPtr makeFormLayoutElement(WidgetPtr labelWidget, WidgetPtr child) + { + ARMARX_CHECK_NOT_NULL(labelWidget); + ARMARX_CHECK_NOT_NULL(child); + FormLayoutElementPtr e = new FormLayoutElement; + e->labelWidget = std::move(labelWidget); + e->child = std::move(child); + e->childIsSpanning = false; + return e; + } + FormLayoutElementPtr makeFormLayoutElement(std::string name, WidgetPtr child, bool spanning) + { + ARMARX_CHECK_NOT_NULL(child); + FormLayoutElementPtr e = new FormLayoutElement; + e->label = std::move(name); + e->child = std::move(child); + e->childIsSpanning = spanning; + return e; + } -WidgetDescription::HBoxLayoutPtr WidgetDescription::makeXYZRollPitchYawWidgetDescription( - const std::string &namePrefix, - float initX, - float initY, - float initz, - float initRoll, - float initPitch, - float initYaw) -{ - HBoxLayoutPtr layout = new HBoxLayout; - { - layout->widgets.emplace_back(new Label{"x / y / z"}); - { - FloatSpinBoxPtr spinX = new FloatSpinBox; - spinX->defaultValue=initX; - spinX->max = +10000; - spinX->min = -10000; - spinX->name=namePrefix+"X"; - layout->widgets.emplace_back(spinX); - } - { - FloatSpinBoxPtr spinY = new FloatSpinBox; - spinY->defaultValue=initY; - spinY->max = +10000; - spinY->min = -10000; - spinY->name=namePrefix+"Y"; - layout->widgets.emplace_back(spinY); - } - { - FloatSpinBoxPtr spinZ = new FloatSpinBox; - spinZ->defaultValue=initz; - spinZ->max = 10000; - spinZ->min = 0; - spinZ->name=namePrefix+"Z"; - layout->widgets.emplace_back(spinZ); - } - layout->widgets.emplace_back(new Label{" "}); - layout->widgets.emplace_back(new Label{"rx / ry / rz"}); - { - FloatSpinBoxPtr spinRoll = new FloatSpinBox; - spinRoll->defaultValue=initRoll; - spinRoll->max = +M_PI*10; - spinRoll->min = -M_PI*10; - spinRoll->steps = 2000; - spinRoll->name=namePrefix+"Roll"; - layout->widgets.emplace_back(spinRoll); - } - { - FloatSpinBoxPtr spinPitch = new FloatSpinBox; - spinPitch->defaultValue = initPitch; - spinPitch->max = +M_PI*10; - spinPitch->min = -M_PI*10; - spinPitch->steps = 2000; - spinPitch->name=namePrefix+"Pitch"; - layout->widgets.emplace_back(spinPitch); - } - { - FloatSpinBoxPtr spinYaw = new FloatSpinBox; - spinYaw->defaultValue=initYaw; - spinYaw->max = +M_PI*10; - spinYaw->min = -M_PI*10; - spinYaw->steps = 2000; - spinYaw->name=namePrefix+"Yaw"; - layout->widgets.emplace_back(spinYaw); - layout->widgets.emplace_back(new Label{"rz"}); - } - return layout; + FormLayoutElementPtr makeFormLayoutElement(WidgetPtr child, bool spanning) + { + ARMARX_CHECK_NOT_NULL(child); + FormLayoutElementPtr e = new FormLayoutElement; + if (ConfigWidgetPtr::dynamicCast(child)) + { + e->label = ConfigWidgetPtr::dynamicCast(child)->name; + } + e->child = std::move(child); + e->childIsSpanning = spanning; + return e; + } + + FormLayoutElementPtr makeSpanningFormLayoutElement(WidgetPtr child) + { + return makeFormLayoutElement(std::move(child), true); + } + + FormLayoutPtr makeFormLayout(std::vector<std::pair<std::string, WidgetPtr> > elements) + { + FormLayoutPtr l = new FormLayout; + l->children.reserve(elements.size()); + for (auto& elem : elements) + { + l->children.emplace_back(makeFormLayoutElement(std::move(elem.first), std::move(elem.second))); + } + return l; + } + + FormLayoutPtr makeFormLayout(std::vector<WidgetPtr> elements) + { + FormLayoutPtr l = new FormLayout; + l->children.reserve(elements.size()); + for (auto& elem : elements) + { + l->children.emplace_back(makeFormLayoutElement(std::move(elem))); + } + return l; + } + + GroupBoxPtr makeGroupBox(std::string label, WidgetPtr child, bool framed) + { + GroupBoxPtr w = new GroupBox; + w->child = std::move(child); + w->label = std::move(label); + w->framed = framed; + return w; + } + + WidgetPtr makeFrame(WidgetPtr child) + { + child->framed = true; + return std::move(child); + } + + HSpacerPtr makeHSpacer() + { + return new HSpacer; + } + + VSpacerPtr makeVSpacer() + { + return new VSpacer; + } + + HLinePtr makeHLine() + { + return new HLine; + } + + VLinePtr makeVLine() + { + return new VLine; + } + + LabelPtr makeLabel(std::string text) + { + return new Label {false, std::move(text)}; + } + + CheckBoxPtr makeCheckBox(std::string name, bool defaultValue, std::string label) + { + CheckBoxPtr w = new CheckBox; + w->name = std::move(name); + w->label = std::move(label); + w->defaultValue = defaultValue; + return w; + } + CheckBoxPtr makeCheckBox(std::string name, bool defaultValue) + { + CheckBoxPtr w = new CheckBox; + w->name = std::move(name); + w->label = w->name; + w->defaultValue = defaultValue; + return w; + } + + IntSpinBoxPtr makeIntSpinBox(std::string name, int min, int max, int defaultValue) + { + IntSpinBoxPtr w = new IntSpinBox; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + return w; + } + + FloatSpinBoxPtr makeFloatSpinBox(std::string name, float min, float max, float defaultValue, int steps, int decimals) + { + FloatSpinBoxPtr w = new FloatSpinBox; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + w->steps = steps; + w->decimals = decimals; + return w; + } + + DoubleSpinBoxPtr makeDoubleSpinBox(std::string name, double min, double max, double defaultValue, int steps, int decimals) + { + DoubleSpinBoxPtr w = new DoubleSpinBox; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + w->steps = steps; + w->decimals = decimals; + return w; + } + + IntSliderPtr makeIntSlider(std::string name, int min, int max, int defaultValue) + { + IntSliderPtr w = new IntSlider; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + return w; + } + + FloatSliderPtr makeFloatSlider(std::string name, float min, float max, float defaultValue) + { + FloatSliderPtr w = new FloatSlider; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + return w; + } + + DoubleSliderPtr makeDoubleSlider(std::string name, double min, double max, double defaultValue) + { + DoubleSliderPtr w = new DoubleSlider; + w->name = std::move(name); + w->min = min; + w->max = max; + w->defaultValue = defaultValue; + return w; + } + + StringComboBoxPtr makeStringComboBox(std::string name, std::vector<std::string> options, long defaultIndex) + { + StringComboBoxPtr w = new StringComboBox; + w->name = std::move(name); + w->options = std::move(options); + w->defaultIndex = defaultIndex; + return w; + } + + LineEditPtr makeLineEdit(std::string name, std::string defaultValue) + { + LineEditPtr w = new LineEdit; + w->name = std::move(name); + w->defaultValue = std::move(defaultValue); + return w; + } + + FloatLineEditPtr makeFloatLineEdit(std::string name, float defaultValue) + { + FloatLineEditPtr w = new FloatLineEdit; + w->name = std::move(name); + w->defaultValue = defaultValue; + return w; + } + + DoubleLineEditPtr makeDoubleLineEdit(std::string name, double defaultValue) + { + DoubleLineEditPtr w = new DoubleLineEdit; + w->name = std::move(name); + w->defaultValue = defaultValue; + return w; + } + + //more complex widgets + HBoxLayoutPtr makeXYZRollPitchYawWidget( + const std::string& namePrefix, + float initX, + float initY, + float initZ, + float initRoll, + float initPitch, + float initYaw, + FloatRange rangeX, + FloatRange rangeY, + FloatRange rangeZ, + FloatRange rangeRoll, + FloatRange rangePitch, + FloatRange rangeYaw) + { + return makeHBoxLayout( + { + makeLabel("x / y / z"), + makeFloatSpinBox(namePrefix + "X", rangeX.min, rangeX.max, initX), + makeFloatSpinBox(namePrefix + "Y", rangeY.min, rangeY.max, initY), + makeFloatSpinBox(namePrefix + "Z", rangeZ.min, rangeZ.max, initZ), + makeLabel(" rx / ry / rz"), + makeFloatSpinBox(namePrefix + "Roll" , rangeRoll.min , rangeRoll.max , initRoll , 2000), + makeFloatSpinBox(namePrefix + "Pitch", rangePitch.min, rangePitch.max, initPitch, 2000), + makeFloatSpinBox(namePrefix + "Yaw" , rangeYaw.min , rangeYaw.max , initYaw , 2000) + }); + } } } diff --git a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.h b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.h index 9531974fbeb6e8a26e8487e0bf280ec69657c7c0..c892d4b45c134c532749f0f87ee972266905eb45 100644 --- a/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.h +++ b/source/ArmarXGui/libraries/DefaultWidgetDescriptions/DefaultWidgetDescriptions.h @@ -29,17 +29,71 @@ namespace armarx { namespace WidgetDescription { - /** - * @brief Values will have the names namePrefix{X,Y,Z,Roll,Pitch,Yaw} - */ - HBoxLayoutPtr makeXYZRollPitchYawWidgetDescription( - const std::string& namePrefix ="", - float initX =0, - float initY =0, - float initz =0, - float initRoll =0, - float initPitch =0, - float initYaw =0); + //base widgets + HBoxLayoutPtr makeHBoxLayout(std::vector<WidgetPtr> elements); + VBoxLayoutPtr makeVBoxLayout(std::vector<WidgetPtr> elements); + + FormLayoutElementPtr makeFormLayoutElement(WidgetPtr child, bool spanning = false); + FormLayoutElementPtr makeSpanningFormLayoutElement(WidgetPtr child); + FormLayoutElementPtr makeFormLayoutElement(std::string name, WidgetPtr child, bool spanning = false); + FormLayoutElementPtr makeFormLayoutElement(WidgetPtr labelWidget, WidgetPtr child); + + FormLayoutPtr makeFormLayout(std::vector<std::pair<std::string, WidgetPtr>> elements); + FormLayoutPtr makeFormLayout(std::vector<WidgetPtr> elements); + + GroupBoxPtr makeGroupBox(std::string label, WidgetPtr child, bool framed = false); + + WidgetPtr makeFrame(WidgetPtr child); + + HSpacerPtr makeHSpacer(); + VSpacerPtr makeVSpacer(); + HLinePtr makeHLine(); + VLinePtr makeVLine(); + LabelPtr makeLabel(std::string text); + + CheckBoxPtr makeCheckBox(std::string name, bool defaultValue, std::string label); + CheckBoxPtr makeCheckBox(std::string name, bool defaultValue = false); + + IntSpinBoxPtr makeIntSpinBox(std::string name, int min = 0, int max = 100, int defaultValue = 0); + FloatSpinBoxPtr makeFloatSpinBox(std::string name, float min = 0, float max = 100, float defaultValue = 0, int steps = 100, int decimals = 3); + DoubleSpinBoxPtr makeDoubleSpinBox(std::string name, double min = 0, double max = 100, double defaultValue = 0, int steps = 100, int decimals = 3); + + IntSliderPtr makeIntSlider(std::string name, int min = 0, int max = 100, int defaultValue = 0); + FloatSliderPtr makeFloatSlider(std::string name, float min = 0, float max = 100, float defaultValue = 0); + DoubleSliderPtr makeDoubleSlider(std::string name, double min = 0, double max = 100, double defaultValue = 0); + + StringComboBoxPtr makeStringComboBox(std::string name, std::vector<std::string> options, long defaultIndex = 0); + + LineEditPtr makeLineEdit(std::string name, std::string defaultValue = ""); + FloatLineEditPtr makeFloatLineEdit(std::string name, float defaultValue = 0); + DoubleLineEditPtr makeDoubleLineEdit(std::string name, double defaultValue = 0); + + //more complex widgets + /** + * @brief Values will have the names namePrefix{X,Y,Z,Roll,Pitch,Yaw} + */ + HBoxLayoutPtr makeXYZRollPitchYawWidget( + const std::string& namePrefix = "", + float initX = 0, + float initY = 0, + float initZ = 0, + float initRoll = 0, + float initPitch = 0, + float initYaw = 0, + FloatRange rangeX = { -25000 , 25000}, + FloatRange rangeY = { -25000 , 25000}, + FloatRange rangeZ = { -0 , 25000}, + FloatRange rangeRoll = { -M_PI, M_PI}, + FloatRange rangePitch = { -M_PI, M_PI}, + FloatRange rangeYaw = { -M_PI, M_PI}); + + inline HBoxLayoutPtr makeXYZRollPitchYawWidget( + const std::string& namePrefix, + FloatRange rangeLin, + FloatRange rangeAng) + { + return makeXYZRollPitchYawWidget(namePrefix, 0, 0, 0, 0, 0, 0, rangeLin, rangeLin, rangeLin, rangeAng, rangeAng, rangeAng); + } } } diff --git a/source/ArmarXGui/libraries/VariantWidget/VariantWidget.cpp b/source/ArmarXGui/libraries/VariantWidget/VariantWidget.cpp index 0a53a1b7c692eb1a045f42762b0b545273bf4dcc..45a4c25d9c59b0aec1ccb0afa9966b229c9453df 100644 --- a/source/ArmarXGui/libraries/VariantWidget/VariantWidget.cpp +++ b/source/ArmarXGui/libraries/VariantWidget/VariantWidget.cpp @@ -51,7 +51,7 @@ namespace armarx }; BoolVariantDataWidget(const VariantDataPtr& v): - disp {DisplayOption::X} + disp {DisplayOption::Boolalpha} { auto l = new QVBoxLayout; l->setContentsMargins(0, 0, 0, 0); diff --git a/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.cpp b/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.cpp index cf417d13772f74bed5b8fa076a6db81d980cc0cb..70893ed57ae12d12cf9e588eb67ba943b8d95e02 100644 --- a/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.cpp +++ b/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.cpp @@ -38,6 +38,7 @@ #include <QCheckBox> #include <QDoubleValidator> #include <QSlider> +#include <QGroupBox> #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #include <qwt_slider.h> @@ -50,7 +51,7 @@ namespace armarx class DescribedWidget : public DescribedWidgetBase { public: - DescribedWidget(const WidgetPtr&, ValueChangedListenerInterface*) {} + DescribedWidget(const WidgetPtr& ptr, ValueChangedListenerInterface*): DescribedWidgetBase(ptr) {} virtual std::map<std::string, VariantBasePtr> getVariants() override { return {}; @@ -62,15 +63,15 @@ namespace armarx { public: DescribedVBoxLayout(const WidgetPtr& p, ValueChangedListenerInterface* listener) - : DescribedWidgetLayoutBase(listener) + : DescribedWidgetLayoutBase(p, listener) { VBoxLayoutPtr ptr = VBoxLayoutPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setLayout(new QVBoxLayout); - for (const WidgetPtr& childPtr : ptr->widgets) + layout()->setContentsMargins(0, 0, 0, 0); + for (const WidgetPtr& childPtr : ptr->children) { - addChild(childPtr); - layout()->addWidget(children.back()); + layout()->addWidget(addChild(childPtr)); } } @@ -81,15 +82,15 @@ namespace armarx { public: DescribedHBoxLayout(const WidgetPtr& p, ValueChangedListenerInterface* listener) - : DescribedWidgetLayoutBase(listener) + : DescribedWidgetLayoutBase(p, listener) { HBoxLayoutPtr ptr = HBoxLayoutPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setLayout(new QHBoxLayout); - for (const WidgetPtr& childPtr : ptr->widgets) + layout()->setContentsMargins(0, 0, 0, 0); + for (const WidgetPtr& childPtr : ptr->children) { - addChild(childPtr); - layout()->addWidget(children.back()); + layout()->addWidget(addChild(childPtr)); } } }; @@ -99,26 +100,82 @@ namespace armarx { public: DescribedFormLayout(const WidgetPtr& p, ValueChangedListenerInterface* listener) - : DescribedWidgetLayoutBase(listener) + : DescribedWidgetLayoutBase(p, listener) { FormLayoutPtr ptr = FormLayoutPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); auto l = new QFormLayout; setLayout(l); - for (const auto& pair : ptr->widgets) + layout()->setContentsMargins(0, 0, 0, 0); + for (const FormLayoutElementPtr& child : ptr->children) { - addChild(pair.second); - l->addRow(QString::fromStdString(pair.first), children.back()); + if (child->childIsSpanning) + { + l->addRow(addChild(child->child)); + continue; + } + if (child->labelWidget) + { + l->addRow(addChild(child->labelWidget), addChild(child->child)); + continue; + } + l->addRow(QString::fromStdString(child->label), addChild(child->child)); } } }; DescribedWidgetFactoryRegistration<DescribedFormLayout> registerDescribedFormLayout {FormLayout::ice_staticId()}; + class DescribedFormLayoutElement : public DescribedWidgetLayoutBase + { + public: + DescribedFormLayoutElement(const WidgetPtr& p, ValueChangedListenerInterface* listener) + : DescribedWidgetLayoutBase(p, listener) + { + FormLayoutElementPtr ptr = FormLayoutElementPtr::dynamicCast(p); + ARMARX_CHECK_NOT_NULL(ptr); + auto l = new QFormLayout; + setLayout(l); + layout()->setContentsMargins(0, 0, 0, 0); + if (ptr->childIsSpanning) + { + l->addRow(addChild(ptr->child)); + } + if (ptr->labelWidget) + { + l->addRow(addChild(ptr->labelWidget), addChild(ptr->child)); + } + l->addRow(QString::fromStdString(ptr->label), addChild(ptr->child)); + } + }; + DescribedWidgetFactoryRegistration<DescribedFormLayoutElement> registerDescribedFormLayoutElement {FormLayoutElement::ice_staticId()}; + + class DescribedGroupBox : public DescribedWidgetLayoutBase + { + public: + DescribedGroupBox(const WidgetPtr& p, ValueChangedListenerInterface* listener) + : DescribedWidgetLayoutBase(p, listener) + { + GroupBoxPtr ptr = GroupBoxPtr::dynamicCast(p); + ARMARX_CHECK_NOT_NULL(ptr); + auto ltop = new QHBoxLayout; + setLayout(ltop); + layout()->setContentsMargins(0, 0, 0, 0); + QGroupBox* grp = new QGroupBox; + ltop->addWidget(grp); + grp->setTitle(QString::fromStdString(ptr->label)); + auto l = new QHBoxLayout; + grp->setLayout(l); + l->setContentsMargins(0, 9, 0, 0); + l->addWidget(addChild(ptr->child)); + } + }; + DescribedWidgetFactoryRegistration<DescribedGroupBox> DescribedGroupBox {GroupBox::ice_staticId()}; + //static elements class DescribedHSpacer : public DescribedWidgetBase { public: - DescribedHSpacer(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedHSpacer(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -134,7 +191,7 @@ namespace armarx class DescribedVSpacer : public DescribedWidgetBase { public: - DescribedVSpacer(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedVSpacer(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -147,13 +204,43 @@ namespace armarx }; DescribedWidgetFactoryRegistration<DescribedVSpacer> registerDescribedVSpacer {VSpacer::ice_staticId()}; + class DescribedHLine : public DescribedWidgetBase + { + public: + DescribedHLine(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) + { + setFrameShape(QFrame::HLine); + setFrameShadow(QFrame::Sunken); + } + virtual std::map<std::string, VariantBasePtr> getVariants() override + { + return {}; + } + }; + DescribedWidgetFactoryRegistration<DescribedHLine> registerDescribedHLine {HLine::ice_staticId()}; + + class DescribedVLine : public DescribedWidgetBase + { + public: + DescribedVLine(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) + { + setFrameShape(QFrame::VLine); + setFrameShadow(QFrame::Sunken); + } + virtual std::map<std::string, VariantBasePtr> getVariants() override + { + return {}; + } + }; + DescribedWidgetFactoryRegistration<DescribedVLine> registerDescribedVLine {VLine::ice_staticId()}; + class DescribedLabel : public DescribedWidgetBase { public: - DescribedLabel(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedLabel(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { auto ptr = LabelPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); layout()->addWidget(new QLabel(QString::fromStdString(ptr->text))); @@ -169,10 +256,10 @@ namespace armarx class DescribedVariantWidget : public DescribedWidgetBase { public: - DescribedVariantWidget(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedVariantWidget(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { auto ptr = VariantWidgetPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); child = new armarx::VariantWidget; @@ -211,10 +298,10 @@ namespace armarx class DescribedCheckBox : public DescribedWidgetBase { public: - DescribedCheckBox(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedCheckBox(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { CheckBoxPtr ptr = CheckBoxPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -240,10 +327,10 @@ namespace armarx class DescribedIntSpinBox : public DescribedWidgetBase { public: - DescribedIntSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedIntSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { IntSpinBoxPtr ptr = IntSpinBoxPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -271,16 +358,17 @@ namespace armarx class DescribedDoubleSpinBox : public DescribedWidgetBase { public: - DescribedDoubleSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedDoubleSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { DoubleSpinBoxPtr ptr = DoubleSpinBoxPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); child = new QDoubleSpinBox {}; child->setMaximum(ptr->max); child->setMinimum(ptr->min); + child->setDecimals(ptr->decimals); child->setValue(ptr->defaultValue); child->setSingleStep((ptr->max - ptr->min) / ptr->steps); layout()->addWidget(child); @@ -303,16 +391,17 @@ namespace armarx class DescribedFloatSpinBox : public DescribedWidgetBase { public: - DescribedFloatSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedFloatSpinBox(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { FloatSpinBoxPtr ptr = FloatSpinBoxPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); child = new QDoubleSpinBox {}; child->setMaximum(ptr->max); child->setMinimum(ptr->min); + child->setDecimals(ptr->decimals); child->setValue(ptr->defaultValue); child->setSingleStep((ptr->max - ptr->min) / ptr->steps); layout()->addWidget(child); @@ -335,10 +424,10 @@ namespace armarx class DescribedStringComboBox : public DescribedWidgetBase { public: - DescribedStringComboBox(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedStringComboBox(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { StringComboBoxPtr ptr = StringComboBoxPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -365,21 +454,20 @@ namespace armarx }; DescribedWidgetFactoryRegistration<DescribedStringComboBox> registerDescribedStringComboBox {StringComboBox::ice_staticId()}; - class DescribedLineEdit : public DescribedWidgetBase { public: - DescribedLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { LineEditPtr ptr = LineEditPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); child = new QLineEdit {}; child->setText(QString::fromStdString(ptr->defaultValue)); layout()->addWidget(child); - connect(child, SIGNAL(returnPressed()), this, SLOT(contentUpdated())); + connect(child, SIGNAL(editingFinished()), this, SLOT(contentUpdated())); } virtual std::map<std::string, VariantBasePtr> getVariants() override { @@ -398,10 +486,10 @@ namespace armarx class DescribedDoubleLineEdit : public DescribedWidgetBase { public: - DescribedDoubleLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedDoubleLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { DoubleLineEditPtr ptr = DoubleLineEditPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -409,7 +497,7 @@ namespace armarx child->setText(QString::number(ptr->defaultValue)); child->setValidator(new QDoubleValidator {this}); layout()->addWidget(child); - connect(child, SIGNAL(returnPressed()), this, SLOT(contentUpdated())); + connect(child, SIGNAL(editingFinished()), this, SLOT(contentUpdated())); } virtual std::map<std::string, VariantBasePtr> getVariants() override { @@ -420,7 +508,7 @@ namespace armarx protected: virtual void contentUpdated() override { - emit valueChangedSignal(getName(), new Variant {child->text().toStdString()}); + emit valueChangedSignal(getName(), new Variant {child->text().toDouble()}); } }; DescribedWidgetFactoryRegistration<DescribedDoubleLineEdit> registerDescribedDoubleLineEdit {DoubleLineEdit::ice_staticId()}; @@ -428,10 +516,10 @@ namespace armarx class DescribedFloatLineEdit : public DescribedWidgetBase { public: - DescribedFloatLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedFloatLineEdit(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { FloatLineEditPtr ptr = FloatLineEditPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -439,7 +527,7 @@ namespace armarx child->setText(QString::number(ptr->defaultValue)); child->setValidator(new QDoubleValidator {this}); layout()->addWidget(child); - connect(child, SIGNAL(returnPressed()), this, SLOT(contentUpdated())); + connect(child, SIGNAL(editingFinished()), this, SLOT(contentUpdated())); } virtual std::map<std::string, VariantBasePtr> getVariants() override { @@ -450,7 +538,7 @@ namespace armarx protected: virtual void contentUpdated() override { - emit valueChangedSignal(getName(), new Variant {child->text().toStdString()}); + emit valueChangedSignal(getName(), new Variant {static_cast<float>(child->text().toDouble())}); } }; DescribedWidgetFactoryRegistration<DescribedFloatLineEdit> registerDescribedFloatLineEdit {FloatLineEdit::ice_staticId()}; @@ -459,10 +547,10 @@ namespace armarx class DescribedIntSlider : public DescribedWidgetBase { public: - DescribedIntSlider(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedIntSlider(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { IntSliderPtr ptr = IntSliderPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); @@ -490,16 +578,17 @@ namespace armarx class DescribedDoubleSlider : public DescribedWidgetBase { public: - DescribedDoubleSlider(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedDoubleSlider(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { DoubleSliderPtr ptr = DoubleSliderPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); setLayout(new QVBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); child = new QwtSlider {this}; child->setRange(ptr->min, ptr->max); child->setValue(ptr->defaultValue); + doubleLabel = new QLabel(QString::number(ptr->defaultValue, 'g', 4), this); layout()->addWidget(child); connect(child, SIGNAL(valueChanged(double)), this, SLOT(contentUpdated())); } @@ -509,9 +598,11 @@ namespace armarx } private: QwtSlider* child; + QLabel* doubleLabel; protected: virtual void contentUpdated() override { + doubleLabel->setText(QString::number(child->value(), 'g', 4)); emit valueChangedSignal(getName(), new Variant(child->value())); } }; @@ -520,34 +611,40 @@ namespace armarx class DescribedFloatSlider : public DescribedWidgetBase { public: - DescribedFloatSlider(const WidgetPtr& p, ValueChangedListenerInterface*) + DescribedFloatSlider(const WidgetPtr& p, ValueChangedListenerInterface*): DescribedWidgetBase(p) { FloatSliderPtr ptr = FloatSliderPtr::dynamicCast(p); - ARMARX_CHECK_EXPRESSION(ptr); + ARMARX_CHECK_NOT_NULL(ptr); setName(ptr->name); - setLayout(new QVBoxLayout); + setLayout(new QHBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); child = new QwtSlider {this}; child->setRange(ptr->min, ptr->max); child->setValue(ptr->defaultValue); + floatLabel = new QLabel(QString::number(ptr->defaultValue, 'g', 4), this); layout()->addWidget(child); + layout()->addWidget(floatLabel); connect(child, SIGNAL(valueChanged(double)), this, SLOT(contentUpdated())); } virtual std::map<std::string, VariantBasePtr> getVariants() override { - return {{getName(), new Variant(child->value())}}; + return {{getName(), new Variant(static_cast<float>(child->value()))}}; } private: QwtSlider* child; + QLabel* floatLabel; protected: virtual void contentUpdated() override { - emit valueChangedSignal(getName(), new Variant(child->value())); + floatLabel->setText(QString::number(child->value(), 'g', 4)); + emit valueChangedSignal(getName(), new Variant(static_cast<float>(child->value()))); } }; DescribedWidgetFactoryRegistration<DescribedFloatSlider> registerDescribedFloatSlider {FloatSlider::ice_staticId()}; //functions from base classes + DescribedWidgetLayoutBase::DescribedWidgetLayoutBase(WidgetPtr ptr, ValueChangedListenerInterface* listener): DescribedWidgetBase(ptr), listener {listener ? listener : this} {} + std::map<std::string, VariantBasePtr> DescribedWidgetLayoutBase::getVariants() { std::map<std::string, VariantBasePtr> result; @@ -558,15 +655,16 @@ namespace armarx return result; } - void DescribedWidgetLayoutBase::addChild(const WidgetPtr& childPtr) + DescribedWidgetBase* DescribedWidgetLayoutBase::addChild(const WidgetPtr& childPtr) { + ARMARX_CHECK_EXPRESSION(listener); DescribedWidgetBase* c = makeDescribedWidget(childPtr, listener); children.emplace_back(c); - connect(c, SIGNAL(valueChangedSignal(std::string, VariantBasePtr)), listener, SLOT(valueChangedSlot(std::string, VariantBasePtr))); connect( this, SIGNAL(variantWidgetUpdatedSignal(std::string, VariantWidgetContent::VariantWidgetContentBasePtr)), c , SLOT(variantWidgetUpdatedSlot(std::string, VariantWidgetContent::VariantWidgetContentBasePtr)) ); + return c; } DescribedWidgetBase* makeDescribedWidget(const WidgetPtr& p, ValueChangedListenerInterface* listener) @@ -574,7 +672,7 @@ namespace armarx class ErrorMessageWidget : public DescribedWidgetBase { public: - ErrorMessageWidget(const std::string& errorMessage) + ErrorMessageWidget(const std::string& errorMessage): DescribedWidgetBase(nullptr) { setLayout(new QVBoxLayout); setName(".ErrorMessageWidget"); @@ -594,7 +692,12 @@ namespace armarx { try { - return DescribedWidgetFactory::get(type)(p, listener); + auto w = DescribedWidgetFactory::get(type)(p, listener); + if (listener) + { + QObject::connect(w, SIGNAL(valueChangedSignal(std::string, VariantBasePtr)), listener, SLOT(valueChangedSlot(std::string, VariantBasePtr))); + } + return w; } catch (std::exception& e) { @@ -612,5 +715,19 @@ namespace armarx return new ErrorMessageWidget {"makeDescribedWidget: Unknown error"}; } + DescribedWidgetBase::DescribedWidgetBase(WidgetPtr ptr) + { + if (ptr && ptr->framed) + { + setFrameShape(QFrame::StyledPanel); + } + } + + ValueChangedListenerInterface::ValueChangedListenerInterface() + { + setFrameShape(QFrame::NoFrame); + setFrameShadow(QFrame::Raised); + } + } } diff --git a/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.h b/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.h index 8fe82d93519e093add4e609882ede96f9a15c04c..baacde9394721dc4453f76b4728c6cc7fa581be9 100644 --- a/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.h +++ b/source/ArmarXGui/libraries/WidgetDescription/WidgetDescription.h @@ -25,7 +25,7 @@ #include <functional> -#include <QWidget> +#include <QFrame> #include <ArmarXCore/core/util/Registrar.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h> @@ -36,18 +36,21 @@ namespace armarx { namespace WidgetDescription { - class ValueChangedListenerInterface: public QWidget + class ValueChangedListenerInterface: public QFrame { Q_OBJECT + public: + ValueChangedListenerInterface(); public slots: virtual void valueChangedSlot(std::string name, VariantBasePtr value) {} }; - class DescribedWidgetBase: public ValueChangedListenerInterface { Q_OBJECT public: + DescribedWidgetBase(WidgetPtr ptr); + virtual std::map<std::string, VariantBasePtr> getVariants() { return {}; @@ -74,7 +77,7 @@ namespace armarx { Q_OBJECT public: - DescribedWidgetLayoutBase(ValueChangedListenerInterface* listener): listener {listener ? listener : this} {} + DescribedWidgetLayoutBase(WidgetPtr ptr, ValueChangedListenerInterface* listener); virtual std::map<std::string, VariantBasePtr> getVariants() override; virtual void valueChangedSlot(std::string name, VariantBasePtr value) override { @@ -84,7 +87,7 @@ namespace armarx { emit variantWidgetUpdatedSignal(name, data); } - virtual void addChild(const WidgetPtr& childPtr); + virtual DescribedWidgetBase* addChild(const WidgetPtr& childPtr); protected: std::vector<DescribedWidgetBase*> children;