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;
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 
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 
57  tm.w_pos = wVector(x,y,z);
58  changedMatrix();
59 }
60 
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 
95 }
96 
99 }
100 
102  /* nothing to do */
103 }
104 
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 
124 }
125 
127 {
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 
149 {
150  labelpos = pos;
151 }
152 
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 
174 {
175  return labeldrawn;
176 }
177 
179  /* nothing to do here */;
180 }