Skip to content

Commit 4f992cd

Browse files
Merge pull request #40 from PauloCarvalhoRJ/Issues20170325
Issues20170325
2 parents 80b2aa6 + 0566b79 commit 4f992cd

20 files changed

+297
-44
lines changed

GammaRay.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ INCLUDEPATH += $$BOOST_INSTALL
290290
# The application version
291291
# Don't forget to update the Util::importSettingsFromPreviousVersion() method to
292292
# enable the import of registry/user settings of previous versions.
293-
VERSION = 1.3.1
293+
VERSION = 1.4
294294

295295
# Define a preprocessor macro so we can get the application version in application code.
296296
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

creategriddialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ void CreateGridDialog::runGammaBar()
106106
par0->getParameter<GSLibParDouble*>(2)->_value = m_par->_specs_z->getParameter<GSLibParDouble*>(2)->_value;
107107
//leave block discretization as one
108108
GSLibParMultiValuedFixed *par1 = gpar.getParameter<GSLibParMultiValuedFixed*>(1);
109-
par1->getParameter<GSLibParUInt*>(0)->_value = 1;
110-
par1->getParameter<GSLibParUInt*>(1)->_value = 1;
111-
par1->getParameter<GSLibParUInt*>(2)->_value = 1;
109+
par1->getParameter<GSLibParUInt*>(0)->_value = ui->txtBlkDiscrX->text().toInt();
110+
par1->getParameter<GSLibParUInt*>(1)->_value = ui->txtBlkDiscrY->text().toInt();
111+
par1->getParameter<GSLibParUInt*>(2)->_value = ui->txtBlkDiscrZ->text().toInt();
112112

113113
//Generate the parameter file
114114
//NOTE: due to a buggy input file setting in gammabar, the parameter file must be generated

creategriddialog.ui

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>663</width>
10-
<height>404</height>
9+
<width>669</width>
10+
<height>433</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -17,7 +17,7 @@
1717
<item>
1818
<widget class="QLabel" name="label">
1919
<property name="text">
20-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This dialog helps the user to create a new cartesian grid file adequate for estimation or simulation of variables in a samples file (point set). It does so by suggesting grid geometry from the point set bounding box and allowing the user to choose a grid resolution with an appropriate inter-cell variance given a variogram model (gammabar).&lt;/p&gt;&lt;p&gt;The created grid contains a binary variable that results in a checkerboard pattern so the user can easily assess the generated geometry in a plot window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
20+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This dialog helps the user to create a new cartesian grid file adequate for estimation or simulation of variables in a samples file (point set). It does so by suggesting grid geometry from the point set bounding box and allowing the user to choose a grid resolution with an appropriate inter-cell variance given a variogram model and an intended block discretization for block kriging.&lt;/p&gt;&lt;p&gt;The created grid contains a binary variable that results in a checkerboard pattern so the user can easily assess the generated geometry in a plot window.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
2121
</property>
2222
<property name="alignment">
2323
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
@@ -146,6 +146,46 @@
146146
</layout>
147147
</widget>
148148
</item>
149+
<item>
150+
<widget class="QFrame" name="frame_6">
151+
<property name="frameShape">
152+
<enum>QFrame::StyledPanel</enum>
153+
</property>
154+
<property name="frameShadow">
155+
<enum>QFrame::Raised</enum>
156+
</property>
157+
<layout class="QHBoxLayout" name="horizontalLayout_5">
158+
<item>
159+
<widget class="QLabel" name="label_2">
160+
<property name="text">
161+
<string>Block discretization (X, Y, Z):</string>
162+
</property>
163+
</widget>
164+
</item>
165+
<item>
166+
<widget class="QLineEdit" name="txtBlkDiscrX">
167+
<property name="text">
168+
<string>1</string>
169+
</property>
170+
</widget>
171+
</item>
172+
<item>
173+
<widget class="QLineEdit" name="txtBlkDiscrY">
174+
<property name="text">
175+
<string>1</string>
176+
</property>
177+
</widget>
178+
</item>
179+
<item>
180+
<widget class="QLineEdit" name="txtBlkDiscrZ">
181+
<property name="text">
182+
<string>1</string>
183+
</property>
184+
</widget>
185+
</item>
186+
</layout>
187+
</widget>
188+
</item>
149189
<item>
150190
<widget class="QLabel" name="lblVarianceLoss">
151191
<property name="text">

