itom 1.4.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 00370 const Param getParamRec(const QString name, bool *nameCheckOk = NULL) const 00371 { 00372 QRegExp rx("^([a-zA-Z]+\\w*)(\\[(\\d+)\\]){0,1}(:(.*)){0,1}$"); 00373 if (rx.indexIn(name) == -1) 00374 { 00375 if (nameCheckOk) 00376 { 00377 *nameCheckOk = false; 00378 } 00379 return Param(); 00380 } 00381 else 00382 { 00383 QStringList pname = rx.capturedTexts(); 00384 if (pname.length() > 1) 00385 { 00386 if (nameCheckOk) 00387 { 00388 *nameCheckOk = true; 00389 } 00390 ito::Param tempParam = m_params.value(pname[1]); 00391 if (pname[2].length()) 00392 { 00393 } 00394 if (pname[4].length()) 00395 { 00396 } 00397 return tempParam; //returns default constructor if value not available in m_params. Default constructor has member isValid() => false 00398 } 00399 } 00400 return Param(); 00401 } 00402 00404 inline AddInInterfaceBase* getBasePlugin(void) const { return m_pBasePlugin; } 00405 00407 inline ito::RetVal MoveToThread(void) 00408 { 00409 m_pThread = new QThread(); 00410 moveToThread(m_pThread); 00411 m_pThread->start(); 00412 return retOk; 00413 } 00414 00416 /* 00417 Use the method setParam in order to change any parameter. 00418 00419 \param paramNames [out]. The pointer contains a pointer to the map after the call of this function 00420 \return RetVal returns retOk. 00421 */ 00422 inline const ito::RetVal getParamList(QMap<QString, Param> **paramNames) { *paramNames = &m_params; return ito::retOk; } 00423 00425 /* 00426 \param [out] funcs is the pointer to a map, that points to the internal map of additional functions after the method-call. 00427 \return retOk 00428 \sa registerExecFunc 00429 */ 00430 inline const ito::RetVal getExecFuncList(QMap<QString, ExecFuncParams> **funcs) { *funcs = &m_execFuncList; return ito::retOk; } 00431 00433 inline int getID() const { return m_uniqueID; } 00434 00436 inline QString getIdentifier() const { return m_identifier; } 00437 00439 virtual int hasConfDialog(void); 00440 00442 virtual const ito::RetVal showConfDialog(void); 00443 00445 inline int createdByGUI() const { return m_createdByGUI; } 00446 00448 inline void setCreatedByGUI(int value) { m_createdByGUI = value; } 00449 00451 /* 00452 The reference counter is zero-based, hence, the value zero means that one reference is pointing to this instance 00453 */ 00454 inline int getRefCount(void) 00455 { 00456 return m_refCount; 00457 } 00458 00460 /* 00461 \sa getDockWidget 00462 */ 00463 inline bool hasDockWidget(void) const { return m_dockWidget ? true : false; } 00464 00466 /* 00467 \sa hasDockWidget 00468 */ 00469 inline QDockWidget* getDockWidget(void) const { return m_dockWidget; } 00470 00471 // doc in source 00472 virtual void dockWidgetDefaultStyle(bool &floating, bool &visible, Qt::DockWidgetArea &defaultArea) const; 00473 00475 /* 00476 Any time-consuming operation of the plugin should regularly set the alive-flag to true 00477 by calling setAlive. The state of this flag is returned by this method and afterwards 00478 reset to 0. This method is thread-safe. 00479 00480 \return current status of alive-flag (1 if "still alive", else 0) 00481 \sa setAlive 00482 */ 00483 int isAlive(void) 00484 { 00485 // QMutexLocker locker(&m_atomicMutex); 00486 int wasalive = m_alive; 00487 m_alive = 0; 00488 return wasalive; 00489 } 00490 00492 /* 00493 This method is thread-safe. 00494 00495 \sa isAlive 00496 */ 00497 void setAlive(void) 00498 { 00499 // QMutexLocker locker(&m_atomicMutex); 00500 m_alive = 1; 00501 } 00502 00504 bool isInitialized(void) 00505 { 00506 // QMutexLocker locker(&m_atomicMutex); 00507 return m_initialized; 00508 } 00509 00511 /* 00512 \param [in] initialized is the value to set 00513 */ 00514 void setInitialized(bool initialized) 00515 { 00516 // QMutexLocker locker(&m_atomicMutex); 00517 m_initialized = initialized; 00518 } 00519 00521 /* 00522 This vector contains all plugin-instances, that have been passed to the init 00523 method of this plugin. The reference counter of these plugin is incremented at 00524 initialization of this plugin and decremented if this plugin will be destroyed. 00525 00526 \sa AddInRef, init 00527 */ 00528 QVector<ito::AddInBase::AddInRef *> * getArgAddIns(void) { return &m_hwDecList; } 00529 00530 protected: 00531 // constructor (doc in source) 00532 AddInBase(); 00533 00534 // destructor (doc in source) 00535 virtual ~AddInBase(); 00536 00538 void setIdentifier(const QString &identifier); 00539 00540 //doc in source 00541 void createDockWidget(QString title, QDockWidget::DockWidgetFeatures features, Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas, QWidget *content = NULL); 00542 00543 // doc in source 00544 ito::RetVal registerExecFunc(const QString funcName, const QVector<ito::Param> ¶msMand, const QVector<ito::Param> ¶msOpt, const QVector<ito::Param> ¶msOut, const QString infoString); 00545 00547 inline void setBasePlugin(AddInInterfaceBase *base) { m_pBasePlugin = base; } 00548 00549 QThread *m_pThread; 00550 AddInInterfaceBase *m_pBasePlugin; 00551 QMap<QString, Param> m_params; 00552 00553 QString m_identifier; 00554 int m_refCount; 00555 int m_createdByGUI; 00556 QVector<ito::AddInBase::AddInRef *> m_hwDecList; 00557 QMap<QString, ExecFuncParams> m_execFuncList; 00558 00559 private: 00560 Q_DISABLE_COPY (AddInBase) 00561 00562 00563 inline void incRefCount(void) 00564 { 00565 m_refCountMutex.lock(); 00566 m_refCount++; 00567 m_refCountMutex.unlock(); 00568 } 00569 00571 inline void decRefCount(void) 00572 { 00573 m_refCountMutex.lock(); 00574 m_refCount--; 00575 m_refCountMutex.unlock(); 00576 } 00577 00578 int m_uniqueID; 00579 00580 QMutex m_refCountMutex; 00581 QDockWidget *m_dockWidget; 00582 int m_alive; 00583 QMutex m_atomicMutex; 00584 bool m_initialized; 00585 00586 friend class AddInInterfaceBase; 00587 00588 static int m_instCounter; 00589 00590 signals: 00592 00600 void parametersChanged(QMap<QString, ito::Param> params); 00601 00602 public slots: 00604 virtual ito::RetVal init(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ItomSharedSemaphore *waitCond = NULL) = 0; 00606 virtual ito::RetVal close(ItomSharedSemaphore *waitCond) = 0; 00607 00609 virtual ito::RetVal getParam(QSharedPointer<ito::Param> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00611 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> val, ItomSharedSemaphore *waitCond = NULL) = 0; 00612 00613 // doc in source-file 00614 ito::RetVal setParamVector(const QVector<QSharedPointer<ito::ParamBase> > values, ItomSharedSemaphore *waitCond = NULL); 00615 00616 // doc in source-file 00617 ito::RetVal getParamVector(const QVector<QSharedPointer<ito::Param> > values, ItomSharedSemaphore *waitCond = NULL); 00618 00619 // doc in source-file 00620 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); 00621 00622 private slots: 00624 00631 void sendParameterRequest(){ emit parametersChanged(m_params); }; 00632 00634 00642 virtual void dockWidgetVisibilityChanged(bool /*visible*/) {}; 00643 00645 00650 void dockWidgetDestroyed() { m_dockWidget = NULL; } 00651 }; 00652 00653 //---------------------------------------------------------------------------------------------------------------------------------- 00680 class ITOMCOMMONQT_EXPORT AddInDataIO : public AddInBase 00681 { 00682 Q_OBJECT 00683 00684 private: 00685 Q_DISABLE_COPY (AddInDataIO) 00686 00687 protected: 00688 virtual ~AddInDataIO() = 0; //TODO:remove the pure virtual implementation -> requires changed interface-number 00689 AddInDataIO(); 00690 00691 void runStatusChanged(bool deviceStarted); 00692 00693 //void timerEvent (QTimerEvent *event) = 0; //implement this event in your plugin, if you are a device, which is accessible by any liveImage!!! 00694 00695 QSet<QObject*> m_autoGrabbingListeners; 00696 int m_timerID; 00697 int m_timerIntervalMS; 00698 bool m_autoGrabbingEnabled; 00700 public: 00701 inline int getAutoGrabbing() { return m_autoGrabbingEnabled; } 00703 signals: 00704 00705 public slots: 00707 virtual ito::RetVal startDevice(ItomSharedSemaphore *waitCond); 00709 virtual ito::RetVal stopDevice(ItomSharedSemaphore *waitCond); 00711 virtual ito::RetVal acquire(const int trigger, ItomSharedSemaphore *waitCond = NULL); 00713 virtual ito::RetVal getVal(void* data, ItomSharedSemaphore *waitCond = NULL); 00715 virtual ito::RetVal getVal(QSharedPointer<char> data, QSharedPointer<int> length, ItomSharedSemaphore *waitCond = NULL); 00717 virtual ito::RetVal copyVal(void *dObj, ItomSharedSemaphore *waitCond); 00718 00720 virtual ito::RetVal setVal(const char *data, const int length, ItomSharedSemaphore *waitCond = NULL); 00721 00723 ito::RetVal enableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00724 00726 ito::RetVal disableAutoGrabbing(ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00727 00729 ito::RetVal startDeviceAndRegisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00730 00732 ito::RetVal stopDeviceAndUnregisterListener(QObject* obj, ItomSharedSemaphore *waitCond = NULL); //consider this method as final 00733 }; 00734 00735 //---------------------------------------------------------------------------------------------------------------------------------- 00736 00737 00744 class ITOMCOMMONQT_EXPORT AddInActuator : public AddInBase 00745 { 00746 Q_OBJECT 00747 00748 private: 00749 Q_DISABLE_COPY (AddInActuator) 00750 00751 int m_nrOfStatusChangedConnections; 00752 int m_nrOfTargetChangedConnections; 00753 bool m_interruptFlag; 00754 QMutex m_interruptMutex; 00756 protected: 00757 virtual ~AddInActuator() = 0; //TODO:remove the pure virtual implementation -> requires changed interface-number 00758 AddInActuator(); 00759 00760 //remove the following five methods due to an incompatibility with qt5. The number of connected signals to statusChanged 00761 //and targetChanged will not be count any more, but the respective signals are always emitted. 00762 virtual void connectNotify (const char * signal); 00763 virtual void disconnectNotify (const char * signal); 00764 int nrOfStatusChangedConnections() const { return m_nrOfStatusChangedConnections; } 00765 int nrOfTargetChangedConnections() const { return m_nrOfTargetChangedConnections; } 00766 int nrOfConnections() const { return m_nrOfStatusChangedConnections + m_nrOfTargetChangedConnections; } 00768 QVector<int> m_currentStatus; 00769 QVector<double> m_currentPos; 00770 QVector<double> m_targetPos; 00772 00773 bool isMotorMoving() const 00774 { 00775 foreach(const int &i, m_currentStatus) 00776 { 00777 if (i & ito::actuatorMoving) 00778 { 00779 return true; 00780 } 00781 } 00782 return false; 00783 } 00784 00785 void sendStatusUpdate(const bool statusOnly = false); 00786 void sendTargetUpdate(); 00787 00789 00793 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; 00794 00796 00806 inline void setStatus(int &status, const int newFlags, const int keepMask = 0) { status = (status & keepMask) | newFlags; } 00807 00809 00819 inline void setStatus(const QVector<int> &axis, const int newFlags, const int keepMask = 0) 00820 { 00821 foreach(const int &i, axis) 00822 { 00823 setStatus(m_currentStatus[i], newFlags, keepMask); 00824 } 00825 } 00826 00828 00837 inline void replaceStatus(int &status, const int existingFlag, const int replaceFlag) { if (status & existingFlag) { status = (status ^ existingFlag) | replaceFlag; } } 00838 00840 00850 inline void replaceStatus(const QVector<int> &axis, const int existingFlag, const int replaceFlag) 00851 { 00852 foreach(const int &i, axis) 00853 { 00854 replaceStatus(m_currentStatus[i], existingFlag, replaceFlag); 00855 } 00856 } 00857 00859 00865 bool isInterrupted() 00866 { 00867 QMutexLocker locker(&m_interruptMutex); 00868 bool res = m_interruptFlag; 00869 m_interruptFlag = false; 00870 return res; 00871 } 00872 00873 public: 00875 00882 void setInterrupt() 00883 { 00884 QMutexLocker locker(&m_interruptMutex); 00885 m_interruptFlag = true; 00886 } 00887 00888 00889 00890 signals: 00892 00901 void actuatorStatusChanged(QVector<int> status, QVector<double> actPosition); 00902 00904 00912 void targetChanged(QVector<double> targetPositions); 00913 00914 public slots: 00916 virtual ito::RetVal calib(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00918 virtual ito::RetVal calib(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00920 virtual ito::RetVal setOrigin(const int axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00922 virtual ito::RetVal setOrigin(const QVector<int> axis, ItomSharedSemaphore *waitCond = NULL) = 0; 00924 virtual ito::RetVal getStatus(QSharedPointer<QVector<int> > status, ItomSharedSemaphore *waitCond) = 0; 00926 virtual ito::RetVal getPos(const int axis, QSharedPointer<double> pos, ItomSharedSemaphore *waitCond) = 0; 00928 virtual ito::RetVal getPos(const QVector<int> axis, QSharedPointer<QVector<double> > pos, ItomSharedSemaphore *waitCond) = 0; 00930 virtual ito::RetVal setPosAbs(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00932 virtual ito::RetVal setPosAbs(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00934 virtual ito::RetVal setPosRel(const int axis, const double pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00936 virtual ito::RetVal setPosRel(const QVector<int> axis, QVector<double> pos, ItomSharedSemaphore *waitCond = NULL) = 0; 00937 00939 virtual ito::RetVal requestStatusAndPosition(bool sendCurrentPos, bool sendTargetPos); //added 2014-03-04 00940 }; 00941 00942 //---------------------------------------------------------------------------------------------------------------------------------- 00951 class ITOMCOMMONQT_EXPORT AddInAlgo : public AddInBase 00952 { 00953 Q_OBJECT 00954 00955 Q_ENUMS(tAlgoCategory) 00956 Q_ENUMS(tAlgoInterface) 00957 00958 private: 00959 Q_DISABLE_COPY(AddInAlgo) 00960 00961 public: 00962 typedef ito::RetVal (* t_filter)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, QVector<ito::ParamBase> *paramsOut); 00963 typedef QWidget* (* t_algoWidget)(QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt, ito::RetVal &retValue); 00964 typedef ito::RetVal (* t_filterParam)(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut); 00965 00967 enum tAlgoCategory 00968 { 00969 catNone = 0x0000, 00970 catDiskIO = 0x0001, 00971 catAnalyseDataObject = 0x0002, 00972 catPlotDataObject = 0x0004 00973 }; 00974 00976 enum tAlgoInterface 00977 { 00978 iNotSpecified = 0x0000, 00979 iReadDataObject = 0x0001, 00980 iWriteDataObject = 0x0002, 00981 iReadPointCloud = 0x0004, 00982 iWritePointCloud = 0x0008, 00983 iReadPolygonMesh = 0x0010, 00984 iWritePolygonMesh = 0x0020, 00985 iPlotSingleObject = 0x0040 00986 }; 00987 00989 class FilterDef 00990 { 00991 public: 00993 FilterDef() : 00994 m_filterFunc(NULL), 00995 m_paramFunc(NULL), 00996 m_pBasePlugin(NULL), 00997 m_category(ito::AddInAlgo::catNone), 00998 m_interface(ito::AddInAlgo::iNotSpecified) 00999 {} 01000 01002 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()) : 01003 m_filterFunc(filterFunc), 01004 m_paramFunc(filterParamFunc), 01005 m_pBasePlugin(NULL), 01006 m_description(description), 01007 m_category(category), 01008 m_interface(interf), 01009 m_interfaceMeta(interfaceMeta) 01010 {} 01011 01012 virtual ~FilterDef() {} 01013 01014 t_filter m_filterFunc; 01015 t_filterParam m_paramFunc; 01016 ito::AddInInterfaceBase *m_pBasePlugin; 01017 QString m_name; 01018 QString m_description; 01019 ito::AddInAlgo::tAlgoCategory m_category; 01020 ito::AddInAlgo::tAlgoInterface m_interface; 01021 QString m_interfaceMeta; 01022 private: 01023 FilterDef (const FilterDef & /*p*/); //disable copy constructor 01024 }; 01025 01027 class AlgoWidgetDef 01028 { 01029 public: 01031 AlgoWidgetDef() : 01032 m_widgetFunc(NULL), 01033 m_paramFunc(NULL), 01034 m_pBasePlugin(NULL), 01035 m_category(ito::AddInAlgo::catNone), 01036 m_interface(ito::AddInAlgo::iNotSpecified) 01037 {} 01038 01040 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()) : 01041 m_widgetFunc(algoWidgetFunc), 01042 m_paramFunc(algoWidgetParamFunc), 01043 m_pBasePlugin(NULL), 01044 m_description(description), 01045 m_category(category), 01046 m_interface(interf), 01047 m_interfaceMeta(interfaceMeta) 01048 {} 01049 01050 virtual ~AlgoWidgetDef() {} 01051 01052 t_algoWidget m_widgetFunc; 01053 t_filterParam m_paramFunc; 01054 ito::AddInInterfaceBase *m_pBasePlugin; 01055 QString m_name; 01056 QString m_description; 01057 ito::AddInAlgo::tAlgoCategory m_category; 01058 ito::AddInAlgo::tAlgoInterface m_interface; 01059 QString m_interfaceMeta; 01060 01061 private: 01062 AlgoWidgetDef (const AlgoWidgetDef & /*p*/); //disable copy constructor 01063 }; 01064 01065 ito::RetVal getFilterList(QHash<QString, FilterDef *> &fList) const; 01066 ito::RetVal getAlgoWidgetList(QHash<QString, AlgoWidgetDef *> &awList) const; 01067 ito::RetVal rejectFilter(const QString &name); 01068 ito::RetVal rejectAlgoWidget(const QString &name); 01069 01070 protected: 01071 virtual ~AddInAlgo(); 01072 AddInAlgo(); 01073 QHash<QString, FilterDef *> m_filterList; 01074 QHash<QString, AlgoWidgetDef *> m_algoWidgetList; 01075 01076 static ito::RetVal prepareParamVectors(QVector<ito::Param> *paramsMand, QVector<ito::Param> *paramsOpt, QVector<ito::Param> *paramsOut) 01077 { 01078 if (!paramsMand) 01079 { 01080 return RetVal(ito::retError, 0, tr("uninitialized vector for mandatory parameters!").toLatin1().data()); 01081 } 01082 if (!paramsOpt) 01083 { 01084 return RetVal(ito::retError, 0, tr("uninitialized vector for optional parameters!").toLatin1().data()); 01085 } 01086 if (!paramsOut) 01087 { 01088 return RetVal(ito::retError, 0, tr("uninitialized vector for output parameters!").toLatin1().data()); 01089 } 01090 paramsMand->clear(); 01091 paramsOpt->clear(); 01092 paramsOut->clear(); 01093 return ito::retOk; 01094 } 01095 01096 public slots: 01097 virtual ito::RetVal getParam(QSharedPointer<ito::Param> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01098 virtual ito::RetVal setParam(QSharedPointer<ito::ParamBase> /*val*/, ItomSharedSemaphore * /*waitCond*/ = NULL) { return ito::retOk; } 01099 }; 01100 01101 //---------------------------------------------------------------------------------------------------------------------------------- 01102 } // namespace ito 01103 01104 #endif //#if !defined(Q_MOC_RUN) || defined(ITOMCOMMONQT_MOC) 01105 01106 //########################################################################################################### 01107 // Interface version: 01108 //########################################################################################################### 01109 // 01110 // 01111 // Please change the interface version, if you made any changes to this interface, files located in the common folder or to the dataObject. 01112 // 01113 // To add a new version, do the following steps 01114 // 01115 // 1. append the string behind the variable ito_AddInInterface_CurrentVersion (e.g. ito.AddIn.InterfaceBase/1.1) to the array ito_AddInInterface_OldVersions 01116 // 2. change the version number in the string ito_AddInInterface_CurrentVersion 01117 // 3. if the AddInInterface version number is incremented, the ito.AbstractItomDesignerPlugin number in AbstractItomDesignerPlugin.h must be incremented as well. 01118 // 01119 // 01120 // This helps, that deprecated or "future" plugins, which fit not to the current implementation of the interface will not be loaded 01121 // but a sophisticated error message is shown. 01122 01123 static const char* ito_AddInInterface_OldVersions[] = { 01124 "ito.AddIn.InterfaceBase/1.0", //version from start of development until 2012-10-11 01125 "ito.AddIn.InterfaceBase/1.1", //version until 2012-10-15 (outdated due to changes in dataObject) 01126 "ito.AddIn.InterfaceBase/1.1.1", //version until 2012-10-21 (outdated due to small changes in addInInterface) 01127 "ito.AddIn.InterfaceBase/1.1.2", //version until 2012-10-30 (outdated due to small changes in addInInterface) 01128 "ito.AddIn.InterfaceBase/1.1.3", //version until 2012-11-09 (outdated due to changes in the checkData()-function in addInGrabber) 01129 "ito.AddIn.InterfaceBase/1.1.4", //version until 2012-11-12 (outdated due to changes in the DataObject) 01130 "ito.AddIn.InterfaceBase/1.1.5", //version until 2012-11-18 (outdated: changes in the API structure) 01131 "ito.AddIn.InterfaceBase/1.1.6", //version until 2012-12-20 (outdated: added paramBase metatype) 01132 "ito.AddIn.InterfaceBase/1.1.7", //version until 2013-01-17 (outdated: last version for itom version 1.0.5) 01133 "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) 01134 "ito.AddIn.InterfaceBase/1.1.9", //version until 2013-03-04 (outdated: changes in dataObjectHelper) 01135 "ito.AddIn.InterfaceBase/1.1.10",//version until 2013-03-12 (outdated: Added license and about string to the plugin) 01136 "ito.AddIn.InterfaceBase/1.1.11",//version until 2013-03-22 (outdated: bugfix in ito::ParamBase) 01137 "ito.AddIn.InterfaceBase/1.1.12",//version until 2013-03-25 (outdated: changes in api) 01138 "ito.AddIn.InterfaceBase/1.1.13",//version until 2013-04-08 (outdated: removed transpose flag in dataObject) 01139 "ito.AddIn.InterfaceBase/1.1.14",//version until 2013-04-17 (outdated: uniqueID and identifier inserted/changed) 01140 "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)) 01141 "ito.AddIn.InterfaceBase/1.1.16",//version until 2013-06-07 (outdated: added qpluginloader to the interface for cleaner unloading of plugins) 01142 "ito.AddIn.InterfaceBase/1.1.17",//version until 2013-06-11 (outdated: apis extended, changes in param-class) 01143 "ito.AddIn.InterfaceBase/1.1.18",//version until 2013-06-18 (outdated: iterator and constIterator introduced for dataObject) 01144 "ito.AddIn.InterfaceBase/1.1.19",//version until 2013-08-15 (outdated: operators +, +=, -, -= introduced for scalar operands) 01145 "ito.AddIn.InterfaceBase/1.1.20",//version until 2013-10-10 (outdated: RGBA-type introduced into dataObjectTypes) 01146 "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) 01147 "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) 01148 "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) 01149 "ito.AddIn.InterfaceBase/1.1.24",//version until 2014-02-09 (outdated: restructuring to itomCommonLib and itomCommonQtLib for a better binary compatibility) 01150 "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) 01151 "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. 01152 "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. 01153 NULL 01154 }; 01155 01156 //these defines exist since itom 1.3.1 01157 #define CREATE_ADDININTERFACE_VERSION_STR(major,minor,patch) "ito.AddIn.InterfaceBase/"#major"."#minor"."#patch 01158 #define CREATE_ADDININTERFACE_VERSION(major,minor,patch) ((major<<16)|(minor<<8)|(patch)) 01159 01160 #define ITOM_ADDININTERFACE_MAJOR 1 01161 #define ITOM_ADDININTERFACE_MINOR 3 01162 #define ITOM_ADDININTERFACE_PATCH 1 01163 #define ITOM_ADDININTERFACE_VERSION CREATE_ADDININTERFACE_VERSION(ITOM_ADDININTERFACE_MAJOR,ITOM_ADDININTERFACE_MINOR,ITOM_ADDININTERFACE_PATCH) 01164 static const char* ito_AddInInterface_CurrentVersion = CREATE_ADDININTERFACE_VERSION_STR(1,3,1); //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) 01165 01166 01167 01169 Q_DECLARE_INTERFACE(ito::AddInInterfaceBase, ito_AddInInterface_CurrentVersion /*"ito.AddIn.InterfaceBase/1.1"*/) 01170 01171 #endif