All Classes Namespaces Functions Variables Typedefs Enumerations Pages
arrow.h
1 /*
2  OpenMBV - Open Multi Body Viewer.
3  Copyright (C) 2009 Markus Friedrich
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 #ifndef _OPENMBV_ARROW_H_
21 #define _OPENMBV_ARROW_H_
22 
23 #include <openmbvcppinterface/dynamiccoloredbody.h>
24 #include <hdf5serie/vectorserie.h>
25 #include <cmath>
26 #include <stdexcept>
27 
28 namespace OpenMBV {
29 
38  class Arrow : public DynamicColoredBody {
39  friend class ObjectFactory;
40  public:
41  enum Type {
42  line,
43  fromHead,
44  toHead,
45  bothHeads,
46  fromDoubleHead,
47  toDoubleHead,
48  bothDoubleHeads
49  };
50  enum ReferencePoint {
51  toPoint,
52  fromPoint,
53  midPoint
54  };
55  protected:
56  std::string pathStr;
57  void createHDF5File();
58  void openHDF5File();
60  double headDiameter, headLength, diameter, scaleLength;
61  Type type;
62  ReferencePoint referencePoint;
63 
64  Arrow();
65  virtual ~Arrow();
66  public:
68  std::string getClassName() { return "Arrow"; }
69 
71  void setPath(bool p) { pathStr=(p==true)?"true":"false"; }
72 
73  bool getPath() { return pathStr=="true"?true:false; }
74 
76  template<typename T>
77  void append(const T& row) {
78  if(data==0) throw std::runtime_error("can not append data to an environment object");
79  if(row.size()!=8) throw std::runtime_error("the dimension does not match");
80  if(!std::isnan(dynamicColor))
81  {
82  std::vector<double> tmprow(8);
83  std::copy(&row[0], &row[8], tmprow.begin());
84  tmprow[7]=dynamicColor;
85  data->append(tmprow);
86  }
87  else
88  data->append(row);
89  }
90 
91  int getRows() { return data?data->getRows():-1; }
92  std::vector<double> getRow(int i) { return data?data->getRow(i):std::vector<double>(8); }
93 
95  void setArrowHead(double diameter, double length) {
96  headDiameter=diameter;
97  headLength=length;
98  }
99 
101  void setHeadDiameter(double diameter) {
102  headDiameter=diameter;
103  }
104 
105  double getHeadDiameter() { return headDiameter; }
106 
108  void setHeadLength(double length) {
109  headLength=length;
110  }
111 
112  double getHeadLength() { return headLength; }
113 
115  void setDiameter(double diameter_) {
116  diameter=diameter_;
117  }
118 
119  double getDiameter() { return diameter; }
120 
130  void setType(Type type_) {
131  type=type_;
132  }
133 
134  Type getType() { return type; }
135 
142  void setReferencePoint(ReferencePoint referencePoint_) {
143  referencePoint=referencePoint_;
144  }
145 
146  ReferencePoint getReferencePoint() { return referencePoint; }
147 
149  void setScaleLength(double scale) {
150  scaleLength=scale;
151  }
152 
153  double getScaleLength() { return scaleLength; }
154 
156  virtual void initializeUsingXML(xercesc::DOMElement *element);
157 
158  xercesc::DOMElement *writeXMLFile(xercesc::DOMNode *parent);
159  };
160 
161 }
162 
163 #endif
void setHeadLength(double length)
Definition: arrow.h:108
virtual void initializeUsingXML(xercesc::DOMElement *element)
Definition: arrow.cc:105
void append(const T &row)
Definition: arrow.h:77
Definition: objectfactory.h:40
void setReferencePoint(ReferencePoint referencePoint_)
Definition: arrow.h:142
Definition: arrow.h:38
void setScaleLength(double scale)
Definition: arrow.h:149
void setHeadDiameter(double diameter)
Definition: arrow.h:101
void setDiameter(double diameter_)
Definition: arrow.h:115
Definition: dynamiccoloredbody.h:28
void setArrowHead(double diameter, double length)
Definition: arrow.h:95
void setType(Type type_)
Definition: arrow.h:130
std::vector< double > getRow(int i)
Definition: arrow.h:92
int getRows()
Definition: arrow.h:91
void setPath(bool p)
Definition: arrow.h:71
void getRow(const int row, size_t size, T data[])
void append(const T data[], size_t size)
std::string getClassName()
Definition: arrow.h:68

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML