Skip to content

Commit

Permalink
IPath: expose bezier items
Browse files Browse the repository at this point in the history
  • Loading branch information
hrobeers committed Apr 3, 2020
1 parent f8b4f81 commit c28ec6f
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 7 deletions.
4 changes: 4 additions & 0 deletions include/patheditor/ipath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "hrlib/fwd/qtfwd.hpp"
#include "patheditor/fwd/patheditorfwd.hpp"

#include <vector>

namespace patheditor
{
class IPath
Expand All @@ -38,6 +40,8 @@ namespace patheditor
virtual qreal minY(qreal *t_top = 0) const = 0;
virtual qreal maxY(qreal *t_top = 0) const = 0;

virtual std::vector<std::vector<QPointF>> bezierItems() const = 0;

virtual ~IPath() {};
};
}
Expand Down
2 changes: 2 additions & 0 deletions include/patheditor/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace patheditor
virtual qreal minY(qreal *t_top = 0) const override;
virtual qreal maxY(qreal *t_top = 0) const override;

virtual std::vector<std::vector<QPointF>> bezierItems() const override;

void paint(QPainter *painter, bool editable = false, const PathSettings *settings = 0);

void disconnectAll();
Expand Down
2 changes: 2 additions & 0 deletions include/patheditor/pathdecorators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ namespace patheditor
virtual qreal minY(qreal *t_top = 0) const override;
virtual qreal maxY(qreal *t_top = 0) const override;

virtual std::vector<std::vector<QPointF>> bezierItems() const override;

virtual ~PathScaleDecorator() {}
};
}
Expand Down
2 changes: 1 addition & 1 deletion include/patheditor/pathitem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace patheditor
void setEndPoint(std::shared_ptr<PathPoint> endPoint);

virtual QList<std::shared_ptr<ControlPoint> > controlPoints() = 0;
QList<QPointF> points();
QList<QPointF> points() const;

// const getters
const PathPoint* constStartPoint() const;
Expand Down
12 changes: 12 additions & 0 deletions src/patheditor/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ qreal Path::maxY(qreal *t_top) const
return extreme<Y, Max>(this, t_top);
}

std::vector<std::vector<QPointF>> Path::bezierItems() const
{
std::vector<std::vector<QPointF>> retVal;
for (auto pi : _pathItemList) {
std::vector<QPointF> i;
for (auto p : pi->points())
i.push_back({p.x(), p.y()});
retVal.push_back(i);
}
return retVal;
}

void Path::disconnectAll()
{
disconnect();
Expand Down
12 changes: 12 additions & 0 deletions src/patheditor/pathdecorators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ qreal PathScaleDecorator::maxY(qreal *t_top) const
{
return (_sy>0 ? _target->maxY(t_top) : _target->minY(t_top)) * _sy;
}

std::vector<std::vector<QPointF>> PathScaleDecorator::bezierItems() const
{
std::vector<std::vector<QPointF>> retVal;
for (auto pi : _target->bezierItems()) {
std::vector<QPointF> i;
for (auto p : pi)
i.push_back({p.x()*_sx, p.y()*_sy});
retVal.push_back(i);
}
return retVal;
}
8 changes: 4 additions & 4 deletions src/patheditor/pathitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ void PathItem::paintPathItem(QPainterPath *totalPainterPath, QPainter *painter,
paintPathItemImpl(totalPainterPath, painter, editable, settings);
}

QList<QPointF> PathItem::points()
QList<QPointF> PathItem::points() const
{
QList<QPointF> pnts;
pnts.append(QPointF(startPoint()->x(), startPoint()->y()));
for (auto p : controlPoints())
pnts.append(QPointF(constStartPoint()->x(), constStartPoint()->y()));
for (auto p : constControlPoints())
pnts.append(QPointF(p->x(), p->y()));
pnts.append(QPointF(endPoint()->x(), endPoint()->y()));
pnts.append(QPointF(constEndPoint()->x(), constEndPoint()->y()));
return pnts;
}
4 changes: 2 additions & 2 deletions src/version_autogen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define MINOR_VERSION 2
#define REVISION 0

#define BUILD_NUMBER 609
#define COMMIT_HASH "4e1ccb8d49b32609bbff02a31c34aa3f4fcc88bb"
#define BUILD_NUMBER 614
#define COMMIT_HASH "f8b4f812ef8dacf47203d9f4f296c6581ff835c0"

#endif // VERSION_AUTOGEN_H

0 comments on commit c28ec6f

Please sign in to comment.