23 #include <QtCore/QObject>
24 #include <QtGui/QAction>
26 #include <tulip/TulipRelease.h>
28 #include <tulip/Plugin.h>
29 #include <tulip/PluginLister.h>
30 #include <tulip/Plugin.h>
34 static const std::string INTERACTOR_CATEGORY = QObject::trUtf8(
"Interactor").toStdString();
54 Q_PROPERTY(
unsigned int priority READ priority)
55 Q_PROPERTY(QAction* action READ action)
56 Q_PROPERTY(
tlp::View* view READ view WRITE setView)
57 Q_PROPERTY(QCursor cursor READ cursor)
61 return INTERACTOR_CATEGORY;
64 return ":/tulip/gui/icons/32/plugin_interactor.png";
70 virtual bool isCompatible(
const std::string& viewName)
const=0;
78 virtual QWidget* configurationWidget()
const=0;
85 virtual unsigned int priority()
const=0;
92 virtual QAction* action()
const=0;
104 virtual QCursor cursor()
const=0;
110 virtual void construct()=0;
124 virtual void install(QObject* target)=0;
130 virtual void uninstall()=0;
135 virtual void undoIsDone()=0;
143 return QObject::eventFilter(obj,ev);
152 static QMap<std::string,QList<std::string> > _compatibilityMap;
154 static void initInteractorsDependencies();
155 static QList<std::string> compatibleInteractors(
const std::string& viewName);
177 #define INTERACTORPLUGINVIEWEXTENSION(CLASS_NAME,STRING_CLASS_NAME,BASE_INTERACTOR_STRING_NAME,VIEW_STRING_NAME,AUTHOR,DATE,DESCRIPTION,VERSION)\
178 class CLASS_NAME : public tlp::Interactor {\
179 mutable tlp::Interactor* _component;\
181 std::string name() const { return std::string(STRING_CLASS_NAME); } \
182 std::string author() const { return std::string(AUTHOR); }\
183 std::string date() const { return std::string(DATE); } \
184 std::string info() const { return std::string(DESCRIPTION); } \
185 std::string release() const { return std::string(VERSION); }\
186 std::string tulipRelease() const { return std::string(TULIP_RELEASE); }\
187 std::string group() const { return getComponent()->group(); }\
188 CLASS_NAME(const PluginContext *):_component(NULL) {}\
189 bool isCompatible(const std::string& viewName) const { return viewName == VIEW_STRING_NAME; }\
190 QWidget* configurationWidget() const { return getComponent()->configurationWidget(); }\
191 unsigned int priority() const { return getComponent()->priority(); }\
192 QAction* action() const { return getComponent()->action(); }\
193 tlp::View* view() const { return getComponent()->view(); }\
194 QCursor cursor() const { return getComponent()->cursor(); }\
195 void construct() { getComponent()->construct(); }\
196 void setView(tlp::View* v) { getComponent()->setView(v); }\
197 void install(QObject* target) { getComponent()->install(target); }\
198 void uninstall() { getComponent()->uninstall(); }\
199 void undoIsDone() { getComponent()->undoIsDone(); }\
200 tlp::Interactor* getComponent() const {\
202 _component = tlp::PluginLister::instance()->getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME,NULL); assert(_component != NULL);\
216 #define INTERACTORPLUGINVIEWEXTENSIONWITHPRIORITY(CLASS_NAME,STRING_CLASS_NAME,BASE_INTERACTOR_STRING_NAME,VIEW_STRING_NAME,AUTHOR,DATE,DESCRIPTION,VERSION,PRIORITY) \
217 class CLASS_NAME : public tlp::Interactor {\
218 mutable tlp::Interactor* _component;\
220 std::string name() const { return std::string(STRING_CLASS_NAME); } \
221 std::string author() const { return std::string(AUTHOR); }\
222 std::string date() const { return std::string(DATE); } \
223 std::string info() const { return std::string(DESCRIPTION); } \
224 std::string release() const { return std::string(VERSION); }\
225 std::string tulipRelease() const { return std::string(TULIP_RELEASE); }\
226 std::string group() const { return getComponent()->group(); }\
227 CLASS_NAME(const PluginContext *):_component(NULL) {}\
228 bool isCompatible(const std::string& viewName) const { return viewName == VIEW_STRING_NAME; }\
229 QWidget* configurationWidget() const { return getComponent()->configurationWidget(); }\
230 unsigned int priority() const { return PRIORITY; }\
231 QAction* action() const { return getComponent()->action(); }\
232 tlp::View* view() const { return getComponent()->view(); }\
233 QCursor cursor() const { return getComponent()->cursor(); }\
234 void construct() { getComponent()->construct(); }\
235 void setView(tlp::View* v) { getComponent()->setView(v); }\
236 void install(QObject* target) { getComponent()->install(target); }\
237 void uninstall() { getComponent()->uninstall(); }\
238 void undoIsDone() { getComponent()->undoIsDone(); }\
239 tlp::Interactor* getComponent() const {\
241 _component = tlp::PluginLister::instance()->getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME,NULL); assert(_component != NULL);\