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