MBSim

Project Page
plot_elements.h
1 /* Copyright (C) 2004-2011 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@gmail.com
18  */
19 
20 #ifndef _PLOT_ELEMENTS_H__
21 #define _PLOT_ELEMENTS_H__
22 #include "mbsim/element.h"
23 
24 #ifdef HAVE_OPENMBVCPPINTERFACE
25 namespace OpenMBV {
26  //class Frame;
27  class Arrow;
28 }
29 #endif
30 
31 namespace MBSim {
32  class RigidBody;
33  class Frame;
34 
35  class PlotFrame : public Element {
36  private:
37  Frame* frame;
38 #ifdef HAVE_OPENMBVCPPINTERFACE
39  OpenMBV::Arrow *openMBVPosition, *openMBVVelocity, *openMBVAcceleration, *openMBVAngularVelocity, *openMBVAngularAcceleration;
40 #endif
41 
42  public:
43  PlotFrame(const std::string &name);
44  void setFrame(Frame *frame_) { frame = frame_; }
45 
46  void init(InitStage stage);
47  virtual void plot(double t, double dt);
48 
49 #ifdef HAVE_OPENMBVCPPINTERFACE
50  virtual void enableOpenMBVPosition(double scaleLength=1, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
51  virtual void enableOpenMBVVelocity(double scaleLength=1, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
52  virtual void enableOpenMBVAcceleration(double scaleLength=1, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
53  virtual void enableOpenMBVAngularVelocity(double scaleLength=1, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
54  virtual void enableOpenMBVAngularAcceleration(double scaleLength=1, double diameter=0.5, double headDiameter=1, double headLength=1, double color=0.5);
55 #endif
56 
57  };
58 
59  class PlotRigidBodyGroup : public Element {
60  private:
61  std::vector<RigidBody*> body;
62  Frame* ref;
63 #ifdef HAVE_OPENMBVCPPINTERFACE
64  OpenMBV::Arrow *openMBVPosition, *openMBVVelocity, *openMBVAcceleration, *openMBVAngularVelocity, *openMBVAngularAcceleration, *openMBVWeight, *openMBVMomentum, *openMBVAngularMomentum, *openMBVDerivativeOfMomentum, *openMBVDerivativeOfAngularMomentum;
65 #endif
66 
67  public:
68  PlotRigidBodyGroup(const std::string &name);
69  void addBody(RigidBody *body_) { body.push_back(body_); }
70  void setFrameOfReference(Frame* frame) { ref = frame; }
71 
72  void init(InitStage stage);
73  virtual void plot(double t, double dt);
74 
75 #ifdef HAVE_OPENMBVCPPINTERFACE
76  void enableOpenMBVWeight(double scaleLength, double diameter, double headDiameter, double headLength, double color=0.5);
77  void enableOpenMBVMomentum(double scaleLength, double diameter, double headDiameter, double headLength, double color=0.5);
78  void enableOpenMBVAngularMomentum(double scaleLength, double diameter, double headDiameter, double headLength, double color=0.5);
79  void enableOpenMBVDerivativeOfMomentum(double scaleLength, double diameter, double headDiameter, double headLength, double color=0.5);
80  void enableOpenMBVDerivativeOfAngularMomentum(double scaleLength, double diameter, double headDiameter, double headLength, double color=0.5);
81 #endif
82 
83  };
84 
85 }
86 
87 #endif
88