wobject.h
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 #ifndef WOBJECT_H
21 #define WOBJECT_H
22 
23 #include "worldsimconfig.h"
24 #include "ownable.h"
25 #include "wmatrix.h"
26 #include "wvector.h"
27 
28 #include <QString>
29 #include <QColor>
30 
31 namespace farsa {
32 
33 class World;
34 
39 class FARSA_WSIM_API WObject : public QObject, public Ownable {
40  Q_OBJECT
41 public:
53  WObject( World* world, QString name="unamed", const wMatrix& tm = wMatrix::identity(), bool addToWorld = true );
55  virtual ~WObject();
57  const wMatrix& matrix() const;
59  void setPosition( const wVector& newpos );
61  void setPosition( real x, real y, real z );
63  World* world();
65  const World* world() const;
67  QString name() const;
69  void setTexture( QString textureName );
71  QString texture() const;
77  void setColor( QColor c );
79  void setAlpha( int alpha );
81  QColor color() const;
83  bool useColorTextureOfOwner() const;
85  void setUseColorTextureOfOwner( bool b );
90  virtual void preUpdate();
95  virtual void postUpdate();
97  void setMatrix( const wMatrix& newm );
99  bool isInvisible() const;
104  void setInvisible( bool b );
114  void drawLocalAxes(bool d);
121  bool localAxesDrawn() const;
127  void setLabel(QString label);
135  void setLabel(QString label, wVector pos);
144  void setLabel(QString label, wVector pos, QColor color);
150  const QString& label() const;
156  void setLabelPosition(const wVector& pos);
162  const wVector& labelPosition() const;
168  void setLabelColor(const QColor& color);
174  const QColor& labelColor() const;
180  void showLabel(bool show);
186  bool labelShown() const;
187 protected:
189  virtual void changedMatrix();
195  QString namev;
197  QString texturev;
199  QColor colorv;
201  bool invisible;
207  QString labelv;
211  QColor labelcol;
214 };
215 
216 } // end namespace farsa
217 
218 #endif
QString namev
Name of the WObject.
Definition: wobject.h:195
World's Object class.
Definition: wobject.h:39
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
wMatrix tm
Trasformation matrix.
Definition: wobject.h:193
wVector labelpos
The position of the label in the object frame of reference.
Definition: wobject.h:209
QString labelv
The text label of the object.
Definition: wobject.h:207
QString texturev
Texture name.
Definition: wobject.h:197
bool labeldrawn
Whether the label should be rendered or not.
Definition: wobject.h:213
bool invisible
if TRUE it will not renderized
Definition: wobject.h:201
World class.
Definition: world.h:223
The base for all class that can have (and can be) an owner.
Definition: ownable.h:37
wMatrix class
Definition: wmatrix.h:48
World * worldv
World.
Definition: wobject.h:191
QColor labelcol
The color of the label.
Definition: wobject.h:211
QColor colorv
Color, it contains also alpha channel.
Definition: wobject.h:199
float real
bool usecolortextureofowner
if true, we will use color and texture of our owner (if we have one).
Definition: wobject.h:203
bool localFrameOfReferenceDrawn
If true, the local frame of reference of the object is drawn.
Definition: wobject.h:205