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>
6
7namespace sf
8{
9// Forward definitions.
10class TCalibrationSets;
11class CalibrationVariablesPropertyPage;
12
25
30{
31 protected:
37
42
43 public:
54 void ReadWriteConfig(bool rd);
55 // Reads or writes the calibration set to the specified ini file.
56 void ReadWriteConfig(IniProfile* inifile, bool rd);
57 // Copy the current calibrated settings for those which are specified int the id's list.
58 // When the list is NULL all calib parameters are set.
59 bool AssignType(ECalibrationType cal_type, const InformationIds* ids = nullptr);
60 // Assignment flags in the variables data field are reset.
61 void ClearType(ECalibrationType cal_type, const InformationIds* ids = nullptr);
62 // Returns true if all calibration values are assigned.
64 // Returns true if all calibration values are assigned.
65 bool AssignComplete() const;
66
67 private:
68 // Read s or writes the calibration values of the specified cal type.
69 bool ReadWriteAssignValues(ECalibrationValueState cvs, ECalibrationType cal_type, KeyValues& key_values, bool rd);
70
71 //
72 const std::string& GetName()
73 {
74 return FName;
75 }
76
77 void SetName(const std::string& name)
78 {
79 FName = name;
80 }
81
82 // Gets a list of global variable Ids.
83 InformationIds* GetIds()
84 {
85 return FIds[ctCAL_NONE];
86 }
87
88 // Handles changes on the
89 void HandleIdsChange(void* sender);
90 // Exports or revokes the current exports.
91 void SetExports(bool var_export);
92 // Owner of this instance which is the set list.
93 TCalibrationSets* FOwner;
94 // Calibration set name.
95 std::string FName;
96 // Holds the list with calibration variables. ctCAL_NONE holds the global vars.
98 // Wrapper for the all variable lists.
99 VariableIdList* FIds[ctCAL_LASTENTRY];
100
101 friend TCalibrationSets;
102 friend CalibrationVariablesPropertyPage;
103};
104
106{
107 // Always return a valid vector.
108 if (ct < ctCAL_NONE || ct >= ctCAL_LASTENTRY)
109 ct = ctCAL_NONE;
110 return FVars[ct];
111}
112
114 : public ProjectScriptObject
116{
117 public:
118 // Constructor.
119 TCalibrationSets(const std::string& prefix, id_type id_offset, id_type id_range);
120 // Destructor.
122 // Returns the amount of sets
123 int Size() const;
124 // Returns the set names.
125 void GetNames(string_list& names) const;
126 // Returns the set index of passed name.
127 int IndexOf(const std::string& name) const;
128 // Returns the set of the passed index.
129 const CalibrationSet* operator[](int index) const;
130 CalibrationSet* operator[](int index);
131
132 const CalibrationSet* Get(int index) const
133 {
134 return (*this)[index];
135 }
136
137 CalibrationSet* Get(int index)
138 {
139 return (*this)[index];
140 }
141
142 // Returns the set with the passed name or NULL when not found.
143 const CalibrationSet* Get(const std::string& name) const;
144 CalibrationSet* Get(const std::string& name);
145 // Reads or writes the calibrations sets and their configurations.
146 void ReadWriteConfig(IniProfile* inifile, bool rd);
147 // Reads all calibration values of all sets for the passed inspection.
148 bool ReadWriteAssignValues(PartInspection* part_insp, bool rd);
149 // Reads all pre calibration values of all sets for the passed project.
150 bool ReadWriteAssignValues(PartProject* part_proj, bool rd);
151 // Returns dirty if the config has changed.
152 bool IsDirty() const;
153 // Resets or sets the dirty flag.
154 void SetDirty(bool dirty = false);
155
156 // Copy the current calibrated settings for those which are specified in
157 // the ID's list. When the list is NULL all calib parameters are set.
158 bool AssignType(ECalibrationType cal_type, const std::string& set_name, const InformationIds* ids = nullptr);
159 // Export all variables of the passed set and revoke all other sets.
160 // When the set does not exist all current exports are revoked.
161 void SetExports(const std::string& set_name) const;
162 void SetExports(int index = -1) const;
163 // When the set does exist assignments of the set are revoked.
164 void ClearType(ECalibrationType cal_type, const std::string& set_name, InformationIds* ids = nullptr);
165 void ClearType(ECalibrationType cal_type, int index = -1, const InformationIds* ids = nullptr);
166 // Returns true when the calibration set is completely assign.
167 bool AssignComplete(const std::string& set_name) const;
168 // Returns true when the calibration set of the passed index is completely assign.
169 // When -1 is passed it checks all sets for assign completion.
170 bool AssignComplete(int index = -1) const;
171
172 protected:
173 // Sets the amount of entries.
174 void Resize(int sz);
175 // Event handler for the global calibration variables.
176 void variableEventHandler(EEvent event, const Variable& caller, Variable& link, bool same_inst) override;
177
178 // Returns the complete name string.
179 std::string GetNamePrefix(ECalibrationType cal_type);
180
181 private:
185 std::string FNamePrefix;
187 id_type FIdOffset;
189 id_type FIdRange;
191 bool FDirty;
192
193 friend CalibrationSet;
194 friend CalibrationVariablesPropertyPage;
195};
196
197inline int TCalibrationSets::Size() const
198{
199 return FSets.count();
200}
201
202inline const CalibrationSet* TCalibrationSets::operator[](int index) const
203{
204 if (index >= FSets.count())
205 return nullptr;
206 return FSets[index];
207}
208
210{
211 if (index >= FSets.count())
212 return nullptr;
213 return FSets[index];
214}
215
216inline const CalibrationSet* TCalibrationSets::Get(const std::string& name) const
217{
218 auto index = IndexOf(name);
219 if (index < 0)
220 return nullptr;
221 return FSets.get(index);
222}
223
224inline CalibrationSet* TCalibrationSets::Get(const std::string& name)
225{
226 return FSets[IndexOf(name)];
227}
228
229inline bool TCalibrationSets::IsDirty() const
230{
231 return FDirty;
232}
233
234inline void TCalibrationSets::SetDirty(bool dirty)
235{
236 FDirty = dirty;
237}
238
239inline void TCalibrationSets::SetExports(const std::string& set_name) const
240{
241 SetExports(IndexOf(set_name));
242}
243
244inline void TCalibrationSets::ClearType(ECalibrationType cal_type, const std::string& set_name, InformationIds* ids)
245{
246 int index = IndexOf(set_name);
247 if (index >= 0)
248 ClearType(cal_type, index, ids);
249}
250
251inline bool TCalibrationSets::AssignComplete(const std::string& set_name) const
252{
253 int index = IndexOf(set_name);
254 if (index >= 0)
255 return AssignComplete();
256 return false;
257}
258
259}// namespace sf
Holds a single calibration set of parameters.
Definition CalibrationSets.h:30
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:105
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 PartInspection.h:11
Definition PartProject.h:10
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Definition CalibrationSets.h:116
void ClearType(ECalibrationType cal_type, const std::string &set_name, InformationIds *ids=nullptr)
Definition CalibrationSets.h:244
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:234
const CalibrationSet * operator[](int index) const
Definition CalibrationSets.h:202
int Size() const
Definition CalibrationSets.h:197
bool IsDirty() const
Definition CalibrationSets.h:229
bool AssignComplete(int index=-1) const
void SetExports(int index=-1) const
void ReadWriteConfig(IniProfile *inifile, bool rd)
CalibrationSet * Get(int index)
Definition CalibrationSets.h:137
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:251
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.
void GetNames(string_list &names) const
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:239
const CalibrationSet * Get(int index) const
Definition CalibrationSets.h:132
bool ReadWriteAssignValues(PartInspection *part_insp, bool rd)
std::string GetNamePrefix(ECalibrationType cal_type)
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:123
constexpr int ctCAL_LASTENTRY(ctCAL_POST+1)
Used as size and as last value to iterate towards.
ECalibrationValueState
State of the calibration value.
Definition CalibrationSets.h:17
@ cvsINITIALIZED
Has been calibrated.
Definition CalibrationSets.h:21
@ cvsASSIGNED
Definition CalibrationSets.h:23
@ cvsEMPTY
Has no value assigned by initialization or calibration.
Definition CalibrationSets.h:19
TStrings< std::string > string_list
Vector of std::strings with additional functionality.
Definition TStrings.h:97
ECalibrationType
Type to identify a scan area type.
Definition ipj/iface/Namespace.h:187
@ ctCAL_NONE
Normal no calibration selected.
Definition ipj/iface/Namespace.h:189