24 #include <qapplication.h>
26 #include <qmessagebox.h>
27 #include <qtoolbutton.h>
40 m_DisplayedGroups(
"default"),
43 m_GenerateAccelerators(false),
44 m_ToolGUIWidget(NULL),
46 m_ToolButtonGroup(NULL),
48 m_EnabledMode(EnabledWithReferenceAndWorkingDataVisible)
50 QFont currentFont = QWidget::font();
51 currentFont.setBold(
true);
52 QWidget::setFont(currentFont);
64 QWidget::setContentsMargins(0, 0, 0, 0);
67 layout()->setContentsMargins(0, 0, 0, 0);
85 QWidget::setEnabled(
false);
120 if (QWidget::isEnabled())
136 if (QWidget::isEnabled())
147 if (!QWidget::isEnabled())
153 QToolButton *toolButton =
dynamic_cast<QToolButton *
>(
m_ToolButtonGroup->buttons().at(
id));
164 toolButton->setChecked(
false);
191 bool emitSignal =
true;
193 if (tool && std::string(tool->
GetGroup()) ==
"organ_segmentation")
220 QToolButton *toolButton(NULL);
233 QAbstractButton *tmpBtn = 0;
234 QList<QAbstractButton *>::iterator it;
238 if (tmpBtn != toolButton)
239 dynamic_cast<QToolButton *
>(tmpBtn)->setChecked(
false);
242 toolButton->setChecked(
true);
259 gui->move(gui->geometry().topLeft());
270 layout->addWidget(gui);
280 QToolButton *selectedToolButton =
dynamic_cast<QToolButton *
>(
m_ToolButtonGroup->checkedButton());
283 if (selectedToolButton)
286 selectedToolButton->setChecked(
false);
297 MITK_DEBUG <<
"OnToolManagerReferenceDataModified()";
307 MITK_DEBUG <<
"OnToolManagerWorkingDataModified()";
329 enabled = referenceNode && workingNode &&
337 enabled = referenceNode && isVisible();
340 enabled = workingNode && isVisible();
343 enabled = isVisible();
347 if (QWidget::isEnabled() == enabled)
350 QWidget::setEnabled(enabled);
402 QList<QAbstractButton *>::iterator it;
403 QAbstractButton *btn;
405 for (it = l.begin(); it != l.end(); ++it)
417 typedef std::pair<std::string::size_type, const mitk::Tool *> SortPairType;
418 typedef std::priority_queue<SortPairType> SortedToolQueueType;
419 SortedToolQueueType toolPositions;
423 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allPossibleTools.begin();
424 iter != allPossibleTools.end();
432 if (!
m_DisplayedGroups.empty() && namePos == std::string::npos && groupPos == std::string::npos)
437 namePos =
static_cast<std::string::size_type
>(tool->
GetName()[0]);
440 SortPairType thisPair = std::make_pair(namePos < groupPos ? namePos : groupPos, *iter);
441 toolPositions.push(thisPair);
445 MITK_DEBUG <<
"Sorting order of tools (lower number --> earlier in button group)";
446 while (!toolPositions.empty())
448 SortPairType thisPair = toolPositions.top();
449 MITK_DEBUG <<
"Position " << thisPair.first <<
" : " << thisPair.second->GetName();
451 allTools.push_back(thisPair.second);
454 std::reverse(allTools.begin(), allTools.end());
457 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter)
459 MITK_DEBUG << (*iter)->GetName();
474 int currentButtonID(0);
477 QToolButton *button = 0;
479 MITK_DEBUG <<
"Creating buttons for tools";
481 for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter)
494 button =
new QToolButton;
495 button->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
497 MITK_DEBUG <<
"Adding button with ID " << currentToolID;
500 MITK_DEBUG <<
"Adding button in row/column " << row <<
"/" << column;
507 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
513 button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
518 button->setCheckable(
true);
521 button->setChecked(
true);
529 QString tooltip = tool->
GetName();
530 MITK_DEBUG << tool->
GetName() <<
", " << label.toLocal8Bit().constData() <<
", '"
531 << tooltip.toLocal8Bit().constData();
541 button->setText(label);
542 button->setToolTip(tooltip);
545 QFont currentFont = button->font();
546 currentFont.setBold(
false);
547 button->setFont(currentFont);
554 button->setIcon(QIcon(QPixmap(tool->
GetXPM())));
559 resourceStream.seekg(0, std::ios::end);
560 std::ios::pos_type length = resourceStream.tellg();
561 resourceStream.seekg(0, std::ios::beg);
563 char *data =
new char[length];
564 resourceStream.read(data, length);
566 pixmap.loadFromData(QByteArray::fromRawData(data, length));
567 QIcon *icon =
new QIcon(pixmap);
570 button->setIcon(*icon);
575 button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
577 button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
579 button->setIconSize(QSize(24, 24));
583 button->setToolButtonStyle(Qt::ToolButtonIconOnly);
584 button->setIconSize(QSize(32, 32));
585 button->setToolTip(tooltip);
591 QString firstLetter = QString(tool->
GetName());
592 firstLetter.truncate(1);
600 button->setEnabled(
false);
605 MITK_DEBUG <<
"m_ButtonIDForToolID[" << currentToolID <<
"] == " << currentButtonID;
606 MITK_DEBUG <<
"m_ToolIDForButtonID[" << currentButtonID <<
"] == " << currentToolID;
627 qApp->processEvents();
632 QMessageBox::critical(
633 this,
"MITK", QString(s.c_str()), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
638 QMessageBox::information(
639 this,
"MITK", QString(s.c_str()), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton);
646 QString q_DisplayedGroups = toolGroups.c_str();
648 q_DisplayedGroups = q_DisplayedGroups.replace(QRegExp(
"\\b(\\w+)\\b|'([^']+)'"),
"'\\1\\2'");
649 MITK_DEBUG <<
"m_DisplayedGroups was \"" << toolGroups <<
"\"";
697 QWidget::showEvent(e);
703 QWidget::hideEvent(e);
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
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 ...
Class for nodes of the DataTree.