Skip to content

Commit

Permalink
Moved SPV writer functions in new SPVWriter class
Browse files Browse the repository at this point in the history
Moved the SPV file writting functions into their own class - out of the SPVreader class. This is to 1) make it easy to find the SPV writing code; and 2) remove all writting code from a class name "reader"! A new class call StaticFunctions has been created to hold helper functions that are required in multiple places but are self contained.
  • Loading branch information
alanspencer committed Oct 28, 2018
1 parent dbe6e5a commit 8ea4ce7
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 358 deletions.
8 changes: 6 additions & 2 deletions SPIERSview/SPIERSview.pro
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ SOURCES += src/main.cpp \
src/vaxmlobject.cpp \
src/isosurface.cpp \
src/scalarfieldlayer.cpp \
src/fullscreenwindow.cpp
src/fullscreenwindow.cpp \
src/spvwriter.cpp \
src/staticfunctions.cpp

HEADERS += src/mainwindow.h \
src/darkstyletheme.h \
Expand All @@ -284,7 +286,9 @@ HEADERS += src/mainwindow.h \
src/vaxmlobject.h \
src/isosurface.h \
src/scalarfieldlayer.h \
src/fullscreenwindow.h
src/fullscreenwindow.h \
src/spvwriter.h \
src/staticfunctions.h

FORMS += ui/mainwindow.ui \
ui/movetogroup.ui \
Expand Down
46 changes: 29 additions & 17 deletions SPIERSview/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "aboutdialog.h"
#include "globals.h"
#include "spvreader.h"
#include "spvwriter.h"
#include "../SPIERScommon/netmodule.h"
#include <vtkProperty2D.h>
#include "movetogroup.h"
Expand Down Expand Up @@ -2084,12 +2085,16 @@ void MainWindow::on_actionSave_Changes_triggered()
if (!containsPresurfaced && containsNonPresurfaced) flag = false;
if (containsPresurfaced && containsNonPresurfaced)
{
if (QMessageBox::question(this, "Ambiguous save", "This file contains items with both presurfaced and compact data. Proceeding will save as compact - is this OK?",
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return;
if (QMessageBox::question(
this,
"Ambiguous save",
"This file contains items with both presurfaced and compact data. Proceeding will save as compact - is this OK?",
QMessageBox::Yes | QMessageBox::No
) != QMessageBox::Yes) return;
}

SPVreader r;
r.WriteFile(flag);
SPVWriter w;
w.writeFile(flag);
isFileDirty = false;
}

Expand All @@ -2098,25 +2103,28 @@ void MainWindow::on_actionSave_Changes_triggered()
*/
void MainWindow::on_actionSave_As_triggered()
{
//First - check no pre v5 files in here

QString cpath;
cpath = fname;
cpath = fname.left(qMax(fname.lastIndexOf("\\"), fname.lastIndexOf("/")));

FilterKeys = false;

QString f = QFileDialog::getSaveFileName(this, tr("Save File (Compact Mode)"),
cpath,
tr("SPV files (*.spv)"));
QString f = QFileDialog::getSaveFileName(
this,
tr("Save File (Compact Mode)"),
cpath,
tr("SPV files (*.spv)")
);
FilterKeys = true;

if (f.isEmpty()) return;
fname = f;
QString shortfname = "SPIERSview - " + fname.mid(qMax(fname.lastIndexOf("\\"), fname.lastIndexOf("/")) + 1);
this->setWindowTitle(shortfname);
SPVreader r;
r.WriteFile(false);

SPVWriter w;
w.writeFile(false);

isFileDirty = false;
}

Expand All @@ -2128,20 +2136,24 @@ void MainWindow::on_actionSave_Presurfaced_triggered()
QString cpath;
cpath = fname;
cpath = fname.left(qMax(fname.lastIndexOf("\\"), fname.lastIndexOf("/")));
FilterKeys = false;

QString f = QFileDialog::getSaveFileName(this, tr("Save File (Presurfaced Mode)"),
cpath,
tr("SPV files (*.spv)"));
FilterKeys = false;
QString f = QFileDialog::getSaveFileName(
this,
tr("Save File (Presurfaced Mode)"),
cpath,
tr("SPV files (*.spv)")
);
FilterKeys = true;

if (f.isEmpty()) return;
fname = f;
QString shortfname = "SPIERSview - " + fname.mid(qMax(fname.lastIndexOf("\\"), fname.lastIndexOf("/")) + 1);
this->setWindowTitle(shortfname);

SPVreader r;
r.WriteFile(true); //with polydata structures tagged on
SPVWriter w;
w.writeFile(true); //with polydata structures tagged on

containsPresurfaced = true;
containsNonPresurfaced = false;
isFileDirty = false;
Expand Down

0 comments on commit 8ea4ce7

Please sign in to comment.