From 981d2b53cf740b616848e4521f552c18b5ef116f Mon Sep 17 00:00:00 2001 From: nemu Date: Thu, 5 Mar 2009 16:13:56 +0000 Subject: [PATCH] added plot dialog --- src/musrgui/PGetPlotDialog.cpp | 149 ++++++++++++++++++ src/musrgui/PGetPlotDialog.h | 48 ++++++ src/musrgui/PSubTextEdit.cpp | 6 + src/musrgui/forms/PGetPlotDialogBase.ui | 198 +++++++++++++----------- src/musrgui/musrgui.pro | 98 ++++++------ 5 files changed, 358 insertions(+), 141 deletions(-) create mode 100644 src/musrgui/PGetPlotDialog.cpp create mode 100644 src/musrgui/PGetPlotDialog.h diff --git a/src/musrgui/PGetPlotDialog.cpp b/src/musrgui/PGetPlotDialog.cpp new file mode 100644 index 00000000..c17e7d04 --- /dev/null +++ b/src/musrgui/PGetPlotDialog.cpp @@ -0,0 +1,149 @@ +/**************************************************************************** + + PGetPlotDialog.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 + +#include "PGetPlotDialog.h" + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +PGetPlotDialog::PGetPlotDialog() +{ + fXRangeLow_lineEdit->setValidator( new QDoubleValidator(fXRangeLow_lineEdit) ); + fXRangeUp_lineEdit->setValidator( new QDoubleValidator(fXRangeUp_lineEdit) ); + fYRangeLow_lineEdit->setValidator( new QDoubleValidator(fYRangeLow_lineEdit) ); + fYRangeUp_lineEdit->setValidator( new QDoubleValidator(fYRangeUp_lineEdit) ); + + fPlot_textEdit->setTextFormat( PlainText ); + fPlot_textEdit->setFamily("Courier"); + fPlot_textEdit->setPointSize(10); // 10pt +} + +//---------------------------------------------------------------------------------------------------- +/** + *

+ */ +void PGetPlotDialog::addPlot() +{ + QString param = ""; + QString str = ""; + QString spaces; + + // add begining of plot block if fPlot_textEdit is still empty + if (fPlot_textEdit->text().isEmpty()) { + param = "###############################################################\n"; + } + + // write type + param += "PLOT "; + if (fType_comboBox->currentText() == "Single Histo") { + param += "1 (single histo plot)\n"; + } else if (fType_comboBox->currentText() == "Asymmetry") { + param += "2 (asymmetry plot)\n"; + } else if (fType_comboBox->currentText() == "RRF") { + param += "4 (rotating reference frame plot)\n"; + } else if (fType_comboBox->currentText() == "NonMusr") { + param += "8 (non muSR plot)\n"; + } + + // write runs + param += "runs " + fRunList_lineEdit->text() + "\n"; + + // write range + param += "range "; + // lower x-/time range + str = fXRangeLow_lineEdit->text(); + if (str.isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "empty lower time-/x-range name not allowed!", + QMessageBox::Ok, QMessageBox::NoButton); + return; + } + param += str; + if (str.length() < 8) + param += spaces.fill(' ', 8 - str.length()); + else + param += " "; + + // upper x-/time range + str = fXRangeUp_lineEdit->text(); + if (str.isEmpty()) { + QMessageBox::critical(this, "**ERROR**", + "empty upper time-/x-range name not allowed!", + QMessageBox::Ok, QMessageBox::NoButton); + return; + } + param += str; + if (str.length() < 8) + param += spaces.fill(' ', 8 - str.length()); + else + param += " "; + + // check y-range: either none given or both + if ((fYRangeLow_lineEdit->text().isEmpty() && !fYRangeUp_lineEdit->text().isEmpty()) || + (!fYRangeLow_lineEdit->text().isEmpty() && fYRangeUp_lineEdit->text().isEmpty())) { + QMessageBox::critical(this, "**ERROR**", + "Only fully empty y-range, or give lower AND upper y-range is acceptable!\n Will ignore the y-range", + QMessageBox::Ok, QMessageBox::NoButton); + } else if (!fYRangeLow_lineEdit->text().isEmpty() && !fYRangeUp_lineEdit->text().isEmpty()) { + str = fYRangeLow_lineEdit->text(); + param += str; + if (str.length() < 8) + param += spaces.fill(' ', 8 - str.length()); + else + param += " "; + param += fYRangeUp_lineEdit->text() + "\n"; + } else { + param += "\n"; + } + param += "\n"; + + fPlot_textEdit->append(param); + + // clean input + fRunList_lineEdit->clear(); + fXRangeLow_lineEdit->clear(); + fXRangeUp_lineEdit->clear(); + fYRangeLow_lineEdit->clear(); + fYRangeUp_lineEdit->clear(); + fRunList_lineEdit->setFocus(); +} + +//---------------------------------------------------------------------------------------------------- +// END +//---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PGetPlotDialog.h b/src/musrgui/PGetPlotDialog.h new file mode 100644 index 00000000..5a1f27d9 --- /dev/null +++ b/src/musrgui/PGetPlotDialog.h @@ -0,0 +1,48 @@ +/**************************************************************************** + + PGetPlotDialog.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 _PGETPLOTDIALOG_H_ +#define _PGETPLOTDIALOG_H_ + +#include "forms/PGetPlotDialogBase.h" + +class PGetPlotDialog : public PGetPlotDialogBase +{ + public: + PGetPlotDialog(); + + QString getPlotBlock() { return fPlot_textEdit->text(); } + + public slots: + void addPlot(); +}; + +#endif // _PGETPLOTDIALOG_H_ diff --git a/src/musrgui/PSubTextEdit.cpp b/src/musrgui/PSubTextEdit.cpp index f4b35674..dfb6de3a 100644 --- a/src/musrgui/PSubTextEdit.cpp +++ b/src/musrgui/PSubTextEdit.cpp @@ -38,6 +38,7 @@ #include "forms/PGetTitleDialog.h" #include "PGetParameterDialog.h" #include "PGetFourierDialog.h" +#include "PGetPlotDialog.h" //---------------------------------------------------------------------------------------------------- /** @@ -207,6 +208,11 @@ void PSubTextEdit::insertFourierBlock() */ void PSubTextEdit::insertPlotBlock() { + PGetPlotDialog *dlg = new PGetPlotDialog(); + + if (dlg->exec() == QDialog::Accepted) { + insert(dlg->getPlotBlock()+"\n"); + } } //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/forms/PGetPlotDialogBase.ui b/src/musrgui/forms/PGetPlotDialogBase.ui index b4631139..1b7e407d 100644 --- a/src/musrgui/forms/PGetPlotDialogBase.ui +++ b/src/musrgui/forms/PGetPlotDialogBase.ui @@ -18,83 +18,6 @@ true - - - layout2 - - - - 10 - 270 - 490 - 28 - - - - - unnamed - - - - fCancel_button - - - &Cancel - - - - - - true - - - - - Horizontal Spacing2 - - - Horizontal - - - Expanding - - - - 290 - 20 - - - - - - fAdd_pushButton - - - &Add - - - Alt+A - - - - - fOk_button - - - &OK - - - - - - true - - - true - - - - fXRangeUp_lineEdit @@ -211,28 +134,15 @@ Run List - - - fRunList_lineEdit - - - - 90 - 40 - 150 - 24 - - - - Asymmetry + Single Histo - Single Histo + Asymmetry @@ -257,6 +167,19 @@ + + + fRunList_lineEdit + + + + 90 + 40 + 150 + 24 + + + fPlot_textEdit @@ -270,6 +193,97 @@ + + + fCancel_button + + + + 11 + 271 + 75 + 26 + + + + &Cancel + + + + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 290 + 20 + + + + + 92 + 274 + 290 + 20 + + + + + + fAdd_pushButton + + + + 388 + 271 + 56 + 26 + + + + &Add + + + Alt+A + + + + + fOk_button + + + + 450 + 271 + 49 + 26 + + + + &OK + + + + + + true + + + true + + diff --git a/src/musrgui/musrgui.pro b/src/musrgui/musrgui.pro index 6d802fb0..2948a295 100644 --- a/src/musrgui/musrgui.pro +++ b/src/musrgui/musrgui.pro @@ -1,58 +1,58 @@ -TEMPLATE = app - -TARGET = musrgui -target.path = $$(HOME)/analysis/bin -INSTALLS += target +TEMPLATE = app +TARGET = musrgui +target.path = $$(HOME)/analysis/bin +INSTALLS += target # install path for the XML configuration file -unix: xml.path = $$(HOME)/analysis/bin/ -win32: xml.path = $$(HOME)/analysis/bin/ +unix:xml.path = $$(HOME)/analysis/bin/ +win32:xml.path = $$(HOME)/analysis/bin/ xml.files = musrgui_startup.xml INSTALLS += xml -CONFIG += qt warn_on debug +CONFIG += qt \ + warn_on \ + debug +HEADERS = PTextEdit.h \ + PSubTextEdit.h \ + PAdmin.h \ + PFitOutputHandler.h \ + PGetDefaultDialog.h \ + PGetParameterDialog.h \ + PGetFourierDialog.h \ + PGetPlotDialog.h +SOURCES = PTextEdit.cpp \ + PSubTextEdit.cpp \ + PAdmin.cpp \ + PFitOutputHandler.cpp \ + PGetDefaultDialog.cpp \ + PGetParameterDialog.cpp \ + PGetFourierDialog.cpp \ + PGetPlotDialog.cpp \ + main.cpp -HEADERS = PTextEdit.h \ - PSubTextEdit.h \ - PAdmin.h \ - PFitOutputHandler.h \ - PGetDefaultDialog.h \ - PGetParameterDialog.h \ - PGetFourierDialog.h - -SOURCES = PTextEdit.cpp \ - PSubTextEdit.cpp \ - PAdmin.cpp \ - PFitOutputHandler.cpp \ - PGetDefaultDialog.cpp \ - PGetParameterDialog.cpp \ - PGetFourierDialog.cpp \ - main.cpp - -FORMS = forms/PGetDefaultDialogBase.ui \ - forms/PMusrGuiAbout.ui \ - forms/PGetTitleDialog.ui \ - forms/PGetParameterDialogBase.ui \ - forms/PGetFourierDialogBase.ui \ - forms/PGetPlotDialogBase.ui +FORMS = forms/PGetDefaultDialogBase.ui \ + forms/PMusrGuiAbout.ui \ + forms/PGetTitleDialog.ui \ + forms/PGetParameterDialogBase.ui \ + forms/PGetFourierDialogBase.ui \ + forms/PGetPlotDialogBase.ui -IMAGES = images/editcopy.xpm \ - images/editcut.xpm \ - images/editpaste.xpm \ - images/editredo.xpm \ - images/editundo.xpm \ - images/filenew.xpm \ - images/fileopen.xpm \ - images/fileprint.xpm \ - images/filesave.xpm \ - images/musrasym.xpm \ - images/musrsinglehisto.xpm \ - images/musrcalcchisq.xpm \ - images/musrfit.xpm \ - images/musrmlog2db.xpm \ - images/musrview.xpm \ - images/musrt0.xpm \ - images/musrprefs.xpm - +IMAGES = images/editcopy.xpm \ + images/editcut.xpm \ + images/editpaste.xpm \ + images/editredo.xpm \ + images/editundo.xpm \ + images/filenew.xpm \ + images/fileopen.xpm \ + images/fileprint.xpm \ + images/filesave.xpm \ + images/musrasym.xpm \ + images/musrsinglehisto.xpm \ + images/musrcalcchisq.xpm \ + images/musrfit.xpm \ + images/musrmlog2db.xpm \ + images/musrview.xpm \ + images/musrt0.xpm \ + images/musrprefs.xpm