done with save plot and all resizing options

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@5 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d
2012-05-29 16:49:30 +00:00
parent 216a9ada7c
commit 20cc6d9a90
9 changed files with 318 additions and 177 deletions

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>748</width> <width>734</width>
<height>339</height> <height>339</height>
</rect> </rect>
</property> </property>
@ -44,6 +44,29 @@
<string>PushButton</string> <string>PushButton</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>108</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Output Directory:</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>118</x>
<y>10</y>
<width>113</width>
<height>21</height>
</rect>
</property>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -483,7 +483,7 @@
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>551</width> <width>551</width>
<height>16</height> <height>27</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
@ -494,11 +494,31 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QPushButton" name="btnClear">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<zorder>gridLayoutWidget_3</zorder>
<zorder>btnClear</zorder>
<zorder>gridLayoutWidget_4</zorder>
</widget> </widget>
<widget class="QGroupBox" name="boxSave"> <widget class="QGroupBox" name="boxSave">
<property name="geometry"> <property name="geometry">
@ -628,9 +648,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>599</x> <x>599</x>
<y>41</y> <y>10</y>
<width>121</width> <width>121</width>
<height>80</height> <height>111</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@ -639,10 +659,10 @@
<widget class="QWidget" name="gridLayoutWidget_2"> <widget class="QWidget" name="gridLayoutWidget_2">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>20</x>
<y>10</y> <y>20</y>
<width>101</width> <width>81</width>
<height>71</height> <height>81</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
@ -653,7 +673,7 @@
<number>9</number> <number>9</number>
</property> </property>
<property name="verticalSpacing"> <property name="verticalSpacing">
<number>-1</number> <number>13</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QPushButton" name="btnClone"> <widget class="QPushButton" name="btnClone">
@ -690,28 +710,6 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>600</x>
<y>16</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="btnClear">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -9,55 +9,78 @@
#define QCLONEWIDGET_H_ #define QCLONEWIDGET_H_
/** Qt Project Class Headers */ /** Qt Project Class Headers */
class SlsQtH1D;
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQt2DPlotLayout; class SlsQt2DPlotLayout;
/** Qt Include Headers */ /** Qt Include Headers */
#include <QFrame> #include <QFrame>
#include <QGridLayout>
#include <QCloseEvent> #include <QCloseEvent>
#include <QGroupBox> #include <QGroupBox>
#include <QWidget> #include <QWidget>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QComboBox>
#include <QPushButton>
#include <QCheckBox> #include <QCheckBox>
/** C++ Include Headers */
#include <string>
using namespace std;
/** /**
*@short Sets up the clone plot widget *@short Sets up the clone plot widget
*/ */
class qCloneWidget:public QMainWindow{ class qCloneWidget:public QFrame{
Q_OBJECT Q_OBJECT
public: public:
/** \short The constructor /** \short The constructor
*/ */
qCloneWidget(QWidget *parent,int id,QSize fSize,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D); qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath);
/** Destructor /** Destructor
*/ */
~qCloneWidget(); ~qCloneWidget();
/** Sets up the widget window
* @param title title of the image with frame number
* @param numDim 1D or 2D
* @param plot1D plot1d object reference
* @param plot2D plot2d object reference
* */
void SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D);
/** Get the 1D plot reference
*/
SlsQt1DPlot* Get1Dplot(){ return cloneplot1D;};
public slots:
/** Get the 1D hist values to plot
* @param nHists Number of graphs in 1D
* @param histNBins Total Number of X axis values/channels in 1D
* @param histXAxis X Axis value in 1D
* @param histYAxis Y Axis value in 1D
* @param histTitle Title for all the graphs in 1D
* */
void SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]);
private: private:
/** clone window id*/ /** clone window id*/
int id; int id;
/** clone 1D Plot */ /** Default Save file path */
SlsQt1DPlot* cloneplot1D; string filePath;
/** clone 2D Plot */ /** clone 2D Plot */
SlsQt2DPlotLayout* cloneplot2D; SlsQt2DPlotLayout* cloneplot2D;
/** clone 1D Plot */
SlsQt1DPlot* cloneplot1D;
/** vector of 1D hist values */
QVector<SlsQtH1D*> cloneplot1D_hists;
QGridLayout *mainLayout; QGridLayout *mainLayout;
QGroupBox *cloneBox;
QGridLayout *gridClone;
QGroupBox *boxSave; QGroupBox *boxSave;
QWidget *horizontalLayoutWidget;
QHBoxLayout *layoutSave; QHBoxLayout *layoutSave;
QLabel *lblFName; QLabel *lblFName;
QHBoxLayout *hLayoutSave; QHBoxLayout *hLayoutSave;
@ -66,6 +89,13 @@ private:
QPushButton *btnSave; QPushButton *btnSave;
QCheckBox *chkAutoFName; QCheckBox *chkAutoFName;
QCheckBox *chkSaveAll; QCheckBox *chkSaveAll;
private slots:
/** Save Plot */
void SavePlot();
protected: protected:
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);

