little extension which allows to normalize plots. Only dialogs added so far, no functionality yet.
This commit is contained in:
parent
2035ae5ede
commit
54fee067df
@ -48,6 +48,7 @@ set(SOURCE_FILES
|
|||||||
Pmupp.cpp
|
Pmupp.cpp
|
||||||
PmuppScript.cpp
|
PmuppScript.cpp
|
||||||
PmuppGui.cpp
|
PmuppGui.cpp
|
||||||
|
PGetNormValDialog.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
75
src/musredit_qt5/mupp/PGetNormValDialog.cpp
Normal file
75
src/musredit_qt5/mupp/PGetNormValDialog.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
PGetNormValDialog.cpp
|
||||||
|
|
||||||
|
Author: Andreas Suter
|
||||||
|
e-mail: andreas.suter@psi.ch
|
||||||
|
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007-2020 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 <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QDoubleValidator>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "PGetNormValDialog.h"
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
PGetNormValDialog::PGetNormValDialog(double dval, QWidget *parent, Qt::WindowFlags f) :
|
||||||
|
QDialog(parent, f), fValue(dval)
|
||||||
|
{
|
||||||
|
QVBoxLayout *vbox = new QVBoxLayout;
|
||||||
|
QHBoxLayout *hbox1 = new QHBoxLayout;
|
||||||
|
QHBoxLayout *hbox2 = new QHBoxLayout;
|
||||||
|
|
||||||
|
vbox->addLayout(hbox1);
|
||||||
|
vbox->addLayout(hbox2);
|
||||||
|
|
||||||
|
QLabel *lab = new QLabel("Norm Value: ");
|
||||||
|
QLineEdit *fEdit = new QLineEdit();
|
||||||
|
fEdit->setValidator(new QDoubleValidator());
|
||||||
|
fEdit->setText(QString("%1").arg(fValue));
|
||||||
|
hbox1->addWidget(lab);
|
||||||
|
hbox1->addWidget(fEdit);
|
||||||
|
|
||||||
|
QPushButton *ok = new QPushButton("OK");
|
||||||
|
QPushButton *cancel = new QPushButton("Cancel");
|
||||||
|
hbox2->addWidget(ok);
|
||||||
|
hbox2->addWidget(cancel);
|
||||||
|
|
||||||
|
setModal(true);
|
||||||
|
|
||||||
|
setLayout(vbox);
|
||||||
|
|
||||||
|
connect( fEdit, SIGNAL(textChanged(const QString&)), this, SLOT(gotValue(const QString&)));
|
||||||
|
connect( ok, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
|
connect( cancel, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
void PGetNormValDialog::gotValue(const QString& str)
|
||||||
|
{
|
||||||
|
fValue = str.toDouble();
|
||||||
|
}
|
54
src/musredit_qt5/mupp/PGetNormValDialog.h
Normal file
54
src/musredit_qt5/mupp/PGetNormValDialog.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
|
||||||
|
PGetNormValDialog.h
|
||||||
|
|
||||||
|
Author: Andreas Suter
|
||||||
|
e-mail: andreas.suter@psi.ch
|
||||||
|
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (C) 2007-2020 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 _PGETNORMVALDIALOG_H_
|
||||||
|
#define _PGETNORMVALDIALOG_H_
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class PGetNormValDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PGetNormValDialog(double dval, QWidget *parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
virtual ~PGetNormValDialog() {}
|
||||||
|
|
||||||
|
virtual double getValue() { return fValue; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
double fValue;
|
||||||
|
QLineEdit *fEdit;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
virtual void gotValue(const QString& str);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _PGETNORMVALDIALOG_H_
|
@ -60,6 +60,7 @@ using namespace std;
|
|||||||
|
|
||||||
#include "mupp_version.h"
|
#include "mupp_version.h"
|
||||||
#include "PmuppGui.h"
|
#include "PmuppGui.h"
|
||||||
|
#include "PGetNormValDialog.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
@ -207,7 +208,11 @@ PmuppGui::PmuppGui( QStringList fln, QWidget *parent, Qt::WindowFlags f )
|
|||||||
fDatime = dt.toTime_t();
|
fDatime = dt.toTime_t();
|
||||||
fMuppInstance = -1;
|
fMuppInstance = -1;
|
||||||
|
|
||||||
fMuppPlot = 0;
|
fMuppPlot = nullptr;
|
||||||
|
fNormalizeAction = nullptr;
|
||||||
|
|
||||||
|
fNormalize = false;
|
||||||
|
fNormVal = 0.0;
|
||||||
|
|
||||||
fMacroPath = QString("./");
|
fMacroPath = QString("./");
|
||||||
fMacroName = QString("");
|
fMacroName = QString("");
|
||||||
@ -526,6 +531,19 @@ void PmuppGui::setupToolActions()
|
|||||||
a->setStatusTip( tr("Dump XY parameter list") );
|
a->setStatusTip( tr("Dump XY parameter list") );
|
||||||
connect( a, SIGNAL( triggered() ), this, SLOT( toolDumpXY() ) );
|
connect( a, SIGNAL( triggered() ), this, SLOT( toolDumpXY() ) );
|
||||||
menu->addAction(a);
|
menu->addAction(a);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
fNormalizeAction = new QAction(tr( "Normalize" ), this);
|
||||||
|
fNormalizeAction->setStatusTip( tr("Plot Data Normalized (y-axis)") );
|
||||||
|
fNormalizeAction->setCheckable(true);
|
||||||
|
connect( fNormalizeAction, SIGNAL( changed() ), this, SLOT( normalize() ) );
|
||||||
|
menu->addAction(fNormalizeAction);
|
||||||
|
|
||||||
|
a = new QAction(tr( "Normalize by Value" ), this);
|
||||||
|
a->setStatusTip( tr("Normalize by Value") );
|
||||||
|
connect( a, SIGNAL( triggered() ), this, SLOT( normVal() ) );
|
||||||
|
menu->addAction(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -666,6 +684,33 @@ void PmuppGui::toolDumpXY()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
void PmuppGui::normalize()
|
||||||
|
{
|
||||||
|
fNormalize = fNormalizeAction->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
void PmuppGui::normVal()
|
||||||
|
{
|
||||||
|
PGetNormValDialog *dlg = new PGetNormValDialog(fNormVal);
|
||||||
|
if (dlg == nullptr) {
|
||||||
|
QMessageBox::critical(this, "**ERROR**", "Couldn't invoke dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg->exec();
|
||||||
|
|
||||||
|
if (dlg->result() != QDialog::Accepted) {
|
||||||
|
delete dlg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fNormVal = dlg->getValue();
|
||||||
|
|
||||||
|
delete dlg;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief PmuppGui::helpCmds
|
* @brief PmuppGui::helpCmds
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2007-2017 by Andreas Suter *
|
* Copyright (C) 2007-2020 by Andreas Suter *
|
||||||
* andreas.suter@psi.ch *
|
* andreas.suter@psi.ch *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
@ -114,6 +114,8 @@ public slots:
|
|||||||
|
|
||||||
void toolDumpCollections();
|
void toolDumpCollections();
|
||||||
void toolDumpXY();
|
void toolDumpXY();
|
||||||
|
void normalize();
|
||||||
|
void normVal();
|
||||||
|
|
||||||
void helpCmds();
|
void helpCmds();
|
||||||
void helpAbout();
|
void helpAbout();
|
||||||
@ -128,6 +130,8 @@ private:
|
|||||||
PmuppAdmin *fAdmin;
|
PmuppAdmin *fAdmin;
|
||||||
bool fDarkTheme;
|
bool fDarkTheme;
|
||||||
bool fDarkToolBarIcon;
|
bool fDarkToolBarIcon;
|
||||||
|
bool fNormalize;
|
||||||
|
double fNormVal;
|
||||||
|
|
||||||
uint fDatime;
|
uint fDatime;
|
||||||
uint fMuppInstance;
|
uint fMuppInstance;
|
||||||
@ -142,6 +146,7 @@ private:
|
|||||||
|
|
||||||
QMenu *fRecentFilesMenu; ///< recent file menu
|
QMenu *fRecentFilesMenu; ///< recent file menu
|
||||||
QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions
|
QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions
|
||||||
|
QAction *fNormalizeAction;
|
||||||
|
|
||||||
QBoxLayout *fBoxLayout_Main; // top->bottom (0)
|
QBoxLayout *fBoxLayout_Main; // top->bottom (0)
|
||||||
QBoxLayout *fBoxLayout_Top; // left->right (1)
|
QBoxLayout *fBoxLayout_Top; // left->right (1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user