/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * 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.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* \author Teemu Murtola <teemu.murtola@gmail.com>
* \ingroup module_analysisdata
*/
-#include "gromacs/analysisdata/arraydata.h"
+#include "gmxpre.h"
+
+#include "arraydata.h"
#include <algorithm>
{
AbstractAnalysisArrayData::AbstractAnalysisArrayData()
- : rowCount_(0), pointSetInfo_(0, 0, 0, 0), xstart_(0.0), xstep_(1.0),
- bReady_(false)
+ : rowCount_(0), pointSetInfo_(0, 0, 0, 0), xstep_(1.0),
+ bUniformX_(true), bReady_(false)
{
+ xvalue_.push_back(0);
}
AbstractAnalysisArrayData::~AbstractAnalysisArrayData()
= value_.begin() + index * columnCount();
return AnalysisDataFrameRef(
AnalysisDataFrameHeader(index, xvalue(index), 0.0),
- AnalysisDataValuesRef(begin, begin + columnCount()),
- AnalysisDataPointSetInfosRef(&pointSetInfo_, 1));
+ constArrayRefFromVector<AnalysisDataValue>(begin, begin + columnCount()),
+ constArrayRefFromArray(&pointSetInfo_, 1));
}
GMX_RELEASE_ASSERT(rowCount > 0, "Invalid number of rows");
GMX_RELEASE_ASSERT(!isAllocated(),
"Cannot change row count after data has been allocated");
+ GMX_RELEASE_ASSERT(bUniformX_ || rowCount_ == 0
+ || rowCount == static_cast<int>(xvalue_.size()),
+ "X axis set with setXAxisValue() does not match the row count");
+ xvalue_.resize(rowCount);
+ if (bUniformX_ && rowCount > rowCount_)
+ {
+ for (int i = rowCount_; i < rowCount; ++i)
+ {
+ xvalue_[i] = xvalue_[0] + i * xstep_;
+ }
+ }
rowCount_ = rowCount;
}
AbstractAnalysisArrayData::setXAxis(real start, real step)
{
GMX_RELEASE_ASSERT(!bReady_, "X axis cannot be set after data is finished");
- xstart_ = start;
- xstep_ = step;
+ xvalue_[0] = start;
+ xstep_ = step;
+ bUniformX_ = true;
+ for (int i = 0; i < rowCount_; ++i)
+ {
+ xvalue_[i] = start + i * xstep_;
+ }
+}
+
+
+void
+AbstractAnalysisArrayData::setXAxisValue(int row, real value)
+{
+ GMX_RELEASE_ASSERT(!bReady_, "X axis cannot be set after data is finished");
+ if (rowCount_ > 0)
+ {
+ GMX_RELEASE_ASSERT(row >= 0 && row < rowCount(), "Row index out of range");
+ }
+ else if (row >= static_cast<int>(xvalue_.size()))
+ {
+ xvalue_.resize(row + 1);
+ }
+ bUniformX_ = false;
+ xstep_ = 0.0;
+ xvalue_[row] = value;
}
modules.notifyPointsAdd(
AnalysisDataPointSetRef(
header, pointSetInfo_,
- AnalysisDataValuesRef(valueIter,
- valueIter + columnCount())));
+ constArrayRefFromVector<AnalysisDataValue>(valueIter,
+ valueIter + columnCount())));
modules.notifyFrameFinish(header);
}
modules.notifyDataFinish();
dest->setColumnCount(src->columnCount());
dest->setRowCount(src->rowCount());
dest->allocateValues();
- dest->setXAxis(src->xstart(), src->xstep());
+ dest->xstep_ = src->xstep_;
+ dest->bUniformX_ = src->bUniformX_;
+ std::copy(src->xvalue_.begin(), src->xvalue_.end(), dest->xvalue_.begin());
std::copy(src->value_.begin(), src->value_.end(), dest->value_.begin());
}