X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMainWindow.cxx;h=d210d118bf2ae5c71ed4e215964130ed02d065f4;hb=c2e0628b1d9f0940ac192ff3683c3ede5d01ceb3;hp=5bdc9780ccd73c693727a1b1dbf1872aa3d70ca7;hpb=6ae5074c8a8f2c27b21849f5cdf2cc0cfb369698;p=clitk.git diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 5bdc978..d210d11 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -491,15 +491,8 @@ void vvMainWindow::OpenVTKContour() //------------------------------------------------------------------------------ -void vvMainWindow::OpenDCStructContour() +void vvMainWindow::AddDCStructContour(int index, QString file) { - if (mSlicerManagers.size() > 0) { - QString Extensions = "Dicom Files ( *.dcm RS*)"; - Extensions += ";;All Files (*)"; - QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions); - if (file.isNull()) - return; - int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); vvMeshReader reader; reader.SetFilename(file.toStdString()); vvStructSelector selector; @@ -519,6 +512,19 @@ void vvMainWindow::OpenDCStructContour() AddContour(index,*i,selector.PropagationEnabled()); QApplication::restoreOverrideCursor(); } +} + +//------------------------------------------------------------------------------ +void vvMainWindow::OpenDCStructContour() +{ + if (mSlicerManagers.size() > 0) { + QString Extensions = "Dicom Files ( *.dcm RS*)"; + Extensions += ";;All Files (*)"; + QString file = QFileDialog::getOpenFileName(this,tr("Merge Images"),mInputPathName,Extensions); + if (file.isNull()) + return; + int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); + AddDCStructContour(index, file); } } //------------------------------------------------------------------------------ @@ -1273,20 +1279,29 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer matrix) +QString vvMainWindow::Get4x4MatrixDoubleAsString(vtkSmartPointer matrix, const int precision) { std::ostringstream strmatrix; + // Figure out the number of digits of the integer part of the largest absolute value + // for each column + unsigned width[4]; + for (unsigned int j = 0; j < 4; j++){ + double absmax = 0.; + for (unsigned int i = 0; i < 4; i++) + absmax = std::max(absmax, vnl_math_abs(matrix->GetElement(i, j))); + unsigned ndigits = (unsigned)std::max(0.,std::log10(absmax))+1; + width[j] = precision+ndigits+3; + } + + // Output with correct width, aligned to the right for (unsigned int i = 0; i < 4; i++) { for (unsigned int j = 0; j < 4; j++) { - strmatrix.flags(ios::showpos); - strmatrix.width(10); - strmatrix.precision(3); strmatrix.setf(ios::fixed,ios::floatfield); + strmatrix.precision(precision); strmatrix.fill(' '); - strmatrix << std::left << matrix->GetElement(i, j); - //strmatrix.width(10); - strmatrix << " "; + strmatrix.width(width[j]); + strmatrix << std::right << matrix->GetElement(i, j); } strmatrix << std::endl; }