some more stuff added to musrgui

This commit is contained in:
nemu 2009-03-01 19:51:46 +00:00
parent dc38de5471
commit 0505aba5af
10 changed files with 689 additions and 25 deletions

View File

@ -0,0 +1,180 @@
/****************************************************************************
PGetParameterDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <qlineedit.h>
#include <qvalidator.h>
#include <qmessagebox.h>
#include <qspinbox.h>
#include <qtextedit.h>
#include "PGetParameterDialog.h"
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
PGetParameterDialog::PGetParameterDialog()
{
fValue_lineEdit->setValidator( new QDoubleValidator(fValue_lineEdit) );
fStep_lineEdit->setValidator( new QDoubleValidator(fStep_lineEdit) );
fParam_textEdit->setTextFormat( PlainText );
fParam_textEdit->setFamily("Courier");
fParam_textEdit->setPointSize(10); // 10pt
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PGetParameterDialog::paramAdd()
{
QString param, str, spaces;
// get No
str = fParamNo_spinBox->text();
if (str.toInt() < 10)
param = " " + str + " ";
else
param = " " + str + " ";
// get name
str = fName_lineEdit->text();
if (str.isEmpty()) {
QMessageBox::critical(this, "**ERROR**",
"empty parameter name not allowed!",
QMessageBox::Ok, QMessageBox::NoButton);
return;
} else {
param += str;
if (str.length() < 13)
param += spaces.fill(' ', 13-str.length());
else
param += " ";
}
// get value
str = fValue_lineEdit->text();
if (str.isEmpty()) {
QMessageBox::critical(this, "**ERROR**",
"empty parameter value not allowed!",
QMessageBox::Ok, QMessageBox::NoButton);
return;
} else {
param += str;
if (str.length() < 10)
param += spaces.fill(' ', 10-str.length());
else
param += " ";
}
// get step
str = fStep_lineEdit->text();
if (str.isEmpty()) {
QMessageBox::critical(this, "**ERROR**",
"empty parameter step not allowed!",
QMessageBox::Ok, QMessageBox::NoButton);
return;
} else {
param += str;
if (str.length() < 10)
param += spaces.fill(' ', 10-str.length());
else
param += " ";
}
// add positive error none
param += "none ";
if ((fLower_lineEdit->text() != "none") || (fUpper_lineEdit->text() != "none")) {
// get lower boundary
str = fLower_lineEdit->text();
bool ok;
double val = str.toDouble(&ok);
if (!ok && (str != "none")) {
QMessageBox::critical(this, "**ERROR**",
"invalid lower boundary! Must be a double are the key word 'none'",
QMessageBox::Ok, QMessageBox::NoButton);
return;
} else {
param += str;
if (str.length() < 10)
param += spaces.fill(' ', 10-str.length());
else
param += " ";
}
// get upper boundary
str = fUpper_lineEdit->text();
val = str.toDouble(&ok);
if (!ok && (str != "none")) {
QMessageBox::critical(this, "**ERROR**",
"invalid upper boundary! Must be a double are the key word 'none'",
QMessageBox::Ok, QMessageBox::NoButton);
return;
} else {
param += str;
if (str.length() < 10)
param += spaces.fill(' ', 10-str.length());
else
param += " ";
}
}
param += "\n";
// write parameter string into fParam_textEdit
fParam_textEdit->append(param);
// increment No counter in spinBox
fParamNo_spinBox->stepUp();
// reset name lineEdit
fName_lineEdit->setText("");
// reset value lineEdit
fValue_lineEdit->setText("");
// reset step lineEdit
fStep_lineEdit->setText("");
// reset lower boundary lineEdit
fLower_lineEdit->setText("none");
// reset upper boundary lineEdit
fUpper_lineEdit->setText("none");
fName_lineEdit->setFocus();
}
//----------------------------------------------------------------------------------------------------
// END
//----------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,48 @@
/****************************************************************************
PGetParameterDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
$Id$
*****************************************************************************/
/***************************************************************************
* Copyright (C) 2009 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PGETPARAMETERDIALOG_H_
#define _PGETPARAMETERDIALOG_H_
#include "forms/PGetParameterDialogBase.h"
class PGetParameterDialog : public PGetParameterDialogBase
{
public:
PGetParameterDialog();
QString getParams() { return fParam_textEdit->text(); }
public slots:
void paramAdd();
};
#endif // _PGETPARAMETERDIALOG_H_

View File

@ -36,6 +36,7 @@
#include "PSubTextEdit.h"
#include "forms/PGetTitleDialog.h"
#include "PGetParameterDialog.h"
//----------------------------------------------------------------------------------------------------
/**
@ -58,18 +59,10 @@ QPopupMenu* PSubTextEdit::createPopupMenu(const QPoint &pos)
connect(a, SIGNAL( activated() ), this, SLOT( insertTitle() ));
a->addTo( menu );
menu->insertSeparator();
a = new QAction(tr("insert Parameter Block"), 0, this, "insertParameterBlock");
connect(a, SIGNAL( activated() ), this, SLOT( insertParameterBlock() ));
a->addTo( menu );
a = new QAction(tr("insert Parameter"), 0, this, "insertParameter");
connect(a, SIGNAL( activated() ), this, SLOT( insertParameter() ));
a->addTo( menu );
menu->insertSeparator();
a = new QAction(tr("insert Theory Block"), 0, this, "insertTheoryBlock");
connect(a, SIGNAL( activated() ), this, SLOT( insertTheoryBlock() ));
a->addTo( menu );
@ -78,6 +71,8 @@ QPopupMenu* PSubTextEdit::createPopupMenu(const QPoint &pos)
connect(a, SIGNAL( activated() ), this, SLOT( insertFunctionBlock() ));
a->addTo( menu );
menu->insertSeparator();
a = new QAction(tr("insert Asymmetry Block"), 0, this, "insertAsymRunBlock");
connect(a, SIGNAL( activated() ), this, SLOT( insertAsymRunBlock() ));
a->addTo( menu );
@ -90,6 +85,8 @@ QPopupMenu* PSubTextEdit::createPopupMenu(const QPoint &pos)
connect(a, SIGNAL( activated() ), this, SLOT( insertNonMusrRunBlock() ));
a->addTo( menu );
menu->insertSeparator();
a = new QAction(tr("insert Command Block"), 0, this, "insertCommandBlock");
connect(a, SIGNAL( activated() ), this, SLOT( insertCommandBlock() ));
a->addTo( menu );
@ -128,18 +125,10 @@ void PSubTextEdit::insertTitle()
*/
void PSubTextEdit::insertParameterBlock()
{
insert("###############################################################\n");
insert("FITPARAMETER\n");
insert("# Nr. Name Value Step Pos_Error Bounderies\n");
insert(" 1 alpha 1.0 0.1 none 0 none\n\n");
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PSubTextEdit::insertParameter()
{
PGetParameterDialog *dlg = new PGetParameterDialog();
if (dlg->exec() == QDialog::Accepted) {
insert(dlg->getParams());
}
}
//----------------------------------------------------------------------------------------------------

View File

@ -47,7 +47,6 @@ protected:
private slots:
void insertTitle();
void insertParameterBlock();
void insertParameter();
void insertTheoryBlock();
void insertFunctionBlock();
void insertAsymRunBlock();

View File

@ -229,6 +229,11 @@ void PTextEdit::setupMusrActions()
a->addTo( tb );
a->addTo( menu );
a = new QAction( QPixmap::fromMimeSource( "musrmlog2db.xpm" ), tr( "&Mlog2dB" ), ALT + Key_M, this, "musrMlog2Db" );
connect( a, SIGNAL( activated() ), this, SLOT( musrMlog2Db() ) );
a->addTo( tb );
a->addTo( menu );
menu->insertSeparator();
a = new QAction( QPixmap::fromMimeSource( "musrview.xpm" ), tr( "&View" ), ALT + Key_V, this, "musrView" );
@ -770,6 +775,20 @@ void PTextEdit::musrFit()
fitOutputHandler.exec();
}
//----------------------------------------------------------------------------------------------------
/**
* <p>
*/
void PTextEdit::musrMlog2Db()
{
if ( !currentEditor() )
return;
QMessageBox::information( this, "musrMlog2Db",
"Will call mlog2db.\n"
"NOT IMPLEMENTED YET :-(" );
}
//----------------------------------------------------------------------------------------------------
/**
* <p>

View File

@ -83,6 +83,7 @@ private slots:
void musrGetSingleHistoDefault();
void musrCalcChisq();
void musrFit();
void musrMlog2Db();
void musrView();
void musrT0();
void musrPrefs();

View File

@ -0,0 +1,396 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>PGetParameterDialogBase</class>
<widget class="QDialog">
<property name="name">
<cstring>PGetParameterDialogBase</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>428</height>
</rect>
</property>
<property name="caption">
<string>Get Parameter</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<widget class="QLineEdit">
<property name="name">
<cstring>fName_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>140</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fStep_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>70</y>
<width>70</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fStep_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>300</x>
<y>40</y>
<width>40</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Step</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fValue_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>220</x>
<y>40</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Value</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fName_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>70</x>
<y>40</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fNo_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>40</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>No</string>
</property>
</widget>
<widget class="QFrame">
<property name="name">
<cstring>frame5</cstring>
</property>
<property name="geometry">
<rect>
<x>380</x>
<y>11</y>
<width>170</width>
<height>90</height>
</rect>
</property>
<property name="frameShape">
<enum>StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>Raised</enum>
</property>
<widget class="QLabel">
<property name="name">
<cstring>fLower_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Lower</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fUpper_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Upper</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fLower_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>70</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>none</string>
</property>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fUpper_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>70</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>none</string>
</property>
</widget>
<widget class="QLabel">
<property name="name">
<cstring>fBoundaries_textLabel</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>110</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Boundaries</string>
</property>
</widget>
</widget>
<widget class="QLineEdit">
<property name="name">
<cstring>fValue_lineEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>220</x>
<y>70</y>
<width>70</width>
<height>24</height>
</rect>
</property>
</widget>
<widget class="QSpinBox">
<property name="name">
<cstring>fParamNo_spinBox</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>50</width>
<height>24</height>
</rect>
</property>
<property name="maxValue">
<number>999</number>
</property>
<property name="minValue">
<number>1</number>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>fCancel_pushButton</cstring>
</property>
<property name="geometry">
<rect>
<x>11</x>
<y>391</y>
<width>75</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>440</width>
<height>20</height>
</size>
</property>
<property name="geometry">
<rect>
<x>92</x>
<y>394</y>
<width>440</width>
<height>20</height>
</rect>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>fAdd_pushButton</cstring>
</property>
<property name="geometry">
<rect>
<x>538</x>
<y>391</y>
<width>56</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>&amp;Add</string>
</property>
<property name="accel">
<string>Alt+A</string>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>fOk_PushButton</cstring>
</property>
<property name="geometry">
<rect>
<x>600</x>
<y>391</y>
<width>49</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QTextEdit">
<property name="name">
<cstring>fParam_textEdit</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>640</width>
<height>270</height>
</rect>
</property>
<property name="font">
<font>
<family>Courier</family>
</font>
</property>
<property name="text">
<string>###############################################################
FITPARAMETER
# Nr. Name Value Step Pos_Error Bounderies</string>
</property>
<property name="wordWrap">
<enum>WidgetWidth</enum>
</property>
</widget>
</widget>
<connections>
<connection>
<sender>fOk_PushButton</sender>
<signal>clicked()</signal>
<receiver>PGetParameterDialogBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>fCancel_pushButton</sender>
<signal>clicked()</signal>
<receiver>PGetParameterDialogBase</receiver>
<slot>reject()</slot>
</connection>
<connection>
<sender>fAdd_pushButton</sender>
<signal>clicked()</signal>
<receiver>PGetParameterDialogBase</receiver>
<slot>paramAdd()</slot>
</connection>
</connections>
<tabstops>
<tabstop>fParamNo_spinBox</tabstop>
<tabstop>fName_lineEdit</tabstop>
<tabstop>fValue_lineEdit</tabstop>
<tabstop>fStep_lineEdit</tabstop>
<tabstop>fLower_lineEdit</tabstop>
<tabstop>fUpper_lineEdit</tabstop>
<tabstop>fAdd_pushButton</tabstop>
<tabstop>fOk_PushButton</tabstop>
<tabstop>fCancel_pushButton</tabstop>
<tabstop>fParam_textEdit</tabstop>
</tabstops>
<slots>
<slot>paramAdd()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@ -0,0 +1,28 @@
/* XPM */
static char * musrmlog2db_xpm[] = {
"22 22 3 1",
" c None",
". c #000000",
"+ c #FF0000",
" .... . ..... ",
".... . . . ",
" . . . ",
".... ... . . ",
" . . . ",
"....... . . . ",
" . . . ",
".... ",
" + ",
"... + ",
" + ",
"...... + + + ",
" +++ ",
".... + ",
" ",
".... +++ +++ ",
" + + + + ",
"..... + + + + ",
" + + +++ ",
"...... + + + + ",
" + + + + ",
".... +++ +++ "};

