diff --git a/src/musrgui/PGetParameterDialog.cpp b/src/musrgui/PGetParameterDialog.cpp new file mode 100644 index 00000000..daf02ac4 --- /dev/null +++ b/src/musrgui/PGetParameterDialog.cpp @@ -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 +#include +#include +#include +#include + +#include "PGetParameterDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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 +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +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 +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PGetParameterDialog.h b/src/musrgui/PGetParameterDialog.h new file mode 100644 index 00000000..87588f1a --- /dev/null +++ b/src/musrgui/PGetParameterDialog.h @@ -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_ diff --git a/src/musrgui/PSubTextEdit.cpp b/src/musrgui/PSubTextEdit.cpp index f8acbc04..ed4f987e 100644 --- a/src/musrgui/PSubTextEdit.cpp +++ b/src/musrgui/PSubTextEdit.cpp @@ -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"); -} - -//---------------------------------------------------------------------------------------------------- -/** - *

- */ -void PSubTextEdit::insertParameter() -{ + PGetParameterDialog *dlg = new PGetParameterDialog(); + if (dlg->exec() == QDialog::Accepted) { + insert(dlg->getParams()); + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PSubTextEdit.h b/src/musrgui/PSubTextEdit.h index 150afc0e..00214ba7 100644 --- a/src/musrgui/PSubTextEdit.h +++ b/src/musrgui/PSubTextEdit.h @@ -47,7 +47,6 @@ protected: private slots: void insertTitle(); void insertParameterBlock(); - void insertParameter(); void insertTheoryBlock(); void insertFunctionBlock(); void insertAsymRunBlock(); diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp index 2a4c119f..f513fb3c 100644 --- a/src/musrgui/PTextEdit.cpp +++ b/src/musrgui/PTextEdit.cpp @@ -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(); } +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +void PTextEdit::musrMlog2Db() +{ + if ( !currentEditor() ) + return; + + QMessageBox::information( this, "musrMlog2Db", + "Will call mlog2db.\n" + "NOT IMPLEMENTED YET :-(" ); +} + //---------------------------------------------------------------------------------------------------- /** *

diff --git a/src/musrgui/PTextEdit.h b/src/musrgui/PTextEdit.h index ac3379b7..bda28648 100644 --- a/src/musrgui/PTextEdit.h +++ b/src/musrgui/PTextEdit.h @@ -83,6 +83,7 @@ private slots: void musrGetSingleHistoDefault(); void musrCalcChisq(); void musrFit(); + void musrMlog2Db(); void musrView(); void musrT0(); void musrPrefs(); diff --git a/src/musrgui/forms/PGetParameterDialogBase.ui b/src/musrgui/forms/PGetParameterDialogBase.ui new file mode 100644 index 00000000..11d47a49 --- /dev/null +++ b/src/musrgui/forms/PGetParameterDialogBase.ui @@ -0,0 +1,396 @@ + +PGetParameterDialogBase + + + PGetParameterDialogBase + + + + 0 + 0 + 662 + 428 + + + + Get Parameter + + + true + + + + fName_lineEdit + + + + 70 + 70 + 140 + 24 + + + + + + fStep_lineEdit + + + + 300 + 70 + 70 + 24 + + + + + + fStep_textLabel + + + + 300 + 40 + 40 + 20 + + + + Step + + + + + fValue_textLabel + + + + 220 + 40 + 50 + 20 + + + + Value + + + + + fName_textLabel + + + + 70 + 40 + 71 + 20 + + + + Name + + + + + fNo_textLabel + + + + 10 + 40 + 40 + 20 + + + + No + + + + + frame5 + + + + 380 + 11 + 170 + 90 + + + + StyledPanel + + + Raised + + + + fLower_textLabel + + + + 10 + 30 + 71 + 20 + + + + Lower + + + + + fUpper_textLabel + + + + 90 + 30 + 71 + 20 + + + + Upper + + + + + fLower_lineEdit + + + + 10 + 60 + 70 + 24 + + + + none + + + + + fUpper_lineEdit + + + + 90 + 60 + 70 + 24 + + + + none + + + + + fBoundaries_textLabel + + + + 10 + 10 + 110 + 20 + + + + Boundaries + + + + + + fValue_lineEdit + + + + 220 + 70 + 70 + 24 + + + + + + fParamNo_spinBox + + + + 10 + 70 + 50 + 24 + + + + 999 + + + 1 + + + + + fCancel_pushButton + + + + 11 + 391 + 75 + 26 + + + + &Cancel + + + + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 440 + 20 + + + + + 92 + 394 + 440 + 20 + + + + + + fAdd_pushButton + + + + 538 + 391 + 56 + 26 + + + + &Add + + + Alt+A + + + + + fOk_PushButton + + + + 600 + 391 + 49 + 26 + + + + &OK + + + + + + true + + + true + + + + + fParam_textEdit + + + + 10 + 110 + 640 + 270 + + + + + Courier + + + + ############################################################### +FITPARAMETER +# Nr. Name Value Step Pos_Error Bounderies + + + WidgetWidth + + + + + + fOk_PushButton + clicked() + PGetParameterDialogBase + accept() + + + fCancel_pushButton + clicked() + PGetParameterDialogBase + reject() + + + fAdd_pushButton + clicked() + PGetParameterDialogBase + paramAdd() + + + + fParamNo_spinBox + fName_lineEdit + fValue_lineEdit + fStep_lineEdit + fLower_lineEdit + fUpper_lineEdit + fAdd_pushButton + fOk_PushButton + fCancel_pushButton + fParam_textEdit + + + paramAdd() + + + diff --git a/src/musrgui/images/musrmlog2db.xpm b/src/musrgui/images/musrmlog2db.xpm new file mode 100644 index 00000000..4aa1bd07 --- /dev/null +++ b/src/musrgui/images/musrmlog2db.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char * musrmlog2db_xpm[] = { +"22 22 3 1", +" c None", +". c #000000", +"+ c #FF0000", +" .... . ..... ", +".... . . . ", +" . . . ", +".... ... . . ", +" . . . ", +"....... . . . ", +" . . . ", +".... ", +" + ", +"... + ", +" + ", +"...... + + + ", +" +++ ", +".... + ", +" ", +".... +++ +++ ", +" + + + + ", +"..... + + + + ", +" + + +++ ", +"...... + + + + ", +" + + + + ", +".... +++ +++ "}; diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index 0a88973c..df99c2fc 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -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 diff --git a/src/musrgui/musrgui_startup.xml b/src/musrgui/musrgui_startup.xml index 0bd956ad..191fecfb 100644 --- a/src/musrgui/musrgui_startup.xml +++ b/src/musrgui/musrgui_startup.xml @@ -7,7 +7,7 @@ /home/nemu/analysis/bin /mnt/home/nemu/analysis - /afs/psi.ch/user/s/suter_a/development/musrgui + /home/nemu/analysis/musrfit/src/musrgui y