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 584945583c..ee3f9bdbc7 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,1265 +1,1287 @@ /*========================================================================= 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 "mitkGlobalInteraction.h" #include "berryIWorkbenchWindow.h" #include "berryIWorkbenchPage.h" #include "berryISelectionService.h" #include "berryConstants.h" #include "berryPlatformUI.h" #include "itkRGBAPixel.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; + 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 != m_View->m_CurrentPickingNode) + { + m_View->m_Controls->m_SetInteractor->setEnabled(false); + } } } } 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; } } } } } 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_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_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())); } } 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_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) { m_SelectedNode->SetProperty("layer",mitk::IntProperty::New(1000)); m_SelectedNode->SetProperty("selected",mitk::BoolProperty::New(false)); m_SelectedNode->SetProperty("visible",mitk::BoolProperty::New(true)); m_SelectedNode->SetProperty("planarfigure.default.line.color",mitk::ColorProperty::New(1,1,1)); m_SelectedNode->SetProperty("planarfigure.default.line.color",mitk::ColorProperty::New(1,1,1)); m_SelectedNode->SetProperty("planarfigure.hover.line.color",mitk::ColorProperty::New(1,1,1)); m_SelectedNode->SetProperty("planarfigure.hover.line.color",mitk::ColorProperty::New(1,1,1)); m_SelectedNode->SetProperty("planarfigure.selected.line.color",mitk::ColorProperty::New(1,1,1)); m_SelectedNode->SetProperty("planarfigure.selected.line.color",mitk::ColorProperty::New(1,1,1)); 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()); // make node visible if (selectedRenderWindow) { mitk::Point3D centerP = _PlaneGeometry->GetOrigin(); selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( centerP, _PlaneGeometry->GetNormal()); selectedRenderWindow->GetSliceNavigationController()->SelectSliceByPoint( centerP); } } } } void QmitkControlVisualizationPropertiesView::SetInteractor() { - + MITK_INFO << "halo"; mitk::DataStorage::SetOfObjects::ConstPointer _NodeSet = this->GetDefaultDataStorage()->GetAll(); mitk::DataNode* node = 0; mitk::FiberBundle* bundle = 0; mitk::FiberBundleInteractor::Pointer bundleInteractor = 0; // finally add all nodes to the model for(mitk::DataStorage::SetOfObjects::ConstIterator it=_NodeSet->Begin(); it!=_NodeSet->End() ; it++) { node = const_cast(it->Value().GetPointer()); bundle = dynamic_cast(node->GetData()); if(bundle) { bundleInteractor = dynamic_cast(node->GetInteractor()); - if(bundleInteractor.IsNull()) + 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; + } - mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); } } + } 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 03d5d77b49..b48fbcf860 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,152 +1,153 @@ /*========================================================================= 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(); 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 aa79aaa933..2006deb0b1 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,612 +1,648 @@ QmitkControlVisualizationPropertiesViewControls 0 0 414 238 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 43 16777215 Width 43 16777215 1 Color 47 16777215 Radius 59 16777215 10.000000000000000 0.050000000000000 0.150000000000000 Tube Wire - + - Set Interactor + 3D Cross Position + + + true + + + false QFrame::NoFrame QFrame::Raised 0 Focus Planar Figure Qt::Vertical QSizePolicy::Expanding 0 0 QmitkFloatingPointSpanSlider QSlider
QmitkFloatingPointSpanSlider.h
QmitkDataStorageComboBox.h
diff --git a/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp b/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp index fc2c5c53d0..92798350c4 100644 --- a/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp +++ b/Modules/DiffusionImaging/Interactions/mitkFiberBundleInteractor.cpp @@ -1,272 +1,273 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2007-12-11 14:46:19 +0100 (Di, 11 Dez 2007) $ Version: $Revision: 13129 $ 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 "mitkFiberBundleInteractor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "mitkBaseRenderer.h" #include #include #include #include #include #include mitk::FiberBundleInteractor::FiberBundleInteractor(const char * type, DataNode* dataNode) : Interactor(type, dataNode), m_LastPosition(0) { m_LastPoint.Fill(0); } mitk::FiberBundleInteractor::~FiberBundleInteractor() {} void mitk::FiberBundleInteractor::SelectFiber(int position) { MITK_INFO << "mitk::FiberBundleInteractor::SelectFiber " << position; mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); if (pointSet == NULL) return; if (pointSet->GetSize()<=0)//if List is empty, then no select of a point can be done! return; mitk::Point3D noPoint;//dummyPoint... not needed anyway noPoint.Fill(0); mitk::PointOperation* doOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); if (m_UndoEnabled) { mitk::PointOperation* undoOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation(doOp); } void mitk::FiberBundleInteractor::DeselectAllFibers() { MITK_INFO << "mitk::FiberBundleInteractor::DeselectAllFibers "; mitk::PointSet* pointSet = dynamic_cast(m_DataNode->GetData()); if (pointSet == NULL) return; mitk::PointSet::DataType *itkPointSet = pointSet->GetPointSet(); mitk::PointSet::PointsContainer::Iterator it, end; end = itkPointSet->GetPoints()->End(); for (it = itkPointSet->GetPoints()->Begin(); it != end; it++) { int position = it->Index(); PointSet::PointDataType pointData = {0, false, PTUNDEFINED}; itkPointSet->GetPointData(position, &pointData); if ( pointData.selected )//then declare an operation which unselects this point; UndoOperation as well! { mitk::Point3D noPoint; noPoint.Fill(0); mitk::PointOperation* doOp = new mitk::PointOperation(OpDESELECTPOINT, noPoint, position); if (m_UndoEnabled) { mitk::PointOperation* undoOp = new mitk::PointOperation(OpSELECTPOINT, noPoint, position); OperationEvent *operationEvent = new OperationEvent(pointSet, doOp, undoOp); m_UndoController->SetOperationEvent(operationEvent); } pointSet->ExecuteOperation(doOp); } } } float mitk::FiberBundleInteractor::CanHandleEvent(StateEvent const* stateEvent) const //go through all points and check, if the given Point lies near a line { float returnValue = 0; mitk::PositionEvent const *posEvent = dynamic_cast (stateEvent->GetEvent()); //checking if a keyevent can be handled: if (posEvent == NULL) { //check, if the current state has a transition waiting for that key event. if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { return 0.5; } else { return 0; } } //Mouse event handling: //on MouseMove do nothing! reimplement if needed differently if (stateEvent->GetEvent()->GetType() == mitk::Type_MouseMove) { return 0; } //if the event can be understood and if there is a transition waiting for that event if (this->GetCurrentState()->GetTransition(stateEvent->GetId())!=NULL) { returnValue = 0.5;//it can be understood } //check on the right data-type mitk::FiberBundle* bundle = dynamic_cast(m_DataNode->GetData()); if (bundle == NULL) return 0; return 0.5; } bool mitk::FiberBundleInteractor::ExecuteAction( Action* action, mitk::StateEvent const* stateEvent ) { bool ok = false;//for return type bool //checking corresponding Data; has to be a PointSet or a subclass mitk::FiberBundle* bundle = dynamic_cast(m_DataNode->GetData()); if (bundle == NULL) return false; // Get Event and extract renderer const Event *event = stateEvent->GetEvent(); BaseRenderer *renderer = NULL; vtkRenderWindow *renderWindow = NULL; vtkRenderWindowInteractor *renderWindowInteractor = NULL; vtkRenderer *currentVtkRenderer = NULL; vtkCamera *camera = NULL; if ( event != NULL ) { renderer = event->GetSender(); if ( renderer != NULL ) { renderWindow = renderer->GetRenderWindow(); if ( renderWindow != NULL ) { renderWindowInteractor = renderWindow->GetInteractor(); if ( renderWindowInteractor != NULL ) { currentVtkRenderer = renderWindowInteractor ->GetInteractorStyle()->GetCurrentRenderer(); if ( currentVtkRenderer != NULL ) { camera = currentVtkRenderer->GetActiveCamera(); } } } } } - MITK_INFO << "FiberBundleInteractor Got Action " << action->GetActionId(); /*Each case must watch the type of the event!*/ switch (action->GetActionId()) { case AcCHECKHOVERING: { - MITK_INFO << "FiberBundleInteractor AcCHECKOBJECT"; - // Re-enable VTK interactor (may have been disabled previously) if ( renderWindowInteractor != NULL ) { renderWindowInteractor->Enable(); } const DisplayPositionEvent *dpe = dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() ); // Check if we have a DisplayPositionEvent if ( dpe != NULL ) { // Check if an object is present at the current mouse position DataNode *pickedNode = dpe->GetPickedObjectNode(); if ( pickedNode != m_DataNode ) { - MITK_INFO << "NO Hovering"; +// if(pickedNode == 0) +// MITK_INFO << "picked node is NULL, no hovering"; +// else +// MITK_INFO << "wrong node: " << pickedNode; + this->HandleEvent( new StateEvent( EIDNOFIGUREHOVER ) ); ok = true; break; } m_CurrentPickedPoint = dpe->GetWorldPosition(); m_CurrentPickedDisplayPoint = dpe->GetDisplayPosition(); - MITK_INFO << "YES Hovering"; +// MITK_INFO << "YES Hovering"; this->HandleEvent( new StateEvent( EIDFIGUREHOVER ) ); } ok = true; break; } break; // case AcSELECTPICKEDOBJECT: // MITK_INFO << "FiberBundleInteractor AcSELECTPICKEDOBJECT"; // break; // case AcDESELECTALL: // MITK_INFO << "FiberBundleInteractor AcDESELECTALL"; // break; case AcREMOVE: { MITK_INFO << "FiberBundleInteractor AcREMOVE"; MITK_INFO << "removing fiber at " << m_CurrentPickedPoint; // QmitkStdMultiWidgetEditor::Pointer multiWidgetEditor; // multiWidgetEditor->GetStdMultiWidget()->GetRenderWindow1()->GetRenderer()->GetSliceNavigationController()->SelectSliceByPoint( // m_CurrentPickedPoint); BaseRenderer* renderer = mitk::BaseRenderer::GetByName("stdmulti.widget1"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); renderer = mitk::BaseRenderer::GetByName("stdmulti.widget2"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); renderer = mitk::BaseRenderer::GetByName("stdmulti.widget3"); renderer->GetSliceNavigationController()->SelectSliceByPoint( m_CurrentPickedPoint); // mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } break; default: MITK_INFO << "FiberBundleInteractor NO ACTION"; return Superclass::ExecuteAction( action, stateEvent ); } return ok; } diff --git a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp index f82e6eb2dd..fc74f6bde5 100644 --- a/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp +++ b/Modules/DiffusionImaging/Rendering/mitkFiberBundleMapper3D.cpp @@ -1,1146 +1,1140 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-05-12 19:56:03 +0200 (Di, 12 Mai 2009) $ Version: $Revision: 17179 $ 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 "mitkProperties.h" #include "mitkFiberBundleMapper3D.h" #include #include #include #include #include #include #include #include #include #include #include #include "vtkVertex.h" #include #include #include #include #include #include "mitkFiberBundleInteractor.h" #include "mitkGlobalInteraction.h" //template mitk::FiberBundleMapper3D::FiberBundleMapper3D() : m_vtkFiberList(NULL), m_VtkFiberDataMapperGL(NULL), m_vtkTubeMapper(NULL) { //MITK_INFO << "FiberBundleMapper3D()"; m_FiberAssembly = vtkPropAssembly::New(); m_FiberActor = vtkOpenGLActor::New(); m_TubeActor = vtkOpenGLActor::New(); /* vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->SetName("Colors"); colorsT->SetNumberOfComponents(4); unsigned char red1[4] = {255, 0, 0 , 10}; colorsT->InsertNextTupleValue(red1); unsigned char red2[4] = {255,0, 0 , 255}; colorsT->InsertNextTupleValue(red2); colorsT->SetValue(3, (unsigned char)(255)); colorsT->SetValue(7, (unsigned char)(255)); //Create points for polyline1. double origin[3] = {100.0, 400.0, 0.0}; double p0[3] = {300.0, 400.0, 0.0}; double p1[3] = {300.0, 200.0, 0.0}; double p2[3] = {100.0, 300.0, 0.0}; double p3[3] = {130.0, 250.0, 0.0}; //create points for polyline2 //double p01[3] = {50.0, 50.0, 13.0}; //double p11[3] = {200.0, 100.0, 13.0}; //insert points to vtkPointarray vtkPoints *pnts = vtkPoints::New(); pnts->InsertPoint(0,origin); pnts->InsertPoint(1,p0); pnts->InsertPoint(2,p1); pnts->InsertPoint(3,p2); //pnts->InsertPoint(4,p01); //pnts->InsertPoint(5,p11); pnts->InsertPoint(4,p3); //generate and define polyline1 vtkPolyLine *polyLine = vtkPolyLine::New(); polyLine->GetPointIds()->SetNumberOfIds(4); polyLine->GetPointIds()->SetId(0,0); polyLine->GetPointIds()->SetId(1,1); polyLine->GetPointIds()->SetId(2,2); polyLine->GetPointIds()->SetId(3,3); /*generate and define polyline2 vtkPolyLine *polyLine2 = vtkPolyLine::New(); polyLine2->GetPointIds()->SetNumberOfIds(2); polyLine2->GetPointIds()->SetId(0,4); polyLine2->GetPointIds()->SetId(1,5); */ /* vtkVertex *vtx = vtkVertex::New(); vtx->GetPointIds()->SetNumberOfIds(1); vtx->GetPointIds()->SetId(0,4); vtkCellArray *lines = vtkCellArray::New(); lines->InsertNextCell(polyLine); //lines->InsertNextCell(vtx); //lines->InsertNextCell(polyLine2); vtkCellArray *vertx = vtkCellArray::New(); vertx->InsertNextCell(vtx); vtkPolyData *polyDataT = vtkPolyData::New(); polyDataT->SetPoints(pnts); polyDataT->SetLines(lines); polyDataT->SetVerts(vertx); //color and opacity handling vtkUnsignedCharArray *colorT = vtkUnsignedCharArray::New(); colorT->SetName("Colors"); colorT->SetNumberOfComponents(4); //4 components cuz of RGBA unsigned char rgba[4] = {255,0,0,255}; unsigned char rgba2[4] = {0,255,0,255}; //if just 1 point in there colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba2); colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba2); colorT->InsertNextTupleValue(rgba); /*for(int i=0; i<6; i++) { double vtkPntTmp[3]; pnts->GetPoint(i, vtkPntTmp); double vtkPntTmpNxt[3]; pnts->GetPoint(i+1, vtkPntTmpNxt); vnl_vector_fixed< double, 3 > tmpPntvtk( vtkPntTmp[0], vtkPntTmp[1],vtkPntTmp[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(vtkPntTmpNxt[0], vtkPntTmpNxt[1], vtkPntTmpNxt[2]); vnl_vector_fixed< double, 3 > diff; diff = tmpPntvtk - nxttmpPntvtk; diff.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); if(i==3) { colorT->InsertNextTupleValue(rgba); colorT->InsertNextTupleValue(rgba); }else if(i==4) { //do nothing }else{ colorT->InsertNextTupleValue(rgba); } } /* unsigned char red[4] = {255, 0, 0 , 20}; unsigned char green[4] = {0, 255, 0 , 190}; unsigned char blue[4] = {0, 0, 255, 255}; unsigned char white[4] = {255, 255, 255, 255}; colorT->InsertNextTupleValue(red); //color for point0 colorT->InsertNextTupleValue(green); //color for point1 colorT->InsertNextTupleValue(blue); colorT->InsertNextTupleValue(white); colorT->InsertNextTupleValue(white); colorT->InsertNextTupleValue(white); //color for point5 polyDataT->GetPointData()->AddArray(colorT); vtkTubeFilter *tube = vtkTubeFilter::New(); tube->SetInput(polyDataT); tube->SetNumberOfSides(8); tube->SetRadius(5); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyDataT); //mapper->SetInputConnection(tube->GetOutputPort()); mapper->ScalarVisibilityOn(); mapper->SetScalarModeToUsePointFieldData(); //mapper->SetColorModeToMapScalars(); mapper->SelectColorArray("Colors"); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); actor->GetProperty()->SetOpacity(1.0); //actor->GetProperty()->SetLineWidth(20); actor->GetProperty()->SetPointSize(5.0); vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->AddActor(actor); //renderer->SetBackground(.2, .3, .4); // Make an oblique view renderer->GetActiveCamera()->Azimuth(30); renderer->GetActiveCamera()->Elevation(30); renderer->ResetCamera(); vtkSmartPointer renWin = vtkSmartPointer::New(); vtkSmartPointer iren = vtkSmartPointer::New(); iren->SetRenderWindow(renWin); renWin->AddRenderer(renderer); //renWin->LineSmoothingOff(); renWin->SetSize(500, 500); renWin->Render(); vtkSmartPointer style = vtkSmartPointer::New(); iren->SetInteractorStyle(style); iren->Start(); MITK_INFO << "swerwas"; /* // Spiral tube double vX, vY, vZ; unsigned int nV = 256; // No. of vertices unsigned int nCyc = 5; // No. of spiral cycles double rT1 = 0.1, rT2 = 0.5;// Start/end tube radii double rS = 2; // Spiral radius double h = 10; // Height unsigned int nTv = 8; // No. of surface elements for each tube vertex unsigned int i; // Create points and cells for the spiral vtkSmartPointer points = vtkSmartPointer::New(); for(i = 0; i < nV; i++) { // Spiral coordinates vX = rS * cos(2 * 3 * nCyc * i / (nV - 1)); vY = rS * sin(2 * 3 * nCyc * i / (nV - 1)); vZ = h * i / nV; points->InsertPoint(i, vX, vY, vZ); } vtkSmartPointer lines = vtkSmartPointer::New(); lines->InsertNextCell(nV); for (i = 0; i < nV; i++) { lines->InsertCellPoint(i); } vtkSmartPointer polyData = vtkSmartPointer::New(); polyData->SetPoints(points); polyData->SetLines(lines); // RBG array (could add Alpha channel too I guess...) // Varying from blue to red vtkSmartPointer colors = vtkSmartPointer::New(); colors->SetName("Colors"); colors->SetNumberOfComponents(3); colors->SetNumberOfTuples(nV); for (i = 0; i < nV ;i++) { unsigned char red[3] = {char(255 * i/ (nV - 1)),0,char(255 * (nV - 1 - i)/(nV - 1))}; colors->InsertNextTupleValue( red); } polyData->GetPointData()->AddArray(colors); vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyData); mapper->ScalarVisibilityOn(); mapper->SetScalarModeToUsePointFieldData(); mapper->SelectColorArray("Colors"); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); vtkSmartPointer renderer = vtkSmartPointer::New(); renderer->AddActor(actor); renderer->SetBackground(.2, .3, .4); // Make an oblique view renderer->GetActiveCamera()->Azimuth(30); renderer->GetActiveCamera()->Elevation(30); renderer->ResetCamera(); vtkSmartPointer renWin = vtkSmartPointer::New(); vtkSmartPointer iren = vtkSmartPointer::New(); iren->SetRenderWindow(renWin); renWin->AddRenderer(renderer); renWin->SetSize(500, 500); renWin->Render(); vtkSmartPointer style = vtkSmartPointer::New(); iren->SetInteractorStyle(style); iren->Start(); /* double origin[3] = {0.0, 0.0, 0.0}; double p0[3] = {10.0, 0.0, 0.0}; double p1[3] = {10.0, 10.0, 0.0}; double p2[3] = {0.0, 10.0, 0.0}; double p3[3] = {10.0, 10.0, 0.0}; double p4[3] = {10.0, 20.0, 0.0}; double p5[3] = {0.0, 20.0, 0.0}; //create a vtkPoints object and store the points in it vtkSmartPointer points = vtkSmartPointer::New(); points->InsertNextPoint(origin); points->InsertNextPoint(p0); points->InsertNextPoint(p1); points->InsertNextPoint(p2); points->InsertNextPoint(p3); points->InsertNextPoint(p4); points->InsertNextPoint(p5); vtkSmartPointer polyLine = vtkSmartPointer::New(); polyLine->GetPointIds()->SetNumberOfIds(7); for(unsigned int i = 0; i < 7; i++) { polyLine->GetPointIds()->SetId(i,i); } double origin2[3] = {30.0, 0.0, 0.0}; double p02[3] = {40.0, 0.0, 0.0}; double p12[3] = {40.0, 20.0, 0.0}; double p22[3] = {30.0, 20.0, 0.0}; double p23[3] = {30.0, 0.0, 0.0}; points->InsertNextPoint(origin2); points->InsertNextPoint(p02); points->InsertNextPoint(p12); points->InsertNextPoint(p22); points->InsertNextPoint(p23); vtkSmartPointer polyLine2 = vtkSmartPointer::New(); polyLine2->GetPointIds()->SetNumberOfIds(5); for(unsigned int i = 0; i < 5; i++) { polyLine2->GetPointIds()->SetId(i,i+7); } //Create a cell array to store the lines in and add the lines to it vtkSmartPointer cells = vtkSmartPointer::New(); cells->InsertNextCell(polyLine); cells->InsertNextCell(polyLine2); //Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New(); //add the points to the dataset polyData->SetPoints(points); //add the lines to the dataset polyData->SetLines(cells); //setup actor and mapper vtkSmartPointer mapper = vtkSmartPointer::New(); mapper->SetInput(polyData); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); m_FiberAssembly->AddPart(actor); */ } //template mitk::FiberBundleMapper3D::~FiberBundleMapper3D() { //MITK_INFO << "FiberBundleMapper3D(destructor)"; m_FiberActor->Delete(); m_FiberAssembly->Delete(); //m_vtkFiberList->Delete(); //m_VtkFiberDataMapperGL->Delete(); //m_VtkFiberDataMapper->Delete(); } const mitk::FiberBundle* mitk::FiberBundleMapper3D::GetInput() { //MITK_INFO << "FiberBundleMapper3D GetInput()" ; return static_cast ( GetData() ); } /* This method is called once the mapper gets new input, for UI rotation or changes in colorcoding this method is NOT called */ void mitk::FiberBundleMapper3D::GenerateData() { /* ######## FIBER PREPARATION START ######### */ //get fiberbundle mitk::FiberBundle::Pointer PFiberBundle = dynamic_cast< mitk::FiberBundle* > (this->GetData()); //get groupFiberBundle, which is a datastructure containing single fibers mitk::FiberBundle::FiberGroupType::Pointer groupFiberBundle = PFiberBundle->GetGroupFiberBundle(); //extractn single fibers //in the groupFiberBundle all smartPointers to single fibers are stored in in a ChildrenList mitk::FiberBundle::ChildrenListType * FiberList; FiberList = groupFiberBundle->GetChildren(); /* ######## FIBER PREPARATION END ######### */ /* ######## VTK FIBER REPRESENTATION ######## */ //create a vtkPoints object and store the all the brainFiber points in it vtkPoints* vtkSmoothPoints = vtkPoints::New(); //in smoothpoints the interpolated points representing a fiber are stored. //in vtkcells all polylines are stored, actually all id's of them are stored vtkCellArray *vtkSmoothCells = vtkCellArray::New(); //cellcontainer for smoothed lines //in some cases a fiber includes just 1 point, so put it in here vtkCellArray *vtkVrtxs = vtkCellArray::New(); //colors and alpha value for each single point, RGBA = 4 components vtkUnsignedCharArray *colorsT = vtkUnsignedCharArray::New(); colorsT->SetNumberOfComponents(4); colorsT->SetName("ColorValues"); vtkDoubleArray *faColors = vtkDoubleArray::New(); faColors->SetName("FaColors"); vtkDoubleArray *tubeRadius = vtkDoubleArray::New(); tubeRadius->SetName("TubeRadius"); // iterate through FiberList for(mitk::FiberBundle::ChildrenListType::iterator itLst = FiberList->begin(); itLst != FiberList->end(); ++itLst) { //all points are stored in one vtkpoints list, soooooooo that the lines find their point id to start and end we need some kind of helper index who monitors the current ids for a polyline //unsigned long pntIdxHelper = vtkpointsDTI->GetNumberOfPoints(); // lists output is SpatialObject, we know we have DTITubeSpacialObjects // dynamic cast only likes pointers, no smartpointers, so each dsmartpointer has membermethod .GetPointer() itk::SpatialObject<3>::Pointer tmp_fbr; tmp_fbr = *itLst; mitk::FiberBundle::DTITubeType::Pointer dtiTract = dynamic_cast< mitk::FiberBundle::DTITubeType * > (tmp_fbr.GetPointer()); if (dtiTract.IsNull()) { return; } //get list of points int fibrNrPnts = dtiTract->GetNumberOfPoints(); mitk::FiberBundle::DTITubeType::PointListType dtiPntList = dtiTract->GetPoints(); //MITK_INFO << "REAL AMOUNT OF FIBERS: " << fibrNrPnts; vtkPoints *vtkpointsDTI = vtkPoints::New(); if (fibrNrPnts <= 0) { //this should never occour! but who knows MITK_INFO << "HyperERROR in fiberBundleMapper3D.cpp ...no point in fiberBundle!!! .. check ur trackingAlgorithm"; continue; } ///////PROCESS ON FIBERS//////// for (int i=0; i1 PFiberBundle->GetGeometry()->IndexToWorld(indexPnt, worldPnt); double worldFbrPnt[3] = {worldPnt[0], worldPnt[1], worldPnt[2]}; vtkpointsDTI->InsertNextPoint(worldFbrPnt); } //MITK_INFO << "REDUCED AMOUNT OF FIBERS: " << vtkpointsDTI->GetNumberOfPoints(); ////POINTS OF DTI ARE READY FOR FUTHER VTK PROCESSING//// } /////PROCESS POLYLINE SMOOTHING///// vtkKochanekSpline* xSpline = vtkKochanekSpline::New(); vtkKochanekSpline* ySpline = vtkKochanekSpline::New(); vtkKochanekSpline* zSpline = vtkKochanekSpline::New(); vtkParametricSpline* spline = vtkParametricSpline::New(); spline->SetXSpline(xSpline); spline->SetYSpline(ySpline); spline->SetZSpline(zSpline); spline->SetPoints(vtkpointsDTI); vtkParametricFunctionSource* functionSource = vtkParametricFunctionSource::New(); functionSource->SetParametricFunction(spline); functionSource->SetUResolution(200); functionSource->SetVResolution(200); functionSource->SetWResolution(200); functionSource->Update(); vtkPolyData* outputFunction = functionSource->GetOutput(); vtkPoints* tmpSmoothPnts = outputFunction->GetPoints(); //smoothPoints of current fiber vtkPolyLine* smoothLine = vtkPolyLine::New(); smoothLine->GetPointIds()->SetNumberOfIds(tmpSmoothPnts->GetNumberOfPoints()); // MITK_INFO << "SMOOTHED AMOUNT OF POINTS:" << tmpSmoothPnts->GetNumberOfPoints(); /////CREATE SMOOTH POLYLINE OBJECT//// /////MANAGE LINE AND CORRELATED POINTS///// int pointHelperCnt = vtkSmoothPoints->GetNumberOfPoints(); //also put current points into global smooth pointcontainer int nrSmPnts = tmpSmoothPnts->GetNumberOfPoints(); tubeRadius->SetNumberOfTuples(nrSmPnts); double tbradius = 1;//default value for radius for(int ism=0; ismGetPointIds()->SetId(ism, ism+pointHelperCnt); vtkSmoothPoints->InsertNextPoint(tmpSmoothPnts->GetPoint(ism)); // MITK_INFO << "LinePntID: " << ism << " linked to: " << ism+pointHelperCnt << " val: " << tmpSmoothPnts->GetPoint(ism)[0] << " " << tmpSmoothPnts->GetPoint(ism)[1] << " " << tmpSmoothPnts->GetPoint(ism)[2]; tubeRadius->SetTuple1(ism,tbradius); //tuple with 1 argument //colorcoding orientation based unsigned char rgba[4] = {0,0,0,0}; if (ism < nrSmPnts-1 && ism>0) { // MITK_INFO << "inbetween fiber, at position:" << ism; // //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); vnl_vector_fixed< double, 3 > diff; diff = (diff1 - diff2)/2.0; rgba[0] = (unsigned char) (255.0 * std::abs(diff[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff[2])); rgba[3] = (unsigned char) (255.0); } else if(ism==0) { //explicit handling of startpoint of line //nimm nur diff1 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > nxttmpPntvtk(tmpSmoothPnts->GetPoint(ism+1)[0], tmpSmoothPnts->GetPoint(ism+1)[1], tmpSmoothPnts->GetPoint(ism+1)[2]); vnl_vector_fixed< double, 3 > diff1; diff1 = tmpPntvtk - nxttmpPntvtk; diff1.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff1[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff1[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff1[2])); rgba[3] = (unsigned char) (255.0); // MITK_INFO << "first point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } else if(ism==nrSmPnts-1) { // last point in fiber // nimm nur diff2 vnl_vector_fixed< double, 3 > tmpPntvtk(tmpSmoothPnts->GetPoint(ism)[0], tmpSmoothPnts->GetPoint(ism)[1],tmpSmoothPnts->GetPoint(ism)[2]); vnl_vector_fixed< double, 3 > prevtmpPntvtk(tmpSmoothPnts->GetPoint(ism-1)[0], tmpSmoothPnts->GetPoint(ism-1)[1], tmpSmoothPnts->GetPoint(ism-1)[2]); vnl_vector_fixed< double, 3 > diff2; diff2 = tmpPntvtk - prevtmpPntvtk; diff2.normalize(); rgba[0] = (unsigned char) (255.0 * std::abs(diff2[0])); rgba[1] = (unsigned char) (255.0 * std::abs(diff2[1])); rgba[2] = (unsigned char) (255.0 * std::abs(diff2[2])); rgba[3] = (unsigned char) (255.0); // // MITK_INFO << "last point color: " << rgba[0] << " " << rgba[1] << " " << rgba[2]; } //end colorcoding // colorsT->InsertNextTupleValue(rgba); }//end of smoothline ///////smooth Fiber ready//////// vtkSmoothCells->InsertNextCell(smoothLine); } //vtkpointsDTI->Delete();//points are not needed anymore TODO uncomment! /* //get FA value ... for that FA has to be interpolated as well as DTItracktLine float faVal = tmpFiberPntLst.GetField(mitk::FiberBundle::DTITubePointType::FA); //use insertNextValue cuz FA Values are reperesented as a single number (1 Tuple containing 1 parameter) faColors->InsertNextValue((double) faVal); */ //vtkcells->InitTraversal(); // Put points and lines together in one polyData structure vtkPolyData *polyData = vtkPolyData::New(); polyData->SetPoints(vtkSmoothPoints); polyData->SetLines(vtkSmoothCells); if (vtkVrtxs->GetSize() > 0) { polyData->SetVerts(vtkVrtxs); } polyData->GetPointData()->AddArray(colorsT); //polyData->GetPointData()->AddArray(faColors); //polyData->GetPointData()->AddArray(tubeRadius); vtkLookupTable *lut = vtkLookupTable::New(); lut->Build(); m_VtkFiberDataMapperGL = vtkOpenGLPolyDataMapper::New(); m_VtkFiberDataMapperGL->SetInput(polyData); m_VtkFiberDataMapperGL->ScalarVisibilityOn(); m_VtkFiberDataMapperGL->SetScalarModeToUsePointFieldData(); //m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); m_VtkFiberDataMapperGL->SetLookupTable(lut); m_vtkTubeMapper = vtkOpenGLPolyDataMapper::New(); //m_FiberActor = vtkOpenGLActor::New(); m_FiberActor->SetMapper(m_VtkFiberDataMapperGL); m_FiberActor->GetProperty()->SetOpacity(1.0); m_FiberActor->GetProperty()->SetPointSize(4.0f); // m_FiberActor->GetProperty()->SetColor(255.0, 0.0, 0.0); m_FiberAssembly->AddPart(m_FiberActor); //setting color and opacity in the fiberActor itself is not recommended //here cuz color and opacity of dataNode will be considered in GetData(baserenderer*) anyway this->GetDataNode()->SetColor(255.0,0,0); this->GetDataNode()->SetOpacity(1.0); } //template void mitk::FiberBundleMapper3D::GenerateData( mitk::BaseRenderer *renderer ) { //MITK_INFO << "FiberBundleMapper3D GenerateData(BaseRenderer)" ; // nodeCC = 1 ... ROI colorcoding // 2 ... orientation colorcoding // 3 ... FA colorcoding int nodeCC; bool isCCd = this->GetDataNode()->GetPropertyValue("ColorCoding", nodeCC); if ( isCCd && nodeCC == 1 ) { //get color and opacity from DataNode int tmpline; bool isLineProp = this->GetDataNode()->GetPropertyValue("LineWidth",tmpline); bool isPointRep; bool successPointProp = this->GetDataNode()->GetPropertyValue("RepPoints", isPointRep); float pointSize; bool successPointSize = this->GetDataNode()->GetPropertyValue("pointSize", pointSize); if (isLineProp) { m_FiberActor->GetProperty()->SetLineWidth(tmpline); } if(isPointRep) { m_FiberActor->GetProperty()->SetRepresentationToPoints(); m_FiberActor->GetProperty()->SetPointSize(pointSize); } } else if (isCCd && nodeCC == 2) { float tmpopa; this->GetDataNode()->GetOpacity(tmpopa, NULL); m_FiberActor->GetProperty()->SetOpacity((double) tmpopa); } else if (isCCd && nodeCC == 3) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_FiberActor->GetProperty()->SetColor(trgb); if(m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 4) { if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 5){ if(!m_VtkFiberDataMapperGL->GetScalarVisibility()) //if visibility is off, switch it on { m_VtkFiberDataMapperGL->ScalarVisibilityOn(); } m_VtkFiberDataMapperGL->SelectColorArray("FaColors"); } else if (isCCd && nodeCC == 6){ //orientationbased colorcoding + FA as opacity //get FA out of polydata, which is saved in faColor vtkDoubleArray vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasAr = tmpPointData->HasArray("FaColors"); if(!hasAr) return; vtkDoubleArray *tmpFAarray = (vtkDoubleArray*)(tmpPointData->GetArray("FaColors")) ; /*for(int i=0; iGetNumberOfTuples(); i++) { double *tmpTuple; tmpFAarray->GetTuple(i, tmpTuple); for(int j=0; jGetNumberOfComponents(); j++) { MITK_INFO << "FA Value: at index " << i << ": " << tmpTuple[j]; } } */ //since we have our FA values, lets replace the alpha values in colorT //we know each 4th entry is a A value of RGBA int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { //double *tmpTupleCV = colorsTtmp->GetTuple4(i); double tmpTupleFA = tmpFAarray->GetTuple1(i); tmpTupleFA = tmpTupleFA * 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); // MITK_INFO << "----" << i; //MITK_INFO << tmpTupleCV[0]; //MITK_INFO << tmpTupleCV[1]; //MITK_INFO << tmpTupleCV[2]; //MITK_INFO << tmpTupleCV[3]; //double *test = m_VtkFiberDataMapperGL->GetInput()->GetPointData()->GetArray("ColorValues")->GetTuple4(i); //MITK_INFO << test[0]; //MITK_INFO << test[1]; //MITK_INFO << test[2]; //MITK_INFO << test[3]; } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 7){ vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPointData *tmpPointData = tmpPolyData->GetPointData(); int hasArCV = tmpPointData->HasArray("ColorValues"); if(!hasArCV) return; vtkUnsignedCharArray *colorsTtmp = dynamic_cast (tmpPointData->GetArray("ColorValues")); for(int i=0; iGetNumberOfTuples(); i++) { double tmpTupleFA = 255.0; colorsTtmp->SetComponent(i,3, tmpTupleFA ); } m_VtkFiberDataMapperGL->SelectColorArray(""); m_VtkFiberDataMapperGL->SelectColorArray("ColorValues"); } else if (isCCd && nodeCC == 8) { /* something is still missing to activate smoothing or make it work.... */ if (!renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(1); renderer->GetRenderWindow()->Modified(); } if (!renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(1); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 9) { if (renderer->GetRenderWindow()->GetLineSmoothing()) { renderer->GetRenderWindow()->SetLineSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPointSmoothing()) { renderer->GetRenderWindow()->SetPointSmoothing(0); renderer->GetRenderWindow()->Modified(); } if (renderer->GetRenderWindow()->GetPolygonSmoothing()) { renderer->GetRenderWindow()->SetPolygonSmoothing(0); renderer->GetRenderWindow()->Modified(); } } else if (isCCd && nodeCC == 10) { // manipulate X Coordinates of selected FiberBundle int tmpXmove; bool isXmove = this->GetDataNode()->GetPropertyValue("Xmove",tmpXmove); if (!isXmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[0] = PtmpPntVal[0] + (double) tmpXmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 11) { // manipulate Y Coordinates of selected FiberBundle int tmpYmove; bool isYmove = this->GetDataNode()->GetPropertyValue("Ymove",tmpYmove); if (!isYmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[1] = PtmpPntVal[1] + (double) tmpYmove; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 12) { // manipulate Z Coordinates of selected FiberBundle int tmpZmove; bool isZmove = this->GetDataNode()->GetPropertyValue("Zmove",tmpZmove); if (!isZmove) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); vtkPoints* tmpVtkPnts = tmpPolyData->GetPoints(); double PtmpPntVal[3]; for (int i=0; iGetNumberOfPoints(); ++i ) { tmpVtkPnts->GetPoint(i,PtmpPntVal); PtmpPntVal[2] = PtmpPntVal[2] + (double) tmpZmove; //PtmpPntVal[2] = PtmpPntVal[2] + 1; tmpVtkPnts->SetPoint(i, PtmpPntVal); tmpPolyData->Modified(); } } else if (isCCd && nodeCC == 13) { int tmpTubeSides; bool isTubeSides = this->GetDataNode()->GetPropertyValue("TubeSides",tmpTubeSides); float tmpRadius; bool isRadius = this->GetDataNode()->GetPropertyValue("TubeRadius",tmpRadius); if (!isTubeSides) return; vtkPolyData *tmpPolyData = m_VtkFiberDataMapperGL->GetInput(); m_tubes = vtkTubeFilter::New(); m_tubes->SetInput(tmpPolyData); m_tubes->SidesShareVerticesOn(); m_tubes->SetRadius((double)(tmpRadius)); m_tubes->SetNumberOfSides(tmpTubeSides); m_tubes->Modified(); // m_tubes->Update(); m_vtkTubeMapper->SetInputConnection(m_tubes->GetOutputPort()); m_vtkTubeMapper->ScalarVisibilityOn(); m_vtkTubeMapper->SetScalarModeToUsePointFieldData(); m_vtkTubeMapper->SelectColorArray(""); m_vtkTubeMapper->SelectColorArray("ColorValues"); m_TubeActor->SetMapper(m_vtkTubeMapper); m_TubeActor->GetProperty()->SetOpacity(1); m_TubeActor->GetProperty()->BackfaceCullingOn(); m_FiberAssembly->AddPart(m_TubeActor); m_FiberAssembly->Modified(); } else if (isCCd && nodeCC == 14) { float temprgb[3]; this->GetDataNode()->GetColor( temprgb, NULL ); double trgb[3] = { (double) temprgb[0], (double) temprgb[1], (double) temprgb[2] }; m_TubeActor->GetProperty()->SetColor(trgb); if(m_vtkTubeMapper->GetScalarVisibility()) //can be 0 or 1, for scalarVis On or Off { m_vtkTubeMapper->ScalarVisibilityOff(); } } else if (isCCd && nodeCC == 15) { m_TubeActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_TubeActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 16) { float tmpTubeOpacity; bool isTubeOpacity = this->GetDataNode()->GetPropertyValue("TubeOpacity",tmpTubeOpacity); m_TubeActor->GetProperty()->SetOpacity((double) tmpTubeOpacity); m_TubeActor->Modified(); } else if (isCCd && nodeCC == 17) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->RemovePart(m_FiberActor); m_FiberAssembly->Modified(); }else if (isCCd && nodeCC == 18) { m_FiberActor->GetProperty()->SetOpacity(0); m_FiberAssembly->AddPart(m_FiberActor); m_FiberAssembly->Modified(); } //MITK_INFO << m_VtkFiberDataMapperGL->GetArrayName(); /* int displayIndex(0); this->GetDataNode()->GetIntProperty( "DisplayChannel", displayIndex, renderer ); InputImageType *input = const_cast< InputImageType* >( this->GetInput() ); mitk::DiffusionImage *input2 = dynamic_cast< mitk::DiffusionImage* >( input ); input2->SetDisplayIndexForRendering(displayIndex); Superclass::GenerateData(renderer); */ } //template void mitk::FiberBundleMapper3D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { //MITK_INFO << "FiberBundleMapper3D SetDefault Properties(...)"; node->AddProperty( "DisplayChannel", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "LineWidth", mitk::IntProperty::New( true ), renderer, overwrite ); node->AddProperty( "ColorCoding", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "VertexOpacity_1", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "Set_FA_VertexAlpha", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "pointSize", mitk::FloatProperty::New(0.5), renderer, overwrite); node->AddProperty( "setShading", mitk::IntProperty::New(1), renderer, overwrite); node->AddProperty( "Xmove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "Ymove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "Zmove", mitk::IntProperty::New( 0 ), renderer, overwrite); node->AddProperty( "RepPoints", mitk::BoolProperty::New( false ), renderer, overwrite); node->AddProperty( "TubeSides", mitk::IntProperty::New( 8 ), renderer, overwrite); node->AddProperty( "TubeRadius", mitk::FloatProperty::New( 0.15 ), renderer, overwrite); node->AddProperty( "TubeOpacity", mitk::FloatProperty::New( 1.0 ), renderer, overwrite); - node->AddProperty( "pickable", mitk::BoolProperty::New( true ), renderer, overwrite); - mitk::FiberBundleInteractor::Pointer bundleInteractor = dynamic_cast(node->GetInteractor()); - if(bundleInteractor.IsNull()) - bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node); - mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); - Superclass::SetDefaultProperties(node, renderer, overwrite); } vtkProp* mitk::FiberBundleMapper3D::GetVtkProp(mitk::BaseRenderer *renderer) { //MITK_INFO << "FiberBundleMapper3D GetVtkProp(renderer)"; return m_FiberAssembly; } void mitk::FiberBundleMapper3D::ApplyProperties(mitk::BaseRenderer* renderer) { // MITK_INFO << "FiberBundleMapper3D ApplyProperties(renderer)"; } void mitk::FiberBundleMapper3D::UpdateVtkObjects() { // MITK_INFO << "FiberBundleMapper3D UpdateVtkObjects()"; } void mitk::FiberBundleMapper3D::SetVtkMapperImmediateModeRendering(vtkMapper *) { }