openmbvcppinterface  3.1.0
OpenMBV C++ Interface
ivscreenannotation.h
1 /*
2  OpenMBV - Open Multi Body Viewer.
3  Copyright (C) 2009 Markus Friedrich
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library 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 GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
20 #ifndef _OPENMBV_IVSCREENANNOTATION_H_
21 #define _OPENMBV_IVSCREENANNOTATION_H_
22 
23 #include "body.h"
24 #include <hdf5serie/vectorserie.h>
25 
26 namespace OpenMBV {
27 
51  class IvScreenAnnotation : public Body {
52  friend class ObjectFactory;
53  public:
54  void initializeUsingXML(xercesc::DOMElement *element) override;
55  xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
56  void setScale1To1(bool scale1To1_);
57  bool getScale1To1();
58 
67  void setScale1To1At(const std::vector<double> &scale1To1Center_);
68 
69  std::vector<double> getScale1To1At();
70  void setIvFileName(std::string ivFileName_) { ivContent=""; ivFileName=std::move(ivFileName_); }
71  std::string getIvFileName() { return ivFileName; }
72  void setIvContent(std::string ivContent_) { ivFileName=""; ivContent=std::move(ivContent_); }
73  const std::string& getIvContent() { return ivContent; }
74  void setColumnLabels(const std::vector<std::string> &columnLabels_);
75  const std::vector<std::string>& getColumnLabels() const;
76 
77  void createHDF5File() override;
78  void openHDF5File() override;
79 
80  template<typename T>
81  void append(const T& row) {
82  if(data==nullptr) throw std::runtime_error("IvScreenAnnotation: Cannot append data to an environment object");
83  if(row.size()!=static_cast<int>(columnLabels.size())) throw std::runtime_error("IvScreenAnnotation: The dimension does not match (append: "+
84  std::to_string(row.size())+", columns: "+std::to_string(columnLabels.size())+")");
85  data->append(&row(0), row.size());
86  }
87 
88  int getRows() override { return data?data->getRows():0; }
89  std::vector<double> getRow(int i) override { return data ? data->getRow(i) : std::vector<double>(columnLabels.size()); }
90  protected:
92  ~IvScreenAnnotation() override = default;
93  bool scale1To1;
94  std::vector<double> scale1To1Center;
95  std::string ivFileName;
96  std::string ivContent;
97  std::vector<std::string> columnLabels;
98  H5::VectorSerie<double>* data{nullptr};
99  };
100 
101 }
102 
103 #endif
int getRows() override
Definition: ivscreenannotation.h:88
Definition: ivscreenannotation.h:51
Definition: objectfactory.h:38
void getRow(int row, size_t size, T data[])
std::vector< double > getRow(int i) override
Definition: ivscreenannotation.h:89
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: ivscreenannotation.cc:51
void append(const T data[], size_t size)
void setScale1To1At(const std::vector< double > &scale1To1Center_)
Definition: ivscreenannotation.cc:91
Definition: body.h:32