/*************************************************************************** PmuppGui.h Author: Andreas Suter e-mail: andreas.suter@psi.ch ***************************************************************************/ /*************************************************************************** * Copyright (C) 2007-2024 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 _PMUPPGUI_H_ #define _PMUPPGUI_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "PVarHandler.h" #include "PVarDialog.h" #include "PmuppAdmin.h" #include "Pmupp.h" #include "mupp.h" //----------------------------------------------------------------------------- /** * @brief The PmuppXY class. */ class PmuppXY { public: PmuppXY() { init(); } void setCollectionTag(int tag) { fCollectionTag = tag; } void setXlabel(QString str) { fXlabel = str; } void addYlabel(QString str) { fYlabel.push_back(str); } void setYlabel(int idx, QString str); void removeYlabel(int idx); void removeYlabel(QString str); int getCollectionTag() { return fCollectionTag; } QString getXlabel() { return fXlabel; } int getXlabelIdx(); int getYlabelSize() { return fYlabel.size(); } QString getYlabel(int idx); int getYlabelIdx(int idx); QVector getYlabels() { return fYlabel; } private: int fCollectionTag; QString fXlabel; QVector fYlabel; void init(); }; //----------------------------------------------------------------------------- /** * @brief The PVarErrorDialog class. It is used to display error messages from * the variable parsing. */ class PVarErrorDialog : public QDialog { Q_OBJECT public: PVarErrorDialog(QString errMsg); private: QPlainTextEdit *fErrMsg; QPushButton *fOK; }; //----------------------------------------------------------------------------- // Layout Scheme of PmuppGui: // |--------------------------------------------------------------------| // | Main | // | |----------------------------------------------------------------| | // | | Top | | // | | |----------------------------| |-----------------------------| | | // | | | Grid Left (2 cols, 3 rows) | | Grid Right (2 cols, 6 rows) | | | // | | | +++++++++ | | ++++++++++ | | | // | | | | | | | | // | | |----------------------------| |-----------------------------| | | // | |----------------------------------------------------------------| | // | | // | |----------------------------------------------------------------| | // | | History | | // | |----------------------------------------------------------------| | // | | Cmd | | // | |----------------------------------------------------------------| | // ---------------------------------------------------------------------- // // Grid Left contains: fColLabel, fColParamSplitter, // fRemoveCollection, fRefreshCollection // Grid Right contains: f(X,Y)axisLabel, fView(X,Y), fAdd(X,Y), fRemove(X,Y), // fAddDitto, fPlot //----------------------------------------------------------------------------- class PmuppGui : public QMainWindow { Q_OBJECT public: PmuppGui(QStringList fln); virtual ~PmuppGui(); public slots: void aboutToQuit(); void fileOpen(); void fileOpenRecent(); void fileExit(); void toolDumpCollections(); void toolDumpXY(); void addVar(); void normalize(); void helpCmds(); void helpAbout(); void helpAboutQt(); protected: bool eventFilter(QObject *o, QEvent *e); private: enum EAxis {kXaxis, kYaxis}; PmuppAdmin *fAdmin; bool fDarkTheme; bool fDarkToolBarIcon; bool fNormalize; qint64 fDatime; uint fMuppInstance; PParamDataHandler *fParamDataHandler; QVector fXY; QVector fVarHandler; QString fMacroPath; QString fMacroName; std::unique_ptr fCentralWidget; QMenu *fRecentFilesMenu; ///< recent file menu QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions std::unique_ptr fNormalizeAction; std::unique_ptr fBoxLayout_Main; // top->bottom (0) std::unique_ptr fBoxLayout_Top; // left->right (1) std::unique_ptr fGridLayout_Left; // 2 columns, 3 rows std::unique_ptr fGridLayout_Right; // 2 columns, 6 rows std::unique_ptr fBoxLayout_Cmd; // left->right (1) std::unique_ptr fColLabel; std::unique_ptr fColParamSplitter; std::unique_ptr fColList; std::unique_ptr fParamList; std::unique_ptr fRemoveCollection; std::unique_ptr fRefreshCollection; std::unique_ptr fXaxisLabel; std::unique_ptr fYaxisLabel; std::unique_ptr fViewX; std::unique_ptr fViewY; std::unique_ptr fAddX; std::unique_ptr fAddY; std::unique_ptr fAddDitto; std::unique_ptr fRemoveX; std::unique_ptr fRemoveY; std::unique_ptr fPlot; std::unique_ptr fCmdSplitter; std::unique_ptr fCmdLineHistory; std::unique_ptr fCmdLine; std::unique_ptr fExitButton; QVector fCmdHistory; ///< command history buffer std::unique_ptr fVarDlg; ///< variable dialog std::unique_ptr fMuppPlot; ///< mupp plotter void setupFileActions(); void setupToolActions(); void setupHelpActions(); void getTheme(); void fillRecentFiles(); void readCmdHistory(); void writeCmdHistory(); bool isNewCollection(PmuppCollection &coll); int getXlabelIndex(QString label); void getMinMax(QVector &data, double &min, double &max); QString substituteDefaultLabels(QString label); void selectCollection(QString cmd); uint getFirstAvailableMuppInstance(); void updateCollectionList(); void updateXYList(int idx); void updateXYListGui(); bool findValue(PmuppRun &run, EAxis tag); bool allXYEqual(); bool indexAlreadyPresent(int idx); void replaceIndex(PmuppXY &data, const int idx); void startMuppPlot(); void parseErrMsgDlg(); QStringList getVarNames(QString parseStr); QVector getValues(QString collName, QString paramName, bool &ok); QVector getPosErr(QString collName, QString paramName, bool &ok); QVector getNegErr(QString collName, QString paramName, bool &ok); private slots: void addDitto(); void addX(QString param=""); void addY(QString param=""); void createMacro(); void handleCmds(); void plot(); void refresh(); void remove(); void removeX(QString param=""); void removeY(QString param=""); void handleNewData(); void updateParamList(int currentRow); void editCollName(QListWidgetItem *item); void dropOnViewX(QListWidgetItem *item); void dropOnViewY(QListWidgetItem *item); void refreshY(); void check(QString varStr, QVector idx); void add(QString varStr, QVector idx); }; #endif // _PMUPPGUI_H_