-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShapeControlPainter.h
92 lines (72 loc) · 2.85 KB
/
ShapeControlPainter.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
/*
* ShapeControlPainter.h
*
* (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* This program 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.
*
* This program 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 <http://www.gnu.org/licenses/>.
*/
#ifndef SHAPE_CONTROL_PAINTER_H_
#define SHAPE_CONTROL_PAINTER_H_
#include <QtGlobal>
#include "MM.h"
#include "MapperGLCanvas.h"
#include "ShapeGraphicsItem.h"
namespace mmp {
class ShapeGraphicsItem;
class MapperGLCanvas;
/**
* An object responsible to paint control points for a specific ShapeGraphicsItem.
*/
class ShapeControlPainter
{
public:
typedef QSharedPointer<ShapeControlPainter> ptr;
ShapeControlPainter(ShapeGraphicsItem* shapeItem);
virtual ~ShapeControlPainter() {}
MShape::ptr getShape() const;
// Just paints the shape (selected=false is for painting shapes in the "background" when the option to display all controls is chosen).
virtual void paintShape(QPainter *painter, MapperGLCanvas* canvas, bool selected=true) = 0;
virtual void paint(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices = QList<int>());
protected:
virtual void _paintVertices(QPainter *painter, MapperGLCanvas* canvas, const QList<int>& selectedVertices = QList<int>());
QPen getRescaledShapeStroke(MapperGLCanvas* canvas, bool selected=true, bool innerStroke=false);
ShapeGraphicsItem* _shapeItem;
};
/// Control painter for polygons.
class PolygonControlPainter : public ShapeControlPainter
{
public:
PolygonControlPainter(ShapeGraphicsItem* shapeItem) : ShapeControlPainter(shapeItem) {}
virtual ~PolygonControlPainter() {}
virtual void paintShape(QPainter *painter, MapperGLCanvas* canvas, bool selected=true);
};
/// Control painter for ellipses.
class EllipseControlPainter : public ShapeControlPainter
{
public:
EllipseControlPainter(ShapeGraphicsItem* shapeItem) : ShapeControlPainter(shapeItem) {}
virtual ~EllipseControlPainter() {}
virtual void paintShape(QPainter *painter, MapperGLCanvas* canvas, bool selected=true);
};
/// Control painter for meshes.
class MeshControlPainter : public ShapeControlPainter
{
public:
MeshControlPainter(ShapeGraphicsItem* shapeItem) : ShapeControlPainter(shapeItem) {}
virtual ~MeshControlPainter() {}
virtual void paintShape(QPainter *painter, MapperGLCanvas* canvas, bool selected=true);
};
}
#endif