fw4spl
TransferFunctionEditor.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 "uiTF/TransferFunctionEditor.hpp"
8 
9 #include <fwCore/base.hpp>
10 
11 #include <fwData/Composite.hpp>
12 #include <fwData/TransferFunction.hpp>
13 
14 #include <fwDataTools/helper/Composite.hpp>
15 
16 #include <fwGui/dialog/InputDialog.hpp>
17 #include <fwGui/dialog/LocationDialog.hpp>
18 #include <fwGui/dialog/MessageDialog.hpp>
19 
20 #include <fwGuiQt/container/QtContainer.hpp>
21 
22 #include <fwIO/ioTypes.hpp>
23 #include <fwIO/IReader.hpp>
24 #include <fwIO/IWriter.hpp>
25 
26 #include <fwRuntime/EConfigurationElement.hpp>
27 #include <fwRuntime/operations.hpp>
28 
29 #include <fwServices/macros.hpp>
30 #include <fwServices/op/Add.hpp>
31 
32 #include <boost/filesystem/convenience.hpp>
33 #include <boost/filesystem/operations.hpp>
34 #include <boost/foreach.hpp>
35 
36 #include <QBoxLayout>
37 #include <QComboBox>
38 #include <QIcon>
39 #include <QPushButton>
40 #include <QString>
41 #include <QWidget>
42 
43 namespace uiTF
44 {
45 
46 static const ::fwServices::IService::KeyType s_TF_POOL_INOUT = "tfPool";
47 static const ::fwServices::IService::KeyType s_TF_OUTPUT = "tf";
48 static const ::fwServices::IService::KeyType s_CURRENT_TF_INPUT = "currentTF";
49 
50 //------------------------------------------------------------------------------
51 
52 fwServicesRegisterMacro( ::fwGui::editor::IEditor, ::uiTF::TransferFunctionEditor);
53 
54 //------------------------------------------------------------------------------
55 
57 {
58 }
59 
60 //------------------------------------------------------------------------------
61 
63 {
64 }
65 
66 //------------------------------------------------------------------------------
67 
69 {
70  this->initialize();
71 
72  const ConfigType srvConfig = this->getConfigTree();
73 
74  bool useDefaultPath = true;
75  if (srvConfig.count("config"))
76  {
77  const ConfigType config = srvConfig.get_child("config");
78 
79  const auto pathCfg = config.equal_range("path");
80  for(auto itCfg = pathCfg.first; itCfg != pathCfg.second; ++itCfg)
81  {
82  const auto path = ::fwRuntime::getBundleResourceFilePath(itCfg->second.get_value<std::string>());
83  m_paths.push_back(path);
84  }
85 
86  const std::string value = config.get("<xmlattr>.useDefaultPath", "yes");
87  SLM_FATAL_IF("'useDefaultPath' value must be 'yes' or 'no'", value != "yes" && value != "no");
88 
89  useDefaultPath = (value == "yes");
90  }
91  if (useDefaultPath)
92  {
93  const auto pathRoot = ::fwRuntime::getBundleResourceFilePath("uiTF", "tf");
94  m_paths.push_back(pathRoot);
95  }
96 }
97 
98 //------------------------------------------------------------------------------
99 
101 {
102  this->create();
103 
104  // Get the Qt container
105  ::fwGuiQt::container::QtContainer::sptr qtContainer
106  = ::fwGuiQt::container::QtContainer::dynamicCast(this->getContainer());
107 
108  // Buttons creation
109  m_pTransferFunctionPreset = new QComboBox();
110 
111  ::boost::filesystem::path bundlePath = ::fwRuntime::getBundleResourcePath(std::string("uiTF"));
112 
113  const auto deletePath = bundlePath / "delete.png";
114  m_deleteButton = new QPushButton(QIcon(deletePath.string().c_str()), "");
115  m_deleteButton->setToolTip(QString("Delete"));
116 
117  const auto newPath = bundlePath / "new.png";
118  m_newButton = new QPushButton(QIcon(newPath.string().c_str()), "");
119  m_newButton->setToolTip(QString("New"));
120 
121  const auto reinitializePath = bundlePath / "reinitialize.png";
122  m_reinitializeButton = new QPushButton(QIcon(reinitializePath.string().c_str()), "");
123  m_reinitializeButton->setToolTip(QString("Reinitialize"));
124 
125  const auto renamePath = bundlePath / "rename.png";
126  m_renameButton = new QPushButton(QIcon(renamePath.string().c_str()), "");
127  m_renameButton->setToolTip(QString("Rename"));
128 
129  const auto importPath = bundlePath / "import.png";
130  m_importButton = new QPushButton(QIcon(importPath.string().c_str()), "");
131  m_importButton->setToolTip(QString("Import"));
132 
133  const auto exportPath = bundlePath / "export.png";
134  m_exportButton = new QPushButton(QIcon(exportPath.string().c_str()), "");
135  m_exportButton->setToolTip(QString("Export"));
136 
137  // Layout management
138  QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
139 
140  layout->addWidget(m_pTransferFunctionPreset);
141  layout->addWidget(m_deleteButton);
142  layout->addWidget(m_newButton);
143  layout->addWidget(m_reinitializeButton);
144  layout->addWidget(m_renameButton);
145  layout->addWidget(m_importButton);
146  layout->addWidget(m_exportButton);
147 
148  qtContainer->setLayout(layout);
149 
150  // Qt signals management ( connection to buttons )
151  QObject::connect(m_pTransferFunctionPreset, SIGNAL(activated(int)), this, SLOT(presetChoice(int)));
152  QObject::connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteTF()));
153  QObject::connect(m_newButton, SIGNAL(clicked()), this, SLOT(newTF()));
154  QObject::connect(m_reinitializeButton, SIGNAL(clicked()), this, SLOT(reinitializeTFPool()));
155  QObject::connect(m_renameButton, SIGNAL(clicked()), this, SLOT(renameTF()));
156  QObject::connect(m_importButton, SIGNAL(clicked()), this, SLOT(importTF()));
157  QObject::connect(m_exportButton, SIGNAL(clicked()), this, SLOT(exportTF()));
158 
159  // preset initialization
160  this->initTransferFunctions();
161 }
162 
163 //------------------------------------------------------------------------------
164 
166 {
168 }
169 
170 //------------------------------------------------------------------------------
171 
173 {
174  // Qt signals management ( disconnection )
175  QObject::disconnect(m_pTransferFunctionPreset, SIGNAL(activated(int)), this, SLOT(presetChoice(int)));
176  QObject::disconnect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteTF()));
177  QObject::disconnect(m_newButton, SIGNAL(clicked()), this, SLOT(newTF()));
178  QObject::disconnect(m_reinitializeButton, SIGNAL(clicked()), this, SLOT(reinitializeTFPool()));
179  QObject::disconnect(m_renameButton, SIGNAL(clicked()), this, SLOT(renameTF()));
180  QObject::disconnect(m_importButton, SIGNAL(clicked()), this, SLOT(importTF()));
181  QObject::disconnect(m_exportButton, SIGNAL(clicked()), this, SLOT(exportTF()));
182 
183  this->destroy();
184 }
185 
186 //------------------------------------------------------------------------------
187 
188 void TransferFunctionEditor::swapping(const KeyType& key)
189 {
190  if (key == s_CURRENT_TF_INPUT)
191  {
193  }
194 }
195 
196 //------------------------------------------------------------------------------
197 
198 void TransferFunctionEditor::presetChoice(int index)
199 {
200  m_pTransferFunctionPreset->setCurrentIndex(index);
201  this->updateTransferFunction();
202 
203  std::string tfName = m_pTransferFunctionPreset->currentText().toStdString();
204  bool isEnabled = (tfName != ::fwData::TransferFunction::s_DEFAULT_TF_NAME);
205 
206  m_renameButton->setEnabled(isEnabled);
207  m_deleteButton->setEnabled(isEnabled);
208 }
209 
210 //------------------------------------------------------------------------------
211 
212 void TransferFunctionEditor::deleteTF()
213 {
215  messageBox.setTitle("Deleting confirmation");
216  messageBox.setMessage("Are you sure you want to delete this transfer function?");
217  messageBox.setIcon(::fwGui::dialog::IMessageDialog::QUESTION);
218  messageBox.addButton(::fwGui::dialog::IMessageDialog::YES);
219  messageBox.addButton(::fwGui::dialog::IMessageDialog::CANCEL);
220  ::fwGui::dialog::IMessageDialog::Buttons answerCopy = messageBox.show();
221 
222  if (answerCopy != ::fwGui::dialog::IMessageDialog::CANCEL)
223  {
224  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
225  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
226 
227  if( poolTF->size() > 1 )
228  {
229  int indexSelectedTF = m_pTransferFunctionPreset->currentIndex();
230  std::string selectedTFKey = m_pTransferFunctionPreset->currentText().toStdString();
231 
232  ::fwDataTools::helper::Composite compositeHelper(poolTF);
233  SLM_ASSERT("TF '"+ selectedTFKey +"' missing in pool", this->hasTransferFunctionName(selectedTFKey));
234  compositeHelper.remove(selectedTFKey);
235 
236  {
237  auto sig = poolTF->signal< ::fwData::Composite::RemovedObjectsSignalType >(
239  ::fwCom::Connection::Blocker block(sig->getConnection(m_slotUpdate));
240  compositeHelper.notify();
241  }
242 
243  m_pTransferFunctionPreset->removeItem(indexSelectedTF);
244  std::string defaultTFName = ::fwData::TransferFunction::s_DEFAULT_TF_NAME;
245 
246  int index = m_pTransferFunctionPreset->findText(QString::fromStdString(defaultTFName));
247  index = std::max(index, 0);
248  this->presetChoice(index);
249  }
250  else
251  {
253  "Warning",
254  "You can not remove this transfer function because the program requires at least one.",
255  ::fwGui::dialog::IMessageDialog::WARNING );
256  }
257  }
258 }
259 
260 //------------------------------------------------------------------------------
261 
262 void TransferFunctionEditor::newTF()
263 {
264  std::string newName = m_selectedTF->getName();
265  if( this->hasTransferFunctionName(newName) )
266  {
267  newName = this->createTransferFunctionName(newName);
268  }
269 
270  fwGui::dialog::InputDialog inputDialog;
271  inputDialog.setTitle("Creating transfer function");
272  inputDialog.setMessage("Transfer function name:");
273  inputDialog.setInput( newName );
274  newName = inputDialog.getInput();
275 
276  if (!newName.empty())
277  {
278  if(!this->hasTransferFunctionName(newName))
279  {
280  ::fwData::TransferFunction::sptr pNewTransferFunction;
281 
282  pNewTransferFunction = ::fwData::Object::copy(m_selectedTF);
283  pNewTransferFunction->setName(newName);
284 
285  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
286  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
287 
288  ::fwDataTools::helper::Composite compositeHelper(poolTF);
289  compositeHelper.add(newName, pNewTransferFunction);
290 
291  m_pTransferFunctionPreset->addItem(QString(newName.c_str()));
292  m_pTransferFunctionPreset->setCurrentIndex(m_pTransferFunctionPreset->count()-1);
293  this->updateTransferFunction();
294 
295  compositeHelper.notify();
296  }
297  else
298  {
300  "Warning",
301  "This transfer function name already exists so you can not overwrite it.",
302  ::fwGui::dialog::IMessageDialog::WARNING);
303  }
304  }
305 }
306 
307 //------------------------------------------------------------------------------
308 
309 void TransferFunctionEditor::reinitializeTFPool()
310 {
312  messageBox.setTitle("Reinitializing confirmation");
313  messageBox.setMessage("Are you sure you want to reinitialize all transfer functions?");
314  messageBox.setIcon(::fwGui::dialog::IMessageDialog::QUESTION);
315  messageBox.addButton(::fwGui::dialog::IMessageDialog::YES);
316  messageBox.addButton(::fwGui::dialog::IMessageDialog::CANCEL);
317  ::fwGui::dialog::IMessageDialog::Buttons answerCopy = messageBox.show();
318 
319  if (answerCopy != ::fwGui::dialog::IMessageDialog::CANCEL)
320  {
321  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
322  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
323 
324  ::fwDataTools::helper::Composite compositeHelper(poolTF);
325  compositeHelper.clear();
326  compositeHelper.notify();
327 
328  this->initTransferFunctions();
329 
330  this->updateTransferFunction();
331  }
332 }
333 
334 //------------------------------------------------------------------------------
335 
336 void TransferFunctionEditor::renameTF()
337 {
338  std::string str = m_pTransferFunctionPreset->currentText().toStdString();
339  std::string newName(str);
340 
341  fwGui::dialog::InputDialog inputDialog;
342  inputDialog.setTitle("Creating transfer function");
343  inputDialog.setMessage("Transfer function name:");
344  inputDialog.setInput( newName );
345  newName = inputDialog.getInput();
346 
347  if (!newName.empty() && newName != str)
348  {
349  if( !this->hasTransferFunctionName(newName) )
350  {
351  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
352  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
353 
354  ::fwData::TransferFunction::sptr pTF;
355  pTF = ::fwData::TransferFunction::dynamicCast((*poolTF)[str]);
356  pTF->setName(newName);
357 
358  ::fwDataTools::helper::Composite compositeHelper(poolTF);
359  compositeHelper.remove(str);
360  compositeHelper.add(newName, pTF);
361  compositeHelper.notify();
362 
363  m_pTransferFunctionPreset->setItemText(m_pTransferFunctionPreset->currentIndex(), QString(newName.c_str()));
364  m_pTransferFunctionPreset->setCurrentIndex(m_pTransferFunctionPreset->findText(QString(newName.c_str())));
365 
366  this->updateTransferFunction();
367  }
368  else
369  {
371  messageBox.setTitle("Warning");
372  messageBox.setMessage("This transfer function name already exists so you can not overwrite it.");
373  messageBox.setIcon(::fwGui::dialog::IMessageDialog::WARNING);
374  messageBox.addButton(::fwGui::dialog::IMessageDialog::OK);
375  messageBox.show();
376  }
377  }
378  if ( newName.empty() )
379  {
381  messageBox.setTitle("Warning");
382  messageBox.setMessage("You have to give a name to your transfer function.");
383  messageBox.setIcon(::fwGui::dialog::IMessageDialog::WARNING);
384  messageBox.addButton(::fwGui::dialog::IMessageDialog::OK);
385  messageBox.show();
386  }
387 }
388 
389 //------------------------------------------------------------------------------
390 
391 void TransferFunctionEditor::importTF()
392 {
393  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
394  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
395 
396  ::fwDataTools::helper::Composite compositeHelper(poolTF);
397 
398  ::fwData::TransferFunction::sptr tf = ::fwData::TransferFunction::New();
399  ::fwIO::IReader::sptr reader = ::fwServices::add< ::fwIO::IReader >("::ioAtoms::SReader");
400 
401  reader->registerInOut(tf, ::fwIO::s_DATA_KEY);
402 
403  reader->start();
404  reader->configureWithIHM();
405  reader->update().wait();
406  reader->stop().wait();
407  ::fwServices::OSR::unregisterService(reader);
408 
409  if (!tf->getName().empty())
410  {
411  if( this->hasTransferFunctionName( tf->getName() ) )
412  {
413  tf->setName( this->createTransferFunctionName( tf->getName() ) );
414  }
415 
416  compositeHelper.add(tf->getName(), tf);
417  m_pTransferFunctionPreset->addItem(QString(tf->getName().c_str()));
418  this->presetChoice(static_cast<int>((*poolTF).size()-1));
419 
420  compositeHelper.notify();
421  }
422 }
423 
424 //------------------------------------------------------------------------------
425 
426 void TransferFunctionEditor::exportTF()
427 {
428  ::fwIO::IWriter::sptr writer = ::fwServices::add< ::fwIO::IWriter >("::ioAtoms::SWriter");
429 
430  writer->registerInput(m_selectedTF, ::fwIO::s_DATA_KEY);
431 
432  writer->start();
433  writer->configureWithIHM();
434  writer->update().wait();
435  writer->stop().wait();
436  ::fwServices::OSR::unregisterService(writer);
437 }
438 
439 //------------------------------------------------------------------------------
440 
442 {
443  // Get transfer function composite (pool TF)
444  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
445  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
446 
447  ::fwDataTools::helper::Composite compositeHelper(poolTF);
448 
449  const std::string defaultTFName = ::fwData::TransferFunction::s_DEFAULT_TF_NAME;
450  if(!this->hasTransferFunctionName(defaultTFName))
451  {
452  ::fwData::TransferFunction::sptr defaultTf = ::fwData::TransferFunction::createDefaultTF();
453  compositeHelper.add(defaultTFName, defaultTf);
454  }
455 
456  // Test if transfer function composite has few TF
457  if( poolTF->size() <= 1 )
458  {
459  // Parse all TF contained in uiTF Bundle's resources
460  std::vector< ::boost::filesystem::path > paths;
461  for(::boost::filesystem::path dirPath : m_paths)
462  {
463  SLM_ASSERT("Invalid directory path '"+dirPath.string()+"'", ::boost::filesystem::exists(dirPath));
464  for(::boost::filesystem::directory_iterator it(dirPath);
465  it != ::boost::filesystem::directory_iterator();
466  ++it )
467  {
468  if(!::boost::filesystem::is_directory(*it) &&
469  ::boost::filesystem::extension(*it) == ".json")
470  {
471  paths.push_back(*it);
472  }
473  }
474  }
475 
476  ::fwData::TransferFunction::sptr tf = ::fwData::TransferFunction::New();
477  ::fwIO::IReader::sptr reader = ::fwServices::add< ::fwIO::IReader >("::ioAtoms::SReader");
478  reader->registerInOut(tf, ::fwIO::s_DATA_KEY);
479 
480  ::fwRuntime::EConfigurationElement::sptr srvCfg = ::fwRuntime::EConfigurationElement::New("service");
481  ::fwRuntime::EConfigurationElement::sptr fileCfg = ::fwRuntime::EConfigurationElement::New("file");
482  srvCfg->addConfigurationElement(fileCfg);
483 
484  for( ::boost::filesystem::path file : paths )
485  {
486  fileCfg->setValue(file.string());
487  reader->setConfiguration(srvCfg);
488  reader->configure();
489  reader->start();
490  reader->update();
491  reader->stop();
492 
493  if (!tf->getName().empty())
494  {
495  ::fwData::TransferFunction::sptr newTF = ::fwData::Object::copy< ::fwData::TransferFunction >(tf);
496  if( this->hasTransferFunctionName( newTF->getName() ) )
497  {
498  newTF->setName( this->createTransferFunctionName( newTF->getName() ) );
499  }
500 
501  compositeHelper.add(newTF->getName(), newTF);
502  }
503  tf->initTF();
504  }
505  ::fwServices::OSR::unregisterService(reader);
506  }
507  compositeHelper.notify();
508 
510 }
511 
512 //---------------------------------------------------------------------------------------------------------------------
513 
515 {
516  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
517  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
518 
519  const std::string defaultTFName = ::fwData::TransferFunction::s_DEFAULT_TF_NAME;
520  // Manage TF preset
521  m_pTransferFunctionPreset->clear();
522  for(::fwData::Composite::value_type elt : *poolTF)
523  {
524  m_pTransferFunctionPreset->addItem( elt.first.c_str() );
525  }
526 
527  std::string currentTFName = defaultTFName;
528  ::fwData::TransferFunction::csptr tf = this->getInput< ::fwData::TransferFunction >(s_CURRENT_TF_INPUT);
529 
530  if (tf)
531  {
532  currentTFName = tf->getName();
533  }
534  else if (m_selectedTF)
535  {
536  currentTFName = m_selectedTF->getName();
537  }
538 
539  int index = m_pTransferFunctionPreset->findText( QString::fromStdString(currentTFName) );
540  index = std::max(index, 0);
541 
542  this->presetChoice(index);
543 }
544 
545 //------------------------------------------------------------------------------
546 
547 bool TransferFunctionEditor::hasTransferFunctionName(const std::string& _sName) const
548 {
549  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
550  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
551  return poolTF->find(_sName) != poolTF->end();
552 }
553 
554 //------------------------------------------------------------------------------
555 
556 std::string TransferFunctionEditor::createTransferFunctionName(const std::string& _sBasename) const
557 {
558  bool bHasTransferFunctionName = true;
559  std::string newName = _sBasename;
560  int cpt = 1;
561  while (bHasTransferFunctionName)
562  {
563  std::stringstream tmpStr;
564  tmpStr << _sBasename << "_" << cpt;
565  newName = tmpStr.str();
566  bHasTransferFunctionName = this->hasTransferFunctionName(newName);
567  cpt++;
568  }
569 
570  return newName;
571 }
572 
573 //------------------------------------------------------------------------------
574 
576 {
577  ::fwData::Composite::sptr poolTF = this->getInOut< ::fwData::Composite >(s_TF_POOL_INOUT);
578  SLM_ASSERT("inout '" + s_TF_POOL_INOUT + "' is not defined.", poolTF);
579 
580  std::string newSelectedTFKey = m_pTransferFunctionPreset->currentText().toStdString();
581  SLM_DEBUG("Transfer function selected : " + newSelectedTFKey);
582 
583  SLM_ASSERT("TF '"+ newSelectedTFKey +"' missing in pool", this->hasTransferFunctionName(newSelectedTFKey));
584 
585  ::fwData::Object::sptr newSelectedTF = (*poolTF)[newSelectedTFKey];
586 
587  if(newSelectedTF && m_selectedTF != newSelectedTF)
588  {
589  this->setOutput(s_TF_OUTPUT, newSelectedTF);
590  m_selectedTF = ::fwData::TransferFunction::dynamicCast(newSelectedTF);
591  }
592 }
593 
594 //------------------------------------------------------------------------------
595 
597 {
598  KeyConnectionsMap connections;
599  connections.push( s_TF_POOL_INOUT, ::fwData::Composite::s_ADDED_OBJECTS_SIG, s_UPDATE_SLOT);
600  connections.push( s_TF_POOL_INOUT, ::fwData::Composite::s_CHANGED_OBJECTS_SIG, s_UPDATE_SLOT);
601  connections.push( s_TF_POOL_INOUT, ::fwData::Composite::s_REMOVED_OBJECTS_SIG, s_UPDATE_SLOT);
602 
603  return connections;
604 }
605 
606 //------------------------------------------------------------------------------
607 
608 } // end namespace
FWDATATOOLS_API void remove(std::string _compositeKey)
Remove an object in the composite.
UITF_API bool hasTransferFunctionName(const std::string &_sName) const
Check if the image contain the specified TF.
This class is a helper to define the connections of a service and its data.
Definition: IService.hpp:454
virtual UITF_API KeyConnectionsMap getAutoConnections() const override
Returns proposals to connect service slots to associated object signals, this method is used for obj/...
virtual UITF_API ~TransferFunctionEditor() noexcept
Basic destructor, do nothing.
static FWDATA_API const std::string s_DEFAULT_TF_NAME
Default transfer function name.
FWDATATOOLS_API void notify()
Send the message of modification.
virtual UITF_API void stopping() override
Stop the TransferFunctionEditor, disconnect Buttons and Combo Box, delete them and clean the containe...
Class allowing to block a Connection.
Definition: Connection.hpp:20
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
Defines the service interface managing the editor service for object.
Definition: IEditor.hpp:25
Defines the generic message box for IHM. Use the Delegate design pattern.
static FWGUI_API IMessageDialog::Buttons showMessageDialog(const std::string &title, const std::string &message,::fwGui::dialog::IMessageDialog::Icons icon=INFO)
FWGUI_API void destroy()
Stops sub-views and toobar services. Destroys view, sub-views and toolbar containers.
virtual FWGUI_API void setMessage(const std::string &msg) override
Set the message.
FWDATATOOLS_API void add(std::string _compositeKey,::fwData::Object::sptr _newObject)
Add an object in the composite.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CHANGED_OBJECTS_SIG
Type of signal when objects are added.
virtual UITF_API void starting() override
Start the TransferFunctionEditor, create Container, place in Buttons, ComboBox, Layout, and connect them.
Defines an helper to modify an fwData::Composite and create in parallel the message to announce this ...
virtual void swapping()
Swap the service from associated object to another object.
Definition: IService.hpp:613
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the input dialog.
virtual FWGUI_API std::string getInput() override
Get the input text in the input field.
#define SLM_DEBUG(message)
Definition: spyLog.hpp:239
UpdateSlotType::sptr m_slotUpdate
Slot to call update method.
Definition: IService.hpp:690
FWSERVICES_API void setOutput(const ::fwServices::IService::KeyType &key, const ::fwData::Object::sptr &object, size_t index=0)
Register an output object at a given key in the OSR, replacing it if it already exists.
Definition: IService.cpp:80
Editor to select a transfer function.
virtual FWGUI_API void addButton(IMessageDialog::Buttons button) override
Add a button (OK, YES_NO, YES, NO, CANCEL)
virtual FWGUI_API IMessageDialog::Buttons show() override
Show the message box and return the clicked button.
FWDATATOOLS_API void clear()
Clear all objects in the composite.
Transfert functions editor.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_OBJECTS_SIG
Type of signal when objects are added.
UITF_API void updateTransferFunction()
Update the output transferFunction with the selected TF in the ComboBox.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
Defines the generic input dialog for IHM. Use the Delegate design pattern.
virtual UITF_API void updating() override
Update the TransferFunctionEditor, do nothing.
FWGUI_API void create()
Creates view, sub-views and toolbar containers. Manages sub-views and toobar services.
virtual FWGUI_API void setIcon(IMessageDialog::Icons icon) override
Set the icon (CRITICAL, WARNING, INFO or QUESTION)
#define SLM_FATAL_IF(message, cond)
Definition: spyLog.hpp:287
UITF_API void updateTransferFunctionPreset()
Update the TF preset from the TF pool.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_OBJECTS_SIG
Type of signal when objects are added.
UITF_API void initTransferFunctions()
Initialize the transfer functions.
virtual FWGUI_API void setInput(const std::string &text) override
Set the input text in the input field.
virtual UITF_API void configuring() override
Configure the transfer function editor.
static FWSERVICES_APIconst::fwCom::Slots::SlotKeyType s_UPDATE_SLOT
Slot to call start method.
Definition: IService.hpp:177
virtual FWGUI_API void setTitle(const std::string &title) override
Set the title of the message box.
UITF_API std::string createTransferFunctionName(const std::string &_sBasename) const
FWGUI_API void initialize()
Initialize managers.
UITF_API TransferFunctionEditor()
Basic constructor, do nothing.
FWSERVICES_API ConfigType getConfigTree() const
Return the configuration, in an boost property tree.
Definition: IService.cpp:247