Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: a7b5a3a23fee10fd4454faf546ad0279db8c0b7a (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
   mapentity.h
   This file is part of the Project::OSiRiON world editor 
   and is distributed under the terms and conditions of 
   the GNU General Public License version 2
*/

#ifndef __INCLUDED_EDITOR_MAPENTITY__
#define __INCLUDED_EDITOR_MAPENTITY__

#include <QWidget>
#include <QList>
#include <QString>

namespace editor
{

/**
 * @brief MapEntity is an entity on the map
 * */
class MapEntity : public QWidget
{
	Q_OBJECT
	
public:
	MapEntity(QWidget *parent = 0);
	
	/**
	 * @brief returns the entity label
	 * */
	inline const QString &label() const {
		return entity_label;
	}
	
	/**
	 * @brief returns the entity name
	 * */
	inline const QString &name() const {
		return entity_name;
	}

	/**
	 * @brief returns the entity radius
	 * */
	inline const float radius() const {
		return entity_radius;
	}
	
	/**
	 * @brief returns the x, y, or z coordinate of the entity location
	 * */
	inline const float location(int index) const {
		return entity_location[index];
	}
	
	/**
	 * @brief returns the properties string
	 * */
	inline const QString &properties() const {
		return entity_properties;
	}

signals:
	/**
	 * @brief the clicked() signal is emitted if the entity is clicked with the left mouse button
	 * */
	void clicked(MapEntity *entity);
	
public slots:
		
	/**
	 * @brief set the entity name
	 * */
	void set_label(const QString &label);

	/**
	 * @brief set the entity label
	 * */
	void set_name(const QString &name);
	
	/**
	 * @brief set the entity radius
	 * */
	void set_radius(const float radius);
	
	/**
	 * @brief set the entity location
	 * */
	void set_location(const float x, const float y, const float z);
	
	/**
	 * @brief set the entity properties string
	 * */
	void set_properties(const QString &properties);
	
	/**
	 * @brief add a property
	 * */
	void add_property(const QString &key, const QString &value);
	
	/**
	 * @brief set the selected state
	 * */
	void set_selected(const bool selected);

protected:
	/**
	 * @brief handle draw events
	 * */
	virtual void paintEvent(QPaintEvent *event);
	
	/**
	 * @brief handle mouse button press events
	 * */
	virtual void mousePressEvent(QMouseEvent *event);
	
private:
	bool		is_selected;
	
	QString		entity_label;
	QString 	entity_name;
	QString		entity_type;
	
	QString 	entity_properties;
	
	float		entity_location[3];
	float 		entity_radius;
	
	QColor		entity_color;
};

}

#endif // __INCLUDED_EDITOR_MAPENTITY__