WorldSim - 1.4.5
Utilities
Configuration
GA
NNFW
WorldSim
Total 99%
Experiments
Main Page
Classes
Files
File List
worldsim
src
wobject.cpp
1
/********************************************************************************
2
* WorldSim -- library for robot simulations *
3
* Copyright (C) 2008-2013 Gianluca Massera <emmegian@yahoo.it> *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the Free Software *
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18
********************************************************************************/
19
20
#include "wobject.h"
21
#include "world.h"
22
23
using namespace
farsa;
24
25
WObject::WObject
(
World
* w, QString name,
const
wMatrix
& tm,
bool
addToWorld ) {
26
this->
worldv
= w;
27
this->tm =
tm
;
28
namev
=
name
;
29
texturev
=
"tile2"
;
30
colorv
= Qt::white;
31
invisible
=
false
;
32
usecolortextureofowner
=
true
;
33
localFrameOfReferenceDrawn
=
false
;
34
labelv
=
""
;
35
labelpos
=
wVector
(0.0f, 0.0f, 0.0f);
36
labelcol
= Qt::white;
37
labeldrawn
=
false
;
38
if
( addToWorld ) {
39
worldv
->pushObject(
this
);
40
}
41
}
42
43
WObject::~WObject
() {
44
worldv
->popObject(
this
);
45
}
46
47
const
wMatrix
&
WObject::matrix
()
const
{
48
return
tm
;
49
}
50
51
void
WObject::setPosition
(
const
wVector
& newpos ) {
52
tm
.w_pos = newpos;
53
changedMatrix
();
54
}
55
56
void
WObject::setPosition
(
real
x,
real
y,
real
z ) {
57
tm
.w_pos =
wVector
(x,y,z);
58
changedMatrix
();
59
}
60
61
World
*
WObject::world
() {
62
return
worldv
;
63
}
64
65
const
World
*
WObject::world
()
const
{
66
return
worldv
;
67
}
68
69
QString
WObject::name
()
const
{
70
return
namev
;
71
}
72
73
void
WObject::setTexture
( QString textureName ) {
74
texturev
= textureName;
75
}
76
77
QString
WObject::texture
()
const
{
78
return
texturev
;
79
}
80
81
void
WObject::setColor
( QColor c ) {
82
colorv
= c;
83
}
84
85
void
WObject::setAlpha
(
int
alpha ) {
86
colorv
.setAlpha( alpha );
87
}
88
89
QColor
WObject::color
()
const
{
90
return
colorv
;
91
}
92
93
bool
WObject::useColorTextureOfOwner
()
const
{
94
return
usecolortextureofowner
;
95
}
96
97
void
WObject::setUseColorTextureOfOwner
(
bool
b ) {
98
usecolortextureofowner
= b;
99
}
100
101
void
WObject::preUpdate
() {
102
/* nothing to do */
103
}
104
105
void
WObject::postUpdate
() {
106
/* nothing to do */
107
}
108
109
void
WObject::setMatrix
(
const
wMatrix
& newm ) {
110
tm
= newm;
111
changedMatrix
();
112
}
113
114
bool
WObject::isInvisible
()
const
{
115
return
invisible
;
116
}
117
118
void
WObject::setInvisible
(
bool
b ) {
119
invisible
= b;
120
}
121
122
void
WObject::drawLocalAxes
(
bool
d) {
123
localFrameOfReferenceDrawn
= d;
124
}
125
126
bool
WObject::localAxesDrawn
()
const
127
{
128
return
localFrameOfReferenceDrawn
;
129
}
130
131
void
WObject::setLabel
(QString label)
132
{
133
labelv
=
label
;
134
}
135
136
void
WObject::setLabel
(QString label,
wVector
pos, QColor color)
137
{
138
labelv
=
label
;
139
labelpos
= pos;
140
labelcol
=
color
;
141
}
142
143
const
QString&
WObject::label
()
const
144
{
145
return
labelv
;
146
}
147
148
void
WObject::setLabelPosition
(
const
wVector
& pos)
149
{
150
labelpos
= pos;
151
}
152
153
const
wVector
&
WObject::labelPosition
()
const
154
{
155
return
labelpos
;
156
}
157
158
void
WObject::setLabelColor
(
const
QColor& color)
159
{
160
labelcol
=
color
;
161
}
162
163
const
QColor&
WObject::labelColor
()
const
164
{
165
return
labelcol
;
166
}
167
168
void
WObject::showLabel
(
bool
show)
169
{
170
labeldrawn
= show;
171
}
172
173
bool
WObject::labelShown
()
const
174
{
175
return
labeldrawn
;
176
}
177
178
void
WObject::changedMatrix
() {
179
/* nothing to do here */
;
180
}