phycylinder.h
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2011 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 PHYCYLINDER_H
21 #define PHYCYLINDER_H
22 
23 #include "phyobject.h"
24 #include "intervals.h"
25 #include <QMap>
26 
27 namespace farsa {
28 
53 class FARSA_WSIM_API PhyCylinder : public PhyObject {
54  Q_OBJECT
55 public:
63  struct SegmentColor {
70  intervals(),
71  color(Qt::white)
72  {
73  }
74 
81  SegmentColor(Intervals i, QColor c) :
82  intervals(i),
83  color(c)
84  {
85  }
86 
91 
95  QColor color;
96  };
97 
98 public:
105  PhyCylinder( real radius, real height, World* world, QString name="unamed", const wMatrix& tm = wMatrix::identity() );
107  virtual ~PhyCylinder();
109  real radius() const {
110  return radiusv;
111  };
113  real height() const {
114  return heightv;
115  };
116 
124  void setUpperBaseColor(QColor color);
125 
131  const QColor& upperBaseColor() const
132  {
133  return m_upperBaseColor;
134  }
135 
143  void setLowerBaseColor(QColor color);
144 
150  const QColor& lowerBaseColor() const
151  {
152  return m_lowerBaseColor;
153  }
154 
171  void setSegmentsColor(QColor base, const QList<SegmentColor>& segmentsColor);
172 
180  const QList<SegmentColor>& segmentsColor() const
181  {
182  if (colorv.isValid()) {
183  m_uniformColor[0].color = colorv;
184 
185  return m_uniformColor;
186  } else {
187  return m_segmentsColor;
188  }
189  }
190 
207  bool graphicalRepresentationNeedsUpdate(void* renderer = NULL);
208 
209 private:
216  void setUpdateAllGraphicalRepresentation();
217 
218  real radiusv;
219  real heightv;
220 
224  QColor m_upperBaseColor;
225 
229  QColor m_lowerBaseColor;
230 
237  QList<SegmentColor> m_segmentsColor;
238 
245  mutable QList<SegmentColor> m_uniformColor;
246 
253  QMap<void*, bool> m_graphicalRepresentationNeedsUpdate;
254 
262  QColor m_oldColorv;
263 
264 protected:
266  void createPrivateObject();
267 };
268 
269 } // end namespace farsa
270 
271 #endif
SegmentColor(Intervals i, QColor c)
Constructor.
Definition: phycylinder.h:81
Intervals intervals
The intervals of the cylinder with the given color.
Definition: phycylinder.h:90
static wMatrix identity()
create an identity matrix
Definition: wmatrix.h:460
real height() const
return the height
Definition: phycylinder.h:113
World class.
Definition: world.h:223
real radius() const
return the radius
Definition: phycylinder.h:109
The structure used to define the color of intervals of the cylinder.
Definition: phycylinder.h:63
wMatrix class
Definition: wmatrix.h:48
const QList< SegmentColor > & segmentsColor() const
Returns the color of segments of the cylinder.
Definition: phycylinder.h:180
float real
PhyCylinder class.
Definition: phycylinder.h:53
const QColor & lowerBaseColor() const
Returns the color of the lower base.
Definition: phycylinder.h:150
const QColor & upperBaseColor() const
Returns the color of the upper base.
Definition: phycylinder.h:131
PhyObject class.
Definition: phyobject.h:46
QColor color
The color of the segment.
Definition: phycylinder.h:95