View File

@ -23,6 +23,8 @@ class qCloneWidget;
#include <QTimer> #include <QTimer>
#include <QString> #include <QString>
#define MAX_1DPLOTS 10
/** /**
*@short Sets up the plot widget *@short Sets up the plot widget
@ -93,7 +95,7 @@ private:
SlsQt2DPlotLayout* plot2D; SlsQt2DPlotLayout* plot2D;
/** vector of 1D hist values */ /** vector of 1D hist values */
QVector<SlsQtH1D*> plot1D_hists; QVector<SlsQtH1D*> plot1D_hists;
QVector<SlsQtH1D*> cloneplot1D_hists;
/**variables for threads */ /**variables for threads */
/** */ /** */
@ -123,7 +125,7 @@ private:
/** Number of graphs in 1D */ /** Number of graphs in 1D */
unsigned int nHists; unsigned int nHists;
/** Title for all the graphs in 1D */ /** Title for all the graphs in 1D */
std::string histTitle[10]; std::string histTitle[MAX_1DPLOTS];
/** X Axis Title in 1D */ /** X Axis Title in 1D */
QString histXAxisTitle; QString histXAxisTitle;
/** Y Axis Title in 1D */ /** Y Axis Title in 1D */
@ -133,7 +135,7 @@ private:
/** X Axis value in 1D */ /** X Axis value in 1D */
double* histXAxis; double* histXAxis;
/** Y Axis value in 1D */ /** Y Axis value in 1D */
double* histYAxis[10]; double* histYAxis[MAX_1DPLOTS];
/** */ /** */
@ -148,9 +150,9 @@ private:
/** */ /** */
const char* GetImageTitle() {return imageTitle.c_str();} const char* GetImageTitle() {return imageTitle.c_str();}
/** */ /** */
const char* GetHistTitle(int i) {return (i>=0&&i<10) ? histTitle[i].c_str():0;} //int for hist number const char* GetHistTitle(int i) {return (i>=0&&i<MAX_1DPLOTS) ? histTitle[i].c_str():0;} //int for hist number
/** */ /** */
double* GetHistYAxis(int i) {return (i>=0&&i<10) ? histYAxis[i]:0;} //int for hist number double* GetHistYAxis(int i) {return (i>=0&&i<MAX_1DPLOTS) ? histYAxis[i]:0;} //int for hist number
@ -172,7 +174,6 @@ private:
void* AcquireImages(); void* AcquireImages();
public slots: public slots:
/** Set number of measurements /** Set number of measurements
* @param num number of measurements to be set * @param num number of measurements to be set
@ -204,7 +205,10 @@ void ClonePlot();
* */ * */
void CloseClones(); void CloseClones();
/** To Save plot
* @param FName full name of file
* */
void SavePlot(QString FName);
private slots: private slots:
/** To update plot /** To update plot
@ -231,6 +235,7 @@ void InterpolateSignal(bool);
void ContourSignal(bool); void ContourSignal(bool);
void LogzSignal(bool); void LogzSignal(bool);
}; };

View File

@ -85,8 +85,9 @@ void SetTitles();
*/ */
void EnableTitles(); void EnableTitles();
/** Save Plot
*/
void SavePlot();
signals: signals:

View File

