21 #include <qapplication.h> 23 #include <qmessagebox.h> 24 #include <qtoolbutton.h> 37 m_DisplayedGroups(
"default"),
40 m_GenerateAccelerators(false),
41 m_ToolGUIWidget(nullptr),
42 m_LastToolGUI(nullptr),
43 m_ToolButtonGroup(nullptr),
44 m_ButtonLayout(nullptr),
45 m_EnabledMode(EnabledWithReferenceAndWorkingDataVisible)
47 QFont currentFont = QWidget::font();
48 currentFont.setBold(
true);
49 QWidget::setFont(currentFont);
61 QWidget::setContentsMargins(0, 0, 0, 0);
62 if (layout() !=
nullptr)
64 layout()->setContentsMargins(0, 0, 0, 0);
82 QWidget::setEnabled(
false);
117 if (QWidget::isEnabled())
133 if (QWidget::isEnabled())
144 if (!QWidget::isEnabled())
150 QToolButton *toolButton =
dynamic_cast<QToolButton *
>(
m_ToolButtonGroup->buttons().at(
id));
161 toolButton->setChecked(
false);
188 bool emitSignal =
true;
190 if (tool && std::string(tool->
GetGroup()) ==
"organ_segmentation")
217 QToolButton *toolButton(
nullptr);
230 QAbstractButton *tmpBtn =
nullptr;
231 QList<QAbstractButton *>::iterator it;
235 if (tmpBtn != toolButton)
236 dynamic_cast<QToolButton *
>(tmpBtn)->setChecked(
false);
239 toolButton->setChecked(
true);
244 itk::Object::Pointer possibleGUI = tool->
GetGUI(
"Qmitk",
"GUI").GetPointer();
246 if (possibleGUI.IsNull())
247 possibleGUI = tool->
GetGUI(
"",
"GUI").GetPointer();
260 gui->move(gui->geometry().topLeft());
271 layout->addWidget(gui);
281 QToolButton *selectedToolButton =
dynamic_cast<QToolButton *
>(
m_ToolButtonGroup->checkedButton());
284 if (selectedToolButton)
287 selectedToolButton->setChecked(
false);
298 MITK_DEBUG <<
"OnToolManagerReferenceDataModified()";
308 MITK_DEBUG <<
"OnToolManagerWorkingDataModified()";
330 enabled = referenceNode && workingNode &&
338 enabled = referenceNode && isVisible();
341 enabled = workingNode && isVisible();
344 enabled = isVisible();
348 if (QWidget::isEnabled() == enabled)
351 QWidget::setEnabled(enabled);
403 QList<QAbstractButton *>::iterator it;
404 QAbstractButton *btn;
406 for (it = l.begin(); it != l.end(); ++it)
418 typedef std::pair<std::string::size_type, const mitk::Tool *> SortPairType;
419 typedef std::priority_queue<SortPairType> SortedToolQueueType;
420 SortedToolQueueType toolPositions;
424 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allPossibleTools.begin();
425 iter != allPossibleTools.end();
433 if (!
m_DisplayedGroups.empty() && namePos == std::string::npos && groupPos == std::string::npos)
438 namePos =
static_cast<std::string::size_type
>(tool->
GetName()[0]);
441 SortPairType thisPair = std::make_pair(namePos < groupPos ? namePos : groupPos, *iter);
442 toolPositions.push(thisPair);
446 MITK_DEBUG <<
"Sorting order of tools (lower number --> earlier in button group)";
447 while (!toolPositions.empty())
449 SortPairType thisPair = toolPositions.top();
450 MITK_DEBUG <<
"Position " << thisPair.first <<
" : " << thisPair.second->GetName();
452 allTools.push_back(thisPair.second);
455 std::reverse(allTools.begin(), allTools.end());
458 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter)
460 MITK_DEBUG << (*iter)->GetName();
475 int currentButtonID(0);
478 QToolButton *button =
nullptr;
480 MITK_DEBUG <<
"Creating buttons for tools";
482 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter)
495 button =
new QToolButton;
496 button->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
498 MITK_DEBUG <<
"Adding button with ID " << currentToolID;
501 MITK_DEBUG <<
"Adding button in row/column " << row <<
"/" << column;
508 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
514 button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
519 button->setCheckable(
true);
522 button->setChecked(
true);
530 QString tooltip = tool->
GetName();
531 MITK_DEBUG << tool->
GetName() <<
", " << label.toLocal8Bit().constData() <<
", '" 532 << tooltip.toLocal8Bit().constData();
542 button->setText(label);
543 button->setToolTip(tooltip);
546 QFont currentFont = button->font();
547 currentFont.setBold(
false);
548 button->setFont(currentFont);
555 button->setIcon(QIcon(QPixmap(tool->
GetXPM())));
559 auto isSVG =
"svg" == iconResource.
GetSuffix();
563 resourceStream.seekg(0, std::ios::end);
564 std::ios::pos_type length = resourceStream.tellg();
565 resourceStream.seekg(0, std::ios::beg);
567 char *data =
new char[length];
568 resourceStream.read(data, length);
577 pixmap.loadFromData(QByteArray::fromRawData(data, length));
578 button->setIcon(QIcon(pixmap));
586 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
588 button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
590 button->setIconSize(QSize(24, 24));
594 button->setToolButtonStyle(Qt::ToolButtonIconOnly);
595 button->setIconSize(QSize(32, 32));
596 button->setToolTip(tooltip);
602 QString firstLetter = QString(tool->
GetName());
603 firstLetter.truncate(1);
611 button->setEnabled(
false);
616 MITK_DEBUG <<
"m_ButtonIDForToolID[" << currentToolID <<
"] == " << currentButtonID;
617 MITK_DEBUG <<
"m_ToolIDForButtonID[" << currentButtonID <<
"] == " << currentToolID;
638 qApp->processEvents();
643 QMessageBox::critical(
644 this,
"MITK", QString(s.c_str()), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
649 QMessageBox::information(
650 this,
"MITK", QString(s.c_str()), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
657 QString q_DisplayedGroups = toolGroups.c_str();
659 q_DisplayedGroups = q_DisplayedGroups.replace(QRegExp(
"\\b(\\w+)\\b|'([^']+)'"),
"'\\1\\2'");
660 MITK_DEBUG <<
"m_DisplayedGroups was \"" << toolGroups <<
"\"";
708 QWidget::showEvent(e);
714 QWidget::hideEvent(e);
Data management class that handles 'was created by' relations.
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
static vtkRenderWindow * GetRenderWindowByName(const std::string &name)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
bool IsVisible(const mitk::BaseRenderer *renderer, const char *propertyKey="visible", bool defaultIsOn=true) const
Convenience access method for visibility properties (instances of BoolProperty). Return value is the ...
std::string GetSuffix() const
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
static QIcon ThemeIcon(const QByteArray &originalSVG)
Class for nodes of the DataTree.