File indexing completed on 2024-12-22 04:17:57
0001 /*************************************************************************** 0002 histogram.h: Histogram for KST 0003 ------------------- 0004 begin : Wed July 11 2002 0005 copyright : (C) 2002 by C. Barth Netterfield 0006 email : netterfield@astro.utoronto.ca 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * * 0011 * This program is free software; you can redistribute it and/or modify * 0012 * it under the terms of the GNU General Public License as published by * 0013 * the Free Software Foundation; either version 2 of the License, or * 0014 * (at your option) any later version. * 0015 * * 0016 ***************************************************************************/ 0017 0018 /** A class for handling power spectra for kst 0019 0020 *@author C. Barth Netterfield 0021 */ 0022 #ifndef HISTOGRAM_H 0023 #define HISTOGRAM_H 0024 0025 #include "dataobject.h" 0026 #include "kstmath_export.h" 0027 0028 namespace Kst { 0029 0030 class ObjectStore; 0031 0032 class KSTMATH_EXPORT Histogram : public DataObject { 0033 Q_OBJECT 0034 0035 public: 0036 enum NormalizationType { Number=0, Percent, Fraction, MaximumOne}; 0037 0038 public: 0039 static const QString staticTypeString; 0040 const QString& typeString() const { return staticTypeString; } 0041 static const QString staticTypeTag; 0042 0043 virtual void internalUpdate(); 0044 virtual void save(QXmlStreamWriter &xml); 0045 virtual QString propertyString() const; 0046 0047 int numberOfBins() const; 0048 void setNumberOfBins(int in_n_bins); 0049 0050 void setXRange(double xmin_in, double xmax_in); 0051 0052 void setVector(VectorPtr); 0053 VectorPtr vector() const; 0054 0055 bool isNormalizationNumber() const { return _NormalizationMode == Number; } 0056 void setIsNormalizationNumber() { _NormalizationMode = Number; } 0057 bool isNormalizationPercent() const { return _NormalizationMode == Percent; } 0058 void setIsNormalizationPercent() { _NormalizationMode = Percent; } 0059 bool isNormalizationFraction() const { return _NormalizationMode == Fraction; } 0060 void setIsNormalizationFraction() { _NormalizationMode = Fraction; } 0061 bool isNormalizationMaximumOne() const { return _NormalizationMode == MaximumOne; } 0062 void setIsNormNormalizationMaximumOne() { _NormalizationMode = MaximumOne; } 0063 void setNormalizationType(NormalizationType normType) { _NormalizationMode = normType; } 0064 NormalizationType normalizationType() const { return _NormalizationMode; } 0065 0066 static void AutoBin(const VectorPtr, int *n, double *max, double *min); 0067 0068 virtual void showNewDialog(); 0069 virtual void showEditDialog(); 0070 0071 virtual bool slaveVectorsUsed() const; 0072 0073 void setRealTimeAutoBin(bool autobin); 0074 bool realTimeAutoBin() const; 0075 0076 VectorPtr vX() const { return _bVector; } 0077 VectorPtr vY() const { return _hVector; } 0078 0079 double xMin() const { return _MinX; } 0080 double xMax() const { return _MaxX; } 0081 double width() const { return _W; } 0082 0083 double vMax() const; 0084 double vMin() const; 0085 int vNumSamples() const; 0086 0087 virtual DataObjectPtr makeDuplicate() const; 0088 0089 virtual QString descriptionTip() const; 0090 0091 void change(VectorPtr in_V, 0092 double xmin_in, double xmax_in, 0093 int in_n_bins, 0094 NormalizationType new_norm_in, 0095 bool realTimeAutoBin = false); 0096 0097 ScriptInterface* createScriptInterface(); 0098 0099 protected: 0100 Histogram(ObjectStore *store); 0101 virtual ~Histogram(); 0102 0103 friend class ObjectStore; 0104 0105 virtual QString _automaticDescriptiveName() const; 0106 virtual void _initializeShortName(); 0107 0108 private: 0109 NormalizationType _NormalizationMode; 0110 VectorPtr _bVector, _hVector; 0111 double _MaxX; 0112 double _MinX; 0113 int _NS; 0114 int _NumberOfBins; 0115 unsigned long *_Bins; 0116 double _Normalization; 0117 double _W; 0118 bool _realTimeAutoBin; 0119 0120 void internalSetNumberOfBins(int in_n_bins); 0121 void internalSetXRange(double xmin_in, double xmax_in); 0122 }; 0123 0124 typedef SharedPtr<Histogram> HistogramPtr; 0125 typedef ObjectList<Histogram> HistogramList; 0126 0127 } 0128 0129 #endif 0130 // vim: ts=2 sw=2 et