docs/GammaRayManual.docx

-12.5 KB
Binary file not shown.

domain/cartesiangrid.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ void CartesianGrid::updateMetaDataFile()
196196
QTextStream out(&file);
197197
out << APP_NAME << " metadata file. This file is generated automatically. Do not edit this file.\n";
198198
out << "version=" << APP_VERSION << '\n';
199-
out << "X0:" << this->_x0 << '\n';
200-
out << "Y0:" << this->_y0 << '\n';
201-
out << "Z0:" << this->_z0 << '\n';
199+
out << "X0:" << QString::number( this->_x0, 'g', 12) << '\n';
200+
out << "Y0:" << QString::number( this->_y0, 'g', 12) << '\n';
201+
out << "Z0:" << QString::number( this->_z0, 'g', 12) << '\n';
202202
out << "NX:" << this->_nx << '\n';
203203
out << "NY:" << this->_ny << '\n';
204204
out << "NZ:" << this->_nz << '\n';

domain/datafile.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "domain/univariatecategoryclassification.h"
1616
#include "domain/categorydefinition.h"
1717
#include "project.h"
18+
#include "objectgroup.h"
1819

1920
DataFile::DataFile(QString path) : File( path )
2021
{
@@ -210,6 +211,20 @@ bool DataFile::isCategorical(Attribute *at)
210211
return false;
211212
}
212213

