actions without scan, positions, min plotimer=250,acquisition problem,error showing in actions tab

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@21 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-07-27 10:01:35 +00:00
parent 111608bdc8
commit 63f9d04981
16 changed files with 1483 additions and 626 deletions

View File

@ -87,6 +87,10 @@ INPUT = \
src/qTabPlot.cpp\
include/qTabActions.h\
src/qTabActions.cpp\
include/qActionsWidget.h\
src/qActionsWidget.cpp\
include/qScanWidget.h\
src/qScanWidget.cpp\
include/qTabAdvanced.h\
src/qTabAdvanced.cpp\
include/qTabSettings.h\

View File

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ActionsObject</class>
<widget class="QWidget" name="ActionsObject">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>680</width>
<height>25</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>1000</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboScript">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Custom Script</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="dispScript">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="lblParameter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Additional Parameter:</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="btnBrowse">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="8">
<widget class="QLineEdit" name="dispParameter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,403 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScanObject</class>
<widget class="QWidget" name="ScanObject">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>724</width>
<height>125</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1000</width>
<height>1000</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>5</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="2" column="2" rowspan="3" colspan="3">
<widget class="QGroupBox" name="group">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>5</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QRadioButton" name="radioConstant">
<property name="text">
<string>Constant Step Size</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioSpecific">
<property name="text">
<string>Specific Values</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Values from File</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QWidget" name="stackedWidget" native="true"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="1" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblPrecision">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Precision:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinPrecision">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblParameter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Additional Parameter:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="dispParameter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblSteps">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Number of Steps:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinSteps">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboScript">
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Energy Scan</string>
</property>
</item>
<item>
<property name="text">
<string>Threshold Scan</string>
</property>
</item>
<item>
<property name="text">
<string>Trimbits Scan</string>
</property>
</item>
<item>
<property name="text">
<string>Custom Script</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="dispScript">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnBrowse">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -221,13 +221,13 @@
<string/>
</property>
<property name="minimum">
<number>0</number>
<number>1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>0</number>
<number>1</number>
</property>
</widget>
</item>
@ -363,13 +363,13 @@
<string/>
</property>
<property name="minimum">
<number>0</number>
<number>1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>0</number>
<number>1</number>
</property>
</widget>
</item>
@ -417,13 +417,13 @@
<string/>
</property>
<property name="minimum">
<number>0</number>
<number>1</number>
</property>
<property name="maximum">
<number>2000000000</number>
</property>
<property name="value">
<number>0</number>
<number>1</number>
</property>
</widget>
</item>

View File

@ -196,7 +196,7 @@
<rect>
<x>10</x>
<y>20</y>
<width>356</width>
<width>358</width>
<height>26</height>
</rect>
</property>
@ -219,6 +219,9 @@
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="checkBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -232,6 +235,9 @@
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="checkBox_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -373,6 +379,9 @@
</item>
<item>
<widget class="QCheckBox" name="chkAutoFName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -402,6 +411,9 @@
</item>
<item>
<widget class="QCheckBox" name="chkSaveAll">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -1054,6 +1066,9 @@
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="radioHistogram">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -1442,6 +1457,9 @@
</item>
<item row="0" column="4">
<widget class="QPushButton" name="btnCloseClones_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>

View File

@ -1,5 +1,5 @@
/*
* qTabActions.h
* qActionsWidget.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
@ -8,118 +8,60 @@
#ifndef QACTIONSWIDGET_H_
#define QACTIONSWIDGET_H_
/** Form Header */
#include "ui_form_action.h"
/** Project Class Headers */
class multiSlsDetector;
/** Qt Include Headers */
#include <QFrame>
class QGridLayout;
class QComboBox;
class QLineEdit;
class QPushButton;
class QLabel;
class QSpinBox;
class QGroupBox;
class QRadioButton;
class QCheckBox;
/** C++ Include Headers */
#include <string>
using namespace std;
class ActionsWidget : public QFrame{
class qActionsWidget : public QWidget,private Ui::ActionsObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
* @param scanType is if its an energy/threshold scan type
* @param id is the id of the widget. to know which one was emitting it
*/
ActionsWidget(QWidget *parent, multiSlsDetector*& detector, int scanType, int id);
qActionsWidget(QWidget *parent, multiSlsDetector*& detector);
~ActionsWidget();
/**set variable expand
*/
void SetExpand(bool expanded){expand = expanded;};
/**get variable expand
*/
bool isExpanded(){return expand;};
~qActionsWidget();
/**to update the widgets*/
void Refresh();
/**number of action widgets*/
static int NUM_ACTION_WIDGETS;
enum actions{Start,Scan0,Scan1,ActionBefore,NumPositions,
HeaderBefore,HeaderAfter,ActionAfter,Stop};
private:
/** The sls detector object */
multiSlsDetector *myDet;
/**if its a scan type*/
int scanType;
/**id of the action widget*/
int id;
/**if this widget has been expanded*/
bool expand;
QGridLayout *layout;
QComboBox *comboScript;
QLineEdit *dispScript;
QPushButton *btnBrowse;
QLabel *lblParameter;
QLineEdit *dispParameter;
QLabel *lblSteps;
QSpinBox *spinSteps;
QLabel *lblPrecision;
QSpinBox *spinPrecision;
QGroupBox *group;
QRadioButton *radioConstant;
QRadioButton *radioSpecific;
QRadioButton *radioValue;
QLabel *lblFrom;
QSpinBox *spinFrom;
QLabel *lblTo;
QSpinBox *spinTo;
QLabel *lblSize;
QSpinBox *spinSize;
QComboBox *comboSpecific;
QLineEdit *dispValues;
QPushButton *btnValues;
QSpinBox *spinNumPos;
QComboBox *comboPos;
QPushButton *btnDelete;
QCheckBox *chkInvert;
QCheckBox *chkSeparate;
QCheckBox *chkReturn;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals */
/** Sets up all the slots and signals
* */
void Initialization();
/**Gets the sls class action index using the gui index
* @param index gui index
*/
int GetActionIndex(int gIndex);
private slots:
/** Sets the scan or script. Accordingly enables, disables other widgets
* @param index value chosen*/
* @param index value chosen
* */
void SetScript(int index);
/** Enables widgets depending on which size is clicked.
* Options: constant size,specific values,values from file */
void EnableSizeWidgets();
/** Browse for the script
* */
void BrowsePath();
@ -133,17 +75,6 @@ void SetScriptFile();
* */
void SetParameter(const QString& parameter);
/** Sets the number of positions
* */
void SetNumPositions(int index);
/** Deletes current position
* */
void DeletePosition();
signals:
void EnableScanBox(bool,int);
};

View File

@ -212,7 +212,7 @@ private:
bool IsXYRange[4];
/** Default timer between plots*/
static const double PLOT_TIMER_MS = 500;
static const double PLOT_TIMER_MS = 250;
/** Specific timer value between plots */
double timerValue;
/** every nth frame when to plot */

View File

