// Read the documentation to learn more about C++ code generator // versioning. // %X% %Q% %Z% %W% #ifndef CREATECONTOURPLOTGROUPS_H #define CREATECONTOURPLOTGROUPS_H 1 #include #include #include #include #include #include #include #include //debug #include // PlotGroupCreator #include class Step; class MarginGrid; class IntegProbGrid; template class ContourPolicy; template<> class ContourPolicy { public: static Grid* getGrid(); static void validate(const Grid* grid); static Real getMinVal(const Grid* grid); static Real getHorizLineVal(const Grid* grid); static void getInitLevels(const Grid* grid, RealArray& relativeLevels); static void getAbsoluteLevels(const Grid* grid, const RealArray& relativeLevels, RealArray& absoluteLevels); static string getParLabel(size_t idx, const Grid* grid); static string getYLabel(const PlotSettings& settings); static string getTitle(const PlotSettings& settings, size_t nDim); }; template<> class ContourPolicy { public: static Grid* getGrid(); static void validate(const Grid* grid); static Real getMinVal(const Grid* grid); static Real getHorizLineVal(const Grid* grid); static void getInitLevels(const Grid* grid, RealArray& relativeLevels); static void getAbsoluteLevels(const Grid* grid, const RealArray& relativeLevels, RealArray& absoluteLevels); static string getParLabel(size_t idx, const Grid* grid); static string getYLabel(const PlotSettings& settings); static string getTitle(const PlotSettings& settings, size_t nDim); }; template<> class ContourPolicy { public: static Grid* getGrid(); static void validate(const Grid* grid); static Real getMinVal(const Grid* grid); static Real getHorizLineVal(const Grid* grid); static void getInitLevels(const Grid* grid, RealArray& relativeLevels); static void getAbsoluteLevels(const Grid* grid, const RealArray& relativeLevels, RealArray& absoluteLevels); static string getParLabel(size_t idx, const Grid* grid); static string getYLabel(const PlotSettings& settings); static string getTitle(const PlotSettings& settings, size_t nDim); }; template struct ContourTraits; template<> struct ContourTraits { static const string cmdName; static const bool addCrosshair; static const bool addHorizontalLine; static const string imageSpec; }; template<> struct ContourTraits { static const string cmdName; static const bool addCrosshair; static const bool addHorizontalLine; static const string imageSpec; }; template<> struct ContourTraits { static const string cmdName; static const bool addCrosshair; static const bool addHorizontalLine; static const string imageSpec; }; template class CreateContourPlotGroups : public PlotGroupCreator //## Inherits: %4B4CDBAE02A1 { public: CreateContourPlotGroups(); virtual ~CreateContourPlotGroups(); virtual std::vector createPlotGroups (const PlotSettings& settings); // Additional Public Declarations protected: // Additional Protected Declarations private: CreateContourPlotGroups(const CreateContourPlotGroups< T > &right); CreateContourPlotGroups< T > & operator=(const CreateContourPlotGroups< T > &right); // Additional Private Declarations private: //## implementation // Additional Implementation Declarations }; // Parameterized Class CreateContourPlotGroups // Parameterized Class CreateContourPlotGroups template CreateContourPlotGroups::CreateContourPlotGroups() : PlotGroupCreator() { } template CreateContourPlotGroups::~CreateContourPlotGroups() { } template std::vector CreateContourPlotGroups::createPlotGroups (const PlotSettings& settings) { // ASSUME that ContourPlot has already verified the existence of the relevant // Grid during its processAdditionalArguments phase, and it should have // checked that it is 1 or 2D. std::vector plotGroups; const Grid* grid = ContourPolicy::getGrid(); const size_t nDim = grid->getParameter().size(); if (nDim == 1) { const Grid::ParameterSpec* ps = grid->getParameter()[0]; // Though this is a contour plot, for 1-D case it uses // the regular PlotGroup constructor. std::auto_ptr apGr(new PlotGroup(ps->parameterValues.size(),0,true)); const size_t nPts = apGr->n; const RealArray& gridData = grid->getGridValues(); std::vector& yVals = apGr->yData.data; apGr->xAxis.data = ps->parameterValues; for (size_t i=0; ixAxis.errors.clear(); apGr->yData.errors.clear(); plotGroups.push_back(apGr.release()); } else if (nDim == 2) { const Grid::ParameterSpec* xps = grid->getParameter()[0]; const Grid::ParameterSpec* yps = grid->getParameter()[1]; std::auto_ptr apGr(new PlotGroup(xps->parameterValues, yps->parameterValues)); std::vector& pgData = apGr->model[0].data; const RealArray& gridData = grid->getGridValues(); const size_t nPts = gridData.size(); if (nPts != apGr->n) throw RedAlert("Grid size mismatch in createPlotGroups function."); for (size_t i=0; i