solved some zmax zmin problems with gui

This commit is contained in:
Dhanya Maliakal 2015-07-27 18:53:16 +02:00
parent 2d8ee637dc
commit b1a9689caf
4 changed files with 70 additions and 25 deletions

View File

@ -136,6 +136,9 @@ private slots:
/** Enables the range of the z axis */
void EnableZRange();
/** Return true if valid */
bool CheckZRange(QString value);
/** Set Plot to none, data graph, histogram*/
void SetPlot();

View File

@ -133,32 +133,43 @@ void SlsQt2DPlotLayout::ResetRange(){
void SlsQt2DPlotLayout::ResetZMinZMax(bool zmin, bool zmax, double min, double max){
z_range_ne->SetNumber(min,0);
z_range_ne->SetNumber(max,1);
if(zmin || zmax) zRangeChecked = true;
else zRangeChecked = false;
if(zmin) z_range_ne->SetNumber(min,0);
if(zmax) z_range_ne->SetNumber(max,1);
//refind z limits
the_plot->SetZMinMax();
if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero();
//finds zmin value from hist
if(btnLogz->isChecked())
the_plot->SetZMinimumToFirstGreaterThanZero();
//first time check validity
if(zmax) z_range_ne->SetValue(max,0);
else z_range_ne->SetValue(the_plot->GetZMaximum(),1);
if(zRangeChecked){
if(zmin) z_range_ne->SetValue(min,0);
else z_range_ne->SetValue(the_plot->GetZMinimum(),0);
//if value not given, take max or min of plot
if(zmax) z_range_ne->SetValue(max,0);
else z_range_ne->SetValue(the_plot->GetZMaximum(),1);
if(zmin) z_range_ne->SetValue(min,0);
else z_range_ne->SetValue(the_plot->GetZMinimum(),0);
//check if zmin and zmax is same or not a proper double value
//if(zmin && zmax){
bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0;
if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0);
if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1);
//}
z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0);
z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1);
//set histogram range
the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1));
if(zmin && zmax){
bool same = (z_range_ne->GetValue(0)==z_range_ne->GetValue(1)) ? 1:0;
if(!z_range_ne->IsValueOk(0)||same) z_range_ne->SetValue(the_plot->GetZMinimum(),0);
if(!z_range_ne->IsValueOk(1)||same) z_range_ne->SetValue(the_plot->GetZMaximum(),1);
}
z_range_ne->SetRange(the_plot->GetZMinimum(),z_range_ne->GetValue(1),0);
z_range_ne->SetRange(z_range_ne->GetValue(0),the_plot->GetZMaximum(),1);
//set histogram range
the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1));
the_plot->Update();
}
@ -216,6 +227,7 @@ void SlsQt2DPlotLayout::SetZRange(double zmin, double zmax){
ResetRange();
}
void SlsQt2DPlotLayout::EnableZRange(bool enable){
#ifdef VERBOSE
cout<<"Setting Z Range Enable to "<<enable<<endl;

View File

@ -253,7 +253,7 @@ double SlsQtNumberEntry::SetNumber(double v,int which_number_field){
}
if(validator_double[i]){
QString s = QString::number(v);
validator_double[i]->fixup(s);
//validator_double[i]->fixup(s);//commented out as it ignores the zmax values
num_field[i]->setText(s);
}
}else if(spin_box[i]){
@ -280,7 +280,7 @@ void SlsQtNumberEntry::SetRange(int min, int max,int which_number_field){
void SlsQtNumberEntry::SetRange(double min, double max,int which_number_field){
int i = (which_number_field<0||which_number_field>1) ? 0:which_number_field;
if(min>max){
cout<<"Warning: SetRange(double,double) no effect min >= max"<<endl;
cout<<"Warning: SetRange(double,double) no effect min("<<min<<") >= max("<<max<<")"<<endl;
}else{
if(validator_int[i]) cout<<"Waring can not call SetRange(double,double) with \"int\" type Validator"<<endl;
if(validator_double[i]) validator_double[i]->setRange(min,max,validator_double[i]->decimals());
@ -407,7 +407,13 @@ double SlsQtNumberEntry::GetNumber(int which_number_field,bool* ok){
if(num_field[i]){
if(validator_int[i]) return num_field[i]->text().toInt(ok);
else return num_field[i]->text().toDouble(ok);
else {
bool k;
cout<<"val:"<<num_field[i]->text().toDouble(&k)<<endl;
cout<<"ok:"<<k<<endl;
return num_field[i]->text().toDouble(ok);
}
}
else if(spin_box[i]) return spin_box[i]->value();
else {if(ok) *ok=0;}

View File

@ -510,8 +510,11 @@ void qTabPlot::SetAxesRange(){
void qTabPlot::SetZRange(){
// emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble());
emit ResetZMinZMaxSignal(chkZMin->isChecked(),chkZMax->isChecked(),dispZMin->text().toDouble(),dispZMax->text().toDouble());
emit ResetZMinZMaxSignal(
(chkZMin->isChecked() && CheckZRange(dispZMin->text())),
(chkZMax->isChecked() && CheckZRange(dispZMax->text())),
dispZMin->text().toDouble(),
dispZMax->text().toDouble());
}
@ -519,9 +522,30 @@ void qTabPlot::SetZRange(){
void qTabPlot::EnableZRange(){
dispZMin->setEnabled(chkZMin->isChecked());
dispZMax->setEnabled(chkZMax->isChecked());
emit ResetZMinZMaxSignal(chkZMin->isChecked(),chkZMax->isChecked(),dispZMin->text().toDouble(),dispZMax->text().toDouble());
emit ResetZMinZMaxSignal(
(chkZMin->isChecked() && CheckZRange(dispZMin->text())),
(chkZMax->isChecked() && CheckZRange(dispZMax->text())),
dispZMin->text().toDouble(),
dispZMax->text().toDouble());
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
bool qTabPlot::CheckZRange(QString value){
if(value.isEmpty())
return false;
bool ok;
value.toDouble(&ok);
if(!ok)
return false;
return true;
}