@ -0,0 +1,99 @@
/*
* qScanWidget.h
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
#ifndef QSCANWIDGET_H_
#define QSCANWIDGET_H_
/** Form Header */
#include "ui_form_scan.h"
/** Project Class Headers */
class multiSlsDetector;
/** Qt Include Headers */
#include <QStackedLayout>
/** C++ Include Headers */
#include <string>
using namespace std;
class qScanWidget : public QWidget,private Ui::ScanObject{
Q_OBJECT
public:
/** \short The constructor
* @param parent is the parent tab widget
* @param detector is the detector returned from the detector tab
*/
qScanWidget(QWidget *parent, multiSlsDetector*& detector);
~qScanWidget();
/**to update the widgets*/
void Refresh();
/**number of scan widgets*/
static int NUM_SCAN_WIDGETS;
private:
/** The sls detector object */
multiSlsDetector *myDet;
/**id of the scan widget*/
int id;
QStackedLayout *stackedLayout;
QLabel *lblFrom;
QSpinBox *spinFrom;
QLabel *lblTo;
QSpinBox *spinTo;
QLabel *lblSize;
QSpinBox *spinSize;
QComboBox *comboSpecific;
QLineEdit *dispValues;
QPushButton *btnValues;
/** Sets up the widget
*/
void SetupWidgetWindow();
/** Sets up all the slots and signals */
void Initialization();
private slots:
/** Sets the scan or script. Accordingly enables, disables other widgets
* @param index value chosen*/
void SetScript(int index);
/** Enables widgets depending on which size is clicked.
* Options: constant size,specific values,values from file */
void EnableSizeWidgets();
/** Browse for the script
* */
void BrowsePath();
/** Sets the script file
* */
void SetScriptFile();
/** Set Parameter
* @param parameter is the parameter to be set to
* */
void SetParameter(const QString& parameter);
signals:
void EnableScanBox(bool,int);
};
#endif /* QSCANWIDGET_H_ */

View File

@ -8,12 +8,19 @@
#ifndef QTABACTIONS_H_
#define QTABACTIONS_H_
/* Qt Project Class Headers */
#include "qActionsWidget.h"
#include "qScanWidget.h"
/** Project Class Headers */
class multiSlsDetector;
class ActionsWidget;
class qActionsWidget;
/** Qt Include Headers */
#include <QWidget>
#include <QPushButton>
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QLabel>
#include <QScrollArea>
#include <QGridLayout>
@ -46,16 +53,33 @@ private:
/** The sls detector object */
multiSlsDetector *myDet;
static const int NUM_ACTION_WIDGETS = 9;
enum actionIndex{Scan0=1, Scan1, NumPositions=4, NumTotalActions=9};
QGridLayout *gridLayout;
QButtonGroup *group;
QPalette *palette;
/** action widget objects */
ActionsWidget *actionWidget[NUM_ACTION_WIDGETS];
QPushButton *btnExpand[NUM_ACTION_WIDGETS];
QLabel *lblName[NUM_ACTION_WIDGETS];
/** all action widget objects */
qActionsWidget *actionWidget[6];
qScanWidget *scanWidget[2];
QWidget *positionWidget;
QPushButton *btnExpand[NumTotalActions];
QLabel *lblName[NumTotalActions];
/** NumPositions widget */
QLabel *lblNumPos;
QLabel *lblPosList;
QSpinBox *spinNumPos;
QComboBox *comboPos;
QPushButton *btnDelete;
QCheckBox *chkInvert;
QCheckBox *chkSeparate;
QCheckBox *chkReturn;
float *positions;
QPalette normal;
/** Sets up the widget */
void SetupWidgetWindow();
@ -63,12 +87,28 @@ private:
/** Sets up all the slots and signals */
void Initialization();
/** creates the Num Positions object */
void CreatePositionsWidget();
/** Returns the index in each of the classes
* of actionwidget and scanwidget
* @param index the index in the list of all widgets
* returns actual index of the class
*/
int GetActualIndex(int index);
private slots:
/** To Expand the Action Widget */
/** To Expand the Action Widget
* */
void Expand(QAbstractButton *button);
/** Sets the positions list and the number of positions
* */
void SetPosition();
/** Deletes current position
* */
void DeletePosition();
signals:
void EnableScanBox(bool,int);

View File

@ -55,6 +55,7 @@ SOURCES = \
src/qTabPlot.cpp\
src/qTabActions.cpp\
src/qActionsWidget.cpp\
src/qScanWidget.cpp\
src/qTabAdvanced.cpp\
src/qTabSettings.cpp\
src/qTabDebugging.cpp\
@ -80,6 +81,7 @@ HEADERS = \
include/qTabPlot.h\
include/qTabActions.h\
include/qActionsWidget.h\
include/qScanWidget.h\
include/qTabAdvanced.h\
include/qTabSettings.h\
include/qTabDebugging.h\
@ -97,5 +99,7 @@ FORMS = \
forms/form_tab_advanced.ui\
forms/form_tab_settings.ui\
forms/form_tab_debugging.ui\
forms/form_tab_developer.ui
forms/form_tab_developer.ui\
# forms/form_tab_messages.ui
forms/form_action.ui\
forms/form_scan.ui

View File

