{
if (i == ptHighlight)
{
-// dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0xFF, 0x00, 0x00), 1, wxSOLID)));
-//// SelectObject(hdc, hRedPen1);
p.setPen(QPen(Qt::red, 1.0, Qt::SolidLine));
if (pts.GetOnCurve(i))
}
else if ((i == ptHighlight || i == ptNextHighlight) && tool == TOOLAddPt)
{
-// dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0xAF, 0x00), 1, wxSOLID)));
-//// SelectObject(hdc, hGreenPen1);
p.setPen(QPen(Qt::green, 1.0, Qt::SolidLine));
if (pts.GetOnCurve(i))
}
else
{
-// dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0x00), 1, wxSOLID)));
-//// SelectObject(hdc, hBlackPen1);
p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
if (pts.GetOnCurve(i))
if (tool == TOOLDelPt && i == ptHighlight)
{
-#if 0
- dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0xFF, 0x00, 0x00), 1, wxSOLID)));
-// SelectObject(hdc, hRedPen1);
-// MoveToEx(hdc, pts.GetX(i) - 5, pts.GetY(i) - 5, NULL);
-// LineTo(hdc, pts.GetX(i) + 5, pts.GetY(i) + 5);
-// LineTo(hdc, pts.GetX(i) - 5, pts.GetY(i) - 5);//Lameness!
-// MoveToEx(hdc, pts.GetX(i) - 5, pts.GetY(i) + 5, NULL);
-// LineTo(hdc, pts.GetX(i) + 5, pts.GetY(i) - 5);
-// LineTo(hdc, pts.GetX(i) - 5, pts.GetY(i) + 5);//More lameness!!
-#endif
p.setPen(QPen(Qt::red, 1.0, Qt::SolidLine));
p.drawLine(pts.GetX(i) - 5, pts.GetY(i) - 5, pts.GetX(i) + 5, pts.GetY(i) + 5);
p.drawLine(pts.GetX(i) + 5, pts.GetY(i) - 5, pts.GetX(i) - 5, pts.GetY(i) + 5);
}
}
-//// SelectObject(hdc, hBlackPen1);
-// dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0x00), 1, wxSOLID)));
- p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
-
// Draw curve formed by points
- for(int poly=0; poly<pts.GetNumPolys(); poly++)
- {
- if (pts.GetNumPoints(poly) > 2)
- {
- // Initial move...
- // If it's not on curve, then move to it, otherwise move to last point...
-
- int x, y;
-
- if (pts.GetOnCurve(poly, pts.GetNumPoints(poly) - 1))
- x = (int)pts.GetX(poly, pts.GetNumPoints(poly) - 1), y = (int)pts.GetY(poly, pts.GetNumPoints(poly) - 1);
- else
- x = (int)pts.GetX(poly, 0), y = (int)pts.GetY(poly, 0);
-
- for(int i=0; i<pts.GetNumPoints(poly); i++)
- {
- if (pts.GetOnCurve(poly, i))
-// LineTo(hdc, pts.GetX(poly, i), pts.GetY(poly, i));
- {
- p.drawLine(x, y, pts.GetX(poly, i), pts.GetY(poly, i));
- x = (int)pts.GetX(poly, i), y = (int)pts.GetY(poly, i);
- }
- else
- {
- uint32 prev = pts.GetPrev(poly, i), next = pts.GetNext(poly, i);
- float px = pts.GetX(poly, prev), py = pts.GetY(poly, prev),
- nx = pts.GetX(poly, next), ny = pts.GetY(poly, next);
-
- if (!pts.GetOnCurve(poly, prev))
- px = (px + pts.GetX(poly, i)) / 2.0f,
- py = (py + pts.GetY(poly, i)) / 2.0f;
-
- if (!pts.GetOnCurve(poly, next))
- nx = (nx + pts.GetX(poly, i)) / 2.0f,
- ny = (ny + pts.GetY(poly, i)) / 2.0f;
-
- Bezier(p, point(px, py), point(pts.GetX(poly, i), pts.GetY(poly, i)), point(nx, ny));
- x = (int)nx, y = (int)ny;
-
- if (pts.GetOnCurve(poly, next))
- i++; // Following point is on curve, so move past it
- }
- }
- }
- }
+ p.setPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+ DrawGlyph(p, pts);
if (haveZeroPoint)
{
// Rotation code
GlyphPoints rotated = pts;
- rotated.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
- p.setPen(QPen(QColor(255, 0, 255), 1.0, Qt::SolidLine));
-#if 0
- for(int poly=0; poly<rotated.GetNumPolys(); poly++)
- {
- if (rotated.GetNumPoints(poly) > 2)
- {
- // Initial move...
- // If it's not on curve, then move to it, otherwise move to last point...
-
- int x, y;
- if (rotated.GetOnCurve(poly, rotated.GetNumPoints(poly) - 1))
- x = (int)rotated.GetX(poly, rotated.GetNumPoints(poly) - 1), y = (int)rotated.GetY(poly, rotated.GetNumPoints(poly) - 1);
- else
- x = (int)rotated.GetX(poly, 0), y = (int)rotated.GetY(poly, 0);
-
- for(int i=0; i<rotated.GetNumPoints(poly); i++)
- {
- if (rotated.GetOnCurve(poly, i))
- // LineTo(hdc, rotated.GetX(poly, i), rotated.GetY(poly, i));
- {
- p.drawLine(x, y, rotated.GetX(poly, i), rotated.GetY(poly, i));
- x = (int)rotated.GetX(poly, i), y = (int)rotated.GetY(poly, i);
- }
- else
- {
- uint32 prev = rotated.GetPrev(poly, i), next = rotated.GetNext(poly, i);
- float px = rotated.GetX(poly, prev), py = rotated.GetY(poly, prev),
- nx = rotated.GetX(poly, next), ny = rotated.GetY(poly, next);
-
- if (!rotated.GetOnCurve(poly, prev))
- px = (px + rotated.GetX(poly, i)) / 2.0f,
- py = (py + rotated.GetY(poly, i)) / 2.0f;
-
- if (!rotated.GetOnCurve(poly, next))
- nx = (nx + rotated.GetX(poly, i)) / 2.0f,
- ny = (ny + rotated.GetY(poly, i)) / 2.0f;
-
- Bezier(p, point(px, py), point(rotated.GetX(poly, i), rotated.GetY(poly, i)), point(nx, ny));
- x = (int)nx, y = (int)ny;
-
- if (rotated.GetOnCurve(poly, next))
- i++; // Following point is on curve, so move past it
- }
- }
- }
+ if (tool == TOOLRotate)
+ rotated.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
+ else if (tool == TOOLRotatePoly)
+ {
+ uint16 poly = rotated.GetPolyForPointNumber(ptHighlight);
+ rotated.RotatePolyAroundCentroid(poly, rotationAngle);
}
-#else
+
+ p.setPen(QPen(QColor(255, 0, 255), 1.0, Qt::SolidLine));
DrawGlyph(p, rotated);
-#endif
}
}
rotationAngle = 0;
update();
}
+ else if (tool == TOOLRotatePoly)
+ {
+ IPoint centroid = pts.GetPolyCentroid(pts.GetPolyForPointNumber(ptHighlight));
+ rotationCenter = QPoint(centroid.x, centroid.y);
+ showRotationCenter = true;
+ pt = GetAdjustedClientPosition(pts.GetX(ptHighlight), pts.GetY(ptHighlight));
+ QCursor::setPos(mapToGlobal(pt));
+ rotationZeroPoint = QPoint(pts.GetX(ptHighlight), pts.GetY(ptHighlight));
+ haveZeroPoint = true;
+ rotationAngle = 0;
+ update();
+ }
}
event->accept();
update();
}
}
- else if (tool == TOOLRotate)
+ else if (tool == TOOLRotate || tool == TOOLRotatePoly)
{
if (pts.GetNumPoints() > 0)
{
{
// Moving, not dragging...
if (tool == TOOLSelect || tool == TOOLDelPt || tool == TOOLAddPt
- || tool == TOOLPolySelect)// || tool == TOOLAddPoly)
+ || tool == TOOLPolySelect || tool == TOOLRotatePoly)
{
QPoint pt2 = GetAdjustedMousePosition(event);
double closest = 1.0e+99;
{
showRotationCenter = false;
haveZeroPoint = false;
- pts.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
+
+ if (tool == TOOLRotate)
+ pts.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
+ else
+ {
+ uint16 poly = pts.GetPolyForPointNumber(ptHighlight);
+ pts.RotatePolyAroundCentroid(poly, rotationAngle);
+ }
+
update();
((TTEdit *)qApp)->mainWindow->statusBar()->showMessage("");
}