214+
CategoryDefinition *DataFile::getCategoryDefinition(Attribute *at)
215+
{
216+
uint index_in_GEOEAS_file = this->getFieldGEOEASIndex( at->getName() );
217+
QList< QPair<uint, QString> >::iterator it = _categorical_attributes.begin();
218+
for(; it != _categorical_attributes.end(); ++it){
219+
if( (*it).first == index_in_GEOEAS_file ){
220+
QString cd_file_name = (*it).second;
221+
return (CategoryDefinition*)Application::instance()->
222+
getProject()->getResourcesGroup()->getChildByName( cd_file_name );
223+
}
224+
}
225+
return nullptr;
226+
}
227+
213228
Attribute *DataFile::getVariableOfNScoreVar(Attribute *at)
214229
{
215230
uint ns_var_index_in_GEOEAS_file = this->getFieldGEOEASIndex( at->getName() );

domain/datafile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ class DataFile : public File
9999
*/
100100
bool isCategorical( Attribute* at );
101101

102+
/**
103+
* Returns the category definition associated to the given attribute, supposedly categorical.
104+
* Returns nullptr if none is found, the attribute is not categorical or does not belong to this data file.
105+
*/
106+
CategoryDefinition *getCategoryDefinition( Attribute* at );
107+
102108
/**
103109
* Returns the variable associated with the declustering weight attribute.
104110
*/

gslib/gslibparameterfiles/gslibparameterfile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,9 +2066,9 @@ void GSLibParameterFile::generateParameterFileTemplates(const QString directory_
20662066
out << "<double> <double> <double> -maximum search radii\n";
20672067
out << "<double> <double> <double> -angles for search ellipsoid\n";
20682068
out << "<option [0:SK][1:OK][2:LVM][3:KED]> <double> -0=SK,1=OK,2=non-st SK,3=exdrift;mean for SK\n";
2069-
out << "<option [0:no][1:yes]> <option [0:no][1:yes]> <option [0:no][1:yes]> " << \
2070-
"<option [0:no][1:yes]> <option [0:no][1:yes]> <option [0:no][1:yes]> " << \
2071-
"<option [0:no][1:yes]> <option [0:no][1:yes]> <option [0:no][1:yes]> -drift: x,y,z,xx,yy,zz,xy,xz,zy\n";
2069+
out << "<option [0: ][1: x ]> <option [0: ][1: y ]> <option [0: ][1: z ]> " << \
2070+
"<option [0: ][1:x^2]> <option [0: ][1:y^2]> <option [0: ][1:z^2]> " << \
2071+
"<option [0: ][1: xy]> <option [0: ][1: xz]> <option [0: ][1: zy]> -drift: x,y,z,xx,yy,zz,xy,xz,zy\n";
20722072
out << "<option [0:variable][1:trend]> -estimate what\n";
20732073
out << "<file> -gridded file with drift/mean\n";
20742074
out << "<uint> - column number in gridded file\n";

gslib/gslibparametersdialog.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,14 @@ GSLibParametersDialog::GSLibParametersDialog(GSLibParameterFile *gpf, QWidget *p
2323
//-------------------end of GUI construction-------------------------------------------------------
2424

2525
connect( this, SIGNAL( accepted() ), SLOT( onDialogAccepted() ) );
26+
connect( this, SIGNAL( rejected() ), SLOT( onDialogRejected() ) );
2627

2728
//restore the dialog settings from registry/user home
2829
recallSettings();
2930
}
3031

3132
GSLibParametersDialog::~GSLibParametersDialog()
3233
{
33-
//save the dialog settings to registry/user home
34-
rememberSettings();
35-
//-----------------------------------------------------------------------------------
36-
//this code block detaches the parameter-owned widgets
37-
//from their Qt object parents, preventing their undue deletion
38-
//upon dialog destruction. Such widgets can only be deleted when
39-
//the parent GSLibParType object is destroyed, othwerwise the program crashes
40-
//when this dialog is called a second time for the same GSLibParameterFile object .
41-
//A call to QLayout::addWidget(QWidget*) automatically sets QLayout as QWidget's parent.
42-
int cparams = this->_gpf->getParameterCount();
43-
for(int i = 0; i < cparams; ++i){
44-
GSLibParType* par = this->_gpf->getParameter<GSLibParType*>( i );
45-
par->detachFromGUI( ui->frmWidgets->layout() );
46-
}
47-
//-----------------------------------------------------------------------------------
4834
delete ui;
4935
}
5036

@@ -110,6 +96,15 @@ void GSLibParametersDialog::recallSettings()
11096
qsettings.endGroup();
11197
}
11298

99+
void GSLibParametersDialog::detachParameterWidgets()
100+
{
101+
int cparams = this->_gpf->getParameterCount();
102+
for(int i = 0; i < cparams; ++i){
103+
GSLibParType* par = this->_gpf->getParameter<GSLibParType*>( i );
104+
par->detachFromGUI( ui->frmWidgets->layout() );
105+
}
106+
}
107+
113108
void GSLibParametersDialog::onDialogAccepted()
114109
{
115110
//update the GSLib parameter object with the user input values in the associated widgets.
@@ -122,6 +117,16 @@ void GSLibParametersDialog::onDialogAccepted()
122117
append("\" are not editable or the parameter update failed.") );
123118
}
124119
}
120+
detachParameterWidgets();
121+
//save the dialog settings to registry/user home
122+
rememberSettings();
123+
}
124+
125+
void GSLibParametersDialog::onDialogRejected()
126+
{
127+
detachParameterWidgets();
128+
//save the dialog settings to registry/user home
129+
rememberSettings();
125130
}
126131

127132
void GSLibParametersDialog::someUintWidgetValueChanged(uint value, QString parameter_name)

gslib/gslibparametersdialog.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,19 @@ class GSLibParametersDialog : public QDialog
4343
*/
4444
void recallSettings();
4545

46+
/** Detaches the parameter-owned widgets
47+
* from their Qt object parents, preventing their undue deletion
48+
* upon dialog destruction. Such widgets can only be deleted when
49+
* the parent GSLibParType object is destroyed, othwerwise the program crashes
50+
* when this dialog is called a second time for the same GSLibParameterFile object .
51+
* A call to QLayout::addWidget(QWidget*) automatically sets QLayout as QWidget's parent.
52+
* This function is usually called when the dialog is about to close.
53+
*/
54+
void detachParameterWidgets();
55+
4656
private slots:
4757
void onDialogAccepted();
58+
void onDialogRejected();
4859
/**
4960
* This slot is called when an WigetGSLibParUint widget's value changed.
5061
* Not all of such widgets trigger this slot. It usually happens for

0 commit comments

Comments
 (0)