3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
33 * Declares gmx::AnalysisDataPlotModule for plotting data (into a file).
36 * \ingroup module_analysisdata
37 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
39 #ifndef GMX_ANALYSISDATA_MODULES_PLOT_H
40 #define GMX_ANALYSISDATA_MODULES_PLOT_H
44 #include "../datamodule.h"
52 * Abstract data module for writing data into a file.
54 * Implements features common to all plotting modules. Subclasses implement
55 * features specific to certain applications (AnalysisDataPlotModule implements
56 * straightforward plotting).
58 * By default, the data is written into an xvgr file, according to the
59 * options read from the Options object given to the constructor.
60 * For non-xvgr data, it's possible to skip all headers by calling
63 * Multipoint data is supported, in which case all the points are written to
64 * the output, in the order in which they are added to the data. A single
65 * output line corresponds to a single frame. In most cases with multipoint
66 * data, setPlainOutput() should be called since the output does not make sense
67 * as an xvgr file, but this is not enforced.
69 * \ingroup module_analysisdata
71 class AbstractPlotModule : public AnalysisDataModuleInterface
74 virtual ~AbstractPlotModule();
77 * Set the output file name.
79 * If no file name is set (or if \p fnm is NULL), no output occurs.
81 void setFileName(const std::string &fnm);
85 * If \p bPlain is true, no xvgr headers are written to the file.
86 * In this case, only setOmitX(), setXFormat(), and setYFormat()
87 * methods have any effect on the output.
89 void setPlainOutput(bool bPlain);
91 * Omit the X coordinates from the output.
93 * This method only makes sense when combined with setPlainOutput().
95 void setOmitX(bool bOmitX);
99 void setTitle(const char *title);
103 void setSubtitle(const char *subtitle);
107 void setXLabel(const char *label);
109 * Set X axis label for time.
111 void setXTimeLabel();
115 void setYLabel(const char *label);
117 * Add legend from an array of strings.
119 * Multiple calls to setLegend() and/or appendLegend() are added
122 void setLegend(int nsets, const char * const *setname);
124 * Add a legend string for the next data set.
126 * Multiple calls to setLegend() and/or appendLegend() are added
129 void appendLegend(const char *setname);
131 * Set field width and precision for X value output.
133 void setXFormat(int width, int prec, char fmt = 'f');
135 * Set field width and precision for Y value output.
137 void setYFormat(int width, int prec, char fmt = 'f');
139 virtual int flags() const;
141 virtual void dataStarted(AbstractAnalysisData *data);
142 virtual void frameStarted(real x, real dx);
143 virtual void pointsAdded(real x, real dx, int firstcol, int n,
144 const real *y, const real *dy,
145 const bool *present) = 0;
146 virtual void frameFinished();
147 virtual void dataFinished();
151 explicit AbstractPlotModule(const Options &options);
153 bool isFileOpen() const;
154 void writeValue(real value) const;
162 // Disallow copy and assign.
163 AbstractPlotModule(const AbstractPlotModule &);
164 void operator =(const AbstractPlotModule &);
169 * Plotting module for straightforward plotting of data.
171 * See AbstractPlotModule for common plotting options.
174 * \ingroup module_analysisdata
176 class AnalysisDataPlotModule : public AbstractPlotModule
179 explicit AnalysisDataPlotModule(const Options &options);
181 virtual void pointsAdded(real x, real dx, int firstcol, int n,
182 const real *y, const real *dy,
183 const bool *present);
185 // Copy and assign disallowed by base.
190 * Plotting module specifically for data consisting of vectors.
192 * See AbstractPlotModule for common plotting options.
195 * \ingroup module_analysisdata
197 class AnalysisDataVectorPlotModule : public AbstractPlotModule
200 explicit AnalysisDataVectorPlotModule(const Options &options);
203 * Set whether to write X component.
205 void setWriteX(bool bWrite);
207 * Set whether to write Y component.
209 void setWriteY(bool bWrite);
211 * Set whether to write Z component.
213 void setWriteZ(bool bWrite);
215 * Set whether to write norm of the vector.
217 void setWriteNorm(bool bWrite);
219 * Set mask for what to write.
221 void setWriteMask(bool bWrite[4]);
223 virtual void pointsAdded(real x, real dx, int firstcol, int n,
224 const real *y, const real *dy,
225 const bool *present);
230 // Copy and assign disallowed by base.