File indexing completed on 2024-04-14 03:40:35
0001 /************************************************************************************* 0002 * Copyright (C) 2010-2014 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or * 0005 * modify it under the terms of the GNU General Public License * 0006 * as published by the Free Software Foundation; either version 2 * 0007 * of the License, or (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the Free Software * 0016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 0017 *************************************************************************************/ 0018 0019 #ifndef FUNCTIONEDITOR_H 0020 #define FUNCTIONEDITOR_H 0021 0022 //Analitza includes 0023 #include <analitzaplot/plotitem.h> 0024 0025 //Qt includes 0026 #include <QDockWidget> 0027 #include <qcombobox.h> 0028 #include <QModelIndex> 0029 0030 //local includes 0031 #include "plotsbuilder.h" 0032 0033 namespace Analitza 0034 { 0035 class FunctionGraph; 0036 class PlotsModel; 0037 class PlotsModel; 0038 } 0039 0040 class DataStore; 0041 class QStackedWidget; 0042 class QTreeView; 0043 class PlotsView; 0044 0045 namespace Ui 0046 { 0047 class PlotsEditorWidget; 0048 } 0049 0050 class PlotsEditor : public QDockWidget 0051 { 0052 Q_OBJECT 0053 public: 0054 explicit PlotsEditor(QWidget *parent); 0055 ~ PlotsEditor() override; 0056 0057 void setDocument(DataStore *doc); 0058 0059 public slots: 0060 void setCurrentSpace(int spaceidx); 0061 void reset(bool clearBuilder = false); // clear fields and reset the widgets like view3d /view2d (centrandolos etc)) 0062 0063 // used to buiild the UI for the plots based on its category 0064 void buildCartesianGraphCurve(bool cancelIsGoHome = false); 0065 void buildCartesianImplicitCurve(bool cancelIsGoHome = false); 0066 void buildCartesianParametricCurve2D(bool cancelIsGoHome = false); 0067 void buildPolarGraphCurve(bool cancelIsGoHome = false); 0068 //3D 0069 void buildCartesianParametricCurve3D(bool cancelIsGoHome = false); 0070 void buildCartesianGraphSurface(bool cancelIsGoHome = false); 0071 void buildCartesianImplicitSurface(bool cancelIsGoHome = false); 0072 void buildCartesianParametricSurface(bool cancelIsGoHome = false); 0073 void buildCylindricalGraphSurface(bool cancelIsGoHome = false); 0074 void buildSphericalGraphSurface(bool cancelIsGoHome = false); 0075 0076 private slots: 0077 void showList(); 0078 void showTypes(); 0079 void showEditor(); 0080 0081 void cancelEditor(); 0082 void addPlots(); 0083 0084 // slot gets activated while editing any plot. 0085 void editPlot(const QModelIndex &index = QModelIndex()); 0086 0087 //adds the plot in the cuurent document 0088 void savePlot(); 0089 0090 //showing/hiding the axis 0091 void showAxis(int state); 0092 0093 //slot to remove a plot from document 0094 void removePlot(); 0095 0096 //to connect the combo-box 0097 void setCurrentFunctionGraphs(const QString &txt); 0098 0099 //adds the default plot names (plot 1 , plot 2 and so on) 0100 void plotnamecheckClicked(bool b); 0101 0102 signals: 0103 //for main-window 0104 void goHome(); 0105 void sendStatus(const QString &stat, int mstimeout = 0); 0106 void updateGridcolor(const QColor &color); 0107 void mapDataChanged(); // emit when the map data is changed ( used for autosaving the file ) 0108 0109 private: 0110 QColor randomFunctionColor() { return QColor::fromHsv(qrand()%255, 255, 255); } 0111 bool eventFilter(QObject *object, QEvent *event) override; 0112 0113 // helpers to set the widgets of interval 0114 void setupVarName(int var, const QString &vvalue); //var: 1 x 2 y 3 z .. vvalue var value ...z,p,t,... 0115 void setupFuncName(int var, const QString &vvalue, const QStringList &vars, bool withparenthesis = true); //var: fname,gname ... 0116 void setupExpressionType(const QStringList &funvalues, const QStringList &varsvalues, bool isimplicit = false, bool isvectorValued = false); 0117 0118 Ui::PlotsEditorWidget *m_widget; 0119 Analitza::PlotsModel *m_localModel; 0120 DataStore *m_document; 0121 PlotsBuilder::PlotType m_currentType; // get the current plots's type 0122 QStringList m_currentFunctionGraphs; 0123 0124 //utils for mainwnd 0125 bool m_cancelIsGoHome; 0126 0127 //track current status when edit/create a plotsbuilder 0128 QStringList m_currentVars; 0129 bool m_currentIsImplicit; 0130 bool m_currentIsVectorValued; 0131 int m_currentVectorSize; 0132 QModelIndex m_indexEdited; 0133 0134 bool isEditing; 0135 int plotnumber; 0136 }; 0137 0138 #endif