Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ScanMethod.h
Go to the documentation of this file.
1#pragma once
5#include <gii/gen/Variable.h>
10#include <math/Types.h>
11#include <misc/qt/ConfigStore.h>
12
13namespace sf
14{
15
16// Forward definitions.
17class ProjectData;
18class CalibrationSet;
19class ClusterList;
20
22{
23 public:
28 {
29 Parameters(ProjectData* prj_data, const QString& method, const QString& area)
30 : _projectData(prj_data)
31 , _methodName(method)
32 , _areaName(area)
33 {}
34
38 QString _methodName;
40 QString _areaName;
41 };
42
46 explicit ScanMethod(const Parameters&);
47
51 ~ScanMethod() override;
52
57 {
59 dpiINDEXCOUNT = 0,
61 dpiINDEXDENS = 1,
63 dpiSCANDENS = 2,
65 dpiSCANLEN = 3,
67 dpiDENSMODE = 4,
69 dpiANGLE_A = 5,
71 dpiANGLE_B = 6,
73 dpiSURFACEANGLE_A = 7,
75 dpiSURFACEANGLE_B = 8,
77 dpiGATEMODE = 10,
79 dpiDEPTH = 23,
81 dpiDEPTHFACTOR = 24,
83 dpiLAST = 0x100,
84 };
85
90 void SetAreaName(const QString& name);
91
95 QString GetAreaName() const;
96
104
108 virtual void DestroyViewer();
109
114 virtual std::ostream& cout();
115
139
145 bool Execute(ECommand cmd);
146
152
158
164 void SetIndexFracRange(double start, double stop);
165
169 int GetIndexCount() const;
170
174 int GetIndexStart() const;
175
179 int GetIndexStop() const;
180
184 int GetScanListIndex() const;
185
192
198
204
209 void LoadSystemSettings(const QString& settings = {});
210
216 bool SaveSystemSettings(const QString& settings);
217
222 bool IsActivated() const;
223
228 bool DoSustain(const timespec&);
229
235
244 bool DoConvertPosition(gmi::AxesCoord& dest, const gmi::AxesCoord& src, bool to_focus) const;
245
255 bool DoGetIndexPos(gmi::AxesCoord& pos, int index, double frac, bool perp) const;
256
265 bool DoGetFocusPos(gmi::AxesCoord& dest, int index, double frac) const;
266
273 bool DoGetIndexVel(gmi::AxesCoord& dest, int index) const;
274
284 bool DoGetMeasureOffset(Vector3D& vector, int index, double frac, bool perp) const;
285
292 bool DoSetAcqParams(int index, double frac);
293
301
308
315
322
329
336
342
347 const Vector3D& GetScanOffset() const;
348
353 Vector3D GetOffset() const;
354
359
364
372 bool GetRefractionAngle(double& dest, double src, bool to_medium = true);
373
377 TDataFilterLinks& GetFilterLinks();
378
384 bool ExecuteFilters(TDataFilterEntry::EAction action = TDataFilterEntry::feaSTART);
385
389 const std::vector<int>& GetUsedDevices() const;
390
396
402 void SetAcqState(InformationServer::EState sel_state, InformationServer::EState unsel_state = InformationServer::issOff);
403
408 {
410 smsCFGERR = -2,
412 smsERROR = -1,
414 smsNOINIT = 0,
426 smsLASTENTRY
427 };
428
433
441 virtual void HandleCursorEvent(bool btn_down, Qt::KeyboardModifiers shift, int index, double frac) {}
442
446 static const char* GetStateName(EState);
447
451 static const char* GetCommandName(ECommand);
452
457
461 const std::string& GetMethodName() const;
462
466 QString GetDirectiveText() const;
467
472
478
482 QString GetElementName();
483
487 QString GetToolName();
488
493
497 QString GetSettingsName() const;
498
502 std::string GetNamePrefix() const;
503
508
512 QString GetCalibrationSetName() const;
513
517 InformationTypes::IdVector& GetCalibrationIds();
518
522 std::string GetFilterConfigs();
523 //
527 Variable::PtrVector& GetLocalVars();
528
532 QWidget* getViewer();
533
534 protected:
541
545 const IdInfo* getInfo(const std::string& name) const override;
546
550 bool getSetValue(const IdInfo* info, Value* value, Value::vector_type* params, bool flag_set) override;
551
557 virtual bool createViewer();
558
566 virtual bool ConvertPosition(gmi::AxesCoord& dest, const gmi::AxesCoord& src, bool to_focus) const = 0;
567
574
581 virtual void StateChange(EState prev, EState cur) = 0;
582
588 virtual bool Initialize() = 0;
589
594 virtual void Read(IniProfile* inifile) = 0;
595
600 virtual void Write(IniProfile* inifile) = 0;
601
606 virtual bool GetGenericInfoList(StringList&) = 0;
607
613 virtual bool Sustain(const timespec& ts);
614
621 virtual bool HandleCommand(ECommand cmd) = 0;
622
632 virtual bool GetIndexPos(gmi::AxesCoord& pos, int index, double frac, bool perp) = 0;
633
642 virtual bool GetFocusPos(gmi::AxesCoord& dest, int index, double frac) = 0;
643
651 virtual bool GetIndexVel(gmi::AxesCoord& dest, int index) = 0;
652
659 virtual bool GetTriggerValue(gmi::AxisValue& value) = 0;
660
667
675 virtual bool SetAcqParams(int index, double frac) = 0;
676
684
695 virtual bool GetMeasureOffset(Vector3D& vector, int index, double frac, bool perp);
696
702 bool FilterHandler(TDataFilterLink*, EFilterNotifyCode fnc);
703
708
714 bool SetState(EState state);
715
719 void setViewer(QWidget* viewer);
720
725
732 bool ClipTriggerValue(gmi::AxisValue& trigger_value);
733
738 void SetIndexCount(int idx_count);
739
744
745 private:
749 void localVarEvent(Variable::EEvent event, const Variable& caller, Variable& link, bool same_inst);
750
757 bool LoadVariableSettingsHandler(long vid, Value& value);
758
762 void HandleParamMappingApply(QObject*);
763
769 void ReadWriteConfig(bool rd);
770
775 void SetStatePriv(EState state);
776
778 ConfigStore _configStore;
780 gmi::AxesCoord _scanStart;
782 gmi::AxesCoord _scanStop;
784 Vector3D _scanOffset;
786 const EState _state;
788 ECommand _command;
790 ProjectData* _projectData;
792 QWidget* _viewer;
794 std::string _methodName;
796 std::string _namePrefix;
798 int _scanIndexCount;
800 bool _scanActive;
802 bool _sustainSentry;
804 QString _element;
806 QString _tool;
808 QString _settings;
810 QString _directiveText;
812 bool _directiveEnabled;
814 ESystemPosition _directivePosition;
816 TDataFilterLinks _filterLinks;
818 std::string _filterConfigs;
820 ClusterList* _clusterList;
822 ResultData rPositions;
824 LocalVariable vPart;
826 LocalVariable vToolName;
828 LocalVariable vToolSerial;
830 LocalVariable vElementName;
832 LocalVariable vElementSerial;
834 LocalVariable vMaterialName;
836 LocalVariable vMaterialVelocity;
838 LocalVariable vVelocityMode;
840 LocalVariable vSettings;
842 LocalVariable vArea;
844 LocalVariable vMethod;
846 LocalVariable vCalibType;
848 LocalVariable vCalibSet;
850 LocalVariable vState;
852 LocalVariable vIndexCount;
854 LocalVariable vFracStart;
856 LocalVariable vFracStop;
858 LocalVariable vScanIndex;
860 Variable::PtrVector _localVars;
862 InformationTypes::IdVector _calibrationIds;
864 const CalibrationSet* _calibSet;
866 TVector<int> _usedDevices;
867 // Instnace to link a variable handler to this class.
869
873 friend class ProjectAnalysisPropertyPage;
874 friend class ScanMethodCalibrationPropertyPage;
875 friend class ScanMethodAcquisitionPropertyPage;
876 friend class ScanDirectivePropertyPage;
877
878 // Declarations of static functions and data members to be able to create registered implementations.
880};
881
882inline const Vector3D& ScanMethod::GetScanOffset() const
883{
884 return _scanOffset;
885}
886
888{
889 return _localVars;
890}
891
892inline TDataFilterLinks& ScanMethod::GetFilterLinks()
893{
894 return _filterLinks;
895}
896
897inline const std::vector<int>& ScanMethod::GetUsedDevices() const
898{
899 return _usedDevices;
900}
901
903{
904 return _calibrationIds;
905}
906
908{
909 return _filterConfigs;
910}
911
912inline bool ScanMethod::GetMeasureOffset(Vector3D& vector, int index, double frac, bool perp)
913{
914 return false;
915}
916
917}// namespace sf
#define SF_DECL_IFACE(InterfaceType, ParamType, FuncName)
Declares a public static function in the class where it is used. Where: InterfaceType: Global typenam...
Definition TClassRegistration.h:71
Holds a single calibration set of parameters.
Definition CalibrationSets.h:30
Class to store application configuration. Uses the global application settings or a given ini-file.
Definition ConfigStore.h:17
EState
Enumerate for state of the info server.
Definition InformationServer.h:42
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
Create a local variable by calling the protected constructor.
Definition Variable.h:953
Definition ParamMappingPropertyPage.h:16
Keeps the project and all scan areas to inspect.
Definition ProjectData.h:25
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Dialog containing multiple property pages.
Definition qt/PropertySheetDialog.h:15
Class for creating and referencing global created data called result data. This class allows linking ...
Definition ResultData.h:20
Definition ScanMethodConfigurationPropertyPage.h:15
Definition ScanMethodPositionPropertyPage.h:15
Definition ScanMethod.h:22
bool ExecuteFilters(TDataFilterEntry::EAction action=TDataFilterEntry::feaSTART)
Execute the referenced filters.
const gmi::AxesCoord & GetScanVelocity() const
Gets the velocity for the scan method to move. Actually calls the scan binder method sf::ScanBinder::...
EState GetState() const
Gets the state of the instance.
QWidget * getViewer()
Called by a derived class to get its UI widget pointer.
bool getSetValue(const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override
Overridden from base class sf::ProjectScriptObject.
const Variable & GetMediumVelocity() const
Gets the medium sound velocity system variable.
QString GetSettingsName() const
Gets the settings name.
ECalibrationType GetCalibrationType()
Gets the calibration type name.
gmi::Controller * GetController()
Gets the allocated controller.
virtual bool GetTriggerValue(gmi::AxisValue &value)=0
Gets the axis used for triggering measurements or when the axis location is #sf::EAxisLocation::alNA ...
int GetIndexStop() const
Gets the clipped stop value of the set range.
gmi::EAxisLocation DoGetScanAxis() const
Gets the scan and index axis for position calculations. Calls the overridden GetScanAxis() method.
QString GetDirectiveText() const
Gets the directive text.
bool DoSustain(const timespec &)
Called by the inspection project to enable the derived class to do some background processing.
ConfigStore & GetSaveState()
Gets the config store for saving and restoring the state of a frame. It is probably in the projects i...
virtual bool GetFocusPos(gmi::AxesCoord &dest, int index, double frac)=0
Gets the focus position of specified index and scan fraction. Must be overridden in a derived class.
virtual bool SetAcqParams(int index, double frac)=0
Sets the project acquisition parameters/variables based on the passed index. Must be overridden by a ...
virtual bool ConvertPosition(gmi::AxesCoord &dest, const gmi::AxesCoord &src, bool to_focus) const =0
Converts a physical position to or from a focus position using the scan's configuration.
std::string GetFilterConfigs()
Gets the comma separated string of filter configuration names.
Definition ScanMethod.h:907
bool DoInitialize()
Initializes the class after the constructor is called. Final virtual functions are only valid after f...
TDataFilterLinks & GetFilterLinks()
Gets the analysis filter links.
Definition ScanMethod.h:892
virtual void StateChange(EState prev, EState cur)=0
Is called when the current state changes for a derived class to act up on. Must be overridden by a de...
const IdInfo * getInfo(const std::string &name) const override
Overridden from base class sf::ProjectScriptObject.
virtual void Read(IniProfile *inifile)=0
Reads the settings from the passed inifile.
bool IsActivated() const
Check if the scan method was activated.
~ScanMethod() override
Virtual destructor for derived classes.
QString GetMaterialName()
Gets the material name.
ECommand GetCommand()
Gets the last Issued command.
void DoAddPropertyPages(PropertySheetDialog *sheet)
Calls AddPropertyPages if the state allows it.
bool SetState(EState state)
Sets the state.
static const char * GetStateName(EState)
Gets the state name of the given state value.
virtual ScriptLink * GetScriptLink()
Gets the script link when one is associated. Can be overridden by a derived class.
EDefaultParamIndex
Default parameter ID indices for derived scan methods.
Definition ScanMethod.h:57
bool DoCreateFrame()
Creates a scan method UI frame if possible. Calls the overridden #CreateFrame() method.
bool GetRefractionAngle(double &dest, double src, bool to_medium=true)
Gets the refracted angle.
static const char * GetCommandName(ECommand)
Gets the command name of the given command value.
void DoWrite(IniEnvelope ini)
Writes the settings of the scan method. Calls eventually the overridden Write() method.
QString GetCalibrationSetName() const
Gets the calibration set name.
int GetIndexCount() const
Gets the amount of indices in the scan method.
EState
States of operation.
Definition ScanMethod.h:408
@ smsACTIVE
Definition ScanMethod.h:418
@ smsCHECKING
Definition ScanMethod.h:420
@ smsSCANNING
Definition ScanMethod.h:422
@ smsREADY
Definition ScanMethod.h:416
@ smsEVALUATING
Definition ScanMethod.h:424
bool DoGetIndexVel(gmi::AxesCoord &dest, int index) const
Gets the velocity calculated by the derived scan mode.
ProjectData * GetProjectData()
Gets the project this instance is part of.
bool DoGetTriggerValue(gmi::AxisValue &value) const
Gets the axis used for triggering measurements or when the axis location is #sf::EAxisLocation::alNA ...
int GetScanListIndex() const
Returns the scan list index of this instance in the project.
void SetAcqState(InformationServer::EState sel_state, InformationServer::EState unsel_state=InformationServer::issOff)
Sets the state on all acquisition devices.
void SetAreaName(const QString &name)
Changes the area name so it is saved by the project under this new name.
virtual bool GetIndexVel(gmi::AxesCoord &dest, int index)=0
Gets the velocity calculated by the derived scan mode. Must be overridden in a derived class.
bool DoConvertPosition(gmi::AxesCoord &dest, const gmi::AxesCoord &src, bool to_focus) const
Converts a physical position to or from a focus position using the scan's configuration....
virtual bool createViewer()
Creates a scan method UI frame if possible. Can be overridden by a derived class.
virtual bool GetGenericInfoList(StringList &)=0
Gets the list of linked variables or results. Must be overridden in a derived class.
void SetIndexCount(int idx_count)
A derived classes uses this function to set the index count for the scan method initialization.
const std::vector< int > & GetUsedDevices() const
Gets the acquisition devices used.
Definition ScanMethod.h:897
void SetIndexFracRange(double start, double stop)
Sets the new scan range for defined surface.
bool DoGetIndexPos(gmi::AxesCoord &pos, int index, double frac, bool perp) const
Gets the axes position calculated by the derived scan mode. Actually calls the overridden GetIndexPos...
QString GetToolName()
Gets the tool name.
const ScanBinder::InfoBase * GetScanInfo() const
Gets the binder information of this scan method instance. Actually calls #sf::ScanBinder::GetScanInfo...
const Variable & GetMaterialVelocity() const
Gets the material sound velocity system variable.
bool DoGetFocusPos(gmi::AxesCoord &dest, int index, double frac) const
Gets the focus position calculated by the derived scan mode. Actually calls the overridden GetFocusPo...
bool SaveSystemSettings(const QString &settings)
Saves the system setting associated with the scan method.
bool GetScanStart(gmi::AxesCoord &ac) const
Gets the position coordinate where the project passes control to the scan method.
void setViewer(QWidget *viewer)
Called by a derived class to set its frame pointer.
virtual void HandleCursorEvent(bool btn_down, Qt::KeyboardModifiers shift, int index, double frac)
Can be overridden to handle cursor events when the scan is selected in the project.
Definition ScanMethod.h:441
const gmi::AxesCoord & GetScanAcceleration() const
Gets the acceleration for the scan method to move. Actually calls the scan binder method sf::ScanBind...
bool Execute(ECommand cmd)
Calls HandleCommand() after several checks.
int GetIndexStart() const
Gets the clipped start value of the set range.
virtual std::ostream & cout()
Gets a output stream to print error or no error information to std::cout. Which can be overridden to ...
QString GetElementName()
Gets the element name.
bool IsCalibReady()
Checks if the calibration is complete.
virtual bool HandleCommand(ECommand cmd)=0
Handles the command given by Execute(). Must be overridden in a derived class.
void DoRead(IniEnvelope ini)
Reads the settings of the scan method. Calls eventually the overridden Read() method.
bool UpdatePositionsData()
Refills the positions result.
ECommand
Available commands.
Definition ScanMethod.h:120
@ smcOFFSETCHANGE
Handle the binder offset has changed.
Definition ScanMethod.h:137
@ smcEVALUATE
Start scan evaluation by setting running mode.
Definition ScanMethod.h:133
@ smcINIT
Initialize the scan method instance after properties have been set.
Definition ScanMethod.h:123
@ smcDEACTIVATE
Deactivate scan method.
Definition ScanMethod.h:127
@ smcSCAN
Start scan recording.
Definition ScanMethod.h:131
@ smcCHECK
Start checking by setting running mode.
Definition ScanMethod.h:129
@ smcACTIVATE
Activate scan method.
Definition ScanMethod.h:125
@ smcSTOP
Stop scan recording.
Definition ScanMethod.h:135
virtual bool GetIndexPos(gmi::AxesCoord &pos, int index, double frac, bool perp)=0
Gets the axes position of specified index and scan fraction. Must be overridden in a derived class.
virtual void Write(IniProfile *inifile)=0
Writes the settings to the passed inifile.
bool DoGetMeasureOffset(Vector3D &vector, int index, double frac, bool perp) const
Gets the vector caused by changing measurement offsets. This means the offset caused by the A-scan de...
Variable::PtrVector & GetLocalVars()
Gets the local variables in a pointer vector.
Definition ScanMethod.h:887
bool FilterHandler(TDataFilterLink *, EFilterNotifyCode fnc)
Event handler for filter events which are passed to the scan method script.
QString GetAreaName() const
Gets the area name of the scan entry.
virtual bool Initialize()=0
Initializes the scan method. Must be overridden by a derived class.
bool DoSetAcqParams(int index, double frac)
Calls the overridden SetAcqParams() method on the derived class.
InformationTypes::id_type GetIdOffset()
Gets Offset used to create the local ID's with for exporting.
bool ClipTriggerValue(gmi::AxisValue &trigger_value)
Clips a trigger value to a value which is allowed by the controller. Is to be used by property pages ...
virtual bool GetMeasureOffset(Vector3D &vector, int index, double frac, bool perp)
Gets the vector caused by changing measurement offsets. This means the offset caused by the A-scan de...
Definition ScanMethod.h:912
virtual gmi::EAxisLocation GetScanAxis()=0
Gets the scan and index axis for position calculations. Must be overridden by a derived class.
virtual void DestroyViewer()
Called before a scan method is deleted.
bool GetScanStop(gmi::AxesCoord &ac) const
Gets the position where the scan method passes control to the project.
virtual bool Sustain(const timespec &ts)
Can be overridden to do background processing.
ScanMethod(const Parameters &)
Constructor for passing general structure for derived classes create by the class factory.
const std::string & GetMethodName() const
Gets this methods name.
const Vector3D & GetScanOffset() const
Gets the offset of the part to its programmed position.
Definition ScanMethod.h:882
void LoadSystemSettings(const QString &settings={})
Loads the system setting associated with the scan method overriding the settings from the selected ca...
Vector3D GetOffset() const
Gets the total offsets added.
bool GetDirectiveEnabled() const
Gets the flag weather the directive is enabled.
InformationTypes::IdVector & GetCalibrationIds()
Gets the calibration ids.
Definition ScanMethod.h:902
std::string GetNamePrefix() const
Gets the name prefix.
ESystemPosition GetDirectivePosition()
??
bool Reinitialize()
When the state is ready the scan method can be reinitialize. After changes are made to the settings f...
virtual void AddPropertyPages(PropertySheetDialog *sheet)
Adds scan method specific property pages to the passed sheet. Can be overridden by a derived class.
Template for linking pointers of member function to Variable instances.
Definition VariableHandler.h:38
Value container class able to performing arithmetic functions.
Definition Value.h:19
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
All axis values in one structure accompanied by some handy manipulation methods.
Definition AxesCoord.h:13
Single position, speed or acceleration value of a specific axis.
Definition GmiTypes.h:174
Pure virtual class for implementation of motion controllers.
Definition Controller.h:13
#define _IPJ_CLASS
Definition ipj/iface/global.h:35
EAxisLocation
Enumeration of axis locations.
Definition GmiTypes.h:81
Definition Application.h:10
ESystemPosition
Fixed system dependent axis positions.
Definition ipj/iface/Namespace.h:239
ECalibrationType
Type to identify a scan area type.
Definition ipj/iface/Namespace.h:187
Structure used a base class for derived binder classes to store scan dependant information.
Definition ScanBinder.h:36
Mandatory structure for initialization of derived class.
Definition ScanMethod.h:28
QString _areaName
Area name for scanning.
Definition ScanMethod.h:40
QString _methodName
Mode for scanning.
Definition ScanMethod.h:38
ProjectData * _projectData
Holds the project data structure.
Definition ScanMethod.h:36
Parameters(ProjectData *prj_data, const QString &method, const QString &area)
Definition ScanMethod.h:29
Used to create static lookup lists.
Definition ScriptObject.h:62