diff --git a/Plugins/org.blueberry.ui.qt/resources/lightstyle.qss b/Plugins/org.blueberry.ui.qt/resources/lightstyle.qss
index 06d9317bbe..3b42dbabf6 100644
--- a/Plugins/org.blueberry.ui.qt/resources/lightstyle.qss
+++ b/Plugins/org.blueberry.ui.qt/resources/lightstyle.qss
@@ -1,76 +1,89 @@
/*
iconColor = #000000 <- This line is parsed by MITK
iconAccentColor = #2067bd <- This line is parsed by MITK
*/
+font.warning {
+ color: red;
+ font-weight: bold;
+}
+
+font.normal {
+ color: #000000;
+}
+
+font.highlight {
+ color: #2067bd;
+}
+
berry--QCTabBar::tab {
background: palette(window);
min-height: 24px;
border-top: 1px solid palette(mid);
border-left: 1px solid palette(mid);
border-bottom: 1px solid palette(mid);
margin-top: -1px;
padding-left: 5px
}
berry--QCTabBar::tab:only-one {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
min-height: 25px;
margin-left: -1px
}
berry--QCTabBar::tab:first {
margin-left: -1px;
border-left: 0px;
border-top-left-radius: 8px;
}
berry--QCTabBar::tab:last {
border-right: 1px solid palette(mid);
border-top-right-radius: 8px
}
berry--QCTabBar::tab:previous-selected {
border-left: 0px
}
berry--QCTabBar::tab:selected {
border-right: 1px solid palette(Mid);
border-bottom: 0px;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
berry--QCTabBar QToolButton {
border: 1px solid palette(window);
max-height: 22px;
background: palette(window);
}
berry--QCTabBar QToolButton#TabCloseButton
{
border: none;
background: none;
}
QWidget#TabTopRightControls {
border: 1px solid palette(mid);
border-left: 0px;
border-top: 0px;
border-right: 0px;
}
QWidget#ViewForm {
border: 1px solid palette(mid);
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
QWidget#StandaloneViewForm {
border: 1px solid palette(mid);
}
QWidget#PageCompositeControlWidget {
margin: 3px;
}
diff --git a/Plugins/org.mitk.gui.qt.common/files.cmake b/Plugins/org.mitk.gui.qt.common/files.cmake
index 00eee0b30e..2782b10fbe 100755
--- a/Plugins/org.mitk.gui.qt.common/files.cmake
+++ b/Plugins/org.mitk.gui.qt.common/files.cmake
@@ -1,63 +1,64 @@
set(SRC_CPP_FILES
QmitkAbstractRenderEditor.cpp
QmitkAbstractView.cpp
QmitkDataNodeSelectionProvider.cpp
QmitkDnDFrameWidget.cpp
QmitkSelectionServiceConnector.cpp
QmitkSliceNavigationListener.cpp
QmitkSingleNodeSelectionWidget.cpp
QmitkNodeSelectionDialog.cpp
QmitkAbstractNodeSelectionWidget.cpp
QmitkMultiNodeSelectionWidget.cpp
QmitkNodeSelectionPreferenceHelper.cpp
QmitkNodeSelectionButton.cpp
)
set(INTERNAL_CPP_FILES
QmitkCommonActivator.cpp
QmitkDataNodeItemModel.cpp
QmitkDataNodeSelection.cpp
QmitkViewCoordinator.cpp
QmitkNodeSelectionConstants.cpp
QmitkNodeSelectionPreferencePage.cpp
)
set(UI_FILES
src/QmitkSingleNodeSelectionWidget.ui
src/QmitkMultiNodeSelectionWidget.ui
src/QmitkNodeSelectionDialog.ui
src/internal/QmitkNodeSelectionPreferencePage.ui
)
set(MOC_H_FILES
src/QmitkAbstractRenderEditor.h
src/QmitkDnDFrameWidget.h
src/QmitkSelectionServiceConnector.h
src/QmitkSliceNavigationListener.h
src/ImporterUtil.h
src/QmitkSingleNodeSelectionWidget.h
src/QmitkNodeSelectionDialog.h
src/QmitkAbstractNodeSelectionWidget.h
src/QmitkMultiNodeSelectionWidget.h
src/QmitkNodeSelectionButton.h
src/internal/QmitkCommonActivator.h
src/internal/QmitkNodeSelectionPreferencePage.h
)
set(CACHED_RESOURCE_FILES
plugin.xml
resources/times.svg
)
set(QRC_FILES
+ resources/common.qrc
)
set(CPP_FILES )
foreach(file ${SRC_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/${file})
endforeach(file ${SRC_CPP_FILES})
foreach(file ${INTERNAL_CPP_FILES})
set(CPP_FILES ${CPP_FILES} src/internal/${file})
endforeach(file ${INTERNAL_CPP_FILES})
diff --git a/Plugins/org.mitk.gui.qt.common/resources/common.qrc b/Plugins/org.mitk.gui.qt.common/resources/common.qrc
new file mode 100644
index 0000000000..e7959f2329
--- /dev/null
+++ b/Plugins/org.mitk.gui.qt.common/resources/common.qrc
@@ -0,0 +1,5 @@
+
+
+ times.svg
+
+
diff --git a/Plugins/org.mitk.gui.qt.common/resources/times.svg b/Plugins/org.mitk.gui.qt.common/resources/times.svg
index 571a32a122..fdb8c5c03b 100644
--- a/Plugins/org.mitk.gui.qt.common/resources/times.svg
+++ b/Plugins/org.mitk.gui.qt.common/resources/times.svg
@@ -1 +1,52 @@
-
\ No newline at end of file
+
+
diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp
index 75dc649353..f0185589be 100644
--- a/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp
+++ b/Plugins/org.mitk.gui.qt.common/src/QmitkNodeSelectionButton.cpp
@@ -1,177 +1,176 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkNodeSelectionButton.h"
+// berry includes
+#include
+#include
+
#include "QPainter"
#include "QTextDocument"
#include
#include
-
// mitk core
#include
#include
#include
#include
#include
#include
// vtk
#include
QPixmap GetPixmapFromImageNode(const mitk::DataNode* dataNode, int height)
{
if (nullptr == dataNode)
{
return QPixmap();
}
const mitk::Image* image = dynamic_cast(dataNode->GetData());
if ((nullptr == image || !image->IsInitialized()) || // -> must be an image
(image->GetPixelType().GetNumberOfComponents() != 1)) // -> for now only single component are allowed
{
auto descManager = QmitkNodeDescriptorManager::GetInstance();
auto desc = descManager->GetDescriptor(dataNode);
auto icon = desc->GetIcon(dataNode);
auto fallBackMap = icon.pixmap(height, height);
return fallBackMap;
}
mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
int sliceNumber = image->GetDimension(2) / 2;
planeGeometry->InitializeStandardPlane(image->GetGeometry(), mitk::PlaneGeometry::Axial, sliceNumber);
mitk::ExtractSliceFilter::Pointer extractSliceFilter = mitk::ExtractSliceFilter::New();
extractSliceFilter->SetInput(image);
extractSliceFilter->SetInterpolationMode(mitk::ExtractSliceFilter::RESLICE_CUBIC);
extractSliceFilter->SetResliceTransformByGeometry(image->GetGeometry());
extractSliceFilter->SetWorldGeometry(planeGeometry);
extractSliceFilter->SetOutputDimensionality(2);
extractSliceFilter->SetVtkOutputRequest(true);
extractSliceFilter->Update();
vtkImageData* imageData = extractSliceFilter->GetVtkOutput();
mitk::LevelWindow levelWindow;
dataNode->GetLevelWindow(levelWindow);
vtkSmartPointer lookupTable = vtkSmartPointer::New();
lookupTable->SetRange(levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound());
lookupTable->SetSaturationRange(0.0, 0.0);
lookupTable->SetValueRange(0.0, 1.0);
lookupTable->SetHueRange(0.0, 0.0);
lookupTable->SetRampToLinear();
vtkSmartPointer levelWindowFilter = vtkSmartPointer::New();
levelWindowFilter->SetLookupTable(lookupTable);
levelWindowFilter->SetInputData(imageData);
levelWindowFilter->SetMinOpacity(0.0);
levelWindowFilter->SetMaxOpacity(1.0);
int dims[3];
imageData->GetDimensions(dims);
double clippingBounds[] = { 0.0, static_cast(dims[0]), 0.0, static_cast(dims[1]) };
levelWindowFilter->SetClippingBounds(clippingBounds);
levelWindowFilter->Update();
imageData = levelWindowFilter->GetOutput();
QImage thumbnailImage(reinterpret_cast(imageData->GetScalarPointer()), dims[0], dims[1], QImage::Format_ARGB32);
thumbnailImage = thumbnailImage.scaledToHeight(height,Qt::SmoothTransformation).rgbSwapped();
return QPixmap::fromImage(thumbnailImage);
}
QmitkNodeSelectionButton::QmitkNodeSelectionButton(QWidget *parent)
: QPushButton(parent), m_OutDatedThumpNail(true)
{ }
QmitkNodeSelectionButton::~QmitkNodeSelectionButton()
{
this->m_SelectedNode = nullptr;
}
void QmitkNodeSelectionButton::SetSelectedNode(mitk::DataNode* node)
{
if (m_SelectedNode != node)
{
this->m_SelectedNode = node;
this->m_OutDatedThumpNail = true;
}
this->update();
};
void QmitkNodeSelectionButton::SetNodeInfo(QString info)
{
this->m_Info = info;
this->update();
};
-// berry includes
-#include
-#include
-
void QmitkNodeSelectionButton::paintEvent(QPaintEvent *p)
{
QString stylesheet;
ctkPluginContext* context = berry::WorkbenchPlugin::GetDefault()->GetPluginContext();
ctkServiceReference styleManagerRef = context->getServiceReference();
if (styleManagerRef)
{
auto styleManager = context->getService(styleManagerRef);
stylesheet = styleManager->GetStylesheet();
}
-
+
QPushButton::paintEvent(p);
QPainter painter(this);
- QTextDocument td;
+ QTextDocument td(this);
td.setDefaultStyleSheet(stylesheet);
auto widgetSize = this->size();
QPoint origin = QPoint(5, 5);
if (this->m_SelectedNode)
{
auto iconLength = widgetSize.height() - 10;
auto node = this->m_SelectedNode;
if (this->m_OutDatedThumpNail)
{
this->m_ThumpNail = GetPixmapFromImageNode(node, iconLength);
this->m_OutDatedThumpNail = false;
}
painter.drawPixmap(origin, m_ThumpNail);
origin.setX(origin.x() + iconLength + 5);
td.setHtml(QString::fromStdString(""+node->GetName()+""));
}
else
{
td.setHtml(m_Info);
}
auto textSize = td.size();
origin.setY( (widgetSize.height() - textSize.height()) / 2.);
painter.translate(origin);
td.drawContents(&painter);
}
diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp b/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp
index 47c0118297..171b2d5b5f 100644
--- a/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp
+++ b/Plugins/org.mitk.gui.qt.common/src/QmitkSingleNodeSelectionWidget.cpp
@@ -1,212 +1,216 @@
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#include "QmitkSingleNodeSelectionWidget.h"
+#include
+
#include
QmitkSingleNodeSelectionWidget::QmitkSingleNodeSelectionWidget(QWidget* parent) : QmitkAbstractNodeSelectionWidget(parent)
{
m_Controls.setupUi(this);
m_Controls.btnSelect->installEventFilter(this);
m_Controls.btnSelect->setVisible(true);
m_Controls.btnClear->setVisible(false);
+ m_Controls.btnClear->setIcon(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/org.mitk.gui.qt.common/times.svg")));
+
this->UpdateInfo();
connect(m_Controls.btnClear, SIGNAL(clicked(bool)), this, SLOT(OnClearSelection()));
}
QmitkSingleNodeSelectionWidget::~QmitkSingleNodeSelectionWidget()
{
}
mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::ExtractCurrentValidSelection(const NodeList& nodes) const
{
mitk::DataNode::Pointer result = nullptr;
for (auto node : nodes)
{
bool valid = true;
if (m_NodePredicate.IsNotNull())
{
valid = m_NodePredicate->CheckNode(node);
}
if (valid)
{
result = node;
break;
}
}
return result;
}
QmitkSingleNodeSelectionWidget::NodeList QmitkSingleNodeSelectionWidget::CompileEmitSelection() const
{
NodeList result;
if (!m_SelectOnlyVisibleNodes)
{
result = m_ExternalSelection;
}
if (m_SelectedNode.IsNotNull() && !result.contains(m_SelectedNode))
{
result.append(m_SelectedNode);
}
return result;
}
void QmitkSingleNodeSelectionWidget::OnNodePredicateChanged(mitk::NodePredicateBase* /*newPredicate*/)
{
m_SelectedNode = this->ExtractCurrentValidSelection(m_ExternalSelection);
};
void QmitkSingleNodeSelectionWidget::OnDataStorageChanged()
{
};
void QmitkSingleNodeSelectionWidget::OnClearSelection()
{
if (m_IsOptional)
{
NodeList emptyList;
this->SetCurrentSelection(emptyList);
}
this->UpdateInfo();
}
mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::GetSelectedNode() const
{
return m_SelectedNode;
};
bool QmitkSingleNodeSelectionWidget::eventFilter(QObject *obj, QEvent *ev)
{
if (obj == m_Controls.btnSelect)
{
if (ev->type() == QEvent::MouseButtonRelease)
{
this->EditSelection();
return true;
}
}
return false;
}
void QmitkSingleNodeSelectionWidget::EditSelection()
{
QmitkNodeSelectionDialog* dialog = new QmitkNodeSelectionDialog(this, m_PopUpTitel, m_PopUpHint);
dialog->SetDataStorage(m_DataStorage.Lock());
dialog->SetNodePredicate(m_NodePredicate);
NodeList list;
if (m_SelectedNode.IsNotNull())
{
list.append(m_SelectedNode);
}
dialog->SetCurrentSelection(list);
dialog->SetSelectOnlyVisibleNodes(m_SelectOnlyVisibleNodes);
dialog->SetSelectionMode(QAbstractItemView::SingleSelection);
m_Controls.btnSelect->setChecked(true);
if (dialog->exec())
{
auto lastEmission = this->CompileEmitSelection();
auto nodes = dialog->GetSelectedNodes();
if (nodes.empty())
{
m_SelectedNode = nullptr;
}
else
{
m_SelectedNode = nodes.first();
}
auto newEmission = this->CompileEmitSelection();
if (!EqualNodeSelections(lastEmission, newEmission))
{
emit CurrentSelectionChanged(newEmission);
this->UpdateInfo();
}
}
m_Controls.btnSelect->setChecked(false);
delete dialog;
};
void QmitkSingleNodeSelectionWidget::UpdateInfo()
{
if (m_SelectedNode.IsNull())
{
if (m_IsOptional)
{
m_Controls.btnSelect->SetNodeInfo(m_EmptyInfo);
}
else
{
m_Controls.btnSelect->SetNodeInfo(m_InvalidInfo);
}
m_Controls.btnClear->setVisible(false);
}
else
{
m_Controls.btnClear->setVisible(m_IsOptional);
}
m_Controls.btnSelect->SetSelectedNode(m_SelectedNode);
};
void QmitkSingleNodeSelectionWidget::SetSelectOnlyVisibleNodes(bool selectOnlyVisibleNodes)
{
auto lastEmission = this->CompileEmitSelection();
m_SelectOnlyVisibleNodes = selectOnlyVisibleNodes;
auto newEmission = this->CompileEmitSelection();
if (!EqualNodeSelections(lastEmission, newEmission))
{
emit CurrentSelectionChanged(newEmission);
this->UpdateInfo();
}
};
void QmitkSingleNodeSelectionWidget::SetCurrentSelection(NodeList selectedNodes)
{
auto lastEmission = this->CompileEmitSelection();
m_ExternalSelection = selectedNodes;
m_SelectedNode = this->ExtractCurrentValidSelection(selectedNodes);
auto newEmission = this->CompileEmitSelection();
if (!EqualNodeSelections(lastEmission, newEmission))
{
emit CurrentSelectionChanged(newEmission);
this->UpdateInfo();
}
};