mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-17 13:01:12 +01:00
Setting axes range and enabling/disabling zooming functionalities successfull
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@10 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
@@ -141,7 +141,7 @@ for(int hist_num=0;hist_num<nHists;hist_num++){
|
||||
k->setTitle(histTitle[hist_num].c_str());
|
||||
k->Attach(cloneplot1D);
|
||||
}
|
||||
cloneplot1D->UnZoom();
|
||||
//cloneplot1D->UnZoom();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ void qDetectorMain::Initialization(){
|
||||
connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(refresh(int)));//( QWidget*)));
|
||||
/** Measurement tab*/
|
||||
/** Plot tab */
|
||||
|
||||
connect(tab_plot,SIGNAL(DisableZoomSignal(bool)),this, SLOT(SetZoomToolTip(bool)));
|
||||
|
||||
/** Plotting */
|
||||
/** When the acquisition is finished, must update the meas tab */
|
||||
@@ -202,6 +202,7 @@ void qDetectorMain::Initialization(){
|
||||
heightCentralWidget = centralwidget->size().height();
|
||||
|
||||
defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput);
|
||||
zoomToolTip = dockWidgetPlot->toolTip();
|
||||
}
|
||||
|
||||
|
||||
@@ -364,8 +365,11 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){
|
||||
|
||||
|
||||
void qDetectorMain::EnableTabs(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Entering EnableTabs function"<<endl;
|
||||
#endif
|
||||
bool enable;
|
||||
enable=(tabs->isTabEnabled(DataOutput)?false:true);
|
||||
enable=!(tabs->isTabEnabled(DataOutput));
|
||||
|
||||
// or use the Enable/Disable button
|
||||
/** normal tabs*/
|
||||
@@ -389,3 +393,12 @@ void qDetectorMain::EnableTabs(){
|
||||
tabs->setTabEnabled(Developer,enable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qDetectorMain::SetZoomToolTip(bool disable){
|
||||
if(disable)
|
||||
dockWidgetPlot->setToolTip("<span style=\" color:#00007f;\">To Enable mouse-controlled zooming capabilities,\ndisable min and max for all axes.<span> ");
|
||||
else
|
||||
dockWidgetPlot->setToolTip(zoomToolTip);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
/** Qt Project Class Headers */
|
||||
#include "qDrawPlot.h"
|
||||
#include "qCloneWidget.h"
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt2DPlotLayout.h"
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
#include "postProcessing.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
@@ -19,12 +19,41 @@
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define Detector_Index 0
|
||||
|
||||
|
||||
|
||||
|
||||
//int numberOfMeasurements;
|
||||
int qDrawPlot::currentFrame;
|
||||
int qDrawPlot::number_of_exposures;
|
||||
//double framePeriod;
|
||||
//double acquisitionTime;
|
||||
pthread_mutex_t qDrawPlot::last_image_complete_mutex;
|
||||
//std::string imageTitle;
|
||||
std::string qDrawPlot::histTitle[MAX_1DPLOTS];
|
||||
unsigned int qDrawPlot::plot_in_scope;
|
||||
unsigned int qDrawPlot::nPixelsX;
|
||||
unsigned int qDrawPlot::nPixelsY;
|
||||
unsigned int qDrawPlot::lastImageNumber;
|
||||
unsigned int qDrawPlot::nHists;
|
||||
int qDrawPlot::histNBins;
|
||||
double* qDrawPlot::histXAxis;
|
||||
double* qDrawPlot::histYAxis[MAX_1DPLOTS];
|
||||
double* qDrawPlot::lastImageArray;
|
||||
double* qDrawPlot::yvalues[MAX_1DPLOTS];
|
||||
double* qDrawPlot::image_data;
|
||||
bool qDrawPlot::gui_acquisition_thread_running;
|
||||
int qDrawPlot::persistency;
|
||||
int qDrawPlot::currentPersistency;
|
||||
int qDrawPlot::progress;
|
||||
bool qDrawPlot::plotEnable;
|
||||
|
||||
|
||||
qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector),numberOfMeasurements(1){
|
||||
if(myDet) {
|
||||
SetupWidgetWindow();
|
||||
@@ -52,40 +81,52 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
#endif
|
||||
stop_signal = 0;
|
||||
pthread_mutex_init(&last_image_complete_mutex,NULL);
|
||||
|
||||
gui_acquisition_thread_running = 0;
|
||||
/** Default Plotting*/
|
||||
plot_in_scope = 0;
|
||||
/**2d*/
|
||||
lastImageNumber = 0;
|
||||
nPixelsX = 0;
|
||||
nPixelsY = 0;
|
||||
lastImageArray = 0;
|
||||
|
||||
|
||||
nPixelsX = 1280; nPixelsY = 100;
|
||||
|
||||
lastImageArray = 0;
|
||||
image_data = 0;
|
||||
/**1d*/
|
||||
nHists = 0;
|
||||
histNBins = 0;
|
||||
histXAxis = 0;
|
||||
for(int i=0;i<MAX_1DPLOTS;i++) histYAxis[i]=0;
|
||||
persistency = 0;
|
||||
currentPersistency = 0;
|
||||
progress = 0;
|
||||
plotEnable=true;
|
||||
for(int i=0;i<MAX_1DPLOTS;i++) {histYAxis[i]=0;yvalues[i]=0; }
|
||||
|
||||
/*clone*/
|
||||
for(int i=0;i<MAXCloneWindows;i++) winClone[i]=0;
|
||||
|
||||
|
||||
/** Setting up window*/
|
||||
setFont(QFont("Sans Serif",9));
|
||||
layout = new QGridLayout;
|
||||
this->setLayout(layout);
|
||||
|
||||
this->setLayout(layout);
|
||||
boxPlot = new QGroupBox("Measurement");
|
||||
layout->addWidget(boxPlot,1,1);
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
boxPlot->setFont(QFont("Sans Serif",11,QFont::Bold));
|
||||
|
||||
layout->addWidget(boxPlot,1,1);
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal));
|
||||
plot_update_timer = new QTimer(this);
|
||||
connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
|
||||
|
||||
|
||||
/** Defaults - only for the initial picture*/
|
||||
/** Default titles- only for the initial picture*/
|
||||
histXAxisTitle="Channel Number";
|
||||
histYAxisTitle="Counts";
|
||||
for(int i=0;i<MAX_1DPLOTS;i++)
|
||||
histTitle[i].assign("curve"+i);
|
||||
|
||||
char temp_title[2000];
|
||||
for(int i=0;i<MAX_1DPLOTS;i++){
|
||||
sprintf(temp_title,"Frame -%d",i);
|
||||
histTitle[i] = temp_title;
|
||||
}
|
||||
imageTitle.assign("Start Image");
|
||||
imageXAxisTitle="Pixel";
|
||||
imageYAxisTitle="Pixel";
|
||||
@@ -93,30 +134,26 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
|
||||
|
||||
|
||||
|
||||
/** setting default plot titles and settings*/
|
||||
plot1D = new SlsQt1DPlot(boxPlot);
|
||||
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
plot1D->hide();
|
||||
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
plot1D->hide();
|
||||
|
||||
plot2D = new SlsQt2DPlotLayout(boxPlot);
|
||||
plot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
||||
plot2D->setTitle(GetImageTitle());
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
plot2D->SetYTitle(imageYAxisTitle);
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot2D->setAlignment(Qt::AlignLeft);
|
||||
plot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
||||
plot2D->setTitle(GetImageTitle());
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
plot2D->SetYTitle(imageYAxisTitle);
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot2D->setAlignment(Qt::AlignLeft);
|
||||
boxPlot->setFlat(true);
|
||||
|
||||
//QSizePolicy sizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
|
||||
//boxPlot->setSizePolicy(sizePolicy);
|
||||
boxPlot->setContentsMargins(0,15,0,0);
|
||||
|
||||
plotLayout = new QGridLayout(boxPlot);
|
||||
plotLayout->addWidget(plot1D,1,1,1,1);
|
||||
plotLayout->addWidget(plot2D,1,1,1,1);
|
||||
|
||||
boxPlot->setContentsMargins(0,15,0,0);
|
||||
plotLayout->addWidget(plot1D,1,1,1,1);
|
||||
plotLayout->addWidget(plot2D,1,1,1,1);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,8 +225,8 @@ int qDrawPlot::ResetDaqForGui(){
|
||||
|
||||
|
||||
bool qDrawPlot::StartOrStopThread(bool start){
|
||||
static bool gui_acquisition_thread_running = 0;
|
||||
static pthread_t gui_acquisition_thread;
|
||||
static pthread_t gui_start_acquire_thread;
|
||||
static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
pthread_mutex_lock(&gui_acquisition_start_stop_mutex);
|
||||
@@ -197,129 +234,112 @@ bool qDrawPlot::StartOrStopThread(bool start){
|
||||
if(gui_acquisition_thread_running){
|
||||
cout<<"Stopping current acquisition thread ...."<<endl;
|
||||
stop_signal = 1;
|
||||
pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits
|
||||
myDet->stopAcquisition();
|
||||
//pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits
|
||||
gui_acquisition_thread_running = 0;
|
||||
}
|
||||
|
||||
//start part
|
||||
if(start){
|
||||
/** Defaults */
|
||||
currentFrame = 0;
|
||||
stop_signal = 0;
|
||||
histNBins = nPixelsX;
|
||||
if(!image_data) image_data = new double[nPixelsX*nPixelsY];
|
||||
if(!lastImageArray) lastImageArray = new double[nPixelsX*nPixelsY];
|
||||
if(!histXAxis) histXAxis = new double [nPixelsX];
|
||||
for(unsigned int px=0;px<nPixelsX;px++) histXAxis[px] = px+10;
|
||||
if(!yvalues[0]) yvalues[0] = new double [nPixelsX];
|
||||
if(!histYAxis[0]) histYAxis[0] = new double [nPixelsX];
|
||||
|
||||
|
||||
Clear1DPlot();
|
||||
cout<<"Starting new acquisition thread ...."<<endl;
|
||||
gui_acquisition_thread_running = !pthread_create(&gui_acquisition_thread, NULL,qDrawPlot::DataAcquisionThread, (void*) this);
|
||||
cout<<"created"<<endl;
|
||||
//myDet->acquire(1);//acquiring
|
||||
/** Setting the callback function to get data from software client*/
|
||||
myDet->registerDataCallback(&(GetDataCallBack));
|
||||
/** Start acquiring data from server */
|
||||
pthread_create(&gui_start_acquire_thread, NULL,DataStartAcquireThread, (void*) this);
|
||||
gui_acquisition_thread_running=1;
|
||||
cout<<"Started acquiring"<<endl;
|
||||
}
|
||||
pthread_mutex_unlock(&gui_acquisition_start_stop_mutex);
|
||||
|
||||
return gui_acquisition_thread_running;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void* qDrawPlot::DataAcquisionThread(void *this_pointer){
|
||||
((qDrawPlot*)this_pointer)->AcquireImages();
|
||||
void* qDrawPlot::DataStartAcquireThread(void *this_pointer){
|
||||
((qDrawPlot*)this_pointer)->myDet->acquire(1);
|
||||
return this_pointer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int qDrawPlot::GetDataCallBack(detectorData *data){
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Entering GetDataCallBack function"<<endl;
|
||||
#endif
|
||||
progress=(int)data->progressIndex;
|
||||
|
||||
void* qDrawPlot::AcquireImages(){
|
||||
//send data to detector
|
||||
|
||||
static unsigned int nx=1280,ny=100;
|
||||
static double* image_data = new double[nx*ny];
|
||||
if(!lastImageArray) lastImageArray = new double[nx*ny];
|
||||
static double* xvalues = new double [nx];
|
||||
static double* yvalues0 = new double [nx];
|
||||
static double* yvalues1 = new double [nx];
|
||||
if(!histXAxis) histXAxis = new double [nx];
|
||||
if(!histYAxis[0]) histYAxis[0] = new double [nx];
|
||||
if(!histYAxis[1]) histYAxis[1] = new double [nx];
|
||||
|
||||
|
||||
|
||||
// char cIndex[200];
|
||||
|
||||
//string filePath = myDet->getFilePath()+'/'+myDet->getFileName()+'_';
|
||||
//cout<<"filePath:"<<filePath<<endl;
|
||||
//string fileName;
|
||||
|
||||
//numberOfMeasurements
|
||||
for(int i=0;i<number_of_exposures;i++){
|
||||
|
||||
/////
|
||||
//fileName.assign(filePath);
|
||||
//sprintf(cIndex,"%d",i);
|
||||
//fileName.append(cIndex);
|
||||
//fileName.append(".raw");
|
||||
//cout<<"filename:"<<fileName<<endl;
|
||||
//short int arg[1280];
|
||||
|
||||
//while(myDet->readDataFile(fileName,arg)==-1);
|
||||
|
||||
|
||||
/////////
|
||||
|
||||
|
||||
//readout detector
|
||||
//fill and write data here
|
||||
for(unsigned int px=0;px<nx;px++)
|
||||
for(unsigned int py=0;py<ny;py++)
|
||||
image_data[py*nx+px] = sqrt(pow(i+1,2)*pow(double(px)-nx/2,2)/pow(nx/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-ny/2,2)/pow(ny/2,2))/sqrt(2);
|
||||
|
||||
for(unsigned int px=0;px<nx;px++){
|
||||
/*
|
||||
xvalues[px] = px;//+10;
|
||||
yvalues0[px] = (double)arg[px];//i + pow(1 - 2*fabs(double(px)-nx/2)/nx,2);
|
||||
yvalues1[px] = 0;//i + pow(1 - 2*fabs(double(px)-nx/2)/nx,4);
|
||||
*/
|
||||
xvalues[px] = px+10;
|
||||
yvalues0[px] = i + pow(1 - 2*fabs(double(px)-nx/2)/nx,2);
|
||||
yvalues1[px] = i + pow(1 - 2*fabs(double(px)-nx/2)/nx,4);
|
||||
|
||||
}
|
||||
|
||||
/* if(framePeriod<acquisitionTime) usleep((int)acquisitionTime*1e6);
|
||||
else usleep((int)framePeriod*1e6);*/
|
||||
//cout<<"Reading in image: "<<i<<endl;
|
||||
//usleep(1000000);
|
||||
if(stop_signal) break; //stop_signal should also go to readout function
|
||||
if(!pthread_mutex_trylock(&last_image_complete_mutex)){
|
||||
|
||||
//plot_in_scope = 1;//i%2 + 1;
|
||||
//plot_in_scope = 2;
|
||||
//cout<<"value:"<<image_data[6]<<endl;
|
||||
|
||||
lastImageNumber = i+1;
|
||||
char temp_title[2000];
|
||||
//1d image stuff
|
||||
nHists = 2;
|
||||
sprintf(temp_title,"curve one %d",i); histTitle[0] = temp_title;
|
||||
sprintf(temp_title,"curve two %d",i); histTitle[1] = temp_title;
|
||||
histNBins = nx;
|
||||
memcpy(histXAxis, xvalues,nx*sizeof(double));
|
||||
memcpy(histYAxis[0],yvalues0,nx*sizeof(double));
|
||||
memcpy(histYAxis[1],yvalues1,nx*sizeof(double));
|
||||
|
||||
//2d image stuff
|
||||
sprintf(temp_title,"Image number %d",i); imageTitle=temp_title;
|
||||
nPixelsX = nx;
|
||||
nPixelsY = ny;
|
||||
memcpy(lastImageArray,image_data,nx*ny*sizeof(double));
|
||||
|
||||
pthread_mutex_unlock(&last_image_complete_mutex);
|
||||
}
|
||||
if(!plotEnable) {
|
||||
lastImageNumber= currentFrame+1;
|
||||
currentFrame++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this;
|
||||
/** Persistency */
|
||||
if(currentPersistency < persistency)currentPersistency++;
|
||||
else currentPersistency=persistency;
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double));
|
||||
nHists = currentPersistency+1;
|
||||
/** Get data from client */
|
||||
memcpy(yvalues[0],data->values,nPixelsX*sizeof(double));
|
||||
|
||||
/**1d*/
|
||||
// if(plot_in_scope==1){
|
||||
if((currentFrame)<(number_of_exposures)){
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Reading in image: "<<currentFrame+1<<endl;
|
||||
#endif
|
||||
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
|
||||
/** only if you got the lock, do u need to remember lastimagenumber to plot*/
|
||||
lastImageNumber= currentFrame+1;
|
||||
/** Titles*/
|
||||
stringstream s;
|
||||
s<<"Frame "<<currentFrame;
|
||||
histTitle[0]=s.str();
|
||||
/** copy data*/
|
||||
|
||||
//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
|
||||
for(int i=currentPersistency;i>0;i--)
|
||||
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
|
||||
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
|
||||
pthread_mutex_unlock(&(last_image_complete_mutex));
|
||||
}
|
||||
|
||||
currentFrame++;
|
||||
}
|
||||
//}
|
||||
///**2d*/
|
||||
//else{
|
||||
// ;
|
||||
//}
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Exiting GetDataCallBack function"<<endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void qDrawPlot::SetPersistency(int val){
|
||||
for(int i=0;i<=val;i++){
|
||||
if(!yvalues[i]) yvalues[i] = new double [nPixelsX];
|
||||
if(!histYAxis[i]) histYAxis[i] = new double [nPixelsX];
|
||||
}
|
||||
persistency = val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qDrawPlot::setNumMeasurements(int num){
|
||||
@@ -361,50 +381,61 @@ void qDrawPlot::Clear1DPlot(){
|
||||
|
||||
void qDrawPlot::UpdatePlot(){
|
||||
//emit UpdatingPlot();
|
||||
static int last_plot_number = 0;
|
||||
|
||||
plot_update_timer->stop();
|
||||
if(plotEnable){
|
||||
LockLastImageArray();
|
||||
//1-d plot stuff
|
||||
if(lastImageNumber){
|
||||
if(histNBins){
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Last Image Number: "<<lastImageNumber<<endl;
|
||||
#endif
|
||||
Clear1DPlot();
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
for(int hist_num=0;hist_num<nHists;hist_num++){
|
||||
SlsQtH1D* h;
|
||||
if(hist_num+1>plot1D_hists.size()){
|
||||
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num)));
|
||||
h->SetLineColor(hist_num+1);
|
||||
}else{
|
||||
h=plot1D_hists.at(hist_num);
|
||||
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
|
||||
}
|
||||
h->setTitle(GetHistTitle(hist_num));
|
||||
h->Attach(plot1D);
|
||||
|
||||
}
|
||||
//plot1D->UnZoom();
|
||||
//if(first){plot1D->UnZoom();first = !first;}
|
||||
//plot1D->SetZoom(double xmin,double ymin,double x_width,double y_width);
|
||||
|
||||
LockLastImageArray();
|
||||
//1-d plot stuff
|
||||
if(histNBins){
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
for(int hist_num=0;hist_num<nHists;hist_num++){
|
||||
SlsQtH1D* h;
|
||||
if(hist_num+1>plot1D_hists.size()){
|
||||
plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num)));
|
||||
h->SetLineColor(hist_num+1);
|
||||
}else{
|
||||
h=plot1D_hists.at(hist_num);
|
||||
h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
|
||||
}
|
||||
h->setTitle(GetHistTitle(hist_num));
|
||||
h->Attach(plot1D);
|
||||
}
|
||||
plot1D->UnZoom();
|
||||
}
|
||||
|
||||
//2-d plot stuff
|
||||
static int last_plot_number = 0;
|
||||
if(lastImageArray){
|
||||
if(lastImageNumber&&last_plot_number!=lastImageNumber && //there is a new plot
|
||||
nPixelsX>0&&nPixelsY>0){
|
||||
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray);
|
||||
//as it inherits a widget
|
||||
plot2D->setTitle(GetImageTitle());
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
plot2D->SetYTitle(imageYAxisTitle);
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update();
|
||||
//2-d plot stuff
|
||||
if(lastImageArray){
|
||||
if(lastImageNumber&&last_plot_number!=lastImageNumber && //there is a new plot
|
||||
nPixelsX>0&&nPixelsY>0){
|
||||
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray);
|
||||
//as it inherits a widget
|
||||
plot2D->setTitle(GetImageTitle());
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
plot2D->SetYTitle(imageYAxisTitle);
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
last_plot_number=lastImageNumber;
|
||||
UnlockLastImageArray();
|
||||
|
||||
/* if(plot_in_scope==1) SelectPlot(1);
|
||||
if(plotEnable) UnlockLastImageArray();
|
||||
/* if(plot_in_scope==1) SelectPlot(1);
|
||||
else if(plot_in_scope==2) SelectPlot(2);*/
|
||||
|
||||
if(number_of_exposures==last_plot_number){
|
||||
gui_acquisition_thread_running=0;
|
||||
StartStopDaqToggle(1);
|
||||
emit UpdatingPlotFinished();
|
||||
}else{
|
||||
@@ -498,3 +529,24 @@ void qDrawPlot::SavePlot(QString FName){
|
||||
render(&painter);
|
||||
img.save(FName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qDrawPlot::EnablePlot(bool enable){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Plotting set to:"<<enable<<endl;
|
||||
#endif
|
||||
plotEnable = !enable;
|
||||
Clear1DPlot();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void qDrawPlot::DisableZoom(bool disable){
|
||||
if(plot_in_scope==1)
|
||||
plot1D->DisableZoom(disable);
|
||||
///disable zoom
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ qTabMeasurement::~qTabMeasurement(){
|
||||
|
||||
void qTabMeasurement::SetupWidgetWindow(){
|
||||
|
||||
progressTimer = new QTimer(this);
|
||||
//btnStartStop->setStyleSheet("color:green");
|
||||
/** Exp Time **/
|
||||
float time = (float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9));
|
||||
spinExpTime->setValue(time);
|
||||
@@ -106,7 +108,7 @@ void qTabMeasurement::SetupWidgetWindow(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
progressBar->setValue(0);
|
||||
//get timing mode from client
|
||||
|
||||
|
||||
@@ -127,6 +129,8 @@ void qTabMeasurement::Initialization(int timingChange){
|
||||
connect(btnStartStop,SIGNAL(clicked()), this, SLOT(startStopAcquisition()));
|
||||
/** Timing Mode **/
|
||||
connect(comboTimingMode,SIGNAL(currentIndexChanged(int)), this, SLOT(setTimingMode(int)));//
|
||||
|
||||
connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress()));
|
||||
}
|
||||
/** Number of Frames**/
|
||||
connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int)));
|
||||
@@ -189,15 +193,17 @@ void qTabMeasurement::Enable(bool enable){
|
||||
void qTabMeasurement::UpdateFinished(){
|
||||
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
|
||||
btnStartStop->setText("Start");
|
||||
//btnStartStop->setStyleSheet("color:green");
|
||||
//btnStartStop->setStyleSheet("background:rgb(239,239,239)");
|
||||
Enable(1);
|
||||
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
|
||||
UpdateProgress();
|
||||
progressTimer->stop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qTabMeasurement::setFileName(const QString& fName){
|
||||
// emit fileNameChanged(fName);
|
||||
// thred-->fileName=s;myDet->setFileName(fName.ascii());
|
||||
myDet->setFileName(fName.toAscii().data());
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting File name to " << myDet->getFileName()<<endl;
|
||||
@@ -209,6 +215,7 @@ void qTabMeasurement::setFileName(const QString& fName){
|
||||
|
||||
void qTabMeasurement::setRunIndex(int index){
|
||||
myDet->setFileIndex(index);
|
||||
lblProgressIndex->setText(QString::number(index));
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting File Index to " << myDet->getFileIndex()<<endl;
|
||||
#endif
|
||||
@@ -221,13 +228,20 @@ void qTabMeasurement::startStopAcquisition(){
|
||||
#ifdef VERBOSE
|
||||
cout<<endl<<endl<<"Starting Acquisition"<<endl;
|
||||
#endif
|
||||
//btnStartStop->setStyleSheet("color:red");
|
||||
btnStartStop->setText("Stop");
|
||||
Enable(0);
|
||||
progressBar->setValue(0);
|
||||
progressTimer->start(200);
|
||||
|
||||
emit StartSignal();
|
||||
}else{
|
||||
#ifdef VERBOSE
|
||||
cout<<"Stopping Acquisition"<<endl;
|
||||
#endif
|
||||
//btnStartStop->setStyleSheet("color:green");
|
||||
//btnStartStop->setStyleSheet("background:rgb(239,239,239)");
|
||||
progressTimer->stop();
|
||||
btnStartStop->setText("Start");
|
||||
Enable(1);
|
||||
emit StopSignal();
|
||||
@@ -270,8 +284,6 @@ void qTabMeasurement::setExposureTime(){
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
}
|
||||
}
|
||||
//float t=exptimeNS;
|
||||
//emit acquisitionTimeChanged(t/(100E+6)); ??????????????????????
|
||||
}
|
||||
|
||||
|
||||
@@ -297,10 +309,6 @@ void qTabMeasurement::setAcquisitionPeriod(){
|
||||
lblPeriod->setPalette(lblNumFrames->palette());
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
}
|
||||
|
||||
|
||||
//float t=exptimeNS;
|
||||
//emit acquisitionTimeChanged(t/(100E+6)); ??????????????????????
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +356,12 @@ void qTabMeasurement::setNumProbes(int val){
|
||||
}
|
||||
|
||||
|
||||
void qTabMeasurement::UpdateProgress(){
|
||||
progressBar->setValue(myPlot->GetProgress());
|
||||
lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void qTabMeasurement::setTimingMode(int mode){
|
||||
|
||||
@@ -36,6 +36,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot
|
||||
//This also selects the text if unchecked
|
||||
//includes setupwidgetwindow
|
||||
//SelectPlot(1);
|
||||
//switch(myDet->detectorytype)
|
||||
Select1DPlot(true);
|
||||
Initialization();
|
||||
}
|
||||
@@ -66,9 +67,12 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
dispXMax->setEnabled(false);
|
||||
dispYMax->setEnabled(false);
|
||||
dispZMax->setEnabled(false);
|
||||
|
||||
//dispFName->setText(QString(myDet->getFilePath().c_str())+'/');
|
||||
|
||||
/* dispXMin->setValidator(new QDoubleValidator(dispXMin));
|
||||
dispYMin->setValidator(new QDoubleValidator(dispYMin));
|
||||
dispZMin->setValidator(new QDoubleValidator(dispZMin));
|
||||
dispXMax->setValidator(new QDoubleValidator(dispXMax));
|
||||
dispYMax->setValidator(new QDoubleValidator(dispYMax));
|
||||
dispZMax->setValidator(new QDoubleValidator(dispZMax));*/
|
||||
}
|
||||
|
||||
|
||||
@@ -103,9 +107,14 @@ void qTabPlot::Select1DPlot(bool b){
|
||||
|
||||
|
||||
void qTabPlot::Initialization(){
|
||||
/** Plot box*/
|
||||
/** Plot arguments box*/
|
||||
connect(chkNoPlot, SIGNAL(toggled(bool)),myPlot, SLOT(EnablePlot(bool)));
|
||||
/** Snapshot box*/
|
||||
connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot()));
|
||||
connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones()));
|
||||
/** 1D Plot box*/
|
||||
connect(chkSuperimpose, SIGNAL(toggled(bool)),this, SLOT(EnablePersistency(bool)));
|
||||
connect(spinPersistency,SIGNAL(valueChanged(int)),myPlot,SLOT(SetPersistency(int)));
|
||||
/** 2D Plot box*/
|
||||
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
|
||||
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
|
||||
@@ -119,13 +128,26 @@ void qTabPlot::Initialization(){
|
||||
connect(dispXAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(textChanged(const QString&)), this, SLOT(SetTitles()));
|
||||
|
||||
connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
connect(chkYMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
connect(chkYMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(EnableRange()));
|
||||
|
||||
connect(dispXMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
connect(dispXMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
connect(dispYMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
connect(dispYMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
|
||||
|
||||
/** Common Buttons*/
|
||||
connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot()));
|
||||
/** Save */
|
||||
connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
|
||||
|
||||
/** test for 1D*/
|
||||
connect(chktest1D, SIGNAL(toggled(bool)), this, SLOT(Select1DPlot(bool)));
|
||||
}
|
||||
|
||||
|
||||
@@ -138,6 +160,16 @@ void qTabPlot::Enable(bool enable){
|
||||
boxPlotAxis->setEnabled(enable);
|
||||
}
|
||||
|
||||
void qTabPlot::EnablePersistency(bool enable){
|
||||
lblPersistency->setEnabled(enable);
|
||||
spinPersistency->setEnabled(enable);
|
||||
if(enable) myPlot->SetPersistency(spinPersistency->value());
|
||||
else myPlot->SetPersistency(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qTabPlot::SetTitles(){
|
||||
int oneD = box1D->isEnabled();
|
||||
/** Plot Title*/
|
||||
@@ -159,6 +191,7 @@ void qTabPlot::SetTitles(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qTabPlot::EnableTitles(){
|
||||
int oneD = box1D->isEnabled();
|
||||
/** Plot Title*/
|
||||
@@ -199,7 +232,91 @@ void qTabPlot::EnableTitles(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void qTabPlot::EnableRange(){
|
||||
bool disableZoom = false;
|
||||
if(!chkXMin->isChecked()) {dispXMin->setText(""); dispXMin->setEnabled(false);}
|
||||
else {disableZoom = true; dispXMin->setEnabled(true); }
|
||||
if(!chkXMax->isChecked()) {dispXMax->setText(""); dispXMax->setEnabled(false);}
|
||||
else {disableZoom = true; dispXMax->setEnabled(true); }
|
||||
if(!chkYMin->isChecked()) {dispYMin->setText(""); dispYMin->setEnabled(false);}
|
||||
else {disableZoom = true; dispYMin->setEnabled(true); }
|
||||
if(!chkYMax->isChecked()) {dispYMax->setText(""); dispYMax->setEnabled(false);}
|
||||
else {disableZoom = true; dispYMax->setEnabled(true); }
|
||||
if(!chkZMin->isChecked()) {dispZMin->setText(""); dispZMin->setEnabled(false);}
|
||||
else {disableZoom = true; dispZMin->setEnabled(true); }
|
||||
if(!chkZMax->isChecked()) {dispZMax->setText(""); dispZMax->setEnabled(false);}
|
||||
else {disableZoom = true; dispZMax->setEnabled(true); }
|
||||
myPlot->DisableZoom(disableZoom);
|
||||
emit DisableZoomSignal(disableZoom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qTabPlot::SetAxesRange(){
|
||||
double xmin,xmax,ymin,ymax,zmin,zmax;
|
||||
int oneD = box1D->isEnabled();
|
||||
//should be filled for 2d as well
|
||||
if(!dispXMin->text().isEmpty()) xmin = dispXMin->text().toDouble();
|
||||
else { if(oneD) xmin = myPlot->GetHistXAxisLowerBound();}
|
||||
if(!dispXMax->text().isEmpty()) xmax = dispXMax->text().toDouble();
|
||||
else { if(oneD) xmax = myPlot->GetHistXAxisUpperBound();}
|
||||
if(!dispYMin->text().isEmpty()) ymin = dispYMin->text().toDouble();
|
||||
else { if(oneD) ymin = myPlot->GetHistYAxisLowerBound();}
|
||||
if(!dispYMax->text().isEmpty()) ymax = dispYMax->text().toDouble();
|
||||
else { if(oneD) ymax = myPlot->GetHistYAxisUpperBound();}
|
||||
if(!dispZMin->text().isEmpty()) zmin = dispZMin->text().toDouble();
|
||||
if(!dispZMax->text().isEmpty()) zmax = dispZMax->text().toDouble();
|
||||
//should be filled for 2d as well
|
||||
if(oneD){
|
||||
myPlot->SetHistXAxisScale(xmin,xmax);
|
||||
myPlot->SetHistYAxisScale(ymin,ymax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qTabPlot::SavePlot(){
|
||||
QString fullFileName = QString(myDet->getFilePath().c_str())+'/'+dispFName->text()+comboFormat->currentText();
|
||||
myPlot->SavePlot(fullFileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//dispzmin... when unchecked, unzoom and get lower and upper bound... when checked just set lower and upper bound
|
||||
|
||||
/*
|
||||
|
||||
#include "SlsQtValidators.h"
|
||||
|
||||
class QDoubleValidator;
|
||||
SlsQtDoubleValidator* validator_double[2];
|
||||
|
||||
|
||||
|
||||
|
||||
validator_double = new SlsQtDoubleValidator(num_field);
|
||||
num_field->setValidator(validator_double);
|
||||
//default settings
|
||||
validator_double->setDecimals(3);
|
||||
double v= num_field->text().toDouble(ok););
|
||||
is ok 1? for correct conversion
|
||||
|
||||
QString s = QString::number(v);
|
||||
validator_double->fixup(s);
|
||||
num_field->setText(s);
|
||||
|
||||
|
||||
num_field[i]->setAlignment(Qt::AlignRight);
|
||||
|
||||
|
||||
|
||||
connect(num_field[i],SIGNAL(lostFocus()),this,SLOT(FirstValueEntered()));
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user