@ -1,5 +1,5 @@
/*
* qTabActions.cpp
* qActionsWidget.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
@ -11,29 +11,19 @@
#include "qActionsWidget.h"
#include "qDefs.h"
// Qt Include Headers
#include <QGridLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QLineEdit>
#include <QPushButton>
#include <QLabel>
#include <QLayout>
#include <QSpacerItem>
#include <QSpinBox>
#include <QGroupBox>
#include <QRadioButton>
#include <QFileDialog>
#include <QCheckBox>
// C++ Include Headers
#include<iostream>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qActionsWidget::NUM_ACTION_WIDGETS(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
ActionsWidget::ActionsWidget(QWidget *parent,multiSlsDetector*& detector, int scanType, int id):
QFrame(parent),myDet(detector),scanType(scanType),id(id),expand(false){
qActionsWidget::qActionsWidget(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
setupUi(this);
SetupWidgetWindow();
Initialization();
}
@ -42,365 +32,134 @@ ActionsWidget::ActionsWidget(QWidget *parent,multiSlsDetector*& detector, int sc
//-------------------------------------------------------------------------------------------------------------------------------------------------
ActionsWidget::~ActionsWidget(){
qActionsWidget::~qActionsWidget(){
delete myDet;
delete layout;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::SetupWidgetWindow(){
// Widget Settings
//setFrameStyle(QFrame::Box);
//setFrameShadow(QFrame::Raised);
// Main Layout Settings
void qActionsWidget::SetupWidgetWindow(){
id = NUM_ACTION_WIDGETS;
NUM_ACTION_WIDGETS++;
setFixedHeight(25);
if(scanType) setFixedHeight(125);
layout = new QGridLayout(this);
setLayout(layout);
layout->setContentsMargins(0,0,0,0);
if(scanType) layout->setVerticalSpacing(5);
if(id==NumPositions){
setFixedHeight(75);
QLabel *lblNumPos = new QLabel("Number of Positions:");
lblNumPos->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(lblNumPos,0,0);
spinNumPos = new QSpinBox(this);
layout->addWidget(spinNumPos,0,1);
layout->addItem(new QSpacerItem(80,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,2);
QLabel *lblPosList = new QLabel("List of Positions:");
lblPosList->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(lblPosList,0,3);
comboPos = new QComboBox(this);
comboPos->setEditable(true);
comboPos->setCompleter(0);
layout->addWidget(comboPos,0,4);
btnDelete = new QPushButton("Delete");
btnDelete->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(btnDelete,0,5);
QGroupBox *w = new QGroupBox;
layout->addWidget(w,1,0,1,6);
QHBoxLayout *l1 = new QHBoxLayout(w);
l1->setContentsMargins(0,0,0,0);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
chkInvert = new QCheckBox("Invert Angles");
l1->addWidget(chkInvert);
chkSeparate = new QCheckBox("Separate Two Halves");
l1->addWidget(chkSeparate);
chkReturn = new QCheckBox("Return to Start Position");
chkReturn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
l1->addWidget(chkReturn);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
}else{
// Main Widgets
comboScript = new QComboBox(this);
if(!scanType){
comboScript->addItem("None");
comboScript->addItem("Custom Script");
}else{
comboScript->addItem("None");
comboScript->addItem("Energy Scan");
comboScript->addItem("Threshold Scan");
comboScript->addItem("Trimbits Scan");
comboScript->addItem("Custom Script");
}
layout->addWidget(comboScript,0,0);
layout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
dispScript = new QLineEdit("");
dispScript->setEnabled(false);
layout->addWidget(dispScript,0,2);
btnBrowse = new QPushButton("Browse");
btnBrowse->setEnabled(false);
layout->addWidget(btnBrowse,0,3);
layout->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,4);
lblParameter = new QLabel("Additional Parameter:");
lblParameter->setEnabled(false);
layout->addWidget(lblParameter,0,5);
dispParameter = new QLineEdit("");
dispParameter->setEnabled(false);
dispParameter->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(dispParameter,0,6);
// Scan Levels Widgets
if(scanType){
lblSteps = new QLabel("Number of Steps:");
lblSteps->setEnabled(false);
layout->addWidget(lblSteps,1,2);
spinSteps = new QSpinBox(this);
spinSteps->setEnabled(false);
layout->addWidget(spinSteps,1,3);
lblPrecision = new QLabel("Precision:");
lblPrecision->setEnabled(false);
layout->addWidget(lblPrecision,1,5);
spinPrecision = new QSpinBox(this);
spinPrecision->setEnabled(false);
layout->addWidget(spinPrecision,1,6);
group = new QGroupBox(this);
group->setEnabled(false);
// Fix the size of the groupbox
group->setFixedSize(513,66);
layout->addWidget(group,2,2,1,6);
// Group Box for step size
// Radio Buttons Layout
QWidget *h1Widget = new QWidget(group);
h1Widget->setGeometry(QRect(10, 5, group->width()-20, 23));
QHBoxLayout *h1 = new QHBoxLayout(h1Widget);
h1->setContentsMargins(0, 0, 0, 0);
radioConstant = new QRadioButton("Constant Step Size",h1Widget);
radioConstant->setChecked(true);
h1->addWidget(radioConstant);
radioSpecific = new QRadioButton("Specific Values",h1Widget);
h1->addWidget(radioSpecific);
radioValue = new QRadioButton("Values from File",h1Widget);
radioValue->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
h1->addWidget(radioValue);
// Constant Size Layout
QWidget *h2ConstantWidget = new QWidget(group);
h2ConstantWidget->setGeometry(QRect(10, 30, group->width()-20, 31));
QHBoxLayout *h2Constant = new QHBoxLayout(h2ConstantWidget);
h2Constant->setContentsMargins(0, 0, 0, 0);
h2Constant->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
lblFrom = new QLabel("from",h2ConstantWidget);
lblFrom->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
h2Constant->addWidget(lblFrom);
spinFrom = new QSpinBox(h2ConstantWidget);
h2Constant->addWidget(spinFrom);
lblTo = new QLabel("to",h2ConstantWidget);
lblTo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
h2Constant->addWidget(lblTo);
spinTo = new QSpinBox(h2ConstantWidget);
h2Constant->addWidget(spinTo);
h2Constant->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
lblSize = new QLabel("Size",h2ConstantWidget);
lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
h2Constant->addWidget(lblSize);
spinSize = new QSpinBox(h2ConstantWidget);
h2Constant->addWidget(spinSize);
h2Constant->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
// Specific Values Layout
QWidget *h2SpecificWidget = new QWidget(group);
h2SpecificWidget->setGeometry(QRect(10, 30, group->width()-20, 31));
QHBoxLayout *h2Specific = new QHBoxLayout(h2SpecificWidget);
h2Specific->setContentsMargins(0, 0, 0, 0);
h2Specific->addItem(new QSpacerItem(200,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
comboSpecific = new QComboBox(h2SpecificWidget);
h2Specific->addWidget(comboSpecific);
comboSpecific->hide();
h2Specific->addItem(new QSpacerItem(200,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
// Values From a File Layout
QWidget *h2ValuesWidget = new QWidget(group);
h2ValuesWidget->setGeometry(QRect(10, 30, group->width()-20, 31));
QHBoxLayout *h2Values = new QHBoxLayout(h2ValuesWidget);
h2Values->setContentsMargins(0, 0, 0, 0);
h2Values->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
dispValues = new QLineEdit("steps.txt",h2ValuesWidget);
dispValues->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
h2Values->addWidget(dispValues);
dispValues->hide();
btnValues = new QPushButton("Browse",h2ValuesWidget);
btnValues->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
h2Values->addWidget(btnValues);
btnValues->hide();
h2Values->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::Initialization(){
if(id==NumPositions){
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetNumPositions(int)));
connect(btnDelete, SIGNAL(clicked()), this, SLOT(DeletePosition()));
}else{
connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetScript(int)));
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath()));
connect(dispParameter, SIGNAL(textChanged(const QString&)), this, SLOT(SetParameter(const QString&)));
if(scanType){
connect(radioConstant, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
connect(radioSpecific, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
connect(radioValue, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
}
}
void qActionsWidget::Initialization(){
//mode
connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetScript(int)));
//file
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath()));
//parameter
connect(dispParameter, SIGNAL(textChanged(const QString&)), this, SLOT(SetParameter(const QString&)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::EnableSizeWidgets(){
// defaults
lblFrom->hide();
spinFrom->hide();
lblTo->hide();
spinTo->hide();
lblSize->hide();
spinSize->hide();
comboSpecific->hide();
dispValues->hide();
btnValues->hide();
lblSteps->setEnabled(true);
spinSteps->setEnabled(true);
// Constant Step Size
if(radioConstant->isChecked()){
lblFrom->show();
spinFrom->show();
lblTo->show();
spinTo->show();
lblSize->show();
spinSize->show();
lblSteps->setEnabled(false);
spinSteps->setEnabled(false);
}// Specific Values
else if(radioSpecific->isChecked())
comboSpecific->show();
// Values from a File
else{
dispValues->show();
btnValues->show();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::SetScript(int index){
// defaults
dispScript->setEnabled(false);
btnBrowse->setEnabled(false);
lblParameter->setEnabled(false);
dispParameter->setEnabled(false);
if(scanType){
group->setEnabled(false);
lblSteps->setEnabled(false);
spinSteps->setEnabled(false);
lblPrecision->setEnabled(false);
spinPrecision->setEnabled(false);
}
// If anything other than None is selected
if(index){
// Custom Script only enables the first layout with addnl parameters etc
if(!comboScript->currentText().compare("Custom Script")){
dispScript->setEnabled(true);
btnBrowse->setEnabled(true);
lblParameter->setEnabled(true);
dispParameter->setEnabled(true);
}
// If this group includes Energy scan , threhold scan etc
if(scanType){
group->setEnabled(true);
lblPrecision->setEnabled(true);
spinPrecision->setEnabled(true);
// Steps are enabled only if constant step size is not checked
lblSteps->setEnabled(!radioConstant->isChecked());
spinSteps->setEnabled(!radioConstant->isChecked());
}
}
//emit signal to enable scanbox and the radiobuttons
if(scanType) emit EnableScanBox(index,((id==2)?1:0));
void qActionsWidget::SetScript(int index){
#ifdef VERBOSE
cout << "Setting mode of action widget:" << id << " to " << index << endl;
#endif
//enabling/disabling
dispScript->setEnabled(index);
btnBrowse->setEnabled(index);
lblParameter->setEnabled(index);
dispParameter->setEnabled(index);
QString fName = dispScript->text();
//script
if((id!=Scan0)&&(id!=Scan1))
//scan and positions wouldnt get here
if(index) myDet->setActionScript(GetActionIndex(id),fName.toAscii().constData());
else myDet->setActionScript(GetActionIndex(id),"");
//scan
else{
//set the mode
if(index) myDet->setActionScript(id,fName.toAscii().constData());
else myDet->setActionScript(id,"");
//mode is not set when fname is blank
if(!fName.isEmpty()){
//check if mode didnt get set
if(index!=myDet->getActionMode(id)){
qDefs::WarningMessage("The mode could not be changed.","ActionsWidget");
comboScript->setCurrentIndex(myDet->getActionMode(id));
}//if mode got set and its custom script
else if(index){
//when the file name did not get set correctly
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
qDefs::WarningMessage("The file path could not be set.","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
SetScriptFile();
}
}
}
cout<<"mode:"<<myDet->getActionMode(GetActionIndex(id))<<" "
"script:"<<myDet->getActionScript(GetActionIndex(id))<<" "
"parameter:"<<myDet->getActionParameter(GetActionIndex(id))<<endl;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::BrowsePath(){
void qActionsWidget::BrowsePath(){
#ifdef VERBOSE
cout << "Browsing Script File Path" << endl;
#endif
QString fName = dispScript->text();
QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep);
if(dir.isEmpty()) dir = "/home";
//dialog
fName = QFileDialog::getOpenFileName(this,
tr("Load Script File"),dir,
tr("Script Files(*.awk);;All Files(*)"));//,0,QFileDialog::ShowDirsOnly);
tr("Script Files(*.awk);;All Files(*)"));
//if empty, set the file name and it calls setscriptfile, else ignore
if (!fName.isEmpty())
if (!fName.isEmpty()){
dispScript->setText(fName);
SetScriptFile();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::SetScriptFile(){
QString fName = dispScript->text();bool set = false;
void qActionsWidget::SetScriptFile(){
QString fName = dispScript->text();
#ifdef VERBOSE
cout << "Setting script file of action widget:" << id << " to " << fName.toAscii().constData() << endl;
#endif
disconnect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
bool set = false;
//blank
if(fName.isEmpty())
set = true;
if(fName.isEmpty()) set = true;
else if(!fName.compare("none")) set = true;
//not blank
else{
QString file = dispScript->text().section('/',-1);
//is a file
if(file.contains('.')){
//check if it exists and set the script file
if(QFile::exists(fName))
set = true;
if(QFile::exists(fName)) set = true;
//if the file doesnt exist, set it to what it was before
else{
qDefs::WarningMessage("The script file entered does not exist","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(GetActionIndex(id)).c_str()));
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}//not a file, set it to what it was before
else {
qDefs::WarningMessage("The script file path entered is not a file","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(GetActionIndex(id)).c_str()));
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}
//if blank or valid file
if(set){
//script
if((id!=Scan0)&&(id!=Scan1)){
//scan and positions wouldnt get here
if(!myDet->setActionScript(GetActionIndex(id),fName.toAscii().constData())){
//did not get set, write what is was before
if(!fName.isEmpty())
qDefs::WarningMessage("The script file could not be set. Reverting to previous file.","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(GetActionIndex(id)).c_str()));
}
}
//scan
else{
//scan and positions wouldnt get here
myDet->setActionScript(id,fName.toAscii().constData());
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
//did not get set, write what is was before
if(!fName.isEmpty())
qDefs::WarningMessage("The script file could not be set. Reverting to previous file.","ActionsWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}
@ -415,115 +174,33 @@ void ActionsWidget::SetScriptFile(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::SetParameter(const QString& parameter){
void qActionsWidget::SetParameter(const QString& parameter){
#ifdef VERBOSE
cout << "Setting parameter of action widget:" << id << " to " << parameter.toAscii().constData() << endl;
#endif
//script
if((id!=ActionsWidget::Scan0)&&(id!=ActionsWidget::Scan1))
//scan and positions wouldnt get here
myDet->setActionParameter(GetActionIndex(id),parameter.toAscii().constData());
//scan
else{
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::SetNumPositions(int index){
//comboPos->setEnabled(index);
//if there arent enough positions
if((index) && (comboPos->count()<index)){
qDefs::WarningMessage("Insufficient number of positions in the list. "
"\nAdd more positions to the list, then set Number of Positions.","ActionsWidget");
spinNumPos->setValue(comboPos->count());
}else{
//emit SetPositionsSignal();
}
myDet->setActionParameter(id,parameter.toAscii().constData());
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::DeletePosition(){
QString pos = comboPos->currentText();
bool found = false;
//loops through to find the index and to make sure its in the list
for(int i=0;i<comboPos->count();i++){
if(!comboPos->itemText(i).compare(pos)){
found = true;
comboPos->removeItem(i);
break;
}
}
//give the warning only when you try to delete stuff that arent there
if((!found)&&(comboPos->count())) qDefs::WarningMessage("This position cannot be deleted as it doesn't exist in the list anyway","ActionsWidget");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void ActionsWidget::Refresh(){
//disabling signals and slots
if(id==NumPositions){
}else{
disconnect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
disconnect(dispParameter, SIGNAL(textChanged(const QString&)),this, SLOT(SetParameter(const QString&)));
}
int mode;string script,parameter;
if((id == Scan0)||(id == Scan1)){
}else if(id == NumPositions){
}else{
mode = (myDet->getActionMode(GetActionIndex(id))>0?1:0);
script = myDet->getActionScript(GetActionIndex(id));
parameter = myDet->getActionParameter(GetActionIndex(id));
//defaults
if(script == "none") script="";
if(parameter == "none") parameter="";
//settings values
dispScript->setText(QString(script.c_str()));
dispParameter->setText(QString(parameter.c_str()));
//set mode which also checks everything
comboScript->setCurrentIndex(mode);
}
//enabling signals and slots
if(id==NumPositions){
}else{
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
connect(dispParameter, SIGNAL(textChanged(const QString&)),this, SLOT(SetParameter(const QString&)));
}
void qActionsWidget::Refresh(){
int mode = (myDet->getActionMode(id)>0?1:0);
string script = myDet->getActionScript(id);
string parameter = myDet->getActionParameter(id);
//defaults
if(script == "none") script="";
if(parameter == "none") parameter="";
//settings values
dispScript->setText(QString(script.c_str()));
dispParameter->setText(QString(parameter.c_str()));
//set mode which also checks everything
comboScript->setCurrentIndex(mode);
#ifdef VERBOSE
cout << "Updated action widget " << id << "\tscript:" << script << "\tparameter:" << parameter << endl;
cout << "Updated action widget " << id << "\tmode:"<<mode<<"\tscript:" << script << "\tparameter:" << parameter << endl;
#endif
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int ActionsWidget::GetActionIndex(int gIndex){
switch(gIndex){
case Start: return slsDetectorDefs::startScript;
case ActionBefore: return slsDetectorDefs::scriptBefore;
case HeaderBefore: return slsDetectorDefs::headerBefore;
case HeaderAfter: return slsDetectorDefs::headerAfter;
case ActionAfter: return slsDetectorDefs::scriptAfter;
case Stop: return slsDetectorDefs::stopScript;
default: return -1;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -174,7 +174,6 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
numFrames = ((numFrames==0)?1:numFrames);
numTriggers = ((numTriggers==0)?1:numTriggers);
number_of_exposures= numFrames * numTriggers;
cout<<"\tNumber of Exposures:"<<number_of_exposures<<endl;
/** ExposureTime */
@ -289,69 +288,70 @@ int qDrawPlot::GetData(detectorData *data){
#ifdef VERYVERBOSE
cout<<"Entering GetDatafunction"<<endl;
#endif
if(!stop_signal){
progress=(int)data->progressIndex;
progress=(int)data->progressIndex;
if(!plotEnable) {
lastImageNumber= currentFrame+1;
currentFrame++;
return 0;
}
/** Get data from client */
/**1d*/
if(plot_in_scope==1){
/** Persistency */
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
for(int i=currentPersistency;i>0;i--)
memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double));
nHists = currentPersistency+1;
//memcpy(yvalues[0],data->values,nPixelsX*sizeof(double));
for(int i=0;i<(int)nPixelsX;i++) *(yvalues[0]+i) = (double)*(data->values+i);
}
/**2d*/
else{
for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int py=0;py<nPixelsY;py++)
image_data[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2);
}
if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE
cout<<"Reading in image: "<<currentFrame+1<<endl;
#endif
if(!plotLock){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
/** only if you got the lock, do u need to remember lastimagenumber to plot*/
if(!plotEnable) {
lastImageNumber= currentFrame+1;
currentFrame++;
return 0;
}
/**1d*/
if(plot_in_scope==1){
/** Titles*/
sprintf(temp_title,"Frame %d",currentFrame); histTitle[0] = temp_title;
/** copy data*/
//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
}
/**2d*/
else{
sprintf(temp_title,"Image Number %d",currentFrame); imageTitle = temp_title;
memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
}
pthread_mutex_unlock(&(last_image_complete_mutex));
/** Get data from client */
/**1d*/
if(plot_in_scope==1){
/** Persistency */
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;
for(int i=currentPersistency;i>0;i--)
memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double));
nHists = currentPersistency+1;
//memcpy(yvalues[0],data->values,nPixelsX*sizeof(double));
for(int i=0;i<(int)nPixelsX;i++) *(yvalues[0]+i) = (double)*(data->values+i);
}
/**2d*/
else{
for(unsigned int px=0;px<nPixelsX;px++)
for(unsigned int py=0;py<nPixelsY;py++)
image_data[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2);
}
if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE
cout<<"Reading in image: "<<currentFrame+1<<endl;
#endif
if(!plotLock){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
/** only if you got the lock, do u need to remember lastimagenumber to plot*/
lastImageNumber= currentFrame+1;
/**1d*/
if(plot_in_scope==1){
/** Titles*/
sprintf(temp_title,"Frame %d",currentFrame); histTitle[0] = temp_title;
/** copy data*/
//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double));
memcpy(histYAxis[0],yvalues[0],nPixelsX*sizeof(double));
}
/**2d*/
else{
sprintf(temp_title,"Image Number %d",currentFrame); imageTitle = temp_title;
memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
}
pthread_mutex_unlock(&(last_image_complete_mutex));
}
}
currentFrame++;
}
/** To make sure plotting locks parameters until it has plotted */
if(frameFactor){
if(currentFrame==number_of_exposures) plotLock = true;
else if(!((currentFrame-1)%frameFactor)) plotLock = true;
}
currentFrame++;
}
/** To make sure plotting locks parameters until it has plotted */
if(frameFactor){
if(currentFrame==number_of_exposures) plotLock = true;
else if(!((currentFrame-1)%frameFactor)) plotLock = true;
}
#ifdef VERYVERBOSE
cout<<"Exiting GetData function"<<endl;

