diff --git a/Modules/QmitkExt/QmitkHistogramWidget.cpp b/Modules/QmitkExt/QmitkHistogramWidget.cpp index 8243a070c1..1ff9420c9d 100644 --- a/Modules/QmitkExt/QmitkHistogramWidget.cpp +++ b/Modules/QmitkExt/QmitkHistogramWidget.cpp @@ -1,186 +1,187 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkHistogramWidget.h" #include "mitkImageStatisticsHolder.h" #include #include #include #include #include #include #include #include #include //#include -QmitkHistogramWidget::QmitkHistogramWidget(QWidget * /*parent*/, bool showreport) +QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport) + : QDialog(parent) { QBoxLayout *layout = new QVBoxLayout(this); //***histogram*** QGroupBox *hgroupbox = new QGroupBox("", this); hgroupbox->setMinimumSize(900, 400); m_Plot = new QwtPlot(hgroupbox); m_Plot->setCanvasBackground(QColor(Qt::white)); m_Plot->setTitle("Histogram"); QwtText text = m_Plot->titleLabel()->text(); text.setFont(QFont("Helvetica", 12, QFont::Normal)); QwtPlotGrid *grid = new QwtPlotGrid; grid->enableXMin(true); grid->enableYMin(true); grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine)); grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); grid->attach(m_Plot); layout->addWidget(hgroupbox); layout->setSpacing(20); if (showreport == true) { //***report*** QGroupBox *rgroupbox = new QGroupBox("", this); rgroupbox->setMinimumSize(900, 400); QLabel *label = new QLabel("Gray Value Analysis", rgroupbox); label->setAlignment(Qt::AlignHCenter); label->setFont(QFont("Helvetica", 14, QFont::Bold)); m_Textedit = new QTextEdit(rgroupbox); m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal)); m_Textedit->setReadOnly(true); layout->addWidget(rgroupbox); } m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::PointSelection, QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn, m_Plot->canvas()); connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)), SLOT(OnSelect(const QwtDoublePoint &))); } QmitkHistogramWidget::~QmitkHistogramWidget() { } void QmitkHistogramWidget::SetHistogram(HistogramType::ConstPointer itkHistogram) { HistogramType::SizeType size = itkHistogram->GetSize(); HistogramType::IndexType index; HistogramType::MeasurementVectorType currentMeasurementVector; QwtArray xValues(size[0]); QwtArray yValues(size[0]); for (unsigned int i = 0; i < size[0]; ++i) { #if !defined(ITK_USE_REVIEW_STATISTICS) index[0] = static_cast (i); #else index[0] = static_cast (i); #endif currentMeasurementVector = itkHistogram->GetMeasurementVector(index); if (currentMeasurementVector[0] != 0.0) { xValues[i] = QwtDoubleInterval(Round(currentMeasurementVector[0]-1), Round(currentMeasurementVector[0])); yValues[i] = static_cast (itkHistogram->GetFrequency(index)); } } // rebuild the plot m_Plot->clear(); m_Histogram = new QmitkHistogram(); m_Histogram->setColor(Qt::darkCyan); m_Histogram->setData(QwtIntervalData(xValues, yValues)); m_Histogram->attach(m_Plot); this->InitializeMarker(); this->InitializeZoomer(); m_Plot->replot(); } void QmitkHistogramWidget::SetHistogram( mitk::Image* mitkImage ) { this->SetHistogram(mitkImage->GetStatistics()->GetScalarHistogram()); } void QmitkHistogramWidget::SetReport(std::string report) { m_Textedit->setText(report.c_str()); } void QmitkHistogramWidget::InitializeMarker() { m_Marker = new QwtPlotMarker(); m_Marker->setXValue(0.); m_Marker->setLineStyle(QwtPlotMarker::VLine); m_Marker->setLabelAlignment(Qt::AlignHCenter | Qt::AlignRight); m_Marker->setLinePen(QPen(QColor(200,150,0), 3, Qt::SolidLine)); m_Marker->setSymbol( QwtSymbol(QwtSymbol::Diamond, QColor(Qt::red), QColor(Qt::red), QSize(10,10))); m_Marker->attach(m_Plot); } void QmitkHistogramWidget::InitializeZoomer() { m_Zoomer = new QwtPlotZoomer(m_Plot->xBottom, m_Plot->yLeft, m_Plot->canvas()); m_Zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine)); m_Zoomer->setTrackerPen(QPen(Qt::red)); m_Zoomer->setSelectionFlags(QwtPlotZoomer::RectSelection); } void QmitkHistogramWidget::OnSelect( const QwtDoublePoint& pos ) { m_Marker->setXValue( this->Round(pos.x()) ); //unsigned int count = (unsigned int)(m_Histogram->data().value(pos.x())); QString str = QString( "%1" ) .arg( (int)(this->Round(pos.x())), 0, 10 ); QwtText text(str); text.setBackgroundBrush(QColor(200,150,0)); text.setFont(QFont("Helvetica", 14, QFont::Bold)); m_Marker->setLabel(text); m_Plot->replot(); } double QmitkHistogramWidget::GetMarkerPosition() { return m_Marker->xValue(); } double QmitkHistogramWidget::Round(double val) { double ival = (double)(int)val; if( (val - ival) > 0.5) return ival+1; else return ival; } diff --git a/Modules/QmitkExt/QmitkVtkHistogramWidget.cpp b/Modules/QmitkExt/QmitkVtkHistogramWidget.cpp index b154264dd7..17e936282f 100644 --- a/Modules/QmitkExt/QmitkVtkHistogramWidget.cpp +++ b/Modules/QmitkExt/QmitkVtkHistogramWidget.cpp @@ -1,277 +1,277 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkVtkHistogramWidget.h" #include "mitkHistogramGenerator.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include -QmitkVtkHistogramWidget::QmitkVtkHistogramWidget( QWidget * /*parent*/ ) -: m_HistogramMode( HISTOGRAM_MODE_ENTIREIMAGE ) +QmitkVtkHistogramWidget::QmitkVtkHistogramWidget( QWidget * parent ) +: QDialog(parent), m_HistogramMode( HISTOGRAM_MODE_ENTIREIMAGE ) { //QGroupBox *hgroupbox = new QGroupBox( "", this ); //hgroupbox->setMinimumSize( 150, 150 ); m_ChartWidget = new vtkQtChartWidget( this ); QBoxLayout *layout = new QVBoxLayout( this ); layout->addWidget( m_ChartWidget ); layout->setSpacing( 10 ); vtkQtChartArea *area = m_ChartWidget->getChartArea(); // Set up the bar chart. m_BarChart = new vtkQtBarChart(); area->insertLayer( area->getAxisLayerIndex(), m_BarChart ); // Set up the default interactor. vtkQtChartMouseSelection *selector = vtkQtChartInteractorSetup::createDefault( area ); vtkQtChartSeriesSelectionHandler *handler = new vtkQtChartSeriesSelectionHandler( selector ); handler->setModeNames( "Bar Chart - Series", "Bar Chart - Bars" ); handler->setMousePressModifiers( Qt::ControlModifier, Qt::ControlModifier ); handler->setLayer( m_BarChart ); selector->addHandler( handler ); selector->setSelectionMode("Bar Chart - Bars"); // Hide the x-axis grid. vtkQtChartAxisLayer *axisLayer = area->getAxisLayer(); vtkQtChartAxis *xAxis = axisLayer->getAxis(vtkQtChartAxis::Bottom); xAxis->getOptions()->setGridVisible(false); xAxis->getOptions()->setPrecision( 0 ); xAxis->getOptions()->setNotation( vtkQtChartAxisOptions::Standard ); vtkQtChartAxis *yAxis = axisLayer->getAxis(vtkQtChartAxis::Left); yAxis->getOptions()->setPrecision( 0 ); yAxis->getOptions()->setNotation( vtkQtChartAxisOptions::Standard ); // Set up the model for the bar chart. m_ItemModel = new QStandardItemModel( m_BarChart ); m_ItemModel->setItemPrototype( new QStandardItem() ); } QmitkVtkHistogramWidget::~QmitkVtkHistogramWidget() { } void QmitkVtkHistogramWidget::SetHistogramModeToDirectHistogram() { if ( m_HistogramMode != HISTOGRAM_MODE_DIRECT ) { m_HistogramMode = HISTOGRAM_MODE_DIRECT; } } void QmitkVtkHistogramWidget::SetHistogramModeToEntireImage() { if ( m_HistogramMode != HISTOGRAM_MODE_ENTIREIMAGE ) { m_HistogramMode = HISTOGRAM_MODE_ENTIREIMAGE; } } void QmitkVtkHistogramWidget::SetHistogramModeToMaskedImage() { if ( m_HistogramMode != HISTOGRAM_MODE_MASKEDIMAGE ) { m_HistogramMode = HISTOGRAM_MODE_MASKEDIMAGE; } } void QmitkVtkHistogramWidget::SetHistogramModeToImageRegion() { if ( m_HistogramMode != HISTOGRAM_MODE_IMAGEREGION ) { m_HistogramMode = HISTOGRAM_MODE_IMAGEREGION; } } void QmitkVtkHistogramWidget::SetHistogramModeToPlanarFigureRegion() { if ( m_HistogramMode != HISTOGRAM_MODE_PLANARFIGUREREGION ) { m_HistogramMode = HISTOGRAM_MODE_PLANARFIGUREREGION; } } void QmitkVtkHistogramWidget::UpdateItemModelFromHistogram() { this->ComputeHistogram(); if ( m_DerivedHistogram.IsNull() ) { return; } // Determine non-zero range of histogram unsigned int startIndex = 0, endIndex = 0, i = 0; HistogramConstIteratorType startIt = m_DerivedHistogram->End(); HistogramConstIteratorType endIt = m_DerivedHistogram->End(); HistogramConstIteratorType it; bool firstNonEmptyBinFound = false; for ( it = m_DerivedHistogram->Begin(); it != m_DerivedHistogram->End(); ++it, ++i ) { if ( it.GetFrequency() > 0.0 ) { endIt = it; endIndex = i; if ( !firstNonEmptyBinFound ) { firstNonEmptyBinFound = true; startIt = it; startIndex = i; } } } ++endIt; // For empty image / mask: clear histogram if ( startIt == m_DerivedHistogram->End() ) { this->ClearItemModel(); return; } // Allocate data in item model m_ItemModel->setRowCount( endIndex + 1 - startIndex ); m_ItemModel->setColumnCount( 1 ); // Fill item model with histogram data for ( it = startIt, i = 0; it != endIt; ++it, ++i ) { const double &frequency = it.GetFrequency(); const double &measurement = it.GetMeasurementVector()[0]; m_ItemModel->setVerticalHeaderItem( i, new QStandardItem() ); m_ItemModel->verticalHeaderItem( i )->setData( QVariant( measurement ), Qt::DisplayRole ); m_ItemModel->setItem( i, 0, new QStandardItem() ); m_ItemModel->item( i, 0 )->setData( QVariant( frequency ), Qt::DisplayRole ); } vtkQtChartTableSeriesModel *table = new vtkQtChartTableSeriesModel( m_ItemModel, m_BarChart ); m_BarChart->setModel( table ); m_ChartWidget->show(); } void QmitkVtkHistogramWidget::ClearItemModel() { m_ItemModel->clear(); } void QmitkVtkHistogramWidget::ComputeHistogram() { switch ( m_HistogramMode ) { case HISTOGRAM_MODE_DIRECT: { m_DerivedHistogram = m_Histogram; break; } case HISTOGRAM_MODE_ENTIREIMAGE: { mitk::HistogramGenerator::Pointer histogramGenerator = mitk::HistogramGenerator::New(); histogramGenerator->SetImage( m_Image ); histogramGenerator->ComputeHistogram(); m_DerivedHistogram = histogramGenerator->GetHistogram(); break; } case HISTOGRAM_MODE_MASKEDIMAGE: { break; } case HISTOGRAM_MODE_IMAGEREGION: { break; } case HISTOGRAM_MODE_PLANARFIGUREREGION: { break; } } } void QmitkVtkHistogramWidget::SetHistogram(const HistogramType* histogram ) { m_Histogram = histogram; } void QmitkVtkHistogramWidget::SetImage(const mitk::Image* image ) { m_Image = image; } void QmitkVtkHistogramWidget::SetImageMask(const mitk::Image* imageMask ) { m_ImageMask = imageMask; } void QmitkVtkHistogramWidget::SetImageRegion( const RegionType imageRegion ) { m_ImageRegion = imageRegion; } void QmitkVtkHistogramWidget::SetPlanarFigure(const mitk::PlanarFigure* planarFigure ) { m_PlanarFigure = planarFigure; } void QmitkVtkHistogramWidget::SetHistogramMode( unsigned int histogramMode ) { m_HistogramMode = histogramMode; } unsigned int QmitkVtkHistogramWidget::GetHistogramMode() { return m_HistogramMode; } diff --git a/Modules/QmitkExt/QmitkVtkHistogramWidget.h b/Modules/QmitkExt/QmitkVtkHistogramWidget.h index 49e684c863..2c418c5bc6 100644 --- a/Modules/QmitkExt/QmitkVtkHistogramWidget.h +++ b/Modules/QmitkExt/QmitkVtkHistogramWidget.h @@ -1,144 +1,144 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkVtkHistogramWidget_H_ #define QmitkVtkHistogramWidget_H_ #include "QmitkHistogram.h" #include "QmitkExtExports.h" #include "mitkImage.h" #include "mitkPlanarFigure.h" #include #include #include #include #include #include #include /** * \brief Widget for displaying image histograms based on the vtkQtChart * framework */ class QmitkExt_EXPORT QmitkVtkHistogramWidget : public QDialog { Q_OBJECT public: - QmitkVtkHistogramWidget( QWidget * /*parent = 0 */); + QmitkVtkHistogramWidget( QWidget * parent = 0 ); virtual ~QmitkVtkHistogramWidget(); typedef mitk::Image::HistogramType HistogramType; typedef mitk::Image::HistogramType::ConstIterator HistogramConstIteratorType; typedef itk::ImageRegion< 3 > RegionType; enum { HISTOGRAM_MODE_DIRECT = 0, HISTOGRAM_MODE_ENTIREIMAGE, HISTOGRAM_MODE_MASKEDIMAGE, HISTOGRAM_MODE_IMAGEREGION, HISTOGRAM_MODE_PLANARFIGUREREGION }; /** \brief Set histogram to be displayed directly. */ void SetHistogram(const HistogramType* histogram); /** \brief Set image from which to calculate the histogram. */ void SetImage(const mitk::Image* image); /** \brief Set binary image mask determining the voxels to include in * histogram calculation. */ void SetImageMask(const mitk::Image* imageMask); /** \brief Set 3D image region for which to calculate the histogram. */ void SetImageRegion(const RegionType imageRegion); /** \brief Set planar figure describing the region for which to calculate * the histogram. */ void SetPlanarFigure(const mitk::PlanarFigure* planarFigure); /** \brief Set/Get operation mode for Histogram */ void SetHistogramMode(unsigned int histogramMode); /** \brief Set/Get operation mode for Histogram */ unsigned int GetHistogramMode(); /** \brief Set/Get operation mode for Histogram */ void SetHistogramModeToDirectHistogram(); /** \brief Set/Get operation mode for Histogram */ void SetHistogramModeToEntireImage(); /** \brief Set/Get operation mode for Histogram */ void SetHistogramModeToMaskedImage(); /** \brief Set/Get operation mode for Histogram */ void SetHistogramModeToImageRegion(); /** \brief Set/Get operation mode for Histogram */ void SetHistogramModeToPlanarFigureRegion(); /** Fill the graphical widget with currently specified histogram. */ void UpdateItemModelFromHistogram(); /** \brief Clear the histogram (nothing is displayed). */ void ClearItemModel(); protected slots: protected: void ComputeHistogram(); vtkQtChartWidget *m_ChartWidget; vtkQtBarChart *m_BarChart; QStandardItemModel *m_ItemModel; mitk::Image::ConstPointer m_Image; mitk::Image::ConstPointer m_ImageMask; RegionType m_ImageRegion; mitk::PlanarFigure::ConstPointer m_PlanarFigure; unsigned int m_HistogramMode; // Histogram set explicitly by user HistogramType::ConstPointer m_Histogram; // Histogram derived from image (not set explicitly by user) HistogramType::ConstPointer m_DerivedHistogram; }; #endif /* QmitkVtkHistogramWidget_H_ */ diff --git a/Modules/QmitkExt/QmitkVtkLineProfileWidget.cpp b/Modules/QmitkExt/QmitkVtkLineProfileWidget.cpp index 4a5b442ed0..ba856cda0e 100644 --- a/Modules/QmitkExt/QmitkVtkLineProfileWidget.cpp +++ b/Modules/QmitkExt/QmitkVtkLineProfileWidget.cpp @@ -1,380 +1,380 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkVtkLineProfileWidget.h" #include "mitkGeometry2D.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if ((VTK_MAJOR_VERSION<=5) && (VTK_MINOR_VERSION<=4) ) #include #endif #if ((VTK_MAJOR_VERSION>=5) && (VTK_MINOR_VERSION>=6) ) #include #include #endif //#include -QmitkVtkLineProfileWidget::QmitkVtkLineProfileWidget( QWidget * /*parent*/ ) -: m_PathMode( PATH_MODE_DIRECT ) +QmitkVtkLineProfileWidget::QmitkVtkLineProfileWidget( QWidget * parent ) + : QDialog(parent), m_PathMode( PATH_MODE_DIRECT ) { m_ChartWidget = new vtkQtChartWidget( this ); QBoxLayout *layout = new QVBoxLayout( this ); layout->addWidget( m_ChartWidget ); layout->setSpacing( 10 ); vtkQtChartArea *area = m_ChartWidget->getChartArea(); // Set up the line chart. m_LineChart = new vtkQtLineChart(); area->insertLayer( area->getAxisLayerIndex(), m_LineChart ); //m_BarChart->getOptions()->setBarGroupFraction(10); // Set up the default interactor. vtkQtChartMouseSelection *selector = vtkQtChartInteractorSetup::createDefault( area ); vtkQtChartSeriesSelectionHandler *handler = new vtkQtChartSeriesSelectionHandler( selector ); handler->setModeNames( "Bar Chart - Series", "Bar Chart - Bars" ); handler->setMousePressModifiers( Qt::ControlModifier, Qt::ControlModifier ); handler->setLayer( m_LineChart ); selector->addHandler( handler ); selector->setSelectionMode("Bar Chart - Bars"); // Hide the x-axis grid. vtkQtChartAxisLayer *axisLayer = area->getAxisLayer(); vtkQtChartAxis *xAxis = axisLayer->getAxis(vtkQtChartAxis::Bottom); xAxis->getOptions()->setGridVisible(false); xAxis->getOptions()->setPrecision( 1 ); xAxis->getOptions()->setNotation( vtkQtChartAxisOptions::Standard ); vtkQtChartAxis *yAxis = axisLayer->getAxis(vtkQtChartAxis::Left); yAxis->getOptions()->setPrecision( 0 ); yAxis->getOptions()->setNotation( vtkQtChartAxisOptions::Standard ); // Set up the model for the bar chart. m_ItemModel = new QStandardItemModel( m_LineChart ); m_ItemModel->setItemPrototype( new QStandardItem() ); m_ItemModel->setHorizontalHeaderItem( 0, new QStandardItem("Intensity profile") ); #if ((VTK_MAJOR_VERSION<=5) && (VTK_MINOR_VERSION<=4) ) vtkQtChartStyleManager *styleManager = area->getStyleManager(); vtkQtChartPenBrushGenerator *pen = new vtkQtChartPenBrushGenerator(); pen->setPen(0,QPen(Qt::SolidLine)); pen->addPens(vtkQtChartColors::WildFlower); styleManager->setGenerator(pen); #endif #if ((VTK_MAJOR_VERSION>=5) && (VTK_MINOR_VERSION>=6) ) vtkQtChartBasicStyleManager *styleManager = qobject_cast(area->getStyleManager()); vtkQtChartPenGenerator *pen = new vtkQtChartPenGenerator(); pen->setPen(0,QPen(Qt::SolidLine)); pen->addPens(vtkQtChartColors::WildFlower); styleManager->setGenerator("Pen",pen); #endif // Initialize parametric path object m_ParametricPath = ParametricPathType::New(); } QmitkVtkLineProfileWidget::~QmitkVtkLineProfileWidget() { } void QmitkVtkLineProfileWidget::SetPathModeToDirectPath() { if ( m_PathMode != PATH_MODE_DIRECT ) { m_PathMode = PATH_MODE_DIRECT; } } void QmitkVtkLineProfileWidget::SetPathModeToPlanarFigure() { if ( m_PathMode != PATH_MODE_PLANARFIGURE ) { m_PathMode = PATH_MODE_PLANARFIGURE; } } void QmitkVtkLineProfileWidget::UpdateItemModelFromPath() { this->ComputePath(); if ( m_DerivedPath.IsNull() ) { throw std::invalid_argument("QmitkVtkLineProfileWidget: no path set"); } // TODO: indices according to mm //// Clear the item model m_ItemModel->clear(); MITK_INFO << "Intensity profile (t)"; MITK_INFO << "Start: " << m_DerivedPath->StartOfInput(); MITK_INFO << "End: " << m_DerivedPath->EndOfInput(); // Get geometry from image mitk::Geometry3D *imageGeometry = m_Image->GetGeometry(); // Fill item model with line profile data double distance = 0.0; mitk::Point3D currentWorldPoint; double t; unsigned int i = 0; int t_tmp = 0; QStandardItemModel *tmp_ItemModel = new QStandardItemModel(); vtkQtChartTableSeriesModel *table; vtkQtChartArea* area = m_ChartWidget->getChartArea(); for(unsigned int j = 0; j < m_VectorLineCharts.size(); j++) { area->removeLayer(m_VectorLineCharts[j]); m_VectorLineCharts[j]->getModel()->deleteLater(); m_VectorLineCharts[j]->deleteLater(); } m_VectorLineCharts.clear(); int k = 0; for ( i = 0, t = m_DerivedPath->StartOfInput(); ;++i ) { const PathType::OutputType &continuousIndex = m_DerivedPath->Evaluate( t ); mitk::Point3D worldPoint; imageGeometry->IndexToWorld( continuousIndex, worldPoint ); if ( i == 0 ) { currentWorldPoint = worldPoint; } distance += currentWorldPoint.EuclideanDistanceTo( worldPoint ); mitk::Index3D indexPoint; imageGeometry->WorldToIndex( worldPoint, indexPoint ); double intensity = m_Image->GetPixelValueByIndex( indexPoint ); MITK_INFO << t << "/" << distance << ": " << indexPoint << " (" << intensity << ")"; m_ItemModel->setVerticalHeaderItem( i, new QStandardItem() ); m_ItemModel->verticalHeaderItem( i )->setData( QVariant( distance ), Qt::DisplayRole ); m_ItemModel->setItem( i, 0, new QStandardItem() ); m_ItemModel->item( i, 0 )->setData( intensity, Qt::DisplayRole ); tmp_ItemModel->setVerticalHeaderItem( k, new QStandardItem() ); tmp_ItemModel->verticalHeaderItem( k )->setData( QVariant( distance ), Qt::DisplayRole ); tmp_ItemModel->setItem( k, 0, new QStandardItem() ); tmp_ItemModel->item( k, 0 )->setData( intensity, Qt::DisplayRole ); if ((int)t > t_tmp){ t_tmp = (int)t; vtkQtLineChart *tmp_LineChart = new vtkQtLineChart(); table = new vtkQtChartTableSeriesModel( tmp_ItemModel, tmp_LineChart ); tmp_LineChart->setModel( table ); m_VectorLineCharts.push_back(tmp_LineChart); tmp_ItemModel = new QStandardItemModel(); k = 0; tmp_ItemModel->setVerticalHeaderItem( k, new QStandardItem() ); tmp_ItemModel->verticalHeaderItem( k )->setData( QVariant( distance ), Qt::DisplayRole ); tmp_ItemModel->setItem( k, 0, new QStandardItem() ); tmp_ItemModel->item( k, 0 )->setData( intensity, Qt::DisplayRole ); } k++; // Go to next index; when iteration offset reaches zero, iteration is finished PathType::OffsetType offset = m_DerivedPath->IncrementInput( t ); if ( !(offset[0] || offset[1] || offset[2]) ) { break; } currentWorldPoint = worldPoint; } for(unsigned int j = 0; j < m_VectorLineCharts.size() ; j++) { /* int styleIndex = styleManager->getStyleIndex(m_LineChart, m_LineChart->getSeriesOptions(0)); vtkQtChartStylePen *stylePen = qobject_cast( styleManager->getGenerator("Pen")); stylePen->getStylePen(styleIndex).setStyle(Qt::SolidLine);*/ area->insertLayer(area->getAxisLayerIndex() + j +1, m_VectorLineCharts[j]); } table = new vtkQtChartTableSeriesModel( m_ItemModel, m_LineChart ); //m_LineChart->setModel( table ); } void QmitkVtkLineProfileWidget::ClearItemModel() { m_ItemModel->clear(); } void QmitkVtkLineProfileWidget::CreatePathFromPlanarFigure() { m_ParametricPath->Initialize(); if ( m_PlanarFigure.IsNull() ) { throw std::invalid_argument("QmitkVtkLineProfileWidget: PlanarFigure not set!" ); } if ( m_Image.IsNull() ) { throw std::invalid_argument("QmitkVtkLineProfileWidget: Image not set -- needed to calculate path from PlanarFigure!" ); } // Get 2D geometry frame of PlanarFigure mitk::Geometry2D *planarFigureGeometry2D = dynamic_cast< mitk::Geometry2D * >( m_PlanarFigure->GetGeometry( 0 ) ); if ( planarFigureGeometry2D == NULL ) { throw std::invalid_argument("QmitkVtkLineProfileWidget: PlanarFigure has no valid geometry!" ); } // Get 3D geometry from Image (needed for conversion of point to index) mitk::Geometry3D *imageGeometry = m_Image->GetGeometry( 0 ); if ( imageGeometry == NULL ) { throw std::invalid_argument("QmitkVtkLineProfileWidget: Image has no valid geometry!" ); } // Get first poly-line of PlanarFigure (other possible poly-lines in PlanarFigure // are not supported) typedef mitk::PlanarFigure::PolyLineType VertexContainerType; const VertexContainerType vertexContainer = m_PlanarFigure->GetPolyLine( 0 ); MITK_INFO << "WorldToIndex:"; VertexContainerType::const_iterator it; for ( it = vertexContainer.begin(); it != vertexContainer.end(); ++it ) { // Map PlanarFigure 2D point to 3D point mitk::Point3D point3D; planarFigureGeometry2D->Map( it->Point, point3D ); // Convert world to index coordinates mitk::Point3D indexPoint3D; imageGeometry->WorldToIndex( point3D, indexPoint3D ); ParametricPathType::OutputType index; index[0] = indexPoint3D[0]; index[1] = indexPoint3D[1]; index[2] = indexPoint3D[2]; MITK_INFO << point3D << " / " << index; // Add index to parametric path m_ParametricPath->AddVertex( index ); } } void QmitkVtkLineProfileWidget::ComputePath() { switch ( m_PathMode ) { case PATH_MODE_DIRECT: { m_DerivedPath = m_Path; break; } case PATH_MODE_PLANARFIGURE: { // Calculate path from PlanarFigure using geometry of specified Image this->CreatePathFromPlanarFigure(); m_DerivedPath = m_ParametricPath; break; } } } void QmitkVtkLineProfileWidget::SetImage( mitk::Image* image ) { m_Image = image; } void QmitkVtkLineProfileWidget::SetPath( const PathType* path ) { m_Path = path; } void QmitkVtkLineProfileWidget::SetPlanarFigure( const mitk::PlanarFigure* planarFigure ) { m_PlanarFigure = planarFigure; } void QmitkVtkLineProfileWidget::SetPathMode( unsigned int pathMode ) { m_PathMode = pathMode; } unsigned int QmitkVtkLineProfileWidget::GetPathMode() { return m_PathMode; } diff --git a/Modules/QmitkExt/QmitkVtkLineProfileWidget.h b/Modules/QmitkExt/QmitkVtkLineProfileWidget.h index d9cb5f7bf9..229e5afd23 100644 --- a/Modules/QmitkExt/QmitkVtkLineProfileWidget.h +++ b/Modules/QmitkExt/QmitkVtkLineProfileWidget.h @@ -1,126 +1,126 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkVtkLineProfileWidget_H_ #define QmitkVtkLineProfileWidget_H_ #include "QmitkExtExports.h" #include "mitkImage.h" #include "mitkPlanarFigure.h" #include #include #include #include #include #include #include #include #include /** * \brief Widget for displaying intensity profiles of images along a given * path */ class QmitkExt_EXPORT QmitkVtkLineProfileWidget : public QDialog { Q_OBJECT public: - QmitkVtkLineProfileWidget( QWidget * /*parent = 0*/ ); + QmitkVtkLineProfileWidget( QWidget * parent = 0 ); virtual ~QmitkVtkLineProfileWidget(); typedef itk::ParametricPath< 3 >::Superclass PathType; typedef itk::PolyLineParametricPath< 3 > ParametricPathType; enum { PATH_MODE_DIRECT = 0, PATH_MODE_PLANARFIGURE }; /** \brief Set image from which to calculate derive the intensity profile. */ void SetImage(mitk::Image* image); /** \brief Set path for calculating intensity profile directly. */ void SetPath(const PathType* path); /** \brief Set planar figure for calculating intensity profile. */ void SetPlanarFigure(const mitk::PlanarFigure* planarFigure); /** \brief Set/Get mode which path to use */ void SetPathMode(unsigned int pathMode); /** \brief Set/Get mode which path to use */ unsigned int GetPathMode(); /** \brief Set/Get mode which path to use */ void SetPathModeToDirectPath(); /** \brief Set/Get mode which path to use */ void SetPathModeToPlanarFigure(); /** Fill the graphical widget with intensity profile from currently specified image/path . */ void UpdateItemModelFromPath(); /** \brief Clear the intensity profile (nothing is displayed). */ void ClearItemModel(); protected slots: protected: void CreatePathFromPlanarFigure(); void ComputePath(); vtkQtChartWidget *m_ChartWidget; vtkQtLineChart *m_LineChart; vtkQtBarChart *m_BarChart; std::vector m_VectorLineCharts; QStandardItemModel *m_ItemModel; mitk::Image::Pointer m_Image; mitk::PlanarFigure::ConstPointer m_PlanarFigure; unsigned int m_PathMode; // Path set explicitly by user PathType::ConstPointer m_Path; // Parametric path as generated from PlanarFigure ParametricPathType::Pointer m_ParametricPath; // Path derived either form user-specified path or from PlanarFigure-generated // path PathType::ConstPointer m_DerivedPath; }; #endif /* QmitkVtkLineProfileWidget_H_ */ diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui index 4de165ebba..867c866563 100644 --- a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui @@ -1,356 +1,281 @@ QmitkImageStatisticsViewControls true 0 0 465 475 Form - - + + 0 0 Mask: None 2 - + + + + Error Message + + + Qt::AutoText + + + + + + + Ignore zero-valued voxels + + + + Statistics - - + + + 0 + + + 0 + + + 0 + + 0 0 100 144 16777215 144 - - - 250 - 185 - - - - 1 - Qt::ScrollBarAlwaysOff Qt::ScrollBarAsNeeded true true true Qt::DotLine true false false 80 true 80 false true true false 20 20 false false Mean StdDev RMS Max Min N V (mm³) Component 1 + + + + Copy to Clipboard + + + - - - - true - - - - 0 - 0 - - - - - 447 - 16777215 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - -1 - - - -1 - - - 1 - - - - - - - - 150 - 160 - - - - Histogram - - - false - - - - 0 - - - 0 - - - - - true - - - - 0 - 0 - - - - - - - - - - - - - - - Intensity Profile - - - - 0 - - - 0 - - - - - - - - - - - - - - - - - Statistics to Clipboard - - - - - - - Histogram to Clipboard - - - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - + + + - 10 - 1 + 150 + 160 - - - - - - Error Message + + Histogram - - Qt::AutoText + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - Ignore zero-valued voxels + + false + + + 6 + + + 0 + + + 9 + + + 0 + + + 0 + + + + + 0 + + + + + + + + + Copy to Clipboard + + + + QmitkVtkHistogramWidget QWidget
QmitkVtkHistogramWidget.h
1
QmitkVtkLineProfileWidget QWidget
QmitkVtkLineProfileWidget.h
1