Skip to content

Commit

Permalink
Merge pull request #16 from PauloCarvalhoRJ/Issues2017026
Browse files Browse the repository at this point in the history
Issues2017026
  • Loading branch information
PauloCarvalhoRJ authored Feb 27, 2017
2 parents e2525f7 + 0cc3019 commit 721b144
Show file tree
Hide file tree
Showing 25 changed files with 108 additions and 42 deletions.
4 changes: 3 additions & 1 deletion GammaRay.pro
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ FORMS += mainwindow.ui \
gslib/gslibparams/widgets/widgetgslibparvmodel.ui

# The application version
VERSION = 1.1.0
# Don't forget to update the Util::importSettingsFromPreviousVersion() method to
# enable the import of registry/user settings of previous versions.
VERSION = 1.2

# Define a preprocessor macro so we can get the application version in application code.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
Expand Down
2 changes: 1 addition & 1 deletion GammaRay.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.0, 2017-02-25T10:35:02. -->
<!-- Written by QtCreator 3.2.0, 2017-02-27T20:08:10. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
4 changes: 2 additions & 2 deletions distributionmodelingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
DistributionModelingDialog::DistributionModelingDialog(Attribute *at, QWidget *parent) :
QDialog(parent),
ui(new Ui::DistributionModelingDialog),
m_attribute( at ),
m_gpf_histsmth( nullptr )
m_gpf_histsmth( nullptr ),
m_attribute( at )
{
ui->setupUi(this);

Expand Down
4 changes: 2 additions & 2 deletions domain/cartesiangrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class CartesianGrid : public DataFile
//DataFile interface
public:
/** Cartesian grids never have declustering weights. At least they are not supposed to be. */
bool isWeight( Attribute* at ) { return false; }
bool isWeight( Attribute* /*at*/ ) { return false; }
/** Cartesian grids never have declustering weights. At least they are not supposed to be. */
virtual Attribute* getVariableOfWeight( Attribute* at ) { return nullptr; }
virtual Attribute* getVariableOfWeight( Attribute* /*at*/ ) { return nullptr; }

// File interface
public:
Expand Down
6 changes: 3 additions & 3 deletions domain/datafile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ void DataFile::updatePropertyCollection()
/*if( index_in_file != this->_x_field_index &&
index_in_file != this->_y_field_index &&
index_in_file != this->_z_field_index ){*/
Attribute *at = new Attribute( fields[i], index_in_file );
Attribute *at = new Attribute( fields[i].trimmed(), index_in_file );
if( isWeight( at ) ){ //if attribute is a weight, it is represented as a child object
//of the variable it refers to
Attribute* variable = this->getVariableOfWeight( at );
if( ! variable )
Application::instance()->logError("Error in variable-weight assignment.");
else{
delete at; //it is not a generic Attribute
Weight* wgt = new Weight( fields[i], index_in_file, variable );
Weight* wgt = new Weight( fields[i].trimmed(), index_in_file, variable );
variable->addChild( wgt );
}
} else if( isNormal( at ) ){ //if attribute is a normal transform of another variable,
Expand All @@ -243,7 +243,7 @@ void DataFile::updatePropertyCollection()
Application::instance()->logError("Error in variable-normal variable assignment.");
else{
delete at; //it is not a generic Attribute
NormalVariable* ns_var = new NormalVariable( fields[i], index_in_file, variable );
NormalVariable* ns_var = new NormalVariable( fields[i].trimmed(), index_in_file, variable );
variable->addChild( ns_var );
}
} else { //common variables are direct children of files
Expand Down
2 changes: 1 addition & 1 deletion domain/distribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void Distribution::updateColumnCollection()
QStringList fields = Util::getFieldNames( this->_path );
for( int i = 0; i < fields.size(); ++i ){
int index_in_file = i + 1;
DistributionColumn *dc = new DistributionColumn( fields[i], index_in_file );
DistributionColumn *dc = new DistributionColumn( fields[i].trimmed(), index_in_file );
this->_children.push_back( dc );
dc->setParent( this );
}
Expand Down
4 changes: 2 additions & 2 deletions domain/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ int Project::rowCount(const QModelIndex &parent) const
parentItem = static_cast<ProjectComponent*>(parent.internalPointer());
return parentItem->getChildCount();
}
int Project::columnCount(const QModelIndex &parent) const
int Project::columnCount(const QModelIndex &/*parent*/) const
{
return 1;
}
Expand All @@ -551,7 +551,7 @@ Qt::ItemFlags Project::flags(const QModelIndex &index) const
return 0;
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
QVariant Project::headerData(int section, Qt::Orientation orientation, int role) const
QVariant Project::headerData(int /*section*/, Qt::Orientation /*orientation*/, int /*role*/) const
{
//if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
// return rootItem->data(section);
Expand Down
2 changes: 1 addition & 1 deletion domain/projectcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int ProjectComponent::getChildIndex(ProjectComponent *child)
return -1;
}

void ProjectComponent::save(QTextStream *txt_stream)
void ProjectComponent::save(QTextStream */*txt_stream*/)
{

}
Expand Down
12 changes: 10 additions & 2 deletions gs/ghostscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ Ghostscript::Ghostscript()
{
}

QString Ghostscript::getGsProgramName()
QString Ghostscript::getGsProgramName(QDir &bin_dir )
{
#ifdef Q_OS_WIN
//GhostScript Windows executable can be gswin64c.exe or gswin32c.exe.
//Try gswin64c.exe preferentially.
QFile gsExePath( bin_dir.filePath( "gswin64c.exe" ) );
if( gsExePath.exists() ){
Application::instance()->logInfo( "GhostScript 64-bit found." );
return "gswin64c.exe";
}
Application::instance()->logInfo( "Trying GhostScript 32-bit." );
return "gswin32c.exe";
#else
return "gs";
Expand All @@ -24,7 +32,7 @@ void Ghostscript::makePNG(const QString input_ps_file_path, const QString output
QProcess cmd;
QDir gs_home = QDir(Application::instance()->getGhostscriptPathSetting());
QDir gs_bin = QDir(gs_home.filePath("bin"));
QString gs_program = gs_bin.filePath( Ghostscript::getGsProgramName() );
QString gs_program = gs_bin.filePath( Ghostscript::getGsProgramName( gs_bin ) );

gs_program = QString("\"").append(gs_program).append("\"");

Expand Down
5 changes: 4 additions & 1 deletion gs/ghostscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define GHOSTSCRIPT_H
#include <QString>

class QDir;

/**
* @brief The Ghostscript class is the hub for interfacing with Ghostscript programs.
Expand All @@ -14,8 +15,10 @@ class Ghostscript
/**
* Returns the name of the Ghostscript parser program file name. It is OS-dependent.
* see http://svn.ghostscript.com/ghostscript/branches/gs-db/doc/Use.htm#Help_command
* @param bin_dir A QDir object refering the bin directory in the GhostScript installation,
* e.g. C:\Program Files (x86)\gs\gs8.53\bin
*/
static QString getGsProgramName();
static QString getGsProgramName(QDir &bin_dir);

/**
* Calls Ghostscript parser to create a PNG image file from the given PS file.
Expand Down
2 changes: 1 addition & 1 deletion gslib/gslib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void GSLib::onProgramOutput()
Application::instance()->logInfo( stdout_text );
}

void GSLib::onProgramFinished(int exit_code, QProcess::ExitStatus exit_status)
void GSLib::onProgramFinished(int exit_code, QProcess::ExitStatus /*exit_status*/)
{
Application::instance()->logInfo( QString("GSLib::onProgramFinished(): Program terminated with exit code = ").append( QString::number(exit_code) ) );
emit programFinished();
Expand Down
2 changes: 1 addition & 1 deletion gslib/gslibparams/gslibparmultivaluedvariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void GSLibParMultiValuedVariable::assureLoop(uint n)

void GSLibParMultiValuedVariable::assure(uint n)
{
if( _parameters.size() >= n)
if( _parameters.size() >= (int)n)
return;
if( getAllowedParameterTypeName() == "double" ){
assureLoop<GSLibParDouble>( n );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ void WidgetGSLibParMultiValuedVariable::updateValue(QList<GSLibParVarWeight *> *
QListIterator<GSLibParVarWeight *> it_par( *param );
QListIterator<QWidget *> it_wid( this->_widgets );
//first, the variables indexes...
int count = 0;
while( it_wid.hasNext() ){
GSLibParVarWeight *var_wgt = it_par.next();
WidgetGSLibParInt *widget = (WidgetGSLibParInt *)it_wid.next();
Expand Down
2 changes: 1 addition & 1 deletion gslib/workerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void WorkerThread::onProgramOutput()
Application::instance()->logInfo( stdout_text );
}

void WorkerThread::onProgramFinished(int exit_code, QProcess::ExitStatus exit_status)
void WorkerThread::onProgramFinished(int exit_code, QProcess::ExitStatus /*exit_status*/)
{
Application::instance()->logInfo( QString("WorkerThread::onProgramFinished(): Program terminated with exit code = ").append( QString::number(exit_code) ) );
delete m_process;
Expand Down
2 changes: 1 addition & 1 deletion indicatorkrigingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void IndicatorKrigingDialog::onConfigureAndRun()

//show the ik3d parameters
GSLibParametersDialog gsd( m_gpf_ik3d, this );
int result = gsd.exec();
/*int result =*/ gsd.exec();

// //if user didn't cancel the dialog
// if( result == QDialog::Accepted ){
Expand Down
5 changes: 3 additions & 2 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,9 @@ void MainWindow::onProjectContextMenu(const QPoint &mouse_location)

void MainWindow::onAddDataFile()
{
QString file = QFileDialog::getOpenFileName(this, "select data file");
QString file = QFileDialog::getOpenFileName(this, "select data file", Util::getLastBrowsedDirectory());
if( ! file.isEmpty() ){
Util::saveLastBrowsedDirectoryOfFile( file );
DataFileDialog dfd(this, file);
dfd.exec();
if( dfd.result() == QDialog::Accepted ){
Expand Down Expand Up @@ -1323,7 +1324,7 @@ void MainWindow::showSetup()

void MainWindow::newProject()
{
QString dir = QFileDialog::getExistingDirectory(this, "select project directory");
QString dir = QFileDialog::getExistingDirectory(this, "Select project directory", QDir::homePath());
if( ! dir.isEmpty() ){
Application::instance()->openProject( dir );
this->setCurrentMRU( dir );
Expand Down
6 changes: 6 additions & 0 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,17 @@
</property>
</action>
<action name="actionIndicatorKrigingContinuous">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Indicator Kriging (continuous)</string>
</property>
</action>
<action name="actionIndicatorKrigingCategorical">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Indicator Kriging (categorical)</string>
</property>
Expand Down
5 changes: 3 additions & 2 deletions setupdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "ui_setupdialog.h"
#include <QFileDialog>
#include "domain/application.h"
#include "util.h"

SetupDialog::SetupDialog(QWidget *parent) :
QDialog(parent),
Expand All @@ -21,14 +22,14 @@ SetupDialog::~SetupDialog()

void SetupDialog::showGSLibPathSearch()
{
QString dir = QFileDialog::getExistingDirectory(this, "select GSLib executables location");
QString dir = QFileDialog::getExistingDirectory(this, "select GSLib executables location", Util::getProgramInstallDir());
if( ! dir.isEmpty() )
ui->txtGSLibPath->setText( dir );
}

void SetupDialog::showGSPathSearch()
{
QString dir = QFileDialog::getExistingDirectory(this, "select Ghostscript installation directory");
QString dir = QFileDialog::getExistingDirectory(this, "select Ghostscript installation directory", Util::getProgramInstallDir());
if( ! dir.isEmpty() )
ui->txtGSPath->setText( dir );
}
Expand Down
29 changes: 27 additions & 2 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ QStringList Util::getFieldNames(const QString gslib_data_file_path)
file.open( QFile::ReadOnly | QFile::Text );
QTextStream in(&file);
int n_vars = 0;
bool ok = false;
int var_count = 0;
for (int i = 0; !in.atEnd(); ++i)
{
Expand Down Expand Up @@ -666,7 +665,7 @@ void Util::importSettingsFromPreviousVersion()
QSettings currentSettings;
//The list of previous versions (order from latest to oldest version is advised)
QStringList previousVersions;
previousVersions << "1.0.1" << "1.0";
previousVersions << "1.1.0" << "1.0.1" << "1.0";
//Iterate through the list of previous versions
QList<QString>::iterator itVersion = previousVersions.begin();
for(; itVersion != previousVersions.end(); ++itVersion){
Expand Down Expand Up @@ -696,3 +695,29 @@ DisplayResolution Util::getDisplayResolutionClass()
else
return DisplayResolution::HIGH_DPI;
}

QString Util::getLastBrowsedDirectory()
{
QSettings settings;
return settings.value( "LastBrowsedDir" ).toString();
}

void Util::saveLastBrowsedDirectory(QString dir_path )
{
QSettings settings;
settings.setValue( "LastBrowsedDir", dir_path );
}

void Util::saveLastBrowsedDirectoryOfFile(QString file_path)
{
Util::saveLastBrowsedDirectory( QFileInfo( file_path ).dir().absolutePath() );
}

QString Util::getProgramInstallDir()
{
#ifdef Q_OS_WIN
return QString( getenv("PROGRAMFILES") );
#else
return QString("/usr");
#endif
}
21 changes: 21 additions & 0 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ class Util
*/
static DisplayResolution getDisplayResolutionClass();

/**
* Return the last browsed directory in a file dialog.
*/
static QString getLastBrowsedDirectory();

/**
* Saves the last browsed directory in a file dialog to registry/home settings.
* The parameter must be a directory path.
*/
static void saveLastBrowsedDirectory(QString dir_path);

/**
* Saves the last browsed directory in a file dialog to registry/home settings.
* The parameter must be a file path.
*/
static void saveLastBrowsedDirectoryOfFile(QString file_path);

/**
* Returns the PROGRAMFILES environmental variable in Windows or /usr otherwise.
*/
static QString getProgramInstallDir();
};

#endif // UTIL_H
22 changes: 11 additions & 11 deletions variogramanalysisdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void VariogramAnalysisDialog::onOpenVarMapParameters()
m_gpf_varmap->getParameter<GSLibParFile*>(7)->_path = Application::instance()->getProject()->generateUniqueTmpFilePath("out");
}
//construct the parameter dialog so the user can adjust other settings before running varmap
GSLibParametersDialog *gslibpardiag = new GSLibParametersDialog( m_gpf_varmap );
int result = gslibpardiag->exec();
GSLibParametersDialog gslibpardiag( m_gpf_varmap );
int result = gslibpardiag.exec();
if( result == QDialog::Accepted ){
//Generate the parameter file
QString par_file_path = Application::instance()->getProject()->generateUniqueTmpFilePath("par");
Expand Down Expand Up @@ -418,9 +418,9 @@ void VariogramAnalysisDialog::onOpenVariogramModelParamateres()
}

//these are useful to compute lag, azimuth and dip from gam regular grid parameters
double xsize;
double ysize;
double zsize;
double xsize = 1.0;
double ysize = 1.0;
double zsize = 1.0;
if( m_gpf_gam )
{
GSLibParGrid* par5 = m_gpf_gam->getParameter<GSLibParGrid*>(5);
Expand Down Expand Up @@ -585,8 +585,8 @@ void VariogramAnalysisDialog::onOpenVariogramModelParamateres()
}

//show the parameter dialog so the user can review and adjust other settings before running vmodel
GSLibParametersDialog *gslibpardiag = new GSLibParametersDialog( m_gpf_vmodel );
int result = gslibpardiag->exec();
GSLibParametersDialog gslibpardiag( m_gpf_vmodel );
int result = gslibpardiag.exec();
if( result == QDialog::Accepted ){
//Generate the parameter file
QString par_file_path = Application::instance()->getProject()->generateUniqueTmpFilePath("par");
Expand Down Expand Up @@ -708,8 +708,8 @@ void VariogramAnalysisDialog::onGamv()
//--------------------------------------------------------------------------------

//show the parameter dialog so the user can adjust other settings before running gamv
GSLibParametersDialog *gslibpardiag = new GSLibParametersDialog( m_gpf_gamv );
int result = gslibpardiag->exec();
GSLibParametersDialog gslibpardiag( m_gpf_gamv );
int result = gslibpardiag.exec();
if( result == QDialog::Accepted ){
//Generate the parameter file
QString par_file_path = Application::instance()->getProject()->generateUniqueTmpFilePath("par");
Expand Down Expand Up @@ -947,8 +947,8 @@ void VariogramAnalysisDialog::onGam()
//--------------------------------------------------------------------------------

//show the parameter dialog so the user can adjust other settings before running gam
GSLibParametersDialog *gslibpardiag = new GSLibParametersDialog( m_gpf_gam );
int result = gslibpardiag->exec();
GSLibParametersDialog gslibpardiag( m_gpf_gam );
int result = gslibpardiag.exec();
if( result == QDialog::Accepted ){
//Generate the parameter file
QString par_file_path = Application::instance()->getProject()->generateUniqueTmpFilePath("par");
Expand Down
Loading

0 comments on commit 721b144

Please sign in to comment.