@ -10,104 +10,24 @@
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "SlsQt2DPlotLayout.h" #include "SlsQt2DPlotLayout.h"
/** Qt Include Headers */ /** Qt Include Headers */
#include <QFrame> #include <QImage>
#include <QGridLayout> #include <QPainter>
#include <QGroupBox>
/** C++ Include Headers */ /** C++ Include Headers */
#include <iostream> #include <iostream>
#include <string>
#include <QSizePolicy>
using namespace std; using namespace std;
qCloneWidget::qCloneWidget(QWidget *parent,int id,QSize fSize,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D):QMainWindow(parent),id(id){ qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath):QFrame(parent,Qt::Popup|Qt::SubWindow),id(id),filePath(FilePath){
/** Window title*/
char winTitle[100];
sprintf(winTitle,"SLS Detector GUI Clone %d",id);
setWindowTitle(QString(winTitle));
/** Set up widget*/
/* mainLayout = new QGridLayout(this); SetupWidgetWindow(title,numDim,plot1D,plot2D);
setLayout(mainLayout);*/
QGroupBox *cloneBox = new QGroupBox(this);
QGridLayout *gridClone = new QGridLayout(cloneBox);
cloneBox->setLayout(gridClone);
cloneBox->resize(fSize);
cloneBox->setTitle(title);
cloneBox->setAlignment(Qt::AlignHCenter);
cloneBox->setFont(QFont("Sans Serif",11,QFont::Bold));
if(numDim==1){
cloneplot1D = plot1D;
gridClone->addWidget(cloneplot1D,0,0);
cloneBox->setFlat(false);
}else{
cloneplot2D = plot2D;
gridClone->addWidget(cloneplot2D,0,0);
cloneBox->setFlat(true);
}
cloneBox->setCentralWidget();
/*
boxSave = new QGroupBox(this);
layoutSave = new QHBoxLayout;
boxSave->setLayout(layoutSave);
lblFName = new QLabel(layoutSave);
lblFName->setText("File Name:");
layoutSave->addWidget(lblFName);
hLayoutSave = new QHBoxLayout();
hLayoutSave->setSpacing(0);
dispFName = new QLineEdit(layoutSave);
hLayoutSave->addWidget(dispFName);
comboFormat = new QComboBox(layoutSave);
comboFormat->setFrame(true);
comboFormat->insertItem(".gif");
comboFormat->insertItem(".pdf");
comboFormat->insertItem(".png");
comboFormat->insertItem(".gif+");
comboFormat->insertItem(".jpg");
comboFormat->insertItem(".ps");
comboFormat->insertItem(".eps");
comboFormat->insertItem(".xpm");
comboFormat->insertItem(".C");
hLayoutSave->addWidget(comboFormat);
layoutSave->addLayout(hLayoutSave);
btnSave = new QPushButton(layoutSave);
bnSave->setText("Save");
QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy2.setHeightForWidth(btnSave->sizePolicy().hasHeightForWidth());
btnSave->setSizePolicy(sizePolicy2);
btnSave->setFocusPolicy(Qt::NoFocus);
layoutSave->addWidget(btnSave);
chkAutoFName = new QCheckBox(layoutSave);
chkAutoFName->setText("Automatic File Name");
layoutSave->addWidget(chkAutoFName);
chkSaveAll = new QCheckBox(layoutSave);
chkSaveAll->setText("Save All")
layoutSave->addWidget(chkSaveAll);
gridClone->addWidget(boxSave,0,0);
mainLayout->addWidget(boxSave,1,1);*/
/*
mainLayout->addWidget(cloneBox,0,0);*/
} }
@ -115,9 +35,129 @@ qCloneWidget::qCloneWidget(QWidget *parent,int id,QSize fSize,QString title,int
qCloneWidget::~qCloneWidget(){ qCloneWidget::~qCloneWidget(){
delete cloneplot1D; delete cloneplot1D;
delete cloneplot2D; delete cloneplot2D;
delete cloneBox;
delete boxSave;
} }
void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D){
/** Main Window Layout */
mainLayout = new QGridLayout(this);
setLayout(mainLayout);
/** plot group box*/
cloneBox = new QGroupBox(this);
gridClone = new QGridLayout(cloneBox);
cloneBox->setLayout(gridClone);
cloneBox->setContentsMargins(0,0,0,0);
//cloneBox->resize(400,200);
cloneBox->setTitle(title);
cloneBox->setAlignment(Qt::AlignHCenter);
cloneBox->setFont(QFont("Sans Serif",11,QFont::Bold));
/** According to dimensions, create appropriate 1D or 2Dplot */
if(numDim==1){
cloneplot1D = plot1D;
gridClone->addWidget(cloneplot1D,0,0);
cloneBox->setFlat(false);
cloneBox->setContentsMargins(0,30,0,0);
}else{
cloneplot2D = plot2D;
//cloneplot2D->setContentsMargins(0,0,0,0);
gridClone->addWidget(cloneplot2D,0,0);
cloneBox->setFlat(true);
cloneBox->setContentsMargins(0,5,0,0);
}
/** Save group box */
boxSave = new QGroupBox("Save",this);
boxSave->setFixedHeight(45);
boxSave->setContentsMargins(0,8,0,0);
layoutSave = new QHBoxLayout;
boxSave->setLayout(layoutSave);
/** Label file name*/
lblFName = new QLabel("File Name:",this);
layoutSave->addWidget(lblFName);
/** To get 0 spacing between the next 2 widgets file name and file format */
hLayoutSave = new QHBoxLayout();
layoutSave->addLayout(hLayoutSave);
hLayoutSave->setSpacing(0);
/** file name */
dispFName = new QLineEdit(this);
hLayoutSave->addWidget(dispFName);
/** file format */
comboFormat = new QComboBox(this);
comboFormat->setFrame(true);
comboFormat->addItem(".gif");
comboFormat->addItem(".pdf");
comboFormat->addItem(".png");
comboFormat->addItem(".gif+");
comboFormat->addItem(".jpg");
comboFormat->addItem(".ps");
comboFormat->addItem(".eps");
comboFormat->addItem(".xpm");
comboFormat->addItem(".C");
hLayoutSave->addWidget(comboFormat);
/** save button */
btnSave = new QPushButton("Save",this);
btnSave->setFocusPolicy(Qt::NoFocus);
layoutSave->addWidget(btnSave);
/** automatic file name check box */
chkAutoFName = new QCheckBox("Automatic File Name",this);
layoutSave->addWidget(chkAutoFName);
/** automatic save all check box */
chkSaveAll = new QCheckBox("Save All",this);
layoutSave->addWidget(chkSaveAll);
/** main window widgets */
mainLayout->addWidget(boxSave,0,0);
mainLayout->addWidget(cloneBox,1,0);
/** Save */
connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
}
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){
/** for each plot*/
for(int hist_num=0;hist_num<nHists;hist_num++){
/** create hists */
SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){
cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,histYAxis[hist_num]));
k->SetLineColor(hist_num+1);
}else{
k=cloneplot1D_hists.at(hist_num);
k->SetData(histNBins,histXAxis,histYAxis[hist_num]);
}
k->setTitle(histTitle[hist_num].c_str());
k->Attach(cloneplot1D);
}
cloneplot1D->UnZoom();
}
void qCloneWidget::SavePlot(){
QString fName = QString(filePath.c_str())+'/'+dispFName->text()+comboFormat->currentText();
QImage img(cloneBox->size().width(),cloneBox->size().height(),QImage::Format_RGB32);
QPainter painter(&img);
cloneBox->render(&painter);
img.save(fName);
}
void qCloneWidget::closeEvent(QCloseEvent* event){ void qCloneWidget::closeEvent(QCloseEvent* event){
emit CloneClosedSignal(id); emit CloneClosedSignal(id);
event->accept(); event->accept();

View File

@ -82,6 +82,7 @@ void qDetectorMain::SetUpWidgetWindow(){
layoutTabs= new QGridLayout; layoutTabs= new QGridLayout;
centralwidget->setLayout(layoutTabs); centralwidget->setLayout(layoutTabs);
/** plot setup*/ /** plot setup*/
myPlot = new qDrawPlot(dockWidgetPlot,myDet); myPlot = new qDrawPlot(dockWidgetPlot,myDet);
dockWidgetPlot->setWidget(myPlot); dockWidgetPlot->setWidget(myPlot);

View File

@ -14,6 +14,8 @@
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
/** Qt Include Headers */ /** Qt Include Headers */
#include <QFont> #include <QFont>
#include <QImage>
#include <QPainter>
/** C++ Include Headers */ /** C++ Include Headers */
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -60,7 +62,7 @@ void qDrawPlot::SetupWidgetWindow(){
nHists = 0; nHists = 0;
histNBins = 0; histNBins = 0;
histXAxis = 0; histXAxis = 0;
for(int i=0;i<10;i++) histYAxis[i]=0; for(int i=0;i<MAX_1DPLOTS;i++) histYAxis[i]=0;
for(int i=0;i<MAXCloneWindows;i++) winClone[i]=0; for(int i=0;i<MAXCloneWindows;i++) winClone[i]=0;
@ -68,31 +70,53 @@ void qDrawPlot::SetupWidgetWindow(){
/** Setting up window*/ /** Setting up window*/
setFont(QFont("Sans Serif",9)); setFont(QFont("Sans Serif",9));
layout = new QGridLayout; layout = new QGridLayout;
boxPlot = new QGroupBox("Measurement"); this->setLayout(layout);
boxPlot = new QGroupBox("Measurement");
layout->addWidget(boxPlot,1,1);
boxPlot->setAlignment(Qt::AlignHCenter); boxPlot->setAlignment(Qt::AlignHCenter);
boxPlot->setFont(QFont("Sans Serif",11,QFont::Bold)); boxPlot->setFont(QFont("Sans Serif",11,QFont::Bold));
layout->addWidget(boxPlot,1,1);
this->setLayout(layout);
plot_update_timer = new QTimer(this); plot_update_timer = new QTimer(this);
connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot())); connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot()));
/** Defaults - only for the initial picture*/
histXAxisTitle="Channel Number";
histYAxisTitle="Counts";
for(int i=0;i<MAX_1DPLOTS;i++)
histTitle[i].assign("curve"+i);
imageTitle.assign("Start Image");
imageXAxisTitle="Pixel";
imageYAxisTitle="Pixel";
imageZAxisTitle="Intensity";
plot1D = new SlsQt1DPlot(boxPlot); plot1D = new SlsQt1DPlot(boxPlot);
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
plot1D->hide(); plot1D->hide();
plot2D = new SlsQt2DPlotLayout(boxPlot); plot2D = new SlsQt2DPlotLayout(boxPlot);
plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
plot2D->setTitle("Start Image"); plot2D->setTitle(GetImageTitle());
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle);
plot2D->setAlignment(Qt::AlignLeft); plot2D->setAlignment(Qt::AlignLeft);
boxPlot->setFlat(true); boxPlot->setFlat(true);
//QSizePolicy sizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
//boxPlot->setSizePolicy(sizePolicy);
plotLayout = new QGridLayout(boxPlot); plotLayout = new QGridLayout(boxPlot);
plotLayout->addWidget(plot1D,1,1,1,1); plotLayout->addWidget(plot1D,1,1,1,1);
plotLayout->addWidget(plot2D,1,1,1,1); plotLayout->addWidget(plot2D,1,1,1,1);
boxPlot->setContentsMargins(0,15,0,0);
} }
@ -219,7 +243,7 @@ void* qDrawPlot::AcquireImages(){
char cIndex[200]; // char cIndex[200];
//string filePath = myDet->getFilePath()+'/'+myDet->getFileName()+'_'; //string filePath = myDet->getFilePath()+'/'+myDet->getFileName()+'_';
//cout<<"filePath:"<<filePath<<endl; //cout<<"filePath:"<<filePath<<endl;
@ -307,11 +331,16 @@ void qDrawPlot::setNumMeasurements(int num){
void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
if(i==1){ if(i==1){
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
plot1D->show(); plot1D->show();
plot2D->hide(); plot2D->hide();
boxPlot->setFlat(false); boxPlot->setFlat(false);
plot_in_scope=1; plot_in_scope=1;
}else{ }else{
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle);
plot1D->hide(); plot1D->hide();
plot2D->show(); plot2D->show();
boxPlot->setFlat(true); boxPlot->setFlat(true);
@ -391,6 +420,8 @@ void qDrawPlot::StopUpdatePlot(){
/**----------------------------CLONES-------------------------*/
void qDrawPlot::ClonePlot(){ void qDrawPlot::ClonePlot(){
int i=0; int i=0;
@ -405,30 +436,22 @@ void qDrawPlot::ClonePlot(){
exit(-1); exit(-1);
} }
winClone[i] = new qCloneWidget(this,i,boxPlot->size(),boxPlot->title(),(int)plot_in_scope,plot1D,plot2D); winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,myDet->getFilePath());
if(plot_in_scope==1){ if(plot_in_scope==1){
plot1D = new SlsQt1DPlot(boxPlot); plot1D = new SlsQt1DPlot(boxPlot);
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
plotLayout->addWidget(plot1D,1,1,1,1); plotLayout->addWidget(plot1D,1,1,1,1);
/** Somehow the 1d plot hists are lost*/ winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle);
SlsQtH1D* h;
for(int hist_num=0;hist_num<nHists;hist_num++){
SlsQtH1D* k;
if(hist_num+1>cloneplot1D_hists.size()){
cloneplot1D_hists.append(k=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num)));
k->SetLineColor(hist_num+1);
}else{
k=cloneplot1D_hists.at(hist_num);
k->SetData(histNBins,histXAxis,GetHistYAxis(hist_num));
}
k->setTitle(GetHistTitle(hist_num));
k->Attach(winClone[i]->Get1Dplot());
}
winClone[i]->Get1Dplot()->UnZoom();
} }
else{ else{
plot2D = new SlsQt2DPlotLayout(boxPlot); plot2D = new SlsQt2DPlotLayout(boxPlot);
plot2D->setFont(QFont("Sans Serif",9,QFont::Normal)); plot2D->setFont(QFont("Sans Serif",9,QFont::Normal));
plot2D->setTitle(GetImageTitle());
plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle);
plotLayout->addWidget(plot2D,1,1,1,1); plotLayout->addWidget(plot2D,1,1,1,1);
} }
UpdatePlot(); UpdatePlot();
@ -455,3 +478,15 @@ void qDrawPlot::CloneCloseEvent(int id){
#endif #endif
} }
/**----------------------------SAVE-------------------------*/
void qDrawPlot::SavePlot(QString FName){
QImage img(size().width(),size().height(),QImage::Format_RGB32);
QPainter painter(&img);
render(&painter);
img.save(FName);
}

