StaticPlotterWidgetController.h
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4
5#include <ArmarXGui/gui-plugins/PlotterPlugin/ui_StaticPlotterWidget.h>
6#include <ArmarXGui/interface/StaticPlotterInterface.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
17class QToolBar;
18
19namespace 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
64 public:
65 static QString
67 {
68 return "Util.Plotter";
69 }
70
71 void loadSettings(QSettings* settings) override;
72 void saveSettings(QSettings* settings) override;
73 void addPlot(const std::string& plotName,
74 const StringVector2fSeqDict& plotsData,
75 const Ice::Current&) override;
76
77 private:
78 QwtPlotCurve* createCurve(const QString& label, QColor color);
79
80 Ui::StaticPlotterWidget ui;
81 QPointer<QwtPlot> plotter;
82 std::map<QString, StringVector2fSeqDict> plotsMap;
83 std::mutex dataMutex;
84 QToolBar* customToolbar;
85
86 // StaticPlotterInterfacePrx topicPrx ;
87 // armarx::SimpleRunningTask<>::pointer_type task;
88
89 // StaticPlotterInterface interface
90 public:
91 void addPlotWithTimestampVector(const std::string& plotName,
92 const Ice::FloatSeq& timestamps,
93 const StringFloatSeqDict& plotsData,
94 const Ice::Current&) override;
95 };
96
97} // namespace armarx
void onInitComponent() override
Pure virtual hook for the subclass.
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void addPlot(const std::string &plotName, const StringVector2fSeqDict &plotsData, const Ice::Current &) override
void plotAdded(QString plotName)
void onConnectComponent() override
Pure virtual hook for the subclass.
void addPlotWithTimestampVector(const std::string &plotName, const Ice::FloatSeq &timestamps, const StringFloatSeqDict &plotsData, const Ice::Current &) override
This file offers overloads of toIce() and fromIce() functions for STL container types.