File indexing completed on 2024-12-22 04:17:53
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2012 C. Barth Netterfield * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include <QByteArray> 0014 #include <QString> 0015 #include <QSizeF> 0016 #include <QList> 0017 0018 #include "scriptinterface.h" 0019 #include "basicplugin.h" 0020 #include "equation.h" 0021 #include "psd.h" 0022 #include "histogram.h" 0023 #include "objectstore.h" 0024 #include "updatemanager.h" 0025 #include "updateserver.h" 0026 0027 #ifndef DATAOBJECTSCRIPTINTERFACE_H 0028 #define DATAOBJECTSCRIPTINTERFACE_H 0029 0030 namespace Kst { 0031 0032 class KSTMATH_EXPORT DataObjectSI : public ScriptInterface 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 QString setInputVector(QString& command); 0038 QString setInputScalar(QString& command); 0039 0040 QString outputVector(QString& command); 0041 QString outputScalar(QString& command); 0042 protected: 0043 DataObjectPtr _dataObject; 0044 0045 }; 0046 0047 0048 class PluginSI; 0049 typedef QString (PluginSI::*PluginInterfaceMemberFn)(QString& command); 0050 0051 class KSTMATH_EXPORT PluginSI : public DataObjectSI 0052 { 0053 Q_OBJECT 0054 public: 0055 explicit PluginSI(BasicPluginPtr plugin); 0056 QString doCommand(QString); 0057 bool isValid(); 0058 QByteArray endEditUpdate(); 0059 0060 static ScriptInterface* newPlugin(ObjectStore *store, QByteArray pluginName); 0061 0062 QString setProperty(QString& command); 0063 0064 protected: 0065 QString noSuchFn(QString&) {return ""; } 0066 0067 private: 0068 BasicPluginPtr _plugin; 0069 0070 QMap<QString,PluginInterfaceMemberFn> _fnMap; 0071 0072 0073 }; 0074 0075 0076 class EquationSI; 0077 typedef QString (EquationSI::*EquationInterfaceMemberFn)(QString& command); 0078 0079 class KSTMATH_EXPORT EquationSI : public DataObjectSI 0080 { 0081 Q_OBJECT 0082 public: 0083 explicit EquationSI(EquationPtr equation); 0084 QString doCommand(QString); 0085 bool isValid(); 0086 QByteArray endEditUpdate(); 0087 0088 static ScriptInterface* newEquation(ObjectStore *store); 0089 0090 protected: 0091 QString noSuchFn(QString&) {return ""; } 0092 0093 private: 0094 EquationPtr _equation; 0095 0096 QMap<QString,EquationInterfaceMemberFn> _fnMap; 0097 0098 QString equation(QString &); 0099 QString setEquation(QString &eq); 0100 QString interpolateVectors(QString& command); 0101 0102 }; 0103 0104 0105 class SpectrumSI; 0106 typedef QString (SpectrumSI::*SpectrumInterfaceMemberFn)(QString& command); 0107 0108 class KSTMATH_EXPORT SpectrumSI : public DataObjectSI 0109 { 0110 Q_OBJECT 0111 public: 0112 explicit SpectrumSI(PSDPtr psd); 0113 QString doCommand(QString); 0114 bool isValid(); 0115 QByteArray endEditUpdate(); 0116 0117 static ScriptInterface* newSpectrum(ObjectStore *store); 0118 0119 protected: 0120 QString noSuchFn(QString&) {return ""; } 0121 0122 private: 0123 PSDPtr _psd; 0124 0125 QMap<QString,SpectrumInterfaceMemberFn> _fnMap; 0126 0127 QString change(QString &command); 0128 QString sampleRate(QString &); 0129 QString interleavedAverage(QString &); 0130 QString fftLength(QString &); 0131 QString apodize(QString &); 0132 QString removeMean(QString &); 0133 QString vectorUnints(QString &); 0134 QString rateUnits(QString &); 0135 QString apodizeFunctionIndex(QString &); 0136 QString gaussianSigma(QString &); 0137 QString outputTypeIndex(QString &); 0138 }; 0139 0140 0141 class HistogramSI; 0142 typedef QString (HistogramSI::*HistogramInterfaceMemberFn)(QString& command); 0143 0144 class KSTMATH_EXPORT HistogramSI : public DataObjectSI 0145 { 0146 Q_OBJECT 0147 public: 0148 explicit HistogramSI(HistogramPtr histogram); 0149 QString doCommand(QString); 0150 bool isValid(); 0151 QByteArray endEditUpdate(); 0152 0153 static ScriptInterface* newHistogram(ObjectStore *store); 0154 0155 protected: 0156 QString noSuchFn(QString&) {return ""; } 0157 0158 private: 0159 HistogramPtr _histogram; 0160 0161 QMap<QString,HistogramInterfaceMemberFn> _fnMap; 0162 0163 QString change(QString &command); 0164 QString xMin(QString &); 0165 QString xMax(QString &); 0166 QString nBins(QString &); 0167 QString normalizationType(QString &); 0168 QString autoBin(QString &); 0169 }; 0170 0171 0172 } 0173 #endif // DATAOBJECTSCRIPTINTERFACE_H