mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 17:18:00 +02:00
no plot histogram, messages work
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@16 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
@ -141,7 +141,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,double* histYAxis[],string histTitle[]){
|
||||
/** for each plot*/
|
||||
/** for each plot*/cout<<"qclone nhists:"<<nHists<<endl;
|
||||
for(int hist_num=0;hist_num<nHists;hist_num++){
|
||||
/** create hists */
|
||||
SlsQtH1D* k;
|
||||
@ -183,11 +183,12 @@ void qCloneWidget::SavePlot(){
|
||||
QPainter painter(&img);
|
||||
cloneBox->render(&painter);
|
||||
|
||||
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),
|
||||
fName,tr("Images (*.png *.xpm *.jpg)"));
|
||||
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("Images (*.png *.xpm *.jpg)"),0,QFileDialog::ShowDirsOnly);
|
||||
if (!fName.isEmpty())
|
||||
if(!(img.save(fName)))
|
||||
qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed","Snapshot: WARNING");
|
||||
if((img.save(fName)))
|
||||
qDefs::InfoMessage("The SnapShot has been successfully saved","Snapshot: Information");
|
||||
else
|
||||
qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed. Wrong Format","Snapshot: WARNING");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "sls_detector_defs.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QSizePolicy>
|
||||
#include <QFileDialog>
|
||||
/** C++ Include Headers */
|
||||
#include<iostream>
|
||||
#include <string>
|
||||
@ -25,6 +26,7 @@ using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
QApplication *theApp = new QApplication(argc, argv);
|
||||
@ -35,8 +37,10 @@ int main (int argc, char **argv) {
|
||||
return theApp->exec();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) :
|
||||
QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){
|
||||
|
||||
@ -61,23 +65,26 @@ qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qDetectorMain::~qDetectorMain(){
|
||||
delete myDet;
|
||||
if (menubar) delete menubar;
|
||||
if (centralwidget) delete centralwidget;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::SetUpWidgetWindow(){
|
||||
|
||||
/** Layout */
|
||||
layoutTabs= new QGridLayout;
|
||||
centralwidget->setLayout(layoutTabs);
|
||||
|
||||
|
||||
/** plot setup*/
|
||||
myPlot = new qDrawPlot(dockWidgetPlot,myDet);
|
||||
dockWidgetPlot->setWidget(myPlot);
|
||||
@ -86,6 +93,7 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
tabs = new MyTabWidget(this);
|
||||
layoutTabs->addWidget(tabs);
|
||||
/** creating all the tab widgets */
|
||||
tab_messages = new qTabMessages (this, myDet);
|
||||
tab_measurement = new qTabMeasurement (this, myDet,myPlot);
|
||||
tab_dataoutput = new qTabDataOutput (this, myDet);
|
||||
tab_plot = new qTabPlot (this, myDet,myPlot);
|
||||
@ -94,7 +102,6 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
tab_advanced = new qTabAdvanced (this, myDet);
|
||||
tab_debugging = new qTabDebugging (this, myDet);
|
||||
tab_developer = new qTabDeveloper (this, myDet);
|
||||
tab_messages = new qTabMessages (this, myDet);
|
||||
/** creating the scroll area widgets for the tabs */
|
||||
for(int i=0;i<NumberOfTabs;i++){
|
||||
scroll[i] = new QScrollArea;
|
||||
@ -109,8 +116,6 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
scroll[Advanced] ->setWidget(tab_advanced);
|
||||
scroll[Debugging] ->setWidget(tab_debugging);
|
||||
scroll[Developer] ->setWidget(tab_developer);
|
||||
|
||||
|
||||
/** inserting all the tabs*/
|
||||
tabs->insertTab(Measurement, scroll[Measurement], "Measurement");
|
||||
tabs->insertTab(DataOutput, scroll[DataOutput], "Data Output");
|
||||
@ -122,21 +127,38 @@ void qDetectorMain::SetUpWidgetWindow(){
|
||||
tabs->insertTab(Developer, scroll[Developer], "Developer");
|
||||
/** Prefer this to expand and not have scroll buttons*/
|
||||
tabs->insertTab(Messages, tab_messages, "Messages");
|
||||
/** Default tab color*/
|
||||
defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput);
|
||||
/**Set the current tab(measurement) to blue as it is the current one*/
|
||||
tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255));
|
||||
/** increase the width so it uses all the empty space for the tab titles*/
|
||||
tabs->tabBar()->setFixedWidth(width()+61);
|
||||
|
||||
/** mode setup - to set up the tabs initially as disabled, not in form so done here */
|
||||
SetDebugMode(false);
|
||||
SetBeamlineMode(false);
|
||||
SetExpertMode(false);
|
||||
SetDeveloperMode(false);
|
||||
SetDeveloperMode(isDeveloper);
|
||||
|
||||
tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255));
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Debug Mode to 0\nSetting Beamline Mode to 0\n"
|
||||
"Setting Expert Mode to 0\nSetting Dockable Mode to false\n"
|
||||
"Setting Developer Mode to "<<isDeveloper<<endl;
|
||||
#endif
|
||||
tabs->setTabEnabled(Debugging,false);
|
||||
//beamline mode to false
|
||||
tabs->setTabEnabled(Advanced,false);
|
||||
dockWidgetPlot->setFloating(false);
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
tabs->setTabEnabled(Developer,isDeveloper);
|
||||
|
||||
/** Other setup*/
|
||||
/**Height of plot and central widget*/
|
||||
heightPlotWindow = dockWidgetPlot->size().height();
|
||||
heightCentralWidget = centralwidget->size().height();
|
||||
/** Default zoom Tool Tip */
|
||||
zoomToolTip = dockWidgetPlot->toolTip();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::SetUpDetector(){
|
||||
|
||||
|
||||
@ -178,14 +200,16 @@ void qDetectorMain::SetUpDetector(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::Initialization(){
|
||||
/** Dockable Plot*/
|
||||
connect(dockWidgetPlot,SIGNAL(topLevelChanged(bool)),this,SLOT(ResizeMainWindow(bool)));
|
||||
|
||||
/** tabs */
|
||||
connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(refresh(int)));//( QWidget*)));
|
||||
connect(tabs,SIGNAL(currentChanged(int)),this, SLOT(Refresh(int)));//( QWidget*)));
|
||||
/** Measurement tab*/
|
||||
/** Plot tab */
|
||||
connect(tab_plot,SIGNAL(DisableZoomSignal(bool)),this, SLOT(SetZoomToolTip(bool)));
|
||||
@ -200,166 +224,187 @@ void qDetectorMain::Initialization(){
|
||||
|
||||
/** menubar */
|
||||
/** Modes Menu */
|
||||
connect(actionDebug, SIGNAL(toggled(bool)),this,SLOT(SetDebugMode(bool)));
|
||||
connect(actionBeamline, SIGNAL(toggled(bool)),this,SLOT(SetBeamlineMode(bool)));
|
||||
connect(actionExpert, SIGNAL(toggled(bool)),this,SLOT(SetExpertMode(bool)));
|
||||
connect(actionDockable, SIGNAL(toggled(bool)),this,SLOT(SetDockableMode(bool)));
|
||||
|
||||
|
||||
connect(menuModes,SIGNAL(triggered(QAction*)),SLOT(EnableModes(QAction*)));
|
||||
/** Utilities Menu */
|
||||
connect(actionOpenSetup,SIGNAL(triggered()),this,SLOT(OpenSetup()));
|
||||
connect(actionSaveSetup,SIGNAL(triggered()),this,SLOT(SaveSetup()));
|
||||
connect(actionMeasurementWizard,SIGNAL(triggered()),this,SLOT(MeasurementWizard()));
|
||||
connect(actionOpenConfiguration,SIGNAL(triggered()),this,SLOT(OpenConfiguration()));
|
||||
connect(actionSaveConfiguration,SIGNAL(triggered()),this,SLOT(SaveConfiguration()));
|
||||
connect(actionEnergyCalibration,SIGNAL(triggered()),this,SLOT(EnergyCalibration()));
|
||||
connect(actionAngularCalibration,SIGNAL(triggered()),this,SLOT(AngularCalibration()));
|
||||
connect(actionAbout,SIGNAL(triggered()),this,SLOT(About()));
|
||||
connect(actionVersion,SIGNAL(triggered()),this,SLOT(Version()));
|
||||
|
||||
heightPlotWindow = dockWidgetPlot->size().height();
|
||||
heightCentralWidget = centralwidget->size().height();
|
||||
|
||||
defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput);
|
||||
zoomToolTip = dockWidgetPlot->toolTip();
|
||||
connect(menuUtilities,SIGNAL(triggered(QAction*)),SLOT(ExecuteUtilities(QAction*)));
|
||||
/** Help Menu */
|
||||
connect(menuHelp,SIGNAL(triggered(QAction*)),SLOT(ExecuteHelp(QAction*)));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SetDeveloperMode(bool b){
|
||||
|
||||
void qDetectorMain::EnableModes(QAction *action){
|
||||
bool enable;
|
||||
|
||||
/**Set DebugMode */
|
||||
if(action==actionDebug){
|
||||
enable = actionDebug->isChecked();
|
||||
tabs->setTabEnabled(Debugging,enable);
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Developer Mode to "<<b<<endl;
|
||||
cout<<"Setting Debug Mode to "<<enable<<endl;
|
||||
#endif
|
||||
tabs->setTabEnabled(Developer,b);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SetDebugMode(bool b){
|
||||
/**Set BeamlineMode */
|
||||
else if(action==actionBeamline){
|
||||
enable = actionBeamline->isChecked();
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Debug Mode to "<<b<<endl;
|
||||
cout<<"Setting Beamline Mode to "<<enable<<endl;
|
||||
#endif
|
||||
tabs->setTabEnabled(Debugging,b);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SetBeamlineMode(bool b){
|
||||
/**Set ExpertMode */
|
||||
else if(action==actionExpert){
|
||||
enable = actionExpert->isChecked();
|
||||
tabs->setTabEnabled(Advanced,enable);
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Beamline Mode to "<<b<<endl;
|
||||
cout<<"Setting Expert Mode to "<<enable<<endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SetExpertMode(bool b){
|
||||
/**Set DockableMode */
|
||||
else{
|
||||
enable = actionDockable->isChecked();
|
||||
if(enable)
|
||||
dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable);
|
||||
else{
|
||||
dockWidgetPlot->setFloating(false);
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Expert Mode to "<<b<<endl;
|
||||
cout<<"Setting Dockable Mode to "<<enable<<endl;
|
||||
#endif
|
||||
tabs->setTabEnabled(Advanced,b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::refresh(int index){
|
||||
|
||||
void qDetectorMain::ExecuteUtilities(QAction *action){
|
||||
|
||||
if(action==actionOpenSetup){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Opening Setup"<<endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
fName = QFileDialog::getOpenFileName(this,
|
||||
tr("Load Detector Setup"),fName,
|
||||
tr("Detector Setup files (*.det)"));
|
||||
/** Gets called when cancelled as well*/
|
||||
if (!fName.isEmpty()){
|
||||
myDet->retrieveDetectorSetup(string(fName.toAscii().constData()));
|
||||
qDefs::InfoMessage("The parameters have been successfully setup.","Main: Information");
|
||||
}
|
||||
}
|
||||
else if(action==actionSaveSetup){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Saving Setup"<<endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
fName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save Current Detector Setup"),fName,
|
||||
tr("Detector Setup files (*.det) "));
|
||||
/** Gets called when cancelled as well*/
|
||||
if (!fName.isEmpty()){
|
||||
myDet->dumpDetectorSetup(string(fName.toAscii().constData()));
|
||||
qDefs::InfoMessage("The setup parameters have been successfully saved.","Main: Information");
|
||||
}
|
||||
}
|
||||
else if(action==actionMeasurementWizard){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Measurement Wizard"<<endl;
|
||||
#endif
|
||||
}
|
||||
else if(action==actionOpenConfiguration){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Opening Configuration"<<endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
fName = QFileDialog::getOpenFileName(this,
|
||||
tr("Load Detector Configuration"),fName,
|
||||
tr("Configuration files (*.config)"));
|
||||
/** Gets called when cancelled as well*/
|
||||
if (!fName.isEmpty()){
|
||||
myDet->readConfigurationFile(string(fName.toAscii().constData()));
|
||||
qDefs::InfoMessage("The parameters have been successfully configured.","Main: Information");
|
||||
}
|
||||
}
|
||||
else if(action==actionSaveConfiguration){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Saving Configuration"<<endl;
|
||||
#endif
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
fName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save Current Detector Configuration"),fName,
|
||||
tr("Configuration files (*.config) "));
|
||||
/** Gets called when cancelled as well*/
|
||||
if (!fName.isEmpty()){
|
||||
myDet->writeConfigurationFile(string(fName.toAscii().constData()));
|
||||
qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main: Information");
|
||||
}
|
||||
}
|
||||
else if(action==actionEnergyCalibration){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing Energy Calibration"<<endl;
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing Angular Calibration"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
Refresh(tabs->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::ExecuteHelp(QAction *action){
|
||||
if(action==actionVersion){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Version"<<endl;
|
||||
#endif
|
||||
}
|
||||
else{
|
||||
#ifdef VERBOSE
|
||||
cout<<"About"<<endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::Refresh(int index){
|
||||
if(!tabs->isTabEnabled(index))
|
||||
tabs->setCurrentIndex((index++)<(tabs->count()-1)?index:Measurement);
|
||||
else{
|
||||
;
|
||||
switch(tabs->currentIndex()){
|
||||
case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break;
|
||||
case Settings: tab_settings->Refresh(); break;
|
||||
case DataOutput: tab_dataoutput->Refresh(); break;
|
||||
case Plot: break;
|
||||
case Actions: tab_actions->Refresh(); break;
|
||||
case Advanced: tab_advanced->Refresh(); break;
|
||||
case Debugging: tab_debugging->Refresh(); break;
|
||||
case Developer: tab_developer->Refresh(); break;
|
||||
case Messages: break;
|
||||
}
|
||||
}
|
||||
for(int i=0;i<NumberOfTabs;i++)
|
||||
tabs->tabBar()->setTabTextColor(i,defaultTabColor);
|
||||
tabs->tabBar()->setTabTextColor(index,QColor(0,0,200,255));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SetDockableMode(bool b){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Dockable Mode to "<<b<<endl;
|
||||
#endif
|
||||
if(b)
|
||||
dockWidgetPlot->setFeatures(QDockWidget::DockWidgetFloatable);
|
||||
else{
|
||||
dockWidgetPlot->setFloating(false);
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::OpenSetup(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Opening Setup"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SaveSetup(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Saving Setup"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::MeasurementWizard(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Measurement Wizard"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::OpenConfiguration(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Opening Configuration"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::SaveConfiguration(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Saving Configuration"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::EnergyCalibration(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing Energy Calibration"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::AngularCalibration(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing Angular Calibration"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::Version(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing Version"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::About(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Executing About"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDetectorMain::ResizeMainWindow(bool b){
|
||||
#ifdef VERBOSE
|
||||
@ -379,6 +424,9 @@ void qDetectorMain::ResizeMainWindow(bool b){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::resizeEvent(QResizeEvent* event){
|
||||
if(!dockWidgetPlot->isFloating()){
|
||||
if(tabs->currentIndex()== Actions){
|
||||
@ -394,8 +442,10 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qDetectorMain::EnableTabs(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Entering EnableTabs function"<<endl;
|
||||
@ -427,6 +477,7 @@ void qDetectorMain::EnableTabs(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -437,4 +488,5 @@ void qDetectorMain::SetZoomToolTip(bool disable){
|
||||
dockWidgetPlot->setToolTip(zoomToolTip);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -7,6 +7,8 @@
|
||||
/** Qt Project Class Headers */
|
||||
#include "qDrawPlot.h"
|
||||
#include "qCloneWidget.h"
|
||||
#include "qDefs.h"
|
||||
#include "slsDetector.h"
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
@ -15,6 +17,7 @@
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QFileDialog>
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -22,7 +25,6 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
|
||||
@ -73,6 +75,9 @@ void qDrawPlot::SetupWidgetWindow(){
|
||||
currentPersistency = 0;
|
||||
progress = 0;
|
||||
plotEnable=true;
|
||||
plotExists=false;
|
||||
/** This is so that it initially stop and plots */
|
||||
running = 1;
|
||||
for(int i=0;i<MAX_1DPLOTS;i++) {histYAxis[i]=0;yvalues[i]=0; }
|
||||
|
||||
/*clone*/
|
||||
@ -144,9 +149,9 @@ void qDrawPlot::Initialization(){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
|
||||
static bool running = 1;
|
||||
//static bool running = 1;
|
||||
if(running){ //stopping
|
||||
StartDaq(0);
|
||||
StartDaq(false);
|
||||
running=!running;
|
||||
}else if(!stop_if_running){ //then start
|
||||
|
||||
@ -199,6 +204,7 @@ int qDrawPlot::ResetDaqForGui(){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
bool qDrawPlot::StartOrStopThread(bool start){
|
||||
static bool firstTime = true;
|
||||
static bool gui_acquisition_thread_running = 0;
|
||||
static pthread_t gui_acquisition_thread;
|
||||
static pthread_mutex_t gui_acquisition_start_stop_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -207,13 +213,13 @@ bool qDrawPlot::StartOrStopThread(bool start){
|
||||
//stop part, before start or restart
|
||||
if(gui_acquisition_thread_running){
|
||||
cout<<"Stopping current acquisition thread ...."<<endl;
|
||||
stop_signal = 1;//sort of useless
|
||||
pthread_join(gui_acquisition_thread,NULL); //wait until he's finished, ie. exits
|
||||
stop_signal = 1;//sorta useless right now
|
||||
gui_acquisition_thread_running = 0;
|
||||
}
|
||||
|
||||
//start part
|
||||
if(start){
|
||||
|
||||
/** Defaults */
|
||||
progress = 0;
|
||||
currentFrame = 0;
|
||||
@ -232,12 +238,14 @@ bool qDrawPlot::StartOrStopThread(bool start){
|
||||
/** Setting the callback function to get data from software client*/
|
||||
myDet->registerDataCallback(&(GetDataCallBack),this);
|
||||
/** Start acquiring data from server */
|
||||
if(!firstTime) pthread_join(gui_acquisition_thread,NULL);//wait until he's finished, ie. exits
|
||||
pthread_create(&gui_acquisition_thread, NULL,DataStartAcquireThread, (void*) this);
|
||||
firstTime = false;
|
||||
/** This is set here and later reset to zero when all the plotting is done
|
||||
* This is manually done instead of keeping track of thread because
|
||||
* this thread returns immediately after executing the acquire command*/
|
||||
gui_acquisition_thread_running=1;
|
||||
cout<<"Started acquiring threaddd"<<endl;
|
||||
cout<<"Started acquiring threaddd:"<<endl;
|
||||
}
|
||||
pthread_mutex_unlock(&gui_acquisition_start_stop_mutex);
|
||||
return gui_acquisition_thread_running;
|
||||
@ -262,9 +270,9 @@ int qDrawPlot::GetDataCallBack(detectorData *data, void *this_pointer){
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
int qDrawPlot::GetData(detectorData *data){
|
||||
//#ifdef VERYVERBOSE
|
||||
#ifdef VERYVERBOSE
|
||||
cout<<"Entering GetDatafunction"<<endl;
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
progress=(int)data->progressIndex;
|
||||
|
||||
@ -332,6 +340,9 @@ int qDrawPlot::GetData(detectorData *data){
|
||||
|
||||
void qDrawPlot::setNumMeasurements(int num){
|
||||
number_of_measurements = num;
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting Number of Measurements to " <<num<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -366,7 +377,6 @@ void qDrawPlot::Clear1DPlot(){
|
||||
|
||||
void qDrawPlot::UpdatePlot(){
|
||||
//static int last_plot_number = 0;
|
||||
|
||||
plot_update_timer->stop();
|
||||
if(plotEnable){
|
||||
LockLastImageArray();
|
||||
@ -392,6 +402,8 @@ void qDrawPlot::UpdatePlot(){
|
||||
h->Attach(plot1D);
|
||||
|
||||
}
|
||||
/**plot exists is false in the beginning, right after cloning and when no plot is checked*/
|
||||
plotExists=true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,14 +419,15 @@ void qDrawPlot::UpdatePlot(){
|
||||
plot2D->SetZTitle(imageZAxisTitle);
|
||||
plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update();
|
||||
}
|
||||
/**plot exists is false in the beginning, right after cloning and when no plot is checked*/
|
||||
plotExists=true;
|
||||
}
|
||||
}
|
||||
last_plot_number=lastImageNumber;
|
||||
|
||||
if(plotEnable) UnlockLastImageArray();
|
||||
|
||||
/** Measurement not over, continue*/
|
||||
if(number_of_exposures!=last_plot_number){
|
||||
if(number_of_exposures!=currentFrame){//las plot number?
|
||||
plot_update_timer->start(500);
|
||||
}
|
||||
/** if a measurement is over */
|
||||
@ -428,7 +441,6 @@ void qDrawPlot::UpdatePlot(){
|
||||
}/** To start the next measurement*/
|
||||
else{
|
||||
StopDaqForGui();
|
||||
//StartDaq(false);
|
||||
StartDaq(true);
|
||||
}
|
||||
}
|
||||
@ -457,7 +469,10 @@ void qDrawPlot::ClonePlot(){
|
||||
}
|
||||
/** save height to keep maintain same height of plot */
|
||||
int preheight = height();
|
||||
|
||||
/** create clone */
|
||||
/** plotexists is true after calling updateplot*/
|
||||
plotExists=false;
|
||||
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);
|
||||
@ -465,7 +480,7 @@ void qDrawPlot::ClonePlot(){
|
||||
plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
|
||||
plot1D->SetYTitle(histYAxisTitle.toAscii().constData());
|
||||
plotLayout->addWidget(plot1D,1,1,1,1);
|
||||
winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle);
|
||||
if(running) winClone[i]->SetCloneHists((int)nHists,histNBins,histXAxis,histYAxis,histTitle);
|
||||
}
|
||||
else{
|
||||
plot2D = new SlsQt2DPlotLayout(boxPlot);
|
||||
@ -478,8 +493,9 @@ void qDrawPlot::ClonePlot(){
|
||||
}
|
||||
setMinimumHeight(preheight);
|
||||
resize(width(),preheight);
|
||||
/** update the actual plot */
|
||||
UpdatePlot();
|
||||
|
||||
/** update the actual plot only if running, else it doesnt know when its over*/
|
||||
if(running) 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)));
|
||||
@ -509,11 +525,21 @@ void qDrawPlot::CloneCloseEvent(int id){
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qDrawPlot::SavePlot(QString FName){
|
||||
void qDrawPlot::SavePlot(){
|
||||
/** render image */
|
||||
QImage img(size().width(),size().height(),QImage::Format_RGB32);
|
||||
QPainter painter(&img);
|
||||
render(&painter);
|
||||
img.save(FName);
|
||||
|
||||
/** save image*/
|
||||
QString fName = QString(myDet->getFilePath().c_str())+"/Image.png";
|
||||
fName = QFileDialog::getSaveFileName(this,tr("Save Image"),fName,tr("Images (*.png *.xpm *.jpg)"));
|
||||
if (!fName.isEmpty())
|
||||
if(img.save(fName))
|
||||
qDefs::InfoMessage("The Image has been successfully saved","Dock: Information");
|
||||
else
|
||||
qDefs::ErrorMessage("ERROR: Attempt to save image failed. Wrong Format","Dock: WARNING");
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -532,7 +558,10 @@ void qDrawPlot::EnablePlot(bool enable){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Plotting set to:"<<enable<<endl;
|
||||
#endif
|
||||
plotEnable = !enable;
|
||||
plotEnable = enable;
|
||||
/**if no plot, cant do setting range.
|
||||
* not true vice versa where plot was false and now set it to true*/
|
||||
if(!enable) plotExists=false;
|
||||
Clear1DPlot();
|
||||
|
||||
}
|
||||
|
@ -232,4 +232,11 @@ void qTabActions::ChangeStepSize(bool b){
|
||||
|
||||
//if(!QString::compare(btntry->text(),"+")){
|
||||
*/
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabActions::Refresh(){
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -76,4 +76,13 @@ void qTabAdvanced::getTemperature(){
|
||||
#endif
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabAdvanced::Refresh(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
using namespace std;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector):
|
||||
@ -27,6 +28,7 @@ qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector):
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qTabDataOutput::~qTabDataOutput(){
|
||||
@ -34,14 +36,16 @@ qTabDataOutput::~qTabDataOutput(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDataOutput::SetupWidgetWindow(){
|
||||
outputDir= QString(myDet->getFilePath().c_str());
|
||||
dispOutputDir->setText(outputDir);
|
||||
dispOutputDir->setText(QString(myDet->getFilePath().c_str()));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDataOutput::Initialization(){
|
||||
connect(dispOutputDir, SIGNAL(textChanged(const QString&)), this, SLOT(setOutputDir(const QString&)));
|
||||
@ -49,22 +53,29 @@ void qTabDataOutput::Initialization(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qTabDataOutput::Enable(bool enable){
|
||||
layoutOutput->setEnabled(enable);
|
||||
boxCorrection->setEnabled(enable);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDataOutput::setOutputDir(const QString& path){
|
||||
outputDir = path;
|
||||
myDet->setFilePath(string(outputDir.toAscii().constData()));
|
||||
myDet->setFilePath(string(path.toAscii().constData()));
|
||||
#ifdef VERBOSE
|
||||
cout<<"Output Directory changed to :"<<myDet->getFilePath()<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDataOutput::Refresh(){
|
||||
/** output dir*/
|
||||
dispOutputDir->setText(QString(myDet->getFilePath().c_str()));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDataOutput::browseOutputDir()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text());
|
||||
@ -73,3 +84,4 @@ void qTabDataOutput::browseOutputDir()
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -48,3 +48,13 @@ void qTabDebugging::Enable(bool enable){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDebugging::Refresh(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -41,5 +41,14 @@ void qTabDeveloper::SetupWidgetWindow(){
|
||||
void qTabDeveloper::Initialization(){
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabDeveloper::Refresh(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -302,7 +302,7 @@ void qTabMeasurement::setExposureTime(){
|
||||
/** Get the value of timer in ns **/
|
||||
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value());
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting acquisition time to " << exptimeNS << " clocks" << endl;
|
||||
cout<<"Setting acquisition time to " << exptimeNS << " clocks" << "/"<<spinExpTime->value()<<qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex())<<endl;
|
||||
#endif
|
||||
myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,exptimeNS);
|
||||
|
||||
@ -312,12 +312,12 @@ void qTabMeasurement::setExposureTime(){
|
||||
if(exptimeNS>acqtimeNS) {
|
||||
lblNote->show();
|
||||
lblPeriod->setPalette(lblNote->palette());
|
||||
lblPeriod->setText("* Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:*");
|
||||
}
|
||||
else {
|
||||
lblNote->hide();
|
||||
lblPeriod->setPalette(lblNumFrames->palette());
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -329,7 +329,7 @@ void qTabMeasurement::setAcquisitionPeriod(){
|
||||
/** Get the value of timer in ns **/
|
||||
acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value());
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks" << endl;
|
||||
cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/"<<spinPeriod->value()<<qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex())<<endl;
|
||||
#endif
|
||||
myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,acqtimeNS);
|
||||
|
||||
@ -338,12 +338,12 @@ void qTabMeasurement::setAcquisitionPeriod(){
|
||||
if(exptimeNS>acqtimeNS){
|
||||
lblNote->show();
|
||||
lblPeriod->setPalette(lblNote->palette());
|
||||
lblPeriod->setText("* Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:*");
|
||||
}
|
||||
else {
|
||||
lblNote->hide();
|
||||
lblPeriod->setPalette(lblNumFrames->palette());
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:");
|
||||
}
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ void qTabMeasurement::setDelay(){
|
||||
/** Get the value of timer in ns **/
|
||||
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value());
|
||||
#ifdef VERBOSE
|
||||
cout<<"Setting delay after trigger to " << exptimeNS << " clocks" << endl;
|
||||
cout<<"Setting delay after trigger to " << exptimeNS << " clocks"<< "/"<<spinDelay->value()<<qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex())<<endl;
|
||||
#endif
|
||||
myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,exptimeNS);
|
||||
}
|
||||
@ -496,7 +496,7 @@ void qTabMeasurement::setTimingMode(int mode){
|
||||
if(lblExpTime->isEnabled()){
|
||||
time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9))));
|
||||
#ifdef VERBOSE
|
||||
cout<<"Getting acquisition time : " << time << "s" << endl;
|
||||
cout<<"Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl;
|
||||
#endif
|
||||
spinExpTime->setValue(time);
|
||||
comboExpUnit->setCurrentIndex((int)unit);
|
||||
@ -506,7 +506,7 @@ void qTabMeasurement::setTimingMode(int mode){
|
||||
if(lblPeriod->isEnabled()){
|
||||
time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9))));
|
||||
#ifdef VERBOSE
|
||||
cout<<"Getting frame period between exposures : " << time << "s" << endl;
|
||||
cout<<"Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl;
|
||||
#endif
|
||||
spinPeriod->setValue(time);
|
||||
comboPeriodUnit->setCurrentIndex((int)unit);
|
||||
@ -517,17 +517,17 @@ void qTabMeasurement::setTimingMode(int mode){
|
||||
if(exptimeNS>acqtimeNS) {
|
||||
lblNote->show();
|
||||
lblPeriod->setPalette(lblNote->palette());
|
||||
lblPeriod->setText("* Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:*");
|
||||
}
|
||||
else {
|
||||
lblNote->hide();
|
||||
lblPeriod->setPalette(lblNumFrames->palette());
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:");
|
||||
}
|
||||
}else {
|
||||
lblNote->hide();
|
||||
lblPeriod->setPalette(lblNumFrames->palette());
|
||||
lblPeriod->setText("Acquisition Period");
|
||||
lblPeriod->setText("Acquisition Period:");
|
||||
}
|
||||
|
||||
/**Number of Triggers */
|
||||
@ -543,7 +543,7 @@ void qTabMeasurement::setTimingMode(int mode){
|
||||
if(lblDelay->isEnabled()){
|
||||
time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9))));
|
||||
#ifdef VERBOSE
|
||||
cout<<"Getting delay after trigger : " << time << "s" << endl;
|
||||
cout<<"Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl;
|
||||
#endif
|
||||
spinDelay->setValue(time);
|
||||
comboDelayUnit->setCurrentIndex((int)unit);
|
||||
@ -574,4 +574,22 @@ void qTabMeasurement::setTimingMode(int mode){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabMeasurement::Refresh(){
|
||||
/** File Name **/
|
||||
dispFileName->setText(QString(myDet->getFileName().c_str()));
|
||||
/** File Index **/
|
||||
spinIndex->setValue(myDet->getFileIndex());
|
||||
/** progress label index **/
|
||||
lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
|
||||
/** Progress bar **/
|
||||
progressBar->setValue(myDet->getCurrentProgress());
|
||||
/** Timing mode**/
|
||||
SetupTimingMode();//comboTimingMode->setCurrentIndex((int)myDet->setExternalCommunicationMode());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -5,25 +5,26 @@
|
||||
* Author: l_maliakal_d
|
||||
*/
|
||||
|
||||
/** Qt Project Class Headers */
|
||||
#include "qTabMessages.h"
|
||||
#include "qDefs.h"
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
/** Qt Include Headers */
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QSpacerItem>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QStringList>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QFileDialog>
|
||||
#include <QSizePolicy>
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):
|
||||
QWidget(parent),myDet(detector){
|
||||
qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
|
||||
SetupWidgetWindow();
|
||||
Initialization();
|
||||
}
|
||||
@ -33,8 +34,6 @@ qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):
|
||||
qTabMessages::~qTabMessages(){
|
||||
delete myDet;
|
||||
delete dispLog;
|
||||
delete dispCommand;
|
||||
delete dispPath;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -42,88 +41,71 @@ qTabMessages::~qTabMessages(){
|
||||
void qTabMessages::SetupWidgetWindow(){
|
||||
/** Layout */
|
||||
QGridLayout *gridLayout = new QGridLayout(this);
|
||||
QLabel *lblCommand = new QLabel("System Command:",this);
|
||||
QLabel *lblPath = new QLabel("Working Directory:",this);
|
||||
QSpacerItem *hSpacer= new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
dispLog = new QTextEdit(this);
|
||||
dispCommand = new QLineEdit(this);
|
||||
dispPath = new QLineEdit(this);
|
||||
dispLog->setReadOnly(true);
|
||||
dispPath->setReadOnly(true);
|
||||
dispLog->setFocusPolicy(Qt::NoFocus);
|
||||
dispPath->setFocusPolicy(Qt::NoFocus);
|
||||
gridLayout->addWidget(dispLog, 0, 0, 1, 3);
|
||||
gridLayout->addWidget(lblCommand, 1, 0, 1, 1);
|
||||
gridLayout->addItem(hSpacer, 1, 1, 1, 1);
|
||||
gridLayout->addWidget(dispCommand, 1, 2, 1, 1);
|
||||
gridLayout->addWidget(lblPath, 2, 0, 1, 1);
|
||||
gridLayout->addWidget(dispPath, 2, 2, 1, 1);
|
||||
|
||||
/** Command & Path*/
|
||||
dispCommand->setText("Insert your command here");
|
||||
dispPath->setText(QDir("./").absolutePath());
|
||||
dispLog = new QTextEdit(this);
|
||||
dispLog->setReadOnly(true);
|
||||
dispLog->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||
|
||||
btnSave = new QPushButton("Save Log",this);
|
||||
btnSave->setFocusPolicy(Qt::NoFocus);
|
||||
btnSave->setSizePolicy(sizePolicy);
|
||||
|
||||
btnClear = new QPushButton("Clear",this);
|
||||
btnClear->setFocusPolicy(Qt::NoFocus);
|
||||
btnClear->setSizePolicy(sizePolicy);
|
||||
|
||||
gridLayout->addWidget(btnSave,0,0,1,1);
|
||||
gridLayout->addWidget(btnClear,0,4,1,1);
|
||||
gridLayout->addWidget(dispLog,1,0,1,5);
|
||||
|
||||
qout=new qDebugStream(std::cout,this);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::Initialization(){
|
||||
connect(dispCommand,SIGNAL(returnPressed()),this,SLOT(executeCommand()));
|
||||
connect(btnSave,SIGNAL(clicked()),this,SLOT(SaveLog()));
|
||||
connect(btnClear,SIGNAL(clicked()),this,SLOT(ClearLog()));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::executeCommand(){
|
||||
#ifdef VERBOSE
|
||||
cout<<"Calling: "<< dispCommand->text().toAscii().constData()<<endl;
|
||||
#endif
|
||||
QProcess proc(this);
|
||||
#ifdef VERBOSE
|
||||
//std::cout <<"working directory would be " << proc.workingDirectory().absPath() << std::endl;
|
||||
cout<<"Original Working Directory: "<< proc.workingDirectory().toAscii().constData()<<endl;
|
||||
#endif
|
||||
proc.setWorkingDirectory(QDir(dispPath->text()).absolutePath());
|
||||
#ifdef VERBOSE
|
||||
//std::cout <<"working directory is " << proc.workingDirectory().absPath() << std::endl;
|
||||
cout<<"Current Working Directory: "<<proc.workingDirectory().toAscii().constData()<<endl;
|
||||
#endif
|
||||
proc.setArguments(QStringList::split(' ',dispCommand->text()));
|
||||
#ifdef VERBOSE
|
||||
/* QStringList list = proc.arguments();
|
||||
QStringList::Iterator it = list.begin();
|
||||
while( it != list.end() ) {
|
||||
cout<<*it<<endl;
|
||||
++it;
|
||||
}*/
|
||||
#endif
|
||||
//if (!proc.start()) {
|
||||
if(!(proc.state()==QProcess::Running)){
|
||||
// error handling
|
||||
cout<<"Could not launch process"<<endl;
|
||||
} else {
|
||||
//while(proc.isRunning()) {
|
||||
while(proc.state()==QProcess::Running){
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
cout<<"Process running "<< proc.exitStatus()<< endl;
|
||||
#endif
|
||||
}
|
||||
//if (proc.normalExit()) {
|
||||
if(proc.exitStatus()==QProcess::NormalExit){
|
||||
;
|
||||
#ifdef VERBOSE
|
||||
cout<<" process returned OK"<<endl;
|
||||
#endif
|
||||
} else
|
||||
cout<<" process returned error"<<endl;
|
||||
while (proc.canReadLineStdout()) {//readAllStandardOutput ()
|
||||
cout<<proc.readLineStdout() <<endl;
|
||||
}
|
||||
while (proc.canReadLineStderr()) {
|
||||
cout<<"Error: "<<proc.readLineStderr() <<endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qTabMessages::customEvent(QEvent *e) {
|
||||
if (e->type() == STREAMEVENT)
|
||||
dispLog->append(((qStreamEvent*)e)->getString());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::SaveLog() {
|
||||
QString fName = QString(myDet->getFilePath().c_str());
|
||||
fName = fName+"/LogFile.txt";
|
||||
fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),
|
||||
fName,tr("Text files (*.txt)"));
|
||||
if (!fName.isEmpty()){
|
||||
QFile outfile;
|
||||
outfile.setFileName(fName);
|
||||
if(outfile.open(QIODevice::WriteOnly | QIODevice::Text)){//Append
|
||||
QTextStream out(&outfile);
|
||||
out<<dispLog->toPlainText() << endl;
|
||||
qDefs::InfoMessage(string("The Log has been successfully saved to "
|
||||
"")+fName.toAscii().constData(),"Messages: Information");
|
||||
}
|
||||
else qDefs::ErrorMessage("ERROR: Attempt to save log file failed.","Messages: WARNING");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabMessages::ClearLog() {
|
||||
dispLog->clear();
|
||||
#ifdef VERBOSE
|
||||
cout<<"Log Cleared"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -11,11 +11,13 @@
|
||||
/** Project Class Headers */
|
||||
#include "slsDetector.h"
|
||||
#include "multiSlsDetector.h"
|
||||
/** Qt Include Headers */
|
||||
/** C++ Include Headers */
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
QString qTabPlot::defaultPlotTitle("Measurement");
|
||||
@ -26,6 +28,9 @@ QString qTabPlot::defaultImageYAxisTitle("Pixel");
|
||||
QString qTabPlot::defaultImageZAxisTitle("Intensity");
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
@ -42,6 +47,7 @@ qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
qTabPlot::~qTabPlot(){
|
||||
@ -50,6 +56,7 @@ qTabPlot::~qTabPlot(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::SetupWidgetWindow(){
|
||||
@ -75,8 +82,11 @@ void qTabPlot::SetupWidgetWindow(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::Select1DPlot(bool b){
|
||||
SetupWidgetWindow();
|
||||
isOneD = b;
|
||||
if(b){
|
||||
box1D->setEnabled(true);
|
||||
box2D->setEnabled(false);
|
||||
@ -105,9 +115,16 @@ void qTabPlot::Select1DPlot(bool b){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::Initialization(){
|
||||
/** Plot arguments box*/
|
||||
connect(chkNoPlot, SIGNAL(toggled(bool)),myPlot, SLOT(EnablePlot(bool)));
|
||||
connect(radioNoPlot, SIGNAL(clicked()),this, SLOT(SetPlot()));
|
||||
connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot()));
|
||||
connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot()));
|
||||
/** Scan box*/
|
||||
//connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(EnablePlot(bool)));
|
||||
/** Snapshot box*/
|
||||
connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot()));
|
||||
connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones()));
|
||||
@ -147,21 +164,13 @@ void qTabPlot::Initialization(){
|
||||
connect(this, SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double)));
|
||||
|
||||
/** Common Buttons*/
|
||||
connect(btnClear, SIGNAL(clicked()), myPlot, SLOT(Clear1DPlot()));
|
||||
/** Save */
|
||||
connect(btnSave, SIGNAL(clicked()), this, SLOT(SavePlot()));
|
||||
|
||||
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabPlot::Enable(bool enable){
|
||||
btnClone->setEnabled(enable);
|
||||
btnCloseClones->setEnabled(enable);
|
||||
box1D->setEnabled(enable);
|
||||
box2D->setEnabled(enable);
|
||||
boxPlotAxis->setEnabled(enable);
|
||||
}
|
||||
|
||||
void qTabPlot::EnablePersistency(bool enable){
|
||||
lblPersistency->setEnabled(enable);
|
||||
@ -172,19 +181,21 @@ void qTabPlot::EnablePersistency(bool enable){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::SetTitles(){
|
||||
int oneD = box1D->isEnabled();
|
||||
/** Plot Title*/
|
||||
if(dispTitle->isEnabled())
|
||||
myPlot->SetPlotTitle(dispTitle->text());
|
||||
/** X Axis */
|
||||
if(dispXAxis->isEnabled()){
|
||||
if(oneD) myPlot->SetHistXAxisTitle(dispXAxis->text());
|
||||
if(isOneD) myPlot->SetHistXAxisTitle(dispXAxis->text());
|
||||
else myPlot->SetImageXAxisTitle(dispXAxis->text());
|
||||
}
|
||||
/** Y Axis */
|
||||
if(dispYAxis->isEnabled()){
|
||||
if(oneD) myPlot->SetHistYAxisTitle(dispYAxis->text());
|
||||
if(isOneD) myPlot->SetHistYAxisTitle(dispYAxis->text());
|
||||
else myPlot->SetImageYAxisTitle(dispYAxis->text());
|
||||
}
|
||||
/** Z Axis */
|
||||
@ -193,9 +204,10 @@ void qTabPlot::SetTitles(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::EnableTitles(){
|
||||
int oneD = box1D->isEnabled();
|
||||
/** Plot Title*/
|
||||
dispTitle->setEnabled(chkTitle->isChecked());
|
||||
if(!chkTitle->isChecked()){
|
||||
@ -205,7 +217,7 @@ void qTabPlot::EnableTitles(){
|
||||
/** X Axis */
|
||||
dispXAxis->setEnabled(chkXAxis->isChecked());
|
||||
if(!chkXAxis->isChecked()){
|
||||
if(oneD){
|
||||
if(isOneD){
|
||||
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
|
||||
dispXAxis->setText(defaultHistXAxisTitle);
|
||||
}
|
||||
@ -217,7 +229,7 @@ void qTabPlot::EnableTitles(){
|
||||
/** Y Axis */
|
||||
dispYAxis->setEnabled(chkYAxis->isChecked());
|
||||
if(!chkYAxis->isChecked()){
|
||||
if(oneD){
|
||||
if(isOneD){
|
||||
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
|
||||
dispYAxis->setText(defaultHistYAxisTitle);
|
||||
}else{
|
||||
@ -234,6 +246,7 @@ void qTabPlot::EnableTitles(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::EnableRange(){
|
||||
@ -253,6 +266,8 @@ void qTabPlot::EnableRange(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::SetAxesRange(){
|
||||
double xmin=0,xmax=0,ymin=0,ymax=0;
|
||||
@ -260,28 +275,40 @@ void qTabPlot::SetAxesRange(){
|
||||
/** If disabled, get the min or max range of the plot as default */
|
||||
if((dispXMin->isEnabled())&&(!dispXMin->text().isEmpty()))
|
||||
xmin = dispXMin->text().toDouble();
|
||||
else xmin = myPlot->GetXMinimum();
|
||||
else if(myPlot->DoesPlotExist())
|
||||
xmin = myPlot->GetXMinimum();
|
||||
if((dispXMax->isEnabled())&&(!dispXMax->text().isEmpty()))
|
||||
xmax = dispXMax->text().toDouble();
|
||||
else xmax = myPlot->GetXMaximum();
|
||||
else if(myPlot->DoesPlotExist())
|
||||
xmax = myPlot->GetXMaximum();
|
||||
if((dispYMin->isEnabled())&&(!dispYMin->text().isEmpty()))
|
||||
ymin = dispYMin->text().toDouble();
|
||||
else ymin = myPlot->GetYMinimum();
|
||||
else if(myPlot->DoesPlotExist())
|
||||
ymin = myPlot->GetYMinimum();
|
||||
if((dispYMax->isEnabled())&&(!dispYMax->text().isEmpty()))
|
||||
ymax = dispYMax->text().toDouble();
|
||||
else ymax = myPlot->GetYMaximum();
|
||||
else if(myPlot->DoesPlotExist())
|
||||
ymax = myPlot->GetYMaximum();
|
||||
|
||||
/** Setting the range*/
|
||||
myPlot->SetXMinMax(xmin,xmax);
|
||||
myPlot->SetYMinMax(ymin,ymax);
|
||||
if(myPlot->DoesPlotExist()){
|
||||
myPlot->SetXMinMax(xmin,xmax);
|
||||
myPlot->SetYMinMax(ymin,ymax);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::SetZRange(){
|
||||
emit SetZRangeSignal(dispZMin->text().toDouble(),dispZMax->text().toDouble());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::EnableZRange(){
|
||||
dispZMin->setEnabled(chkZMin->isChecked());
|
||||
dispZMax->setEnabled(chkZMax->isChecked());
|
||||
@ -289,9 +316,48 @@ void qTabPlot::EnableZRange(){
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
void qTabPlot::SavePlot(){
|
||||
QString fullFileName = QString(myDet->getFilePath().c_str())+'/'+dispFName->text()+comboFormat->currentText();
|
||||
myPlot->SavePlot(fullFileName);
|
||||
|
||||
void qTabPlot::SetPlot(){
|
||||
if(radioNoPlot->isChecked()){
|
||||
myPlot->EnablePlot(false);
|
||||
/**if enable is true, disable everything */
|
||||
box1D->setEnabled(false);
|
||||
box2D->setEnabled(false);
|
||||
boxSnapshot->setEnabled(false);
|
||||
boxSave->setEnabled(false);
|
||||
boxPlotAxis->setEnabled(false);
|
||||
boxScan->setEnabled(false);
|
||||
}else if(radioHistogram->isChecked()){
|
||||
myPlot->EnablePlot(true);
|
||||
/**if enable is true, disable everything */
|
||||
box1D->setEnabled(true);
|
||||
box2D->setEnabled(true);
|
||||
boxSnapshot->setEnabled(true);
|
||||
boxSave->setEnabled(true);
|
||||
boxPlotAxis->setEnabled(true);
|
||||
boxScan->setEnabled(false);
|
||||
}else{
|
||||
myPlot->EnablePlot(true);
|
||||
/**if enable is true, disable everything */
|
||||
box1D->setEnabled(true);
|
||||
box2D->setEnabled(true);
|
||||
boxSnapshot->setEnabled(true);
|
||||
boxSave->setEnabled(true);
|
||||
boxPlotAxis->setEnabled(true);
|
||||
boxScan->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabPlot::EnableHistogram(bool enable){
|
||||
//boxScan->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -148,3 +148,13 @@ void qTabSettings::setSettings(int index){
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
void qTabSettings::Refresh(){
|
||||
/** Settings */
|
||||
SetupDetectorSettings();
|
||||
comboSettings->setCurrentIndex(myDet->getSettings(detID));
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user