diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp index 4ace192761..21224bab07 100644 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.cpp @@ -1,285 +1,353 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ 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. =========================================================================*/ // Blueberry #include #include // Qmitk #include "QmitkFiberBundleDeveloperView.h" #include // Qt // VTK #include #include #include const std::string QmitkFiberBundleDeveloperView::VIEW_ID = "org.mitk.views.fiberbundledeveloper"; const std::string id_DataManager = "org.mitk.views.datamanager"; using namespace berry; QmitkFiberBundleDeveloperView::QmitkFiberBundleDeveloperView() : QmitkFunctionality() , m_Controls( 0 ) , m_MultiWidget( NULL ) { } // Destructor QmitkFiberBundleDeveloperView::~QmitkFiberBundleDeveloperView() { } void QmitkFiberBundleDeveloperView::CreateQtPartControl( QWidget *parent ) { // build up qt view, unless already done in QtDesigner, etc. if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkFiberBundleDeveloperViewControls; m_Controls->setupUi( parent ); connect( m_Controls->buttonGenerateFibers, SIGNAL(clicked()), this, SLOT(DoGenerateFibers()) ); + connect( m_Controls->radioButton_directionRandom, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); + connect( m_Controls->radioButton_directionX, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); + connect( m_Controls->radioButton_directionY, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); + connect( m_Controls->radioButton_directionZ, SIGNAL(clicked()), this, SLOT(DoUpdateGenerateFibersWidget()) ); } // Checkpoint for fiber ORIENTATION if ( m_DirectionRadios.empty() ) { m_DirectionRadios.insert(0, m_Controls->radioButton_directionRandom); m_DirectionRadios.insert(1, m_Controls->radioButton_directionX); m_DirectionRadios.insert(2, m_Controls->radioButton_directionY); m_DirectionRadios.insert(3, m_Controls->radioButton_directionZ); } } +void QmitkFiberBundleDeveloperView::DoUpdateGenerateFibersWidget() +{ + MITK_INFO << "DO_UPDATE_GENERATE_FIBERS_WIDGET :-) "; + //get selected radioButton + QString fibDirection; //stores the object_name of selected radiobutton + QVector::const_iterator i; + for (i = m_DirectionRadios.begin(); i != m_DirectionRadios.end(); ++i) + { + QRadioButton* rdbtn = *i; + if (rdbtn->isChecked()) + fibDirection = rdbtn->objectName(); + } + + if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_RANDOM ) { + // disable radiobuttons + if (m_Controls->boxFiberMinLength->isEnabled()) + m_Controls->boxFiberMinLength->setEnabled(false); + + if (m_Controls->labelFiberMinLength->isEnabled()) + m_Controls->labelFiberMinLength->setEnabled(false); + + if (m_Controls->boxFiberMaxLength->isEnabled()) + m_Controls->boxFiberMaxLength->setEnabled(false); + + if (m_Controls->labelFiberMaxLength->isEnabled()) + m_Controls->labelFiberMaxLength->setEnabled(false); + + //enable radiobuttons + if (!m_Controls->labelFibersTotal->isEnabled()) + m_Controls->labelFibersTotal->setEnabled(true); + + if (!m_Controls->boxFiberNumbers->isEnabled()) + m_Controls->boxFiberNumbers->setEnabled(true); + + if (!m_Controls->labelDistrRadius->isEnabled()) + m_Controls->labelDistrRadius->setEnabled(true); + + if (!m_Controls->boxDistributionRadius->isEnabled()) + m_Controls->boxDistributionRadius->setEnabled(true); + + + } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_X ) { + // disable radiobuttons + + + + + } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Y ) { + // disable radiobuttons + + } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Z ) { + // disable radiobuttons + } + + +} + void QmitkFiberBundleDeveloperView::DoGenerateFibers() { // GET SELECTED FIBER DIRECTION QString fibDirection; //stores the object_name of selected radiobutton QVector::const_iterator i; for (i = m_DirectionRadios.begin(); i != m_DirectionRadios.end(); ++i) { QRadioButton* rdbtn = *i; if (rdbtn->isChecked()) fibDirection = rdbtn->objectName(); } vtkSmartPointer output; // FiberPD stores the generated PolyData if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_RANDOM ) { // build polydata with random lines and fibers output = GenerateVtkFibersRandom(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_X ) { // build polydata with XDirection fibers output = GenerateVtkFibersDirectionX(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Y ) { // build polydata with YDirection fibers output = GenerateVtkFibersDirectionY(); } else if ( fibDirection == FIB_RADIOBUTTON_DIRECTION_Z ) { // build polydata with ZDirection fibers output = GenerateVtkFibersDirectionZ(); } //mitkFiberBundleX::New() //write to dataStorage } /* * Generate polydata of random fibers */ vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersRandom() { int numOfFibers = m_Controls->boxFiberNumbers->value(); - int pntsPrFiber = m_Controls->boxPointsPerFiber->value(); - int numOfPoints = numOfFibers * pntsPrFiber; + int distrRadius = m_Controls->boxDistributionRadius->value(); + int numOfPoints = numOfFibers * distrRadius; + + + std::vector< std::vector > fiberStorage; + for (int i=0; i a; + fiberStorage.push_back( a ); + + } + + //get number of items in fiberStorage + MITK_INFO << "Fibers in fiberstorage: " << fiberStorage.size(); + + for (unsigned long i=0; i singleFiber = fiberStorage.at(i); + MITK_INFO << "====FIBER_" << i << "_====="; + + for (unsigned long si=0; si randomPoints = vtkSmartPointer::New(); randomPoints->SetCenter(0.0, 0.0, 0.0); randomPoints->SetNumberOfPoints(numOfPoints); - randomPoints->SetRadius(pntsPrFiber); + randomPoints->SetRadius(distrRadius); randomPoints->Update(); vtkPolyData* pntHost = randomPoints->GetOutput(); vtkPoints* pnts = pntHost->GetPoints(); //=================================== //checkpoint if requested amount of points equals generated amount if (numOfPoints != pnts->GetNumberOfPoints()) { MITK_INFO << "VTK POINT ERROR, WRONG AMOUNT OF GENRERATED POINTS"; return 0; }// ================================= // Set Fibers vtkSmartPointer linesCell = vtkSmartPointer::New(); // iterate through points - for (int i=0; i < numOfPoints; i+=pntsPrFiber) // e.g. i eqals 0, 50, 100, etc., I choose this cuz then its more easy to fill the lines with according points. - { - if (i%pntsPrFiber == 0) - { - vtkSmartPointer newFiber = vtkSmartPointer::New(); - newFiber->GetPointIds()->SetNumberOfIds(pntsPrFiber); - - // construct the fiber - for (int pc = 0; pc < pntsPrFiber; ++pc) - { - newFiber->GetPointIds()->SetId(pc, pc+i); - // MITK_INFO << linesCell->GetNumberOfCells() << ": " << pnts->GetPoint(pc+i)[0] << " " << pnts->GetPoint(pc+i)[1] << " " << pnts->GetPoint(pc+i)[2]; - } - - linesCell->InsertNextCell(newFiber); - - - // ================SHALL NEVER OCCUR================= - } else { - MITK_INFO << "LOGIC ERROR IN CREATING FIBERS...Check Values in QmitkFiberBundleDeveloperView.cpp"; - } - // =================================================== - } - vtkSmartPointer PDRandom = vtkSmartPointer::New(); PDRandom->SetPoints(pnts); PDRandom->SetLines(linesCell); return PDRandom; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionX() { int numOfFibers = m_Controls->boxFiberNumbers->value(); vtkSmartPointer linesCell = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); //insert Origin point, this point has index 0 in point array double originX = 0.0; double originY = 0.0; double originZ = 0.0; //after each iteration the origin of the new fiber increases //here you set which direction is affected. double increaseX = 0.0; double increaseY = 1.0; double increaseZ = 0.0; //walk along X axis //length of fibers increases in each iteration for (int i=0; i newFiber = vtkSmartPointer::New(); newFiber->GetPointIds()->SetNumberOfIds(i+2); //create starting point and add it to pointset points->InsertNextPoint(originX + (double)i * increaseX , originY + (double)i * increaseY, originZ + (double)i * increaseZ); //add starting point to fiber newFiber->GetPointIds()->SetId(0,points->GetNumberOfPoints()-1); - + //insert remaining points for fiber for (int pj=0; pj<=i ; ++pj) { //generate next point on X axis points->InsertNextPoint( originX + (double)pj+1 , originY + (double)i * increaseY, originZ + (double)i * increaseZ ); newFiber->GetPointIds()->SetId(pj+1,points->GetNumberOfPoints()-1); } linesCell->InsertNextCell(newFiber); } vtkSmartPointer PDX = vtkSmartPointer::New(); PDX->SetPoints(points); PDX->SetLines(linesCell); return PDX; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionY() { vtkSmartPointer PDY = vtkSmartPointer::New(); //todo return PDY; } vtkSmartPointer QmitkFiberBundleDeveloperView::GenerateVtkFibersDirectionZ() { vtkSmartPointer PDZ = vtkSmartPointer::New(); //todo return PDZ; } void QmitkFiberBundleDeveloperView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { m_MultiWidget = &stdMultiWidget; } void QmitkFiberBundleDeveloperView::StdMultiWidgetNotAvailable() { m_MultiWidget = NULL; } /* OnSelectionChanged is registered to SelectionService, therefore no need to implement SelectionService Listener explicitly */ void QmitkFiberBundleDeveloperView::OnSelectionChanged( std::vector nodes ) { } void QmitkFiberBundleDeveloperView::Activated() { MITK_INFO << "FB OPerations ACTIVATED()"; } diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h index 65bdaa9d4c..af5487c418 100644 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h +++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperView.h @@ -1,113 +1,113 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2010-03-31 16:40:27 +0200 (Mi, 31 Mrz 2010) $ Version: $Revision: 21975 $ 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 QmitkFiberBundleDeveloperView_h #define QmitkFiberBundleDeveloperView_h #include #include #include #include "ui_QmitkFiberBundleDeveloperViewControls.h" #include #include // Qt #include #include #include // VTK #include #include const QString FIB_RADIOBUTTON_DIRECTION_RANDOM = "radioButton_directionRandom"; const QString FIB_RADIOBUTTON_DIRECTION_X = "radioButton_directionX"; const QString FIB_RADIOBUTTON_DIRECTION_Y = "radioButton_directionY"; const QString FIB_RADIOBUTTON_DIRECTION_Z = "radioButton_directionZ"; /*! \brief QmitkFiberBundleView \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class QmitkFiberBundleDeveloperView : public QmitkFunctionality { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkFiberBundleDeveloperView(); virtual ~QmitkFiberBundleDeveloperView(); virtual void CreateQtPartControl(QWidget *parent); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); virtual void Activated(); protected slots: void DoGenerateFibers(); - + void DoUpdateGenerateFibersWidget(); protected: /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); Ui::QmitkFiberBundleDeveloperViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; private: vtkSmartPointer GenerateVtkFibersRandom(); vtkSmartPointer GenerateVtkFibersDirectionX(); vtkSmartPointer GenerateVtkFibersDirectionY(); vtkSmartPointer GenerateVtkFibersDirectionZ(); //contains the selected FiberBundle mitk::DataNode::Pointer m_FiberBundleNode; // radiobutton groups QVector< QRadioButton* > m_DirectionRadios; QVector< QRadioButton* > m_FARadios; QVector< QRadioButton* > m_GARadios; }; #endif // _QMITKFIBERTRACKINGVIEW_H_INCLUDED diff --git a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui index 40f9c41523..8e9abb471a 100644 --- a/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui +++ b/Modules/Bundles/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkFiberBundleDeveloperViewControls.ui @@ -1,692 +1,660 @@ QmitkFiberBundleDeveloperViewControls 0 0 382 691 Form 12 50 false 0 0 0 - 357 - 474 + 355 + 395 Fiber Generator 0 Fiber Bundles Generate Fiberbundle Fiber Parameters - - - - - 10 - - - - 99 - - - - - - - - 10 - - - - 999999999 - - - 100 - - - - - - - - 11 - - - - Points per Fiber - - - 11 Total number of Fibers - - + + 10 - - 2 - 999999999 - 50 + 100 Qt::Horizontal 40 20 - - + + + + + 11 + + + + Distribution Radius + + + + + 10 - 50 + 99 - + 11 Fiber Length Max (points) - - + + - 11 + 10 - - Distribution Radius + + 50 - + 11 Fiber Length Min (points) - + 10 10 labelFibersTotal - labelPntsPerFiber - boxPointsPerFiber boxFiberNumbers horizontalSpacer_3 labelDistrRadius boxDistributionRadius labelFiberMaxLength boxFiberMaxLength labelFiberMinLength boxFiberMinLength 11 Fiber Orientation along Z Axis along X Axis random true along Y Axis Qt::Horizontal 40 20 Qt::Vertical 20 40 DWI Values GA Values no values true nothing yet implemented 11 FA Values const value false 10 1.000000000000000 0.100000000000000 1.000000000000000 random range false 10 1.000000000000000 0.100000000000000 no values true false 10 1.000000000000000 0.100000000000000 Qt::Vertical 20 40 Page Select a FiberBundle in Datamanager Qt::Vertical 20 40 0 0 343 - 409 + 403 Fiber Processor 2 Colors Fiber Coloring Color Fibers Qt::Vertical 20 40 Shape Qt::Vertical 20 40 Fiber Smoothing Smooth Fibers QFrame::StyledPanel QFrame::Raised static value relative in% false 10 none true false 10 9999 Qt::Horizontal 40 20 vtkFilters Tubes vtkDecimatePro vtkSmoothPolyDataFilter Cutting Qt::Vertical 20 40