itom 2.0.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut für Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 *********************************************************************** */ 00027 00028 #ifndef ADDININTERFACE_H 00029 #define ADDININTERFACE_H 00030 00031 #include "commonGlobal.h" 00032 00033 #include "apiFunctionsInc.h" 00034 #include "apiFunctionsGraphInc.h" 00035 00036 #include "sharedStructuresQt.h" 00037 #include "sharedStructures.h" 00038 00039 #include <qlist.h> 00040 #include <qmap.h> 00041 #include <qpair.h> 00042 #include <qset.h> 00043 #include <qthread.h> 00044 #include <qsharedpointer.h> 00045 #include <qmutex.h> 00046 00047 #if QT_VERSION < 0x050000 00048 #include <qpluginloader.h> 00049 #include <qdockwidget.h> 00050 #else 00051 #include <QtCore/qpluginloader.h> 00052 #include <QtWidgets/qdockwidget.h> 00053 #endif 00054 00055 //plugins define VISUAL_LEAK_DETECTOR_CMAKE in their CMake configuration file 00056 #if defined _DEBUG && defined(_MSC_VER) && defined(VISUAL_LEAK_DETECTOR_CMAKE) 00057 #define NOMINMAX //instead min, max is defined as macro in winDef.h, included by vld.h 00058 #include "vld.h" 00059 #endif 00060 00061 #if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) //only moc this file in itomCommonQtLib but not in other libraries or executables linking against this itomCommonQtLib 00062 00063 //write this macro right after Q_INTERFACE(...) in your interface class definition 00064 #define PLUGIN_ITOM_API \ 00065 protected: \ 00066 void importItomApi(void** apiPtr) \ 00067 {ito::ITOM_API_FUNCS = apiPtr;} \ 00068 void importItomApiGraph(void** apiPtr) \ 00069 { ito::ITOM_API_FUNCS_GRAPH = apiPtr;} \ 00070 public: \ 00071 //. 00072 00074 00078 #define NEW_PLUGININSTANCE(PluginClass) \ 00079 PluginClass* newInst = new PluginClass(); \ 00080 newInst->setBasePlugin(this); \ 00081 *addInInst = qobject_cast<ito::AddInBase*>(newInst); \ 00082 m_InstList.append(*addInInst); 00083 00085 00090 #define REMOVE_PLUGININSTANCE(PluginClass) \ 00091 if (*addInInst) \ 00092 { \ 00093 delete qobject_cast<PluginClass*>(*addInInst); \ 00094 m_InstList.removeOne(*addInInst); \ 00095 } 00096 00098 00102 #define REGISTER_FILTERS_AND_WIDGETS \ 00103 foreach(ito::AddInAlgo::FilterDef *f, newInst->m_filterList) \ 00104 { \ 00105 f->m_pBasePlugin = this; \ 00106 } \ 00107 foreach(ito::AddInAlgo::AlgoWidgetDef *w, newInst->m_algoWidgetList) \ 00108 { \ 00109 w->m_pBasePlugin = this; \ 00110 } 00111 00112 00113 namespace ito 00114 { 00115 //---------------------------------------------------------------------------------------------------------------------------------- 00117 00121 enum tPluginType { 00122 typeDataIO = 0x1, 00123 typeActuator = 0x2, 00124 typeAlgo = 0x4, 00125 typeGrabber = 0x80, 00126 typeADDA = 0x100, 00127 typeRawIO = 0x200 00128 }; 00129 00131 00140 enum tActuatorStatus { 00141 //moving flags 00142 actuatorUnknown = 0x0001, 00143 actuatorInterrupted = 0x0002, 00144 actuatorMoving = 0x0004, 00145 actuatorAtTarget = 0x0008, 00146 actuatorTimeout = 0x0010, 00147 //switches 00148 actuatorEndSwitch = 0x0100, 00149 actuatorLeftEndSwitch = 0x0200, 00150 actuatorRightEndSwitch = 0x0400, 00151 actuatorRefSwitch = 0x0800, 00152 actuatorLeftRefSwitch = 0x1000, 00153 actuatorRightRefSwitch = 0x2000, 00154 //status flags 00155 actuatorAvailable = 0x4000, 00156 actuatorEnabled = 0x8000, 00158 actMovingMask = actuatorUnknown | actuatorInterrupted | actuatorMoving | actuatorAtTarget | actuatorTimeout, 00159 actEndSwitchMask = actuatorEndSwitch | actuatorLeftEndSwitch | actuatorRightEndSwitch, 00160 actRefSwitchMask = actuatorRefSwitch | actuatorLeftRefSwitch | actuatorRightRefSwitch, 00161 actSwitchesMask = actEndSwitchMask | actRefSwitchMask, 00162 actStatusMask = actuatorAvailable | actuatorEnabled 00163 }; 00164 00165 enum tAutoLoadPolicy { 00166 autoLoadAlways = 0x1, 00167 autoLoadNever = 0x2, 00168 autoLoadKeywordDefined = 0x4 00169 }; 00170 00171 enum tAutoSavePolicy { 00172 autoSaveAlways = 0x1, 00173 autoSaveNever = 0x2 00174 }; 00175 00176 struct ExecFuncParams{ 00177 ExecFuncParams() : infoString("") {} 00178 QVector<Param> paramsMand; 00179 QVector<Param> paramsOpt; 00180 QVector<Param> paramsOut; 00181 QString infoString; 00182 }; 00183 00184 struct FilterParams { 00185 QVector<Param> paramsMand; 00186 QVector<Param> paramsOpt; 00187 QVector<Param> paramsOut; 00188 }; 00189 00190 class AddInBase; 00191 class DataObject; 00192 00193 //---------------------------------------------------------------------------------------------------------------------------------- 00217 class ITOMCOMMONQT_EXPORT AddInInterfaceBase : public QObject 00218 { 00219 Q_OBJECT 00220 00221 private: 00223 virtual ito::RetVal closeThisInst(ito::AddInBase **addInInst) = 0; 00224 00225 protected: 00226 int m_type; 00227 int m_version; 00228 QString m_filename; 00229 int m_maxItomVer; 00230 int m_minItomVer; 00231 QString m_author; 00232 QString m_description; 00233 QString m_detaildescription; 00234 QString m_license; 00235 QString m_aboutThis; 00236 QList<ito::AddInBase *> m_InstList; 00237 QVector<ito::Param> m_initParamsMand; 00238 QVector<ito::Param> m_initParamsOpt; 00239 //bool m_enableAutoLoad; //* Varialbe to enable autoload for plugin. Standard value is false. Must be overwritten in AddInConstructor */ 00240 tAutoLoadPolicy m_autoLoadPolicy; 00241 tAutoSavePolicy m_autoSavePolicy; 00242 bool m_callInitInNewThread; 00243 QPluginLoader *m_loader; 00244 00245 virtual void importItomApi(void** apiPtr) = 0; //this methods are implemented in the plugin itsself. Therefore place ITOM_API right after Q_INTERFACE in the header file and replace Q_EXPORT_PLUGIN2 by Q_EXPORT_PLUGIN2_ITOM in the source file. 00246 virtual void importItomApiGraph(void** apiPtr) = 0; 00247 00248 public: 00249 void **m_apiFunctionsBasePtr; 00250 void **m_apiFunctionsGraphBasePtr; 00251 00252 virtual ~AddInInterfaceBase(); 00253 00255 AddInInterfaceBase() : 00256 m_type(0), m_version(CREATEVERSION(0,0,0)), m_filename(""), 00257 m_maxItomVer(MAXVERSION), m_minItomVer(MINVERSION), 00258 m_author(""), m_description(""), m_detaildescription(""), m_license("LGPL with ITO itom-exception"), m_aboutThis(""), 00259 /*m_enableAutoLoad(false),*/ m_autoLoadPolicy(ito::autoLoadNever), 00260 m_autoSavePolicy(ito::autoSaveNever), m_callInitInNewThread(true), m_apiFunctionsBasePtr(NULL), m_apiFunctionsGraphBasePtr(NULL), m_loader(NULL) 00261 { } 00262 00264 inline int getType(void) const { return m_type; } 00266 inline int getVersion(void) const { return m_version; } 00268 inline int getMinItomVer(void) const { return m_minItomVer; } 00270 inline int getMaxItomVer(void) const { return m_maxItomVer; } 00271 00273 inline bool getCallInitInNewThread(void) const { return m_callInitInNewThread; } 00274 00276 inline tAutoLoadPolicy getAutoLoadPolicy(void) const { return m_autoLoadPolicy; } 00277 00279 inline tAutoSavePolicy getAutoSavePolicy(void) const { return m_autoSavePolicy; } 00280 00282 const QString getAuthor(void) const { return m_author; } 00284 const QString getDescription(void) const { return m_description; } 00286 const QString getDetailDescription(void) const { return m_detaildescription; } 00288 const QString getLicenseInfo(void) const { return m_license; } 00290 const QString getAboutInfo(void) const { return m_aboutThis; } 00292 const QString getFilename(void) const { return m_filename; } 00293 00294 const ito::RetVal setFilename(const QString &name) { m_filename = name; return ito::retOk; } 00296 inline QList<ito::AddInBase *> getInstList(void) { return m_InstList; } 00297 inline const QList<ito::AddInBase *> getInstList(void) const { return m_InstList; } 00299 ito::RetVal closeInst(ito::AddInBase **addInInst); 00301 virtual QVector<ito::Param>* getInitParamsMand(void) { return &m_initParamsMand; } 00303 virtual QVector<ito::Param>* getInitParamsOpt(void) { return &m_initParamsOpt; } 00305 virtual ito::RetVal getAddInInst(ito::AddInBase **addInInst) = 0; 00307 void incRef(ito::AddInBase *addIn); 00309 void decRef(ito::AddInBase *addIn); 00311 int getRef(ito::AddInBase *addIn); 00313 int getInstCount() { return m_InstList.length(); } 00315 void setApiFunctions(void **apiFunctions); 00316 void setApiFunctionsGraph(void ** apiFunctionsGraph); 00317 inline void setLoader(QPluginLoader *loader) { m_loader = loader; } 00318 inline QPluginLoader * getLoader(void) { return m_loader; } 00319 00320 bool event(QEvent *e); 00321 00322 00323 }; 00324 00325 //---------------------------------------------------------------------------------------------------------------------------------- 00339 class ITOMCOMMONQT_EXPORT AddInBase : public QObject 00340 { 00341 Q_OBJECT 00342 00343 public: 00344 00345 struct AddInRef { 00346 AddInRef() : type(-1), ptr(0) {} 00347 AddInRef(void *p, int t) : type(t), ptr(p) {} 00348 int type; 00349 void *ptr; 00350 }; 00351 00353 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const; 00354 00356 inline AddInInterfaceBase* getBasePlugin(void) const { return m_pBasePlugin; } 00357 00359 ito::RetVal MoveToThread(void); 00360 00362 /* 00363 Use the method setParam in order to change any parameter. 00364 00365 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00366 \return RetVal returns retOk. 00367 */ 00368 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00369 00371 /* 00372 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00373 \return retOk 00374 \sa registerExecFunc 00375 */ 00376 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00377 00379 inline int getID() const { return m_uniqueID; } 00380 00382 inline QString getIdentifier() const { return m_identifier; } 00383 00385 virtual int hasConfDialog(void); 00386 00388 virtual const ito::RetVal showConfDialog(void); 00389 00391 inline int createdByGUI() const { return m_createdByGUI; } 00392 00394 inline void setCreatedByGUI(int value) { m_createdByGUI = value; } 00395 00397 /* 00398 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00399 */ 00400 inline int getRefCount(void) const 00401 { 00402 return m_refCount; 00403 } 00404 00406 /* 00407 \sa getDockWidget 00408 */ 00409 inline bool hasDockWidget(void) const { return m_dockWidget ? true : false; } 00410 00412 /* 00413 \sa hasDockWidget 00414 */ 00415 inline QDockWidget* getDockWidget(void) const { return m_dockWidget; } 00416 00417 // doc in source 00418 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00419 00421 /* 00422 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00423 by calling setAlive. The state of this flag is returned by this method and afterwards 00424 reset to 0. This method is thread-safe. 00425 00426 \return current status of alive-flag (1 if "still alive", else 0) 00427 \sa setAlive 00428 */ 00429 int isAlive(void) 00430 { 00431 // QMutexLocker locker(&m_atomicMutex); 00432 int wasalive = m_alive; 00433 m_alive = 0; 00434 return wasalive; 00435 } 00436 00438 /* 00439 This method is thread-safe. 00440 00441 \sa isAlive 00442 */ 00443 void setAlive(void) 00444 { 00445 // QMutexLocker locker(&m_atomicMutex); 00446 m_alive = 1; 00447 } 00448 00450 bool isInitialized(void) const 00451 { 00452 // QMutexLocker locker(&m_atomicMutex); 00453 return m_initialized; 00454 } 00455 00457 /* 00458 \param [in] initialized is the value to set 00459 */ 00460 void setInitialized(bool initialized) 00461 { 00462 // QMutexLocker locker(&m_atomicMutex); 00463 m_initialized = initialized; 00464 } 00465 00467 /* 00468 This vector contains all plugin-instances, that have been passed to the init 00469 method of this plugin. The reference counter of these plugin is incremented at 00470 initialization of this plugin and decremented if this plugin will be destroyed. 00471 00472 \sa AddInRef, init 00473 */ 00474 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00475 00476 protected: 00477 // constructor (doc in source) 00478 AddInBase(); 00479 00480 // destructor (doc in source) 00481 virtual ~AddInBase(); 00482 00484 void setIdentifier(const QString &identifier); 00485 00486 //doc in source 00487 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00488 00489 // doc in source 00490 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00491 00493 inline void setBasePlugin(AddInInterfaceBase *base) { m_pBasePlugin = base; } 00494 00495 QMap<QString, Param> m_params; 00496 00497 QString m_identifier; 00498 00499 private: 00500 Q_DISABLE_COPY (AddInBase) 00501 00502 00503 inline void incRefCount(void) 00504 { 00505 m_refCountMutex.lock(); 00506 m_refCount++; 00507 m_refCountMutex.unlock(); 00508 } 00509 00511 inline void decRefCount(void) 00512 { 00513 m_refCountMutex.lock(); 00514 m_refCount--; 00515 m_refCountMutex.unlock(); 00516 } 00517 00518 QThread *m_pThread; 00519 AddInInterfaceBase *m_pBasePlugin; 00520 00521 int m_refCount; 00522 int m_createdByGUI; 00523 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00524 QMap<QString, ExecFuncParams> m_execFuncList; 00525 00526 int m_uniqueID; 00527 00528 QMutex m_refCountMutex; 00529 QDockWidget *m_dockWidget; 00530 int m_alive; 00531 QMutex m_atomicMutex; 00532 bool m_initialized; 00533 00534 friend class AddInInterfaceBase; 00535 00536 static int m_instCounter; 00537 00538 signals: 00540 00548 void parametersChanged(QMap<QString, ito::Param> params); 00549 00550 public slots: 00552 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00554 virtual ito::RetVal close(ItomSharedSemaphore *waitCond) = 0; 00555 00557 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00559 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00560 00562 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00563 00565 ito::RetVal getParamVector(const QVector<QSharedPointer<ito::Param> > values, ItomSharedSemaphore *waitCond = NULL); 00566 00568 virtual ito::RetVal execFunc(const QString funcName, QSharedPointer<QVector<ito::ParamBase> > paramsMand, QSharedPointer<QVector<ito::ParamBase> > paramsOpt, QSharedPointer<QVector<ito::ParamBase> > paramsOut, ItomSharedSemaphore *waitCond = NULL); 00569 00571 ito::RetVal moveBackToApplicationThread(ItomSharedSemaphore *waitCond = NULL); 00572 00573 private slots: 00575 00582 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00583 00585 00593 virtual void dockWidgetVisibilityChanged(bool /*visible*/) {}; 00594 00596 00601 void dockWidgetDestroyed() { m_dockWidget = NULL; } 00602 }; 00603 00604 //---------------------------------------------------------------------------------------------------------------------------------- 00631 class ITOMCOMMONQT_EXPORT AddInDataIO : public AddInBase 00632 { 00633 Q_OBJECT 00634 00635 private: 00636 Q_DISABLE_COPY (AddInDataIO) 00637 00638 protected: 00639 virtual ~AddInDataIO(); 00640 AddInDataIO(); 00641 00642 void runStatusChanged(bool deviceStarted); 00643 00644 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00645 00646 QSet<QObject*> m_autoGrabbingListeners; 00647 int m_timerID; 00648 int m_timerIntervalMS; 00649 bool m_autoGrabbingEnabled; 00651 public: 00652 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00654 signals: 00655 00656 public slots: 00658 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00660 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00662 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00664 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00666 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00668 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00669 00671 virtual ito::RetVal setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00672 00674 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00675 00677 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00678 00680 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00681 00683 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00684 }; 00685 00686 //---------------------------------------------------------------------------------------------------------------------------------- 00687 00688 00695 class ITOMCOMMONQT_EXPORT AddInActuator : public AddInBase 00696 { 00697 Q_OBJECT 00698 00699 private: 00700 Q_DISABLE_COPY (AddInActuator) 00701 00702 int m_nrOfStatusChangedConnections; 00703 int m_nrOfTargetChangedConnections; 00704 bool m_interruptFlag; 00705 QMutex m_interruptMutex; 00707 protected: 00708 virtual ~AddInActuator(); 00709 AddInActuator(); 00710 00711 QVector<int> m_currentStatus; 00712 QVector<double> m_currentPos; 00713 QVector<double> m_targetPos; 00715 00716 bool isMotorMoving() const 00717 { 00718 foreach(const int &i, m_currentStatus) 00719 { 00720 if (i & ito::actuatorMoving) 00721 { 00722 return true; 00723 } 00724 } 00725 return false; 00726 } 00727 00728 void sendStatusUpdate(const bool statusOnly = false); 00729 void sendTargetUpdate(); 00730 00732 00736 virtual ito::RetVal waitForDone(const int timeoutMS = -1, const QVector<int> axis = QVector<int>() /*if empty -> all axis*/, const int flags = 0 /*for your use*/) = 0; 00737 00739 00749 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00750 00752 00762 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00763 { 00764 foreach(const int &i, axis) 00765 { 00766 setStatus(m_currentStatus[i], newFlags, keepMask); 00767 } 00768 } 00769 00771 00780 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00781 00783 00793 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00794 { 00795 foreach(const int &i, axis) 00796 { 00797 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00798 } 00799 } 00800 00802 00808 bool isInterrupted() 00809 { 00810 QMutexLocker locker(&m_interruptMutex); 00811 bool res = m_interruptFlag; 00812 m_interruptFlag = false; 00813 return res; 00814 } 00815 00816 public: 00818 00825 void setInterrupt() 00826 { 00827 QMutexLocker locker(&m_interruptMutex); 00828 m_interruptFlag = true; 00829 } 00830 00831 00832 00833 signals: 00835 00844 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00845 00847 00855 void targetChanged(QVector<double> targetPositions); 00856 00857 public slots: 00859 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00861 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00863 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00865 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00867 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00869 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00871 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00873 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00875 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00877 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00879 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00880 00882 virtual ito::RetVal requestStatusAndPosition(bool sendCurrentPos, bool sendTargetPos); //added 2014-03-04 00883 }; 00884 00885 //---------------------------------------------------------------------------------------------------------------------------------- 00894 class ITOMCOMMONQT_EXPORT AddInAlgo : public AddInBase 00895 { 00896 Q_OBJECT 00897 00898 Q_ENUMS(tAlgoCategory) 00899 Q_ENUMS(tAlgoInterface) 00900 00901 private: 00902 Q_DISABLE_COPY(AddInAlgo) 00903 00904 public: 00905 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00906 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00907 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00908 00910 enum tAlgoCategory 00911 { 00912 catNone = 0x0000, 00913 catDiskIO = 0x0001, 00914 catAnalyseDataObject = 0x0002, 00915 catPlotDataObject = 0x0004 00916 }; 00917 00919 enum tAlgoInterface 00920 { 00921 iNotSpecified = 0x0000, 00922 iReadDataObject = 0x0001, 00923 iWriteDataObject = 0x0002, 00924 iReadPointCloud = 0x0004, 00925 iWritePointCloud = 0x0008, 00926 iReadPolygonMesh = 0x0010, 00927 iWritePolygonMesh = 0x0020, 00928 iPlotSingleObject = 0x0040 00929 }; 00930 00932 class FilterDef 00933 { 00934 public: 00936 FilterDef() : 00937 m_filterFunc(NULL), 00938 m_paramFunc(NULL), 00939 m_pBasePlugin(NULL), 00940 m_category(ito::AddInAlgo::catNone), 00941 m_interface(ito::AddInAlgo::iNotSpecified) 00942 {} 00943 00945 FilterDef(AddInAlgo::t_filter filterFunc, AddInAlgo::t_filterParam filterParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 00946 m_filterFunc(filterFunc), 00947 m_paramFunc(filterParamFunc), 00948 m_pBasePlugin(NULL), 00949 m_description(description), 00950 m_category(category), 00951 m_interface(interf), 00952 m_interfaceMeta(interfaceMeta) 00953 {} 00954 00955 virtual ~FilterDef() {} 00956 00957 t_filter m_filterFunc; 00958 t_filterParam m_paramFunc; 00959 ito::AddInInterfaceBase *m_pBasePlugin; 00960 QString m_name; 00961 QString m_description; 00962 ito::AddInAlgo::tAlgoCategory m_category; 00963 ito::AddInAlgo::tAlgoInterface m_interface; 00964 QString m_interfaceMeta; 00965 private: 00966 FilterDef (const FilterDef & /*p*/); //disable copy constructor 00967 }; 00968 00970 class AlgoWidgetDef 00971 { 00972 public: 00974 AlgoWidgetDef() : 00975 m_widgetFunc(NULL), 00976 m_paramFunc(NULL), 00977 m_pBasePlugin(NULL), 00978 m_category(ito::AddInAlgo::catNone), 00979 m_interface(ito::AddInAlgo::iNotSpecified) 00980 {} 00981 00983 AlgoWidgetDef(AddInAlgo::t_algoWidget algoWidgetFunc, AddInAlgo::t_filterParam algoWidgetParamFunc, QString description = QString(), ito::AddInAlgo::tAlgoCategory category = ito::AddInAlgo::catNone, ito::AddInAlgo::tAlgoInterface interf = ito::AddInAlgo::iNotSpecified, QString interfaceMeta = QString()) : 00984 m_widgetFunc(algoWidgetFunc), 00985 m_paramFunc(algoWidgetParamFunc), 00986 m_pBasePlugin(NULL), 00987 m_description(description), 00988 m_category(category), 00989 m_interface(interf), 00990 m_interfaceMeta(interfaceMeta) 00991 {} 00992 00993 virtual ~AlgoWidgetDef() {} 00994 00995 t_algoWidget m_widgetFunc; 00996 t_filterParam m_paramFunc; 00997 ito::AddInInterfaceBase *m_pBasePlugin; 00998 QString m_name; 00999 QString m_description; 01000 ito::AddInAlgo::tAlgoCategory m_category; 01001 ito::AddInAlgo::tAlgoInterface m_interface; 01002 QString m_interfaceMeta; 01003 01004 private: 01005 AlgoWidgetDef (const AlgoWidgetDef & /*p*/); //disable copy constructor 01006 }; 01007 01008 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 01009 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 01010 ito::RetVal rejectFilter(const QString &name); 01011 ito::RetVal rejectAlgoWidget(const QString &name); 01012 01013 protected: 01014 virtual ~AddInAlgo(); 01015 AddInAlgo(); 01016 QHash<QString, FilterDef *> m_filterList; 01017 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 01018 01019 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 01020 { 01021 if (!paramsMand) 01022 { 01023 return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toLatin1().data()); 01024 } 01025 if (!paramsOpt) 01026 { 01027 return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toLatin1().data()); 01028 } 01029 if (!paramsOut) 01030 { 01031 return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toLatin1().data()); 01032 } 01033 paramsMand->clear(); 01034 paramsOpt->clear(); 01035 paramsOut->clear(); 01036 return ito::retOk; 01037 } 01038 01039 public slots: 01040 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01041 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01042 }; 01043 01044 //---------------------------------------------------------------------------------------------------------------------------------- 01045 } // namespace ito 01046 01047 #endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) 01048 01049 //########################################################################################################### 01050 // Interface version: 01051 //########################################################################################################### 01052 // 01053 // 01054 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01055 // 01056 // To add a new version, do the following steps 01057 // 01058 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01059 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01060 // 3. if the AddInInterface version number is incremented, the ito.AbstractItomDesignerPlugin number in AbstractItomDesignerPlugin.h must be incremented as well. 01061 // 01062 // 01063 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01064 // but a sophisticated error message is shown. 01065 01066 static const char* ito_AddInInterface_OldVersions[] = { 01067 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01068 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01069 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01070 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01071 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01072 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01073 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01074 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01075 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01076 "ito.AddIn.InterfaceBase/1.1.8", //version until 2013-01-23 (outdated: changes in auto-grabbing of cameras, first interface for itom version 1.0.6) 01077 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01078 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01079 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01080 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01081 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01082 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01083 "ito.AddIn.InterfaceBase/1.1.15",//version until 2013-04-23 (outdated: made some tag-space related methods non-inline (due to linker errors in MSVC)) 01084 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01085 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01086 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01087 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01088 "ito.AddIn.InterfaceBase/1.1.20",//version until 2013-10-10 (outdated: RGBA-type introduced into dataObjectTypes) 01089 "ito.AddIn.InterfaceBase/1.1.21",//version until 2013-10-15 (outdated: getSize(..) and getTotalSize(..) return int now and -1 if error. Consistency to documented behaviour) 01090 "ito.AddIn.InterfaceBase/1.1.22",//version until 2013-10-27 (outdated: class Rgba32Base in typedefs.h and inherited class Rgba32 in color.h introduced, improved data() method in dataObj) 01091 "ito.AddIn.InterfaceBase/1.1.23",//version until 2013-12-17 (outdated: changed dataObject internal size parameters (back) from size_t to int - hopfully last time) 01092 "ito.AddIn.InterfaceBase/1.1.24",//version until 2014-02-09 (outdated: restructuring to itomCommonLib and itomCommonQtLib for a better binary compatibility) 01093 "ito.AddIn.InterfaceBase/1.2.0", //outdated on 2014-03-14 due to change in AddInDataIO::setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); (const void *data changed to const char *data) (Qt5 bugfix) 01094 "ito.AddIn.InterfaceBase/1.2.1", //outdated on 2014-10-06 due to changes in APIs, retVal.h and itomWidgets-project. The next version 1.3.0 is the version for the setup 1.3.0. 01095 "ito.AddIn.InterfaceBase/1.3.0", //outdated on 2014-10-27 due to insertion of ito::AutoInterval object and addition of further ito::ParamMeta classes. 01096 "ito.AddIn.InterfaceBase/1.3.1", //outdated on 2015-03-01 due to rework on data object 01097 "ito.AddIn.InterfaceBase/1.4.0", //outdated on 2015-07-03 due to removal of lock mechanism in data object, add of embedded line plots, qt5 incompatiblity changes and some refinements in addInInterface 01098 NULL 01099 }; 01100 01101 //these defines exist since itom 1.3.1 01102 #define CREATE_ADDININTERFACE_VERSION_STR(major,minor,patch) "ito.AddIn.InterfaceBase/"#major"."#minor"."#patch 01103 #define CREATE_ADDININTERFACE_VERSION(major,minor,patch) ((major<<16)|(minor<<8)|(patch)) 01104 01105 #define ITOM_ADDININTERFACE_MAJOR 2 01106 #define ITOM_ADDININTERFACE_MINOR 0 01107 #define ITOM_ADDININTERFACE_PATCH 0 01108 #define ITOM_ADDININTERFACE_VERSION CREATE_ADDININTERFACE_VERSION(ITOM_ADDININTERFACE_MAJOR,ITOM_ADDININTERFACE_MINOR,ITOM_ADDININTERFACE_PATCH) 01109 static const char* ito_AddInInterface_CurrentVersion = CREATE_ADDININTERFACE_VERSION_STR(2,0,0); //results in "ito.AddIn.InterfaceBase/x.x.x"; (the numbers 1,3,1 can not be replaced by the macros above. Does not work properly) 01110 01111 01112 01114 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01115 01116 #endif