PriorMemoryEditorPlugin.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 // Dialogs
26 
27 #include "CollectionCreateDialog.h"
30 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_CollectionCreateDialog.h>
31 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_PriorEditorConfigDialog.h>
32 
33 // ArmarX core
35 #include <ArmarXCore/interface/core/Log.h>
37 
39 
40 // Qt headers
41 #include <QBrush>
42 #include <QCheckBox>
43 #include <QMessageBox>
44 #include <QPushButton>
45 #include <QSlider>
46 #include <QSpinBox>
47 #include <QStandardItemModel>
48 #include <QStringList>
49 #include <QTableView>
50 #include <Qt>
51 #include <QtGlobal>
52 
53 // Coin3D headers
54 #include <Inventor/Qt/SoQt.h>
55 #include <Inventor/SoDB.h>
56 #include <Inventor/nodes/SoUnits.h>
57 
58 // System
59 #include <math.h>
60 #include <stdio.h>
61 #include <stdlib.h>
62 #include <string.h>
63 
64 #include <iostream>
65 #include <string>
66 
67 // Boost
68 #include <filesystem>
69 
70 // Simox-VirtualRobot
71 #include <VirtualRobot/CollisionDetection/CollisionModel.h>
72 #include <VirtualRobot/Grasping/Grasp.h>
73 #include <VirtualRobot/Grasping/GraspSet.h>
74 #include <VirtualRobot/ManipulationObject.h>
75 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
76 #include <VirtualRobot/XML/ObjectIO.h>
77 #include <VirtualRobot/XML/RobotIO.h>
78 
79 // MemoryX
85 
86 using namespace memoryx;
87 using namespace memoryx::EntityWrappers;
88 using namespace VirtualRobot;
89 
90 namespace fs = std::filesystem;
91 
92 #define DEFAULT_SETTINGS_PLUGIN_NAME "PriorMemoryEditorPlugin"
93 #define DEFAULT_SETTINGS_PRIORMEMORY_NAME "PriorKnowledge"
94 
95 namespace TreeItemType
96 {
98  {
99  eItemObject = QTreeWidgetItem::UserType + 1,
100  eItemAttr = QTreeWidgetItem::UserType + 2,
101  eItemValue = QTreeWidgetItem::UserType + 3
102  };
103 } // namespace TreeItemType
104 
106 {
107  addWidget<PriorEditorController>();
108 }
109 
111 {
112  visu = nullptr;
113  show3DViewer = false;
114 
115  ui.setupUi(getWidget());
116  treeCurrentItemChanged(nullptr, nullptr);
117 
118  collCreateDialog = new CollectionCreateDialog();
119  collCreateDialog->setCollectionPrefix(memoryx::PRIOR_COLLECTION_PREFIX);
120  getWidget()->setEnabled(false);
121 }
122 
123 void
125 {
126  ARMARX_TRACE;
127  verbose = true;
128 
129  visu = new SoSeparator();
130  visu->ref();
131 
132  connectSlots();
133 
134  ARMARX_INFO << "PriorMemory: " << settings_priorMemory;
135 
136  usingProxy(settings_priorMemory);
137  usingProxy("CommonStorage");
138  if (!settings_robotStateComponentProxyName.empty())
139  {
140  usingProxy(settings_robotStateComponentProxyName);
141  }
142 }
143 
144 void
146 {
147  ARMARX_TRACE;
148  memoryPrx = getProxy<PriorKnowledgeInterfacePrx>(settings_priorMemory);
149  classesSegmentPrx = memoryPrx->getObjectClassesSegment();
150  databasePrx = memoryPrx->getCommonStorage();
151  if (!settings_robotStateComponentProxyName.empty())
152  {
153  getProxy(robotStateComponent, settings_robotStateComponentProxyName);
154  }
155 
156  fileManager.reset(new GridFileManager(databasePrx));
157 
158  ui.editHost->setText(QString::fromStdString(databasePrx->getMongoHostAndPort()));
159 
160  connected = databasePrx->isConnected();
161 
162  refreshControls();
163  refreshCollectionList();
164  setCurrentCollection(classesSegmentPrx->getWriteCollectionNS());
165  enableMainWidgetAsync(true);
166 }
167 
168 void
170 {
171  ARMARX_TRACE;
172  dialog->close();
173  collCreateDialog->close();
174  connected = false;
175  refreshControls();
176  enableMainWidgetAsync(false);
177 }
178 
179 void
181 {
182  ARMARX_TRACE;
183  clearObjects();
184 
185  if (visu)
186  {
187  visu->unref();
188  }
189 }
190 
191 QPointer<QDialog>
193 {
194  if (!dialog)
195  {
196  dialog = new PriorEditorConfigDialog(getIceManager(), parent);
197  dialog->ui->editPriorMemoryEditorName->setText(
198  QString::fromStdString(DEFAULT_SETTINGS_PLUGIN_NAME));
199  dialog->ui->editPriorMemoryName->setText(
200  QString::fromStdString(DEFAULT_SETTINGS_PRIORMEMORY_NAME));
201  }
202 
203  return qobject_cast<PriorEditorConfigDialog*>(dialog);
204 }
205 
206 void
208 {
209  ARMARX_VERBOSE << "PriorEditorController::configured()";
210  settings_mongoHost = dialog->ui->editMongoHost->text().toStdString();
211  settings_mongoUser = dialog->ui->editMongoUser->text().toStdString();
212  settings_mongoPass = dialog->ui->editMongoPass->text().toStdString();
213  settings_priorMemory = dialog->ui->editPriorMemoryName->text().toStdString();
214  this->setInstanceName(dialog->ui->editPriorMemoryEditorName->text());
215  settings_robotStateComponentProxyName =
216  dialog->proxyFinder->getSelectedProxyName().toStdString();
217 
218  // ???
219  // databasePrx->reconnect(ui.editHost->text().toStdString(), settings_mongoUser, settings_mongoPass);
220 }
221 
222 void
224 {
225  /*robotFile = settings->value("RobotFile", QString::fromStdString(robotFile_default)).toString().toStdString();
226  objectFile = settings->value("ObjectFile", QString::fromStdString(objectFile_default)).toString().toStdString();
227  show3DViewer = settings->value("ViewerEnabled", "false") == "true";*/
228 }
229 
230 void
232 {
233  /*settings->setValue("RobotFile", QString::fromStdString(robotFile));
234  settings->setValue("ObjectFile", QString::fromStdString(objectFile));
235  settings->setValue("ViewerEnabled", QString(show3DViewer?"true":"false"));*/
236 }
237 
238 SoNode*
240 {
241  ARMARX_TRACE;
242  if (visu)
243  {
244  std::cout << "returning scene=" << visu->getName() << std::endl;
245  }
246 
247  return visu;
248 }
249 
250 void
252 {
253  ARMARX_TRACE;
254  connect(ui.btnReconnect, SIGNAL(clicked()), this, SLOT(reconnect()));
255 
256  connect(ui.btnAddCollection, SIGNAL(clicked()), this, SLOT(addCollection()));
257  connect(ui.btnRefetch, SIGNAL(clicked()), this, SLOT(refetchData()));
258 
259  connect(ui.cbCollection,
260  SIGNAL(currentIndexChanged(int)),
261  this,
262  SLOT(collectionChanged()),
263  Qt::QueuedConnection);
264 
265  connect(ui.btnShowVisu, SIGNAL(clicked()), this, SLOT(showObjectClassVisu()));
266  connect(ui.btnShowColl, SIGNAL(clicked()), this, SLOT(showObjectClassColl()));
267  connect(ui.btnEdit, SIGNAL(clicked()), this, SLOT(editObjectClass()));
268  connect(ui.btnAdd, SIGNAL(clicked()), this, SLOT(addObjectClass()));
269  connect(ui.btnRemove, SIGNAL(clicked()), this, SLOT(removeObjectClass()));
270  connect(this, SIGNAL(objectsLoaded()), this, SLOT(clearVisualization()), Qt::QueuedConnection);
271  // connect(this, SIGNAL(objectChanged(QString, bool)), this, SLOT(updateObjectVisu(QString, bool)), Qt::QueuedConnection);
272 
273  connect(ui.treeWidgetEntities,
274  SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
275  this,
276  SLOT(treeCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
277  connect(ui.treeWidgetEntities,
278  SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
279  this,
280  SLOT(treeItemDoubleClicked(QTreeWidgetItem*, int)));
281 }
282 
283 void
285 {
286  ARMARX_TRACE;
287  clearObjects();
288  connected = databasePrx->reconnect(
289  ui.editHost->text().toStdString(), settings_mongoUser, settings_mongoPass);
290  refreshControls();
291 
292  if (!connected)
293  {
294  QMessageBox msgBox;
295  msgBox.setText("Error connecting to MongoDB! \nCheck if mongod is running on " +
296  ui.editHost->text());
297  msgBox.setIcon(QMessageBox::Critical);
298  msgBox.exec();
299  }
300 
301  refreshCollectionList();
302 }
303 
304 void
305 PriorEditorController::setCurrentCollection(const std::string& collNS)
306 {
307  ARMARX_TRACE;
308  ui.cbCollection->setCurrentIndex(ui.cbCollection->findText(QString::fromStdString(collNS)));
309 }
310 
311 void
313 {
314  ARMARX_TRACE;
315  const std::string collName = ui.cbCollection->currentText().toStdString();
316 
317  if (!collName.empty())
318  {
319  CollectionInterfacePrx coll = databasePrx->requestCollection(collName);
320  classesSegmentPrx->setWriteCollection(coll);
321  refetchData();
322  }
323 }
324 
325 void
327 {
328  ARMARX_TRACE;
329  const NameList dbNames = databasePrx->getDBNames();
330  collCreateDialog->setDatabases(dbNames);
331  int result = collCreateDialog->exec();
332 
333  if (result == QDialog::Accepted)
334  {
335  const std::string collectionNS =
336  collCreateDialog->getDBName() + "." + collCreateDialog->getCollectionName();
337  ui.cbCollection->addItem(QString::fromStdString(collectionNS));
338  setCurrentCollection(collectionNS);
339  }
340 }
341 
342 void
344 {
345  ARMARX_TRACE;
346  const std::string collName = ui.cbCollection->currentText().toStdString();
347  ARMARX_INFO << "Refetching data from DB from collection '" << collName << "'";
348  std::unique_lock lock(mutexEntities);
349  clearObjects();
350 
351  auto collection = databasePrx->requestCollection(collName);
352  auto ids = collection->findAllIds();
353  ARMARX_INFO << "Found " << ids.size() << " entities";
354 
355  // classesSegmentPrx->addReadCollection(collName);
356  for (const auto& id : ids)
357  {
358  EntityBasePtr entity = classesSegmentPrx->getEntityById(id);
359 
360  if (!entity)
361  {
362  ARMARX_WARNING << "Could not find entity with id " << id << " in collection "
363  << collName;
364  }
365 
366  const ObjectClassPtr objClass = ObjectClassPtr::dynamicCast(entity);
367 
368  if (objClass)
369  {
370  updateObject(objClass);
371  }
372  else
373  {
374  ARMARX_WARNING << "Failed to cast to ObjectClass: " << entity->getName() << ", "
375  << entity->getId() << ", " << entity->ice_id();
376  }
377  }
378 
379 
380  ui.treeWidgetEntities->sortByColumn(0, Qt::AscendingOrder);
381 
382  emit objectsLoaded();
383 }
384 
385 void
386 PriorEditorController::refreshCollectionList()
387 {
388  ARMARX_TRACE;
389  ui.cbCollection->clear();
390 
391  if (!connected)
392  {
393  return;
394  }
395 
396  auto activeReadCollectionNames = memoryPrx->getObjectClassesSegment()->getReadCollectionsNS();
397  const NameList dbNames = databasePrx->getDBNames();
398  int firstActiveCollection = -1;
399 
400  for (std::string const& dbName : dbNames)
401  {
402  const NameList collNames = databasePrx->getCollectionNames(dbName);
403 
404  for (std::string const& collName : collNames)
405  {
406  std::string fullCollName = dbName + "." + collName;
407  if (memoryPrx->isPriorCollection(fullCollName))
408  {
409  if (std::find(activeReadCollectionNames.begin(),
410  activeReadCollectionNames.end(),
411  fullCollName) != activeReadCollectionNames.end())
412  {
413  ui.cbCollection->addItem(QString::fromStdString(fullCollName));
414 
415  if (firstActiveCollection == -1)
416  {
417  firstActiveCollection = ui.cbCollection->count() - 1;
418  }
419  }
420  else
421  {
422  ui.cbCollection->addItem(QString::fromStdString(
423  collName + "(not selected in PriorKnowledge config)"));
424  const QStandardItemModel* model =
425  qobject_cast<const QStandardItemModel*>(ui.cbCollection->model());
427  QStandardItem* item = model->item(model->rowCount() - 1);
429 
430  item->setFlags(item->flags() & ~(Qt::ItemIsSelectable | Qt::ItemIsEnabled));
431  // visually disable by greying out - works only if combobox has been painted already and palette returns the wanted color
432  item->setData(
433  ui.cbCollection->palette().color(
434  QPalette::Disabled,
435  QPalette::Text), // clear item data in order to use default color
436  Qt::TextColorRole);
437  }
438  }
439  }
440  }
441 
442  if (ui.cbCollection->currentIndex() >= 0)
443  {
444  const QStandardItemModel* model =
445  qobject_cast<const QStandardItemModel*>(ui.cbCollection->model());
447  QStandardItem* item = model->item(ui.cbCollection->currentIndex());
449 
450  if (!(item->flags() & Qt::ItemIsEnabled))
451  {
452  ui.cbCollection->setCurrentIndex(firstActiveCollection);
453  }
454  }
455  else
456  {
457  ui.cbCollection->setCurrentIndex(firstActiveCollection);
458  }
459 }
460 
461 void
463 {
464  ARMARX_TRACE;
465  doEditClass(true);
466 }
467 
468 void
470 {
471  ARMARX_TRACE;
472  doEditClass(false);
473 }
474 
475 void
476 PriorEditorController::doEditClass(bool isNew)
477 {
478  ARMARX_TRACE;
479  ARMARX_INFO << "Opening edit dialog...";
480 
481  // init object class
482  const std::string clsId = getSelectedClassId();
483  ObjectClassPtr objectClass;
484 
485  if (isNew)
486  {
487  objectClass = new ObjectClass();
488  objectClass->addWrapper(new SimoxObjectWrapper(fileManager));
489  objectClass->addWrapper(new ObjectRecognitionWrapper());
490  objectClass->addWrapper(new TexturedRecognitionWrapper(fileManager));
491  objectClass->addWrapper(new SegmentableRecognitionWrapper(fileManager));
492  objectClass->addWrapper(new HandMarkerBallWrapper(fileManager));
493  objectClass->addWrapper(new ArMarkerWrapper(fileManager));
494  }
495  else
496  {
497  objectClass = currentObjectClasses[clsId];
498  }
499 
500 
501  // create dialog
502  ObjectClassEditDialog* classEditDialog = new ObjectClassEditDialog(robotStateComponent);
503 
504  if (!isNew)
505  {
506  // do not allow changeing of existing classes names
507  classEditDialog->setClassNameEditable(false);
508  classEditDialog->updateGui(objectClass);
509  }
510 
511  int result = classEditDialog->exec();
512 
513  if (result == QDialog::Accepted)
514  {
515  ARMARX_INFO << "Saving changes to object class...";
517 
518  classEditDialog->updateEntity(objectClass, getFilesDBName());
519 
520  // update memory segment
521  if (isNew)
522  {
523  const std::string id = classesSegmentPrx->addEntity(objectClass);
524  objectClass->setId(id);
525  currentObjectClasses[id] = objectClass;
526  }
527  else
528  {
529  classesSegmentPrx->updateEntity(objectClass->getId(), objectClass);
530  }
531 
532  updateObjectInTree(objectClass);
533  classEditDialog->updateGui(objectClass);
534  }
535 
536  delete classEditDialog;
537 }
538 
539 void
541 {
542  ARMARX_TRACE;
543  const std::string clsName = getSelectedClassName();
544  const std::string clsId = getSelectedClassId();
545 
546  if (clsId.empty())
547  {
548  return;
549  }
550 
551  QMessageBox msgBox;
552  msgBox.setText("Delete object class " + QString(clsName.c_str()) + "?");
553  msgBox.setIcon(QMessageBox::Question);
554  msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
555  int ret = msgBox.exec();
556 
557  if (ret == QMessageBox::Yes)
558  {
559  ObjectEntryMap::iterator it = currentObjectClasses.find(clsId);
560 
561  if (it != currentObjectClasses.end())
562  {
563  it->second->getWrapper<SimoxObjectWrapper>()->clear();
564  currentObjectClasses.erase(it);
565  }
566 
567  classesSegmentPrx->removeEntity(clsId);
568  QTreeWidgetItem* selItem = ui.treeWidgetEntities->currentItem();
569 
570  if (selItem)
571  {
572  delete ui.treeWidgetEntities->takeTopLevelItem(
573  ui.treeWidgetEntities->indexOfTopLevelItem(selItem));
574  }
575 
577  }
578 }
579 
580 std::string
581 PriorEditorController::getSelectedClassId()
582 {
583  ARMARX_TRACE;
584  QTreeWidgetItem* selItem = ui.treeWidgetEntities->currentItem();
585 
586  if (selItem && selItem->type() == TreeItemType::eItemObject)
587  {
588  return selItem->text(1).toStdString();
589  }
590  else
591  {
592  return "";
593  }
594 }
595 
596 std::string
597 PriorEditorController::getSelectedClassName()
598 {
599  ARMARX_TRACE;
600  QTreeWidgetItem* selItem = ui.treeWidgetEntities->currentItem();
601 
602  if (selItem && selItem->type() == TreeItemType::eItemObject)
603  {
604  return selItem->text(0).toStdString();
605  }
606  else
607  {
608  return "";
609  }
610 }
611 
612 void
613 PriorEditorController::refreshControls()
614 {
615  ARMARX_TRACE;
616  ui.lblConnected->setText(QString::fromStdString(connected ? "Connected" : "Disconnected"));
617  ui.lblConnected->setStyleSheet(
618  QString::fromStdString(connected ? "color: rgb(0, 170, 0);" : "color: rgb(170, 0, 0);"));
619 
620  ui.btnAddCollection->setEnabled(connected);
621  ui.btnRefetch->setEnabled(connected);
622 
623  QTreeWidgetItem* cur = ui.treeWidgetEntities->currentItem();
624  bool clsSelected = connected && (cur && cur->type() == TreeItemType::eItemObject);
625  ui.btnAdd->setEnabled(connected);
626  ui.btnEdit->setEnabled(clsSelected);
627  ui.btnRemove->setEnabled(clsSelected);
628  ui.btnShowVisu->setEnabled(clsSelected);
629  ui.btnShowColl->setEnabled(clsSelected);
630 }
631 
632 void
633 PriorEditorController::treeCurrentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev)
634 {
635  ARMARX_TRACE;
636  refreshControls();
637 }
638 
639 void
640 PriorEditorController::treeItemDoubleClicked(QTreeWidgetItem* item, int column)
641 {
642  ARMARX_TRACE;
643  if (item->type() == TreeItemType::eItemObject)
644  {
645  ARMARX_INFO << " Selected object: " << item->text(1).toStdString();
646  showObjectClassModel(item->text(1).toStdString(), SceneObject::Full);
647  }
648 }
649 
650 std::string
651 PriorEditorController::getFilesDBName()
652 {
653  ARMARX_TRACE;
654  const std::string ns = classesSegmentPrx->getWriteCollectionNS();
655  const size_t found = ns.find_first_of('.');
656  return (found != std::string::npos) ? ns.substr(0, found) : "";
657 }
658 
659 void
660 PriorEditorController::updateObjectInTree(ObjectClassPtr obj)
661 {
662  ARMARX_TRACE;
663  QString objName(obj->getName().c_str());
664  QString objId(obj->getId().c_str());
665 
666  QList<QTreeWidgetItem*> oldItems =
667  ui.treeWidgetEntities->findItems(objId, Qt::MatchFixedString, 1);
668 
669  QTreeWidgetItem* objItem =
670  (oldItems.size() == 0)
671  ? new QTreeWidgetItem(ui.treeWidgetEntities, TreeItemType::eItemObject)
672  : oldItems.at(0);
673  objItem->setText(0, objName);
674  objItem->setText(1, objId);
675 
676  // clear object node
677  /* QList<QTreeWidgetItem *> oldAttrs = objItem->takeChildren();
678  while(!oldAttrs.empty())
679  delete oldAttrs.takeFirst();
680 
681  QBrush evenRow(QColor(217, 255, 226)), oddRow(Qt::white);
682  int i = 0;
683  memoryx::NameList attrNames = obj->getAttributeNames();
684  for (memoryx::NameList::const_iterator it = attrNames.begin(); it != attrNames.end(); ++it)
685  {
686  // QList<QTreeWidgetItem *> oldAttrs = objItem->findItems(objId, Qt::MatchFixedString, 0);
687  QTreeWidgetItem *attrItem = new QTreeWidgetItem(objItem, TreeItemType::eItemAttr);
688  armarx::VariantPtr attrValue = obj->getAttributeMean(*it);
689  QString attrName(it->c_str());
690  QString attrValStr(attrValue->getOutputValueOnly().c_str());
691  QBrush& bgBrush = (i % 2 == 0) ? evenRow : oddRow;
692  attrItem->setText(0, attrName);
693  attrItem->setText(1, attrValStr);
694  attrItem->setBackground(0, bgBrush);
695  attrItem->setBackground(1, bgBrush);
696  ++i;
697  }*/
698 }
699 
700 void
702 {
703  ARMARX_TRACE;
704  if (!objClass)
705  {
706  return;
707  }
708 
709  std::unique_lock lock(mutexEntities);
710 
711  const std::string id = objClass->getId();
712 
713  if (force || currentObjectClasses.find(id) == currentObjectClasses.end())
714  {
715  // build new entry
716  ARMARX_INFO << "Building new entry for object class " << objClass->getName();
717  objClass->addWrapper(new SimoxObjectWrapper(fileManager));
718  objClass->addWrapper(new ObjectRecognitionWrapper());
719  objClass->addWrapper(new TexturedRecognitionWrapper(fileManager));
720  objClass->addWrapper(new SegmentableRecognitionWrapper(fileManager));
721  objClass->addWrapper(new HandMarkerBallWrapper(fileManager));
722  objClass->addWrapper(new ArMarkerWrapper(fileManager));
723 
724  currentObjectClasses[id] = objClass;
725  }
726 
727  updateObjectInTree(objClass);
728 }
729 
730 void
731 PriorEditorController::showObjectClassModel(const std::string& objectId,
732  SceneObject::VisualizationType visuType)
733 {
734  ARMARX_TRACE;
735  std::unique_lock lock(mutexEntities);
736  ObjectEntryMap::iterator it = currentObjectClasses.find(objectId);
737 
738  if (it == currentObjectClasses.end())
739  {
740  ARMARX_TRACE;
741  return;
742  }
743 
744  // no rotation/translation
746  SimoxObjectWrapperPtr simoxWrapper = it->second->getWrapper<SimoxObjectWrapper>();
747 
748  ARMARX_TRACE;
749  auto mo = simoxWrapper->getManipulationObject();
750 
751  ARMARX_TRACE;
752  mo->setGlobalPose(m);
753  mo->showCoordinateSystem(true);
754 
756  VisualizationNodePtr visNode;
757 
758  if (visuType == SceneObject::Full)
759  {
760  ARMARX_TRACE;
761  visNode = simoxWrapper->getVisualization();
762  }
763  else if (visuType == SceneObject::Collision && simoxWrapper->getCollisionModel())
764  {
765  ARMARX_TRACE;
766  visNode = simoxWrapper->getCollisionModel()->getVisualization();
767  }
768 
769  if (visu && visNode)
770  {
771  ARMARX_TRACE;
772  visu->addChild(VirtualRobot::CoinVisualizationFactory::getCoinVisualization(visNode));
773  }
774 }
775 
776 void
778 {
779  ARMARX_TRACE;
780  showObjectClassModel(getSelectedClassId(), SceneObject::Full);
781 }
782 
783 void
785 {
786  ARMARX_TRACE;
787  showObjectClassModel(getSelectedClassId(), SceneObject::Collision);
788 }
789 
790 void
792 {
793  ARMARX_TRACE;
794  std::unique_lock lock(mutexEntities);
795 
796  // clear storage
797  currentObjectClasses.clear();
798 
799  // clear SceneTree
800  ui.treeWidgetEntities->clear();
801 }
802 
803 void
805 {
806  ARMARX_TRACE;
807  visu->removeAllChildren();
808 }
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::ManagedIceObject::getIceManager
IceManagerPtr getIceManager() const
Returns the IceManager.
Definition: ManagedIceObject.cpp:366
TreeItemType::TreeItemTypeEnum
TreeItemTypeEnum
Definition: PriorMemoryEditorPlugin.cpp:97
armarx::aron::ret
ReaderT::InputType T & ret
Definition: rw.h:13
memoryx::CollectionCreateDialog
Definition: CollectionCreateDialog.h:37
TreeItemType::eItemObject
@ eItemObject
Definition: PriorMemoryEditorPlugin.cpp:99
memoryx::PriorEditorController::updateObject
void updateObject(const memoryx::ObjectClassPtr obj, bool force=false)
Definition: PriorMemoryEditorPlugin.cpp:701
memoryx::PriorEditorController::addCollection
void addCollection()
Definition: PriorMemoryEditorPlugin.cpp:326
VirtualRobot
Definition: FramedPose.h:42
memoryx::PriorEditorController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: PriorMemoryEditorPlugin.cpp:145
memoryx::PriorEditorController::show3DViewer
bool show3DViewer
Definition: PriorMemoryEditorPlugin.h:203
string.h
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
memoryx::PriorEditorController::visu
SoSeparator * visu
Definition: PriorMemoryEditorPlugin.h:205
Pose.h
memoryx::PriorEditorController::showObjectClassColl
void showObjectClassColl()
Definition: PriorMemoryEditorPlugin.cpp:784
TreeItemType::eItemAttr
@ eItemAttr
Definition: PriorMemoryEditorPlugin.cpp:100
memoryx::PriorEditorController::reconnect
void reconnect()
Definition: PriorMemoryEditorPlugin.cpp:284
trace.h
memoryx::PriorEditorController::addObjectClass
void addObjectClass()
Definition: PriorMemoryEditorPlugin.cpp:462
GridFileManager.h
memoryx::ObjectClassEditDialog
Definition: ObjectClassEditDialog.h:43
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
memoryx::PriorEditorController::configured
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
Definition: PriorMemoryEditorPlugin.cpp:207
ObjectRecognitionWrapper.h
memoryx::PriorEditorController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: PriorMemoryEditorPlugin.cpp:180
memoryx::PriorEditorController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: PriorMemoryEditorPlugin.cpp:231
memoryx::PriorEditorController::clearVisualization
void clearVisualization()
Definition: PriorMemoryEditorPlugin.cpp:804
memoryx::EntityWrappers::SegmentableRecognitionWrapper
SegmentableRecognitionWrapper offers a simplified access to the data of an object class or instance r...
Definition: ObjectRecognitionWrapper.h:85
memoryx::PriorEditorController::PriorEditorController
PriorEditorController()
Definition: PriorMemoryEditorPlugin.cpp:110
memoryx::PriorEditorController::collectionChanged
void collectionChanged()
Definition: PriorMemoryEditorPlugin.cpp:312
memoryx::PriorEditorController::connectSlots
void connectSlots()
Definition: PriorMemoryEditorPlugin.cpp:251
IceInternal::Handle< ObjectClass >
memoryx::ObjectClassEditDialog::updateGui
void updateGui(const EntityPtr &entity) override
Pure virtual method.
Definition: ObjectClassEditDialog.cpp:69
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
memoryx::PriorEditorController::currentObjectClasses
ObjectEntryMap currentObjectClasses
Definition: PriorMemoryEditorPlugin.h:202
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
memoryx::PriorEditorController::treeItemDoubleClicked
void treeItemDoubleClicked(QTreeWidgetItem *item, int column)
Definition: PriorMemoryEditorPlugin.cpp:640
memoryx::PriorEditorController::verbose
bool verbose
Definition: PriorMemoryEditorPlugin.h:199
CollectionCreateDialog.h
memoryx::ObjectClassEditDialog::setClassNameEditable
void setClassNameEditable(bool editable)
Definition: ObjectClassEditDialog.cpp:63
memoryx::PriorEditorController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: PriorMemoryEditorPlugin.cpp:124
memoryx::PriorEditorController::objectsLoaded
void objectsLoaded()
memoryx::EntityWrappers::TexturedRecognitionWrapper
TexturedRecognitionWrapper offers a simplified access to the data of an object class or instance rela...
Definition: ObjectRecognitionWrapper.h:63
ObjectClassEditDialog.h
PriorEditorConfigDialog.h
MemoryXCoreObjectFactories.h
memoryx::PriorEditorController::ui
Ui::PriorMemoryEditorPlugin ui
Definition: PriorMemoryEditorPlugin.h:197
memoryx::ObjectClass
Definition: ObjectClass.h:37
memoryx::PriorEditorController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: PriorMemoryEditorPlugin.cpp:223
memoryx::PriorEditorController::treeCurrentItemChanged
void treeCurrentItemChanged(QTreeWidgetItem *cur, QTreeWidgetItem *prev)
Definition: PriorMemoryEditorPlugin.cpp:633
memoryx::EntityWrappers::SimoxObjectWrapper
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
Definition: SimoxObjectWrapper.h:46
armarx::ArmarXWidgetController::setInstanceName
bool setInstanceName(QString instanceName)
sets the name of this instance.
Definition: ArmarXWidgetController.cpp:107
memoryx::PriorEditorController::editObjectClass
void editObjectClass()
Definition: PriorMemoryEditorPlugin.cpp:469
TreeItemType::eItemValue
@ eItemValue
Definition: PriorMemoryEditorPlugin.cpp:101
memoryx::PriorEditorConfigDialog
Definition: PriorEditorConfigDialog.h:41
SimoxObjectWrapper.h
No
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics No
Definition: ReadMe.txt:21
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
memoryx::EntityWrappers
Definition: AbstractEntityWrapper.cpp:30
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::ArmarXWidgetController::enableMainWidgetAsync
void enableMainWidgetAsync(bool enable)
This function enables/disables the main widget asynchronously (if called from a non qt thread).
Definition: ArmarXWidgetController.cpp:191
memoryx::PriorEditorController::getScene
SoNode * getScene() override
Reimplementing this function and returning a SoNode* will show this SoNode in the 3DViewerWidget,...
Definition: PriorMemoryEditorPlugin.cpp:239
DEFAULT_SETTINGS_PLUGIN_NAME
#define DEFAULT_SETTINGS_PLUGIN_NAME
Definition: PriorMemoryEditorPlugin.cpp:92
GfxTL::Yes
OnOff< true > Yes
Definition: OnOff.h:14
memoryx::EntityWrappers::ObjectRecognitionWrapper
Definition: ObjectRecognitionWrapper.h:40
memoryx::GridFileManager
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
Definition: GridFileManager.h:41
memoryx::PriorEditorController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: PriorMemoryEditorPlugin.cpp:169
MemoryXTypesObjectFactories.h
armarx::ArmarXWidgetController::getWidget
virtual QPointer< QWidget > getWidget()
getWidget returns a pointer to the a widget of this controller.
Definition: ArmarXWidgetController.cpp:54
memoryx::ObjectClassEditDialog::updateEntity
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
Definition: ObjectClassEditDialog.cpp:88
memoryx::PriorEditorController::removeObjectClass
void removeObjectClass()
Definition: PriorMemoryEditorPlugin.cpp:540
PriorMemoryEditorPlugin.h
memoryx::EntityWrappers::ArMarkerWrapper
ArMarkerWrapper offers a simplified access to the necessary information for localization of AR marker...
Definition: ObjectRecognitionWrapper.h:131
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
DEFAULT_SETTINGS_PRIORMEMORY_NAME
#define DEFAULT_SETTINGS_PRIORMEMORY_NAME
Definition: PriorMemoryEditorPlugin.cpp:93
armarx::ManagedIceObject::getProxy
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
Definition: ManagedIceObject.cpp:407
ArmarXDataPath.h
memoryx::PriorEditorController::refetchData
void refetchData()
Definition: PriorMemoryEditorPlugin.cpp:343
memoryx::PriorEditorController::getConfigDialog
QPointer< QDialog > getConfigDialog(QWidget *parent=0) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
Definition: PriorMemoryEditorPlugin.cpp:192
TreeItemType
Definition: PriorMemoryEditorPlugin.cpp:95
memoryx::PriorMemoryEditorPlugin::PriorMemoryEditorPlugin
PriorMemoryEditorPlugin()
Definition: PriorMemoryEditorPlugin.cpp:105
armarx::ManagedIceObject::usingProxy
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
Definition: ManagedIceObject.cpp:154
memoryx::PriorEditorController::showObjectClassVisu
void showObjectClassVisu()
Definition: PriorMemoryEditorPlugin.cpp:777
memoryx::PriorEditorController::clearObjects
void clearObjects()
Definition: PriorMemoryEditorPlugin.cpp:791
memoryx::EntityWrappers::HandMarkerBallWrapper
HandMarkerBallWrapper offers a simplified access to the necessary information for localization of the...
Definition: ObjectRecognitionWrapper.h:110