Developer documentation | Axl-2.5.1

axlInspectorToolFactory.cpp
Go to the documentation of this file.
1 /* axlInspectorToolFactory.cpp ---
2  *
3  * Author: Meriadeg Perrinel
4  * Copyright (C) 2008 - Julien Wintz, Inria.
5  * Created: mar. mars 29 12:35:33 2011 (+0200)
6  * Version: $Id$
7  * Last-Updated: Wed Apr 20 14:03:24 2011 (+0200)
8  * By: Julien Wintz
9  * Update #: 20
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
21 
22 #include <dtkCoreSupport/dtkAbstractProcess.h>
23 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
24 
26 
27 
36 
37 // /////////////////////////////////////////////////////////////////
38 //
39 // /////////////////////////////////////////////////////////////////
40 
42 {
43  m_view = NULL;
44  m_controller = NULL;
45  m_process = NULL;
46 
47  m_toolFactorySingleton = axlInspectorToolFactory::instance();
48 
49 }
50 
52 {
53  // if(m_process && !(dynamic_cast<axlAbstractFieldGenerator*>(m_process)) ){
54  if(m_process){
55  delete m_process;
56  }
57 
58  m_process = NULL;
59 
60 
61 }
62 
64 {
65  this->m_controller = controller;
66 }
67 
68 void axlInspectorToolInterface::setImplementation(const QString& implementation)
69 {
70  if(!(this->m_process = dtkAbstractProcessFactory::instance()->create(implementation))){
71 
72  }
73 
74  if(dynamic_cast<axlAbstractFieldGenerator*>(m_process)){
75  connect(m_process, SIGNAL(dataSetFieldsChanged(QList<axlAbstractData *>, QString)), this, SIGNAL(dataSetFieldsChanged(QList<axlAbstractData *>, QString)));
76  }
77 
78  this->setToolTip(m_process->description());
79 
80 }
81 
83 {
84  m_toolFactorySingleton = toolFactorySingleton;
85 }
86 
88 {
89  return m_toolFactorySingleton;
90 }
91 
92 //dtkAbstractProcess *axlInspectorToolInterface::getProcess(void)
93 //{
94 // return m_process;
95 //}
96 
97 
99 {
100  this->m_view = view;
101 }
102 
103 // /////////////////////////////////////////////////////////////////
104 //
105 // /////////////////////////////////////////////////////////////////
106 
107 class axlInspectorToolFactoryPrivate
108 {
109 public:
111 };
112 
114 {
115  if(!s_instance)
117 
118  return s_instance;
119 }
120 
122 {
123  if(!d->creators.contains(interface_name))
124  {
125  d->creators.insert(interface_name, func);
126  }
127 
128  return true;
129 }
130 
132 {
133  if(!d->creators.contains(interface_name))
134  return NULL;
135 
136  return d->creators[interface_name]();
137 }
138 
139 
141 {
142 
143  d->creators.insert("axlLineCreator", createaxlInspectorToolCreatorLine);
144  d->creators.insert("axlConeCreator",createaxlInspectorToolCreatorCone );
145  d->creators.insert("axlCylinderCreator", createaxlInspectorToolCreatorCylinder);
146  d->creators.insert("axlPlaneCreator", createaxlInspectorToolCreatorPlane);
147  d->creators.insert("axlTorusCreator", createaxlInspectorToolCreatorTorus);
148  d->creators.insert("axlSphereCreator", createaxlInspectorToolCreatorSphere);
149  d->creators.insert("axlEllipsoidCreator", createaxlInspectorToolCreatorEllipsoid);
150 
151 
152 }
153 
154 axlInspectorToolFactory::axlInspectorToolFactory(void) : QObject(), d(new axlInspectorToolFactoryPrivate)
155 {
156 }
157 
158 axlInspectorToolFactory::~axlInspectorToolFactory(void)
159 {
160  delete d;
161 
162  d = NULL;
163 }
164 
static axlInspectorToolFactory * s_instance
axlInspectorToolFactory * toolFactorySingleton(void)
void setToolFactorySingleton(axlInspectorToolFactory *toolFactorySingleton)
axlInspectorToolInterface * createaxlInspectorToolCreatorTorus(void)
axlInspectorToolInterface * create(const QString &type)
QHash< QString, axlInspectorToolCreator > axlInspectorToolCreatorHash
void setImplementation(const QString &implementation)
axlInspectorToolInterface * createaxlInspectorToolCreatorLine(void)
void setView(axlAbstractView *view)
axlInspectorToolInterface * createaxlInspectorToolCreatorEllipsoid(void)
axlInspectorToolInterface(QWidget *parent=0)
axlInspectorToolInterface * createaxlInspectorToolCreatorCylinder(void)
axlInspectorObjectController * m_controller
axlInspectorToolInterface * createaxlInspectorToolCreatorCone(void)
virtual void setController(axlInspectorObjectController *controller)
axlInspectorToolInterface * createaxlInspectorToolCreatorSphere(void)
static axlInspectorToolFactory * instance(void)
void dataSetFieldsChanged(QList< axlAbstractData * > dataSet, QString fieldName)
bool registerInspectorTool(const QString &type, axlInspectorToolCreator func)
axlInspectorToolInterface * createaxlInspectorToolCreatorPlane(void)