MeVisLab Toolbox Reference
mlXMarkerList.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_XMARKER_LIST_H
14 #define ML_XMARKER_LIST_H
15 
16 
18 
19 // Defines the classes:
20 // - XMarker: A general marker with a 6D-position, a 3D-vector and an integer type.
21 // - XMarkerList: A list of XMarker items
22 // - XMarkerContainer: A container module for a XMarkerList object
23 
24 // ML includes
25 #include "mlBaseInit.h"
26 #include "mlModuleIncludes.h"
27 #include "mlLinearAlgebra.h"
28 #include "mlTreeNode.h"
29 
30 
31 
32 #include "mlListBase.h"
33 #include "mlListContainer.h"
34 
35 
36 
37 ML_START_NAMESPACE
38 
39 
40 
41 // ------------------------------------------------------------------
44 // ------------------------------------------------------------------
45 
52 {
53 public:
54 
57 
60  int type;
61 
63 
64 
67 
70  : pos(0), vec(0), type(0) {}
72  XMarker (const Vector3 &pos_)
73  : pos(pos_,0,0,0), vec(0), type(0) {}
75  XMarker (const Vector6 &pos_)
76  : pos(pos_), vec(0), type(0) {}
78  XMarker (const Vector6 &pos_, int type_)
79  : pos(pos_), vec(0), type(type_) {}
81  XMarker (const Vector6 &pos_, int type_, const char *name_)
82  : pos(pos_), vec(0), type(type_) {setName(name_);}
83 
85  XMarker (const Vector6 &pos_, const Vector3 &vec_)
86  : pos(pos_), vec(vec_), type(0) {}
88  XMarker (const Vector6 &pos_, const Vector3 &vec_, int type_)
89  : pos(pos_), vec(vec_), type(type_) {}
91  XMarker (const Vector6 &pos_, const Vector3 &vec_, int type_, const char *name_)
92  : pos(pos_), vec(vec_), type(type_) {setName(name_);}
93 
95  XMarker (const XMarker &marker) : BaseItem() { *this = marker; }
96 
98 
99 
101  XMarker &operator = (const XMarker &marker);
102 
104  bool operator ==(const XMarker &marker) const { return (pos == marker.pos) && (vec == marker.vec) && (type == marker.type); }
105 
108 
109  double &x () { return pos[ML_VX]; }
110  double &y () { return pos[ML_VY]; }
111  double &z () { return pos[ML_VZ]; }
112  double &c () { return pos[ML_VC]; }
113  double &t () { return pos[ML_VT]; }
114  double &u () { return pos[ML_VU]; }
115 
116  const double &x () const { return pos[ML_VX]; }
117  const double &y () const { return pos[ML_VY]; }
118  const double &z () const { return pos[ML_VZ]; }
119  const double &c () const { return pos[ML_VC]; }
120  const double &t () const { return pos[ML_VT]; }
121  const double &u () const { return pos[ML_VU]; }
122 
123  double vx () const { return vec[ML_VX]; }
124  double vy () const { return vec[ML_VY]; }
125  double vz () const { return vec[ML_VZ]; }
126 
128 
129 
133  std::string persistentState() const override;
134 
136  void setPersistentState(const std::string& state) override;
137 
139  void addStateToTree(TreeNode *parent) const override;
140 
143 
145  void readStateFromTree(TreeNode *parent) override;
146 
148 
149 
150 private:
151 
154 
155 };
156 
157 
158 
159 // ------------------------------------------------------------------
162 // ------------------------------------------------------------------
163 
167 {
168 public:
169 
172 
179 private:
180 
183 
184 };
185 
186 
187 
188 // ------------------------------------------------------------------
191 // ------------------------------------------------------------------
192 
196 {
197 public:
198 
201 
202 
203 protected:
204 
208  bool isPropertyField (Field *field) override;
209 
211  void resetPropertyFields () override;
212 
214  void updatePropertyFields () override;
215 
217 
218 
225  bool modifyItem (MLssize_t index, Field *field, bool fromCurrentItem) override;
226 
228  void copyItemToTemplate (MLssize_t index) override;
229 
231  void copyTemplateToCurrent () override;
232 
236  void initItem (MLssize_t index) override;
237 
239 
240 
241 private:
242 
245 
246  Vector3Field *_fldPosXYZ;
247  FloatField *_fldPosC,
248  *_fldPosT,
249  *_fldPosU;
250  Vector3Field *_fldVec;
251  FloatField* _fldVecLength;
252  IntField *_fldType;
253 
254  // template fields for initialization of a newly inserted item
255 
256  Vector3Field *_fldNewPosXYZ;
257  FloatField *_fldNewPosC,
258  *_fldNewPosT,
259  *_fldNewPosU;
260  Vector3Field *_fldNewVec;
261  IntField *_fldNewType;
262 
264 
265 
268 
269 };
270 
271 
272 
273 ML_END_NAMESPACE
274 
275 #endif // __mlXMarkerList_H
General Base object class for list items that have an id and a name.
Definition: mlBaseItem.h:38
BaseItem & operator=(const BaseItem &item)
Assignment operator.
void setName(const char *newName)
Set name, object stores a copy.
Base object template list class for list item classes derived from BaseItem.
Definition: mlListBase.h:654
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate a float value.
Definition: mlFields.h:389
Field to encapsulate an integer value.
Definition: mlFields.h:117
Template module class ListContainerTemplate for a specific list class.
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition: mlTreeNode.h:154
Field to encapsulate a vector of three double values.
Definition: mlFields.h:1019
Base object class XMarkerListContainer (derived from ListContainerTemplate) for XMarkerList objects.
void resetPropertyFields() override
Reset all property fields.
XMarkerListContainer()
Constructor.
void initItem(MLssize_t index) override
Initialize the list item at position index.
void copyItemToTemplate(MLssize_t index) override
Copy values from item at position index to the template fields.
void copyTemplateToCurrent() override
Copy the values of the templates fields to _currentItem.
bool isPropertyField(Field *field) override
void updatePropertyFields() override
Update property fields from the current list item.
bool modifyItem(MLssize_t index, Field *field, bool fromCurrentItem) override
Modify item at position index.
Base object class XMarkerList (derived from BaseListTemplate) specialized for XMarker items.
XMarkerList()
Constructor, enables persistence.
Base object class XMarker (derived form baseItem) with 6D pos, 3D vec and type int.
Definition: mlXMarkerList.h:52
Vector3 vec
Marker vector, relative to position.
Definition: mlXMarkerList.h:59
XMarker(const Vector3 &pos_)
3D-Position
Definition: mlXMarkerList.h:72
double & x()
double & y()
const double & u() const
Vector6 pos
Marker position.
Definition: mlXMarkerList.h:58
const double & x() const
double vx() const
double vy() const
XMarker(const Vector6 &pos_, int type_, const char *name_)
6D-Position, type and name
Definition: mlXMarkerList.h:81
const double & c() const
double vz() const
int type
Marker type.
Definition: mlXMarkerList.h:60
double & t()
XMarker(const Vector6 &pos_, int type_)
6D-Position and type
Definition: mlXMarkerList.h:78
ML_SET_ADDSTATE_VERSION(0)
Set addState version number.
const double & z() const
void addStateToTree(TreeNode *parent) const override
Add state to tree.
void setPersistentState(const std::string &state) override
Initialize the item object from the string state.
XMarker(const XMarker &marker)
Copy constructor.
Definition: mlXMarkerList.h:95
const double & y() const
std::string persistentState() const override
Return a string representation of the item object.
double & z()
XMarker(const Vector6 &pos_)
6D-Position
Definition: mlXMarkerList.h:75
XMarker(const Vector6 &pos_, const Vector3 &vec_, int type_, const char *name_)
6D-Position, vector, type and name
Definition: mlXMarkerList.h:91
XMarker(const Vector6 &pos_, const Vector3 &vec_)
6D-Position and vector
Definition: mlXMarkerList.h:85
double & u()
XMarker(const Vector6 &pos_, const Vector3 &vec_, int type_)
6D-Position, vector and type
Definition: mlXMarkerList.h:88
XMarker()
Default constructor.
Definition: mlXMarkerList.h:69
double & c()
const double & t() const
void readStateFromTree(TreeNode *parent) override
Read state from tree.
#define ML_MODULE_CLASS_HEADER(className)
Similar to ML_CLASS_HEADER for the usage of derived classes from Module.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition: mlBaseInit.h:22
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non-existing export symbol.
@ ML_VT
Array index for t (time) components (entry 4)
Definition: mlTypeDefs.h:1152
@ ML_VC
Array index for c (color) components (entry 3)
Definition: mlTypeDefs.h:1151
@ ML_VY
Array index for y components (entry 1)
Definition: mlTypeDefs.h:1148
@ ML_VU
Array index for u (unit/user dimension) components (entry 5)
Definition: mlTypeDefs.h:1153
@ ML_VZ
Array index for z components (entry 2)
Definition: mlTypeDefs.h:1149
@ ML_VX
Array index for x components (entry 0)
Definition: mlTypeDefs.h:1147
SSIZE_T MLssize_t
The signed ML size type that is a signed 32-bit size_t on 32-bit platforms and 64-bit one on 64-bit p...
Definition: mlTypeDefs.h:566
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Returns true if yes.
Definition: mlMatrix2.h:425