// Read the documentation to learn more about C++ code generator // versioning. // %X% %Q% %Z% %W% #ifndef PLOT_H #define PLOT_H 1 // utility #include // Error #include // string #include // Observer #include // Response #include // PlotVector #include // PlotStyle #include // PlotTypes #include class SpectralData; namespace XSContainer { class DataContainer; } // namespace XSContainer class Grid; class Graph; class Plot : public Observer //## Inherits: %3D63EF2D01BC { public: typedef enum {STD,ROOTN,GEHRELS1,GEHRELS2,GEHRELSM} PlotErrMode; typedef enum {CHANNELS, ENERGY, WAVELENGTH} XaxisMode; class NoEnergiesDefined : public YellowAlert //## Inherits: %3D9B3A0F0271 { public: NoEnergiesDefined (const string& diag); protected: private: private: //## implementation }; class NoDataLoaded : public YellowAlert //## Inherits: %3DD56E890362 { public: NoDataLoaded(); protected: private: private: //## implementation }; class NoModelDefined : public YellowAlert //## Inherits: %3DD56E82025D { public: NoModelDefined (const string& command); protected: private: private: //## implementation }; typedef enum {INACTIVE, ACTIVE, FOLDED} ModelStatus; class ModelNotFound : public YellowAlert //## Inherits: %3E1DB953035D { public: ModelNotFound (const string& msg); protected: private: private: //## implementation }; struct RebinInfo { // Data Members for Class Attributes Real sigma; int maxBins; Plot::PlotErrMode mode; public: protected: private: private: //## implementation }; class NoGrid : public YellowAlert //## Inherits: %3ECE70F90369 { public: NoGrid (const string& diag); protected: private: private: //## implementation }; class InvalidContourLevels : public YellowAlert //## Inherits: %3ED7B1470187 { public: InvalidContourLevels (const string& diag); protected: private: private: //## implementation }; class NotImplemented : public YellowAlert //## Inherits: %3ED7C0AD0216 { public: NotImplemented (const string& diag); protected: private: private: //## implementation }; typedef enum {NO_SAVE, X_AR, XERR_AR, Y_AR, YERR_AR, MODEL_AR} SaveArrayOption; ~Plot(); static Plot* Instance (const string& graphPackage, const string& labelDictionaryPath); virtual void Update (Subject* changed = 0); void setXOption (const string& option); void makeBinnedPlotArrays (bool unfold = false); void makePlotArraysFromSpectra (); void setPlotGroupNums (const string& rangesString); void setIDs (const std::vector& values); void setSelectedLabel (size_t nLabel, const string& labelKey, const string& option = string()); void fixYMin (Real value); void autoSelectedLabels (const string& key); const PlotGroupContainer& groups () const; void resetPlotGroups (); void bundlePlotVectors (bool addComponents = false); char xAxisLabel (); Plot::ModelStatus determineModelStatus (); void makeTheGraph (); void prepareTheGraph (); void makePlotArraysFromModels (const string& name, bool addComponents = false); const std::pair& ranges (const string& axis) const; void fixXMin (Real value); void fixXMax (Real value); void fixYMax (Real value); void setRangesFromGrid (); void ungroupAll (); bool showAddComponents () const; void showAddComponents (bool value); Plot::XaxisMode xOption () const; void xOption (Plot::XaxisMode value); bool plotIDs () const; void plotIDs (bool value); Real temperature () const; Real emisLimit () const; Real redshift () const; bool counts () const; void counts (bool value); const std::vector& selectedLabels () const; bool yLog () const; void yLog (bool value); short int rangeDefaultFlags () const; void rangeDefaultFlags (short int value); bool xLog () const; void xLog (bool value); static const Real NODATA (); static const int MAXCMDLEN (); PlotStyle::Symbol dataStyle () const; void dataStyle (PlotStyle::Symbol value); PlotStyle::LineStyle modelStyle () const; void modelStyle (PlotStyle::LineStyle value); const std::pair& xLine () const; void xLine (const std::pair& value); bool plotXLog () const; void plotXLog (bool value); bool plotYLog () const; void plotYLog (bool value); size_t numGraphs () const; void numGraphs (size_t value); size_t currentGraphNumber () const; void currentGraphNumber (size_t value); const Plot::ModelStatus modelStatus () const; const size_t plotBeginIndex () const; std::map& groupsRebinInfo (); std::pair& lastRebinEntry (); const PlotKind plotType () const; void plotType (PlotKind value); const StringArray& lastCommand () const; void lastCommand (const StringArray& value); const Grid* getGrid () const; void grid (const Grid* value); std::pair& divideByArea (); const std::vector& savedPlotArray () const; const std::pair saveArrayInfo () const; void saveArrayInfo (std::pair value); bool splashPage () const; void splashPage (bool value); // showBackground flag indicates that the background should // be displayed IN ADDITION TO the spectrum display. bool showBackground () const; void showBackground (bool value); // 0 = angstrom units, 1 = Hz. Though only 2 choices for // now, this is an int rather than a bool in case we want // to add more in the near future. int waveUnitsHz () const; void waveUnitsHz (int value); const std::map >& ranges () const; void setRanges (const std::map >& value); std::pair< Real,Real >& ranges (const string& axis); void ranges (const string& axis, const std::pair< Real,Real >& value); const std::map& labelNames () const; void setLabelNames (const std::map& value); const std::string& labelNames (const string& label) const; void labelNames (const string& label, const std::string& value); Graph* graph () const; PlotGroupContainer& groups (); void groups (const PlotGroupContainer& value); public: // Additional Public Declarations protected: Plot (const string& graphPackage, const string& labelDictionaryPath); // Additional Protected Declarations private: void loadLabelDictionary (const string& dictionaryPath); // gtplin.f bool getNextPlotBin (PlotGroup* gr, int npts, std::list& groupSpectra, int& latestChannel, bool unfold); // analogue of gtdpin.f PlotGroup* initializePlotGroup (size_t groupIndex, std::list& groupSpectra, bool unfold); void integrateModelFluxes (std::list& spectra, Real eMin, Real eMax, PlotGroup* group, int point); void setXaxis (PlotGroup* group, int firstChannel, int lastChannel, Real eMin, Real eMax, int point); void setError (Plot::PlotErrMode errorType, Real& error, Real& backError, Real areaSum, Real backAreaSum, Real count, Real backgroundCount, Real bscaleRatio); void initializeSpectra (XSContainer::DataContainer* dataContainer); void resetAttributes (); // create a plot group from an input spectrum. PlotGroup* initializePlotGroup (SpectralData* spectrum); // create a plot group from an input spectrum. PlotGroup* initializePlotGroup (Model* model, // Create a plot group from a defined model. Intended // for use even when the model has a dummy response. bool addComponents = false); static void initEffectiveAreas (std::list& spectraInGroup); static void clearEffectiveAreas (std::list& spectraInGroup); void saveArray (); void itemizePlotGroupModels (); // Additional Private Declarations private: //## implementation // Data Members for Class Attributes static Plot* s_instance; bool m_isCurrent; bool m_showAddComponents; Plot::XaxisMode m_xOption; std::pair m_prevGroupRange; bool m_plotIDs; Real m_temperature; Real m_emisLimit; Real m_redshift; string m_labelDictionaryFile; bool m_counts; std::vector m_selectedLabels; bool m_yLog; short int m_rangeDefaultFlags; bool m_xLog; static const Real s_NODATA; static const int s_MAXCMDLEN; PlotStyle::Symbol m_dataStyle; PlotStyle::LineStyle m_modelStyle; std::pair m_xLine; bool m_plotXLog; bool m_plotYLog; size_t m_numGraphs; size_t m_currentGraphNumber; Plot::ModelStatus m_modelStatus; size_t m_plotBeginIndex; std::map m_groupsRebinInfo; std::pair m_lastRebinEntry; PlotKind m_plotType; StringArray m_lastCommand; const Grid* m_grid; std::pair m_divideByArea; std::vector m_savedPlotArray; std::pair m_saveArrayInfo; bool m_splashPage; ModelPositionInfo m_modelPositionDirectory; SpectraModelHolder m_modelsForSpectra; bool m_showBackground; int m_waveUnitsHz; // Data Members for Associations std::map > m_ranges; SpecGroup m_spectra; std::map m_labelNames; Graph* m_graph; PlotGroupContainer m_groups; // Additional Implementation Declarations }; // Class Plot::NoEnergiesDefined // Class Plot::NoDataLoaded // Class Plot::NoModelDefined // Class Plot::ModelNotFound // Class Plot::RebinInfo // Class Plot::NoGrid // Class Plot::InvalidContourLevels // Class Plot::NotImplemented // Class Plot inline const PlotGroupContainer& Plot::groups () const { return m_groups; } inline const std::pair& Plot::ranges (const string& axis) const { std::map >::const_iterator f (m_ranges.find(axis)); if (f == m_ranges.end()) throw RedAlert("Internal Error - range specification"); return f->second; } inline bool Plot::showAddComponents () const { return m_showAddComponents; } inline void Plot::showAddComponents (bool value) { m_showAddComponents = value; } inline Plot::XaxisMode Plot::xOption () const { return m_xOption; } inline void Plot::xOption (Plot::XaxisMode value) { m_xOption = value; } inline bool Plot::plotIDs () const { return m_plotIDs; } inline void Plot::plotIDs (bool value) { m_plotIDs = value; } inline Real Plot::temperature () const { return m_temperature; } inline Real Plot::emisLimit () const { return m_emisLimit; } inline Real Plot::redshift () const { return m_redshift; } inline bool Plot::counts () const { return m_counts; } inline void Plot::counts (bool value) { m_counts = value; } inline const std::vector& Plot::selectedLabels () const { return m_selectedLabels; } inline bool Plot::yLog () const { return m_yLog; } inline void Plot::yLog (bool value) { m_yLog = value; } inline short int Plot::rangeDefaultFlags () const { return m_rangeDefaultFlags; } inline void Plot::rangeDefaultFlags (short int value) { m_rangeDefaultFlags = value; } inline bool Plot::xLog () const { return m_xLog; } inline void Plot::xLog (bool value) { m_xLog = value; } inline const Real Plot::NODATA () { return s_NODATA; } inline const int Plot::MAXCMDLEN () { return s_MAXCMDLEN; } inline PlotStyle::Symbol Plot::dataStyle () const { return m_dataStyle; } inline void Plot::dataStyle (PlotStyle::Symbol value) { m_dataStyle = value; } inline PlotStyle::LineStyle Plot::modelStyle () const { return m_modelStyle; } inline void Plot::modelStyle (PlotStyle::LineStyle value) { m_modelStyle = value; } inline const std::pair& Plot::xLine () const { return m_xLine; } inline void Plot::xLine (const std::pair& value) { m_xLine.first = value.first; m_xLine.second = value.second; } inline bool Plot::plotXLog () const { return m_plotXLog; } inline void Plot::plotXLog (bool value) { m_plotXLog = value; } inline bool Plot::plotYLog () const { return m_plotYLog; } inline void Plot::plotYLog (bool value) { m_plotYLog = value; } inline size_t Plot::numGraphs () const { return m_numGraphs; } inline void Plot::numGraphs (size_t value) { m_numGraphs = value; } inline size_t Plot::currentGraphNumber () const { return m_currentGraphNumber; } inline void Plot::currentGraphNumber (size_t value) { m_currentGraphNumber = value; } inline const Plot::ModelStatus Plot::modelStatus () const { return m_modelStatus; } inline const size_t Plot::plotBeginIndex () const { return m_plotBeginIndex; } inline std::map& Plot::groupsRebinInfo () { return m_groupsRebinInfo; } inline std::pair& Plot::lastRebinEntry () { return m_lastRebinEntry; } inline const PlotKind Plot::plotType () const { return m_plotType; } inline void Plot::plotType (PlotKind value) { m_plotType = value; } inline const StringArray& Plot::lastCommand () const { return m_lastCommand; } inline void Plot::lastCommand (const StringArray& value) { m_lastCommand = value; } inline const Grid* Plot::getGrid () const { return m_grid; } inline void Plot::grid (const Grid* value) { m_grid = value; } inline std::pair& Plot::divideByArea () { return m_divideByArea; } inline const std::vector& Plot::savedPlotArray () const { return m_savedPlotArray; } inline const std::pair Plot::saveArrayInfo () const { return m_saveArrayInfo; } inline void Plot::saveArrayInfo (std::pair value) { m_saveArrayInfo.first = value.first; m_saveArrayInfo.second = value.second; } inline bool Plot::splashPage () const { return m_splashPage; } inline void Plot::splashPage (bool value) { m_splashPage = value; } inline bool Plot::showBackground () const { return m_showBackground; } inline void Plot::showBackground (bool value) { m_showBackground = value; } inline int Plot::waveUnitsHz () const { return m_waveUnitsHz; } inline void Plot::waveUnitsHz (int value) { m_waveUnitsHz = value; } inline const std::map >& Plot::ranges () const { return m_ranges; } inline void Plot::setRanges (const std::map >& value) { m_ranges = value; } inline std::pair< Real,Real >& Plot::ranges (const string& axis) { return m_ranges[axis]; } inline void Plot::ranges (const string& axis, const std::pair< Real,Real >& value) { m_ranges[axis].first = value.first; m_ranges[axis].second = value.second; } inline const std::map& Plot::labelNames () const { return m_labelNames; } inline void Plot::setLabelNames (const std::map& value) { m_labelNames = value; } inline const std::string& Plot::labelNames (const string& label) const { std::map::const_iterator f(m_labelNames.find(label)); if ( f == m_labelNames.end() ) throw YellowAlert(" no such plot label\n "); return f->second; } inline void Plot::labelNames (const string& label, const std::string& value) { m_labelNames[label] = value; } inline Graph* Plot::graph () const { return m_graph; } inline PlotGroupContainer& Plot::groups () { return m_groups; } inline void Plot::groups (const PlotGroupContainer& value) { m_groups = value; } #endif