Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / analysisdata / modules / plot.h
index 235dfc0daed224aa3532ded2a59246f2f73a4007..9696d54e66627f73d782c2c395aa771828964563 100644 (file)
@@ -1,32 +1,36 @@
 /*
+ * This file is part of the GROMACS molecular simulation package.
  *
- *                This source code is part of
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
- *                 G   R   O   M   A   C   S
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
  *
- *          GROningen MAchine for Chemical Simulations
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2009, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
  *
- * If you want to redistribute modifications, please consider that
- * scientific software is very special. Version control is crucial -
- * bugs must be traceable. We will be happy to consider code for
- * inclusion in the official distribution, but derived work must not
- * be called official GROMACS. Details are found in the README & COPYING
- * files - if they are missing, get the official version at www.gromacs.org.
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
  *
  * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
- *
- * For more info, check our website at http://www.gromacs.org
+ * the research papers on the package. Check out http://www.gromacs.org.
  */
 /*! \file
  * \brief
@@ -34,7 +38,7 @@
  *
  * \inpublicapi
  * \ingroup module_analysisdata
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
+ * \author Teemu Murtola <teemu.murtola@gmail.com>
  */
 #ifndef GMX_ANALYSISDATA_MODULES_PLOT_H
 #define GMX_ANALYSISDATA_MODULES_PLOT_H
 
 #include <boost/shared_ptr.hpp>
 
-#include "../datamodule.h"
-#include "../../options/timeunitmanager.h"
-#include "../../utility/common.h"
+#include "gromacs/analysisdata/datamodule.h"
+#include "gromacs/options/timeunitmanager.h"
+#include "gromacs/utility/common.h"
 
 namespace gmx
 {
 
+class AnalysisDataValue;
 class Options;
 class SelectionCollection;
 
@@ -108,8 +113,8 @@ class AnalysisDataPlotSettings
 
     private:
         const SelectionCollection *selections_;
-        TimeUnit                timeUnit_;
-        int                     plotFormat_;
+        TimeUnit                   timeUnit_;
+        int                        plotFormat_;
 };
 
 /*! \brief
@@ -120,19 +125,22 @@ class AnalysisDataPlotSettings
  * straightforward plotting).
  *
  * By default, the data is written into an xvgr file, according to the
- * options read from the Options object given to the constructor.
+ * options read from the AnalysisDataPlotSettings object given to the
+ * constructor.
  * For non-xvgr data, it's possible to skip all headers by calling
  * setPlainOutput().
  *
- * Multipoint data is supported, in which case all the points are written to
- * the output, in the order in which they are added to the data.  A single
- * output line corresponds to a single frame.  In most cases with multipoint
- * data, setPlainOutput() should be called since the output does not make sense
- * as an xvgr file, but this is not enforced.
+ * A single output line corresponds to a single frame.  In most cases with
+ * multipoint data, setPlainOutput() should be called since the output does not
+ * make sense as an xvgr file, but this is not enforced.
+ *
+ * Multipoint data and multiple data sets are both supported, in which case all
+ * the points are written to the output, in the order in which they are added
+ * to the data.
  *
  * \ingroup module_analysisdata
  */
-class AbstractPlotModule : public AnalysisDataModuleInterface
+class AbstractPlotModule : public AnalysisDataModuleSerial
 {
     public:
         virtual ~AbstractPlotModule();
@@ -144,9 +152,9 @@ class AbstractPlotModule : public AnalysisDataModuleInterface
         /*! \brief
          * Set the output file name.
          *
-         * If no file name is set (or if \p fnm is NULL), no output occurs.
+         * If no file name is set (or if \p filename is empty), no output occurs.
          */
-        void setFileName(const std::string &fnm);
+        void setFileName(const std::string &filename);
         /*! \brief
          * Set plain output.
          *
@@ -155,6 +163,10 @@ class AbstractPlotModule : public AnalysisDataModuleInterface
          * methods have any effect on the output.
          */
         void setPlainOutput(bool bPlain);
+        /*! \brief
+         * Plot errors as a separate output column after each value column.
+         */
+        void setErrorsAsSeparateColumn(bool bSeparate);
         /*! \brief
          * Omit the X coordinates from the output.
          *
@@ -198,14 +210,16 @@ class AbstractPlotModule : public AnalysisDataModuleInterface
          * together.
          */
         void appendLegend(const char *setname);
+        //! \copydoc appendLegend(const char *)
+        void appendLegend(const std::string &setname);
         /*! \brief
          * Set field width and precision for X value output.
          */
-        void setXFormat(int width, int prec, char fmt = 'f');
+        void setXFormat(int width, int precision, char format = 'f');
         /*! \brief
          * Set field width and precision for Y value output.
          */
-        void setYFormat(int width, int prec, char fmt = 'f');
+        void setYFormat(int width, int precision, char format = 'f');
 
         virtual int flags() const;
 
@@ -218,17 +232,28 @@ class AbstractPlotModule : public AnalysisDataModuleInterface
     protected:
         /*! \cond libapi */
         AbstractPlotModule();
-        //! Creates AbstractPlotModule and assign common settings for the plotting
+        //! Creates AbstractPlotModule and assign common settings.
         explicit AbstractPlotModule(const AnalysisDataPlotSettings &settings);
 
+        //! Whether an output file has been opened.
         bool isFileOpen() const;
-        void writeValue(real value) const;
+        /*! \brief
+         * Appends a single value to the current output line.
+         *
+         * \param[in] value  Value to append.
+         *
+         * Should be used from pointsAdded() implementations in derived classes
+         * to write out individual y values to the output.
+         *
+         * Must not be called if isFileOpen() returns false.
+         */
+        void writeValue(const AnalysisDataValue &value) const;
         //! \endcond
 
     private:
         class Impl;
 
-        PrivateImplPointer<Impl> _impl;
+        PrivateImplPointer<Impl> impl_;
 };
 
 
@@ -244,7 +269,7 @@ class AnalysisDataPlotModule : public AbstractPlotModule
 {
     public:
         AnalysisDataPlotModule();
-        //! Creates AnalysisDataPlotModule and assign common settings for the plotting
+        //! Creates AnalysisDataPlotModule and assign common settings.
         explicit AnalysisDataPlotModule(const AnalysisDataPlotSettings &settings);
 
         virtual void pointsAdded(const AnalysisDataPointSetRef &points);
@@ -265,7 +290,7 @@ class AnalysisDataVectorPlotModule : public AbstractPlotModule
 {
     public:
         AnalysisDataVectorPlotModule();
-        //! Creates AnalysisDataVectorPlotModule and assign common settings for the plotting
+        //! Creates AnalysisDataVectorPlotModule and assign common settings.
         explicit AnalysisDataVectorPlotModule(const AnalysisDataPlotSettings &settings);
 
         /*! \brief
@@ -292,17 +317,17 @@ class AnalysisDataVectorPlotModule : public AbstractPlotModule
         virtual void pointsAdded(const AnalysisDataPointSetRef &points);
 
     private:
-        bool                    _bWrite[4];
+        bool                    bWrite_[4];
 
         // Copy and assign disallowed by base.
 };
 
 //! Smart pointer to manage an AnalysisDataPlotModule object.
 typedef boost::shared_ptr<AnalysisDataPlotModule>
-        AnalysisDataPlotModulePointer;
+    AnalysisDataPlotModulePointer;
 //! Smart pointer to manage an AnalysisDataVectorPlotModule object.
 typedef boost::shared_ptr<AnalysisDataVectorPlotModule>
-        AnalysisDataVectorPlotModulePointer;
+    AnalysisDataVectorPlotModulePointer;
 
 } // namespace gmx