StaticPlotterWidgetController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <functional>
4 
6 #include <ArmarXGui/interface/StaticPlotterInterface.h>
7 #include <ArmarXGui/gui-plugins/PlotterPlugin/ui_StaticPlotterWidget.h>
8 
9 #pragma GCC diagnostic push
10 #pragma GCC diagnostic ignored "-Wpedantic"
11 #include <qwt_plot.h>
12 #include <qwt_plot_curve.h>
13 #pragma GCC diagnostic pop
14 
16 
17 class QToolBar;
18 
19 namespace armarx
20 {
21 
22  /*!
23  * \page ArmarXGui-GuiPlugins-StaticPlotterPlugin Static Plotter
24  * \brief The plotter widget allows the user to send data to a the StaticPlotterInterface topic, which can be plotted with this widget.
25  * To send plotting data from your code use code similar to this:
26  \verbatim
27  #include <ArmarXGui/interface/StaticPlotterInterface.h>
28  topicPrx = getTopic<StaticPlotterInterfacePrx>("StaticPlotter");
29  Vector2fSeq data {{1, 0},
30  {200, 300},
31  {300, 100}
32  };
33  Vector2fSeq data2 {{1, 0},
34  {200, 500},
35  {340, 600}
36  };
37  topicPrx->addPlot("TestCurve", {{"curve", data}, {"curve2", data2}});
38  \endverbatim
39  The GUI needs to be running before the plot is sent.
40  */
42  public ArmarXComponentWidgetControllerTemplate<StaticPlotterWidgetController>,
43  public StaticPlotterInterface
44  {
45  Q_OBJECT
46  public:
48 
49  // ManagedIceObject interface
50  protected:
51  void onInitComponent() override;
52  void onConnectComponent() override;
53 
54  // ArmarXWidgetController interface
55  QPointer<QWidget> getCustomTitlebarWidget(QWidget* parent) override;
56  signals:
57  void plotAdded(QString plotName);
58  public slots:
59  void addToPlotList(QString plotName);
60  void changePlot(QString plotName);
61  void showCurve(QwtPlotItem* item, bool on);
62  void clearPlots();
63  public:
64  static QString GetWidgetName()
65  {
66  return "Util.Plotter";
67  }
68  void loadSettings(QSettings* settings) override;
69  void saveSettings(QSettings* settings) override;
70  void addPlot(const std::string& plotName, const StringVector2fSeqDict& plotsData, const Ice::Current&) override;
71 
72  private:
73  QwtPlotCurve* createCurve(const QString& label, QColor color);
74 
75  Ui::StaticPlotterWidget ui;
76  QPointer<QwtPlot> plotter;
77  std::map<QString, StringVector2fSeqDict > plotsMap;
78  std::mutex dataMutex;
79  QToolBar* customToolbar;
80 
81  // StaticPlotterInterfacePrx topicPrx ;
82  // armarx::SimpleRunningTask<>::pointer_type task;
83 
84  // StaticPlotterInterface interface
85  public:
86  void addPlotWithTimestampVector(const std::string& plotName, const Ice::FloatSeq& timestamps, const StringFloatSeqDict& plotsData, const Ice::Current&) override;
87  };
88 
89 } // namespace armarx
90 
armarx::StaticPlotterWidgetController::plotAdded
void plotAdded(QString plotName)
armarx::StaticPlotterWidgetController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: StaticPlotterWidgetController.cpp:78
armarx::StaticPlotterWidgetController::addToPlotList
void addToPlotList(QString plotName)
Definition: StaticPlotterWidgetController.cpp:130
armarx::StaticPlotterWidgetController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: StaticPlotterWidgetController.cpp:72
armarx::StaticPlotterWidgetController::changePlot
void changePlot(QString plotName)
Definition: StaticPlotterWidgetController.cpp:142
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
armarx::StaticPlotterWidgetController::GetWidgetName
static QString GetWidgetName()
Definition: StaticPlotterWidgetController.h:64
armarx::StaticPlotterWidgetController::addPlotWithTimestampVector
void addPlotWithTimestampVector(const std::string &plotName, const Ice::FloatSeq &timestamps, const StringFloatSeqDict &plotsData, const Ice::Current &) override
Definition: StaticPlotterWidgetController.cpp:204
armarx::StaticPlotterWidgetController::clearPlots
void clearPlots()
Definition: StaticPlotterWidgetController.cpp:121
armarx::StaticPlotterWidgetController
Definition: StaticPlotterWidgetController.h:41
armarx::StaticPlotterWidgetController::addPlot
void addPlot(const std::string &plotName, const StringVector2fSeqDict &plotsData, const Ice::Current &) override
Definition: StaticPlotterWidgetController.cpp:190
ArmarXComponentWidgetController.h
armarx::StaticPlotterWidgetController::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: StaticPlotterWidgetController.cpp:234
armarx::StaticPlotterWidgetController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: StaticPlotterWidgetController.cpp:182
TaskUtil.h
armarx::StaticPlotterWidgetController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: StaticPlotterWidgetController.cpp:186
armarx::StaticPlotterWidgetController::StaticPlotterWidgetController
StaticPlotterWidgetController()
Definition: StaticPlotterWidgetController.cpp:21
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StaticPlotterWidgetController::showCurve
void showCurve(QwtPlotItem *item, bool on)
Definition: StaticPlotterWidgetController.cpp:100