fw4spl
DumpEditor.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "monitorQt/DumpEditor.hpp"
8 
9 #include <fwCom/Slot.hpp>
10 #include <fwCom/Slot.hxx>
11 
12 #include <fwCore/base.hpp>
13 
14 #include <fwGui/Cursor.hpp>
15 #include <fwGui/dialog/IMessageDialog.hpp>
16 #include <fwGui/dialog/MessageDialog.hpp>
17 
18 #include <fwGuiQt/container/QtContainer.hpp>
19 
20 #include <fwMemory/BufferManager.hpp>
21 #include <fwMemory/ByteSize.hpp>
22 #include <fwMemory/IPolicy.hpp>
23 #include <fwMemory/tools/MemoryMonitorTools.hpp>
24 
25 #include <fwServices/macros.hpp>
26 #include <fwServices/registry/ActiveWorkers.hpp>
27 
28 #include <fwTools/fwID.hpp>
29 #include <fwTools/Stringizer.hpp>
30 
31 #include <boost/lexical_cast.hpp>
32 
33 #include <QComboBox>
34 #include <QFuture>
35 #include <QHeaderView>
36 #include <QItemDelegate>
37 #include <QStringList>
38 #include <QTableWidgetItem>
39 #include <QtConcurrentRun>
40 #include <QTimer>
41 #include <QVBoxLayout>
42 
43 namespace monitorQt
44 {
45 
46 //------------------------------------------------------------------------------
47 
48 fwServicesRegisterMacro( ::fwGui::editor::IEditor, ::monitorQt::DumpEditor );
49 
50 ::fwMemory::BufferManager::BufferInfoMapType m_bufferInfos;
51 ::fwMemory::BufferManager::BufferStats m_bufferStats = {0, 0};
52 
53 //------------------------------------------------------------------------------
54 
55 QString getHumanReadableSize(::fwMemory::ByteSize::SizeType bytes)
56 {
57  return QString::fromStdString(::fwMemory::ByteSize(bytes));
58 }
59 
60 //------------------------------------------------------------------------------
61 
62 class PolicyComboBoxDelegate : public QItemDelegate
63 {
64 
65 public:
66  PolicyComboBoxDelegate(QObject* parent = 0) :
67  QItemDelegate(parent)
68  {
69  }
70 
71  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
72 
73  void setEditorData(QWidget* editor, const QModelIndex& index) const;
74  void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
75 
76  void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
77 };
78 
79 //------------------------------------------------------------------------------
80 
81 QWidget* PolicyComboBoxDelegate::createEditor(QWidget* parent,
82  const QStyleOptionViewItem& option,
83  const QModelIndex& index ) const
84 {
85  QComboBox* policyComboBox = new QComboBox(parent);
86 
87  const std::string value = index.model()->data(index, Qt::DisplayRole).toString().toStdString();
88 
89  const ::fwMemory::policy::registry::Type::KeyVectorType& factories =
90  ::fwMemory::policy::registry::get()->getFactoryKeys();
91 
92  for( const ::fwMemory::policy::registry::KeyType& policy : factories)
93  {
94  policyComboBox->addItem(QString::fromStdString(policy));
95  if(value == policy)
96  {
97  policyComboBox->setCurrentIndex(policyComboBox->count()-1);
98  }
99  }
100  return policyComboBox;
101 }
102 
103 //------------------------------------------------------------------------------
104 
105 void PolicyComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
106 {
107  QString value = index.model()->data(index, Qt::DisplayRole).toString();
108 
109  QComboBox* policyComboBox = static_cast<QComboBox*>(editor);
110 
111  int idx = policyComboBox->findText(value);
112  if( idx != -1 )
113  {
114  policyComboBox->setCurrentIndex(idx);
115  }
116 }
117 
118 //------------------------------------------------------------------------------
119 
120 void PolicyComboBoxDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
121 {
122  QComboBox* policyComboBox = static_cast<QComboBox*>(editor);
123  QString value = policyComboBox->currentText();
124 
125  model->setData(index, value, Qt::EditRole);
126 }
127 
128 //------------------------------------------------------------------------------
129 
130 void PolicyComboBoxDelegate::updateEditorGeometry(QWidget* editor,
131  const QStyleOptionViewItem& option,
132  const QModelIndex& index ) const
133 {
134  editor->setGeometry(option.rect);
135 }
136 
137 class PolicyTableModel : public QAbstractTableModel
138 {
139 
140 public:
141  PolicyTableModel(QObject* parent = 0);
142 
143  int rowCount(const QModelIndex& parent) const;
144  int columnCount(const QModelIndex& parent) const;
145  QVariant data(const QModelIndex& index, int role) const;
146  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
147  Qt::ItemFlags flags(const QModelIndex& index) const;
148  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
149 
150  static const int s_EXTRA_INFO_NB;
151 private:
152 
153  ::fwMemory::BufferManager::sptr m_buffManager;
154 };
155 
156 const int PolicyTableModel::s_EXTRA_INFO_NB = 1;
157 
158 PolicyTableModel::PolicyTableModel(QObject* parent) :
159  QAbstractTableModel(parent)
160 {
161  m_buffManager = ::fwMemory::BufferManager::getDefault();
162 }
163 
164 //------------------------------------------------------------------------------
165 
166 int PolicyTableModel::rowCount(const QModelIndex& parent) const
167 {
168  Q_UNUSED(parent);
169  size_t nbParam = 0;
170  if(m_buffManager)
171  {
172  ::fwCore::mt::ReadLock lock( m_buffManager->getMutex() );
173  ::fwMemory::IPolicy::sptr currentPolicy = m_buffManager->getDumpPolicy();
174  nbParam = currentPolicy->getParamNames().size();
175  }
176 
177  return static_cast<int>(nbParam + s_EXTRA_INFO_NB);
178 }
179 
180 //------------------------------------------------------------------------------
181 
182 int PolicyTableModel::columnCount(const QModelIndex& parent) const
183 {
184  Q_UNUSED(parent);
185  return 1;
186 }
187 
188 //------------------------------------------------------------------------------
189 
190 QVariant PolicyTableModel::data(const QModelIndex& index, int role) const
191 {
192  if (!m_buffManager && !index.isValid())
193  {
194  return QVariant();
195  }
196  ::fwCore::mt::ReadLock lock( m_buffManager->getMutex() );
197  ::fwMemory::IPolicy::sptr currentPolicy = m_buffManager->getDumpPolicy();
198 
199  if (index.row() > (s_EXTRA_INFO_NB + currentPolicy->getParamNames().size()) || index.row() < 0)
200  {
201  return QVariant();
202  }
203 
204  if (role == Qt::DisplayRole)
205  {
206 
207  if (index.column() == 0)
208  {
209  const ::fwMemory::IPolicy::ParamNamesType& names = currentPolicy->getParamNames();
210  if(index.row() == 0)
211  {
212  return QString::fromStdString(currentPolicy->getLeafClassname());
213  }
214  else if( (unsigned int)index.row() <= names.size())
215  {
216  const ::fwMemory::IPolicy::ParamNamesType::value_type& name = names.at(index.row() - 1);
217 
218  return QString::fromStdString(currentPolicy->getParam(name));
219 
220  }
221  }
222  }
223  return QVariant();
224 }
225 
226 //------------------------------------------------------------------------------
227 
228 QVariant PolicyTableModel::headerData(int section, Qt::Orientation orientation, int role) const
229 {
230  if (role != Qt::DisplayRole)
231  {
232  return QVariant();
233  }
234 
235  if (m_buffManager && orientation == Qt::Vertical)
236  {
237  ::fwCore::mt::ReadLock lock( m_buffManager->getMutex() );
238  ::fwMemory::IPolicy::sptr currentPolicy = m_buffManager->getDumpPolicy();
239  const ::fwMemory::IPolicy::ParamNamesType& names = currentPolicy->getParamNames();
240  if (section <= 0)
241  {
242  return QString("Current policy");
243  }
244  else if( (unsigned int)section <= names.size() )
245  {
246  const ::fwMemory::IPolicy::ParamNamesType::value_type& name = names.at(section - 1);
247  return QString::fromStdString(name);
248  }
249  }
250  return QVariant();
251 }
252 
253 //------------------------------------------------------------------------------
254 
255 bool PolicyTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
256 {
257  if (m_buffManager && index.isValid() && role == Qt::EditRole)
258  {
259  int row = index.row();
260  int col = index.column();
261  const std::string strvalue = value.toString().toStdString();
262 
263  ::fwCore::mt::ReadLock lock( m_buffManager->getMutex() );
264  ::fwMemory::IPolicy::sptr currentPolicy = m_buffManager->getDumpPolicy();
265  const ::fwMemory::IPolicy::ParamNamesType& names = currentPolicy->getParamNames();
266 
267  if (col == 0 && (unsigned int)row <= names.size() )
268  {
269  ::fwMemory::IPolicy::sptr dumpPolicy;
270  switch (row)
271  {
272  case 0:
273  if(strvalue != currentPolicy->getLeafClassname())
274  {
275  dumpPolicy = ::fwMemory::policy::registry::get()->create(strvalue);
276  if(dumpPolicy)
277  {
278  ::fwCore::mt::ReadToWriteLock lock( m_buffManager->getMutex() );
279  m_buffManager->setDumpPolicy(dumpPolicy);
280  }
281  this->beginResetModel();
282  this->endResetModel();
283  }
284  break;
285  default:
286  const ::fwMemory::IPolicy::ParamNamesType::value_type& name = names.at(row - 1);
287  currentPolicy->setParam(name, strvalue);
288  return true;
289  }
290  }
291  }
292  return false;
293 }
294 
295 //------------------------------------------------------------------------------
296 
297 Qt::ItemFlags PolicyTableModel::flags(const QModelIndex& index) const
298 {
299  if (!index.isValid())
300  {
301  return Qt::ItemIsEnabled;
302  }
303 
304  return QAbstractTableModel::flags(index) | Qt::ItemIsEditable;
305 }
306 
307 //------------------------------------------------------------------------------
308 
309 class InfoTableModel : public QAbstractTableModel
310 {
311 
312 public:
313  InfoTableModel(QObject* parent = 0);
314 
315  int rowCount(const QModelIndex& parent) const;
316  int columnCount(const QModelIndex& parent) const;
317  QVariant data(const QModelIndex& index, int role) const;
318  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
319 
320 private:
321 
322  ::fwMemory::BufferManager::sptr m_buffManager;
323 };
324 
325 InfoTableModel::InfoTableModel(QObject* parent) :
326  QAbstractTableModel(parent)
327 {
328  m_buffManager = ::fwMemory::BufferManager::getDefault();
329 }
330 
331 //------------------------------------------------------------------------------
332 
333 int InfoTableModel::rowCount(const QModelIndex& parent) const
334 {
335  Q_UNUSED(parent);
336  return 4;
337 }
338 
339 //------------------------------------------------------------------------------
340 
341 int InfoTableModel::columnCount(const QModelIndex& parent) const
342 {
343  Q_UNUSED(parent);
344  return 1;
345 }
346 
347 //------------------------------------------------------------------------------
348 
349 QVariant InfoTableModel::data(const QModelIndex& index, int role) const
350 {
351  if (!m_buffManager || !index.isValid())
352  {
353  return QVariant();
354  }
355 
356  if (index.row() > this->rowCount(index))
357  {
358  return QVariant();
359  }
360 
361  if (role == Qt::DisplayRole)
362  {
363  if (index.column() == 0)
364  {
365  std::uint64_t sysMem;
366  ::fwMemory::BufferManager::SizeType bufferManagerMem;
367  switch (index.row())
368  {
369  case 0:
370  sysMem = ::fwMemory::tools::MemoryMonitorTools::getTotalSystemMemory();
371  return QString(getHumanReadableSize(sysMem));
372  break;
373  case 1:
374  sysMem = ::fwMemory::tools::MemoryMonitorTools::getFreeSystemMemory();
375  return QString(getHumanReadableSize(sysMem));
376  break;
377  case 2:
378  bufferManagerMem = m_bufferStats.totalManaged;
379  return QString(getHumanReadableSize(bufferManagerMem));
380  break;
381  case 3:
382  bufferManagerMem = m_bufferStats.totalDumped;
383  return QString(getHumanReadableSize(bufferManagerMem));
384  break;
385  }
386  }
387  }
388  return QVariant();
389 }
390 
391 //------------------------------------------------------------------------------
392 
393 QVariant InfoTableModel::headerData(int section, Qt::Orientation orientation, int role) const
394 {
395  if (role == Qt::DisplayRole && orientation == Qt::Vertical)
396  {
397  switch (section)
398  {
399  case 0:
400  return QString("Total System Memory");
401  break;
402  case 1:
403  return QString("Free System Memory");
404  break;
405  case 2:
406  return QString("Managed");
407  break;
408  case 3:
409  return QString("Dumped");
410  break;
411  }
412 
413  }
414 
415  return QVariant();
416 }
417 
418 //------------------------------------------------------------------------------
419 
421 {
422 }
423 
424 //------------------------------------------------------------------------------
425 
427 {
428 }
429 
430 //------------------------------------------------------------------------------
431 
433 {
435 
436  ::fwGuiQt::container::QtContainer::sptr qtContainer
437  = ::fwGuiQt::container::QtContainer::dynamicCast(this->getContainer() );
438 
439  m_updateTimer = new QTimer(qtContainer->getQtContainer());
440  m_updateTimer->setInterval(300);
441  m_updateTimer->setSingleShot(true);
442 
443  m_list = new QTableWidget();
444  m_mapper = new QSignalMapper();
445 
446  m_list->setColumnCount(5);
447  QStringList header;
448  header.push_back("Size");
449  header.push_back("Status");
450  header.push_back("Timestamp");
451  header.push_back("Locked");
452  header.push_back("Action");
453  m_list->setHorizontalHeaderLabels(header);
454 
455  m_refresh = new QPushButton(tr("Refresh"));
456  QVBoxLayout* sizer = new QVBoxLayout();
457 
458  QHBoxLayout* sizerButton = new QHBoxLayout();
459  sizerButton->addWidget(m_refresh);
460 
461  sizerButton->addItem(new QSpacerItem(10, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
462  QFrame* verticalLine = new QFrame();
463  verticalLine->setFrameShape(QFrame::VLine);
464  verticalLine->setFrameShadow(QFrame::Sunken);
465  sizerButton->addWidget(verticalLine);
466 
467  sizer->addLayout(sizerButton);
468  sizer->addWidget(m_list, 2);
469 
470  m_policyEditor = new QTableView();
471  PolicyComboBoxDelegate* policyComboBoxDelegate = new PolicyComboBoxDelegate(m_policyEditor);
472  PolicyTableModel* policyTableModel = new PolicyTableModel(m_policyEditor);
473  m_policyEditor->setModel(policyTableModel);
474  m_policyEditor->setItemDelegateForRow(0, policyComboBoxDelegate);
475  m_policyEditor->setSortingEnabled(false);
476  m_policyEditor->horizontalHeader()->hide();
477 
478  InfoTableModel* infoTableModel = new InfoTableModel();
479  m_infoEditor = new QTableView();
480  m_infoEditor->setModel(infoTableModel);
481  m_infoEditor->horizontalHeader()->hide();
482 
483  QHBoxLayout* tablesLayout = new QHBoxLayout();
484  tablesLayout->addWidget(m_infoEditor);
485  tablesLayout->addWidget(m_policyEditor);
486 
487  sizer->addLayout(tablesLayout);
488 
489  qtContainer->setLayout( sizer );
490 
491  QObject::connect(m_refresh, SIGNAL(clicked()), this, SLOT(onRefreshButton()));
492  QObject::connect(m_mapper, SIGNAL(mapped(int)), this, SLOT(changeStatus(int)));
493 
494  QObject::connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(onRefreshButton()));
495  QObject::connect(&m_watcher, SIGNAL(finished()), this, SLOT(onBufferInfo()));
496 
497  ::fwMemory::BufferManager::sptr buffManager = ::fwMemory::BufferManager::getDefault();
498  if (buffManager)
499  {
500  m_updateSlot = ::fwCom::newSlot( &DumpEditor::onUpdate, this );
501  ::fwServices::registry::ActiveWorkers::sptr workers = ::fwServices::registry::ActiveWorkers::getDefault();
502  m_updateSlot->setWorker( workers->getWorker( ::fwServices::registry::ActiveWorkers::s_DEFAULT_WORKER ));
503  m_connection = buffManager->getUpdatedSignal()->connect( m_updateSlot );
504  }
505 
506  this->updating();
507 }
508 
509 //------------------------------------------------------------------------------
510 
512 {
513  m_connection.disconnect();
514  QObject::disconnect(m_refresh, SIGNAL(clicked()), this, SLOT(onRefreshButton()));
515  QObject::disconnect(m_mapper, SIGNAL(mapped(int)), this, SLOT(changeStatus(int)));
516  QObject::disconnect(&m_watcher, SIGNAL(finished()), this, SLOT(onBufferInfo()));
517 
518  this->destroy();
519 }
520 
521 //------------------------------------------------------------------------------
522 
524 {
525  SLM_TRACE_FUNC();
527 }
528 
529 //------------------------------------------------------------------------------
530 
531 class SizeTableWidgetItem : public QTableWidgetItem
532 {
533 public:
534 
535  SizeTableWidgetItem(const QString& text) :
536  QTableWidgetItem(text)
537  {
538  }
539 
540  //------------------------------------------------------------------------------
541 
542  virtual bool operator< ( const QTableWidgetItem& other ) const
543  {
544  return data(Qt::UserRole).toULongLong() < other.data(Qt::UserRole).toULongLong();
545  }
546 
547 protected:
548 
549  size_t m_size;
550 };
551 
552 //------------------------------------------------------------------------------
553 
554 ::fwMemory::BufferManager::BufferInfoMapType getInfoMap()
555 {
556  ::fwMemory::BufferManager::BufferInfoMapType infoMap;
557  ::fwMemory::BufferManager::sptr buffManager = ::fwMemory::BufferManager::getDefault();
558  if(buffManager)
559  {
560  infoMap = buffManager->getBufferInfos().get();
561  }
562  return infoMap;
563 }
564 
565 //------------------------------------------------------------------------------
566 
568 {
569  m_policyEditor->reset();
570  m_policyEditor->resizeColumnsToContents();
571 
572  QFuture< ::fwMemory::BufferManager::BufferInfoMapType > qFuture = QtConcurrent::run(getInfoMap);
573  m_watcher.setFuture(qFuture);
574 }
575 
576 //------------------------------------------------------------------------------
577 
578 void DumpEditor::onBufferInfo()
579 {
580  m_bufferInfos = m_watcher.result();
581  m_bufferStats = ::fwMemory::BufferManager::computeBufferStats(m_bufferInfos);
582 
583  m_mapper->blockSignals(true);
584  ::fwCom::Connection::Blocker block(m_connection);
585 
586  for(int row = 0; row < m_list->rowCount(); row++)
587  {
588  m_mapper->removeMappings( m_list->cellWidget(row, 4) );
589  }
590  m_list->clearContents();
591  m_objectsUID.clear();
592 
593  int itemCount = 0;
594  m_list->setSortingEnabled(false);
595  m_list->setRowCount(static_cast<int>(m_bufferInfos.size()));
596  m_list->setColumnCount(5);
597  QColor backColor;
598  for(const ::fwMemory::BufferManager::BufferInfoMapType::value_type& elt : m_bufferInfos)
599  {
600  m_objectsUID.push_back(elt.first);
601 
602  std::string status = "?";
603  std::string date = "?";
604  std::string lockStatus = "?";
605 
606  const ::fwMemory::BufferInfo& dumpBuffInfo = elt.second;
607  bool loaded = dumpBuffInfo.loaded;
608  if(!loaded)
609  {
610  backColor = Qt::darkYellow;
611  status = "Dumped";
612  }
613  else
614  {
615  backColor = Qt::white;
616  status = "-";
617  }
618 
619  bool isLock = dumpBuffInfo.lockCount() > 0;
620  if ( isLock )
621  {
622  lockStatus = "locked(" + ::fwTools::getString(dumpBuffInfo.lockCount()) +")";
623  }
624  else
625  {
626  lockStatus = "unlocked";
627  }
628 
629  date = ::fwTools::getString(dumpBuffInfo.lastAccess.getLogicStamp());
630 
631  QTableWidgetItem* currentSizeItem = new SizeTableWidgetItem( getHumanReadableSize(dumpBuffInfo.size) );
632  currentSizeItem->setData(Qt::UserRole, (qulonglong)dumpBuffInfo.size );
633  currentSizeItem->setFlags(Qt::ItemIsEnabled);
634  currentSizeItem->setBackgroundColor(backColor);
635  m_list->setItem(itemCount, 0, currentSizeItem );
636 
637  QTableWidgetItem* statusItem = new QTableWidgetItem( QString::fromStdString(status));
638  statusItem->setFlags(Qt::ItemIsEnabled);
639  statusItem->setBackgroundColor(backColor);
640  m_list->setItem(itemCount, 1, statusItem );
641 
642  QTableWidgetItem* dateItem = new QTableWidgetItem( QString::fromStdString(date));
643  dateItem->setFlags(Qt::ItemIsEnabled);
644  dateItem->setBackgroundColor(backColor);
645  m_list->setItem(itemCount, 2, dateItem );
646 
647  QTableWidgetItem* lockStatusItem = new QTableWidgetItem( QString::fromStdString(lockStatus));
648  lockStatusItem->setFlags(Qt::ItemIsEnabled);
649  lockStatusItem->setBackgroundColor(backColor);
650  m_list->setItem(itemCount, 3, lockStatusItem );
651 
652  QPushButton* actionItem = new QPushButton(QString::fromStdString((loaded) ? "Dump" : "Restore"), m_list);
653  actionItem->setEnabled(!isLock && (dumpBuffInfo.size > 0) );
654  m_list->setCellWidget(itemCount, 4, actionItem );
655  QObject::connect(actionItem, SIGNAL(pressed()), m_mapper, SLOT(map()));
656  m_mapper->setMapping(actionItem, itemCount);
657 
658  ++itemCount;
659  }
660  m_list->setSortingEnabled(true);
661 
662  m_mapper->blockSignals(false);
663 
664  m_infoEditor->reset();
665  m_infoEditor->resizeColumnsToContents();
666 }
667 
668 //------------------------------------------------------------------------------
669 
671 {
672  this->updating();
673 }
674 
675 //------------------------------------------------------------------------------
676 
677 void DumpEditor::info( std::ostream& _sstream )
678 {
679  _sstream << "Dump Editor";
680 }
681 
682 //------------------------------------------------------------------------------
683 
685 {
686  m_updateTimer->start();
687 }
688 
689 //------------------------------------------------------------------------------
690 
692 {
693  this->updating();
694 }
695 
696 //------------------------------------------------------------------------------
697 
698 void DumpEditor::changeStatus( int index )
699 {
700  ::fwMemory::BufferManager::sptr buffManager = ::fwMemory::BufferManager::getDefault();
701  if(buffManager)
702  {
703  const ::fwMemory::BufferManager::BufferInfoMapType buffInfoMap = m_bufferInfos;
704  ::fwMemory::BufferManager::ConstBufferPtrType selectedBuffer = m_objectsUID[index];
705 
706  ::fwMemory::BufferManager::BufferInfoMapType::const_iterator iter;
707  iter = buffInfoMap.find(selectedBuffer);
708  if( iter != buffInfoMap.end())
709  {
710  ::fwGui::Cursor cursor;
711  cursor.setCursor(::fwGui::ICursor::BUSY);
712  const ::fwMemory::BufferInfo& dumpBuffInfo = iter->second;
713 
714  bool isLock = dumpBuffInfo.lockCount() > 0;
715  if ( !isLock )
716  {
717  if ( dumpBuffInfo.loaded )
718  {
719  buffManager->dumpBuffer(selectedBuffer);
720  }
721  else
722  {
723  buffManager->restoreBuffer(selectedBuffer);
724  }
725  }
726  else
727  {
729  "Dump process information",
730  "Dump process is locked. It is impossible to dump or restore this object.",
731  ::fwGui::dialog::IMessageDialog::WARNING);
732  }
733 
734  cursor.setDefaultCursor();
735 
736  this->updating();
737  }
738  else
739  {
740  std::stringstream stream;
741  stream << "Object " << selectedBuffer << " not found, please refresh the grid.";
743  "Dump process information",
744  stream.str(),
745  ::fwGui::dialog::IMessageDialog::WARNING);
746  }
747  }
748 }
749 
750 //------------------------------------------------------------------------------
751 
752 }
void changeStatus(int)
This method is called when an item is pressed.
Definition: DumpEditor.cpp:698
virtual FWGUI_API void setCursor(::fwGui::ICursor::CursorType cursor) override
Set the cursor.
::boost::upgrade_lock< ReadWriteMutex > ReadToWriteLock
Defines an upgradable lock type for read/write mutex.
Conversion helper for size in bytes Converts string to number of bytes and vice-versa. This class is also able to manage conversions between units standards (IEC, SI)
Definition: ByteSize.hpp:25
Class allowing to block a Connection.
Definition: Connection.hpp:20
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
Defines the service interface managing the editor service for object.
Definition: IEditor.hpp:25
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
virtual void configuring() override
Calls classic IAction methods to configure.
Definition: DumpEditor.cpp:523
static FWMEMORY_API BufferManager::sptr getDefault()
Returns the current BufferManager instance.
virtual void info(std::ostream &_sstream) override
Overrides. Does nothing.
Definition: DumpEditor.cpp:677
virtual void stopping() override
Stop the layout.
Definition: DumpEditor.cpp:511
virtual MONITORQT_API ~DumpEditor() noexcept
Destructor. Does nothing.
Definition: DumpEditor.cpp:426
static FWSERVICES_API const std::string s_DEFAULT_WORKER
Key of default worker in registry, created and registered by initRegistry method. ...
MONITORQT_API DumpEditor() noexcept
Constructor. Does nothing.
Definition: DumpEditor.cpp:420
virtual void starting() override
Install the layout and call updating() method.
Definition: DumpEditor.cpp:432
static FWSERVICES_API ActiveWorkers::sptr getDefault()
Returns an instance of ActiveWorkers.
void onUpdate()
Start m_updateTimer, call on buffManager signal emit ( see m_refreshSignal )
Definition: DumpEditor.cpp:684
void onRefreshButton()
Slot called when user click on button m_refresh, call updating() method.
Definition: DumpEditor.cpp:691
::boost::shared_lock< ReadWriteMutex > ReadLock
Defines a lock of read type for read/write mutex.
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
virtual void swapping() override
Call updating() method.
Definition: DumpEditor.cpp:670
Defines the generic cursor for IHM. Use the Delegate design pattern.
virtual void updating() override
Update the choice selection.
Definition: DumpEditor.cpp:567
FWGUI_API void initialize()
Initialize managers.
Editor to dump or restore selected buffer.
Definition: DumpEditor.hpp:42
virtual FWGUI_API void setDefaultCursor() override
Set the default cursor.