Add reading and writing to AWH module
[gromacs.git] / src / gromacs / fileio / xvgr.h
blob1c5104d367e9b2243850e587bdc9199fc28aa6cb
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2010,2014,2015,2017, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 #ifndef GMX_FILEIO_XVGR_H
38 #define GMX_FILEIO_XVGR_H
40 #include <stdio.h>
42 #include <string>
43 #include <vector>
45 #include "gromacs/utility/basedefinitions.h"
46 #include "gromacs/utility/real.h"
48 struct gmx_output_env_t;
50 /***************************************************
51 * XVGR DEFINITIONS
52 ***************************************************/
53 enum {
54 elNone, elSolid, elDotted, elDashed,
55 elLongDashed, elDotDashed, elNR
57 /* xvgr line-styles */
59 enum {
60 ecWhite, ecFrank, ecBlack = ecFrank,
61 ecRed, ecGreen, ecBlue, ecYellow, ecBrown, ecGray,
62 ecPurple, ecLightBlue, ecViolet, ecHolland, ecLila, ecDarkGray,
63 ecAquamarine, ecOlive, ecNR
65 /* xvgr line-colors */
67 enum {
68 eppNone, eppColor, eppPattern, eppNR
70 /* xvgr pattern type */
72 enum {
73 evView, evWorld, evNR
75 /* view type */
77 /***************************************************
78 * XVGR ROUTINES
79 ***************************************************/
81 /* Strings such as titles, lables and legends can contain escape sequences
82 * for formatting. Currently supported are:
83 * \s : start subscript
84 * \S : start superscript
85 * \N : end sub/superscript
86 * \symbol : where symbol is the full name of a greek letter
87 * (see the xvgrstr function in xvgr.c for the full list)
88 * when starting with a capital, a capital symbol will be printed,
89 * note that symbol does not need to be followed by a space
90 * \8 : (deprecated) start symbol font
91 * \4 : (deprecated) end symbol font
94 gmx_bool output_env_get_print_xvgr_codes(const struct gmx_output_env_t *oenv);
95 /* Returns if we should print xmgrace or xmgr codes */
97 enum {
98 exvggtNONE, exvggtXNY, exvggtXYDY, exvggtXYDYDY, exvggtNR
101 void xvgr_header(FILE *fp, const char *title, const std::string &xaxis,
102 const std::string &yaxis, int exvg_graph_type,
103 const struct gmx_output_env_t *oenv);
104 /* In most cases you want to use xvgropen_type, which does the same thing
105 * but takes a filename and opens it.
108 FILE *xvgropen_type(const char *fn, const char *title, const std::string &xaxis,
109 const std::string &yaxis, int exvg_graph_type,
110 const struct gmx_output_env_t *oenv);
111 /* Open a file, and write a title, and axis-labels in Xvgr format
112 * or write nothing when oenv specifies so.
113 * The xvgr graph type enum is defined above.
116 FILE *xvgropen(const char *fn, const char *title, const std::string &xaxis,
117 const std::string &yaxis, const struct gmx_output_env_t *oenv);
118 /* Calls xvgropen_type with graph type xvggtXNY. */
120 /* Close xvgr file, and clean up internal file buffers correctly */
121 void xvgrclose(FILE *fp);
123 void xvgr_subtitle(FILE *out, const char *subtitle,
124 const struct gmx_output_env_t *oenv);
125 /* Set the subtitle in xvgr */
127 void xvgr_view(FILE *out, real xmin, real ymin, real xmax, real ymax,
128 const struct gmx_output_env_t *oenv);
129 /* Set the view in xvgr */
131 void xvgr_world(FILE *out, real xmin, real ymin, real xmax, real ymax,
132 const struct gmx_output_env_t *oenv);
133 /* Set the world in xvgr */
135 void xvgrLegend(FILE *out,
136 const std::vector<std::string> &setNames,
137 const struct gmx_output_env_t *oenv);
138 /* Make a legend box, and also modifies the view to make room for the legend */
140 void xvgr_legend(FILE *out, int nsets, const char** setnames,
141 const struct gmx_output_env_t *oenv);
142 /* Make a legend box, and also modifies the view to make room for the legend */
144 void xvgr_new_dataset(FILE *out,
145 int nr_first, int nsets, const char **setnames,
146 const struct gmx_output_env_t *oenv);
147 /* End the previous data set(s) and start new one(s).
148 nr_first = the global set number of the first new set (or 0 if no legend)
149 nsets = the number of sets (or 0 if no legends)
150 setnames = the set names (or NULL if no legends)
153 void xvgr_line_props(FILE *out, int NrSet, int LineStyle, int LineColor,
154 const struct gmx_output_env_t *oenv);
155 /* Set xvgr line styles and colors */
157 void xvgr_box(FILE *out,
158 int LocType,
159 real xmin, real ymin, real xmax, real ymax,
160 int LineStyle, int LineWidth, int LineColor,
161 int BoxFill, int BoxColor, int BoxPattern,
162 const struct gmx_output_env_t *oenv);
163 /* Make a box */
165 int read_xvg_legend(const char *fn, double ***y, int *ny,
166 char **subtitle, char ***legend);
167 /* Read an xvg file for post processing. The number of rows is returned
168 * fn is the filename, y is a pointer to a 2D array (to be allocated by
169 * the routine) ny is the number of columns (including X if appropriate).
170 * If subtitle!=NULL, read the subtitle (when present),
171 * the subtitle string will be NULL when not present.
172 * If legend!=NULL, read the legends for the sets (when present),
173 * 0 is the first y legend, the legend string will be NULL when not present.
176 int read_xvg(const char *fn, double ***y, int *ny);
177 /* As read_xvg_legend, but does not read legends. */
179 void write_xvg(const char *fn, const char *title, int nx, int ny, real **y,
180 const char** leg, const struct gmx_output_env_t *oenv);
181 /* Write a two D array (y) of dimensions nx rows times
182 * ny columns to a file. If leg != NULL it will be written too.
186 /* This function reads ascii (xvg) files and extracts the data sets to a
187 * two dimensional array which is returned.
189 real **read_xvg_time(const char *fn,
190 gmx_bool bHaveT,
191 gmx_bool bTB, real tb,
192 gmx_bool bTE, real te,
193 int nsets_in, int *nset, int *nval,
194 real *dt, real **t);
195 #endif