forked from Rsnelllenberg/VolumeProjectorPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteractiveShape.h
More file actions
89 lines (70 loc) · 2.1 KB
/
Copy pathInteractiveShape.h
File metadata and controls
89 lines (70 loc) · 2.1 KB
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
#pragma once
#include <QColor>
#include <QPainter>
#include <QRectF>
#include <QPixmap>
#include <QBitmap>
enum class SelectedSide {
None,
Left,
Right,
Top,
Bottom
};
struct gradientData {
bool gradient;
int textureID;
float xOffset;
float yOffset;
float width;
float height;
int rotation;
};
namespace mv::gui
{
class PointRenderer;
}
class InteractiveShape {
public:
InteractiveShape(const QPixmap& pixmap, const QRectF& rect, const QRect& bounds, const QColor& pixmapColor, int globalAlphaValue, mv::gui::PointRenderer* pointRenderer, qreal threshold = 10.0);
void draw(QPainter& painter, bool drawBorder, bool useGlobalAlpha, bool normalizeWindow, QColor borderColor = Qt::black, int scaleTo = 0) const;
void drawID(QPainter& painter, bool normalizeWindow, int id, int scaleTo = 0) const;
bool contains(const QPointF& point) const;
void moveBy(const QPointF& delta);
void resizeBy(const QPointF& delta, SelectedSide& side);
bool isNearSide(const QPointF& point, SelectedSide& side) const;
bool isNearTopRightCorner(const QPointF& point) const;
void setSelected(bool selected);
bool getSelected() const;
void setColor(const QColor& color);
QColor getColor() const;
void setThreshold(qreal threshold);
void setBounds(const QRect& bounds);
void updateGradient(const gradientData& data);
QImage getGradientImage() const;
gradientData getGradientData() const;
void setGlobalAlphaValue(int globalAlphaValue);
QRectF getRelativeRect() const;
QRectF getWorldRect() const;
QRectF getAdjustedWorldRect(int scaleTo = 0) const;
private:
QRectF getAbsoluteRect() const;
void updatePixmap();
private:
QPixmap _pixmap;
QPixmap _globalAlphaPixmap;
QPixmap _colormap;
QPixmap _globalAlphaColormap;
QRectF _rect;
QRect _bounds;
bool _isSelected;
qreal _threshold;
QColor _pixmapColor;
QBitmap _mask;
int _globalAlphaValue = 100;
QImage _gradient1D;
QImage _gradient2D;
QImage _usedGradient;
gradientData _gradientData;
mv::gui::PointRenderer* _pointRenderer = nullptr;
};