ArmarXManagerModel.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 ArmarX::Gui
19  * @author Jan Issac ( jan.issac at gmail dot com)
20  * @date 2012
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 
26 #include "ArmarXManagerModel.h"
27 
28 #include <fstream>
29 
30 #include <QFileSystemModel>
31 #include <QStandardItem>
32 
33 #include <Ice/Connection.h>
34 
35 #include <SimoxUtility/algorithm/string/string_tools.h>
36 
38 
41 
42 #include "ManagedIceObjectItem.h"
43 
44 #define LiveMetaInfoDescriptionString "Live Meta Information"
45 
46 namespace armarx
47 {
49  {
50  connect(this, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateItem(QStandardItem*)));
51  }
52 
54  {
55  }
56 
58  ArmarXManagerModel::getItem(int row, int column) const
59  {
60  return dynamic_cast<ArmarXManagerItem*>(QStandardItemModel::item(row, column));
61  }
62 
65  {
66  CHECK_QT_THREAD(this);
67 
68  ArmarXManagerItem* item;
69 
70  for (int i = 0; i < this->rowCount(); i++)
71  {
72  item = this->getItem(i);
73 
74  if (item->getName().compare(name) == 0)
75  {
76  return item;
77  }
78  }
79 
80  return nullptr;
81  }
82 
85  {
86  CHECK_QT_THREAD(this);
87 
88  ManagerPrxMap result;
89  ArmarXManagerItem* item;
90  // ARMARX_IMPORTANT << this->rowCount();
91  for (int i = 0; i < this->rowCount(); i++)
92  {
93  item = this->getItem(i);
94  if (!item->getManagerProxy())
95  {
96  try
97  {
98  ARMARX_DEBUG << item->getName().toStdString();
99  auto proxy = getIceManager()->getProxy<ArmarXManagerInterfacePrx>(
100  item->getName().toStdString());
101  ARMARX_DEBUG << item->getName().toStdString() << " done";
102  item->setManagerProxy(ArmarXManagerInterfacePrx::uncheckedCast(proxy));
103  }
104  catch (...)
105  {
107  }
108  }
109  result[item->getName()] = item->getManagerProxy();
110  }
111  return result;
112  }
113 
115  ArmarXManagerModel::getManagerProxyMap(const QStringList& managerNames) const
116  {
117  ManagerPrxMap result;
118  // ARMARX_IMPORTANT << this->rowCount();
119  for (auto& name : managerNames)
120  {
121  try
122  {
123  ARMARX_DEBUG << name.toStdString();
124  auto proxy =
125  getIceManager()->getProxy<ArmarXManagerInterfacePrx>(name.toStdString());
126  ARMARX_DEBUG << name.toStdString() << " done";
127  result[name] = proxy;
128  }
129  catch (...)
130  {
132  }
133  }
134 
135 
136  return result;
137  }
138 
139  void
141  const ArmarXManagerItem::ManagerDataMap& managerDataMap,
142  bool deactivateIfMissing)
143  {
144  CHECK_QT_THREAD(this);
145  dependenciesMap.clear();
146  IceUtil::Time start = IceUtil::Time::now();
147 
148  std::map<std::string, std::vector<QString>> offererMap;
149  std::map<std::string, std::vector<QString>> listenerMap;
150  // iterate over all manager items
151  for (int i = 0; i < this->rowCount(); i++)
152  {
153  ArmarXManagerItem* item = this->getItem(i);
154  // ARMARX_DEBUG << deactivateSpam(1, item->getName().toStdString()) << "Checking " << item->getName().toStdString();
155  // ARMARX_INFO << "Checking " << item->getName().toStdString();
156  // for (auto& element : item->getObjects())
157  // {
158  // DependencyMap depMap = element.connectivity.dependencies;
159  // // ARMARX_INFO << "Checking sub item " << element.name.toStdString() << " with " << depMap.size() << " dependencies";
160  // if (depMap.size() > 0)
161  // {
162  // dependenciesMap[toStdString()] = depMap;
163  // }
164  // }
165 
166  auto it = managerDataMap.find(item->getName());
167  if (it == managerDataMap.end())
168  {
169  ARMARX_INFO << deactivateSpam(15, item->getName().toStdString()) << "Didnt find "
170  << item->getName().toStdString();
171  if (deactivateIfMissing)
172  {
173  item->setOnline(false);
174  }
175  continue;
176  }
177  else
178  {
179  item->setOnline(it->second.online);
180  }
181 
182  item->setConnection(it->second.connection);
183  item->setEndpointStr(it->second.endpointStr);
184  // ARMARX_DEBUG << deactivateSpam(1, item->getName().toStdString()) << "endpoint: " << it->second.endpointStr;
185 
186  if (!item->getManagerProxy() && !it->second.proxy)
187  {
188  ARMARX_INFO << "Proxy for " << item->getName().toStdString() << " is null";
189  item->setOnline(false);
190  continue;
191  }
192  if (it->second.proxy)
193  {
194  item->setManagerProxy(it->second.proxy);
195  }
196  item->setAppProperties(it->second.appProperties);
197 
198  const ArmarXManagerItem::ObjectMap& updates = it->second.objects;
199  ArmarXManagerItem::ObjectMap& objects = item->getObjects();
200  for (int j = 0; j < updates.size(); j++)
201  {
202  QString objName = updates.keys().at(j);
203  const ManagedIceObjectItem& updateItem = updates[objName];
204  ManagedIceObjectItem& objItem = objects[objName];
205  objItem.connectivity = updateItem.connectivity;
206  objItem.state = updateItem.state;
207  objItem.properties = updateItem.properties;
208  objItem.metaInfoMap = updateItem.metaInfoMap;
209  for (const auto& topic : objItem.connectivity.offeredTopics)
210  {
211  offererMap[topic].push_back(objName);
212  }
213  for (const auto& topic : objItem.connectivity.usedTopics)
214  {
215  listenerMap[topic].push_back(objName);
216  }
217  if (objItem.connectivity.dependencies.size() > 0)
218  {
219  dependenciesMap[objName.toStdString()] = objItem.connectivity.dependencies;
220  }
221  }
222  }
223  // std::set<std::string> offeredTopics = armarx::getMapKeys(offererMap);
224  // ARMARX_INFO << deactivateSpam(10) << VAROUT(listenerMap) << "\n" << VAROUT(offererMap);
225  // iterate over all manager items
226  for (int i = 0; i < this->rowCount(); i++)
227  {
228  ArmarXManagerItem* item = this->getItem(i);
229  item->setEditable(false);
230 
231  QBrush managerBrush;
232 
233  if (!item->isOnline())
234  {
235  managerBrush.setStyle(Qt::SolidPattern);
236  managerBrush.setColor(Qt::lightGray);
237  item->clear(false);
238  }
239  else
240  {
241  managerBrush.setColor(Qt::transparent);
242  }
243 
244  item->setBackground(managerBrush);
245 
246  auto addPropertiesToItem =
247  [](ObjectPropertyInfos const& properties, QStandardItem* item)
248  {
249  if (!properties.empty())
250  {
251  QStandardItem* objectPropertiesItem = new QStandardItem("Properties");
252  objectPropertiesItem->setEditable(false);
253 
254  QList<QStandardItem*> objectPropertiesRow;
255 
256  for (auto property : properties)
257  {
258  QStandardItem* objectPropertyItem =
259  new QStandardItem(QString("%1 %2: %3")
260  .arg(property.first.c_str())
261  .arg(property.second.constant ? "(constant)" : "")
262  .arg(property.second.value.c_str()));
263  objectPropertyItem->setEditable(!property.second.constant);
264  if (!property.second.constant)
265  {
266  objectPropertyItem->setToolTip(
267  "Double-click to edit this property and to send the updated "
268  "property to the component.");
269  }
270  objectPropertiesRow.append(objectPropertyItem);
271  }
272 
273  objectPropertiesItem->appendRows(objectPropertiesRow);
274  item->appendRow(objectPropertiesItem);
275  }
276  };
277 
278  if (item->rowCount() == 0 && item->isOnline()) // only when app is coming (back) online
279  {
280  auto applicationItem = new QStandardItem("Application Properties");
281  applicationItem->setData((int)ApplicationRowType::ApplicationProperties,
283  applicationItem->setEditable(false);
284  try
285  {
286 
287  auto& properties =
288  item->getAppProperties(); //item->getManagerProxy()->ice_timeout(1000)->getApplicationPropertyInfos();
289  addPropertiesToItem(properties, applicationItem);
290  item->appendRow(applicationItem);
291  }
292  catch (...)
293  {
294  }
295  }
296 
297  ArmarXManagerItem::ObjectMap& objects = item->getObjects();
298  // iterate over all ManagedIceObjectItems controlled by the manager
299  for (int j = 0; j < objects.size(); j++)
300  {
301  QString objName = objects.keys().at(j);
302 
303 
304  ManagedIceObjectItem& objItem = objects[objName];
305  if (!objItem.item)
306  {
307  objItem.item = new QStandardItem(objName);
308  objItem.item->setEditable(false);
309 
310  item->appendRow(objItem.item);
311 
312  auto& properties = objItem.properties;
313 
314  // iterate over all properties and add them as a separate subentry
315 
316  addPropertiesToItem(properties, objItem.item);
317 
318  QStandardItem* metaInfoItem = new QStandardItem(LiveMetaInfoDescriptionString);
319  metaInfoItem->setEditable(false);
320  for (auto& pair : objItem.metaInfoMap)
321  {
322  auto name = QString::fromStdString(pair.first);
323  auto value = QString::fromStdString(
324  VariantPtr::dynamicCast(pair.second)->getOutputValueOnly());
325  QStandardItem* infoItem = new QStandardItem(
326  name + ": " + (value.size() > 100 ? (value.left(100) + "...") : value));
327  metaInfoItem->appendRow(infoItem);
328  }
329  objItem.item->appendRow(metaInfoItem);
330 
331  DependencyMap depMap = objItem.connectivity.dependencies;
332  DependencyMap::iterator it = depMap.begin();
333 
334  // iterate over proxy dependencies
335  while (it != depMap.end())
336  {
337  QStandardItem* depObjItem =
338  new QStandardItem(it->second->getName().c_str());
339  depObjItem->setEditable(false);
340 
341  if (it->second->getResolved())
342  {
343  depObjItem->setData(true, (int)UserDataRoles::ResolvedDependency);
344  depObjItem->setBackground(QBrush(QColor(50, 205, 50)));
345  depObjItem->setToolTip("Dependency resolved");
346  }
347  else
348  {
349  depObjItem->setData(false, (int)UserDataRoles::ResolvedDependency);
350  depObjItem->setBackground(QBrush(QColor(255, 106, 106)));
351  depObjItem->setToolTip("Dependency missing");
352  }
353  objItem.item->appendRow(depObjItem);
354 
355  ++it;
356  }
357  }
358  else
359  {
360 
361  auto endpointItem =
362  findItemByUserData(static_cast<Qt::ItemDataRole>(UserDataRoles::RowType),
364  item);
365  auto endpointText = "Endpoint: " + item->getEndpointStr();
366  if (!endpointItem)
367  {
368  endpointItem = new QStandardItem(endpointText);
369  endpointItem->setEditable(false);
370  endpointItem->setData((int)ApplicationRowType::Endpoint,
372  item->appendRow(endpointItem);
373  }
374  else
375  {
376  endpointItem->setText(endpointText);
377  }
378 
379  DependencyMap depMap = objItem.connectivity.dependencies;
380  DependencyMap::iterator it = depMap.begin();
381 
382  // iterate over proxy dependencies
383  while (it != depMap.end())
384  {
385  auto depObjItem =
386  findItem(QString::fromStdString(it->second->getName()), objItem.item);
387 
388 
389  if (depObjItem)
390  {
391  depObjItem->setEditable(false);
392 
393  if (it->second->getResolved())
394  {
395  depObjItem->setData(true, (int)UserDataRoles::ResolvedDependency);
396  depObjItem->setBackground(QBrush(QColor(50, 205, 50)));
397  depObjItem->setToolTip("Dependency resolved");
398  }
399  else
400  {
401  depObjItem->setData(false, (int)UserDataRoles::ResolvedDependency);
402  depObjItem->setBackground(QBrush(QColor(255, 106, 106)));
403  depObjItem->setToolTip("Dependency missing");
404  }
405  }
406 
407 
408  ++it;
409  }
410 
411  if (objItem.connectivity.offeredTopics.size() > 0)
412  {
413  auto topicsItem = findItem(QString("Offered Topics"), objItem.item);
414  if (!topicsItem)
415  {
416  topicsItem =
417  new QStandardItem(QString::fromStdString("Offered Topics"));
418  topicsItem->setEditable(false);
419  objItem.item->appendRow(topicsItem);
420  }
421 
422  for (const auto& topic : objItem.connectivity.offeredTopics)
423  {
424  auto topicItem = findItem(QString::fromStdString(topic), topicsItem);
425  if (!topicItem)
426  {
427  topicItem = new QStandardItem(QString::fromStdString(topic));
428  topicItem->setEditable(false);
429  topicsItem->appendRow(topicItem);
430  }
431  auto& listeners = listenerMap[topic];
432  syncStringListChildren(topicItem, listeners);
433  // topicItem->removeRows(0, topicItem->rowCount());
434  // for (auto& listener : listeners)
435  // {
436  // QStandardItem* listenerItem = new QStandardItem(("Listener: " + listener));
437  // listenerItem->setEditable(false);
438  // topicItem->appendRow(listenerItem);
439  // }
440  }
441  }
442 
443  if (objItem.connectivity.usedTopics.size() > 0)
444  {
445  auto topicsItem = findItem(QString("Used Topics"), objItem.item);
446  if (!topicsItem)
447  {
448  topicsItem = new QStandardItem(QString::fromStdString("Used Topics"));
449  topicsItem->setEditable(false);
450  objItem.item->appendRow(topicsItem);
451  }
452  if (topicsItem)
453  {
454  // QList<QStandardItem*> objectPropertiesRow;
455 
456  for (const auto& topic : objItem.connectivity.usedTopics)
457  {
458  auto topicItem =
459  findItem(QString::fromStdString(topic), topicsItem);
460  if (!topicItem)
461  {
462  topicItem = new QStandardItem(QString::fromStdString(topic));
463  topicItem->setEditable(false);
464  topicsItem->appendRow(topicItem);
465  }
466  if (offererMap.count(topic) == 0)
467  {
468  topicItem->setBackground(QBrush(QColor(255, 163, 33)));
469  topicItem->setToolTip(
470  "The topic " + QString::fromStdString(topic) +
471  " is not offered by any listed component - though not all "
472  "components might be listed");
473  }
474  else
475  {
476  topicItem->setBackground(QBrush());
477  auto& offerers = offererMap[topic];
478  syncStringListChildren(topicItem, offerers);
479  // topicItem->removeRows(0, topicItem->rowCount());
480  // for (auto& offerer : offerers)
481  // {
482  // QStandardItem* offererItem = new QStandardItem(("Offerer: " + offerer));
483  // offererItem->setEditable(false);
484  // topicItem->appendRow(offererItem);
485  // }
486  }
487  topicItem->setEditable(false);
488  // objectPropertiesRow.append(topicItem);
489  }
490  }
491  }
492 
493  // update meta infos
494  auto metaInfoItem =
495  findItem(QString(LiveMetaInfoDescriptionString), objItem.item);
496  if (metaInfoItem)
497  {
498  metaInfoItem->removeRows(0, metaInfoItem->rowCount());
499  for (auto& pair : objItem.metaInfoMap)
500  {
501  auto name = QString::fromStdString(pair.first);
502  auto value = QString::fromStdString(
503  VariantPtr::dynamicCast(pair.second)->getOutputValueOnly());
504  QStandardItem* infoItem = new QStandardItem(
505  name + ": " +
506  (value.size() > 100 ? (value.left(100) + "...") : value));
507  metaInfoItem->appendRow(infoItem);
508  }
509  }
510  }
511 
512  objItem.item->setBackground(getBrush(objItem.state));
513  auto stateBool = objItem.state == eManagedIceObjectStarted;
514  // ARMARX_INFO << "Setting objItem: " << objItem.name.toStdString() << " with shown name " << objItem.item->text().toStdString() << " to " << stateBool;
515 
516  objItem.item->setToolTip(
517  "Component state: " +
518  QString::fromStdString(
520  objItem.item->setData(stateBool, (int)UserDataRoles::ComponentStarted);
521  }
522  }
523 
524  ARMARX_DEBUG_S << "Updating SystemState model took "
525  << (IceUtil::Time::now() - start).toMilliSecondsDouble() << " ms";
526 
527  std::string dotString = GenerateDependencyGraph(dependenciesMap);
528  std::ofstream f("/tmp/dependencygraph.dot");
529  f << dotString;
530  }
531 
532  void
534  {
535  CHECK_QT_THREAD(this);
536  bool found = false;
537  // iterate over all manager items
538  for (int i = 0; i < this->rowCount(); i++)
539  {
540  ArmarXManagerItem* item = this->getItem(i);
541  if (item->getName() == data.name)
542  {
543  found = true;
544  break;
545  }
546  }
547  if (!found)
548  {
549  ARMARX_DEBUG << "Inserting " << data.name.toStdString();
550  this->appendRow(new ArmarXManagerItem(data.name));
551  }
552  updateManagerDetails({{data.name, data}}, false);
553  }
554 
555  void
556  ArmarXManagerModel::moveSelectionTo(QItemSelectionModel* selectionModel,
557  ArmarXManagerModel* destinationModel)
558  {
559  CHECK_QT_THREAD(this);
560  swapSelection(this, destinationModel, selectionModel);
561  }
562 
563  void
564  ArmarXManagerModel::takeSelectionFrom(QItemSelectionModel* selectionModel,
565  ArmarXManagerModel* sourceModel)
566  {
567  CHECK_QT_THREAD(this);
568  swapSelection(sourceModel, this, selectionModel);
569  }
570 
571  void
572  ArmarXManagerModel::swapSelection(ArmarXManagerModel* sourceModel,
573  ArmarXManagerModel* destinationModel,
574  QItemSelectionModel* selectionModel)
575  {
576  CHECK_QT_THREAD(this);
577  QList<QPersistentModelIndex> persistentSelectionModelList =
578  getPersistentModelIndex(selectionModel);
579 
580  // swap selections
581  QList<QPersistentModelIndex>::Iterator persistentModelIndexIter;
582  persistentModelIndexIter = persistentSelectionModelList.begin();
583 
584  while (persistentModelIndexIter != persistentSelectionModelList.end())
585  {
586  destinationModel->insertRow(destinationModel->rowCount(),
587  sourceModel->takeRow(persistentModelIndexIter->row()));
588 
589  ++persistentModelIndexIter;
590  }
591  }
592 
593  void
594  ArmarXManagerModel::deleteSelection(QItemSelectionModel* selectionModel)
595  {
596  CHECK_QT_THREAD(this);
597  QList<QPersistentModelIndex> persistentSelectionModelList =
598  getPersistentModelIndex(selectionModel);
599 
600  QList<QPersistentModelIndex>::Iterator persistentModelIndexIter;
601  persistentModelIndexIter = persistentSelectionModelList.begin();
602 
603  while (persistentModelIndexIter != persistentSelectionModelList.end())
604  {
605  takeRow(persistentModelIndexIter->row());
606 
607  ++persistentModelIndexIter;
608  }
609  }
610 
611  QList<QPersistentModelIndex>
612  ArmarXManagerModel::getPersistentModelIndex(QItemSelectionModel* selectionModel)
613  {
614  CHECK_QT_THREAD(this);
615  QModelIndexList selection = selectionModel->selectedRows();
616 
617  // populate persistent selection model list
618  QList<QPersistentModelIndex> persistentModelIndex;
619  QModelIndexList::Iterator modelIndexIter;
620  modelIndexIter = selection.begin();
621 
622  while (modelIndexIter != selection.end())
623  {
624  persistentModelIndex.append(*modelIndexIter);
625 
626  ++modelIndexIter;
627  }
628 
629  return persistentModelIndex;
630  }
631 
632  QVariant
633  ArmarXManagerModel::headerData(int section, Qt::Orientation orientation, int role) const
634  {
635  CHECK_QT_THREAD(this);
636  if (role == Qt::DisplayRole)
637  {
638  if (orientation == Qt::Horizontal)
639  {
640  switch (section)
641  {
642  case 0:
643  return "Name";
644 
645  case 1:
646  return "Object state";
647  }
648  }
649  }
650 
651  return QVariant();
652  }
653 
654  std::mutex&
656  {
657  return mutex;
658  }
659 
660  void
661  ArmarXManagerModel::updateItem(QStandardItem* item)
662  {
663  CHECK_QT_THREAD(this);
664  ArmarXManagerItem* managerItem = dynamic_cast<ArmarXManagerItem*>(item);
665 
666  if (managerItem)
667  {
668  // std::unique_lock lock(getMutex());
669 
670  managerItem->setName(item->text());
671  }
672  }
673 
674  QStringList
676  {
677  CHECK_QT_THREAD(this);
678  QStringList managerList;
679 
680  for (int i = 0; i < this->rowCount(); i++)
681  {
682  managerList.append(this->getItem(i)->getName());
683  }
684 
685  return managerList;
686  }
687 
688  bool
690  {
691  return rowCount() == 0;
692  }
693 
694  void
695  ArmarXManagerModel::populate(const QStringList& managerList)
696  {
697  CHECK_QT_THREAD(this);
698  // std::unique_lock lock(getMutex());
699 
700  this->clear();
701 
702  for (int i = 0; i < managerList.size(); i++)
703  {
704  this->appendRow(new ArmarXManagerItem(managerList.at(i)));
705  }
706  }
707 
710  {
711  CHECK_QT_THREAD(this);
712  ArmarXManagerModel* modelCopy = new ArmarXManagerModel();
713 
714  std::unique_lock lock(getMutex());
715 
716  for (int i = 0; i < rowCount(); i++)
717  {
718  ArmarXManagerItem* itemClone = new ArmarXManagerItem(item(i)->text());
719 
720  modelCopy->appendRow(itemClone);
721  }
722 
723  return modelCopy;
724  }
725 
726  void
728  {
729  CHECK_QT_THREAD(this);
730  // std::unique_lock lock(getMutex());
731  // std::unique_lock lockSource(source->getMutex());
732 
733  this->clear();
734 
735  for (int i = 0; i < source->rowCount(); i++)
736  {
737  ArmarXManagerItem* itemClone = new ArmarXManagerItem(source->item(i)->text());
738 
739  appendRow(itemClone);
740  }
741  }
742 
743  void
745  {
746  this->iceManager = iceManager;
747  }
748 
751  {
752  return iceManager;
753  }
754 
755  QBrush
756  ArmarXManagerModel::getBrush(armarx::ManagedIceObjectState state) const
757  {
758  QBrush brush;
759  brush.setStyle(Qt::SolidPattern);
760 
761  switch (state)
762  {
763  case armarx::eManagedIceObjectCreated:
764  brush.setColor(QColor(255, 196, 106));
765  break;
766 
767  case armarx::eManagedIceObjectInitializing:
768  brush.setColor(QColor(255, 255, 196));
769  break;
770 
771  case armarx::eManagedIceObjectInitialized:
772  brush.setColor(QColor(255, 255, 0));
773  break;
774 
775  case armarx::eManagedIceObjectInitializationFailed:
776  brush.setColor(QColor(255, 16, 16));
777  break;
778 
779  case armarx::eManagedIceObjectStarting:
780  brush.setColor(QColor(128, 196, 255));
781  break;
782 
783  case armarx::eManagedIceObjectStarted:
784  brush.setColor(QColor(128, 255, 128));
785  break;
786 
787  case armarx::eManagedIceObjectStartingFailed:
788  brush.setColor(QColor(255, 64, 64));
789  break;
790 
791  case armarx::eManagedIceObjectExiting:
792  brush.setColor(QColor(225, 225, 225));
793  break;
794 
795  case armarx::eManagedIceObjectExited:
796  brush.setColor(QColor(196, 196, 196));
797  break;
798  }
799 
800  return brush;
801  }
802 
803  QStandardItem*
804  ArmarXManagerModel::findItem(const QString& name, QStandardItem* item)
805  {
806  for (int i = 0; i < item->rowCount(); ++i)
807  {
808  QStandardItem* curItem = item->child(i);
809  if (curItem->text() == name)
810  {
811  return curItem;
812  }
813  }
814  return NULL;
815  }
816 
817  QStandardItem*
818  ArmarXManagerModel::findItemByUserData(Qt::ItemDataRole role,
819  const QVariant& data,
820  QStandardItem* item)
821  {
822  for (int i = 0; i < item->rowCount(); ++i)
823  {
824  QStandardItem* curItem = item->child(i);
825  if (curItem->data(role) == data)
826  {
827  return curItem;
828  }
829  }
830  return NULL;
831  }
832 
833  void
834  ArmarXManagerModel::syncStringListChildren(QStandardItem* item,
835  const std::vector<QString>& strings)
836  {
837  for (int i = item->rowCount() - 1; i >= 0; i--)
838  {
839  QStandardItem* curItem = item->child(i);
840  if (std::find(strings.begin(), strings.end(), curItem->text()) == strings.end())
841  {
842  item->removeRow(i);
843  }
844  }
845  for (const QString& s : strings)
846  {
847  auto child = findItem(s, item);
848  if (!child)
849  {
850  auto newChild = new QStandardItem(s);
851  newChild->setEditable(false);
852  item->appendRow(newChild);
853  }
854  }
855  }
856 
857  std::string
858  ArmarXManagerModel::GenerateDependencyGraph(
859  const std::map<std::string, DependencyMap>& dependenciesMap)
860  {
861  std::stringstream ss;
862  ss << "digraph ArmarXDependencyGraph\n"
863  "{";
864  for (auto& pair : dependenciesMap)
865  {
866  auto name = pair.first;
867  for (auto& pair2 : pair.second)
868  {
869  auto name2 = pair2.first;
870  name = simox::alg::replace_all(name, "-", "_");
871  name2 = simox::alg::replace_all(name2, "-", "_");
872  name = simox::alg::replace_all(name, ">", "_");
873  name2 = simox::alg::replace_all(name2, ">", "_");
874  ss << name << " -> " << name2 << ";\n";
875  }
876  }
877  ss << "\n}";
878  return ss.str();
879  }
880 } // namespace armarx
armarx::ArmarXManagerModel::getManagerItemByName
ArmarXManagerItem * getManagerItemByName(const QString &name)
Returns the requested manager item by its name.
Definition: ArmarXManagerModel.cpp:64
armarx::ArmarXManagerModel::toStringList
QStringList toStringList() const
Returns the model as a string list containing the manager names.
Definition: ArmarXManagerModel.cpp:675
armarx::ArmarXManagerModel::updateItem
void updateItem(QStandardItem *item)
Definition: ArmarXManagerModel.cpp:661
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:10
armarx::ArmarXManagerModel::getManagerProxyMap
ManagerPrxMap getManagerProxyMap() const
Definition: ArmarXManagerModel.cpp:84
armarx::ArmarXManagerModel::getMutex
std::mutex & getMutex()
Returns the access mutex.
Definition: ArmarXManagerModel.cpp:655
armarx::ManagedIceObjectItem::properties
ObjectPropertyInfos properties
Definition: ManagedIceObjectItem.h:50
ArmarXManagerModel.h
armarx::ArmarXManagerModel::empty
bool empty() const
Definition: ArmarXManagerModel.cpp:689
armarx::ArmarXManagerModel
Definition: ArmarXManagerModel.h:48
armarx::ArmarXManagerModel::clone
ArmarXManagerModel * clone()
Returns a clone of this ArmarXManagerModel.
Definition: ArmarXManagerModel.cpp:709
armarx::ArmarXManagerItem::getName
QString getName() const
Definition: ArmarXManagerItem.cpp:56
armarx::ManagedIceObjectItem::state
ManagedIceObjectState state
Definition: ManagedIceObjectItem.h:48
LiveMetaInfoDescriptionString
#define LiveMetaInfoDescriptionString
Definition: ArmarXManagerModel.cpp:44
armarx::ArmarXManagerModel::populate
void populate(const QStringList &managerList)
Populates this model with the given manager name list.
Definition: ArmarXManagerModel.cpp:695
armarx::ArmarXManagerItem::isOnline
bool isOnline() const
Definition: ArmarXManagerItem.cpp:62
armarx::ArmarXManagerItem::setConnection
void setConnection(Ice::ConnectionPtr connection)
Definition: ArmarXManagerItem.cpp:127
armarx::ArmarXManagerItem::setOnline
void setOnline(bool online)
Definition: ArmarXManagerItem.cpp:105
ManagedIceObjectItem.h
armarx::ArmarXManagerModel::copyFrom
void copyFrom(ArmarXManagerModel *source)
Copies the source model content to this one.
Definition: ArmarXManagerModel.cpp:727
armarx::ArmarXManagerModel::setIceManager
void setIceManager(IceManagerPtr iceManager)
Definition: ArmarXManagerModel.cpp:744
armarx::ManagedIceObject::GetObjectStateAsString
static std::string GetObjectStateAsString(int state)
Definition: ManagedIceObject.cpp:219
armarx::ArmarXManagerItem::setAppProperties
void setAppProperties(const ObjectPropertyInfos &properties)
Definition: ArmarXManagerItem.cpp:121
armarx::ManagedIceObjectItem::metaInfoMap
StringVariantBaseMap metaInfoMap
Definition: ManagedIceObjectItem.h:52
armarx::ArmarXManagerItem::getAppProperties
const ObjectPropertyInfos & getAppProperties() const
Definition: ArmarXManagerItem.cpp:139
armarx::ArmarXManagerItem::setManagerProxy
void setManagerProxy(ArmarXManagerInterfacePrx proxy)
Definition: ArmarXManagerItem.cpp:113
armarx::ArmarXManagerModel::ApplicationRowType::ApplicationProperties
@ ApplicationProperties
armarx::ArmarXManagerModel::UserDataRoles::RowType
@ RowType
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:75
armarx::ArmarXManagerModel::deleteSelection
void deleteSelection(QItemSelectionModel *selectionModel)
Deletes the selected set of rows from this model.
Definition: ArmarXManagerModel.cpp:594
armarx::ArmarXManagerModel::getIceManager
IceManagerPtr getIceManager() const
Definition: ArmarXManagerModel.cpp:750
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
ARMARX_DEBUG_S
#define ARMARX_DEBUG_S
Definition: Logging.h:205
armarx::ArmarXManagerModel::upsertManagerDetails
void upsertManagerDetails(const ArmarXManagerItem::ManagerData &data)
Definition: ArmarXManagerModel.cpp:533
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::ArmarXManagerModel::UserDataRoles::ComponentStarted
@ ComponentStarted
armarx::ProxyType::topic
@ topic
armarx::ArmarXManagerModel::getBrush
QBrush getBrush(armarx::ManagedIceObjectState state) const
Returns an instance of state dependent brush.
Definition: ArmarXManagerModel.cpp:756
armarx::ArmarXManagerModel::UserDataRoles::ResolvedDependency
@ ResolvedDependency
armarx::ArmarXManagerItem::ManagerDataMap
std::map< QString, ManagerData > ManagerDataMap
Definition: ArmarXManagerItem.h:57
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::ArmarXManagerModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Returns the data header.
Definition: ArmarXManagerModel.cpp:633
armarx::ArmarXManagerModel::ArmarXManagerModel
ArmarXManagerModel()
Constructs an ArmarXManagerModel.
Definition: ArmarXManagerModel.cpp:48
armarx::ArmarXManagerItem::setEndpointStr
void setEndpointStr(const QString &endpointStr)
Definition: ArmarXManagerItem.cpp:133
CHECK_QT_THREAD
#define CHECK_QT_THREAD(qtObject)
Macro to check whether the current function is executed in the thread of the given Qt object.
Definition: QtUtil.h:30
ArmarXWidgetController.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::ArmarXManagerItem::clear
void clear(bool clearProxy=true)
Clears the item data.
Definition: ArmarXManagerItem.cpp:36
armarx::ArmarXManagerItem::ObjectMap
QMap< QString, ManagedIceObjectItem > ObjectMap
Definition: ArmarXManagerItem.h:44
armarx::ManagedIceObjectItem::connectivity
ManagedIceObjectConnectivity connectivity
Definition: ManagedIceObjectItem.h:49
IceUtil::Handle< IceManager >
QtUtil.h
armarx::ArmarXManagerItem::getObjects
ObjectMap & getObjects()
Definition: ArmarXManagerItem.cpp:86
armarx::ManagerPrxMap
std::map< QString, ArmarXManagerInterfacePrx > ManagerPrxMap
Definition: ArmarXManagerModel.h:46
armarx::ArmarXManagerItem::ManagerData
Definition: ArmarXManagerItem.h:46
armarx::transparent
QColor transparent()
Definition: StyleSheets.h:90
armarx::ArmarXManagerModel::ApplicationRowType::Endpoint
@ Endpoint
armarx::ArmarXManagerModel::updateManagerDetails
void updateManagerDetails(const ArmarXManagerItem::ManagerDataMap &managerDataMap, bool deactivateIfMissing=true)
Definition: ArmarXManagerModel.cpp:140
armarx::handleExceptions
void handleExceptions()
Definition: Exception.cpp:157
armarx::ArmarXManagerItem
Definition: ArmarXManagerItem.h:41
armarx::ArmarXManagerItem::setName
void setName(QString name)
Definition: ArmarXManagerItem.cpp:92
armarx::ArmarXManagerModel::getItem
ArmarXManagerItem * getItem(int row, int column=0) const
Returns a requested Model item.
Definition: ArmarXManagerModel.cpp:58
armarx::ArmarXManagerModel::~ArmarXManagerModel
~ArmarXManagerModel() override
Model destructor.
Definition: ArmarXManagerModel.cpp:53
Variant.h
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::ManagedIceObjectItem::item
QStandardItem * item
Definition: ManagedIceObjectItem.h:51
armarx::ArmarXManagerModel::moveSelectionTo
void moveSelectionTo(QItemSelectionModel *selectionModel, ArmarXManagerModel *destinationModel)
Takes the specified selected rows via the selection model from this and appends the rows to the given...
Definition: ArmarXManagerModel.cpp:556
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ArmarXManagerModel::takeSelectionFrom
void takeSelectionFrom(QItemSelectionModel *selectionModel, ArmarXManagerModel *sourceModel)
Takes the specified selected rows via the selection model from the source model and appends the rows ...
Definition: ArmarXManagerModel.cpp:564
armarx::ManagedIceObjectItem
Definition: ManagedIceObjectItem.h:37
armarx::ArmarXManagerItem::getManagerProxy
ArmarXManagerInterfacePrx getManagerProxy() const
Definition: ArmarXManagerItem.cpp:68
armarx::ArmarXManagerItem::getEndpointStr
QString getEndpointStr() const
Definition: ArmarXManagerItem.cpp:80