Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ProjectData.h
Go to the documentation of this file.
1#pragma once
6#include <ipj/iface/global.h>
9#include <misc/gen/Sustain.h>
10
11namespace sf
12{
13
14// Forward declarations.
15class ProjectWidget;
16class DataFilterList;
17class CustomFields;
18class ScanEntry;
19
25{
26 public:
31
35 ~ProjectData() override;
36
40 void debug();
41
46
51
57 bool read(std::istream& is);
58
64 bool write(std::ostream& os);
65
70
74 QString getStateName();
75
80
176
181
187 bool start(unsigned index);
188
195 bool evaluate(unsigned index, int file_index = -1);
196
203
209 bool moveToQuery(int scan);
210
219 bool moveTo(int scan, int index, double frac = 0.0, bool perp = false);
220
228 bool activate(unsigned index);
229
234 bool suspend();
235
239 bool stop();
240
244 bool abort();
245
250 bool rotate(int scan_entry);
251
257
265 bool finalize(int lock = 0);
266
271 bool isFinalized() const;
272
278
283 bool canStart(int scan_entry);
284
289 bool canStop();
290
295 bool canAbort();
296
302
307 bool canRotate(int scan_entry);
308
313 bool canEvaluate(int scan_entry);
314
320 bool canFinalize(int lock = 0);
321
326 bool canMoveTo();
327
331 void clear();
332
338 IniEnvelope getScanIni(const QString& scan_area);
339
344
350 bool isScanArea(const QString& name);
351
356 void removeScan(unsigned index);
357
363 void moveScan(unsigned src, unsigned dest);
364
370 void swapScan(unsigned idx1, unsigned idx2);
371
376 int indexOf(ScanEntry*) const;
377
383 int getScanListIndex(const ScanMethod* sm) const;
384
390 bool disableProject(bool disable);
391
397 bool storeFilterList(bool rd);
398
403
409
415
421
427
431 void setSelectedScanIndex(int index);
432
438
444
449
454 void setScanBinderName(const QString& name);
455
460
466
472
476 std::string getNamePrefix();
477
481 QString getErrorText();
482
486 DataFilterList* getFilterList();
487
491 QString getMediumName();
492
498
503
508
513 void setReportTemplate(const QString& templ);
514
520
527 void setPartProject(const PartProject* part_project);
528
533
537 void setPartInspection(const PartInspection* part_inspection);
538
543
548 void setWidget(ProjectWidget* project_widget);
549
555
559 QWidget* getViewerParent();
560
566 ScanEntry* getScan(ssize_t index);
567
571 ssize_t getScanCount();
572
577
581 QString getStateName(int state);
582
586 QString getPart() const;
587
594 void setDirty(bool tf = true);
595
600 bool isDirty() const;
601
606
612 std::string getScanMethodName(ssize_t index);
613
618
619 protected:
624
630 bool sustain(const timespec& ts);
631
637 bool process(const timespec& ts);
638
645 bool setError(const QString& error_text);
646
652 bool setState(EState state);
653
658 void attach(ScanEntry* entry);
659
664 void detach(ScanEntry* entry);
665
672 bool storeProfile(IniProfile& ini_profile, bool rd);
673
678 void storeConfig(bool rd);
679
685
689 const IdInfo* getInfo(const std::string& name) const override;
690
694 bool getSetValue(const IdInfo* info, Value* value, Value::vector_type* params, bool flag_set) override;
695
701
706 bool isDataSavingReady() const;
707
708 private:
710 void variableEvent(Variable::EEvent, const Variable&, Variable&, bool);
711
713 void handleInspectionChange(const void*);
714
716 void handlePropertyPageApply(const void* sender);
717
719 enum : int
720 {
721 weDISABLED = 0,
722 weENABLED,
723 weEVENT
724 };
725
730 void setExports(bool var_export);
731
739 void sendCursorEvent(bool btn_dn, Qt::KeyboardModifiers shift, int index, double frac);
740
746 bool getGenericInfoList(StringList& strings);
747
751 void updateScanStateChanges();
752
754 class InformationVariables;
756 InformationVariables* _vars;
758 ProjectWidget* _projectWidget;
760 TVector<ScanEntry*> _scanList;
762 PartProject* _partProject;
764 bool _dirtyFlag;
766 int _activeScanIndex;
768 int _previousScanIndex;
770 int _quitScanIndex;
772 int _dataFileIndex;
774 ScanMethod* _activeScanMethod;
776 EState _state;
778 EState _prevState;
780 EState _resumeState;
782 ElapseTimer _initTimer;
783 //
784 ElapseTimer _changeTimer;
786 QString _errorText;
788 bool _shouldStop;
790 EState _evalPreState;
792 ScanBinder* _scanBinder;
794 ConfigStore _configStore;
796 std::string _namePrefix;
798 std::string _namePrefixCalibPre;
800 std::string _namePrefixCalibPost;
802 Variable::PtrVector _localVars;
804 PartInspection* _partInspection;
806 int _finalized;
808 TCalibrationSets* _calibSets;
810 ReportOptions _reportOptions;
812 QString _reportTemplate;
814 TVariableHandler<ProjectData> _variableHandler;
815
816 friend class ScanEntry;
818};
819
820}// namespace sf
Class to store application configuration. Uses the global application settings or a given ini-file.
Definition ConfigStore.h:17
Timer for turning true when a certain amount of time has passed.
Definition ElapseTimer.h:12
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
Definition ProjectDataPropertyPage.h:15
Keeps the project and all scan areas to inspect.
Definition ProjectData.h:25
PartProject * getPartProject() const
Gets the part-project pointer of the current project.
void addPropertyPages(PropertySheetDialog *sheet)
Adds the project property pages to the given property sheet.
InformationTypes::id_type getScanMethodIdOffset()
Gets the scan method id-offset for derived scan methods. Scan methods use the id-offset to determine ...
bool canFinalize(int lock=0)
Checks if it is possible to 'finalize' at the current time. When the lock argument is non-zero,...
void detach(ScanEntry *entry)
Called from the ScanEntry instance to detach itself to this project.
ScanEntry * getSelectedScan()
Gets the selected scan entry pointer.
bool setError(const QString &error_text)
Sets the error state and the SetState function to set the psERROR state. Called from process() to all...
bool isValidPart()
Check if the part this project data is referring to is valid.
void clear()
Clears the all scan entries of the current project.
bool initializeScans()
Initializes all scan methods.
IniEnvelope getScanIni(const QString &scan_area)
Gets an ini file descendant with information about the scan area configuration.
QString getReportTemplate()
Gets the report template file.
void setScanBinderName(const QString &name)
Sets scan-binder name and so change the implementation.
bool canEvaluate(int scan_entry)
Checks if it is possible to 'Evaluate' at the current time.
int getActiveScanIndex()
Gets the active scan entry index.
int getScanListIndex(const ScanMethod *sm) const
Gets scan method entry index in the scan list.
ProjectWidget * getWidget()
Gets the project's frame.
DataFilterList * getFilterList()
Gets the selected or used filter list. (same as global for now)
bool disableProject(bool disable)
Disables or enables a project when other is running.
bool canAbort()
Checks if it is possible to 'Abort' at the current time.
void moveScan(unsigned src, unsigned dest)
Moves the scan area in the list from the given source to a destination index.
ssize_t getScanMethodCount()
Gets the number of available scan methods.
double getScanProgress()
Gets the progress of the current active scan.
bool canRotate(int scan_entry)
Checks if it is possible to 'Rotate' at the current time.
int indexOf(ScanEntry *) const
Gets the index in the scan entry in the list.
bool isDataSavingReady() const
Checks is saving data is completed.
ProjectData()
Default constructor.
bool process(const timespec &ts)
Called from sustain.
void setDirty(bool tf=true)
Set or resets the dirty flag. Calls attached method of the onDirty closure. When dirty,...
const ConfigStore & getConfigStore() const
Gets a fresh copy of the config store.
bool start(unsigned index)
Start scanning at the specified index in the list of scans.
bool rotate(int scan_entry)
Starts rotating the scan axis if possible.
~ProjectData() override
Virtual overridden destructor.
bool moveToSysPos(ESystemPosition sp)
Makes the manipulator move to a predefined system position.
int getSelectedScanIndex()
Gets the selected scan entry index.
QString getErrorText()
Gets the last error text set.
void SetReportOptions(ReportOptions options)
Sets the report options of the project.
void swapScan(unsigned idx1, unsigned idx2)
Swaps to scan entries in the list between the 3 given indices.
const TCalibrationSets & getCalibrationSets()
Gets the calibration sets.
bool storeFilterList(bool rd)
Read or writes the filter list file.
bool finalize(int lock=0)
Finalizes the project so it is locked for changes. When the argument lock is non-zero,...
bool abort()
Aborts the current active scan method immediately.
QString getStateName()
Gets the name of the current state the project is in.
bool shouldWaitForEvent()
Allows state machines to wait for a user event.
void setWidget(ProjectWidget *project_widget)
Sets the frame.
void debug()
Just for development and debugging.
bool stop()
Signals a stop to the current active scan method.
const IdInfo * getInfo(const std::string &name) const override
Overridden from base class ProjectScriptObject.
ssize_t getScanCount()
Gets the number of scans in the current scan plan list.
bool moveTo(int scan, int index, double frac=0.0, bool perp=false)
Moves controller to the location on the surface of a scan area.
bool isScanArea(const QString &name)
Gets if the given scan area name exists.
void addModulePropertyPages(PropertySheetDialog *sheet)
Add the module property pages from this project to the given property sheet.
void attach(ScanEntry *entry)
Called from the ScanEntry instance to attach itself to this project.
void setPartInspection(const PartInspection *part_inspection)
Sets the part-inspection of this project.
void setPartProject(const PartProject *part_project)
Assigment clears the scan list and sets the part name. This must be done before this instance can be ...
bool read(std::istream &is)
Reads the project from the stream.
ScanEntry * getActiveScan()
Gets the active scan.
bool isDirty() const
Get the dirty flag.
bool getSetValue(const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override
Overridden from base class ProjectScriptObject.
bool activate(unsigned index)
Activates the scan method. This makes the mode export its variables. Only one scan method is activate...
ReportOptions getReportOptions()
Gets the report options of the project.
EState getState()
Gets the current state of the project data state machine.
bool storeProfile(IniProfile &ini_profile, bool rd)
Reads or writes all project data to or from the given ini-profile instance.
void setSelectedScanIndex(int index)
Sets the selected scan entry index enter -1 for none.
bool setState(EState state)
Sets the new state.
bool isFinalized() const
Checks if the project is finalized.
bool evaluate(unsigned index, int file_index=-1)
Starts evaluating.
bool sustain(const timespec &ts)
Handler set using the _sustainEntry.
bool write(std::ostream &os)
Writes the project information to the output stream.
QString getStateName(int state)
Gets the state-machine's name of the given state.
QString getScanBinderName()
Gets current scan-binder name.
bool canStop()
Checks if it is possible to 'Stop' at the current time.
InformationTypes::id_type getScanBinderIdOffset()
Gets the scan method ID offset for the derived scan binder. The scan binder uses the id-offset to det...
ConfigStore getPartStateIni()
Gets an ini file descendant with screen position information.
TSustain< ProjectData > _sustainEntry
Hooks the sustain function into the sustain interface.
Definition ProjectData.h:623
void removeScan(unsigned index)
Removes the scan at the given index.
bool canSuspend()
Checks if it is possible to 'Suspend' at the current time.
bool isRotating()
Checks iof the rotating axis is rotating currently.
QWidget * getViewerParent()
Gets the parent for the scan method viewers.
EState
Project states in the machine.
Definition ProjectData.h:85
@ psFINISHED
Definition ProjectData.h:149
@ psACCOMMODATING
Project is moving to the programmed system position.
Definition ProjectData.h:170
@ psSTOPPING
Project is stopping prematurely.
Definition ProjectData.h:157
@ psSUSPENDED
Project is suspended.
Definition ProjectData.h:154
@ psRETREATED
Definition ProjectData.h:145
@ psTOOLCHANGING
Project is moving to the tool change tool position.
Definition ProjectData.h:114
@ psFINISHING
Project is finishing on the scan area.
Definition ProjectData.h:148
@ psRESETTING
Resetting the manipulator and scan binder.
Definition ProjectData.h:165
@ psSUSPENDING
Project is waiting for scan to go into suspend state.
Definition ProjectData.h:152
@ psAPPROACHED
Definition ProjectData.h:119
@ psCHECKING
Scan method is in check positions mode.
Definition ProjectData.h:122
@ psACCOMMODATED
Project arrived at the programmed system position.
Definition ProjectData.h:172
@ psSCANNING
Scan method is scanning.
Definition ProjectData.h:126
@ psEVALUATED
Definition ProjectData.h:136
@ psINITIALIZED
Initializing scan methods succeeded.
Definition ProjectData.h:101
@ psERROR
Definition ProjectData.h:92
@ psEVALUATING
Definition ProjectData.h:135
@ psSTOPPED
Definition ProjectData.h:158
@ psINITIALIZING
Initializing scan methods.
Definition ProjectData.h:99
@ psMOVING
Project is doing a system move.
Definition ProjectData.h:161
@ psINITFAILED
Project failed to initialize.
Definition ProjectData.h:103
@ psPREPARING
Prepare a project for the next scan area.
Definition ProjectData.h:109
@ psMOVED
Definition ProjectData.h:162
@ psREADY
Project is ready for action.
Definition ProjectData.h:106
@ psREPORTED
finished reporting.
Definition ProjectData.h:141
@ psPREPARED
Project is prepared for the next scan area.
Definition ProjectData.h:111
@ psDATASAVING
Scan data is being saved.
Definition ProjectData.h:130
@ psCHECKED
Definition ProjectData.h:123
@ psUNINITIALIZED
Start of the state at project creation.
Definition ProjectData.h:97
@ psDISABLED
When another project is running.
Definition ProjectData.h:94
@ psSCANNED
Definition ProjectData.h:127
@ psREPORTING
Scan method is reporting.
Definition ProjectData.h:139
@ psTOOLCHANGED
Definition ProjectData.h:115
@ psRESUMING
Project is trying to resume from a stop.
Definition ProjectData.h:167
@ psAPPROACHING
Binder is approaching to scan the start position.
Definition ProjectData.h:118
@ psRETREATING
Binder is retreating from the stop position.
Definition ProjectData.h:144
bool canStart(int scan_entry)
Checks if it is possible to 'Start' at the current time.
void setReportTemplate(const QString &templ)
Sets the report template file.
bool canInitialize()
Checks if it is possible to 'Initialize' at the current time.
bool canMoveTo()
Checks if the MoveTo function can be executed successfully.
bool initialize()
Initializes or reinitializes the project binder and all its scans.
bool moveToQuery(int scan)
Queries for a surface position by the user.
ScanEntry * addScan()
Gets a pointer to a newly created scan entry instance.
bool suspend()
Tries to signal the current scan to hold.
ScanBinder * getScanBinder()
Gets the Scan binder derived instance pointer of the implementation.
std::string getScanMethodName(ssize_t index)
Gets the name of the scan method at the given index.
std::string getNamePrefix()
Gets the name prefix of the exported parameters.
TClosure< void, void * > onDirty
Closure method to notify changes on the dirty flag. The attached handler is called when a scan of the...
Definition ProjectData.h:519
ScanEntry * getScan(ssize_t index)
Gets the scan entry pointer of the given index.
bool startDataSaving()
Initiates the start of storing data.
void storeConfig(bool rd)
Reads or writes the module configuration information.
PartInspection * getPartInspection() const
Gets the part-inspection of this project.
QString getMediumName()
Gets the medium name of the project like 'water'.
QString getPart() const
Gets the part name of the loaded project.
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Manages all inspection project data.
Definition ProjectWidget.h:20
Dialog containing multiple property pages.
Definition qt/PropertySheetDialog.h:15
Abstract base class for implementing scan binders.
Definition ScanBinder.h:30
Definition ScanEntry.h:12
Definition ScanMethod.h:22
Definition CalibrationSets.h:116
Encapsulates the std::function() template.
Definition TClosure.h:14
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
Template for linking pointers of member function to Variable instances.
Definition VariableHandler.h:38
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:19
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
#define _IPJ_CLASS
Definition ipj/iface/global.h:35
Definition Application.h:10
ESystemPosition
Fixed system dependent axis positions.
Definition ipj/iface/Namespace.h:239
QFlags< EReportOption > ReportOptions
Reporting option flags.
Definition ipj/iface/Namespace.h:288
Used to create static lookup lists.
Definition ScriptObject.h:62