This commit is contained in:
maliakal_d 2019-06-17 15:51:17 +02:00
parent 4213a161fe
commit 326b14737f
5 changed files with 59 additions and 205 deletions

View File

@ -40,11 +40,6 @@ xxxxxxxxxxxxxxx
void SetXRange();
void SetYRange();
void CheckAspectRatio();
void SetXYRange();
/**
* Maintain aspect ratio
*/
void MaintainAspectRatio(int dimension);
void SetZRange();
@ -66,9 +61,8 @@ private:
void SetupWidgetWindow();
void Initialization();
void GetGapPixels();
void EnableRange();
void SetAxesRange();
bool CheckZRange(QString value);
void SetXYRange();
void MaintainAspectRatio(int dimension);
multiSlsDetector *myDet;
qDrawPlot *myPlot;

View File

@ -1,23 +1,8 @@
/**
* @author Ian Johnson
* @version 1.0
* @comments
* 19.06.2012 All modifications with the Ian flag has been made since
* z_range_ne and the buttons are defined in another class.
* Logz button and z_range_ne have wrappers to connect them
* 05.05.2013 Added ResetZMinZMax
*/
#ifndef SLSQT2DPLOTLAYOUT_H
#define SLSQT2DPLOTLAYOUT_H
#pragma once
#include <qwidget.h>
#include <qgroupbox.h>
#include "SlsQtNumberEntry.h"
#include "SlsQt2DPlot.h"
class QGridLayout;
@ -37,7 +22,7 @@ public:
void SetXTitle(QString st);
void SetYTitle(QString st);
void SetZTitle(QString st);
void UpdateNKeepSetRangeIfSet();
void KeepZRangeIfSet();
private:
@ -46,32 +31,23 @@ private:
QToolButton* btnContour;
QToolButton* btnLogz;
SlsQt2DPlot* the_plot;
SlsQtNumberEntry* z_range_ne;
#ifndef IAN
bool zRangeChecked;
#endif
void CreateTheButtons();
void ConnectSignalsAndSlots();
void Layout();
bool isLog;
double zmin;
double zmax;
bool isZmin;
bool isZmax;
public slots:
void SetZScaleToLog(bool yes);
void SetZScaleToLog(bool enable);
void ResetRange();
#ifndef IAN
void SetZRange(double,double);
void EnableZRange(bool enable);
void ResetZMinZMax(bool zmin, bool zmax, double min, double max);
#endif
void SetZRange(bool isMin, bool isMax, double min, double max);
signals:
void InterpolateSignal(bool);
void ContourSignal(bool);
void LogzSignal(bool);
};
#endif

View File