View File

@ -36,6 +36,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot
//This also selects the text if unchecked //This also selects the text if unchecked
//includes setupwidgetwindow //includes setupwidgetwindow
//SelectPlot(1); //SelectPlot(1);
Select1DPlot(false);
Initialization(); Initialization();
} }
} }
@ -65,13 +66,15 @@ void qTabPlot::SetupWidgetWindow(){
dispXMax->setEnabled(false); dispXMax->setEnabled(false);
dispYMax->setEnabled(false); dispYMax->setEnabled(false);
dispZMax->setEnabled(false); dispZMax->setEnabled(false);
//dispFName->setText(QString(myDet->getFilePath().c_str())+'/');
} }
void qTabPlot::Select1DPlot(bool b){ void qTabPlot::Select1DPlot(bool b){
SetupWidgetWindow(); SetupWidgetWindow();
if(b){ if(b){
myPlot->Select1DPlot();
box1D->setEnabled(true); box1D->setEnabled(true);
box2D->setEnabled(false); box2D->setEnabled(false);
chkZAxis->setEnabled(false); chkZAxis->setEnabled(false);
@ -81,8 +84,8 @@ void qTabPlot::Select1DPlot(bool b){
dispXAxis->setText(defaultHistXAxisTitle); dispXAxis->setText(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
dispYAxis->setText(defaultHistYAxisTitle); dispYAxis->setText(defaultHistYAxisTitle);
myPlot->Select1DPlot();
}else{ }else{
myPlot->Select2DPlot();
box1D->setEnabled(false); box1D->setEnabled(false);
box2D->setEnabled(true); box2D->setEnabled(true);
chkZAxis->setEnabled(true); chkZAxis->setEnabled(true);
@ -94,6 +97,7 @@ void qTabPlot::Select1DPlot(bool b){
dispYAxis->setText(defaultImageYAxisTitle); dispYAxis->setText(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle); dispZAxis->setText(defaultImageZAxisTitle);
myPlot->Select2DPlot();
} }
} }
@ -115,9 +119,10 @@ void qTabPlot::Initialization(){
connect(dispXAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles())); connect(dispXAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles())); connect(dispYAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles())); connect(dispZAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
/** Common Buttons*/ /** Common Buttons*/
connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot())); connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot()));
/** Save */
connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
/** test for 1D*/ /** test for 1D*/
connect(chktest1D, SIGNAL(toggled(bool)), this, SLOT(Select1DPlot(bool))); connect(chktest1D, SIGNAL(toggled(bool)), this, SLOT(Select1DPlot(bool)));
@ -194,4 +199,7 @@ void qTabPlot::EnableTitles(){
} }
void qTabPlot::SavePlot(){
QString fullFileName = QString(myDet->getFilePath().c_str())+'/'+dispFName->text()+comboFormat->currentText();
myPlot->SavePlot(fullFileName);
}