Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
CalibrationSets.h
Go to the documentation of this file.
1#pragma once
2#include "Namespace.h"
4#include <gii/gen/Variable.h>
7
8namespace sf
9{
10// Forward definitions.
11class TCalibrationSets;
12class TCalibrationVariablesPropertyPage;
13
26
31{
32 protected:
38
43
44 public:
55 void ReadWriteConfig(bool rd);
56 // Reads or writes the calibration set to the specified ini file.
57 void ReadWriteConfig(IniProfile* inifile, bool rd);
58 // Copy the current calibrated settings for those which are specified int the id's list.
59 // When the list is NULL all calib parameters are set.
60 bool AssignType(ECalibrationType cal_type, const InformationIds* ids = nullptr);
61 // Assignment flags in the variables data field are reset.
62 void ClearType(ECalibrationType cal_type, const InformationIds* ids = nullptr);
63 // Returns true if all calibration values are assigned.
65 // Returns true if all calibration values are assigned.
66 bool AssignComplete() const;
67
68 private:
69 // Read s or writes the calibration values of the specified cal type.
70 bool ReadWriteAssignValues(ECalibrationValueState cvs, ECalibrationType cal_type, KeyValues& key_values, bool rd);
71
72 //
73 const std::string& GetName()
74 {
75 return FName;
76 }
77
78 void SetName(const std::string& name)
79 {
80 FName = name;
81 }
82
83 // Gets a list of global variable Ids.
84 InformationIds* GetIds()
85 {
86 return FIds[ctCAL_NONE];
87 }
88
89 // Handles changes on the
90 void HandleIdsChange(void* sender);
91 // Exports or revokes the current exports.
92 void SetExports(bool var_export);
93 // Owner of this instance which is the set list.
94 TCalibrationSets* FOwner;
95 // Calibration set name.
96 std::string FName;
97 // Holds the list with calibration variables. ctCAL_NONE holds the global vars.
99 // Wrapper for the all variable lists.
100 VariableIdList* FIds[ctCAL_LASTENTRY];
101
102 friend TCalibrationSets;
103 friend TCalibrationVariablesPropertyPage;
104};
105
107{
108 // Always return a valid vector.
109 if (ct < ctCAL_NONE || ct >= ctCAL_LASTENTRY)
110 ct = ctCAL_NONE;
111 return FVars[ct];
112}
113
115 : public ProjectScriptObject
117{
118 public:
119 // Constructor.
120 TCalibrationSets(const std::string& prefix, id_type id_offset, id_type id_range);
121 // Destructor.
123 // Returns the amount of sets
124 int Size() const;
125 // Returns the set names.
126 void GetNames(strings& names) const;
127 // Returns the set index of passed name.
128 int IndexOf(const std::string& name) const;
129 // Returns the set of the passed index.
130 const CalibrationSet* operator[](int index) const;
131 CalibrationSet* operator[](int index);
132
133 const CalibrationSet* Get(int index) const
134 {
135 return (*this)[index];
136 }
137
138 CalibrationSet* Get(int index)
139 {
140 return (*this)[index];
141 }
142
143 // Returns the set with the passed name or NULL when not found.
144 const CalibrationSet* Get(const std::string& name) const;
145 CalibrationSet* Get(const std::string& name);
146 // Reads or writes the calibrations sets and their configurations.
147 void ReadWriteConfig(IniProfile* inifile, bool rd);
148 // Reads all calibration values of all sets for the passed inspection.
149 bool ReadWriteAssignValues(TPartInspection* part_insp, bool rd);
150 // Reads all pre calibration values of all sets for the passed project.
151 bool ReadWriteAssignValues(PartProject* part_proj, bool rd);
152 // Returns dirty if the config has changed.
153 bool IsDirty() const;
154 // Resets or sets the dirty flag.
155 void SetDirty(bool dirty = false);
156
157 // Copy the current calibrated settings for those which are specified in
158 // the ID's list. When the list is NULL all calib parameters are set.
159 bool AssignType(ECalibrationType cal_type, const std::string& set_name, const InformationIds* ids = nullptr);
160 // Export all variables of the passed set and revoke all other sets.
161 // When the set does not exist all current exports are revoked.
162 void SetExports(const std::string& set_name) const;
163 void SetExports(int index = -1) const;
164 // When the set does exist assignments of the set are revoked.
165 void ClearType(ECalibrationType cal_type, const std::string& set_name, InformationIds* ids = nullptr);
166 void ClearType(ECalibrationType cal_type, int index = -1, const InformationIds* ids = nullptr);
167 // Returns true when the calibration set is completely assign.
168 bool AssignComplete(const std::string& set_name) const;
169 // Returns true when the calibration set of the passed index is completely assign.
170 // When -1 is passed it checks all sets for assign completion.
171 bool AssignComplete(int index = -1) const;
172
173 protected:
174 // Sets the amount of entries.
175 void Resize(int sz);
176 // Event handler for the global calibration variables.
177 void variableEventHandler(EEvent event, const Variable& caller, Variable& link, bool same_inst) override;
178
179 // Returns the complete name string.
180 std::string GetNamePrefix(ECalibrationType cal_type);
181
182 private:
184 std::string FNamePrefix;
185 id_type FIdOffset;
186 id_type FIdRange;
187 bool FDirty;
188
189 friend CalibrationSet;
190 friend TCalibrationVariablesPropertyPage;
191};
192
193inline int TCalibrationSets::Size() const
194{
195 return FSets.count();
196}
197
198inline const CalibrationSet* TCalibrationSets::operator[](int index) const
199{
200 if (index >= FSets.count())
201 return nullptr;
202 return FSets[index];
203}
204
206{
207 if (index >= FSets.count())
208 return nullptr;
209 return FSets[index];
210}
211
212inline const CalibrationSet* TCalibrationSets::Get(const std::string& name) const
213{
214 return FSets[IndexOf(name)];
215}
216
217inline CalibrationSet* TCalibrationSets::Get(const std::string& name)
218{
219 return FSets[IndexOf(name)];
220}
221
222inline bool TCalibrationSets::IsDirty() const
223{
224 return FDirty;
225}
226
227inline void TCalibrationSets::SetDirty(bool dirty)
228{
229 FDirty = dirty;
230}
231
232inline void TCalibrationSets::SetExports(const std::string& set_name) const
233{
234 SetExports(IndexOf(set_name));
235}
236
237inline void TCalibrationSets::ClearType(ECalibrationType cal_type, const std::string& set_name, InformationIds* ids)
238{
239 int index = IndexOf(set_name);
240 if (index >= 0)
241 ClearType(cal_type, index, ids);
242}
243
244inline bool TCalibrationSets::AssignComplete(const std::string& set_name) const
245{
246 int index = IndexOf(set_name);
247 if (index >= 0)
248 return AssignComplete();
249 return false;
250}
251
252}// namespace sf
Holds a single calibration set of parameters.
Definition CalibrationSets.h:31
void ReadWriteConfig(bool rd)
Reads or writes the calibration set.
void ClearType(ECalibrationType cal_type, const InformationIds *ids=nullptr)
bool AssignComplete(ECalibrationType ct) const
bool AssignType(ECalibrationType cal_type, const InformationIds *ids=nullptr)
const Variable::PtrVector & Get(ECalibrationType ct=ctCAL_NONE) const
Gets the calibration variable array.
Definition CalibrationSets.h:106
bool AssignComplete() const
void ReadWriteConfig(IniProfile *inifile, bool rd)
~CalibrationSet()
Destructor.
CalibrationSet(TCalibrationSets *owner)
Protected constructor.
Abstract class to store information id's in a configuration string. Used to be implemented twice,...
Definition InformationIds.h:13
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
Class for reading and writing ini-profiles.
Definition IniProfile.h:17
Definition PartProject.h:10
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Definition CalibrationSets.h:117
void ClearType(ECalibrationType cal_type, const std::string &set_name, InformationIds *ids=nullptr)
Definition CalibrationSets.h:237
bool ReadWriteAssignValues(PartProject *part_proj, bool rd)
void ClearType(ECalibrationType cal_type, int index=-1, const InformationIds *ids=nullptr)
void SetDirty(bool dirty=false)
Definition CalibrationSets.h:227
const CalibrationSet * operator[](int index) const
Definition CalibrationSets.h:198
void GetNames(strings &names) const
int Size() const
Definition CalibrationSets.h:193
bool IsDirty() const
Definition CalibrationSets.h:222
bool AssignComplete(int index=-1) const
void SetExports(int index=-1) const
void ReadWriteConfig(IniProfile *inifile, bool rd)
bool ReadWriteAssignValues(TPartInspection *part_insp, bool rd)
CalibrationSet * Get(int index)
Definition CalibrationSets.h:138
bool AssignType(ECalibrationType cal_type, const std::string &set_name, const InformationIds *ids=nullptr)
int IndexOf(const std::string &name) const
~TCalibrationSets() override
bool AssignComplete(const std::string &set_name) const
Definition CalibrationSets.h:244
void variableEventHandler(EEvent event, const Variable &caller, Variable &link, bool same_inst) override
Pure virtual function which must be implemented when used in a polymorphic setting.
TCalibrationSets(const std::string &prefix, id_type id_offset, id_type id_range)
void Resize(int sz)
void SetExports(const std::string &set_name) const
Definition CalibrationSets.h:232
const CalibrationSet * Get(int index) const
Definition CalibrationSets.h:133
std::string GetNamePrefix(ECalibrationType cal_type)
Definition PartInspection.h:11
Base class used for giving a Variable instance access to a member functions of a derived class....
Definition VariableHandler.h:14
TVector< Variable * > PtrVector
Vector for pointers to variables.
Definition VariableTypes.h:31
EEvent
Events send to the handler set with sf::Variable::setHandler.
Definition VariableTypes.h:130
Class for creating and referencing global or local created parameters or settings called variables....
Definition Variable.h:16
Definition Application.h:10
IniProfile::KeyValueMap KeyValues
Definition ipj/iface/Namespace.h:188
ECalibrationValueState
State of the calibration value.
Definition CalibrationSets.h:18
@ cvsINITIALIZED
Has been calibrated.
Definition CalibrationSets.h:22
@ cvsASSIGNED
Definition CalibrationSets.h:24
@ cvsEMPTY
Has no value assigned by initialization or calibration.
Definition CalibrationSets.h:20
TStrings< std::string > strings
Vector of std::strings with additional functionality.
Definition TStrings.h:193
ECalibrationType
Type to identify a scan area type.
Definition ipj/iface/Namespace.h:247
@ ctCAL_NONE
Definition ipj/iface/Namespace.h:249
@ ctCAL_LASTENTRY
Definition ipj/iface/Namespace.h:255