Skip to content

Commit

Permalink
Detailed calculation on point release
Browse files Browse the repository at this point in the history
  • Loading branch information
hrobeers committed May 3, 2013
1 parent d2ad3e4 commit a95010d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/fineditors/outlineeditor/thicknesscontours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void ThicknessContours::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->setBrush(QColor(min, 0, max, a));
painter->drawPath(*_outline);

calcContours();

int numberOfContours = _contours.length();
if (numberOfContours > 0)
{
Expand All @@ -72,8 +74,6 @@ void ThicknessContours::paint(QPainter *painter, const QStyleOptionGraphicsItem
painter->drawPath(*contour);
}
}

calcContours();
}
}

Expand All @@ -90,17 +90,20 @@ QRectF ThicknessContours::boundingRect() const

void ThicknessContours::onOutlineChange(EditablePath *sender)
{
_fastCalc = !(sender->released());
_outline = sender->painterPath();
}

void ThicknessContours::onProfileChange(EditablePath *sender)
{
_fastCalc = !(sender->released());
_profile = sender->painterPath();
this->scene()->update(boundingRect());
}

void ThicknessContours::onThicknessChange(EditablePath *sender)
{
_fastCalc = !(sender->released());
_thickness = sender->painterPath();
this->scene()->update(boundingRect());
}
Expand All @@ -116,7 +119,7 @@ void ThicknessContours::calcContours()
QSharedPointer<QPainterPath> path(new QPainterPath());
_contours.append(path);

ContourCalculator calc(thickness, _outline.data(), _profile.data(), _thickness.data(), path.data(), true);
ContourCalculator calc(thickness, _outline.data(), _profile.data(), _thickness.data(), path.data(), _fastCalc);
calc.run();
}
#endif
Expand All @@ -126,7 +129,7 @@ void ThicknessContours::calcContours()
QSharedPointer<QPainterPath> path(new QPainterPath());
_contours.append(path);

_tPool.start(new ContourCalculator(thickness, _outline.data(), _profile.data(), _thickness.data(), path.data(), true));
_tPool.start(new ContourCalculator(thickness, _outline.data(), _profile.data(), _thickness.data(), path.data(), _fastCalc));
}
_tPool.waitForDone();
#endif
Expand Down
1 change: 1 addition & 0 deletions src/fineditors/outlineeditor/thicknesscontours.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace fineditors
void onThicknessChange(EditablePath *sender);

private:
bool _fastCalc;
QThreadPool _tPool;

QSharedPointer<QPainterPath> _outline;
Expand Down
12 changes: 10 additions & 2 deletions src/patheditor/editablepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ EditablePath::EditablePath(QGraphicsItem * parent)
: QGraphicsObject(parent)
{
_firstPaint = true;
_released = true;
_settings = PathSettings::Default();
}

Expand Down Expand Up @@ -118,16 +119,23 @@ QSharedPointer<QPainterPath> EditablePath::painterPath()
return _painterPath;
}

bool EditablePath::released()
{
return _released;
}

void EditablePath::onPointDrag(PathPoint* /*unused*/)
{
this->scene()->update(boundingRect());
_released = false;
emit pathChanged(this);
this->scene()->update(boundingRect());
}

void EditablePath::onPointRelease(PathPoint* /*unused*/)
{
this->scene()->update(boundingRect());
_released = true;
emit pathChanged(this);
this->scene()->update(boundingRect());
}

void EditablePath::connectPoints(PathItem *pathItem)
Expand Down
3 changes: 3 additions & 0 deletions src/patheditor/editablepath.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace patheditor
*/
QSharedPointer<QPainterPath> painterPath();

bool released();

virtual ~EditablePath() {}

signals:
Expand All @@ -69,6 +71,7 @@ namespace patheditor

private:
bool _firstPaint;
bool _released;

PathSettings _settings;

Expand Down
4 changes: 2 additions & 2 deletions src/version_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef VERSION_AUTOGEN_H
#define VERSION_AUTOGEN_H

#define BUILD_NUMBER 125
#define COMMIT_HASH "0a9a108a72f84277da9d06cc6a79577d5bac9c7e"
#define BUILD_NUMBER 126
#define COMMIT_HASH "d2ad3e487ace8ea567d23f76a16ea792150344f2"

#endif // VERSION_AUTOGEN_H

0 comments on commit a95010d

Please sign in to comment.