X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Feditwindow.cpp;h=ef3d585b2ddd4fd333c2c74759c3a43e3ccf9376;hb=2b16243b0aa693d18ce49a071cdae73cadc37c4f;hp=242d237bb14a877b1038e5af334fd137e641a5a2;hpb=360d040a4727383cc8e78d0b8a3c8151c27d26fc;p=ttedit diff --git a/src/editwindow.cpp b/src/editwindow.cpp index 242d237..ef3d585 100755 --- a/src/editwindow.cpp +++ b/src/editwindow.cpp @@ -71,12 +71,12 @@ QSize EditWindow::sizeHint() const void EditWindow::CreateCursors(void) { - int hotx[10] = { 1, 1, 11, 15, 1, 1, 1, 1, 1, 1 }; - int hoty[10] = { 1, 1, 11, 13, 1, 1, 1, 1, 1, 1 }; - char cursorName[10][48] = { "select", "select-poly", "scroll", "zoom", "add-point", - "add-poly", "del-point", "del-poly", "rotate", "rotate" }; + int hotx[11] = { 1, 1, 11, 15, 1, 1, 1, 1, 1, 1, 1 }; + int hoty[11] = { 1, 1, 11, 13, 1, 1, 1, 1, 1, 1, 1 }; + char cursorName[11][48] = { "select", "select-poly", "scroll", "zoom", "add-point", + "add-poly", "del-point", "del-poly", "rotate", "rotate", "select" }; - for(int i=0; i<10; i++) + for(int i=0; i<11; i++) { QString s; s.sprintf(":/res/cursor-%s.png", cursorName[i]); @@ -117,17 +117,9 @@ void EditWindow::paintEvent(QPaintEvent * /*event*/) QPainter p(this); //hm, causes lockup (or does it???) p.setRenderHint(QPainter::Antialiasing); -//Doesn't do crap! -//dc.SetBackground(*wxWHITE_BRUSH); -// Due to the screwiness of wxWidgets coord system, the origin is ALWAYS -// the upper left corner--regardless of axis orientation, etc... -// int width, height; -// dc.GetSize(&width, &height); QSize winSize = size(); -// dc.SetDeviceOrigin(-offsetX, height - (-offsetY)); -// dc.SetAxisOrientation(true, true); p.translate(QPoint(-offsetX, winSize.height() - (-offsetY))); p.scale(1.0, -1.0); @@ -138,13 +130,10 @@ void EditWindow::paintEvent(QPaintEvent * /*event*/) // Instead, we have to scale EVERYTHING by hand. Crap! // It's not *that* bad, but not as convenient either... -// dc.SetPen(*(wxThePenList->FindOrCreatePen(wxColour(0x00, 0x00, 0xFF), 1, wxDOT))); -//// dc.DrawLine(0, 0, 10, 10); p.setPen(QPen(Qt::blue, 1.0, Qt::DotLine)); // Draw coordinate axes -// dc.CrossHair(0, 0); p.drawLine(0, -16384, 0, 16384); p.drawLine(-16384, 0, 16384, 0); @@ -237,46 +226,89 @@ void EditWindow::DrawGlyph(QPainter & p, GlyphPoints & glyph) { for(int poly=0; poly 2) - { - // Initial move... - // If it's not on curve, then move to it, otherwise move to last point... + if (glyph.GetNumPoints(poly) < 3) + continue; - int x, y; + // Initial move: If our start point is on curve, then go to it. Otherwise, + // check previous point. If it's on curve, go to it otherwise go the + // midpoint between start point and previous (since it's between two curve + // control points). + IPoint pt = (glyph.GetOnCurve(poly, 0) + ? glyph.GetPoint(poly, 0) : (glyph.GetPrevOnCurve(poly, 0) + ? glyph.GetPrevPoint(poly, 0) : glyph.GetMidpointToPrev(poly, 0))); - if (glyph.GetOnCurve(poly, glyph.GetNumPoints(poly) - 1)) - x = (int)glyph.GetX(poly, glyph.GetNumPoints(poly) - 1), y = (int)glyph.GetY(poly, glyph.GetNumPoints(poly) - 1); - else - x = (int)glyph.GetX(poly, 0), y = (int)glyph.GetY(poly, 0); +// Need to add separate color handling here for polys that are being manipulated... - for(int i=0; i 0) + QPoint pt = GetAdjustedMousePosition(event); + IPoint pointToAdd(pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true)); + + if (pts.GetNumPoints() < 2) + { +// pts += IPoint(pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true)); + pts += pointToAdd; + ptHighlight = pts.GetNumPoints() - 1; + } + else { - QPoint pt = GetAdjustedMousePosition(event); - pts.InsertPoint(pts.GetNext(ptHighlight), pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true)); +// QPoint pt = GetAdjustedMousePosition(event); +// pts.InsertPoint(pts.GetNext(ptHighlight), pt.x(), pt.y(), ((event->modifiers() == Qt::ShiftModifier || event->modifiers() == Qt::ControlModifier) ? false : true)); + pts.InsertPoint(pts.GetNext(ptHighlight), pointToAdd); ptHighlight = ptNextHighlight; - update(); +// update(); } + + update(); } else if (tool == TOOLAddPoly) // "Add Poly" tool { @@ -382,6 +426,13 @@ WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumP rotationAngle = 0; update(); } + else if (tool == TOOLFlipWinding) + { + pts.InvertPolyDrawSequence(pts.GetPolyForPointNumber(ptHighlight)); + pt = GetAdjustedClientPosition(pts.GetX(ptHighlight), pts.GetY(ptHighlight)); + QCursor::setPos(mapToGlobal(pt)); + update(); + } } event->accept(); @@ -417,15 +468,13 @@ void EditWindow::mouseMoveEvent(QMouseEvent * event) { if (tool == TOOLAddPt || tool == TOOLAddPoly || tool == TOOLSelect) { - if (tool != TOOLAddPt || pts.GetNumPoints() > 0)//yecch. - { -//temporary, for testing. BTW, Select drag bug is here...! -#if 1 - QPoint pt2 = GetAdjustedMousePosition(event); - pts.SetXY(ptHighlight, pt2.x(), pt2.y()); - update(); -#endif - } + // Bail out if we have the select tool and no points yet... + if (tool == TOOLSelect && pts.GetNumPoints() == 0) + return; + + QPoint pt2 = GetAdjustedMousePosition(event); + pts.SetXY(ptHighlight, pt2.x(), pt2.y()); + update(); } else if (tool == TOOLPolySelect) { @@ -434,6 +483,8 @@ void EditWindow::mouseMoveEvent(QMouseEvent * event) QPoint pt2 = GetAdjustedMousePosition(event); // Should also set onCurve here as well, depending on keystate //Or should we? +//Would be nice, but we'd need to trap the keyPressEvent() as well, otherwise pressing/releasing +//the hotkey would show no change until the user moved their mouse. pts.OffsetPoly(pts.GetPoly(ptHighlight), pt2.x() - pts.GetX(ptHighlight), pt2.y() - pts.GetY(ptHighlight)); update(); } @@ -472,7 +523,7 @@ void EditWindow::mouseMoveEvent(QMouseEvent * event) { // Moving, not dragging... if (tool == TOOLSelect || tool == TOOLDelPt || tool == TOOLAddPt - || tool == TOOLPolySelect || tool == TOOLRotatePoly) + || tool == TOOLPolySelect || tool == TOOLRotatePoly || tool == TOOLFlipWinding) { QPoint pt2 = GetAdjustedMousePosition(event); double closest = 1.0e+99;