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 
138 #if !ML_DEPRECATED_SINCE(3,5,0)
139 protected:
140 #endif
141 
145  [[nodiscard]][[deprecated]] char *getPersistentState () const override;
146 
149  [[deprecated]] void setPersistentState(const char *state) override;
150 #if !ML_DEPRECATED_SINCE(3,5,0)
151 public:
152 #endif
153 
154 
156  void addStateToTree(TreeNode *parent) const override;
157 
160 
162  void readStateFromTree(TreeNode *parent) override;
163 
165 
166 
167 private:
168 
171 
172 };
173 
174 
175 
176 // ------------------------------------------------------------------
179 // ------------------------------------------------------------------
180 
184 {
185 public:
186 
189 
196 private:
197 
200 
201 };
202 
203 
204 
205 // ------------------------------------------------------------------
208 // ------------------------------------------------------------------
209 
213 {
214 public:
215 
218 
219 
220 protected:
221 
225  bool isPropertyField (Field *field) override;
226 
228  void resetPropertyFields () override;
229 
231  void updatePropertyFields () override;
232 
234 
235 
242  bool modifyItem (MLssize_t index, Field *field, bool fromCurrentItem) override;
243 
245  void copyItemToTemplate (MLssize_t index) override;
246 
248  void copyTemplateToCurrent () override;
249 
253  void initItem (MLssize_t index) override;
254 
256 
257 
258 private:
259 
262 
263  Vector3Field *_fldPosXYZ;
264  FloatField *_fldPosC,
265  *_fldPosT,
266  *_fldPosU;
267  Vector3Field *_fldVec;
268  FloatField* _fldVecLength;
269  IntField *_fldType;
270 
271  // template fields for initialization of a newly inserted item
272 
273  Vector3Field *_fldNewPosXYZ;
274  FloatField *_fldNewPosC,
275  *_fldNewPosT,
276  *_fldNewPosU;
277  Vector3Field *_fldNewVec;
278  IntField *_fldNewType;
279 
281 
282 
285 
286 };
287 
288 
289 
290 ML_END_NAMESPACE
291 
292 #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:722
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate a float value.
Definition: mlFields.h:627
Field to encapsulate an integer value.
Definition: mlFields.h:161
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:170
Field to encapsulate a vector of 3 double values.
Definition: mlFields.h:1538
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()
void setPersistentState(const char *state) override
Initialize the item object from the string state /deprecated.
char * getPersistentState() const override
Return a string representation of the item object.
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)
Like 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:1268
@ ML_VC
Array index for c (color) components (entry 3)
Definition: mlTypeDefs.h:1267
@ ML_VY
Array index for y components (entry 1)
Definition: mlTypeDefs.h:1264
@ ML_VU
Array index for u (unit/user dimension) components (entry 5)
Definition: mlTypeDefs.h:1269
@ ML_VZ
Array index for z components (entry 2)
Definition: mlTypeDefs.h:1265
@ ML_VX
Array index for x components (entry 0)
Definition: mlTypeDefs.h:1263
SSIZE_T MLssize_t
The signed ML size type which is a signed 32 bit size_t on 32 bit platforms and 64 bit one on 64 bit ...
Definition: mlTypeDefs.h:654
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Return true if yes.
Definition: mlMatrix2.h:425