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)=0;
77 virtual QWidget* configurationWidget()
const=0;
84 virtual unsigned int priority()
const=0;
91 virtual QAction* action()
const=0;
103 virtual QCursor cursor()
const=0;
109 virtual void construct()=0;
123 virtual void install(QObject* target)=0;
129 virtual void uninstall()=0;
134 virtual void undoIsDone()=0;
142 return QObject::eventFilter(obj,ev);
151 static QMap<std::string,QList<std::string> > _compatibilityMap;
153 static void initInteractorsDependencies();
154 static QList<std::string> compatibleInteractors(
const std::string& viewName);
176 #define INTERACTORPLUGINVIEWEXTENSION(CLASS_NAME,STRING_CLASS_NAME,BASE_INTERACTOR_STRING_NAME,VIEW_STRING_NAME,AUTHOR,DATE,DESCRIPTION,VERSION)\
177 class CLASS_NAME : public tlp::Interactor {\
178 mutable tlp::Interactor* _component;\
180 std::string name() const { return std::string(STRING_CLASS_NAME); } \
181 std::string author() const { return std::string(AUTHOR); }\
182 std::string date() const { return std::string(DATE); } \
183 std::string info() const { return std::string(DESCRIPTION); } \
184 std::string release() const { return std::string(VERSION); }\
185 std::string tulipRelease() const { return std::string(TULIP_RELEASE); }\
186 std::string group() const { return getComponent()->group(); }\
187 CLASS_NAME(const PluginContext *):_component(NULL) {}\
188 bool isCompatible(const std::string& viewName) { return viewName == VIEW_STRING_NAME; }\
189 QWidget* configurationWidget() const { return getComponent()->configurationWidget(); }\
190 unsigned int priority() const { return getComponent()->priority(); }\
191 QAction* action() const { return getComponent()->action(); }\
192 tlp::View* view() const { return getComponent()->view(); }\
193 QCursor cursor() const { return getComponent()->cursor(); }\
194 void construct() { getComponent()->construct(); }\
195 void setView(tlp::View* v) { getComponent()->setView(v); }\
196 void install(QObject* target) { getComponent()->install(target); }\
197 void uninstall() { getComponent()->uninstall(); }\
198 void undoIsDone() { getComponent()->undoIsDone(); }\
199 tlp::Interactor* getComponent() const {\
201 _component = tlp::PluginLister::instance()->getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME,NULL); assert(_component != NULL);\
215 #define INTERACTORPLUGINVIEWEXTENSIONWITHPRIORITY(CLASS_NAME,STRING_CLASS_NAME,BASE_INTERACTOR_STRING_NAME,VIEW_STRING_NAME,AUTHOR,DATE,DESCRIPTION,VERSION,PRIORITY) \
216 class CLASS_NAME : public tlp::Interactor {\
217 mutable tlp::Interactor* _component;\
219 std::string name() const { return std::string(STRING_CLASS_NAME); } \
220 std::string author() const { return std::string(AUTHOR); }\
221 std::string date() const { return std::string(DATE); } \
222 std::string info() const { return std::string(DESCRIPTION); } \
223 std::string release() const { return std::string(VERSION); }\
224 std::string tulipRelease() const { return std::string(TULIP_RELEASE); }\
225 std::string group() const { return getComponent()->group(); }\
226 CLASS_NAME(const PluginContext *):_component(NULL) {}\
227 bool isCompatible(const std::string& viewName) { return viewName == VIEW_STRING_NAME; }\
228 QWidget* configurationWidget() const { return getComponent()->configurationWidget(); }\
229 unsigned int priority() const { return PRIORITY; }\
230 QAction* action() const { return getComponent()->action(); }\
231 tlp::View* view() const { return getComponent()->view(); }\
232 QCursor cursor() const { return getComponent()->cursor(); }\
233 void construct() { getComponent()->construct(); }\
234 void setView(tlp::View* v) { getComponent()->setView(v); }\
235 void install(QObject* target) { getComponent()->install(target); }\
236 void uninstall() { getComponent()->uninstall(); }\
237 void undoIsDone() { getComponent()->undoIsDone(); }\
238 tlp::Interactor* getComponent() const {\
240 _component = tlp::PluginLister::instance()->getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME,NULL); assert(_component != NULL);\