/
KiwiObjectController.h
119 lines (92 loc) · 4.12 KB
/
KiwiObjectController.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
==============================================================================
This file is part of the KIWI library.
Copyright (c) 2014 Pierre Guillot & Eliott Paris.
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
Details of these licenses can be found at: www.gnu.org/licenses
KIWI 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.
------------------------------------------------------------------------------
To release a closed-source product which uses KIWI, contact : guillotpierre6@gmail.com
==============================================================================
*/
#ifndef __DEF_KIWI_OBJECT_CONTROLLER__
#define __DEF_KIWI_OBJECT_CONTROLLER__
#include "KiwiObject.h"
namespace Kiwi
{
// ================================================================================ //
// OBJECT CONTROLLER //
// ================================================================================ //
class Object::Controller : public GuiController
{
private:
const sObject m_object;
ulong m_zoom;
bool m_locked;
bool m_presentation;
bool m_display_grid;
bool m_snap_to_grid;
public:
//! The object controller constructor.
/** The function does nothing.
@param object The object.
*/
Controller(sObject object) noexcept;
//! The controller destructor.
/** The function does nothing.
*/
~Controller() noexcept;
//! Retrieve the object of the controller.
/** The function retrieves the object of the controller.
@return The object.
*/
inline sObject getObject() const noexcept
{
return dynamic_pointer_cast<Object>(getModel());
}
// ================================================================================ //
// PRESENTATION //
// ================================================================================ //
//! Retrieve the zoom of the object.
/** The function retrieves the zoom of the object.
@return the zoom of the object in percent.
@see setZoom
*/
inline ulong getZoom() const noexcept { return m_zoom; }
//! Set the zoom of the object.
/** The function sets the zoom of the object.
@param zoom The zoom of the object in percent.
@see getZoom
*/
void setZoom(const ulong zoom);
//! Retrieve if the object is locked or unlocked.
/** The function retrieves if the object is locked or unlocked.
@return True if the object is locked, false if it is unlocked.
@see setLockStatus
*/
inline bool getLockStatus() const noexcept { return m_locked; }
//! Lock or unlock the object.
/** The function locks or unlocks the object.
@param locked True to lock the object, false to unlock it.
@see getLockStatus
*/
void setLockStatus(const bool locked);
//! Retrieve if the object is visible.
/** The function retrieves if the object is visible.
@param true if the object is visible, otherwise false.
*/
bool isVisible() const noexcept;
protected:
//! The draw method that should be override.
/** The function shoulds draw some stuff.
@param view The view that owns the controller.
@param sketch The sketch to draw.
*/
void draw(sGuiView view, Sketch& sketch) override;
};
}
#endif