X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Feditwindow.cpp;h=4a3d43f50fc8def35436ee526b222036a837cda0;hb=1881acb17ed405cdb5aa2cb333a7af77f644a86d;hp=93757ce1803e22577737b7da92319f66c11ede1b;hpb=f027e22ef9a22ac2f601eac91667f7a721ed084c;p=ttedit diff --git a/src/editwindow.cpp b/src/editwindow.cpp old mode 100755 new mode 100644 index 93757ce..4a3d43f --- a/src/editwindow.cpp +++ b/src/editwindow.cpp @@ -43,10 +43,9 @@ EditWindow::EditWindow(QWidget * parent/*= NULL*/): QWidget(parent), - scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect), - ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1), - polyFirstPoint(true), showRotationCenter(false), haveZeroPoint(false), - selectionInProgress(false) + tool(TOOLSelect), ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), + oldPtNextHighlight(-1), polyFirstPoint(true), showRotationCenter(false), + haveZeroPoint(false), selectionInProgress(false) { setBackgroundRole(QPalette::Base); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -81,29 +80,11 @@ void EditWindow::CreateCursors(void) for(int i=0; i<12; i++) { - QString s; - s.sprintf(":/res/cursor-%s.png", cursorName[i]); - QPixmap pmTmp(s); + QPixmap pmTmp(QString(":/res/cursor-%1.png").arg(cursorName[i])); cur[i] = QCursor(pmTmp, hotx[i], hoty[i]); } } -#if 0 -QPoint EditWindow::GetAdjustedMousePosition(QMouseEvent * event) -{ - // This is undoing the transform, e.g. going from client coords to local - // coords. In essence, the height - y is height + (y * -1), the (y * -1) - // term doing the conversion of the y-axis from increasing bottom to top. - return QPoint(offsetX + event->x(), offsetY + (size().height() - event->y())); -} - - -QPoint EditWindow::GetAdjustedClientPosition(int x, int y) -{ - // VOODOO ALERT (ON Y COMPONENT!!!!) - return QPoint(-offsetX + x, (size().height() - (-offsetY + y)) * +1.0); -} -#endif /* TODO: @@ -118,27 +99,12 @@ void EditWindow::paintEvent(QPaintEvent * /*event*/) Painter painter(&qtp); painter.SetRenderHint(QPainter::Antialiasing); - Global::zoom = scale; - Global::origin = Vector(offsetX, offsetY); Global::viewportHeight = size().height(); Global::screenSize = Vector(size().width(), size().height()); -// p.translate(QPoint(-offsetX, size().height() - (-offsetY))); -// p.scale(1.0, -1.0); -//Nope, a big load of shit. So we'll have to bite the bullet and do it the -//hard way™. -// p.scale(scale, -scale); - -// Scrolling can be done by using OffsetViewportOrgEx -// Scaling can be done by adjusting SetWindowExtEx (it's denominator of txform) -// you'd use: % = ViewportExt / WindowExt -// But it makes the window look like crap: fuggetuboutit. -// Instead, we have to scale EVERYTHING by hand. Crap! -// It's not *that* bad, but not as convenient either... - - painter.SetPen(QPen(Qt::blue, 1.0, Qt::DotLine)); // Draw coordinate axes + painter.SetPen(QPen(Qt::blue, 1.0, Qt::DotLine)); painter.DrawLine(0, -16384, 0, 16384); painter.DrawLine(-16384, 0, 16384, 0); @@ -433,7 +399,7 @@ WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumP { // pt = GetAdjustedClientPosition(pts.GetX(ptHighlight), pts.GetY(ptHighlight)); Vector pt = Painter::CartesianToQtCoords(Vector(pts.GetX(ptHighlight), pts.GetY(ptHighlight))); -//printf("GetAdjustedClientPosition = %i, %i\n", pt.x(), pt.y()); +//printf("GetAdjustedClientPosition = %lf, %lf\n", pt.x, pt.y); QPoint warp(pt.x, pt.y); QCursor::setPos(mapToGlobal(warp)); @@ -459,9 +425,9 @@ WriteLogMsg(" --> [# polys: %u, # points: %u]\n", pts.GetNumPolys(), pts.GetNumP else if (tool == TOOLRotate) { // I think what's needed here is to keep the initial mouse click, - // paint the rotation center, then use the 1st mouse move event to establish - // the rotation "zero line", which becomes the line of reference to all - // subsequent mouse moves. + // paint the rotation center, then use the 1st mouse move event to + // establish the rotation "zero line", which becomes the line of + // reference to all subsequent mouse moves. // rotationCenter = GetAdjustedMousePosition(event); rotationCenter = Painter::QtToCartesianCoords(Vector(event->x(), event->y())); showRotationCenter = true; @@ -513,14 +479,15 @@ void EditWindow::mouseMoveEvent(QMouseEvent * event) // Calc offset from previous point Vector pt(event->x(), event->y()); pt /= Global::zoom; - ptOffset = Vector(pt.x - ptPrevious.x, pt.y - ptPrevious.y); + ptOffset = Vector(pt.x - ptPrevious.x, -(pt.y - ptPrevious.y)); // Then multiply it by the scaling factor. Whee! // This looks wacky because we're using screen coords for the offset... // Otherwise, we would subtract both offsets! - offsetX -= ptOffset.x, offsetY += ptOffset.y; - update(); +// offsetX -= ptOffset.x, offsetY += ptOffset.y; + Global::origin -= ptOffset; ptPrevious = pt; + update(); } else if (event->buttons() == Qt::LeftButton) {