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
59 class IvScreenAnnotation : public Body {
60 friend class ObjectFactory;
61 public:
62 void initializeUsingXML(xercesc::DOMElement *element) override;
63 xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *parent) override;
64 void setScale1To1(bool scale1To1_);
65 bool getScale1To1();
66
75 void setScale1To1At(const std::vector<double> &scale1To1Center_);
76
77 std::vector<double> getScale1To1At();
78 void setIvFileName(std::string ivFileName_) { ivContent=""; ivFileName=std::move(ivFileName_); }
79 std::string getIvFileName() { return ivFileName; }
80 void setIvContent(std::string ivContent_) { ivFileName=""; ivContent=std::move(ivContent_); }
81 const std::string& getIvContent() { return ivContent; }
82 void setColumnLabels(const std::vector<std::string> &columnLabels_);
83 const std::vector<std::string>& getColumnLabels() const;
84
85 void createHDF5File() override;
86 void openHDF5File() override;
87
88 template<typename T>
89 void append(const T& row) {
90 if(data==nullptr) throw std::runtime_error("IvScreenAnnotation: Cannot append data to an environment object");
91 if(row.size()!=static_cast<int>(columnLabels.size())) throw std::runtime_error("IvScreenAnnotation: The dimension does not match (append: "+
92 std::to_string(row.size())+", columns: "+std::to_string(columnLabels.size())+")");
93 data->append(&row(0), row.size());
94 }
95
96 int getRows() override { return data?data->getRows():0; }
97 std::vector<double> getRow(int i) override { return data ? data->getRow(i) : std::vector<double>(columnLabels.size()); }
98 protected:
99 IvScreenAnnotation();
100 ~IvScreenAnnotation() override = default;
101 bool scale1To1;
102 std::vector<double> scale1To1Center;
103 std::string ivFileName;
104 std::string ivContent;
105 std::vector<std::string> columnLabels;
106 H5::VectorSerie<double>* data{nullptr};
107 };
108
109 }
110
111 #endif
OpenMBV::IvScreenAnnotation::getRows
int getRows() override
Definition: ivscreenannotation.h:96
OpenMBV::IvScreenAnnotation
Definition: ivscreenannotation.h:59
OpenMBV::ObjectFactory
Definition: objectfactory.h:38
H5::VectorSerie::getRow
void getRow(int row, size_t size, T data[])
OpenMBV::IvScreenAnnotation::getRow
std::vector< double > getRow(int i) override
Definition: ivscreenannotation.h:97
H5::VectorSerie< double >
OpenMBV::IvScreenAnnotation::initializeUsingXML
void initializeUsingXML(xercesc::DOMElement *element) override
Definition: ivscreenannotation.cc:51
H5::VectorSerie::append
void append(const T data[], size_t size)
OpenMBV::IvScreenAnnotation::setScale1To1At
void setScale1To1At(const std::vector< double > &scale1To1Center_)
Definition: ivscreenannotation.cc:91
H5::VectorSerie::getRows
int getRows()
OpenMBV::Body
Definition: body.h:32