File: plotLegend.h

package info (click to toggle)
groops 0%2Bgit20250907%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid
  • size: 11,140 kB
  • sloc: cpp: 135,607; fortran: 1,603; makefile: 20
file content (84 lines) | stat: -rw-r--r-- 2,545 bytes parent folder | download | duplicates (2)
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
/***********************************************/
/**
* @file plotLegend.h
*
* @brief Legend.
*
* @author Andreas Kvas
* @author Torsten Mayer-Guerr
* @date 2020-05-03
*
*/
/***********************************************/

#ifndef __GROOPS_PLOTLEGEND__
#define __GROOPS_PLOTLEGEND__

// Latex documentation
#ifdef DOCSTRING_PlotLegend
static const char *docstringPlotLegend = R"(
\section{PlotLegend}\label{plotLegendType}
Plot a legend of the descriptions provided in
\configClass{plotGraphLayer}{plotGraphLayerType} in \program{PlotGraph}.
)";
#endif

/***********************************************/

#include "base/import.h"
#include "config/config.h"
#include "plot/plotMisc.h"

/** @addtogroup plotGroup */
/// @{

/***** TYPES ***********************************/

class PlotLegend;
typedef std::shared_ptr<PlotLegend> PlotLegendPtr;

/***** CLASS ***********************************/

/** @brief A Legend for GMT plots.
* An Instance of this class can be created by @ref readConfig. */
class PlotLegend
{
  Double       positionX, positionY;
  UInt         ncolumns;
  Double       width, height;
  PlotLinePtr  edgeLine;
  PlotColorPtr textColor, fillColor;
  std::string  anchor;
  Bool         _hasEntries;

public:
  /** @brief Constructor. */
  PlotLegend(Config &config, const std::string &name);

  std::string scriptEntry() const;

  void writeDataFile(const FileName &workingDirectory, const std::vector<std::string> &legendText);

  /** @brief creates an derived instance of this class. */
  static PlotLegendPtr create(Config &config, const std::string &name) {return PlotLegendPtr(new PlotLegend(config, name));}
};

/***** FUNCTIONS *******************************/

/** @brief Creates a class PlotLegend.
* Search for a node with @a name in the Config node.
* if @a name is not found the function returns FALSE and @a plotLegend 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] plotLegend 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 PlotLegend */
template<> Bool readConfig(Config &config, const std::string &name, PlotLegendPtr &plotLegend, Config::Appearance mustSet, const std::string &defaultValue, const std::string &annotation);

/// @}

/***********************************************/

#endif