@ -1,9 +1,3 @@
/**
* @author Ian Johnson
* @version 1.0
*/
#include <iostream>
#include <qtoolbutton.h>
@ -19,125 +13,67 @@
SlsQt2DPlotLayout::SlsQt2DPlotLayout(QWidget *parent):QGroupBox(parent){
the_layout=0;
the_plot = new SlsQt2DPlot(this);
z_range_ne = new SlsQtNumberEntry(this,1,(char*)"Set the z axis range from",2,(char*)"to",2);
z_range_ne->setFixedWidth(402);
zRangeChecked = false;
z_range_ne->hide();
CreateTheButtons();
isLog = false;
zmin = 0;
zmax = 0;
isZmin = false;
isZmax = false;
Layout();
ConnectSignalsAndSlots();
}
SlsQt2DPlotLayout::~SlsQt2DPlotLayout(){
if(the_layout) delete the_layout;
delete the_plot;
delete z_range_ne;
}
void SlsQt2DPlotLayout::CreateTheButtons(){
btnLogz = new QToolButton(this);
btnLogz->setText("Log Scale (Z)");
btnLogz->setCheckable(true);
btnLogz->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
btnLogz->hide();
}
void SlsQt2DPlotLayout::Layout(){
if(the_layout) delete the_layout;
the_layout = new QGridLayout(this);
the_layout->addWidget(the_plot,2,0,3,3);
the_layout->addWidget(z_range_ne,5,0,1,3);
}
void SlsQt2DPlotLayout::ConnectSignalsAndSlots(){
connect(this, SIGNAL(InterpolateSignal(bool)), the_plot, SLOT(InterpolatedPlot(bool)));
connect(this, SIGNAL(ContourSignal(bool)), the_plot, SLOT(showContour(bool)));
connect(z_range_ne, SIGNAL(CheckBoxChanged(bool)), this, SLOT(ResetRange()));
connect(z_range_ne, SIGNAL(AValueChanged(SlsQtNumberEntry*)), this, SLOT(ResetRange()));
btnLogz->setChecked(false);
connect(this, SIGNAL(InterpolateSignal(bool)), the_plot, SLOT(InterpolatedPlot(bool)));
connect(this, SIGNAL(ContourSignal(bool)), the_plot, SLOT(showContour(bool)));
connect(this, SIGNAL(LogzSignal(bool)), this, SLOT(SetZScaleToLog(bool)));
}
void SlsQt2DPlotLayout::UpdateNKeepSetRangeIfSet(){
//just reset histogram range before update
the_plot->SetZMinMax(z_range_ne->GetValue(0),z_range_ne->GetValue(1));
the_plot->Update();
void SlsQt2DPlotLayout::KeepZRangeIfSet(){
SetZRange(isZMin, isZmax, zmin, zmax);
}
void SlsQt2DPlotLayout::ResetRange(){
//refind z limits
void SlsQt2DPlotLayout::SetZRange(bool isMin, bool isMax, double min, double max){
isZMin = isMin;
isZmax = isMax;
// reset zmin and zmax first
the_plot->SetZMinMax();
if(btnLogz->isChecked()) the_plot->SetZMinimumToFirstGreaterThanZero();
if(zRangeChecked){
//first time check validity
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();
}
void SlsQt2DPlotLayout::ResetZMinZMax(bool zmin, bool zmax, double min, double max){
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();
//finds zmin value from hist
if(btnLogz->isChecked())
if(isLog) {
the_plot->SetZMinimumToFirstGreaterThanZero();
if(zRangeChecked){
//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));
}
// set zmin and zmax
if (isZmin || isZmax) {
zmin = (isZmin ? min : the_plot->GetZMinimum());
zmax = (isZmax ? max : the_plot->GetZMaximum());
// if it is the same values, we should reset it to plots min and max (not doing this now: not foolproof now)
// setting the range of values possible in the dispZMin and dispZMax (not doin this now: not foolproof)
the_plot->SetZMinMax(zmin, zmax);
} else {
zmin = 0;
zmax = -1;
}
the_plot->Update();
}
void SlsQt2DPlotLayout::SetZScaleToLog(bool yes){
#ifdef VERBOSE
cout<<"Setting ZScale to log:"<<yes<<endl;
#endif
btnLogz->setChecked(yes);
the_plot->LogZ(yes);
ResetRange();
void SlsQt2DPlotLayout::SetZScaleToLog(bool enable) {
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Z Scale to log";
isLog = enable;
the_plot->LogZ(enable);
SetZRange(isZMin, isZmax, zmin, zmax);
}
@ -158,23 +94,3 @@ void SlsQt2DPlotLayout::SetZTitle(QString st){
title.setFont(QFont("Sans Serif",11,QFont::Normal));
GetPlot()->axisWidget(QwtPlot::yRight)->setTitle(title);
}
void SlsQt2DPlotLayout::SetZRange(double zmin, double zmax){
#ifdef VERBOSE
cout<<"zmin:"<<zmin<<"\tzmax:"<<zmax<<endl;
#endif
z_range_ne->SetNumber(zmin,0);
z_range_ne->SetNumber(zmax,1);
ResetRange();
}
void SlsQt2DPlotLayout::EnableZRange(bool enable){
#ifdef VERBOSE
cout<<"Setting Z Range Enable to "<<enable<<endl;
#endif
zRangeChecked = enable;
ResetRange();
}

View File

@ -373,9 +373,9 @@ void qDrawPlot::Initialization() {
connect(this, SIGNAL(UpdatePlotSignal()), this, SLOT(UpdatePlot()));
connect(this, SIGNAL(InterpolateSignal(bool)), plot2D, SIGNAL(InterpolateSignal(bool)));
connect(this, SIGNAL(ContourSignal(bool)), plot2D, SIGNAL(ContourSignal(bool)));
connect(this, SIGNAL(LogzSignal(bool)), plot2D, SLOT(SetZScaleToLog(bool)));
connect(this, SIGNAL(LogzSignal(bool)), plot2D, SIGNAL(LogzSignal(bool))));
connect(this, SIGNAL(LogySignal(bool)), plot1D, SLOT(SetLogY(bool)));
connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), plot2D, SLOT(ResetZMinZMax(bool, bool, double, double)));
connect(this, SIGNAL(ResetZMinZMaxSignal(bool, bool, double, double)), plot2D, SLOT(SetZRange(bool, bool, double, double)));
connect(this, SIGNAL(AcquisitionErrorSignal(QString)), this, SLOT(ShowAcquisitionErrorMessage(QString)));
@ -1425,7 +1425,7 @@ void qDrawPlot::UpdatePlot() {
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle);
plot2D->UpdateNKeepSetRangeIfSet(); //keep a "set" z range, and call Update();
plot2D->KeepZRangeIfSet(); //keep a "set" z range, and call Update();
if (gainPlotEnable) {
gainplot2D->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, startPixel, endPixel, gainImageArray);
gainplot2D->setTitle(GetImageTitle());
@ -1734,7 +1734,7 @@ void qDrawPlot::DisableZoom(bool disable) {
plot2D->SetXTitle("Pixel");
plot2D->SetYTitle("Pixel");
plot2D->SetZTitle("Trimbits");
plot2D->UpdateNKeepSetRangeIfSet();
plot2D->KeepZRangeIfSet();
#ifdef VERBOSE
std::cout << "Trimbits Plot updated" <<'\n';
#endif

View File

@ -562,46 +562,16 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
void qTabPlot::SetZRange() {
emit ResetZMinZMaxSignal(
(chkZMin->isChecked() && CheckZRange(dispZMin->text())),
(chkZMax->isChecked() && CheckZRange(dispZMax->text())),
dispZMin->text().toDouble(),
dispZMax->text().toDouble());
}
void qTabPlot::EnableZRange() {
disconnect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange()));
disconnect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange()));
dispZMin->setEnabled(chkZMin->isChecked());
dispZMax->setEnabled(chkZMax->isChecked());
emit ResetZMinZMaxSignal(
(chkZMin->isChecked() && CheckZRange(dispZMin->text())),
(chkZMax->isChecked() && CheckZRange(dispZMax->text())),
dispZMin->text().toDouble(),
dispZMax->text().toDouble());
connect(dispZMin, SIGNAL(editingFinished()), this, SLOT(SetZRange()));
connect(dispZMax, SIGNAL(editingFinished()), this, SLOT(SetZRange()));
}
bool qTabPlot::CheckZRange(QString value) {
if (value.isEmpty())
return false;
bool ok;
value.toDouble(&ok);
if (!ok) {
qDefs::Message(qDefs::WARNING, "<nobr>Check Z Range</nobr><br><nobr>"
"Zmin and Zmax should be in double</nobr>",
"qTabPlot::CheckZRange");
return false;
bool isZmin = chkZMin->isChecked();
bool isZmax = chkZMax->isChecked();
double zmin = 0, zmax = 1;
if (!dispZMin->text().empty()) {
zmin = dispZMin->text().toDouble();
}
return true;
if (!dispZMax->text().empty()) {
zmax = dispZMax->text().toDouble();
}
emit ResetZMinZMaxSignal(isZmin, isZmax, zmin, zmax);
}
@ -679,8 +649,6 @@ bool qTabPlot::CheckZRange(QString value) {