27 #include <dtkCoreSupport/dtkAbstractProcess.h>
28 #include <dtkCoreSupport/dtkAbstractProcessFactory.h>
29 #include <dtkCoreSupport/dtkGlobal.h>
30 #include <dtkCoreSupport/dtkPlugin.h>
31 #include <dtkCoreSupport/dtkPluginManager.h>
33 #include <dtkGuiSupport/dtkTagCloud.h>
41 this->setAlternatingRowColors(
false);
42 this->setAttribute(Qt::WA_MacShowFocusRect,
false);
43 this->setColumnHidden(1,
true);
44 this->setFrameShape(QFrame::NoFrame);
45 this->setHeaderHidden(
true);
47 connect(
this, SIGNAL(itemDoubleClicked(QTreeWidgetItem *,
int)),
this, SLOT(
onItemDoubleClicked(QTreeWidgetItem *,
int)));
59 emit
clicked(item->text(0), item->text(1));
65 static bool filterNum3sisPlugins(QString item_name)
67 QRegExp rx(
"^num[A-Z]");
69 if(!(rx.indexIn(item_name) == 0))
84 this->union_mode =
false;
102 connect(this->cloud, SIGNAL(tagClicked(QString)),
this, SLOT(setFilter(QString)));
109 connect(this->scope, SIGNAL(tagSet(QString)),
this, SLOT(setFilter(QString)));
110 connect(this->scope, SIGNAL(tagAdded(QString)),
this, SLOT(addFilter(QString)));
111 connect(this->scope, SIGNAL(cleared(
void)),
this, SLOT(clear()));
112 connect(this->scope, SIGNAL(unionMode(
bool)),
this, SLOT(onUnionMode(
bool)));
117 this->items << dtkItem(name,
"", QStringList());
125 this->items << dtkItem(name, description, QStringList());
133 this->items << dtkItem(name, description, tags);
151 QHash<QString, QStringList> tags;
153 foreach(dtkItem item, this->items)
154 foreach(QString tag, item.tags())
155 tags[tag] << item.name();
157 foreach(QString tag, tags.keys())
158 this->tags << dtkTag(tag, tags[tag].count(), tags[tag]);
161 static bool axlInspectorToolManagerControllerFilter(QStringList l1, QStringList l2)
163 QStringList ll1;
foreach(QString s1, l1) ll1 << s1.toLower();
164 QStringList ll2;
foreach(QString s2, l2) ll2 << s2.toLower();
168 foreach(QString s, ll1)
175 void axlInspectorToolManagerController::clear(
void)
177 this->filters.clear();
183 void axlInspectorToolManagerController::onUnionMode(
bool mode){
185 this->union_mode = !mode;
189 static bool intersect(QStringList l1, QStringList l2) {
191 foreach(QString s, l1)
if(!l2.contains(s)) pass =
false;
195 static bool unite(QStringList l1, QStringList l2) {
196 if(l1.isEmpty())
return true;
198 foreach(QString s, l1)
if(l2.contains(s)) pass =
true;
227 QHash<QString, QStringList> tags;
229 foreach(dtkItem item, this->items)
230 foreach(QString tag, item.tags())
231 tags[tag] << item.name();
233 foreach(QString tag, tags.keys())
234 this->tags << dtkTag(tag, tags[tag].count(), tags[tag]);
239 foreach(dtkItem item, this->items)
240 if((this->union_mode && unite(this->filters, item.tags())) || (!this->union_mode && intersect(this->filters, item.tags())) || axlInspectorToolManagerControllerFilter(this->filters, item.tags()))
241 this->view->addTopLevelItem(
new QTreeWidgetItem(this->view, QStringList() << item.name() << item.description()));
245 this->cloud->clear();
246 foreach(dtkTag tag, this->tags)
247 this->cloud->addTag(tag);
248 this->cloud->render();
252 this->scope->clear();
253 foreach(QString filter, this->filters){
254 if(filter.at(0).isLower())
255 filter.replace(0,1,filter.at(0).toUpper());
256 this->scope->addTag(filter, tags[filter].count());
258 this->scope->render();
262 this->scope->setTags(tags.keys());
265 void axlInspectorToolManagerController::addFilter(QString filter)
267 this->filters << filter;
272 void axlInspectorToolManagerController::setFilter(QString filter)
274 this->filters.clear();
275 this->filters << filter;
284 static QString axlInspectorToolManager_cloud_stylesheet =
285 "body { color: rgb(230, 230, 230); background-color: rgb(230, 230, 230); }"
286 "a:link { color: rgb(70, 70, 70); text-decoration:none; }"
287 "a:active { color: rgb(70, 70, 70); text-decoration:none; }"
288 "a:hover { color: rgb(90, 90, 90); text-decoration:none; }";
290 static QString axlInspectorToolManager_scope_stylesheet =
291 "body { background-color: rgb(230, 230, 230); }"
292 "input.text { background-color: rgb(230, 230, 230); border: 1px solid rgb(100, 100, 100); }";
296 d->cloud =
new dtkTagCloud(
this);
297 d->cloud->setSortingType(dtkTagCloud::Alpha);
298 d->cloud->setSortingOrder(dtkTagCloud::Asc);
299 d->cloud->setFontSize(18);
300 d->cloud->setFontRange(10);
301 d->cloud->setMinimumHeight(100);
302 d->cloud->setMinimumWidth(300);
303 d->cloud->setMaximumHeight(130);
304 d->cloud->setStyleSheet(axlInspectorToolManager_cloud_stylesheet);
305 d->cloud->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
307 d->scope =
new dtkTagScope(
this);
308 d->scope->setStyleSheet(axlInspectorToolManager_scope_stylesheet);
311 d->view->setMinimumHeight(25);
312 d->view->setMinimumWidth(300);
313 d->view->setMaximumHeight(400);
314 d->view->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
315 d->view->setSortingEnabled(1);
316 d->view->header()->setSortIndicator(0, Qt::AscendingOrder);
319 d->inspector_tool->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
322 d->controller->attach(d->view);
323 d->controller->attach(d->scope);
324 d->controller->attach(d->cloud);
326 QStringList interfaceList;
328 foreach(QString interface_name, dtkAbstractProcessFactory::instance()->interfaces())
330 if(!interfaceList.contains(interface_name) )
332 interfaceList << interface_name;
334 foreach(QString implementation, dtkAbstractProcessFactory::instance()->implementations(interface_name))
336 if(filterNum3sisPlugins(implementation))
337 d->controller->addItem(implementation, interface_name, QStringList() << interface_name.remove(
"axlAbstract"));
343 d->controller->addItem(
"axlCircleArcCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
344 d->controller->addItem(
"axlConeCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
345 d->controller->addItem(
"axlCylinderCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
346 d->controller->addItem(
"axlDataDynamicCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
347 d->controller->addItem(
"axlEllipsoidCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
348 d->controller->addItem(
"axlLineCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
349 d->controller->addItem(
"axlPlaneCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
350 d->controller->addItem(
"axlPointCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
352 d->controller->addItem(
"axlSphereCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
353 d->controller->addItem(
"axlTorusCreator",
"axlAbstractCreator", QStringList() << QString(
"Creator"));
363 d->controller->addItem(
"axlBarycenterProcess",
"axlAbstractProcess", QStringList() <<
"Barycenter");
364 d->controller->addItem(
"axlIntersection",
"axlAbstractProcess", QStringList() <<
"Intersection");
365 d->controller->addItem(
"axlProcessProjection",
"axlAbstractProcess", QStringList() <<
"Projection");
367 d->controller->addItem(
"axlFieldSpatialCoordinatesCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Creator");
368 d->controller->addItem(
"axlFieldSpatialPointDistanceCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Spatial" <<
"Distance" <<
"Creator");
369 d->controller->addItem(
"axlFieldParametricNormalVectorCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Parametric"<<
"Creator");
370 d->controller->addItem(
"axlFieldParametricCurveTangentVectorCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Parametric"<<
"Creator");
371 d->controller->addItem(
"axlFieldParametricSurfaceTangentVectorCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Parametric"<<
"Creator");
372 d->controller->addItem(
"axlFieldParametricVolumeTangentVectorCreator",
"axlAbstractProcess", QStringList() <<
"FieldGenerator" <<
"Field" <<
"Generator" <<
"Parametric"<<
"Creator");
376 QVBoxLayout *layout =
new QVBoxLayout(
this);
377 layout->setAlignment(Qt::AlignTop);
378 layout->setContentsMargins(0, 0, 0, 0);
379 layout->setSpacing(0);
381 layout->addWidget(d->cloud);
383 layout->addWidget(d->scope);
385 layout->addWidget(d->view);
388 layout->addWidget(d->inspector_tool);
391 connect(d->view, SIGNAL(clicked(QString, QString)),
this, SIGNAL(
selected(QString, QString)));
392 connect(d->inspector_tool, SIGNAL(
update()),
this, SIGNAL(
update()));
395 connect(d->inspector_tool, SIGNAL(
dataChanged(dtkAbstractData *)),
this, SIGNAL(
dataChanged(dtkAbstractData *)));
402 connect(
this, SIGNAL(
selected(QString,QString)), d->inspector_tool, SLOT(onProcessSelected(QString,QString)));
414 return QSize(300, 1000);
419 d->ObjectController = controller;
420 d->inspector_tool->setController(controller);
425 d->inspector_tool->setView(view);
Class axlAbstractData defines an API for all type of axel data.