/
TextureToolRotateManipulator.h
82 lines (60 loc) · 2.27 KB
/
TextureToolRotateManipulator.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
#pragma once
#include "imanipulator.h"
#include "../BasicSelectable.h"
#include "selection/manipulators/ManipulatorComponents.h"
#include "../Renderables.h"
#include "selection/textool/TextureToolManipulationPivot.h"
namespace textool
{
class TextureRotator :
public selection::ManipulatorComponentBase
{
private:
Vector2 _start;
Vector2 _deviceStart;
Vector2 _screenStart;
Vector2 _current;
Vector2 _deviceCurrent;
Vector2 _screenCurrent;
// The most recently calculated angle for rendering purposes
Vector2::ElementType _curAngle;
std::function<void(const Vector2&, Vector2::ElementType)> _rotateFunctor;
public:
TextureRotator(const std::function<void(const Vector2&, Vector2::ElementType)>& rotateFunctor) :
_curAngle(0),
_rotateFunctor(rotateFunctor)
{}
void beginTransformation(const Matrix4& pivot2world, const VolumeTest& view, const Vector2& devicePoint) override;
void transform(const Matrix4& pivot2world, const VolumeTest& view, const Vector2& devicePoint, unsigned int constraints) override;
void resetCurAngle();
Vector2::ElementType getCurAngle() const;
// The vector from the pivot to the starting point of the manipulation (screen space, normalised)
const Vector2& getStartDirection() const;
const Vector2& getStartDirectionInScreenSpace() const;
};
class TextureToolRotateManipulator :
public selection::ITextureToolManipulator
{
private:
TextureToolManipulationPivot& _pivot;
std::size_t _id;
selection::BasicSelectable _selectableZ;
TextureRotator _rotator;
RenderableCircle _renderableCircle;
ShaderPtr _shader;
IGLFont::Ptr _glFont;
double _circleRadius;
public:
TextureToolRotateManipulator(TextureToolManipulationPivot& pivot);
virtual std::size_t getId() const override;
virtual void setId(std::size_t id) override;
virtual Type getType() const override;
virtual Component* getActiveComponent() override;
virtual void setSelected(bool select) override;
virtual bool isSelected() const override;
virtual void testSelect(SelectionTest& test, const Matrix4& pivot2world) override;
virtual void renderComponents(const render::IRenderView& view, const Matrix4& pivot2World) override;
private:
void rotateSelected(const Vector2& pivot, double angle);
};
}