1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
/***********************************************/
/**
* @file plotMisc.h
*
* @brief Miscellaneous classes for plots.
*
* @author Torsten Mayer-Guerr
* @author Andreas Kvas
* @date 2010-01-13
*
*/
/***********************************************/
#ifndef __GROOPS_PLOTMISC__
#define __GROOPS_PLOTMISC__
#include "base/import.h"
#include "config/config.h"
/** @addtogroup plotGroup */
/// @{
/***** CLASS ***********************************/
// Latex documentation
#ifdef DOCSTRING_PlotColor
static const char *docstringPlotColor = R"(
\section{PlotColor}\label{plotColorType}
Selects a color.
Used in \program{PlotDegreeAmplitudes}, \program{PlotGraph}, \program{PlotMap},
\program{PlotMatrix}, \program{PlotSphericalHarmonicsTriangle}.
)";
#endif
class PlotColor;
typedef std::shared_ptr<PlotColor> PlotColorPtr;
/** @brief Color options for GMT plots.
* An Instance of this class can be created by @ref readConfig. */
class PlotColor
{
std::string colorStr; //!< color string needed by GMT
public:
/// Constructor.
PlotColor(Config &config, const std::string &name);
std::string str() const {return colorStr;}
/** @brief creates an derived instance of this class. */
static PlotColorPtr create(Config &config, const std::string &name) {return PlotColorPtr(new PlotColor(config, name));}
};
/** @brief Creates a class PlotColor.
* Search for a node with @a name in the Config node.
* if @a name is not found the function returns FALSE and @a plotColor is untouched.
* @param config The config node which includes the node with the options for this class
* @param name Tag name in the config.
* @param[out] plotColor Created class.
* @param mustSet If is MUSTSET and @a name is not found, this function throws an exception instead of returning with FALSE.
* @param defaultValue Ignored at the moment.
* @param annotation Description of the function of this class.
* @relates PlotColor */
template<> Bool readConfig(Config &config, const std::string &name, PlotColorPtr &plotColor, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation);
/***** CLASS ***********************************/
// Latex documentation
#ifdef DOCSTRING_PlotLine
static const char *docstringPlotLine = R"(
\section{PlotLine}\label{plotLineType}
Defines the line style to be plotted.
)";
#endif
class PlotLine;
typedef std::shared_ptr<PlotLine> PlotLinePtr;
/** @brief Line style for plots
* An Instance of this class can be created by @ref readConfig. */
class PlotLine
{
protected:
std::string style;
Double width;
PlotColorPtr color;
public:
virtual ~PlotLine() {}
virtual std::string str() const;
/** @brief creates an derived instance of this class. */
static PlotLinePtr create(Config &config, const std::string &name);
};
/** @brief Creates a class PlotLine.
* Search for a node with @a name in the Config node.
* if @a name is not found the function returns FALSE and @a PlotLine is untouched.
* @param config The config node which includes the node with the options for this class
* @param name Tag name in the config.
* @param[out] PlotLine Created class.
* @param mustSet If is MUSTSET and @a name is not found, this function throws an exception instead of returning with FALSE.
* @param defaultValue Ignored at the moment.
* @param annotation Description of the function of this class.
* @relates PlotLine */
template<> Bool readConfig(Config &config, const std::string &name, PlotLinePtr &PlotLine, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation);
/***** CLASS ***********************************/
// Latex documentation
#ifdef DOCSTRING_PlotSymbol
static const char *docstringPlotSymbol = R"(
\section{PlotSymbol}\label{plotSymbolType}
Plots a symbol as used e.g. in \configClass{plotGraphLayer:linesAndPoints}{plotGraphLayerType:linesAndPoints}
or \configClass{plotMapLayer:points}{plotMapLayerType:points}.
)";
#endif
class PlotSymbol;
typedef std::shared_ptr<PlotSymbol> PlotSymbolPtr;
/** @brief Symbol options for GMT plots.
* An Instance of this class can be created by @ref readConfig. */
class PlotSymbol
{
Bool colorFromValue_;
std::string scriptLine;
std::string legendLine;
public:
/// Constructor.
PlotSymbol(Config &config, const std::string &name);
/** @brief Return whether symbol color is determined externally. */
Bool requiresColorBar() const {return colorFromValue_;}
/** @brief Script entry. */
std::string str() const {return scriptLine;}
std::string legendStr() const {return legendLine;}
/** @brief creates an derived instance of this class. */
static PlotSymbolPtr create(Config &config, const std::string &name) {return PlotSymbolPtr(new PlotSymbol(config, name));}
};
/** @brief Creates a class PlotSymbol.
* Search for a node with @a name in the Config node.
* if @a name is not found the function returns FALSE and @a plotSymbol is untouched.
* @param config The config node which includes the node with the options for this class
* @param name Tag name in the config.
* @param[out] plotSymbol Created class.
* @param mustSet If is MUSTSET and @a name is not found, this function throws an exception instead of returning with FALSE.
* @param defaultValue Ignored at the moment.
* @param annotation Description of the function of this class.
* @relates PlotSymbol */
template<> Bool readConfig(Config &config, const std::string &name, PlotSymbolPtr &plotSymbol, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation);
/***** CLASS ***********************************/
/** @brief Basic options for GMT plots. */
class PlotBasics
{
public:
std::string nameProgram;
FileName fileNamePlot;
FileName baseDirectory, workingDirectory;
Double width, height;
Bool drawGridOnTop;
std::string title;
Double marginTitle;
UInt titleSize;
Bool transparent;
UInt dpi;
Bool removeFiles;
std::string optionsString;
void read(Config &config, const std::string &nameProgram_, const FileName &fileNamePlot_, const std::string &title_,
const std::string &defaultWidth, const std::string &defaultHeight, const std::vector<std::string> &optionsDefault=std::vector<std::string>());
FileName fileNameScript() const;
std::string scriptHeader() const;
std::string scriptTrailer() const;
Bool runScript() const;
/** @brief Axis anntotation in GMT plots. */
static std::string axisTicks(Bool isLog, Double vmin, Double vmax, Double annotation, Double frame, Double grid, const std::string &unit="", const std::string &label="");
static std::string scriptSetVariable(const std::string &var, const std::string &value);
static std::string scriptVariable(const std::string &var);
static std::string scriptError2Null();
static UInt gmtVersion();
};
/***********************************************/
/// @}
/***********************************************/
#endif /* __GROOPS_PLOTMISC__ */
|