diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc
index 791d03ae51..bb5c69bb9e 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/QmitkDiffusionImaging.qrc
@@ -1,23 +1,26 @@
qball.png
tensor.png
dwi.png
dwiimport.png
quantification.png
reconodf.png
recontensor.png
texIntONIcon.png
texIntOFFIcon.png
vizControls.png
Refresh_48.png
QBallData24.png
glyphsoff_C.png
glyphsoff_S.png
glyphsoff_T.png
glyphson_C.png
glyphson_S.png
glyphson_T.png
FiberBundle.png
+ color24.gif
+ color48.gif
+ color64.gif
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color24.gif b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color24.gif
new file mode 100644
index 0000000000..07699c0173
Binary files /dev/null and b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color24.gif differ
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color48.gif b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color48.gif
new file mode 100644
index 0000000000..d206296c70
Binary files /dev/null and b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color48.gif differ
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color64.gif b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color64.gif
new file mode 100644
index 0000000000..be8b1bddcd
Binary files /dev/null and b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/resources/color64.gif differ
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp
index 1cdc1cf345..e85823fba1 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp
@@ -1,1463 +1,1484 @@
/*=========================================================================
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile$
Language: C++
Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $
Version: $Revision: 17495 $
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "QmitkControlVisualizationPropertiesView.h"
#include "mitkNodePredicateDataType.h"
#include "mitkDataNodeObject.h"
#include "mitkOdfNormalizationMethodProperty.h"
#include "mitkOdfScaleByProperty.h"
#include "mitkResliceMethodProperty.h"
#include "mitkRenderingManager.h"
#include "mitkDiffusionImage.h"
#include "mitkPlanarFigure.h"
#include "mitkFiberBundle.h"
#include "QmitkDataStorageComboBox.h"
#include "QmitkStdMultiWidget.h"
#include "mitkFiberBundleInteractor.h"
#include "mitkPlanarFigureInteractor.h"
#include "mitkGlobalInteraction.h"
#include "mitkGeometry2D.h"
#include "berryIWorkbenchWindow.h"
#include "berryIWorkbenchPage.h"
#include "berryISelectionService.h"
#include "berryConstants.h"
#include "berryPlatformUI.h"
#include "itkRGBAPixel.h"
#include "itkTractsToProbabilityImageFilter.h"
#include "qwidgetaction.h"
#include "qcolordialog.h"
const std::string QmitkControlVisualizationPropertiesView::VIEW_ID = "org.mitk.views.controlvisualizationpropertiesview";
using namespace berry;
struct CvpSelListener : ISelectionListener
{
berryObjectMacro(CvpSelListener);
CvpSelListener(QmitkControlVisualizationPropertiesView* view)
{
m_View = view;
}
void ApplySettings(mitk::DataNode::Pointer node)
{
bool do_vis;
node->GetBoolProperty("VisibleOdfs_T", do_vis);
if(do_vis)
{
m_View->m_Controls->m_VisibleOdfsON_T->setIcon(*m_View->m_IconGlyON_T);
m_View->m_Controls->m_VisibleOdfsON_T->setChecked(true);
m_View->m_GlyIsOn_T = true;
}
else
{
m_View->m_Controls->m_VisibleOdfsON_T->setIcon(*m_View->m_IconGlyOFF_T);
m_View->m_Controls->m_VisibleOdfsON_T->setChecked(false);
m_View->m_GlyIsOn_T = false;
}
node->GetBoolProperty("VisibleOdfs_C", do_vis);
if(do_vis)
{
m_View->m_Controls->m_VisibleOdfsON_C->setIcon(*m_View->m_IconGlyON_C);
m_View->m_Controls->m_VisibleOdfsON_C->setChecked(true);
m_View->m_GlyIsOn_C = true;
}
else
{
m_View->m_Controls->m_VisibleOdfsON_C->setIcon(*m_View->m_IconGlyOFF_C);
m_View->m_Controls->m_VisibleOdfsON_C->setChecked(false);
m_View->m_GlyIsOn_C = false;
}
node->GetBoolProperty("VisibleOdfs_S", do_vis);
if(do_vis)
{
m_View->m_Controls->m_VisibleOdfsON_S->setIcon(*m_View->m_IconGlyON_S);
m_View->m_Controls->m_VisibleOdfsON_S->setChecked(true);
m_View->m_GlyIsOn_S = true;
}
else
{
m_View->m_Controls->m_VisibleOdfsON_S->setIcon(*m_View->m_IconGlyOFF_S);
m_View->m_Controls->m_VisibleOdfsON_S->setChecked(false);
m_View->m_GlyIsOn_S = false;
}
bool tex_int;
node->GetBoolProperty("texture interpolation", tex_int);
if(tex_int)
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON);
m_View->m_Controls->m_TextureIntON->setChecked(true);
m_View->m_TexIsOn = true;
}
else
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF);
m_View->m_Controls->m_TextureIntON->setChecked(false);
m_View->m_TexIsOn = false;
}
int val;
node->GetIntProperty("ShowMaxNumber", val);
m_View->m_Controls->m_ShowMaxNumber->setValue(val);
m_View->m_Controls->m_NormalizationDropdown->setCurrentIndex(dynamic_cast(node->GetProperty("Normalization"))->GetValueAsId());
float fval;
node->GetFloatProperty("Scaling",fval);
m_View->m_Controls->m_ScalingFactor->setValue(fval);
m_View->m_Controls->m_AdditionalScaling->setCurrentIndex(dynamic_cast(node->GetProperty("ScaleBy"))->GetValueAsId());
node->GetFloatProperty("IndexParam1",fval);
m_View->m_Controls->m_IndexParam1->setValue(fval);
node->GetFloatProperty("IndexParam2",fval);
m_View->m_Controls->m_IndexParam2->setValue(fval);
}
void DoSelectionChanged(ISelection::ConstPointer selection)
{
// save current selection in member variable
m_View->m_CurrentSelection = selection.Cast();
m_View->m_Controls->m_VisibleOdfsON_T->setVisible(false);
m_View->m_Controls->m_VisibleOdfsON_S->setVisible(false);
m_View->m_Controls->m_VisibleOdfsON_C->setVisible(false);
m_View->m_Controls->m_TextureIntON->setVisible(false);
m_View->m_Controls->m_ImageControlsFrame->setVisible(false);
m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(false);
m_View->m_Controls->m_BundleControlsFrame->setVisible(false);
m_View->m_SelectedNode = 0;
if(m_View->m_CurrentSelection.IsNull())
return;
if(m_View->m_CurrentSelection->Size() == 1)
{
mitk::DataNodeObject::Pointer nodeObj = m_View->m_CurrentSelection->Begin()->Cast();
if(nodeObj.IsNotNull())
{
mitk::DataNode::Pointer node = nodeObj->GetDataNode();
if(dynamic_cast(node->GetData()) != 0)
{
m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(true);
m_View->m_SelectedNode = node;
}
if(dynamic_cast(node->GetData()) != 0)
{
MITK_INFO << "Node " << node.GetPointer();
MITK_INFO << "pick " << m_View->m_CurrentPickingNode;
m_View->m_Controls->m_BundleControlsFrame->setVisible(true);
m_View->m_SelectedNode = node;
if(m_View->m_CurrentPickingNode != 0 && node.GetPointer() != m_View->m_CurrentPickingNode)
{
m_View->m_Controls->m_SetInteractor->setEnabled(false);
}
else
{
m_View->m_Controls->m_SetInteractor->setEnabled(true);
}
mitk::ColorProperty* nodecolor= mitk::ColorProperty::New();
node->GetProperty(nodecolor,"color");
m_View->m_Controls->m_Color->setAutoFillBackground(true);
QString styleSheet = "background-color:rgb(";
styleSheet.append(QString::number(nodecolor->GetColor().GetRed()*255.0));
styleSheet.append(",");
styleSheet.append(QString::number(nodecolor->GetColor().GetGreen()*255.0));
styleSheet.append(",");
styleSheet.append(QString::number(nodecolor->GetColor().GetBlue()*255.0));
styleSheet.append(")");
m_View->m_Controls->m_Color->setStyleSheet(styleSheet);
}
}
}
if(m_View->m_CurrentSelection->Size() > 0 && m_View->m_SelectedNode == 0)
{
m_View->m_Controls->m_ImageControlsFrame->setVisible(true);
bool foundDiffusionImage = false;
bool foundQBIVolume = false;
bool foundTensorVolume = false;
bool foundImage = false;
bool foundMultipleOdfImages = false;
bool foundRGBAImage = false;
// do something with the selected items
if(m_View->m_CurrentSelection)
{
// iterate selection
for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin();
i != m_View->m_CurrentSelection->End(); ++i)
{
// extract datatree node
if (mitk::DataNodeObject::Pointer nodeObj = i->Cast())
{
mitk::DataNode::Pointer node = nodeObj->GetDataNode();
// only look at interesting types
if(QString("DiffusionImage").compare(node->GetData()->GetNameOfClass())==0)
{
foundDiffusionImage = true;
bool tex_int;
node->GetBoolProperty("texture interpolation", tex_int);
if(tex_int)
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON);
m_View->m_Controls->m_TextureIntON->setChecked(true);
m_View->m_TexIsOn = true;
}
else
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF);
m_View->m_Controls->m_TextureIntON->setChecked(false);
m_View->m_TexIsOn = false;
}
int val;
node->GetIntProperty("DisplayChannel", val);
m_View->m_Controls->m_DisplayIndex->setValue(val);
QString label = "Channel %1";
label = label.arg(val);
m_View->m_Controls->label_channel->setText(label);
int maxVal = (dynamic_cast* >(node->GetData()))->GetVectorImage()->GetVectorLength();
m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1);
}
else if(QString("QBallImage").compare(node->GetData()->GetNameOfClass())==0)
{
foundMultipleOdfImages = foundQBIVolume || foundTensorVolume;
foundQBIVolume = true;
ApplySettings(node);
}
else if(QString("TensorImage").compare(node->GetData()->GetNameOfClass())==0)
{
foundMultipleOdfImages = foundQBIVolume || foundTensorVolume;
foundTensorVolume = true;
ApplySettings(node);
}
else if(QString("Image").compare(node->GetData()->GetNameOfClass())==0)
{
foundImage = true;
mitk::Image::Pointer img = dynamic_cast(node->GetData());
if(img.IsNotNull() && img->GetPixelType().GetItkTypeId() == &typeid(itk::RGBAPixel) )
{
foundRGBAImage = true;
}
bool tex_int;
node->GetBoolProperty("texture interpolation", tex_int);
if(tex_int)
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON);
m_View->m_Controls->m_TextureIntON->setChecked(true);
m_View->m_TexIsOn = true;
}
else
{
m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF);
m_View->m_Controls->m_TextureIntON->setChecked(false);
m_View->m_TexIsOn = false;
}
}
+
+ else if(QString("PlanarFigure").compare(node->GetData()->GetNameOfClass())==0)
+ {
+ float val;
+ node->GetFloatProperty("planarfigure.line.width", val);
+ m_View->m_Controls->m_PFWidth->setValue((int)(val*10.0));
+
+ QString label = "Width %1";
+ label = label.arg(val);
+ m_View->m_Controls->label_pfwidth->setText(label);
+ }
}
}
}
m_View->m_Controls->m_DisplayIndex->setVisible(foundDiffusionImage);
m_View->m_Controls->label_channel->setVisible(foundDiffusionImage);
m_View->m_FoundSingleOdfImage = (foundQBIVolume || foundTensorVolume)
&& !foundMultipleOdfImages;
m_View->m_Controls->m_NumberGlyphsFrame->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_NormalizationDropdown->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->label->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_ScalingFactor->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_AdditionalScaling->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_NormalizationScalingFrame->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->OpacMinFrame->setVisible(foundRGBAImage || m_View->m_FoundSingleOdfImage);
// changed for SPIE paper, Principle curvature scaling
//m_View->m_Controls->params_frame->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->params_frame->setVisible(false);
m_View->m_Controls->m_VisibleOdfsON_T->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_VisibleOdfsON_S->setVisible(m_View->m_FoundSingleOdfImage);
m_View->m_Controls->m_VisibleOdfsON_C->setVisible(m_View->m_FoundSingleOdfImage);
bool foundAnyImage = foundDiffusionImage ||
foundQBIVolume || foundTensorVolume || foundImage;
m_View->m_Controls->m_Reinit->setVisible(foundAnyImage);
m_View->m_Controls->m_TextureIntON->setVisible(foundAnyImage);
m_View->m_Controls->m_TSMenu->setVisible(foundAnyImage);
if(m_View->m_IsInitialized)
{
//m_View->GetSite()->GetWorkbenchWindow()->GetActivePage()
// ->HideView(IViewPart::Pointer(m_View));
//berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()
// ->ShowView(QmitkControlVisualizationPropertiesView::VIEW_ID,
// "", berry::IWorkbenchPage::VIEW_VISIBLE);
}
}
}
void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection)
{
// check, if selection comes from datamanager
if (part)
{
QString partname(part->GetPartName().c_str());
if(partname.compare("Datamanager")==0)
{
// apply selection
DoSelectionChanged(selection);
}
}
}
QmitkControlVisualizationPropertiesView* m_View;
};
QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView()
: QmitkFunctionality(),
m_Controls(NULL),
m_MultiWidget(NULL),
m_IconTexOFF(new QIcon(":/QmitkDiffusionImaging/texIntOFFIcon.png")),
m_IconTexON(new QIcon(":/QmitkDiffusionImaging/texIntONIcon.png")),
m_IconGlyOFF_T(new QIcon(":/QmitkDiffusionImaging/glyphsoff_T.png")),
m_IconGlyON_T(new QIcon(":/QmitkDiffusionImaging/glyphson_T.png")),
m_IconGlyOFF_C(new QIcon(":/QmitkDiffusionImaging/glyphsoff_C.png")),
m_IconGlyON_C(new QIcon(":/QmitkDiffusionImaging/glyphson_C.png")),
m_IconGlyOFF_S(new QIcon(":/QmitkDiffusionImaging/glyphsoff_S.png")),
m_IconGlyON_S(new QIcon(":/QmitkDiffusionImaging/glyphson_S.png")),
m_CurrentSelection(0),
m_CurrentPickingNode(0)
{
currentThickSlicesMode = 1;
m_MyMenu = NULL;
}
QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other)
{
Q_UNUSED(other)
throw std::runtime_error("Copy constructor not implemented");
}
QmitkControlVisualizationPropertiesView::~QmitkControlVisualizationPropertiesView()
{
this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener);
}
void QmitkControlVisualizationPropertiesView::OnThickSlicesModeSelected( QAction* action )
{
currentThickSlicesMode = action->data().toInt();
switch(currentThickSlicesMode)
{
default:
case 1:
this->m_Controls->m_TSMenu->setText("MIP");
break;
case 2:
this->m_Controls->m_TSMenu->setText("SUM");
break;
case 3:
this->m_Controls->m_TSMenu->setText("WEIGH");
break;
}
mitk::DataNode* n;
n = GetDataStorage()->GetNamedNode("widget1Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
n = GetDataStorage()->GetNamedNode("widget2Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
n = GetDataStorage()->GetNamedNode("widget3Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
mitk::BaseRenderer::Pointer renderer =
this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer->GetRenderingManager()->RequestUpdateAll();
}
void QmitkControlVisualizationPropertiesView::OnTSNumChanged(int num)
{
if(num==0)
{
mitk::DataNode* n;
n = GetDataStorage()->GetNamedNode("widget1Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) );
n = GetDataStorage()->GetNamedNode("widget2Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) );
n = GetDataStorage()->GetNamedNode("widget3Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) );
}
else
{
mitk::DataNode* n;
n = GetDataStorage()->GetNamedNode("widget1Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
n = GetDataStorage()->GetNamedNode("widget2Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
n = GetDataStorage()->GetNamedNode("widget3Plane"); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) );
n = GetDataStorage()->GetNamedNode("widget1Plane"); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) );
n = GetDataStorage()->GetNamedNode("widget2Plane"); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) );
n = GetDataStorage()->GetNamedNode("widget3Plane"); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) );
}
m_TSLabel->setText(QString::number(num*2+1));
mitk::BaseRenderer::Pointer renderer =
this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer();
if(renderer.IsNotNull())
{
renderer->SendUpdateSlice();
}
renderer->GetRenderingManager()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS);
}
void QmitkControlVisualizationPropertiesView::CreateQtPartControl(QWidget *parent)
{
if (!m_Controls)
{
// create GUI widgets
m_Controls = new Ui::QmitkControlVisualizationPropertiesViewControls;
m_Controls->setupUi(parent);
this->CreateConnections();
m_MyMenu = new QMenu(parent);
connect( m_MyMenu, SIGNAL( aboutToShow() ), this, SLOT(OnMenuAboutToShow()) );
// button for changing rotation mode
m_Controls->m_TSMenu->setMenu( m_MyMenu );
//m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) );
m_Controls->params_frame->setVisible(false);
QIcon icon5(":/QmitkDiffusionImaging/Refresh_48.png");
m_Controls->m_Reinit->setIcon(icon5);
+ m_Controls->m_Focus->setIcon(icon5);
+
+ QIcon iconColor(":/QmitkDiffusionImaging/color24.gif");
+ m_Controls->m_PFColor->setIcon(iconColor);
+ m_Controls->m_PFColor3D->setIcon(iconColor);
m_Controls->m_TextureIntON->setCheckable(true);
m_Controls->m_VisibleOdfsON_T->setCheckable(true);
m_Controls->m_VisibleOdfsON_S->setCheckable(true);
m_Controls->m_VisibleOdfsON_C->setCheckable(true);
#ifndef DIFFUSION_IMAGING_EXTENDED
int size = m_Controls->m_AdditionalScaling->count();
for(int t=0; tm_AdditionalScaling->itemText(t).toStdString() == "Scale by ASR")
{
m_Controls->m_AdditionalScaling->removeItem(t);
}
}
#endif
m_Controls->m_OpacitySlider->setRange(0.0,1.0);
m_Controls->m_OpacitySlider->setLowerValue(0.0);
m_Controls->m_OpacitySlider->setUpperValue(0.0);
m_Controls->m_ScalingFrame->setVisible(false);
m_Controls->m_NormalizationFrame->setVisible(false);
}
m_IsInitialized = false;
m_SelListener = berry::ISelectionListener::Pointer(new CvpSelListener(this));
this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener);
berry::ISelection::ConstPointer sel(
this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager"));
m_CurrentSelection = sel.Cast();
m_SelListener.Cast()->DoSelectionChanged(sel);
m_IsInitialized = true;
}
void QmitkControlVisualizationPropertiesView::OnMenuAboutToShow ()
{
// THICK SLICE SUPPORT
QMenu *myMenu = m_MyMenu;
myMenu->clear();
QActionGroup* thickSlicesActionGroup = new QActionGroup(myMenu);
thickSlicesActionGroup->setExclusive(true);
mitk::BaseRenderer::Pointer renderer =
this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer();
int currentTSMode = 0;
{
mitk::ResliceMethodProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices" ));
if( m.IsNotNull() )
currentTSMode = m->GetValueAsId();
}
const int maxTS = 30;
int currentNum = 0;
{
mitk::IntProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices.num" ));
if( m.IsNotNull() )
{
currentNum = m->GetValue();
if(currentNum < 0) currentNum = 0;
if(currentNum > maxTS) currentNum = maxTS;
}
}
if(currentTSMode==0)
currentNum=0;
QSlider *m_TSSlider = new QSlider(myMenu);
m_TSSlider->setMinimum(0);
m_TSSlider->setMaximum(maxTS-1);
m_TSSlider->setValue(currentNum);
m_TSSlider->setOrientation(Qt::Horizontal);
connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) );
QHBoxLayout* _TSLayout = new QHBoxLayout;
_TSLayout->setContentsMargins(4,4,4,4);
_TSLayout->addWidget(m_TSSlider);
_TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),myMenu));
QWidget* _TSWidget = new QWidget;
_TSWidget->setLayout(_TSLayout);
QActionGroup* thickSliceModeActionGroup = new QActionGroup(myMenu);
thickSliceModeActionGroup->setExclusive(true);
QWidgetAction *m_TSSliderAction = new QWidgetAction(myMenu);
m_TSSliderAction->setDefaultWidget(_TSWidget);
myMenu->addAction(m_TSSliderAction);
QAction* mipThickSlicesAction = new QAction(myMenu);
mipThickSlicesAction->setActionGroup(thickSliceModeActionGroup);
mipThickSlicesAction->setText("MIP (max. intensity proj.)");
mipThickSlicesAction->setCheckable(true);
mipThickSlicesAction->setChecked(currentThickSlicesMode==1);
mipThickSlicesAction->setData(1);
myMenu->addAction( mipThickSlicesAction );
QAction* sumThickSlicesAction = new QAction(myMenu);
sumThickSlicesAction->setActionGroup(thickSliceModeActionGroup);
sumThickSlicesAction->setText("SUM (sum intensity proj.)");
sumThickSlicesAction->setCheckable(true);
sumThickSlicesAction->setChecked(currentThickSlicesMode==2);
sumThickSlicesAction->setData(2);
myMenu->addAction( sumThickSlicesAction );
QAction* weightedThickSlicesAction = new QAction(myMenu);
weightedThickSlicesAction->setActionGroup(thickSliceModeActionGroup);
weightedThickSlicesAction->setText("WEIGHTED (gaussian proj.)");
weightedThickSlicesAction->setCheckable(true);
weightedThickSlicesAction->setChecked(currentThickSlicesMode==3);
weightedThickSlicesAction->setData(3);
myMenu->addAction( weightedThickSlicesAction );
connect( thickSliceModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnThickSlicesModeSelected(QAction*)) );
}
void QmitkControlVisualizationPropertiesView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget)
{
m_MultiWidget = &stdMultiWidget;
}
void QmitkControlVisualizationPropertiesView::StdMultiWidgetNotAvailable()
{
m_MultiWidget = NULL;
}
void QmitkControlVisualizationPropertiesView::CreateConnections()
{
if ( m_Controls )
{
connect( (QObject*)(m_Controls->m_DisplayIndex), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) );
connect( (QObject*)(m_Controls->m_TextureIntON), SIGNAL(clicked()), this, SLOT(TextIntON()) );
connect( (QObject*)(m_Controls->m_Reinit), SIGNAL(clicked()), this, SLOT(Reinit()) );
connect( (QObject*)(m_Controls->m_VisibleOdfsON_T), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_T()) );
connect( (QObject*)(m_Controls->m_VisibleOdfsON_S), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_S()) );
connect( (QObject*)(m_Controls->m_VisibleOdfsON_C), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_C()) );
connect( (QObject*)(m_Controls->m_ShowMaxNumber), SIGNAL(editingFinished()), this, SLOT(ShowMaxNumberChanged()) );
connect( (QObject*)(m_Controls->m_NormalizationDropdown), SIGNAL(currentIndexChanged(int)), this, SLOT(NormalizationDropdownChanged(int)) );
connect( (QObject*)(m_Controls->m_ScalingFactor), SIGNAL(valueChanged(double)), this, SLOT(ScalingFactorChanged(double)) );
connect( (QObject*)(m_Controls->m_AdditionalScaling), SIGNAL(currentIndexChanged(int)), this, SLOT(AdditionalScaling(int)) );
connect( (QObject*)(m_Controls->m_IndexParam1), SIGNAL(valueChanged(double)), this, SLOT(IndexParam1Changed(double)) );
connect( (QObject*)(m_Controls->m_IndexParam2), SIGNAL(valueChanged(double)), this, SLOT(IndexParam2Changed(double)) );
connect( (QObject*)(m_Controls->m_ScalingCheckbox), SIGNAL(clicked()), this, SLOT(ScalingCheckbox()) );
connect( (QObject*)(m_Controls->m_OpacitySlider), SIGNAL(spanChanged(double,double)), this, SLOT(OpacityChanged(double,double)) );
connect((QObject*) m_Controls->m_Wire, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationWire()));
connect((QObject*) m_Controls->m_Tube, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationTube()));
connect((QObject*) m_Controls->m_Color, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationColor()));
connect((QObject*) m_Controls->m_Focus, SIGNAL(clicked()), (QObject*) this, SLOT(PlanarFigureFocus()));
connect((QObject*) m_Controls->m_SetInteractor, SIGNAL(clicked()), (QObject*) this, SLOT(SetInteractor()));
- connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(double)), (QObject*) this, SLOT(PFWidth(double)));
+ connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(PFWidth(int)));
connect((QObject*) m_Controls->m_PFColor, SIGNAL(clicked()), (QObject*) this, SLOT(PFColor()));
connect((QObject*) m_Controls->m_2DHeatmap, SIGNAL(clicked()), (QObject*) this, SLOT(Heatmap()));
}
}
void QmitkControlVisualizationPropertiesView::Activated()
{
berry::ISelection::ConstPointer sel(
this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager"));
m_CurrentSelection = sel.Cast();
m_SelListener.Cast()->DoSelectionChanged(sel);
QmitkFunctionality::Activated();
}
void QmitkControlVisualizationPropertiesView::Deactivated()
{
QmitkFunctionality::Deactivated();
}
int QmitkControlVisualizationPropertiesView::GetSizeFlags(bool width)
{
if(!width)
{
return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL;
}
else
{
return 0;
}
}
int QmitkControlVisualizationPropertiesView::ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult)
{
if(width==false)
{
return m_FoundSingleOdfImage ? 120 : 80;
}
else
{
return preferredResult;
}
}
mitk::DataStorage::SetOfObjects::Pointer
QmitkControlVisualizationPropertiesView::ActiveSet(std::string classname)
{
if (m_CurrentSelection)
{
mitk::DataStorage::SetOfObjects::Pointer set =
mitk::DataStorage::SetOfObjects::New();
int at = 0;
for (IStructuredSelection::iterator i = m_CurrentSelection->Begin();
i != m_CurrentSelection->End();
++i)
{
if (mitk::DataNodeObject::Pointer nodeObj = i->Cast())
{
mitk::DataNode::Pointer node = nodeObj->GetDataNode();
if(QString(classname.c_str()).compare(node->GetData()->GetNameOfClass())==0)
{
set->InsertElement(at++, node);
}
}
}
return set;
}
return 0;
}
void QmitkControlVisualizationPropertiesView::SetBoolProp(
mitk::DataStorage::SetOfObjects::Pointer set,
std::string name, bool value)
{
if(set.IsNotNull())
{
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetBoolProperty(name.c_str(), value);
++itemiter;
}
}
}
void QmitkControlVisualizationPropertiesView::SetIntProp(
mitk::DataStorage::SetOfObjects::Pointer set,
std::string name, int value)
{
if(set.IsNotNull())
{
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetIntProperty(name.c_str(), value);
++itemiter;
}
}
}
void QmitkControlVisualizationPropertiesView::SetFloatProp(
mitk::DataStorage::SetOfObjects::Pointer set,
std::string name, float value)
{
if(set.IsNotNull())
{
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetFloatProperty(name.c_str(), value);
++itemiter;
}
}
}
void QmitkControlVisualizationPropertiesView::SetLevelWindowProp(
mitk::DataStorage::SetOfObjects::Pointer set,
std::string name, mitk::LevelWindow value)
{
if(set.IsNotNull())
{
mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(value);
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetProperty(name.c_str(), prop);
++itemiter;
}
}
}
void QmitkControlVisualizationPropertiesView::SetEnumProp(
mitk::DataStorage::SetOfObjects::Pointer set,
std::string name, mitk::EnumerationProperty::Pointer value)
{
if(set.IsNotNull())
{
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetProperty(name.c_str(), value);
++itemiter;
}
}
}
void QmitkControlVisualizationPropertiesView::DisplayIndexChanged(int dispIndex)
{
QString label = "Channel %1";
label = label.arg(dispIndex);
m_Controls->label_channel->setText(label);
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("DiffusionImage");
if(set.IsNotNull())
{
mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() );
mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() );
while ( itemiter != itemiterend )
{
(*itemiter)->SetIntProperty("DisplayChannel", dispIndex);
++itemiter;
}
//m_MultiWidget->RequestUpdate();
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
void QmitkControlVisualizationPropertiesView::Reinit()
{
if (m_CurrentSelection)
{
mitk::DataNodeObject::Pointer nodeObj =
m_CurrentSelection->Begin()->Cast();
mitk::DataNode::Pointer node = nodeObj->GetDataNode();
mitk::BaseData::Pointer basedata = node->GetData();
if (basedata.IsNotNull())
{
mitk::RenderingManager::GetInstance()->InitializeViews(
basedata->GetTimeSlicedGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true );
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
}
}
void QmitkControlVisualizationPropertiesView::TextIntON()
{
if(m_TexIsOn)
{
m_Controls->m_TextureIntON->setIcon(*m_IconTexOFF);
}
else
{
m_Controls->m_TextureIntON->setIcon(*m_IconTexON);
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("DiffusionImage");
SetBoolProp(set,"texture interpolation", !m_TexIsOn);
set = ActiveSet("TensorImage");
SetBoolProp(set,"texture interpolation", !m_TexIsOn);
set = ActiveSet("QBallImage");
SetBoolProp(set,"texture interpolation", !m_TexIsOn);
set = ActiveSet("Image");
SetBoolProp(set,"texture interpolation", !m_TexIsOn);
m_TexIsOn = !m_TexIsOn;
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::VisibleOdfsON_S()
{
if(m_GlyIsOn_S)
{
m_Controls->m_VisibleOdfsON_S->setIcon(*m_IconGlyOFF_S);
}
else
{
m_Controls->m_VisibleOdfsON_S->setIcon(*m_IconGlyON_S);
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetBoolProp(set,"VisibleOdfs_S", !m_GlyIsOn_S);
set = ActiveSet("TensorImage");
SetBoolProp(set,"VisibleOdfs_S", !m_GlyIsOn_S);
m_GlyIsOn_S = !m_GlyIsOn_S;
VisibleOdfsON(0);
}
void QmitkControlVisualizationPropertiesView::VisibleOdfsON_T()
{
if(m_GlyIsOn_T)
{
m_Controls->m_VisibleOdfsON_T->setIcon(*m_IconGlyOFF_T);
}
else
{
m_Controls->m_VisibleOdfsON_T->setIcon(*m_IconGlyON_T);
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetBoolProp(set,"VisibleOdfs_T", !m_GlyIsOn_T);
set = ActiveSet("TensorImage");
SetBoolProp(set,"VisibleOdfs_T", !m_GlyIsOn_T);
m_GlyIsOn_T = !m_GlyIsOn_T;
VisibleOdfsON(1);
}
void QmitkControlVisualizationPropertiesView::VisibleOdfsON_C()
{
if(m_GlyIsOn_C)
{
m_Controls->m_VisibleOdfsON_C->setIcon(*m_IconGlyOFF_C);
}
else
{
m_Controls->m_VisibleOdfsON_C->setIcon(*m_IconGlyON_C);
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetBoolProp(set,"VisibleOdfs_C", !m_GlyIsOn_C);
set = ActiveSet("TensorImage");
SetBoolProp(set,"VisibleOdfs_C", !m_GlyIsOn_C);
m_GlyIsOn_C = !m_GlyIsOn_C;
VisibleOdfsON(2);
}
void QmitkControlVisualizationPropertiesView::VisibleOdfsON(int view)
{
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::ShowMaxNumberChanged()
{
int maxNr = m_Controls->m_ShowMaxNumber->value();
if ( maxNr < 1 )
{
m_Controls->m_ShowMaxNumber->setValue( 1 );
maxNr = 1;
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetIntProp(set,"ShowMaxNumber", maxNr);
set = ActiveSet("TensorImage");
SetIntProp(set,"ShowMaxNumber", maxNr);
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::NormalizationDropdownChanged(int normDropdown)
{
typedef mitk::OdfNormalizationMethodProperty PropType;
PropType::Pointer normMeth = PropType::New();
switch(normDropdown)
{
case 0:
normMeth->SetNormalizationToMinMax();
break;
case 1:
normMeth->SetNormalizationToMax();
break;
case 2:
normMeth->SetNormalizationToNone();
break;
case 3:
normMeth->SetNormalizationToGlobalMax();
break;
default:
normMeth->SetNormalizationToMinMax();
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetEnumProp(set,"Normalization", normMeth.GetPointer());
set = ActiveSet("TensorImage");
SetEnumProp(set,"Normalization", normMeth.GetPointer());
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::ScalingFactorChanged(double scalingFactor)
{
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetFloatProp(set,"Scaling", scalingFactor);
set = ActiveSet("TensorImage");
SetFloatProp(set,"Scaling", scalingFactor);
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::AdditionalScaling(int additionalScaling)
{
typedef mitk::OdfScaleByProperty PropType;
PropType::Pointer scaleBy = PropType::New();
switch(additionalScaling)
{
case 0:
scaleBy->SetScaleByNothing();
break;
case 1:
scaleBy->SetScaleByGFA();
//m_Controls->params_frame->setVisible(true);
break;
#ifdef DIFFUSION_IMAGING_EXTENDED
case 2:
scaleBy->SetScaleByPrincipalCurvature();
// commented in for SPIE paper, Principle curvature scaling
//m_Controls->params_frame->setVisible(true);
break;
#endif
default:
scaleBy->SetScaleByNothing();
}
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetEnumProp(set,"ScaleBy", scaleBy.GetPointer());
set = ActiveSet("TensorImage");
SetEnumProp(set,"ScaleBy", scaleBy.GetPointer());
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::IndexParam1Changed(double param1)
{
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetFloatProp(set,"IndexParam1", param1);
set = ActiveSet("TensorImage");
SetFloatProp(set,"IndexParam1", param1);
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::IndexParam2Changed(double param2)
{
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetFloatProp(set,"IndexParam2", param2);
set = ActiveSet("TensorImage");
SetFloatProp(set,"IndexParam2", param2);
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::OpacityChanged(double l, double u)
{
mitk::LevelWindow olw;
olw.SetRangeMinMax(l*255, u*255);
mitk::DataStorage::SetOfObjects::Pointer set =
ActiveSet("QBallImage");
SetLevelWindowProp(set,"opaclevelwindow", olw);
set = ActiveSet("TensorImage");
SetLevelWindowProp(set,"opaclevelwindow", olw);
set = ActiveSet("Image");
SetLevelWindowProp(set,"opaclevelwindow", olw);
m_Controls->m_OpacityMinFaLabel->setText(QString::number(l,'f',2) + " : " + QString::number(u,'f',2));
if(m_MultiWidget)
m_MultiWidget->RequestUpdate();
}
void QmitkControlVisualizationPropertiesView::ScalingCheckbox()
{
m_Controls->m_ScalingFrame->setVisible(
m_Controls->m_ScalingCheckbox->isChecked());
}
void QmitkControlVisualizationPropertiesView::BundleRepresentationWire()
{
if(m_SelectedNode)
{
m_SelectedNode->SetProperty("LineWidth",mitk::IntProperty::New(m_Controls->m_LineWidth->value()));
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(15));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(18));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(1));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(2));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(3));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(4));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
}
}
void QmitkControlVisualizationPropertiesView::BundleRepresentationTube()
{
if(m_SelectedNode)
{
m_SelectedNode->SetProperty("TubeRadius",mitk::FloatProperty::New(m_Controls->m_TubeRadius->value()));
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(17));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(13));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(16));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
}
}
void QmitkControlVisualizationPropertiesView::BundleRepresentationColor()
{
if(m_SelectedNode)
{
QColor color = QColorDialog::getColor();
m_Controls->m_Color->setAutoFillBackground(true);
QString styleSheet = "background-color:rgb(";
styleSheet.append(QString::number(color.red()));
styleSheet.append(",");
styleSheet.append(QString::number(color.green()));
styleSheet.append(",");
styleSheet.append(QString::number(color.blue()));
styleSheet.append(")");
m_Controls->m_Color->setStyleSheet(styleSheet);
m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(14));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(3));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0));
mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll();
}
}
void QmitkControlVisualizationPropertiesView::PlanarFigureFocus()
{
if(m_SelectedNode)
{
mitk::PlanarFigure* _PlanarFigure = 0;
_PlanarFigure = dynamic_cast (m_SelectedNode->GetData());
if (_PlanarFigure)
{
QmitkRenderWindow* selectedRenderWindow = 0;
QmitkRenderWindow* RenderWindow1 =
this->GetActiveStdMultiWidget()->GetRenderWindow1();
QmitkRenderWindow* RenderWindow2 =
this->GetActiveStdMultiWidget()->GetRenderWindow2();
QmitkRenderWindow* RenderWindow3 =
this->GetActiveStdMultiWidget()->GetRenderWindow3();
QmitkRenderWindow* RenderWindow4 =
this->GetActiveStdMultiWidget()->GetRenderWindow4();
bool PlanarFigureInitializedWindow = false;
// find initialized renderwindow
if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow",
PlanarFigureInitializedWindow, RenderWindow1->GetRenderer()))
{
selectedRenderWindow = RenderWindow1;
}
if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
"PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
RenderWindow2->GetRenderer()))
{
selectedRenderWindow = RenderWindow2;
}
if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
"PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
RenderWindow3->GetRenderer()))
{
selectedRenderWindow = RenderWindow3;
}
if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty(
"PlanarFigureInitializedWindow", PlanarFigureInitializedWindow,
RenderWindow4->GetRenderer()))
{
selectedRenderWindow = RenderWindow4;
}
const mitk::PlaneGeometry
* _PlaneGeometry =
dynamic_cast (_PlanarFigure->GetGeometry2D());
mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl();
mitk::Geometry2D::ConstPointer worldGeometry1 =
RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D();
mitk::PlaneGeometry::ConstPointer _Plane1 =
dynamic_cast( worldGeometry1.GetPointer() );
mitk::VnlVector normal1 = _Plane1->GetNormalVnl();
mitk::Geometry2D::ConstPointer worldGeometry2 =
RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D();
mitk::PlaneGeometry::ConstPointer _Plane2 =
dynamic_cast( worldGeometry2.GetPointer() );
mitk::VnlVector normal2 = _Plane2->GetNormalVnl();
mitk::Geometry2D::ConstPointer worldGeometry3 =
RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D();
mitk::PlaneGeometry::ConstPointer _Plane3 =
dynamic_cast( worldGeometry3.GetPointer() );
mitk::VnlVector normal3 = _Plane3->GetNormalVnl();
normal[0] = fabs(normal[0]); normal[1] = fabs(normal[1]); normal[2] = fabs(normal[2]);
normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]);
normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]);
normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]);
double ang1 = angle(normal, normal1);
double ang2 = angle(normal, normal2);
double ang3 = angle(normal, normal3);
if(ang1 < ang2 && ang1 < ang3)
{
selectedRenderWindow = RenderWindow1;
}
else
{
if(ang2 < ang3)
{
selectedRenderWindow = RenderWindow2;
}
else
{
selectedRenderWindow = RenderWindow3;
}
}
// make node visible
if (selectedRenderWindow)
{
mitk::Point3D centerP = _PlaneGeometry->GetOrigin();
selectedRenderWindow->GetSliceNavigationController()->ReorientSlices(
centerP, _PlaneGeometry->GetNormal());
selectedRenderWindow->GetSliceNavigationController()->SelectSliceByPoint(
centerP);
}
}
// set interactor for new node (if not already set)
mitk::PlanarFigureInteractor::Pointer figureInteractor
= dynamic_cast(m_SelectedNode->GetInteractor());
if(figureInteractor.IsNull())
figureInteractor = mitk::PlanarFigureInteractor::New("PlanarFigureInteractor", m_SelectedNode);
mitk::GlobalInteraction::GetInstance()->AddInteractor(figureInteractor);
m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true));
}
}
void QmitkControlVisualizationPropertiesView::SetInteractor()
{
typedef std::vector Container;
Container _NodeSet = this->GetDataManagerSelection();
mitk::DataNode* node = 0;
mitk::FiberBundle* bundle = 0;
mitk::FiberBundleInteractor::Pointer bundleInteractor = 0;
// finally add all nodes to the model
for(Container::const_iterator it=_NodeSet.begin(); it!=_NodeSet.end()
; it++)
{
node = const_cast(*it);
bundle = dynamic_cast(node->GetData());
if(bundle)
{
bundleInteractor = dynamic_cast(node->GetInteractor());
if(bundleInteractor.IsNotNull())
mitk::GlobalInteraction::GetInstance()->RemoveInteractor(bundleInteractor);
if(!m_Controls->m_SetInteractor->isChecked())
{
m_Controls->m_SetInteractor->setChecked(false);
this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::ArrowCursor);
m_CurrentPickingNode = 0;
}
else
{
m_Controls->m_SetInteractor->setChecked(true);
bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node);
mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor);
this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::CrossCursor);
m_CurrentPickingNode = node;
}
}
}
}
-void QmitkControlVisualizationPropertiesView::PFWidth(double width)
+void QmitkControlVisualizationPropertiesView::PFWidth(int w)
{
+ double width = w/10.0;
m_SelectedNode->SetProperty("planarfigure.line.width", mitk::FloatProperty::New(width) );
m_SelectedNode->SetProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(width) );
m_SelectedNode->SetProperty("planarfigure.outline.width", mitk::FloatProperty::New(width) );
m_SelectedNode->SetProperty("planarfigure.helperline.width", mitk::FloatProperty::New(width) );
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
+
+ QString label = "Width %1";
+ label = label.arg(width);
+ m_Controls->label_pfwidth->setText(label);
+
}
void QmitkControlVisualizationPropertiesView::PFColor()
{
QColor color = QColorDialog::getColor();
m_Controls->m_PFColor->setAutoFillBackground(true);
QString styleSheet = "background-color:rgb(";
styleSheet.append(QString::number(color.red()));
styleSheet.append(",");
styleSheet.append(QString::number(color.green()));
styleSheet.append(",");
styleSheet.append(QString::number(color.blue()));
styleSheet.append(")");
m_Controls->m_PFColor->setStyleSheet(styleSheet);
m_SelectedNode->SetProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
m_SelectedNode->SetProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
m_SelectedNode->SetProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
m_SelectedNode->SetProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
m_SelectedNode->SetProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0));
- mitk::RenderingManager::GetInstance()->RequestUpdateAll();
-
-// m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(0.0,1.0,0.0) );
-// m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(0.0,1.0,0.0) );
-// m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(0.0,1.0,0.0) );
+ m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) );
+ m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) );
+ m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) );
// m_SelectedNode->SetProperty( "planarfigure.hover.markerline.color", mitk::ColorProperty::New(0.0,1.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.hover.marker.color", mitk::ColorProperty::New(0.0,1.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.selected.line.color", mitk::ColorProperty::New(1.0,0.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.selected.outline.color", mitk::ColorProperty::New(1.0,0.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.selected.helperline.color", mitk::ColorProperty::New(1.0,0.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.selected.markerline.color", mitk::ColorProperty::New(1.0,0.0,0.0) );
// m_SelectedNode->SetProperty( "planarfigure.selected.marker.color", mitk::ColorProperty::New(1.0,0.0,0.0) );
+ mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
void QmitkControlVisualizationPropertiesView::Heatmap()
{
if(m_SelectedNode)
{
mitk::FiberBundle* bundle = dynamic_cast(m_SelectedNode->GetData());
if(!bundle)
return;
///////////////////////////////
// Generate unsigned char Image
typedef unsigned char OutPixType2;
// run generator
typedef itk::Image< float, 3 > WMPImageType;
typedef itk::TractsToProbabilityImageFilter ImageGeneratorType2;
ImageGeneratorType2::Pointer generator = ImageGeneratorType2::New();
//generator->SetInput(NULL);
generator->SetFiberBundle(bundle);
generator->SetInvertImage(false);
generator->SetUpsamplingFactor(2);
generator->SetBinaryEnvelope(false);
generator->Update();
// get result
typedef itk::Image OutType2;
OutType2::Pointer outImg = generator->GetOutput();
mitk::Image::Pointer img2 = mitk::Image::New();
img2->InitializeByItk(outImg.GetPointer());
img2->SetVolume(outImg->GetBufferPointer());
// to datastorage
mitk::DataNode::Pointer node = mitk::DataNode::New();
node->SetData(img2);
QString name(m_SelectedNode->GetName().c_str());
name += "_heatmap";
node->SetName(name.toStdString());
node->SetVisibility(true);
GetDataStorage()->Add(node);
}
}
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h
index 55d41f7bcd..38110af6d7 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h
@@ -1,158 +1,158 @@
/*=========================================================================
Program: Medical Imaging & Interaction Toolkit
Module: $RCSfile$
Language: C++
Date: $Date: 2009-05-28 17:19:30 +0200 (Do, 28 Mai 2009) $
Version: $Revision: 17495 $
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef _QMITKControlVisualizationPropertiesView_H_INCLUDED
#define _QMITKControlVisualizationPropertiesView_H_INCLUDED
#include
#include
#include "berryISelectionListener.h"
#include "berryIStructuredSelection.h"
#include "berryISizeProvider.h"
#include "ui_QmitkControlVisualizationPropertiesViewControls.h"
#include "mitkEnumerationProperty.h"
/*!
* \ingroup org_mitk_gui_qt_diffusionquantification_internal
*
* \brief QmitkControlVisualizationPropertiesView
*
* Document your class here.
*
* \sa QmitkFunctionality
*/
class QmitkControlVisualizationPropertiesView : public QmitkFunctionality//, public berry::ISizeProvider
{
friend struct CvpSelListener;
// this is needed for all Qt objects that should have a MOC object (everything that derives from QObject)
Q_OBJECT
public:
static const std::string VIEW_ID;
QmitkControlVisualizationPropertiesView();
QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other);
virtual ~QmitkControlVisualizationPropertiesView();
virtual void CreateQtPartControl(QWidget *parent);
/// \brief Creation of the connections of main and control widget
virtual void CreateConnections();
/// \brief Called when the functionality is activated
virtual void Activated();
virtual void Deactivated();
virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget);
virtual void StdMultiWidgetNotAvailable();
mitk::DataStorage::SetOfObjects::Pointer ActiveSet(std::string);
void SetBoolProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,bool);
void SetIntProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,int);
void SetFloatProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,float);
void SetLevelWindowProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::LevelWindow);
void SetEnumProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::EnumerationProperty::Pointer);
virtual int GetSizeFlags(bool width);
virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult);
protected slots:
void DisplayIndexChanged(int);
void TextIntON();
void Reinit();
void VisibleOdfsON(int view);
void VisibleOdfsON_S();
void VisibleOdfsON_T();
void VisibleOdfsON_C();
void ShowMaxNumberChanged();
void NormalizationDropdownChanged(int);
void ScalingFactorChanged(double);
void AdditionalScaling(int);
void IndexParam1Changed(double);
void IndexParam2Changed(double);
void OpacityChanged(double,double);
void ScalingCheckbox();
void OnThickSlicesModeSelected( QAction* action );
void OnTSNumChanged(int num);
void OnMenuAboutToShow ();
void BundleRepresentationWire();
void BundleRepresentationTube();
void BundleRepresentationColor();
void PlanarFigureFocus();
void SetInteractor();
- void PFWidth(double);
+ void PFWidth(int);
void PFColor();
void Heatmap();
protected:
Ui::QmitkControlVisualizationPropertiesViewControls* m_Controls;
QmitkStdMultiWidget* m_MultiWidget;
berry::ISelectionListener::Pointer m_SelListener;
berry::IStructuredSelection::ConstPointer m_CurrentSelection;
bool m_FoundSingleOdfImage;
bool m_IsInitialized;
QIcon* m_IconTexOFF;
QIcon* m_IconTexON;
QIcon* m_IconGlyOFF_T;
QIcon* m_IconGlyON_T;
QIcon* m_IconGlyOFF_C;
QIcon* m_IconGlyON_C;
QIcon* m_IconGlyOFF_S;
QIcon* m_IconGlyON_S;
bool m_TexIsOn;
bool m_GlyIsOn_T;
bool m_GlyIsOn_C;
bool m_GlyIsOn_S;
int currentThickSlicesMode;
QLabel* m_TSLabel;
QMenu* m_MyMenu;
// for planarfigure and bundle handling:
mitk::DataNode* m_SelectedNode;
mitk::DataNode* m_CurrentPickingNode;
};
#endif // _QMITKControlVisualizationPropertiesView_H_INCLUDED
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui
index 8143cfa3c1..b73569181b 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesViewControls.ui
@@ -1,700 +1,736 @@
QmitkControlVisualizationPropertiesViewControls
0
0
414
- 268
+ 270
0
100
0
0
QmitkTemplate
0
0
-
QFrame::NoFrame
QFrame::Raised
0
-
0
0
QFrame::NoFrame
QFrame::Raised
0
-
Reinit view
Reinit view
Reinit view
true
false
-
Texture interpolation ON
Texture interpolation ON
Texture interpolation ON
true
false
-
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
true
false
-
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
true
false
-
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
Toggle visibility of ODF glyphs
true
false
-
Multislice Projection
Multislice Projection
Multislice Projection
MIP
QToolButton::MenuButtonPopup
Qt::NoArrow
-
Channel
-
300
Qt::Horizontal
-
QFrame::NoFrame
QFrame::Plain
0
-
Qt::Horizontal
20
20
-
#Glyphs
-
9999
-
QFrame::NoFrame
QFrame::Plain
0
-
Opacity
-
100
Qt::Horizontal
-
80
0
0.0 : 0.0
-
QFrame::NoFrame
QFrame::Raised
0
0
-
QFrame::NoFrame
QFrame::Raised
0
0
-
QFrame::NoFrame
QFrame::Plain
0
-
false
-
None
-
By GFA
-
By ASR
-
*
-
-
Scaling
-
QFrame::NoFrame
QFrame::Plain
0
0
-
false
-
Min-Max
-
Max
-
None
-
Global-Max
-
QFrame::NoFrame
QFrame::Raised
0
-
Param1
-
9999.989999999999782
-
Param2
-
9999.989999999999782
-
QFrame::NoFrame
QFrame::Raised
3
0
-
QFrame::NoFrame
QFrame::Raised
0
-
43
16777215
Width
-
43
16777215
1
-
Wire
-
Set Color
-
Tube
-
Position Crosshair 3D
true
false
-
59
16777215
10.000000000000000
0.050000000000000
0.150000000000000
-
47
16777215
Radius
-
Generate 2D Heatmap
-
QFrame::NoFrame
QFrame::Raised
0
-
-
+
- Focus Planar Figure
+
+
+
+
+ -
+
+
+
+ 25
+ 16777215
+
+
+
+ 2D:
-
- Color
+ 2D
-
-
+
+
+
+ 25
+ 16777215
+
+
- Width
+ 3D:
-
- Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ -
+
+
+ 3D
-
-
-
- 1
+
+
+ 20
-
- 0.100000000000000
+
+ Qt::Horizontal
-
- 2.000000000000000
+
+
+ -
+
+
+
+ 80
+ 0
+
+
+
+ Width
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
Qt::Vertical
QSizePolicy::Expanding
0
0
QmitkFloatingPointSpanSlider
QSlider
QmitkFloatingPointSpanSlider.h
QmitkDataStorageComboBox.h
diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp
index 8e13e9f1a1..7070125bfe 100644
--- a/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp
+++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimagingapp/src/internal/QmitkDiffusionImagingAppIntroPart.cpp
@@ -1,283 +1,287 @@
/*=========================================================================
Program: BlueBerry Platform
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "QmitkDiffusionImagingAppIntroPart.h"
#include "mitkNodePredicateDataType.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef QT_WEBKIT
#include
#include
#endif
#include
#include
#include
#include
#include
#include
#include "QmitkStdMultiWidgetEditor.h"
#include "QmitkDiffusionImagingAppApplicationPlugin.h"
#include "mitkDataStorageEditorInput.h"
#include "mitkBaseDataIOFactory.h"
#include "mitkSceneIO.h"
#include "mitkProgressBar.h"
#include "mitkDataNodeFactory.h"
#include "mitkNodePredicateNot.h"
#include "mitkNodePredicateProperty.h"
QmitkDiffusionImagingAppIntroPart::QmitkDiffusionImagingAppIntroPart()
: m_Controls(NULL)
{
berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionImagingAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences();
workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true);
workbenchPrefs->Flush();
}
QmitkDiffusionImagingAppIntroPart::~QmitkDiffusionImagingAppIntroPart()
{
// if the workbench is not closing (that means, welcome screen was closed explicitly), set "Show_intro" false
if (!this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing())
{
berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionImagingAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences();
workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, false);
workbenchPrefs->Flush();
}
else
{
berry::IPreferences::Pointer workbenchPrefs = QmitkDiffusionImagingAppApplicationPlugin::GetDefault()->GetPreferencesService()->GetSystemPreferences();
workbenchPrefs->PutBool(berry::WorkbenchPreferenceConstants::SHOW_INTRO, true);
workbenchPrefs->Flush();
}
// if workbench is not closing (Just welcome screen closing), open last used perspective
if (this->GetIntroSite()->GetPage()->GetPerspective()->GetId()
== "org.mitk.diffusionimagingapp.perspectives.welcome" && !this->GetIntroSite()->GetPage()->GetWorkbenchWindow()->GetWorkbench()->IsClosing())
{
berry::IPerspectiveDescriptor::Pointer perspective = this->GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->GetPerspectiveRegistry()->FindPerspectiveWithId("org.mitk.diffusionimagingapp.perspectives.diffusionimagingapp");
if (perspective)
{
this->GetIntroSite()->GetPage()->SetPerspective(perspective);
}
}
}
void QmitkDiffusionImagingAppIntroPart::CreateQtPartControl(QWidget* parent)
{
if (!m_Controls)
{
// create GUI widgets
m_Controls = new Ui::QmitkWelcomeScreenViewControls;
m_Controls->setupUi(parent);
#ifdef QT_WEBKIT
// create a QWebView as well as a QWebPage and QWebFrame within the QWebview
m_view = new QWebView(parent);
m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
QUrl urlQtResource(QString("qrc:/org.mitk.gui.qt.welcomescreen/mitkdiffusionimagingappwelcomeview.html"), QUrl::TolerantMode );
m_view->load( urlQtResource );
// adds the webview as a widget
parent->layout()->addWidget(m_view);
this->CreateConnections();
#else
parent->layout()->addWidget(new QLabel("Please install Qt with the WebKit option to see cool pictures!
"));
#endif
}
}
#ifdef QT_WEBKIT
void QmitkDiffusionImagingAppIntroPart::CreateConnections()
{
if ( m_Controls )
{
connect( (QObject*)(m_view->page()), SIGNAL(linkClicked(const QUrl& )), this, SLOT(DelegateMeTo(const QUrl& )) );
}
}
void QmitkDiffusionImagingAppIntroPart::DelegateMeTo(const QUrl& showMeNext)
{
QString scheme = showMeNext.scheme();
QByteArray urlHostname = showMeNext.encodedHost();
QByteArray urlPath = showMeNext.encodedPath();
QByteArray dataset = showMeNext.encodedQueryItemValue("dataset");
if (scheme.isEmpty()) MITK_INFO << " empty scheme of the to be delegated link" ;
// if the scheme is set to mitk, it is to be tested which action should be applied
if (scheme.contains(QString("mitk")) )
{
if(urlPath.isEmpty() ) MITK_INFO << " mitk path is empty " ;
// searching for the perspective keyword within the host name
if(urlHostname.contains(QByteArray("perspectives")) )
{
// the simplified method removes every whitespace
// ( whitespace means any character for which the standard C++ isspace() method returns true)
urlPath = urlPath.simplified();
QString tmpPerspectiveId(urlPath.data());
tmpPerspectiveId.replace(QString("/"), QString("") );
std::string perspectiveId = tmpPerspectiveId.toStdString();
// is working fine as long as the perspective id is valid, if not the application crashes
GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() );
mitk::DataStorageEditorInput::Pointer editorInput;
editorInput = new mitk::DataStorageEditorInput();
berry::IEditorPart::Pointer editor = GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID);
QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor;
mitk::DataStorage::Pointer dataStorage;
if (editor.Cast().IsNull())
{
editorInput = new mitk::DataStorageEditorInput();
dataStorage = editorInput->GetDataStorageReference()->GetDataStorage();
}
else
{
multiWidgetEditor = editor.Cast();
multiWidgetEditor->GetStdMultiWidget()->RequestUpdate();
dataStorage = multiWidgetEditor->GetEditorInput().Cast()->GetDataStorageReference()->GetDataStorage();
}
bool dsmodified = false;
QString *fileName = new QString(dataset.data());
if ( fileName->right(5) == ".mitk" )
{
mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New();
bool clearDataStorageFirst(false);
mitk::ProgressBar::GetInstance()->AddStepsToDo(2);
dataStorage = sceneIO->LoadScene( fileName->toLocal8Bit().constData(), dataStorage, clearDataStorageFirst );
dsmodified = true;
mitk::ProgressBar::GetInstance()->Progress(2);
}
else
{
mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New();
try
{
nodeReader->SetFileName(fileName->toLocal8Bit().data());
nodeReader->Update();
for ( unsigned int i = 0 ; i < nodeReader->GetNumberOfOutputs( ); ++i )
{
mitk::DataNode::Pointer node;
node = nodeReader->GetOutput(i);
if ( node->GetData() != NULL )
{
dataStorage->Add(node);
dsmodified = true;
}
}
}
catch(...)
{
-
+ MITK_INFO << "Could not open file!";
}
}
- if(dsmodified)
+ if(dataStorage.IsNotNull() && dsmodified)
{
// get all nodes that have not set "includeInBoundingBox" to false
mitk::NodePredicateNot::Pointer pred
= mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox"
, mitk::BoolProperty::New(false)));
mitk::DataStorage::SetOfObjects::ConstPointer rs = dataStorage->GetSubset(pred);
- // calculate bounding geometry of these nodes
- mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs);
- // initialize the views to the bounding geometry
- mitk::RenderingManager::GetInstance()->InitializeViews(bounds);
+
+ if(rs->Size() > 0)
+ {
+ // calculate bounding geometry of these nodes
+ mitk::TimeSlicedGeometry::Pointer bounds = dataStorage->ComputeBoundingGeometry3D(rs);
+ // initialize the views to the bounding geometry
+ mitk::RenderingManager::GetInstance()->InitializeViews(bounds);
+ }
}
}
// searching for the load
if(urlHostname.contains(QByteArray("perspectives")) )
{
// the simplified method removes every whitespace
// ( whitespace means any character for which the standard C++ isspace() method returns true)
urlPath = urlPath.simplified();
QString tmpPerspectiveId(urlPath.data());
tmpPerspectiveId.replace(QString("/"), QString("") );
std::string perspectiveId = tmpPerspectiveId.toStdString();
// is working fine as long as the perspective id is valid, if not the application crashes
GetIntroSite()->GetWorkbenchWindow()->GetWorkbench()->ShowPerspective(perspectiveId, GetIntroSite()->GetWorkbenchWindow() );
mitk::DataStorageEditorInput::Pointer editorInput;
editorInput = new mitk::DataStorageEditorInput();
GetIntroSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID);
}
else
{
MITK_INFO << "Unkown mitk action keyword (see documentation for mitk links)" ;
}
}
// if the scheme is set to http, by default no action is performed, if an external webpage needs to be
// shown it should be implemented below
else if (scheme.contains(QString("http")) )
{
QDesktopServices::openUrl(showMeNext);
// m_view->load( ) ;
}
else if(scheme.contains("qrc"))
{
m_view->load(showMeNext);
}
}
#endif
void QmitkDiffusionImagingAppIntroPart::StandbyStateChanged(bool standby)
{
}
void QmitkDiffusionImagingAppIntroPart::SetFocus()
{
}