-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractObject.h
71 lines (55 loc) · 1.71 KB
/
AbstractObject.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
#ifndef ABSTRACTOBJECT_H
#define ABSTRACTOBJECT_H
#include <QString>
#include "Position.h"
class ViewItem;
class World;
class AbstractObject
{
public:
AbstractObject(const QString& anImageName, const Position& aPosition, float aWidth, float aHeight);
/// Check if this object at the given position and size would be colliding with any other object.
/// @note: no checks for collisions with view here!
/// @returns true if collision happens
bool wouldBeColliding(const Position& aPosition, float aWidth, float aHeight) const;
ViewItem* createViewObject();
/** returns the Name of the object, for users.
* If a non-US locale is specified, the returned string
* will already be translated
*/
// TODO/FIXME: virtual const QString getName ( ) const = 0;
virtual const QString getName ( ) const
{return "BLOCK";}
// TODO/FIXME: rename to getCenterPos()
/// Get the Position of the object.
/// This is the "original" center, i.e. where the object will
/// be when not in simulation.
/// @returns the value of theCenter
virtual Position getOrigCenter ( ) const
{
return theCenter;
}
/// Get the value of theHeight
/// @return the value of theHeight
qreal getTheHeight ( ) const
{
return theHeight;
}
/// Get the value of theWidth
/// @return the value of theWidth
qreal getTheWidth ( ) const
{
return theWidth;
}
QString theImageName;
private:
Position theCenter;
float theWidth;
float theHeight;
ViewItem *theVIPtr;
World* theWorldPtr;
friend class World;
friend class ViewItem;
friend class ResizeRotateMoveUndoCommand;
};
#endif // ABSTRACTOBJECT_H