diff --git a/data/ArmarXGui/VariantInfo-ArmarXGui.xml b/data/ArmarXGui/VariantInfo-ArmarXGui.xml index 865993f9505d3e89f8469e9b763ead1deba9d975..eebe860b050181ccab0a70066f6c9cff2ece6999 100644 --- a/data/ArmarXGui/VariantInfo-ArmarXGui.xml +++ b/data/ArmarXGui/VariantInfo-ArmarXGui.xml @@ -11,5 +11,13 @@ propertyName="StaticPlotterName" propertyIsOptional="true" propertyDefaultValue="StaticPlotter" /> + <Topic include="ArmarXGui/interface/MessageDisplayInterface.h" + humanName="Message Display Topic" + typeName="MessageDisplayInterfacePrx" + memberName="messageDisplay" + getterName="getMessageDisplayTopic" + propertyName="MessageDisplayName" + propertyIsOptional="true" + propertyDefaultValue="MessageDisplayTopic" /> </Lib> </VariantInfo> diff --git a/source/ArmarXGui/gui-plugins/CMakeLists.txt b/source/ArmarXGui/gui-plugins/CMakeLists.txt index 5155abfe0cc8c8037bb26b0da2473856680ee84c..55121f1a387e02ce5d1444a9f26636b1a136a1e7 100644 --- a/source/ArmarXGui/gui-plugins/CMakeLists.txt +++ b/source/ArmarXGui/gui-plugins/CMakeLists.txt @@ -16,3 +16,5 @@ add_subdirectory(TopicReplayerPlugin) add_subdirectory(IceProxy) add_subdirectory(PlotterPlugin) + +add_subdirectory(MessageDisplayPlugin) \ No newline at end of file diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/CMakeLists.txt b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f39733154a7971c8235d621667ab2f7812fc000 --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/CMakeLists.txt @@ -0,0 +1,41 @@ + +armarx_set_target("MessageDisplayPluginGuiPlugin") + +# most qt components will be linked against in the call armarx_gui_library +#armarx_find_qt(QtCore QtGui QtDesigner) + +# ArmarXGui gets included through depends_on_armarx_package(ArmarXGui "OPTIONAL") +# in the toplevel CMakeLists.txt +armarx_build_if(ArmarXGui_FOUND "ArmarXGui not available") + + +# all include_directories must be guarded by if(Xyz_FOUND) +# for multiple libraries write: if(X_FOUND AND Y_FOUND).... +#if(Xyz_FOUND) +# include(${Xyz_INCLUDE_DIRECTORIES}) +#endif() + +set(SOURCES +./MessageDisplayPluginGuiPlugin.cpp ./MessageDisplayPluginWidgetController.cpp +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.cpp @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.cpp +) + +# do not rename this variable, it is used in armarx_gui_library()... +set(HEADERS +./MessageDisplayPluginGuiPlugin.h ./MessageDisplayPluginWidgetController.h +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@GuiPlugin.h @COMPONENT_PATH@/@COMPONENT_NAME@WidgetController.h +) + +set(GUI_MOC_HDRS ${HEADERS}) + +set(GUI_UIS +./MessageDisplayPluginWidget.ui +#@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@Widget.ui +) + +# Add more libraries you depend on here, e.g. ${QT_LIBRARIES}. +set(COMPONENT_LIBS ArmarXGuiInterfaces) + +if(ArmarXGui_FOUND) + armarx_gui_library(MessageDisplayPluginGuiPlugin "${SOURCES}" "${GUI_MOC_HDRS}" "${GUI_UIS}" "" "${COMPONENT_LIBS}") +endif() diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.cpp b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f9da1abdaf5db3974aeb5ffd7c3d2f983b3a4056 --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.cpp @@ -0,0 +1,36 @@ +/* + * 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::gui-plugins::MessageDisplayPluginGuiPlugin + * \author Peter Kaiser ( peter dot kaiser at kit dot edu ) + * \date 2018 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "MessageDisplayPluginGuiPlugin.h" + +#include "MessageDisplayPluginWidgetController.h" + +using namespace armarx; + +MessageDisplayPluginGuiPlugin::MessageDisplayPluginGuiPlugin() +{ + addWidget < MessageDisplayPluginWidgetController > (); +} + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) +Q_EXPORT_PLUGIN2(armarx_gui_MessageDisplayPluginGuiPlugin, MessageDisplayPluginGuiPlugin) +#endif diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.h b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.h new file mode 100644 index 0000000000000000000000000000000000000000..572d9b956aedd14817fe1709c92d62396d31928e --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginGuiPlugin.h @@ -0,0 +1,52 @@ +/* + * 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::gui-plugins::MessageDisplayPlugin + * \author Peter Kaiser ( peter dot kaiser at kit dot edu ) + * \date 2018 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +#include <ArmarXCore/core/system/ImportExportComponent.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> + +namespace armarx +{ + /** + * \class MessageDisplayPluginGuiPlugin + * \ingroup ArmarXGuiPlugins + * \brief MessageDisplayPluginGuiPlugin brief description + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT MessageDisplayPluginGuiPlugin: + public armarx::ArmarXGuiPlugin + { + Q_OBJECT +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + Q_INTERFACES(ArmarXGuiInterface) + Q_PLUGIN_METADATA(IID "ArmarXGuiInterface/1.00") +#endif + public: + /** + * All widgets exposed by this plugin are added in the constructor + * via calls to addWidget() + */ + MessageDisplayPluginGuiPlugin(); + }; +} diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidget.ui b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..b57944e87393ff9dab33e273fb73d751ca8536cc --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidget.ui @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MessageDisplayPluginWidget</class> + <widget class="QWidget" name="MessageDisplayPluginWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>1122</width> + <height>169</height> + </rect> + </property> + <property name="windowTitle"> + <string>MessageDisplayPluginWidget</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QLabel" name="labelCaption"> + <property name="font"> + <font> + <pointsize>48</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="textFormat"> + <enum>Qt::AutoText</enum> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="labelSubcaption"> + <property name="font"> + <font> + <pointsize>30</pointsize> + </font> + </property> + <property name="text"> + <string/> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.cpp b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bee7d70e3f35544baa41c66eda68a1cf4440607 --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.cpp @@ -0,0 +1,110 @@ +/* + * 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::gui-plugins::MessageDisplayPluginWidgetController + * \author Peter Kaiser ( peter dot kaiser at kit dot edu ) + * \date 2018 + * \copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "MessageDisplayPluginWidgetController.h" + +#include <string> +#include <sstream> + +using namespace armarx; + +#define FADE_TIMER_MSEC 100 +#define FADE_DURATION 2000 + +MessageDisplayPluginWidgetController::MessageDisplayPluginWidgetController() +{ + widget.setupUi(getWidget()); +} + + +MessageDisplayPluginWidgetController::~MessageDisplayPluginWidgetController() +{ + +} + + +void MessageDisplayPluginWidgetController::loadSettings(QSettings* settings) +{ + +} + +void MessageDisplayPluginWidgetController::saveSettings(QSettings* settings) +{ + +} + + +void MessageDisplayPluginWidgetController::onInitComponent() +{ + usingTopic("MessageDisplayTopic"); + + // Don't display anything on startup + widget.labelCaption->setText(""); + widget.labelSubcaption->setText(""); + + connect(&fadeTimer, SIGNAL(timeout()), this, SLOT(timerEvent())); + connect(this, SIGNAL(setMessageContent(QString,QString)), this, SLOT(setMessageContentImpl(QString,QString))); +} + + +void MessageDisplayPluginWidgetController::onConnectComponent() +{ + +} + +void MessageDisplayPluginWidgetController::setMessage(const std::string &caption, const std::string &subCaption, const Ice::Current &) +{ + ARMARX_INFO << "New message: " << caption << " (" << subCaption << ")"; + emit setMessageContent(QString::fromStdString(caption), QString::fromStdString(subCaption)); +} + +void MessageDisplayPluginWidgetController::timerEvent() +{ + fadeDuration -= FADE_TIMER_MSEC; + if (fadeDuration <= 0) + { + fadeTimer.stop(); + } + + std::stringstream ss; + ss << "#" << std::hex << (int)(255 * (((float)fadeDuration) / FADE_DURATION)) << "0000"; + + ARMARX_INFO << ("<font color='" + QString::fromStdString(ss.str()) + "'>" + currentCaption + "</font>").toStdString(); + widget.labelCaption->setText("<font color='" + QString::fromStdString(ss.str()) + "'>" + currentCaption + "</font>"); + widget.labelSubcaption->setText("<font color='" + QString::fromStdString(ss.str()) + "'>" + currentSubCaption + "</font>"); +} + +void MessageDisplayPluginWidgetController::setMessageContentImpl(const QString &caption, const QString &subcaption) +{ + ARMARX_INFO << "PPP"; + + fadeTimer.stop(); + + currentCaption = caption; + currentSubCaption = subcaption; + + widget.labelCaption->setText("<font color='#FF0000'>" + currentCaption + "</font>"); + widget.labelSubcaption->setText("<font color='#FF0000'>" + currentSubCaption + "</font>"); + + fadeDuration = FADE_DURATION; + fadeTimer.start(FADE_TIMER_MSEC); +} diff --git a/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.h b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.h new file mode 100644 index 0000000000000000000000000000000000000000..4ff19e2c9da3a5713f65dd9b60ec9c3b61f3dc1f --- /dev/null +++ b/source/ArmarXGui/gui-plugins/MessageDisplayPlugin/MessageDisplayPluginWidgetController.h @@ -0,0 +1,124 @@ +/* + * 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::gui-plugins::MessageDisplayPluginWidgetController + * @author Peter Kaiser ( peter dot kaiser at kit dot edu ) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +#include "ui_MessageDisplayPluginWidget.h" + +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXGuiPlugin.h> +#include <ArmarXGui/libraries/ArmarXGuiBase/ArmarXComponentWidgetController.h> +#include <ArmarXGui/interface/MessageDisplayInterface.h> + +#include <ArmarXCore/core/system/ImportExportComponent.h> + +#include <QTimer> + +namespace armarx +{ + /** + \page ArmarXGui-GuiPlugins-MessageDisplayPlugin MessageDisplayPlugin + \brief The MessageDisplayPlugin allows visualizing ... + + \image html MessageDisplayPlugin.png + The user can + + API Documentation \ref MessageDisplayPluginWidgetController + + \see MessageDisplayPluginGuiPlugin + */ + + /** + * \class MessageDisplayPluginWidgetController + * \brief MessageDisplayPluginWidgetController brief one line description + * + * Detailed description + */ + class ARMARXCOMPONENT_IMPORT_EXPORT + MessageDisplayPluginWidgetController: + public armarx::ArmarXComponentWidgetControllerTemplate < MessageDisplayPluginWidgetController >, + public armarx::MessageDisplayInterface + { + Q_OBJECT + + public: + /** + * Controller Constructor + */ + explicit MessageDisplayPluginWidgetController(); + + /** + * Controller destructor + */ + virtual ~MessageDisplayPluginWidgetController(); + + /** + * @see ArmarXWidgetController::loadSettings() + */ + void loadSettings(QSettings* settings) override; + + /** + * @see ArmarXWidgetController::saveSettings() + */ + void saveSettings(QSettings* settings) override; + + /** + * Returns the Widget name displayed in the ArmarXGui to create an + * instance of this class. + */ + static QString GetWidgetName() + { + return "Util.MessageDisplayPlugin"; + } + + /** + * \see armarx::Component::onInitComponent() + */ + void onInitComponent() override; + + /** + * \see armarx::Component::onConnectComponent() + */ + void onConnectComponent() override; + + void setMessage(const std::string& caption, const std::string& subCaption, const Ice::Current&) override; + + public slots: + void timerEvent(); + void setMessageContentImpl(const QString& caption, const QString& subcaption); + + signals: + void setMessageContent(const QString& caption, const QString& subcaption); + + private: + /** + * Widget Form + */ + Ui::MessageDisplayPluginWidget widget; + + QTimer fadeTimer; + int fadeDuration; + + QString currentCaption; + QString currentSubCaption; + }; +} + + diff --git a/source/ArmarXGui/interface/CMakeLists.txt b/source/ArmarXGui/interface/CMakeLists.txt index c4c30f52a3112763caaf08d85315bba55812dd3c..7d0e5ace84d4935c67cb9c1c52b9b6e6b9ce1b0e 100644 --- a/source/ArmarXGui/interface/CMakeLists.txt +++ b/source/ArmarXGui/interface/CMakeLists.txt @@ -7,6 +7,7 @@ set(ARMARXGUI_INTERFACE_DEPEND ArmarXCore) set(SLICE_FILES WidgetDescription.ice StaticPlotterInterface.ice + MessageDisplayInterface.ice ) # generate the interface library diff --git a/source/ArmarXGui/interface/MessageDisplayInterface.ice b/source/ArmarXGui/interface/MessageDisplayInterface.ice new file mode 100644 index 0000000000000000000000000000000000000000..eaff9b4440008c4e27478ae6a9624f1cb0b7ed4c --- /dev/null +++ b/source/ArmarXGui/interface/MessageDisplayInterface.ice @@ -0,0 +1,32 @@ +/* + * 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 RobotAPI::ArmarXGui + * @author Peter Kaiser (peter dot kaiser at kit dot edu) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +module armarx +{ + interface MessageDisplayInterface + { + void setMessage(string caption, string subCaption); + }; + +}; +