mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
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:
parent
216a9ada7c
commit
20cc6d9a90
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>748</width>
|
||||
<width>734</width>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -44,6 +44,29 @@
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -483,7 +483,7 @@
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>551</width>
|
||||
<height>16</height>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
@ -494,11 +494,31 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<zorder>gridLayoutWidget_3</zorder>
|
||||
<zorder>btnClear</zorder>
|
||||
<zorder>gridLayoutWidget_4</zorder>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="boxSave">
|
||||
<property name="geometry">
|
||||
@ -628,9 +648,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>599</x>
|
||||
<y>41</y>
|
||||
<y>10</y>
|
||||
<width>121</width>
|
||||
<height>80</height>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
@ -639,10 +659,10 @@
|
||||
<widget class="QWidget" name="gridLayoutWidget_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>71</height>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
@ -653,7 +673,7 @@
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>-1</number>
|
||||
<number>13</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="btnClone">
|
||||
@ -690,28 +710,6 @@
|
||||
</layout>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -9,63 +9,93 @@
|
||||
#define QCLONEWIDGET_H_
|
||||
|
||||
/** Qt Project Class Headers */
|
||||
class SlsQtH1D;
|
||||
class SlsQt1DPlot;
|
||||
class SlsQt2DPlotLayout;
|
||||
/** Qt Include Headers */
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QCloseEvent>
|
||||
#include <QGroupBox>
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
/** C++ Include Headers */
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
*@short Sets up the clone plot widget
|
||||
*/
|
||||
class qCloneWidget:public QMainWindow{
|
||||
class qCloneWidget:public QFrame{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/** \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
|
||||
*/
|
||||
~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:
|
||||
/** clone window id*/
|
||||
int id;
|
||||
/** clone 1D Plot */
|
||||
SlsQt1DPlot* cloneplot1D;
|
||||
/** Default Save file path */
|
||||
string filePath;
|
||||
|
||||
/** clone 2D Plot */
|
||||
SlsQt2DPlotLayout* cloneplot2D;
|
||||
/** clone 1D Plot */
|
||||
SlsQt1DPlot* cloneplot1D;
|
||||
/** vector of 1D hist values */
|
||||
QVector<SlsQtH1D*> cloneplot1D_hists;
|
||||
|
||||
|
||||
QGridLayout *mainLayout;
|
||||
QGroupBox *boxSave;
|
||||
QWidget *horizontalLayoutWidget;
|
||||
QGroupBox *cloneBox;
|
||||
QGridLayout *gridClone;
|
||||
QGroupBox *boxSave;
|
||||
QHBoxLayout *layoutSave;
|
||||
QLabel *lblFName;
|
||||
QLabel *lblFName;
|
||||
QHBoxLayout *hLayoutSave;
|
||||
QLineEdit *dispFName;
|
||||
QComboBox *comboFormat;
|
||||
QLineEdit *dispFName;
|
||||
QComboBox *comboFormat;
|
||||
QPushButton *btnSave;
|
||||
QCheckBox *chkAutoFName;
|
||||
QCheckBox *chkSaveAll;
|
||||
QCheckBox *chkAutoFName;
|
||||
QCheckBox *chkSaveAll;
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
/** Save Plot */
|
||||
void SavePlot();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
|
@ -23,6 +23,8 @@ class qCloneWidget;
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#define MAX_1DPLOTS 10
|
||||
|
||||
|
||||
/**
|
||||
*@short Sets up the plot widget
|
||||
@ -93,7 +95,7 @@ private:
|
||||
SlsQt2DPlotLayout* plot2D;
|
||||
/** vector of 1D hist values */
|
||||
QVector<SlsQtH1D*> plot1D_hists;
|
||||
QVector<SlsQtH1D*> cloneplot1D_hists;
|
||||
|
||||
|
||||
/**variables for threads */
|
||||
/** */
|
||||
@ -123,7 +125,7 @@ private:
|
||||
/** Number of graphs in 1D */
|
||||
unsigned int nHists;
|
||||
/** Title for all the graphs in 1D */
|
||||
std::string histTitle[10];
|
||||
std::string histTitle[MAX_1DPLOTS];
|
||||
/** X Axis Title in 1D */
|
||||
QString histXAxisTitle;
|
||||
/** Y Axis Title in 1D */
|
||||
@ -133,7 +135,7 @@ private:
|
||||
/** X Axis value in 1D */
|
||||
double* histXAxis;
|
||||
/** 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* 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();
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
/** Set number of measurements
|
||||
* @param num number of measurements to be set
|
||||
@ -204,7 +205,10 @@ void ClonePlot();
|
||||
* */
|
||||
void CloseClones();
|
||||
|
||||
|
||||
/** To Save plot
|
||||
* @param FName full name of file
|
||||
* */
|
||||
void SavePlot(QString FName);
|
||||
|
||||
private slots:
|
||||
/** To update plot
|
||||
@ -231,6 +235,7 @@ void InterpolateSignal(bool);
|
||||
void ContourSignal(bool);
|
||||
void LogzSignal(bool);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -85,8 +85,9 @@ void SetTitles();
|
||||
*/
|
||||
void EnableTitles();
|
||||
|
||||
|
||||
|
||||
/** Save Plot
|
||||
*/
|
||||
void SavePlot();
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -10,104 +10,24 @@
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt2DPlotLayout.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QFrame>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <QSizePolicy>
|
||||
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));
|
||||
|
||||
|
||||
/* mainLayout = new QGridLayout(this);
|
||||
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);*/
|
||||
/** Set up widget*/
|
||||
SetupWidgetWindow(title,numDim,plot1D,plot2D);
|
||||
|
||||
}
|
||||
|
||||
@ -115,9 +35,129 @@ qCloneWidget::qCloneWidget(QWidget *parent,int id,QSize fSize,QString title,int
|
||||
qCloneWidget::~qCloneWidget(){
|
||||
delete cloneplot1D;
|
||||
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){
|
||||
emit CloneClosedSignal(id);
|
||||
event->accept();
|
||||
|
@ -82,6 +82,7 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
layoutTabs= new QGridLayout;
|
||||
centralwidget->setLayout(layoutTabs);
|
||||
|
||||
|
||||
/** plot setup*/
|
||||
myPlot = new qDrawPlot(dockWidgetPlot,myDet);
|
||||
dockWidgetPlot->setWidget(myPlot);
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "multiSlsDetector.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -60,7 +62,7 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
nHists = 0;
|
||||
histNBins = 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;
|
||||
|
||||
@ -68,31 +70,53 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
/** Setting up window*/
|
||||
setFont(QFont("Sans Serif",9));
|
||||
layout = new QGridLayout;
|
||||
boxPlot = new QGroupBox("Measurement");
|
||||
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);
|
||||
this->setLayout(layout);
|
||||
|
||||
plot_update_timer = new QTimer(this);
|
||||
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->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("Start Image");
|
||||
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);
|
||||
|
||||
plotLayout = new QGridLayout(boxPlot);
|
||||
plotLayout->addWidget(plot1D,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()+'_';
|
||||
//cout<<"filePath:"<<filePath<<endl;
|
||||
@ -307,11 +331,16 @@ void qDrawPlot::setNumMeasurements(int num){
|
||||
|
||||
void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
|
||||
if(i==1){
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
plot1D->show();
|
||||
plot2D->hide();
|
||||
boxPlot->setFlat(false);
|
||||
plot_in_scope=1;
|
||||
}else{
|
||||
plot2D->SetXTitle(imageXAxisTitle);
|
||||
plot2D->SetYTitle(imageYAxisTitle);
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot1D->hide();
|
||||
plot2D->show();
|
||||
boxPlot->setFlat(true);
|
||||
@ -391,6 +420,8 @@ void qDrawPlot::StopUpdatePlot(){
|
||||
|
||||
|
||||
|
||||
/**----------------------------CLONES-------------------------*/
|
||||
|
||||
|
||||
void qDrawPlot::ClonePlot(){
|
||||
int i=0;
|
||||
@ -405,30 +436,22 @@ void qDrawPlot::ClonePlot(){
|
||||
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){
|
||||
plot1D = new SlsQt1DPlot(boxPlot);
|
||||
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);
|
||||
/** Somehow the 1d plot hists are lost*/
|
||||
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();
|
||||
winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle);
|
||||
}
|
||||
else{
|
||||
plot2D = new SlsQt2DPlotLayout(boxPlot);
|
||||
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);
|
||||
}
|
||||
UpdatePlot();
|
||||
@ -455,3 +478,15 @@ void qDrawPlot::CloneCloseEvent(int id){
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**----------------------------SAVE-------------------------*/
|
||||
void qDrawPlot::SavePlot(QString FName){
|
||||
QImage img(size().width(),size().height(),QImage::Format_RGB32);
|
||||
QPainter painter(&img);
|
||||
render(&painter);
|
||||
img.save(FName);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot
|
||||
//This also selects the text if unchecked
|
||||
//includes setupwidgetwindow
|
||||
//SelectPlot(1);
|
||||
Select1DPlot(false);
|
||||
Initialization();
|
||||
}
|
||||
}
|
||||
@ -65,13 +66,15 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
dispXMax->setEnabled(false);
|
||||
dispYMax->setEnabled(false);
|
||||
dispZMax->setEnabled(false);
|
||||
|
||||
//dispFName->setText(QString(myDet->getFilePath().c_str())+'/');
|
||||
|
||||
}
|
||||
|
||||
|
||||
void qTabPlot::Select1DPlot(bool b){
|
||||
SetupWidgetWindow();
|
||||
if(b){
|
||||
myPlot->Select1DPlot();
|
||||
box1D->setEnabled(true);
|
||||
box2D->setEnabled(false);
|
||||
chkZAxis->setEnabled(false);
|
||||
@ -81,8 +84,8 @@ void qTabPlot::Select1DPlot(bool b){
|
||||
dispXAxis->setText(defaultHistXAxisTitle);
|
||||
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
|
||||
dispYAxis->setText(defaultHistYAxisTitle);
|
||||
myPlot->Select1DPlot();
|
||||
}else{
|
||||
myPlot->Select2DPlot();
|
||||
box1D->setEnabled(false);
|
||||
box2D->setEnabled(true);
|
||||
chkZAxis->setEnabled(true);
|
||||
@ -94,6 +97,7 @@ void qTabPlot::Select1DPlot(bool b){
|
||||
dispYAxis->setText(defaultImageYAxisTitle);
|
||||
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
|
||||
dispZAxis->setText(defaultImageZAxisTitle);
|
||||
myPlot->Select2DPlot();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,12 +119,13 @@ void qTabPlot::Initialization(){
|
||||
connect(dispXAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
|
||||
connect(dispYAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
|
||||
connect(dispZAxis, SIGNAL(returnPressed()), this, SLOT(SetTitles()));
|
||||
|
||||
/** 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*/
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user