if (!_fnDist.empty())
{
- AnalysisDataPlotModule *plotm = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plotm
+ = new AnalysisDataPlotModule(settings.plotSettings());
plotm->setFileName(_fnDist);
plotm->setTitle("Average distance");
- plotm->setXLabel("Time (ps)");
+ plotm->setXAxisIsTime();
plotm->setYLabel("Distance (nm)");
_data.addModule(plotm);
}
class AbstractPlotModule::Impl
{
public:
- explicit Impl(const Options &options);
+ explicit Impl(const AnalysisDataPlotSettings &settings);
~Impl();
void closeFile();
+ AnalysisDataPlotSettings settings;
std::string fnm;
FILE *fp;
bool bPlain;
bool bOmitX;
- output_env_t oenv;
- const SelectionCollection *sel;
std::string title;
std::string subtitle;
std::string xlabel;
std::vector<std::string> leg;
char xfmt[15];
char yfmt[15];
+ real xscale;
};
} // namespace gmx
#include <cstdio>
#include <cstring>
+#include <boost/shared_ptr.hpp>
+
#include <gmxfio.h>
+#include <smalloc.h>
#include <statutil.h>
#include <vec.h>
#include <xvgr.h>
-#include "gromacs/options/globalproperties.h"
+#include "gromacs/options/basicoptions.h"
#include "gromacs/options/options.h"
+#include "gromacs/options/timeunitmanager.h"
#include "gromacs/fatalerror/exceptions.h"
#include "gromacs/fatalerror/gmxassert.h"
#include "gromacs/selection/selectioncollection.h"
+#include "gromacs/utility/format.h"
#include "plot-impl.h"
+static const char *const g_plotFormats[] = {
+ "none", "xmgrace", "xmgr", NULL
+};
+
namespace gmx
{
+/********************************************************************
+ * AnalysisDataPlotSettings
+ */
+
+AnalysisDataPlotSettings::AnalysisDataPlotSettings()
+ : selections_(NULL), timeUnit_(eTimeUnit_ps), plotFormat_(1)
+{
+}
+
+void
+AnalysisDataPlotSettings::setSelectionCollection(const SelectionCollection *selections)
+{
+ selections_ = selections;
+}
+
+
+void
+AnalysisDataPlotSettings::addOptions(Options *options)
+{
+ options->addOption(StringOption("xvg").enumValue(g_plotFormats)
+ .defaultValue("xmgrace")
+ .storeEnumIndex(&plotFormat_)
+ .description("Plot formatting"));
+}
+
+
/********************************************************************
* AbstractPlotModule::Impl
*/
-AbstractPlotModule::Impl::Impl(const Options &options)
- : fp(NULL), bPlain(false), bOmitX(false),
- oenv(options.globalProperties().output_env()),
- sel(NULL)
+AbstractPlotModule::Impl::Impl(const AnalysisDataPlotSettings &settings)
+ : settings(settings), fp(NULL), bPlain(false), bOmitX(false), xscale(1.0)
{
strcpy(xfmt, "%11.3f");
strcpy(yfmt, " %8.3f");
* AbstractPlotModule
*/
-AbstractPlotModule::AbstractPlotModule(const Options &options)
- : _impl(new Impl(options))
+AbstractPlotModule::AbstractPlotModule(const AnalysisDataPlotSettings &settings)
+ : _impl(new Impl(settings))
{
}
void
-AbstractPlotModule::setXTimeLabel()
+AbstractPlotModule::setXAxisIsTime()
{
- _impl->xlabel = output_env_get_xvgr_tlabel(_impl->oenv);
+ TimeUnitManager manager(_impl->settings.timeUnit());
+ _impl->xlabel = formatString("Time (%s)", manager.timeUnitAsString());
+ _impl->xscale = manager.inverseTimeScaleFactor();
}
}
else
{
+ output_env_t oenv;
+ snew(oenv, 1);
+ output_env_init_default(oenv);
+ boost::shared_ptr<output_env> oenvGuard(oenv, &output_env_done);
+ oenv->time_unit = static_cast<time_unit_t>(_impl->settings.timeUnit() + 1);
+ oenv->xvg_format =
+ (_impl->settings.plotFormat() > 0
+ ? static_cast<xvg_format_t>(_impl->settings.plotFormat())
+ : exvgNONE);
_impl->fp = xvgropen(_impl->fnm.c_str(), _impl->title.c_str(),
_impl->xlabel.c_str(), _impl->ylabel.c_str(),
- _impl->oenv);
- if (_impl->sel != NULL)
+ oenv);
+ const SelectionCollection *selections
+ = _impl->settings.selectionCollection();
+ if (selections != NULL)
{
- _impl->sel->printXvgrInfo(_impl->fp, _impl->oenv);
+ selections->printXvgrInfo(_impl->fp, oenv);
}
if (!_impl->subtitle.empty())
{
- xvgr_subtitle(_impl->fp, _impl->subtitle.c_str(), _impl->oenv);
+ xvgr_subtitle(_impl->fp, _impl->subtitle.c_str(), oenv);
}
- if (output_env_get_print_xvgr_codes(_impl->oenv)
+ if (output_env_get_print_xvgr_codes(oenv)
&& !_impl->leg.empty())
{
- const char **leg;
-
- leg = new const char *[_impl->leg.size()];
+ std::vector<const char *> leg;
+ leg.reserve(_impl->leg.size());
for (size_t i = 0; i < _impl->leg.size(); ++i)
{
- leg[i] = _impl->leg[i].c_str();
+ leg.push_back(_impl->leg[i].c_str());
}
- xvgr_legend(_impl->fp, _impl->leg.size(), leg, _impl->oenv);
- delete [] leg;
+ xvgr_legend(_impl->fp, leg.size(), &leg[0], oenv);
}
}
}
}
if (!_impl->bOmitX)
{
- std::fprintf(_impl->fp, _impl->xfmt, x);
+ std::fprintf(_impl->fp, _impl->xfmt, x * _impl->xscale);
}
}
* DataPlotModule
*/
-AnalysisDataPlotModule::AnalysisDataPlotModule(const Options &options)
- : AbstractPlotModule(options)
+AnalysisDataPlotModule::AnalysisDataPlotModule(
+ const AnalysisDataPlotSettings &settings)
+ : AbstractPlotModule(settings)
{
}
* DataVectorPlotModule
*/
-AnalysisDataVectorPlotModule::AnalysisDataVectorPlotModule(const Options &options)
- : AbstractPlotModule(options)
+AnalysisDataVectorPlotModule::AnalysisDataVectorPlotModule(
+ const AnalysisDataPlotSettings &settings)
+ : AbstractPlotModule(settings)
{
for (int i = 0; i < DIM; ++i)
{
#include <string>
#include "../datamodule.h"
+#include "../../options/timeunitmanager.h"
namespace gmx
{
class Options;
+class SelectionCollection;
+
+/*! \brief
+ * Common settings for data plots.
+ *
+ * \inpublicapi
+ * \ingroup module_analysisdata
+ */
+class AnalysisDataPlotSettings
+{
+ public:
+ //! Constructs default analysis plot settings.
+ AnalysisDataPlotSettings();
+
+ //! Returns the selection collection set with setSelectionCollection().
+ const SelectionCollection *selectionCollection() const
+ {
+ return selections_;
+ }
+ //! Returns the time unit set with setTimeUnit().
+ TimeUnit timeUnit() const { return timeUnit_; }
+ /*! \brief
+ * Returns the plot format.
+ *
+ * \todo Use a proper enum.
+ */
+ int plotFormat() const { return plotFormat_; }
+
+ /*! \brief
+ * Set selection collection to print as comments into the output.
+ *
+ * Formatted selection text from all selections in \p selections is
+ * printed as comments in the output file.
+ * If this method is not called, no selection information is written
+ * to the output.
+ */
+ void setSelectionCollection(const SelectionCollection *selections);
+ /*! \brief
+ * Sets the time unit for the plot.
+ *
+ * The value is used only if AbstractPlotModule::setXAxisIsTime() is
+ * called, in which case it is used to print the appropriate axis label
+ * and to scale the values.
+ * If not called, the default time unit is ps.
+ */
+ void setTimeUnit(TimeUnit timeUnit) { timeUnit_ = timeUnit; }
+
+
+ /*! \brief
+ * Adds common options for setting plot options.
+ *
+ * \param[in,out] options Options object to which options are added.
+ */
+ void addOptions(Options *options);
+
+ private:
+ const SelectionCollection *selections_;
+ TimeUnit timeUnit_;
+ int plotFormat_;
+};
/*! \brief
* Abstract data module for writing data into a file.
*/
void setXLabel(const char *label);
/*! \brief
- * Set X axis label for time.
+ * Treat X axis as time.
+ *
+ * Sets the label for the axis accordingly and also scales output to
+ * take into account the correct time unit.
*/
- void setXTimeLabel();
+ void setXAxisIsTime();
/*! \brief
* Set Y axis label.
*/
protected:
/*! \cond libapi */
- explicit AbstractPlotModule(const Options &options);
+ explicit AbstractPlotModule(const AnalysisDataPlotSettings &settings);
bool isFileOpen() const;
void writeValue(real value) const;
class AnalysisDataPlotModule : public AbstractPlotModule
{
public:
- explicit AnalysisDataPlotModule(const Options &options);
+ explicit AnalysisDataPlotModule(const AnalysisDataPlotSettings &settings);
virtual void pointsAdded(real x, real dx, int firstcol, int n,
const real *y, const real *dy,
class AnalysisDataVectorPlotModule : public AbstractPlotModule
{
public:
- explicit AnalysisDataVectorPlotModule(const Options &options);
+ explicit AnalysisDataVectorPlotModule(const AnalysisDataPlotSettings &settings);
/*! \brief
* Set whether to write X component.
* the option should provide as the template argument. After this is done, it
* is possible to add options of this new type using Options::addOption().
*
- * There is limited support for options that need to share information across
- * instances, e.g., to store values in a shared external data structure or to
- * provide a global option to set a common setting for all such options,
- * provided by the OptionsGlobalProperties class. This mechanism is not
- * generic, meaning that it is required to change the options module to add
- * data to this structure.
- *
* To implement new parsers, one can use OptionsAssigner, which provides an
* interface to set values in an Options object.
*
#include "gromacs/fatalerror/exceptions.h"
#include "gromacs/options/basicoptioninfo.h"
-#include "gromacs/options/globalproperties.h"
#include "gromacs/options/options.h"
#include "gromacs/utility/format.h"
{
ValueList::const_iterator match =
std::find(_allowed.begin(), _allowed.end(), values()[i]);
- _enumIndexStore[i] = (match - _allowed.begin());
+ GMX_ASSERT(match != _allowed.end(),
+ "Enum value not found (internal error)");
+ _enumIndexStore[i] = static_cast<int>(match - _allowed.begin());
}
}
}
bRead_(settings.bRead_), bWrite_(settings.bWrite_),
bLibrary_(settings.bLibrary_)
{
- if (filetype_ == eftPlot)
- {
- options->globalProperties().request(eogpPlotFormat);
- }
}
std::string FileNameOptionStorage::formatValue(int i) const
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * 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.
- *
- * 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.
- *
- * 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
- */
-/*! \internal \file
- * \brief
- * Implements gmx::OptionsGlobalProperties.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \ingroup module_options
- */
-#include "gromacs/options/globalproperties.h"
-
-#include <cstddef>
-
-#include <smalloc.h>
-#include <statutil.h>
-
-#include "gromacs/options/basicoptions.h"
-#include "gromacs/options/options.h"
-
-namespace gmx
-{
-
-static const char *const plotFormats[] = {
- "none", "xmgrace", "xmgr", NULL
-};
-
-
-OptionsGlobalProperties::OptionsGlobalProperties()
- : _usedProperties(0), _plotFormat(1),
- _oenv(NULL)
-{
- // TODO: If/when this is refactored, exception safety should be considered
- snew(_oenv, 1);
- output_env_init_default(_oenv);
-}
-
-
-OptionsGlobalProperties::~OptionsGlobalProperties()
-{
- if (_oenv != NULL)
- {
- output_env_done(_oenv);
- }
-}
-
-
-void OptionsGlobalProperties::addDefaultOptions(Options *options)
-{
- if (isPropertyUsed(eogpPlotFormat))
- {
- options->addOption(StringOption("xvg").enumValue(plotFormats)
- .defaultValue("xmgrace")
- .storeEnumIndex(&_plotFormat)
- .description("Plot formatting"));
- }
-}
-
-
-void OptionsGlobalProperties::finish()
-{
- if (isPropertyUsed(eogpPlotFormat))
- {
- if (_plotFormat == 0)
- {
- _oenv->xvg_format = exvgNONE;
- }
- else
- {
- _oenv->xvg_format = static_cast<xvg_format_t>(_plotFormat);
- }
- }
-}
-
-} // namespace gmx
+++ /dev/null
-/*
- *
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * 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.
- *
- * 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.
- *
- * 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
- */
-/*! \libinternal \file
- * \brief
- * Declares gmx::OptionsGlobalProperties.
- *
- * \author Teemu Murtola <teemu.murtola@cbr.su.se>
- * \inlibraryapi
- * \ingroup module_options
- */
-#ifndef GMX_OPTIONS_GLOBALPROPERTIES_H
-#define GMX_OPTIONS_GLOBALPROPERTIES_H
-
-#include <typedefs.h>
-
-namespace gmx
-{
-
-class Options;
-
-/*! \libinternal \brief
- * ID numbers for global properties.
- */
-enum OptionGlobalPropertyId
-{
- eogpPlotFormat,
-};
-
-/*! \libinternal \brief
- * Describes global properties of an Options collection.
- *
- * These properties are used to implement features that require all options of
- * a certain type to access some global data.
- * For example, if there are options that specify times, and in addition an
- * option that specifies the unit for these times, all the time options need to
- * know the scaling factor to get the time in internal units.
- *
- * \todo
- * There are things in this class that would be
- * better placed in the analysisdata module (for selecting plot formats).
- * It should be considered whether this should be implemented in some other way
- * (see Redmine issue #839).
- *
- * \inlibraryapi
- * \ingroup module_options
- */
-class OptionsGlobalProperties
-{
- public:
- ~OptionsGlobalProperties();
-
- //! Request for a global property to be used.
- void request(OptionGlobalPropertyId id)
- {
- _usedProperties |= (1<<id);
- }
-
- /*! \brief
- * Returns an output environment structure for interfacing with old
- * code.
- *
- * Currently, the returned structure is always filled with default
- * values for most fields.
- *
- * \deprecated
- */
- output_env_t output_env() const
- {
- return _oenv;
- }
-
- private:
- OptionsGlobalProperties();
-
- //! Returns true if request() has been called for the given property.
- bool isPropertyUsed(OptionGlobalPropertyId id) const
- {
- return _usedProperties & (1<<id);
- }
- /*! \brief
- * Adds options for setting requested global properties.
- *
- * \param[in,out] options Options to which the global property options
- * are added.
- *
- * If a global property has been requested and it can be set/customized
- * by the user, this method adds the necessary option to \p options.
- *
- * This method performs the real work of Options::addDefaultOptions().
- */
- void addDefaultOptions(Options *options);
- /*! \brief
- * Initializes variables dependent on global properties.
- *
- * This method should be called after the values for the options
- * generated with addDefaultOptions() have been set.
- */
- void finish();
-
- unsigned long _usedProperties;
- int _plotFormat;
- output_env_t _oenv;
-
- friend class Options;
-
- // Disallow copy and assign.
- OptionsGlobalProperties(const OptionsGlobalProperties &);
- void operator =(const OptionsGlobalProperties &);
-};
-
-} // namespace gmx
-
-#endif
{
class AbstractOptionStorage;
-class OptionsGlobalProperties;
/*! \internal \brief
* Private implementation class for Options.
OptionList _options;
//! Options object that contains this object as a subsection, or NULL.
Options *_parent;
- /*! \brief
- * Object that contains global properties, or NULL if \a _parent != NULL.
- *
- * This object is always owned by the Options object.
- * For subsections, the global properties are kept in the parent, and
- * this pointer is NULL.
- */
- // Could be scoped_ptr
- std::auto_ptr<OptionsGlobalProperties> _globalProperties;
};
} // namespace gmx
#include "gromacs/fatalerror/messagestringcollector.h"
#include "gromacs/options/abstractoption.h"
#include "gromacs/options/abstractoptionstorage.h"
-#include "gromacs/options/globalproperties.h"
#include "options-impl.h"
Options::Impl::Impl(const char *name, const char *title)
: _name(name != NULL ? name : ""), _title(title != NULL ? title : ""),
- _parent(NULL), _globalProperties(new OptionsGlobalProperties)
+ _parent(NULL)
{
}
"Duplicate subsection name");
_impl->_subSections.push_back(section);
section->_impl->_parent = this;
-
- globalProperties()._usedProperties |=
- section->_impl->_globalProperties->_usedProperties;
- section->_impl->_globalProperties.reset();
}
void Options::addOption(const AbstractOption &settings)
option.release();
}
-void Options::addDefaultOptions()
-{
- globalProperties().addDefaultOptions(this);
-}
-
bool Options::isSet(const char *name) const
{
AbstractOptionStorage *option = _impl->findOption(name);
errors.append(ex.what());
}
}
- if (_impl->_parent == NULL)
- {
- GMX_RELEASE_ASSERT(_impl->_globalProperties.get() != NULL,
- "Global properties should exist for the top-level options");
- _impl->_globalProperties->finish();
- }
if (!errors.isEmpty())
{
// TODO: This exception type may not always be appropriate.
}
}
-OptionsGlobalProperties &Options::globalProperties()
-{
- Options *section = this;
- while (section->_impl->_parent != NULL)
- {
- section = section->_impl->_parent;
- }
- GMX_RELEASE_ASSERT(section->_impl->_globalProperties.get() != NULL,
- "Global properties should exist for the top-level options");
- return *section->_impl->_globalProperties;
-}
-
} // namespace gmx
{
class AbstractOption;
-class OptionsGlobalProperties;
class OptionsAssigner;
class OptionsIterator;
* See \link Options class documentation \endlink for example usage.
*/
void addOption(const AbstractOption &settings);
- /*! \brief
- * Adds default options to this collection.
- *
- * Adds default options for altering global properties such as the time
- * unit into this collection.
- *
- * It is possible to call this method on a subsection of a collection.
- * Even in that case, the generated options set the properties for the
- * parent collection.
- */
- void addDefaultOptions();
//! Returns true if option \p name is set.
bool isSet(const char *name) const;
*/
void finish();
- /*! \brief
- * Returns the global property object for this collection.
- *
- * The caller should not store pointers or references to the object;
- * it can change if this object is added as a subsection into
- * another collection.
- *
- * The global property object is shared by all Options objects that
- * are part of the same section/subsection hierarchy.
- *
- * \see OptionsGlobalProperties
- */
- OptionsGlobalProperties &globalProperties();
- //! \copydoc globalProperties()
- const OptionsGlobalProperties &globalProperties() const
- { return const_cast<Options *>(this)->globalProperties(); }
-
private:
class Impl;
#include <gtest/gtest.h>
#include "gromacs/fatalerror/exceptions.h"
-#include "gromacs/options/globalproperties.h"
#include "gromacs/options/options.h"
#include "gromacs/options/optionsassigner.h"
#include "gromacs/selection/selection.h"
#include "analysissettings.h"
+#include "../analysisdata/modules/plot.h"
#include "../options/timeunitmanager.h"
namespace gmx
Impl() : flags(0), frflags(0), bRmPBC(true), bPBC(true) {}
TimeUnitManager timeUnitManager;
+ AnalysisDataPlotSettings plotSettings;
unsigned long flags;
int frflags;
}
+const TimeUnitManager &
+TrajectoryAnalysisSettings::timeUnitManager() const
+{
+ return _impl->timeUnitManager;
+}
+
+
+const AnalysisDataPlotSettings &
+TrajectoryAnalysisSettings::plotSettings() const
+{
+ return _impl->plotSettings;
+}
+
+
unsigned long
TrajectoryAnalysisSettings::flags() const
{
#include "../legacyheaders/typedefs.h"
+#include "../options/timeunitmanager.h"
+
namespace gmx
{
+class AnalysisDataPlotSettings;
class Options;
class TrajectoryAnalysisRunnerCommon;
TrajectoryAnalysisSettings();
~TrajectoryAnalysisSettings();
+ //! Returns the time unit manager with time unit timeUnit().
+ const TimeUnitManager &timeUnitManager() const;
+ //! Returns the time unit the user has requested.
+ TimeUnit timeUnit() { return timeUnitManager().timeUnit(); }
+ //! Returns common settings for analysis data plot modules.
+ const AnalysisDataPlotSettings &plotSettings() const;
+
//! Returns the currently set flags.
unsigned long flags() const;
//! Tests whether a flag has been set.
#include "gromacs/fatalerror/gmxassert.h"
#include "gromacs/options/asciihelpwriter.h"
#include "gromacs/options/cmdlineparser.h"
-#include "gromacs/options/globalproperties.h"
#include "gromacs/options/options.h"
#include "gromacs/selection/selectioncollection.h"
#include "gromacs/selection/selectionoptioninfo.h"
options->addSubSection(selectionOptions);
options->addSubSection(moduleOptions);
- commonOptions->addDefaultOptions();
setSelectionCollectionForOptions(options, selections);
{
#include "gromacs/selection/selection.h"
#include "gromacs/selection/selectionoption.h"
#include "gromacs/selection/selectionoptioninfo.h"
+#include "gromacs/trajectoryanalysis/analysissettings.h"
#include "gromacs/utility/format.h"
namespace gmx
registerAnalysisDataset(&_data, "angle");
- AnalysisDataPlotModule *plotm = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plotm
+ = new AnalysisDataPlotModule(settings.plotSettings());
plotm->setFileName(_fnAngle);
plotm->setTitle("Angle");
- plotm->setXTimeLabel();
- plotm->setYLabel("Angle [degrees]");
+ plotm->setXAxisIsTime();
+ plotm->setYLabel("Angle (degrees)");
_data.addModule(plotm);
}
#include "gromacs/options/options.h"
#include "gromacs/selection/selection.h"
#include "gromacs/selection/selectionoption.h"
+#include "gromacs/trajectoryanalysis/analysissettings.h"
namespace gmx
{
_avem = new AnalysisDataAverageModule();
_data.addModule(_avem);
- _plotm = new AnalysisDataPlotModule(_options);
+ _plotm = new AnalysisDataPlotModule(settings.plotSettings());
_plotm->setFileName(_fnDist);
_plotm->setTitle("Distance");
- _plotm->setXLabel("Time [ps]");
- _plotm->setYLabel("Distance [nm]");
+ _plotm->setXAxisIsTime();
+ _plotm->setYLabel("Distance (nm)");
_data.addModule(_plotm);
}
}
if (!_fnSize.empty())
{
- AnalysisDataPlotModule *plot = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plot
+ = new AnalysisDataPlotModule(settings.plotSettings());
plot->setFileName(_fnSize);
plot->setTitle("Selection size");
- plot->setXLabel("Time [ps]");
+ plot->setXAxisIsTime();
plot->setYLabel("Number");
_sdata.addModule(plot);
}
registerAnalysisDataset(&_cdata, "cfrac");
if (!_fnFrac.empty())
{
- AnalysisDataPlotModule *plot = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plot
+ = new AnalysisDataPlotModule(settings.plotSettings());
plot->setFileName(_fnFrac);
plot->setTitle("Covered fraction");
- plot->setXLabel("Time [ps]");
+ plot->setXAxisIsTime();
plot->setYLabel("Fraction");
plot->setYFormat(6, 4);
_cdata.addModule(plot);
registerAnalysisDataset(&_idata, "index");
if (!_fnIndex.empty())
{
- AnalysisDataPlotModule *plot = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plot
+ = new AnalysisDataPlotModule(settings.plotSettings());
plot->setFileName(_fnIndex);
plot->setPlainOutput(true);
plot->setYFormat(4, 0);
}
else
{
- AnalysisDataPlotModule *plot = new AnalysisDataPlotModule(_options);
+ AnalysisDataPlotModule *plot
+ = new AnalysisDataPlotModule(settings.plotSettings());
plot->setFileName(_fnMask);
plot->setPlainOutput(_bDump);
plot->setOmitX(_bDump);
plot->setTitle("Selection mask");
- plot->setXLabel("Time [ps]");
+ plot->setXAxisIsTime();
plot->setYLabel("Occupancy");
plot->setYFormat(1, 0);
_mdata.addModule(plot);
#include "gromacs/fatalerror/exceptions.h"
#include "gromacs/fatalerror/gmxassert.h"
#include "gromacs/options/basicoptions.h"
-#include "gromacs/options/globalproperties.h"
#include "gromacs/options/options.h"
#include "gromacs/selection/indexutil.h"
#include "gromacs/selection/selectioncollection.h"
sfree(fr->f);
sfree(fr);
}
+ if (_oenv != NULL)
+ {
+ output_env_done(_oenv);
+ }
}
// Add time unit option.
settings._impl->timeUnitManager.addTimeUnitOption(&options, "tu");
+ // Add plot options.
+ settings._impl->plotSettings.addOptions(&options);
+
// Add common options for trajectory processing.
if (!settings.hasFlag(TrajectoryAnalysisSettings::efNoUserRmPBC))
{
return false;
}
+ _impl->_settings._impl->plotSettings.setTimeUnit(
+ _impl->_settings._impl->timeUnitManager.timeUnit());
+
if (_impl->_trjfile.empty() && _impl->_topfile.empty())
{
GMX_THROW(InconsistentInputError("No trajectory or topology provided, nothing to do!"));
{
return;
}
- _impl->_oenv = _impl->_options.globalProperties().output_env();
+ snew(_impl->_oenv, 1);
+ output_env_init_default(_impl->_oenv);
+ _impl->_oenv->time_unit
+ = static_cast<time_unit_t>(_impl->_settings.timeUnit() + 1);
int frflags = _impl->_settings.frflags();
frflags |= TRX_NEED_X;