VAPOR3 3.9.4
TFMapWidget.h
Go to the documentation of this file.
1#pragma once
2
3#include <QFrame>
4#include <QMenu>
5#include <glm/glm.hpp>
6#include <vector>
7
8namespace VAPoR {
9class DataMgr;
10class ParamsMgr;
11class RenderParams;
12class MapperFunction;
13} // namespace VAPoR
14
15class TFInfoWidget;
16class TFMapWidget;
17
23
24class TFMap : public QObject {
25 Q_OBJECT
26
27 const std::string _variableNameTag;
28 TFMapWidget * _parent = nullptr;
29 TFInfoWidget * _infoWidget = nullptr;
30 int _width = 0;
31 int _height = 0;
32 bool _insideSaveStateGroup = false;
33 bool _hidden = false;
34
35 VAPoR::DataMgr * _dataMgr = nullptr;
36 VAPoR::ParamsMgr * _paramsMgr = nullptr;
37 VAPoR::RenderParams *_renderParams = nullptr;
38
39public:
40 TFMap(const std::string &variableNameTag, TFMapWidget *parent = nullptr);
41
43 void Update(VAPoR::DataMgr *dataMgr, VAPoR::ParamsMgr *paramsMgr, VAPoR::RenderParams *rParams);
44 bool HasValidParams() const;
45 bool IsShown() const;
46 virtual void LostFocus() = 0;
47 virtual QSize minimumSizeHint() const = 0;
49 virtual void PopulateContextMenu(QMenu *menu, const glm::vec2 &p) {}
50 virtual void PopulateSettingsMenu(QMenu *menu) const {}
51
52 int width() const { return _width; }
53 int height() const { return _height; }
54 void resize(int width, int height);
58 QRect paddedRect() const;
59 QRect rect() const;
60 const QFont getFont() const;
61
63 virtual void paintEvent(QPainter &p) = 0;
64 virtual void mousePressEvent(QMouseEvent *event);
65 virtual void mouseReleaseEvent(QMouseEvent *event);
66 virtual void mouseMoveEvent(QMouseEvent *event);
67 virtual void mouseDoubleClickEvent(QMouseEvent *event);
68
69 friend class TFMapWidget;
70
71public slots:
73 void update();
74 void show();
75 void hide();
76
77protected:
78 virtual void paramsUpdate() = 0;
79
80 VAPoR::DataMgr * getDataMgr() const { return _dataMgr; }
81 VAPoR::ParamsMgr * getParamsMgr() const { return _paramsMgr; }
82 VAPoR::RenderParams * getRenderParams() const { return _renderParams; }
84 std::string getVariableName() const;
85 const std::string & getVariableNameTag() const;
86
87 void drawControl(QPainter &p, const QPointF &pos, bool selected = false) const;
89
90 glm::vec2 NDCToPixel(const glm::vec2 &v) const;
91 QPointF NDCToQPixel(const glm::vec2 &v) const;
92 QPointF NDCToQPixel(float x, float y) const;
93 glm::vec2 PixelToNDC(const QPointF &p) const;
94 glm::vec2 PixelToNDC(const glm::vec2 &p) const;
95
96 virtual QMargins GetPadding() const;
98
99 void BeginSaveStateGroup(VAPoR::ParamsMgr *paramsMgr, const std::string &description = "");
102
103signals:
105 void Activated(TFMap *who);
106};
107
110
111class TFMapWidget : public QWidget {
112 Q_OBJECT
113
114 std::vector<TFMap *> _maps;
115
116public:
119 void AddMap(TFMap *map);
120 std::vector<TFMap *> GetMaps() const;
122 void Update(VAPoR::DataMgr *dataMgr, VAPoR::ParamsMgr *paramsMgr, VAPoR::RenderParams *rParams);
124 QSize minimumSizeHint() const override;
125 void showMap(TFMap *map);
126 void hideMap(TFMap *map);
127
128signals:
130
131private slots:
132 void _mapActivated(TFMap *who);
133 void _showContextMenu(const QPoint &);
134
135protected:
136 void paintEvent(QPaintEvent *event) override;
137 void mousePressEvent(QMouseEvent *event) override;
138 void mouseReleaseEvent(QMouseEvent *event) override;
139 void mouseMoveEvent(QMouseEvent *event) override;
140 void mouseDoubleClickEvent(QMouseEvent *event) override;
141 void resizeEvent(QResizeEvent *event) override;
142};
void showMap(TFMap *map)
void Update(VAPoR::DataMgr *dataMgr, VAPoR::ParamsMgr *paramsMgr, VAPoR::RenderParams *rParams)
void Deactivate()
void Activated(TFMapWidget *who)
void mousePressEvent(QMouseEvent *event) override
void mouseDoubleClickEvent(QMouseEvent *event) override
void mouseReleaseEvent(QMouseEvent *event) override
void AddMap(TFMap *map)
void hideMap(TFMap *map)
QSize minimumSizeHint() const override
std::vector< TFMap * > GetMaps() const
void resizeEvent(QResizeEvent *event) override
TFInfoWidget * GetInfoWidget()
void mouseMoveEvent(QMouseEvent *event) override
TFMapWidget(TFMap *map)
void paintEvent(QPaintEvent *event) override
virtual void mouseReleaseEvent(QMouseEvent *event)
QRect paddedRect() const
Returns the rect of the internal padded area.
virtual void mouseMoveEvent(QMouseEvent *event)
void drawControl(QPainter &p, const QPointF &pos, bool selected=false) const
void show()
virtual QMargins GetPadding() const
virtual void paramsUpdate()=0
virtual TFInfoWidget * createInfoWidget()=0
void CancelSaveStateGroup(VAPoR::ParamsMgr *paramsMgr)
const std::string & getVariableNameTag() const
bool isLargeEnoughToPaint() const
Sometimes Qt tries painting a 0 sized widget.
void hide()
void BeginSaveStateGroup(VAPoR::ParamsMgr *paramsMgr, const std::string &description="")
VAPoR::MapperFunction * getMapperFunction() const
void Update(VAPoR::DataMgr *dataMgr, VAPoR::ParamsMgr *paramsMgr, VAPoR::RenderParams *rParams)
glm::vec2 PixelToNDC(const QPointF &p) const
const QFont getFont() const
bool HasValidParams() const
void EndSaveStateGroup(VAPoR::ParamsMgr *paramsMgr)
TFMap(const std::string &variableNameTag, TFMapWidget *parent=nullptr)
bool IsShown() const
QPointF NDCToQPixel(float x, float y) const
QPointF NDCToQPixel(const glm::vec2 &v) const
void Activated(TFMap *who)
Emittend when focus was gained.
virtual void LostFocus()=0
virtual void PopulateSettingsMenu(QMenu *menu) const
Definition: TFMapWidget.h:50
void resize(int width, int height)
glm::vec2 PixelToNDC(const glm::vec2 &p) const
virtual void PopulateContextMenu(QMenu *menu, const glm::vec2 &p)
(Right-click menu)
Definition: TFMapWidget.h:49
VAPoR::DataMgr * getDataMgr() const
Definition: TFMapWidget.h:80
VAPoR::ParamsMgr * getParamsMgr() const
Definition: TFMapWidget.h:81
int GetControlPointRadius() const
glm::vec2 NDCToPixel(const glm::vec2 &v) const
virtual void paintEvent(QPainter &p)=0
These map to the QWidget counterparts.
int height() const
Definition: TFMapWidget.h:53
VAPoR::RenderParams * getRenderParams() const
Definition: TFMapWidget.h:82
virtual QSize minimumSizeHint() const =0
std::string getVariableName() const
void update()
These map to the QWidget counterparts.
TFInfoWidget * GetInfoWidget()
int width() const
Definition: TFMapWidget.h:52
virtual void mousePressEvent(QMouseEvent *event)
virtual void mouseDoubleClickEvent(QMouseEvent *event)
QRect rect() const
A cache based data reader.
Definition: DataMgr.h:110
Parent class for TransferFunction and IsoControl, supports positioning histogram over color/opacity m...
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A Params subclass for managing parameters used by Renderers.
Definition: RenderParams.h:43