mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Merge branch 'feature/transform-shape-gui' into develop
This commit is contained in:
+27
-24
@@ -150,7 +150,7 @@ Ellipse* createEllipseForColor(int frameWidth, int frameHeight)
|
||||
);
|
||||
}
|
||||
|
||||
void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool selected, bool locked, MShape::ShapeMode shapeMode, qreal radius, qreal strokeWidth)
|
||||
void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool major, bool selected, bool locked, MShape::ShapeMode shapeMode, qreal radius, qreal strokeWidth)
|
||||
{
|
||||
// Init colors and stroke.
|
||||
if (locked)
|
||||
@@ -164,32 +164,35 @@ void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool selected,
|
||||
(vertex.y() - radius) - 1,
|
||||
radius * 2, radius * 2);
|
||||
|
||||
if (locked) {
|
||||
// Draw loccked ellipse.
|
||||
if (locked)
|
||||
{
|
||||
// Draw ellipse.
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
} else {
|
||||
switch (shapeMode) {
|
||||
case MShape::ScaleMode:
|
||||
// Draw scale icons
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
painter->drawPixmap(target, QPixmap(":/vertex-scale"));
|
||||
break;
|
||||
case MShape::RotateMode:
|
||||
// Draw rotate icons
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
painter->drawPixmap(target, QPixmap(":/vertex-rotate"));
|
||||
break;
|
||||
default:
|
||||
// Draw ellipse.
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (shapeMode == MShape::DefaultMode)
|
||||
{
|
||||
// Draw ellipse.
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
|
||||
// Draw cross.
|
||||
qreal offset = sin(M_PI/4) * radius;
|
||||
painter->drawLine( vertex + QPointF(offset, offset), vertex + QPointF(-offset, -offset) );
|
||||
painter->drawLine( vertex + QPointF(offset, -offset), vertex + QPointF(-offset, offset) );
|
||||
}
|
||||
else if (!major)
|
||||
{
|
||||
painter->drawEllipse(vertex, radius, radius);
|
||||
}
|
||||
else if (shapeMode == MShape::ScaleMode)
|
||||
{
|
||||
painter->drawPixmap(target, QPixmap(":/vertex-scale"));
|
||||
}
|
||||
else // RotateMode
|
||||
{
|
||||
// Draw rotate icons
|
||||
painter->drawPixmap(target, QPixmap(":/vertex-rotate"));
|
||||
}
|
||||
|
||||
// Draw cross.
|
||||
// qreal offset = sin(M_PI/4) * radius;
|
||||
// painter->drawLine( vertex + QPointF(offset, offset), vertex + QPointF(-offset, -offset) );
|
||||
// painter->drawLine( vertex + QPointF(offset, -offset), vertex + QPointF(-offset, offset) );
|
||||
}
|
||||
|
||||
bool fileExists(const QString& filename)
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ Mesh* createMeshForColor(int frameWidth, int frameHeight);
|
||||
Triangle* createTriangleForColor(int frameWidth, int frameHeight);
|
||||
Ellipse* createEllipseForColor(int frameWidth, int frameHeight);
|
||||
|
||||
void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool selected, bool locked, MShape::ShapeMode shapeMode, qreal radius = MM::VERTEX_SELECT_RADIUS, qreal strokeWidth = MM::VERTEX_SELECT_STROKE_WIDTH);
|
||||
void drawControlsVertex(QPainter* painter, const QPointF& vertex, bool major, bool selected, bool locked, MShape::ShapeMode shapeMode, qreal radius = MM::VERTEX_SELECT_RADIUS, qreal strokeWidth = MM::VERTEX_SELECT_STROKE_WIDTH);
|
||||
|
||||
/**
|
||||
* Checks if a file exists or not.
|
||||
|
||||
@@ -149,4 +149,10 @@ void Ellipse::setVertex(int i, const QPointF& v)
|
||||
sanitize();
|
||||
}
|
||||
|
||||
// Returns true iff vertex index is considered a major (external) control point.
|
||||
bool Ellipse::isMajorVertex(int idx) const
|
||||
{
|
||||
return !hasCenterControl() || idx != 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -132,6 +132,9 @@ public:
|
||||
// Override the parent, checking to make sure the vertices are displaced correctly.
|
||||
virtual void setVertex(int i, const QPointF& v);
|
||||
|
||||
// Returns true iff vertex index is considered a major (external) control point.
|
||||
virtual bool isMajorVertex(int idx) const;
|
||||
|
||||
protected:
|
||||
/// Returns a new MShape (using default constructor).
|
||||
virtual MShape* _create() const { return new Ellipse(); }
|
||||
|
||||
@@ -131,6 +131,15 @@ void Mesh::setVertex(int i, const QPointF& v)
|
||||
_rawSetVertex(i, realV);
|
||||
}
|
||||
|
||||
bool Mesh::isMajorVertex(int idx) const
|
||||
{
|
||||
return (idx == 0 ||
|
||||
idx == nColumns()-1 ||
|
||||
idx == nVertices()-1 ||
|
||||
idx == nVertices()-nColumns());
|
||||
}
|
||||
|
||||
|
||||
void Mesh::resizeVertices2d(IndexVector2d& vertices2d, int nColumns, int nRows)
|
||||
{
|
||||
vertices2d.resize(nColumns);
|
||||
|
||||
@@ -59,6 +59,9 @@ public:
|
||||
// Override the parent, checking to make sure the vertices are displaced correctly.
|
||||
virtual void setVertex(int i, const QPointF& v);
|
||||
|
||||
// Returns true iff vertex index is considered a major (external) control point.
|
||||
virtual bool isMajorVertex(int idx) const;
|
||||
|
||||
QPointF getVertex2d(int i, int j) const
|
||||
{
|
||||
return vertices[_vertices2d[i][j]];
|
||||
|
||||
@@ -132,6 +132,9 @@ public:
|
||||
qCopy(vertices_.begin(), vertices_.end(), vertices.begin());
|
||||
}
|
||||
|
||||
// Returns true iff vertex index is considered a major (external) control point.
|
||||
virtual bool isMajorVertex(int idx) const { Q_UNUSED(idx); return true; }
|
||||
|
||||
// Returns center of object.
|
||||
virtual QPointF getCenter() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user