23 #include <tulip/Plugin.h>
24 #include <tulip/PluginLister.h>
37 static const std::string INTERACTOR_CATEGORY =
"Interactor";
65 Q_PROPERTY(
unsigned int priority READ priority)
66 Q_PROPERTY(QAction *action READ action)
67 Q_PROPERTY(
tlp::View *view READ view WRITE setView)
68 Q_PROPERTY(QCursor cursor READ cursor)
72 return INTERACTOR_CATEGORY;
74 std::string
icon()
const override {
75 return ":/tulip/gui/icons/32/plugin_interactor.png";
83 virtual bool isCompatible(
const std::string &viewName)
const = 0;
97 virtual QLabel *configurationDocWidget()
const {
100 virtual QWidget *configurationOptionsWidget()
const {
110 virtual unsigned int priority()
const = 0;
117 virtual QAction *action()
const = 0;
130 virtual QCursor cursor()
const = 0;
136 virtual void construct() = 0;
142 static void setupConfigWidget(QWidget *);
168 virtual void install(QObject *target) = 0;
174 virtual void uninstall() = 0;
179 virtual void undoIsDone() = 0;
187 return QObject::eventFilter(obj, ev);
196 class TLP_QT_SCOPE InteractorLister {
197 static QMap<std::string, QList<std::string>> _compatibilityMap;
200 static void initInteractorsDependencies();
201 static QList<std::string> compatibleInteractors(
const std::string &viewName);
228 #define INTERACTORPLUGINVIEWEXTENSION(CLASS_NAME, STRING_CLASS_NAME, BASE_INTERACTOR_STRING_NAME, \
229 VIEW_STRING_NAME, AUTHOR, DATE, DESCRIPTION, VERSION) \
230 class CLASS_NAME : public tlp::Interactor { \
231 mutable tlp::Interactor *_component; \
234 std::string name() const { \
235 return std::string(STRING_CLASS_NAME); \
237 std::string author() const { \
238 return std::string(AUTHOR); \
240 std::string date() const { \
241 return std::string(DATE); \
243 std::string info() const { \
244 return std::string(DESCRIPTION); \
246 std::string release() const { \
247 return std::string(VERSION); \
249 std::string tulipRelease() const { \
250 return std::string(TULIP_VERSION); \
252 std::string group() const { \
253 return getComponent()->group(); \
255 CLASS_NAME(const PluginContext *) : _component(nullptr) {} \
256 bool isCompatible(const std::string &viewName) const { \
257 return viewName == VIEW_STRING_NAME; \
259 QWidget *configurationWidget() const { \
260 return getComponent()->configurationWidget(); \
262 QLabel *configurationDocWidget() const { \
263 return getComponent()->configurationDocWidget(); \
265 QWidget *configurationActionsWidget() const { \
266 return getComponent()->configurationOptionsWidget(); \
268 unsigned int priority() const { \
269 return getComponent()->priority(); \
271 QAction *action() const { \
272 return getComponent()->action(); \
274 tlp::View *view() const { \
275 return getComponent()->view(); \
277 QCursor cursor() const { \
278 return getComponent()->cursor(); \
281 getComponent()->construct(); \
283 void setView(tlp::View *v) { \
284 getComponent()->setView(v); \
286 void install(QObject *target) { \
287 getComponent()->install(target); \
290 getComponent()->uninstall(); \
292 void undoIsDone() { \
293 getComponent()->undoIsDone(); \
295 tlp::Interactor *getComponent() const { \
298 tlp::PluginLister::getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME, nullptr); \
299 assert(_component != nullptr); \
315 #define INTERACTORPLUGINVIEWEXTENSIONWITHPRIORITY(CLASS_NAME, STRING_CLASS_NAME, \
316 BASE_INTERACTOR_STRING_NAME, VIEW_STRING_NAME, \
317 AUTHOR, DATE, DESCRIPTION, VERSION, PRIORITY) \
318 class CLASS_NAME : public tlp::Interactor { \
319 mutable tlp::Interactor *_component; \
322 std::string name() const { \
323 return std::string(STRING_CLASS_NAME); \
325 std::string author() const { \
326 return std::string(AUTHOR); \
328 std::string date() const { \
329 return std::string(DATE); \
331 std::string info() const { \
332 return std::string(DESCRIPTION); \
334 std::string release() const { \
335 return std::string(VERSION); \
337 std::string tulipRelease() const { \
338 return std::string(TULIP_VERSION); \
340 std::string group() const { \
341 return getComponent()->group(); \
343 CLASS_NAME(const PluginContext *) : _component(nullptr) {} \
344 bool isCompatible(const std::string &viewName) const { \
345 return viewName == VIEW_STRING_NAME; \
347 QWidget *configurationWidget() const { \
348 return getComponent()->configurationWidget(); \
350 QLabel *configurationDocWidget() const { \
351 return getComponent()->configurationDocWidget(); \
353 QWidget *configurationActionsWidget() const { \
354 return getComponent()->configurationOptionsWidget(); \
356 unsigned int priority() const { \
359 QAction *action() const { \
360 return getComponent()->action(); \
362 tlp::View *view() const { \
363 return getComponent()->view(); \
365 QCursor cursor() const { \
366 return getComponent()->cursor(); \
369 getComponent()->construct(); \
371 void setView(tlp::View *v) { \
372 getComponent()->setView(v); \
374 void install(QObject *target) { \
375 getComponent()->install(target); \
378 getComponent()->uninstall(); \
380 void undoIsDone() { \
381 getComponent()->undoIsDone(); \
383 tlp::Interactor *getComponent() const { \
386 tlp::PluginLister::getPluginObject<Interactor>(BASE_INTERACTOR_STRING_NAME, nullptr); \
387 assert(_component != nullptr); \