View File

@ -18,18 +18,21 @@ HEADERS = PTextEdit.h \
PSubTextEdit.h \
PAdmin.h \
PFitOutputHandler.h \
PGetDefaultDialog.h
PGetDefaultDialog.h \
PGetParameterDialog.h
SOURCES = PTextEdit.cpp \
PSubTextEdit.cpp \
PAdmin.cpp \
PFitOutputHandler.cpp \
PGetDefaultDialog.cpp \
PGetParameterDialog.cpp \
main.cpp
FORMS = forms/PGetDefaultDialogBase.ui \
forms/PMusrGuiAbout.ui \
forms/PGetTitleDialog.ui
forms/PGetTitleDialog.ui \
forms/PGetParameterDialogBase.ui
IMAGES = images/editcopy.xpm \
images/editcut.xpm \
@ -44,6 +47,7 @@ IMAGES = images/editcopy.xpm \
images/musrsinglehisto.xpm \
images/musrcalcchisq.xpm \
images/musrfit.xpm \
images/musrmlog2db.xpm \
images/musrview.xpm \
images/musrt0.xpm \
images/musrprefs.xpm

View File

@ -7,7 +7,7 @@
<general>
<exec_path>/home/nemu/analysis/bin</exec_path>
<default_save_path>/mnt/home/nemu/analysis</default_save_path>
<msr_default_file_path>/afs/psi.ch/user/s/suter_a/development/musrgui</msr_default_file_path>
<msr_default_file_path>/home/nemu/analysis/musrfit/src/musrgui</msr_default_file_path>
<show_mlog>y</show_mlog>
</general>
<msr_file_defaults>