View File

@ -0,0 +1,321 @@
/*
* qScanWidget.cpp
*
* Created on: May 10, 2012
* Author: l_maliakal_d
*/
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
// Qt Project Class Headers
#include "qScanWidget.h"
#include "qDefs.h"
// Qt Include Headers
#include <QFileDialog>
#include <QStackedLayout>
// C++ Include Headers
#include<iostream>
using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qScanWidget::NUM_SCAN_WIDGETS(0);
//-------------------------------------------------------------------------------------------------------------------------------------------------
qScanWidget::qScanWidget(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
setupUi(this);
SetupWidgetWindow();
Initialization();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
qScanWidget::~qScanWidget(){
delete myDet;
delete stackedLayout;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::SetupWidgetWindow(){
id = NUM_SCAN_WIDGETS;
NUM_SCAN_WIDGETS++;
setFixedHeight(125);
//layout for the size widgets
stackedLayout = new QStackedLayout;
stackedLayout->setSpacing(0);
// Constant Size Layout
QWidget *constantWidget = new QWidget;
QHBoxLayout *layoutConstant = new QHBoxLayout(constantWidget);
layoutConstant->setContentsMargins(0, 0, 0, 0);
layoutConstant->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
lblFrom = new QLabel("from",constantWidget);
lblFrom->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layoutConstant->addWidget(lblFrom);
spinFrom = new QSpinBox(constantWidget);
layoutConstant->addWidget(spinFrom);
lblTo = new QLabel("to",constantWidget);
lblTo->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layoutConstant->addWidget(lblTo);
spinTo = new QSpinBox(constantWidget);
layoutConstant->addWidget(spinTo);
layoutConstant->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
lblSize = new QLabel("Size",constantWidget);
lblSize->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layoutConstant->addWidget(lblSize);
spinSize = new QSpinBox(constantWidget);
layoutConstant->addWidget(spinSize);
layoutConstant->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
// Specific Values Layout
QWidget *specificWidget = new QWidget;
QHBoxLayout *layoutSpecific = new QHBoxLayout(specificWidget);
layoutSpecific->setContentsMargins(0, 0, 0, 0);
layoutSpecific->addItem(new QSpacerItem(200,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
comboSpecific = new QComboBox(specificWidget);
comboSpecific->setEditable(true);
comboSpecific->setCompleter(false);
layoutSpecific->addWidget(comboSpecific);
layoutSpecific->addItem(new QSpacerItem(200,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
// Values From a File Layout
QWidget *valuesWidget = new QWidget;
QHBoxLayout *layoutValues = new QHBoxLayout(valuesWidget);
layoutValues->setContentsMargins(0, 0, 0, 0);
layoutValues->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
dispValues = new QLineEdit("steps.txt",valuesWidget);
dispValues->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
layoutValues->addWidget(dispValues);
btnValues = new QPushButton("Browse",valuesWidget);
btnValues->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layoutValues->addWidget(btnValues);
layoutValues->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
stackedLayout->addWidget(constantWidget);
stackedLayout->addWidget(specificWidget);
stackedLayout->addWidget(valuesWidget);
stackedWidget->setLayout(stackedLayout);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::Initialization(){
//mode
connect(comboScript, SIGNAL(currentIndexChanged(int)), this,SLOT(SetScript(int)));
//file
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath()));
//parameter
connect(dispParameter, SIGNAL(textChanged(const QString&)), this, SLOT(SetParameter(const QString&)));
//sizewidgets
connect(radioConstant, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
connect(radioSpecific, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
connect(radioValue, SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::EnableSizeWidgets(){
if(radioConstant->isChecked())
stackedLayout->setCurrentIndex(0);
else if(radioSpecific->isChecked())
stackedLayout->setCurrentIndex(1);
else
stackedLayout->setCurrentIndex(2);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::SetScript(int index){
#ifdef VERBOSE
cout << "Setting mode of scan widget:" << id << " to " << index << endl;
#endif
// defaults
dispScript->setEnabled(false);
btnBrowse->setEnabled(false);
lblParameter->setEnabled(false);
dispParameter->setEnabled(false);
group->setEnabled(false);
lblSteps->setEnabled(false);
spinSteps->setEnabled(false);
lblPrecision->setEnabled(false);
spinPrecision->setEnabled(false);
// If anything other than None is selected
if(index){
// Custom Script only enables the first layout with addnl parameters etc
if(index==4){
dispScript->setEnabled(true);
btnBrowse->setEnabled(true);
lblParameter->setEnabled(true);
dispParameter->setEnabled(true);
}
group->setEnabled(true);
lblPrecision->setEnabled(true);
spinPrecision->setEnabled(true);
// Steps are enabled only if constant step size is not checked
lblSteps->setEnabled(!radioConstant->isChecked());
spinSteps->setEnabled(!radioConstant->isChecked());
}
//emit signal to enable scanbox in plot tab
emit EnableScanBox(index,id);
QString fName = dispScript->text();
//set the mode
if(index) myDet->setActionScript(id,fName.toAscii().constData());
else myDet->setActionScript(id,"");
//mode is not set when fname is blank
if(!fName.isEmpty()){
//check if mode didnt get set
if(index!=myDet->getActionMode(id)){
qDefs::WarningMessage("The mode could not be changed.","ScanWidget");
comboScript->setCurrentIndex(myDet->getActionMode(id));
}//if mode got set and its custom script
else if(index){
//when the file name did not get set correctly
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
qDefs::WarningMessage("The file path could not be set.","ScanWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
SetScriptFile();
}
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::BrowsePath(){
#ifdef VERBOSE
cout << "Browsing Script File Path" << endl;
#endif
QString fName = dispScript->text();
QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep);
if(dir.isEmpty()) dir = "/home";
//dialog
fName = QFileDialog::getOpenFileName(this,
tr("Load Script File"),dir,
tr("Script Files(*.awk);;All Files(*)"));
//if empty, set the file name and it calls setscriptfile, else ignore
if (!fName.isEmpty()){
dispScript->setText(fName);
SetScriptFile();
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::SetScriptFile(){
QString fName = dispScript->text();bool set = false;
#ifdef VERBOSE
cout << "Setting script file of scan widget:" << id << " to " << fName.toAscii().constData() << endl;
#endif
disconnect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
//blank
if(fName.isEmpty()) set = true;
else if(!fName.compare("none")) set = true;
//not blank
else{
QString file = dispScript->text().section('/',-1);
//is a file
if(file.contains('.')){
//check if it exists and set the script file
if(QFile::exists(fName))
set = true;
//if the file doesnt exist, set it to what it was before
else{
qDefs::WarningMessage("The script file entered does not exist","ScanWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}//not a file, set it to what it was before
else {
qDefs::WarningMessage("The script file path entered is not a file","ScanWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}
//if blank or valid file
if(set){
myDet->setActionScript(id,fName.toAscii().constData());
if(fName.compare(QString(myDet->getActionScript(id).c_str()))){
//did not get set, write what is was before
if(!fName.isEmpty())
qDefs::WarningMessage("The script file could not be set. Reverting to previous file.","ScanWidget");
dispScript->setText(QString(myDet->getActionScript(id).c_str()));
}
}
//dont display if theres a none
if(!dispScript->text().compare("none")) dispScript->setText("");
connect(dispScript, SIGNAL(editingFinished()), this, SLOT(SetScriptFile()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::SetParameter(const QString& parameter){
#ifdef VERBOSE
cout << "Setting parameter of scan widget:" << id << " to " << parameter.toAscii().constData() << endl;
#endif
myDet->setActionParameter(id,parameter.toAscii().constData());
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qScanWidget::Refresh(){
int mode = (myDet->getScanMode(id)>0?1:0);
string script = myDet->getScanScript(id);
string parameter = myDet->getScanParameter(id);
double precision = myDet->getScanPrecision(id);
//defaults
if(script == "none") script="";
if(parameter == "none") parameter="";
//settings values
dispScript->setText(QString(script.c_str()));
dispParameter->setText(QString(parameter.c_str()));
spinPrecision->setValue(precision);
//set mode which also checks everything
comboScript->setCurrentIndex(mode);
#ifdef VERBOSE
cout << "Updated scan widget " << id << "\t"
"mode:"<<mode<<"\t"
"script:" << script << "\t"
"parameter:" << parameter << "\t"
"precision:" << precision << endl;
#endif
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -7,7 +7,6 @@
// Qt Project Class Headers
#include "qTabActions.h"
#include "qDefs.h"
#include "qActionsWidget.h"
// Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
@ -22,7 +21,7 @@ using namespace std;
qTabActions::qTabActions(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent),myDet(detector){
QWidget(parent),myDet(detector),positions(NULL){
SetupWidgetWindow();
Initialization();
}
@ -59,48 +58,54 @@ void qTabActions::SetupWidgetWindow(){
group = new QButtonGroup(this);
palette = new QPalette();
char names[NumTotalActions][200] = {
"Action at Start",
"Scan Level 0",
"Scan Level 1",
"Action before each Frame",
"Positions",
"Header before Frame",
"Header after Frame",
"Action after each Frame",
"Action at Stop"
};
// For each level of Actions
for(int i=0;i<NUM_ACTION_WIDGETS;i++){
// Add the extra widgets only for the 1st 2 levels
if((i==ActionsWidget::Scan0)||(i==ActionsWidget::Scan1))
actionWidget[i] = new ActionsWidget(this,myDet,1,i);
else
actionWidget[i] = new ActionsWidget(this,myDet,0,i);
for(int i=0;i<NumTotalActions;i++){
//common widgets
lblName[i] = new QLabel(QString(names[i]));
btnExpand[i] = new QPushButton("+");
btnExpand[i]->setFixedSize(20,20);
lblName[i] = new QLabel("");
btnExpand[i]->setFixedSize(20,20);
group->addButton(btnExpand[i],i);
//Number of positions is only for mythen or gotthard
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
if((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::AGIPD)) {
lblName[NumPositions]->setEnabled(false);
btnExpand[NumPositions]->setEnabled(false);
}
//add the widgets to the layout , depending on the type create the widgets
gridLayout->addWidget(btnExpand[i],(i*2),0);
gridLayout->addWidget(lblName[i],(i*2),1);
gridLayout->addWidget(actionWidget[i],(i*2)+1,1,1,2);
/* gridLayout->addWidget(btnExpand[i],(i*2),i);
gridLayout->addWidget(lblName[i],(i*2),i+1);
gridLayout->addWidget(actionWidget[i],(i*2)+1,i+1,1,2);*/
}
if(i==NumPositions){
CreatePositionsWidget();
gridLayout->addWidget(positionWidget,(i*2)+1,1,1,2);
positionWidget->hide();
}else if((i==Scan0)||(i==Scan1)){
scanWidget[qScanWidget::NUM_SCAN_WIDGETS] = new qScanWidget(this,myDet);
gridLayout->addWidget(scanWidget[qScanWidget::NUM_SCAN_WIDGETS-1],(i*2)+1,1,1,2);
scanWidget[qScanWidget::NUM_SCAN_WIDGETS-1]->hide();
}else{
actionWidget[qActionsWidget::NUM_ACTION_WIDGETS] = new qActionsWidget(this,myDet);
gridLayout->addWidget(actionWidget[qActionsWidget::NUM_ACTION_WIDGETS-1],(i*2)+1,1,1,2);
actionWidget[qActionsWidget::NUM_ACTION_WIDGETS-1]->hide();
}
//gridLayout->addWidget(btnExpand[i],(i*2),i);
//gridLayout->addWidget(lblName[i],(i*2),i+1);
//gridLayout->addWidget(actionWidget[i],(i*2)+1,i+1,1,2);
// Label Values
lblName[ActionsWidget::Start]->setText("Action at Start");
lblName[ActionsWidget::Scan0]->setText("Scan Level 0");
lblName[ActionsWidget::Scan1]->setText("Scan Level 1");
lblName[ActionsWidget::ActionBefore]->setText("Action before each Frame");
lblName[ActionsWidget::NumPositions]->setText("Positions");
lblName[ActionsWidget::HeaderBefore]->setText("Header before Frame");
lblName[ActionsWidget::HeaderAfter]->setText("Header after Frame");
lblName[ActionsWidget::ActionAfter]->setText("Action after each Frame");
lblName[ActionsWidget::Stop]->setText("Action at Stop");
// initially hide all the widgets
for(int i=0;i<NUM_ACTION_WIDGETS;i++)
actionWidget[i]->hide();
//Number of positions is only for mythen or gotthard
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
if((detType == slsDetectorDefs::EIGER) || (detType == slsDetectorDefs::AGIPD)) {
lblName[ActionsWidget::NumPositions]->setEnabled(false);
btnExpand[ActionsWidget::NumPositions]->setEnabled(false);
}
}
@ -109,11 +114,75 @@ void qTabActions::SetupWidgetWindow(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::Initialization(){
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
connect(actionWidget[ActionsWidget::Scan0],SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int)));
connect(actionWidget[ActionsWidget::Scan1],SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int)));
void qTabActions::CreatePositionsWidget(){
positionWidget = new QWidget;
positionWidget->setFixedHeight(25);
QGridLayout *layout = new QGridLayout(positionWidget);
layout->setContentsMargins(0,0,0,0);
layout->setHorizontalSpacing(0);
layout->setVerticalSpacing(5);
lblNumPos = new QLabel("Number of Positions:");
lblNumPos->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(lblNumPos,0,0);
layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,1);
spinNumPos = new QSpinBox(this);
layout->addWidget(spinNumPos,0,2);
layout->addItem(new QSpacerItem(80,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,3);
lblPosList = new QLabel("List of Positions:");
lblPosList->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
lblPosList->setEnabled(false);
lblPosList->setToolTip("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</tnobr>");
layout->addWidget(lblPosList,0,4);
layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,5);
comboPos = new QComboBox(this);
comboPos->setEditable(true);
comboPos->setCompleter(false);
normal = comboPos->palette();
comboPos->setEnabled(false);
QDoubleValidator *validate = new QDoubleValidator(comboPos);
comboPos->setValidator(validate);
layout->addWidget(comboPos,0,6);
layout->addItem(new QSpacerItem(5,20,QSizePolicy::Fixed,QSizePolicy::Fixed),0,7);
btnDelete = new QPushButton("Delete");
btnDelete->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
layout->addWidget(btnDelete,0,8);
//might be included at some point
/* QGroupBox *w = new QGroupBox;
layout->addWidget(w,1,0,1,9);
QHBoxLayout *l1 = new QHBoxLayout(w);
l1->setContentsMargins(0,0,0,0);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
chkInvert = new QCheckBox("Invert Angles");
l1->addWidget(chkInvert);
chkSeparate = new QCheckBox("Separate Two Halves");
l1->addWidget(chkSeparate);
chkReturn = new QCheckBox("Return to Start Position");
chkReturn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
l1->addWidget(chkReturn);
l1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
w->setLayout(l1);*/
positionWidget->setLayout(layout);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::Initialization(){
//expand
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
//enable scan box in plot tab
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
connect(scanWidget[i], SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int)));
//positions
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
connect(btnDelete, SIGNAL(clicked()), this, SLOT(DeletePosition()));
}
@ -126,28 +195,104 @@ void qTabActions::Expand(QAbstractButton *button ){
if(!QString::compare(button->text(), "-")){
palette->setColor(QPalette::WindowText,Qt::black);
lblName[index]->setPalette(*palette);
actionWidget[index]->hide();
button->setText("+");
if((index==ActionsWidget::Scan0)||(index==ActionsWidget::Scan1)){
if(index==NumPositions) {
positionWidget->hide();
setFixedHeight(height()-30);//-80 if the checkboxes are included
}
else if((index==Scan0)||(index==Scan1)) {
scanWidget[GetActualIndex(index)]->hide();
setFixedHeight(height()-130);
}
else if(index==ActionsWidget::NumPositions)
setFixedHeight(height()-80);
else
else {
actionWidget[GetActualIndex(index)]->hide();
setFixedHeight(height()-30);
}
}else{
// Expand
palette->setColor(QPalette::WindowText,QColor(0,0,200,255));
lblName[index]->setPalette(*palette);
actionWidget[index]->show();
button->setText("-");
if((index==ActionsWidget::Scan0)||(index==ActionsWidget::Scan1)){
if(index==NumPositions){
positionWidget->show();
setFixedHeight(height()+30);//+80 if the checkboxes are included
}
else if((index==Scan0)||(index==Scan1)){
scanWidget[GetActualIndex(index)]->show();
setFixedHeight(height()+130);
}
else if(index==ActionsWidget::NumPositions)
setFixedHeight(height()+80);
else
else{
actionWidget[GetActualIndex(index)]->show();
setFixedHeight(height()+30);
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::SetPosition(){
#ifdef VERBOSE
cout << "Entering SetPosition\tnum Pos:" << spinNumPos->value() << "\tlist count:" << comboPos->count() << endl;
#endif
//get number of positions
int numPos = spinNumPos->value();
comboPos->setMaxCount(numPos);
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
//deleting too many or not entering enough
if(numPos>comboPos->count()){
QPalette red = QPalette();
red.setColor(QPalette::Active,QPalette::WindowText,Qt::red);
lblPosList->setPalette(red);
QString tip = QString("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</nobr><br><br>")+
QString("<nobr><font color=\"red\">Add ")+
(QString("%1").arg(((numPos)-(comboPos->count()))))+
QString(" more positions to the list to match <b>Number of Positions</b>.</font></nobr>");
lblPosList->setToolTip(tip);
lblPosList->setText("List of Positions:*");
}else{
lblPosList->setText("List of Positions:");
lblPosList->setPalette(normal);
lblPosList->setToolTip("<nobr>Enter the positions at which the detector should be moved.</nobr><br>"
"<nobr>Number of entries is restricted to <b>Number of Positions</b> field.</tnobr>");
//delete existing positions
if (positions) delete [] positions;
positions=new float[numPos];
//copying the list
for(int i=0;i<numPos;i++)
positions[i] = comboPos->itemText(i).toDouble();
//setting the list and catching error
if(myDet->setPositions(numPos,positions)!=numPos)
qDefs::WarningMessage("The positions list was not set for some reason.","Actions");
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabActions::DeletePosition(){
QString pos = comboPos->currentText();
bool found = false;
//loops through to find the index and to make sure its in the list
for(int i=0;i<comboPos->count();i++){
if(!comboPos->itemText(i).compare(pos)){
found = true;
comboPos->removeItem(i);
break;
}
}
if(found){
#ifdef VERBOSE
cout << "Deleting Position " << endl;
#endif
}
}
@ -157,12 +302,64 @@ void qTabActions::Expand(QAbstractButton *button ){
void qTabActions::Refresh(){
#ifdef VERBOSE
cout << "Updating action widgets " << endl;
cout << "Updating all action widgets " << endl;
#endif
for(int i=0;i<NUM_ACTION_WIDGETS;i++)
if(lblName[NumPositions]->isEnabled()){
//delete existing positions
if (positions) delete [] positions;
//get number of positions
int numPos=myDet->getPositions();
comboPos->setMaxCount(numPos);
//set the number of positions in the gui
disconnect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
spinNumPos->setValue(numPos);
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));
positions=new float[numPos];
//load the positions
myDet->getPositions(positions);
//delete the combolist and reload it
disconnect(comboPos,SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
comboPos->setEnabled(numPos);
lblPosList->setEnabled(numPos);
lblPosList->setText("List of Positions:");
lblPosList->setPalette(normal);
for(int i=0;i<comboPos->count();i++)
comboPos->removeItem(i);
for(int i=0;i<numPos;i++)
comboPos->insertItem(i,QString("%1").arg(positions[i]));
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
#ifdef VERBOSE
cout << "Updated position widget\tnum:" << numPos << endl;
#endif
}
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
scanWidget[i]->Refresh();
for(int i=0;i<qActionsWidget::NUM_ACTION_WIDGETS;i++)
actionWidget[i]->Refresh();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qTabActions::GetActualIndex(int index){
switch(index){
case 0: return slsDetectorDefs::startScript;
case Scan0: return 0;
case Scan1: return 1;
case 3: return slsDetectorDefs::scriptBefore;
case 5: return slsDetectorDefs::headerBefore;
case 6: return slsDetectorDefs::headerAfter;
case 7: return slsDetectorDefs::scriptAfter;
case 8: return slsDetectorDefs::stopScript;
default: return -1;
}
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -639,8 +639,8 @@ void qTabMeasurement::setTimingMode(int mode){
// to let qdrawplot know that triggers or frames are used
myPlot->setFrameEnabled(lblNumTriggers->isEnabled());
myPlot->setTriggerEnabled(lblNumFrames->isEnabled());
myPlot->setFrameEnabled(lblNumFrames->isEnabled());
myPlot->setTriggerEnabled(lblNumTriggers->isEnabled());
return;
}
@ -660,8 +660,8 @@ void qTabMeasurement::Refresh(){
SetupTimingMode();
// to let qdrawplot know that triggers or frames are used
myPlot->setFrameEnabled(lblNumTriggers->isEnabled());
myPlot->setTriggerEnabled(lblNumFrames->isEnabled());
myPlot->setFrameEnabled(lblNumFrames->isEnabled());
myPlot->setTriggerEnabled(lblNumTriggers->isEnabled());
}

View File

@ -86,7 +86,7 @@ void qTabPlot::SetupWidgetWindow(){
spinTimeGap->setMinimum(0);
spinTimeGap->setDecimals(3);
spinTimeGap->setMaximum(999999);
spinTimeGap->setValue(500.00);
spinTimeGap->setValue(myPlot->GetMinimumPlotTimer());
comboTimeGapUnit = new QComboBox;
comboTimeGapUnit->addItem("hr");
comboTimeGapUnit->addItem("min");
@ -362,8 +362,8 @@ void qTabPlot::SetPlot(){
if(radioNoPlot->isChecked()){
myPlot->EnablePlot(false);
/**if enable is true, disable everything */
box1D->hide();
box2D->hide();
if(isOneD) {box1D->show(); box1D->setEnabled(false); box2D->hide();}
if(!isOneD){box2D->show(); box2D->setEnabled(false); box1D->hide();}
boxSnapshot->setEnabled(false);
boxSave->setEnabled(false);
boxFrequency->setEnabled(false);
@ -372,8 +372,8 @@ void qTabPlot::SetPlot(){
}else {
myPlot->EnablePlot(true);
/**if enable is true, disable everything */
if(isOneD) box1D->show(); else box1D->hide();
if(!isOneD) box2D->show(); else box2D->hide();
if(isOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide();
if(!isOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide();
boxSnapshot->setEnabled(true);
boxSave->setEnabled(true);
boxFrequency->setEnabled(true);
@ -428,7 +428,7 @@ void qTabPlot::SetFrequency(){
if(timeMS<minPlotTimer){
int minFrame = (ceil)(minPlotTimer/acqPeriodMS);
qDefs::WarningMessage("<b>Plot Tab:</b> Interval between Plots - The nth Image must be larger.<br><br>"
"Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 500ms."
"Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 250ms."
"<br><br>Nth image adjusted to minimum, "
"for the chosen Acquisition Period.","Plot");
spinNthFrame->setValue(minFrame);