From 2dd83f421dbb035a94189d0e7f9b662aa99e16de Mon Sep 17 00:00:00 2001 From: Ajay Limaye Date: Mon, 26 Nov 2018 18:23:58 +1100 Subject: [PATCH] Drishti-2.6.5 --- tools/paint/drishtipaint.ui | 2 +- tools/paint/volumefilemanager.cpp | 14 ++++++++------ tools/paint/volumefilemanager.h | 2 +- tools/paint/volumemask.cpp | 32 ++++++++++++++++++------------- tools/paint/volumemask.h | 1 + 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/tools/paint/drishtipaint.ui b/tools/paint/drishtipaint.ui index f73cc109..13586101 100644 --- a/tools/paint/drishtipaint.ui +++ b/tools/paint/drishtipaint.ui @@ -983,7 +983,7 @@ - Export .mask + Export .rawmask diff --git a/tools/paint/volumefilemanager.cpp b/tools/paint/volumefilemanager.cpp index 6966fbdf..08c7dfee 100644 --- a/tools/paint/volumefilemanager.cpp +++ b/tools/paint/volumefilemanager.cpp @@ -1177,23 +1177,23 @@ VolumeFileManager::saveMemFile() } -void +QString VolumeFileManager::exportMask() { QString flnm; flnm = QFileDialog::getSaveFileName(0, - "Export to .mask file", + "Export to .rawmask file", Global::previousDirectory(), - "Mask Files (*.mask)", + "Mask Files (*.rawmask)", 0, QFileDialog::DontUseNativeDialog); if (flnm.isEmpty()) - return; + return QString(); - if (!StaticFunctions::checkExtension(flnm, ".mask")) - flnm += ".mask"; + if (!StaticFunctions::checkExtension(flnm, ".rawmask")) + flnm += ".rawmask"; uchar vt; if (m_voxelType == _UChar) vt = 0; // unsigned byte @@ -1232,6 +1232,8 @@ VolumeFileManager::exportMask() m_qfile.close(); progress.setValue(100); + + return flnm; } void diff --git a/tools/paint/volumefilemanager.h b/tools/paint/volumefilemanager.h index cfbc122b..19d44869 100644 --- a/tools/paint/volumefilemanager.h +++ b/tools/paint/volumefilemanager.h @@ -36,7 +36,7 @@ class VolumeFileManager : public QObject QString fileName(); bool exists(); - void exportMask(); + QString exportMask(); void checkPoint(); bool loadCheckPoint(); bool loadCheckPoint(QString); diff --git a/tools/paint/volumemask.cpp b/tools/paint/volumemask.cpp index 8e09ea3b..5fe8871a 100644 --- a/tools/paint/volumemask.cpp +++ b/tools/paint/volumemask.cpp @@ -31,7 +31,9 @@ VolumeMask::reset() void VolumeMask::exportMask() { - m_maskFileManager.exportMask(); + QString maskfile = m_maskFileManager.exportMask(); + if (!maskfile.isEmpty()) + createPvlNc(maskfile); } void VolumeMask::checkPoint() @@ -184,13 +186,8 @@ VolumeMask::setGridSize(int d, int w, int h, int slabsize) } void -VolumeMask::checkMaskFile() +VolumeMask::createPvlNc(QString maskfile) { - // create mask file if not present - if (!m_maskFileManager.exists()) - { - m_maskFileManager.createFile(true, true); - QDomDocument doc("Drishti_Header"); QDomElement topElement = doc.createElement("PvlDotNcFileHeader"); @@ -206,9 +203,9 @@ VolumeMask::checkMaskFile() { QDomElement de0 = doc.createElement("pvlnames"); QDomText tn0; - QFileInfo fileInfo(m_maskfile); + QFileInfo fileInfo(maskfile); QDir direc = fileInfo.absoluteDir(); - QString vstr = direc.relativeFilePath(m_maskfile); + QString vstr = direc.relativeFilePath(maskfile); tn0 = doc.createTextNode(vstr); de0.appendChild(tn0); topElement.appendChild(de0); @@ -270,8 +267,7 @@ VolumeMask::checkMaskFile() topElement.appendChild(de0); } - QString pvlfile = m_maskfile; - //pvlfile.chop(4); + QString pvlfile = maskfile; pvlfile += ".pvl.nc"; QFile pf(pvlfile.toLatin1().data()); if (pf.open(QIODevice::WriteOnly)) @@ -279,8 +275,18 @@ VolumeMask::checkMaskFile() QTextStream out(&pf); doc.save(out, 2); pf.close(); - } - + } +} + +void +VolumeMask::checkMaskFile() +{ + // create mask file if not present + if (!m_maskFileManager.exists()) + { + m_maskFileManager.createFile(true, true); + + createPvlNc(m_maskfile); } } diff --git a/tools/paint/volumemask.h b/tools/paint/volumemask.h index 04102fc0..3469e85f 100644 --- a/tools/paint/volumemask.h +++ b/tools/paint/volumemask.h @@ -54,6 +54,7 @@ class VolumeMask : public QObject uchar* m_maskslice; void checkMaskFile(); + void createPvlNc(QString); }; #endif