OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
9#include "OTCore/Flags.h"
10#include "OTCore/Serializable.h"
12
13namespace ot {
14
17 public:
19 enum FlipState {
20 NoFlip = 0x00,
21 FlipVertically = 0x01,
22 FlipHorizontally = 0x02
23 };
25
28 Transform();
29 Transform(double _rotationAngle, const FlipStateFlags& _flipState = FlipStateFlags(FlipState::NoFlip));
30 Transform(const Transform& _other);
31 virtual ~Transform();
32
33 Transform& operator = (const Transform& _other);
34
35 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
36
37 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
38
41 void setRotation(double _angle) { m_rotation = _angle; };
42
45 double getRotation(void) const { return m_rotation; };
46
47 void setFlipState(FlipState _state, bool _active = true) { m_flipState.setFlag(_state, _active); };
48 void setFlipStateFlags(const FlipStateFlags& _flags) { m_flipState = _flags; };
49 const FlipStateFlags& getFlipStateFlags(void) const { return m_flipState; };
50
52 bool hasTransform(void) const { return m_rotation != 0. || m_flipState != FlipState::NoFlip; };
53
54 private:
55 double m_rotation;
56 FlipStateFlags m_flipState;
57 };
58}
59
#define OT_ADD_FLAG_FUNCTIONS(___enumName)
Will add the default bitwise operations for the provided private 32/64 bit bitfield....
Definition Flags.h:129
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The Flags class is a wrapper around a enum that allows bitwise operations (flags)....
Definition Flags.h:214
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
General item transformation.
Definition Transform.h:16
void setRotation(double _angle)
Set item rotation. The angle must be between 0 and 359 degrees.
Definition Transform.h:41
void setFlipStateFlags(const FlipStateFlags &_flags)
Definition Transform.h:48
double getRotation(void) const
Item rotation. The angle must be between 0 and 359 degrees.
Definition Transform.h:45
bool hasTransform(void) const
Returns true if any transformation is set.
Definition Transform.h:52
FlipState
Flip state.
Definition Transform.h:19
Flags< FlipState > FlipStateFlags
Definition Transform.h:24
void setFlipState(FlipState _state, bool _active=true)
Definition Transform.h:47
const FlipStateFlags & getFlipStateFlags(void) const
Definition Transform.h:49
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30