/
graphpanelwidget.h
133 lines (92 loc) · 4.41 KB
/
graphpanelwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR 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 <https://gnu.org/licenses>.
*******************************************************************************/
//==============================================================================
// Graph panel widget
//==============================================================================
#pragma once
//==============================================================================
#include "graphpanelplotwidget.h"
#include "graphpanelwidgetglobal.h"
#include "widget.h"
//==============================================================================
#include <QList>
//==============================================================================
namespace OpenCOR {
namespace GraphPanelWidget {
//==============================================================================
static const QColor DefaultGraphPanelBackgroundColor = Qt::white;
static const QColor DefaultGraphPanelForegroundColor = Qt::black;
static const bool DefaultGraphPanelLegend = true;
//==============================================================================
class GRAPHPANELWIDGET_EXPORT GraphPanelWidgetProperties
{
public:
explicit GraphPanelWidgetProperties(const QColor &pBackgroundColor = DefaultGraphPanelBackgroundColor,
const QColor &pForegroundColor = DefaultGraphPanelForegroundColor,
bool pLegend = DefaultGraphPanelLegend);
QColor backgroundColor() const;
QColor foregroundColor() const;
bool legend() const;
private:
QColor mBackgroundColor;
QColor mForegroundColor;
bool mLegend;
};
//==============================================================================
class GraphPanelWidget;
//==============================================================================
using GraphPanelWidgets = QList<GraphPanelWidget *>;
//==============================================================================
class GRAPHPANELWIDGET_EXPORT GraphPanelWidget : public Core::Widget
{
Q_OBJECT
public:
explicit GraphPanelWidget(const GraphPanelWidgets &pNeighbors,
QAction *pSynchronizeXAxisAction,
QAction *pSynchronizeYAxisAction,
QWidget *pParent);
explicit GraphPanelWidget(const GraphPanelWidgets &pNeighbors,
QWidget *pParent);
~GraphPanelWidget() override;
void retranslateUi() override;
bool isActive() const;
void setActive(bool pActive, bool pForce = false);
GraphPanelPlotWidget * plot() const;
GraphPanelPlotGraphs graphs() const;
void addGraph(GraphPanelPlotGraph *pGraph,
const GraphPanelPlotGraphProperties &pGraphProperties = GraphPanelPlotGraphProperties());
void removeGraphs(const GraphPanelPlotGraphs &pGraphs);
void removeAllGraphs();
protected:
void changeEvent(QEvent *pEvent) override;
void mousePressEvent(QMouseEvent *pEvent) override;
private:
QFrame *mMarker;
GraphPanelPlotWidget *mPlot;
bool mActive = false;
void updateMarkerColor();
signals:
void activated(GraphPanelWidget *pGraphPanel);
void inactivated(GraphPanelWidget *pGraphPanel);
void graphAdded(GraphPanelWidget *pGraphPanel, GraphPanelPlotGraph *pGraph,
const GraphPanelPlotGraphProperties &pGraphProperties);
void graphsRemoved(GraphPanelWidget *pGraphPanel,
const GraphPanelPlotGraphs &pGraphs);
};
//==============================================================================
} // namespace GraphPanelWidget
} // namespace OpenCOR
//==============================================================================
// End of file
//==============================================================================