diff --git a/MantidQt/API/src/TSVSerialiser.cpp b/MantidQt/API/src/TSVSerialiser.cpp index 04555244a06f4e33ea30c3fa1c09d1a3f5c49ab5..db5f268e722b988e69f912da9ab836e4c975923f 100644 --- a/MantidQt/API/src/TSVSerialiser.cpp +++ b/MantidQt/API/src/TSVSerialiser.cpp @@ -246,7 +246,7 @@ bool TSVSerialiser::asBool(const size_t i) const { } QRect TSVSerialiser::asQRect(const size_t i) const { - if (i+3 >= m_curValues.size()) + if (i + 3 >= m_curValues.size()) return QRect(); std::string valStr = m_curValues.at(i); @@ -263,7 +263,7 @@ QRect TSVSerialiser::asQRect(const size_t i) const { } QColor TSVSerialiser::asQColor(const size_t i) const { - if (i+3 >= m_curValues.size()) + if (i + 3 >= m_curValues.size()) return QColor(); std::string valStr = m_curValues.at(i); @@ -386,25 +386,18 @@ TSVSerialiser &TSVSerialiser::operator<<(const bool &val) { TSVSerialiser &TSVSerialiser::operator<<(const QRect &val) { auto point0 = val.topLeft(); auto point1 = val.bottomRight(); - m_output << "\t" - << point0.x() << "\t" - << point0.y() << "\t" - << point1.x() << "\t" - << point1.y(); + m_output << "\t" << point0.x() << "\t" << point0.y() << "\t" << point1.x() + << "\t" << point1.y(); return *this; } TSVSerialiser &TSVSerialiser::operator<<(const QColor &val) { - m_output << "\t" - << val.red() << "\t" - << val.green() << "\t" - << val.blue() << "\t" - << val.alpha(); + m_output << "\t" << val.red() << "\t" << val.green() << "\t" << val.blue() + << "\t" << val.alpha(); return *this; } - void TSVSerialiser::writeRaw(const std::string &raw) { if (m_midLine) { m_output << "\n"; diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h index 7ed76f7f25cec395ac65e830ba548dde78d8f467..78e46407b974f7191e54b6441118b893b8b96bfd 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView/Shape2D.h @@ -208,7 +208,7 @@ public: QPointF getPoint(const QString &prop) const override; void setPoint(const QString &prop, const QPointF &value) override; /// Load state for the shape from a project file - static Shape2D* loadFromProject(const std::string &lines); + static Shape2D *loadFromProject(const std::string &lines); /// Save state for the shape to a project file virtual std::string saveToProject() const override; @@ -234,7 +234,7 @@ public: } void addToPath(QPainterPath &path) const override; /// Load state for the shape from a project file - static Shape2D* loadFromProject(const std::string &lines); + static Shape2D *loadFromProject(const std::string &lines); /// Save state for the shape to a project file virtual std::string saveToProject() const override; @@ -270,7 +270,7 @@ public: QColor getColor() const override { return m_outer_shape->getColor(); } const Shape2D *getOuterShape() const { return m_outer_shape; } /// Load state for the shape from a project file - static Shape2D* loadFromProject(const std::string &lines); + static Shape2D *loadFromProject(const std::string &lines); /// Save state for the shape to a project file virtual std::string saveToProject() const override; @@ -305,7 +305,7 @@ public: void addPolygon(const QPolygonF &polygon); void subtractPolygon(const QPolygonF &polygon); /// Load state for the shape from a project file - static Shape2D* loadFromProject(const std::string &lines); + static Shape2D *loadFromProject(const std::string &lines); /// Save state for the shape to a project file virtual std::string saveToProject() const override; diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp index a804c5eb6625f773caf4ccc33bb1ea1aaf4f7f4c..571bfc049539ac6a43d36dc485395a29920cbaa5 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp @@ -711,9 +711,8 @@ void InstrumentWidgetPickTab::loadFromProject(const std::string &lines) { // load active push button std::vector<QPushButton *> buttons{ - m_zoom, m_edit, m_ellipse, m_rectangle, - m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one, - m_tube, m_peak, m_peakSelect}; + m_zoom, m_edit, m_ellipse, m_rectangle, m_ring_ellipse, m_ring_rectangle, + m_free_draw, m_one, m_tube, m_peak, m_peakSelect}; tab.selectLine("ActiveTools"); for (auto button : buttons) { @@ -732,9 +731,8 @@ std::string InstrumentWidgetPickTab::saveToProject() const { // save active push button std::vector<QPushButton *> buttons{ - m_zoom, m_edit, m_ellipse, m_rectangle, - m_ring_ellipse, m_ring_rectangle, m_free_draw, m_one, - m_tube, m_peak, m_peakSelect}; + m_zoom, m_edit, m_ellipse, m_rectangle, m_ring_ellipse, m_ring_rectangle, + m_free_draw, m_one, m_tube, m_peak, m_peakSelect}; tab.writeLine("ActiveTools"); for (auto button : buttons) { diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp index 14db847c05953c0476b116b1d8b27e6d787f8203..43a732e4e9b12f38a2345b7ca2c79905196ec33b 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/Projection3D.cpp @@ -465,8 +465,7 @@ void Projection3D::setLightingModel(bool picking) const { /** Load 3D projection state from a Mantid project file * @param lines :: lines from the project file to load state from */ -void Projection3D::loadFromProject(const std::string &lines) -{ +void Projection3D::loadFromProject(const std::string &lines) { ProjectionSurface::loadFromProject(lines); TSVSerialiser tsv(lines); @@ -480,8 +479,7 @@ void Projection3D::loadFromProject(const std::string &lines) /** Save the state of the 3D projection to a Mantid project file * @return a string representing the state of the 3D projection */ -std::string Projection3D::saveToProject() const -{ +std::string Projection3D::saveToProject() const { TSVSerialiser tsv; tsv.writeRaw(ProjectionSurface::saveToProject()); tsv.writeSection("Viewport", m_viewport.saveToProject()); diff --git a/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp b/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp index 46bb81d948829aacbe4a0cee673e059cd4dcc12b..6349bce5cbf3ead4b09469e811d510bcb74f21e3 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/ProjectionSurface.cpp @@ -728,7 +728,7 @@ void ProjectionSurface::loadFromProject(const std::string &lines) { tsv >> m_backgroundColor; } - if(tsv.selectSection("shapes")) { + if (tsv.selectSection("shapes")) { std::string shapesLines; tsv >> shapesLines; m_maskShapes.loadFromProject(shapesLines); diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp index 3d07af8e6475060ab3e3ab344cbbaa217801015e..c1e08874c9c41ae59361d9d38aac0653fd1e93fa 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/Shape2D.cpp @@ -159,8 +159,7 @@ bool Shape2D::isMasked(const QPointF &p) const { * @param lines :: lines from the project file to load state from * @return a new shape2D with old state applied */ -Shape2D* Shape2D::loadFromProject(const std::string &lines) -{ +Shape2D *Shape2D::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); if (!tsv.selectLine("Type")) @@ -225,17 +224,12 @@ Shape2D *Shape2D::loadShape2DFromType(const std::string &type, /** Save the state of the shape 2D to a Mantid project file * @return a string representing the state of the shape 2D */ -std::string Shape2D::saveToProject() const -{ +std::string Shape2D::saveToProject() const { TSVSerialiser tsv; - bool props[] { - m_scalable, - m_editing, - m_selected, - m_visible }; + bool props[]{m_scalable, m_editing, m_selected, m_visible}; tsv.writeLine("Properties"); - for(auto prop : props) { + for (auto prop : props) { tsv << prop; } @@ -358,7 +352,7 @@ void Shape2DEllipse::setPoint(const QString &prop, const QPointF &value) { * @param lines :: lines from the project file to load state from * @return a new shape2D in the shape of a ellipse */ -Shape2D* Shape2DEllipse::loadFromProject(const std::string &lines) { +Shape2D *Shape2DEllipse::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); tsv.selectLine("Parameters"); double radius1, radius2, x, y; @@ -369,8 +363,7 @@ Shape2D* Shape2DEllipse::loadFromProject(const std::string &lines) { /** Save the state of the shape 2D ellipe to a Mantid project file * @return a string representing the state of the shape 2D */ -std::string Shape2DEllipse::saveToProject() const -{ +std::string Shape2DEllipse::saveToProject() const { TSVSerialiser tsv; double radius1 = getDouble("radius1"); double radius2 = getDouble("radius2"); @@ -423,7 +416,7 @@ void Shape2DRectangle::addToPath(QPainterPath &path) const { * @param lines :: lines from the project file to load state from * @return a new shape2D in the shape of a rectangle */ -Shape2D* Shape2DRectangle::loadFromProject(const std::string &lines) { +Shape2D *Shape2DRectangle::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); tsv.selectLine("Parameters"); double x0, y0, x1, y1; @@ -436,8 +429,7 @@ Shape2D* Shape2DRectangle::loadFromProject(const std::string &lines) { /** Save the state of the shape 2D rectangle to a Mantid project file * @return a string representing the state of the shape 2D */ -std::string Shape2DRectangle::saveToProject() const -{ +std::string Shape2DRectangle::saveToProject() const { TSVSerialiser tsv; auto x0 = m_boundingRect.x0(); auto x1 = m_boundingRect.x1(); @@ -593,7 +585,7 @@ void Shape2DRing::setColor(const QColor &color) { * @param lines :: lines from the project file to load state from * @return a new shape2D in the shape of a ring */ -Shape2D* Shape2DRing::loadFromProject(const std::string &lines) { +Shape2D *Shape2DRing::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); tsv.selectLine("Parameters"); double xWidth, yWidth; @@ -610,8 +602,7 @@ Shape2D* Shape2DRing::loadFromProject(const std::string &lines) { /** Save the state of the shape 2D ring to a Mantid project file * @return a string representing the state of the shape 2D */ -std::string Shape2DRing::saveToProject() const -{ +std::string Shape2DRing::saveToProject() const { TSVSerialiser tsv; auto xWidth = getDouble("xwidth"); auto yWidth = getDouble("ywidth"); @@ -762,14 +753,14 @@ void Shape2DFree::subtractPolygon(const QPolygonF &polygon) { * @param lines :: lines from the project file to load state from * @return a new freefrom shape2D */ -Shape2D* Shape2DFree::loadFromProject(const std::string &lines) { +Shape2D *Shape2DFree::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); QPolygonF polygon; - size_t paramCount = tsv.values("Parameters").size()-1; + size_t paramCount = tsv.values("Parameters").size() - 1; tsv.selectLine("Parameters"); - for(size_t i = 0; i < paramCount; i+=2) { + for (size_t i = 0; i < paramCount; i += 2) { double x, y; tsv >> x >> y; polygon << QPointF(x, y); @@ -781,25 +772,21 @@ Shape2D* Shape2DFree::loadFromProject(const std::string &lines) { /** Save the state of the shape 2D to a Mantid project file * @return a string representing the state of the shape 2D */ -std::string Shape2DFree::saveToProject() const -{ +std::string Shape2DFree::saveToProject() const { TSVSerialiser tsv; tsv.writeLine("Type") << "free"; tsv.writeLine("Parameters"); - for(auto& point : m_polygon) { + for (auto &point : m_polygon) { tsv << point.x() << point.y(); } tsv.writeRaw(Shape2D::saveToProject()); return tsv.outputLines(); } -Shape2DFree::Shape2DFree(const QPolygonF &polygon) - : m_polygon(polygon) -{ +Shape2DFree::Shape2DFree(const QPolygonF &polygon) : m_polygon(polygon) { resetBoundingRect(); } - } // MantidWidgets } // MantidQt diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp index 26d1546020938f609ccc901c57140b0b29e3cae5..0abbe62468c4bc074401198ff95d05847319e381 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/Shape2DCollection.cpp @@ -668,8 +668,7 @@ void Shape2DCollection::eraseFree(const QPolygonF &polygon) { /** Load shape 2D collection state from a Mantid project file * @param lines :: lines from the project file to load state from */ -void Shape2DCollection::loadFromProject(const std::string &lines) -{ +void Shape2DCollection::loadFromProject(const std::string &lines) { TSVSerialiser tsv(lines); for (auto shapeLines : tsv.sections("shape")) { Shape2D *shape = Shape2D::loadFromProject(shapeLines); @@ -680,10 +679,9 @@ void Shape2DCollection::loadFromProject(const std::string &lines) /** Save the state of the shape 2D collection to a Mantid project file * @return a string representing the state of the shape 2D collection */ -std::string Shape2DCollection::saveToProject() const -{ +std::string Shape2DCollection::saveToProject() const { TSVSerialiser tsv; - for(auto shape : m_shapes) { + for (auto shape : m_shapes) { tsv.writeSection("shape", shape->saveToProject()); } return tsv.outputLines(); diff --git a/MantidQt/MantidWidgets/src/InstrumentView/Viewport.cpp b/MantidQt/MantidWidgets/src/InstrumentView/Viewport.cpp index f737554e7fe4ad8464fd637fed8583fb2baeeb97..efe2f53695ade7c5037c7d06428f135fd9cd6540 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/Viewport.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/Viewport.cpp @@ -469,8 +469,7 @@ void Viewport::transform(Mantid::Kernel::V3D &pos) const { pos += Mantid::Kernel::V3D(m_xTrans, m_yTrans, 0.0); } -void Viewport::loadFromProject(const std::string &lines) -{ +void Viewport::loadFromProject(const std::string &lines) { reset(); TSVSerialiser tsv(lines); @@ -485,7 +484,7 @@ void Viewport::loadFromProject(const std::string &lines) setZoom(zoom); tsv.selectLine("Rotation"); - double w, a ,b, c; + double w, a, b, c; tsv >> w >> a >> b >> c; Mantid::Kernel::Quat quat(w, a, b, c); setRotation(quat); @@ -497,7 +496,7 @@ std::string Viewport::saveToProject() const { tsv.writeLine("Zoom") << m_zoomFactor; tsv.writeLine("Rotation"); - for(int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) { tsv << m_quaternion[i]; }