VisualizationZoneWidget.h
108 lines
| 3.8 KiB
| text/x-c
|
CLexer
r58 | #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H | |||
#define SCIQLOP_VISUALIZATIONZONEWIDGET_H | ||||
r1347 | #include "Data/DateTimeRange.h" | |||
r118 | #include "Visualization/IVisualizationWidget.h" | |||
r839 | #include "Visualization/VisualizationDragWidget.h" | |||
r118 | ||||
Alexandre Leroux
|
r219 | #include <QLoggingCategory> | ||
r58 | #include <QWidget> | |||
r539 | #include <memory> | |||
#include <Common/spimpl.h> | ||||
Alexandre Leroux
|
r219 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationZoneWidget) | ||
r1420 | namespace Ui | |||
{ | ||||
r58 | class VisualizationZoneWidget; | |||
r844 | } // namespace Ui | |||
r58 | ||||
r1420 | class Variable2; | |||
Alexandre Leroux
|
r197 | class VisualizationGraphWidget; | ||
r1420 | class VisualizationZoneWidget : public VisualizationDragWidget, public IVisualizationWidget | |||
{ | ||||
r58 | Q_OBJECT | |||
public: | ||||
r1420 | explicit VisualizationZoneWidget(const QString& name = {}, QWidget* parent = 0); | |||
r58 | virtual ~VisualizationZoneWidget(); | |||
r1138 | /// Sets the range of the zone, only works if there is at least one graph in the zone | |||
/// Note: calibrations between graphs are lost. | ||||
r1420 | void setZoneRange(const DateTimeRange& range); | |||
r1138 | ||||
r839 | /// Adds a graph widget | |||
r1420 | void addGraph(VisualizationGraphWidget* graphWidget); | |||
r118 | ||||
r844 | /// Inserts a graph widget | |||
r1420 | void insertGraph(int index, VisualizationGraphWidget* graphWidget); | |||
r839 | ||||
Alexandre Leroux
|
r200 | /** | ||
* Creates a graph using a variable. The variable will be displayed in the new graph. | ||||
r839 | * The graph is added at the end. | |||
Alexandre Leroux
|
r200 | * @param variable the variable for which to create the graph | ||
* @return the pointer to the created graph | ||||
*/ | ||||
r1420 | VisualizationGraphWidget* createGraph(std::shared_ptr<Variable2> variable); | |||
r118 | ||||
r839 | /** | |||
* Creates a graph using a variable. The variable will be displayed in the new graph. | ||||
* The graph is inserted at the specified index. | ||||
* @param variable the variable for which to create the graph | ||||
* @param index The index where the graph should be inserted in the layout | ||||
* @return the pointer to the created graph | ||||
*/ | ||||
r1420 | VisualizationGraphWidget* createGraph(std::shared_ptr<Variable2> variable, int index); | |||
r839 | ||||
/** | ||||
* Creates a graph using a list of variables. The variables will be displayed in the new graph. | ||||
* The graph is inserted at the specified index. | ||||
* @param variables List of variables to be added to the graph | ||||
* @param index The index where the graph should be inserted in the layout | ||||
* @return the pointer to the created graph | ||||
*/ | ||||
r1420 | VisualizationGraphWidget* createGraph( | |||
std::vector<std::shared_ptr<Variable2>> variables, int index); | ||||
r839 | ||||
r1048 | /// Returns the first graph in the zone or nullptr if there is no graph inside | |||
r1420 | VisualizationGraphWidget* firstGraph() const; | |||
r1048 | ||||
r1307 | /// Closes all graphes inside the zone | |||
void closeAllGraphs(); | ||||
r118 | // IVisualizationWidget interface | |||
r1420 | void accept(IVisualizationWidgetVisitor* visitor) override; | |||
bool canDrop(Variable2& variable) const override; | ||||
bool contains(Variable2& variable) const override; | ||||
r119 | QString name() const override; | |||
r118 | ||||
r839 | // VisualisationDragWidget | |||
r1420 | QMimeData* mimeData(const QPoint& position) const override; | |||
r839 | bool isDragAllowed() const override; | |||
r1420 | void notifyMouseMoveInGraph(const QPointF& graphPosition, const QPointF& plotPosition, | |||
VisualizationGraphWidget* graphWidget); | ||||
void notifyMouseLeaveGraph(VisualizationGraphWidget* graphWidget); | ||||
r960 | ||||
Alexandre Leroux
|
r738 | protected: | ||
r1420 | void closeEvent(QCloseEvent* event) override; | |||
Alexandre Leroux
|
r738 | |||
r58 | private: | |||
r1420 | Ui::VisualizationZoneWidget* ui; | |||
r539 | ||||
class VisualizationZoneWidgetPrivate; | ||||
spimpl::unique_impl_ptr<VisualizationZoneWidgetPrivate> impl; | ||||
Alexandre Leroux
|
r657 | |||
private slots: | ||||
r1420 | void onVariableAdded(std::shared_ptr<Variable2> variable); | |||
Alexandre Leroux
|
r737 | /// Slot called when a variable is about to be removed from a graph contained in the zone | ||
r1420 | void onVariableAboutToBeRemoved(std::shared_ptr<Variable2> variable); | |||
r839 | ||||
r1420 | void dropMimeData(int index, const QMimeData* mimeData); | |||
void dropMimeDataOnGraph(VisualizationDragWidget* dragWidget, const QMimeData* mimeData); | ||||
r58 | }; | |||
#endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H | ||||