From: Shamus Hammons Date: Fri, 26 Dec 2014 14:45:08 +0000 (-0600) Subject: Converted codebase from Qt4 to Qt5. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=architektonas;a=commitdiff_plain;h=6c1279871f6bb86bc59e2561b6a7f74ab081f71e Converted codebase from Qt4 to Qt5. --- diff --git a/README b/README index e749f3f..b979c36 100644 --- a/README +++ b/README @@ -70,7 +70,7 @@ love to hear from you so that we can improve! @-~ Installation ~-@ -Architektonas is built on the Qt 4 framework; it requires version 4.7.4 or +Architektonas is built on the Qt 5 framework; it requires version 5.3.2 or later. We build it using gcc v4.4.6; we can't guarantee that it will compile on lesser versions but you never know. Building Architektonas should be as easy as typing: diff --git a/architektonas.pro b/architektonas.pro index 53c36b2..a16a8a8 100644 --- a/architektonas.pro +++ b/architektonas.pro @@ -11,6 +11,7 @@ CONFIG += qt warn_on release RESOURCES += res/architektonas.qrc #LIBS += -Ldxflib/lib -ldxf +QT += widgets # We stuff all the intermediate crap into obj/ so it won't confuse us mere mortals ;-) OBJECTS_DIR = obj diff --git a/cross-compile b/cross-compile index 4115825..cbb56a3 100755 --- a/cross-compile +++ b/cross-compile @@ -6,13 +6,16 @@ # (C) 2012 Underground Software # TARGET=architektonas -echo "Cross compiling ${TARGET} for Win32..." +#echo "Cross compiling ${TARGET} for Win32..." +echo "Cross compiling ${TARGET} for Win64..." export PATH=/opt/mxe/usr/bin:$PATH rm Makefile -/opt/mxe/usr/i686-pc-mingw32/qt/bin/qmake -make +#/opt/mxe/usr/i686-pc-mingw32/qt/bin/qmake +/opt/mxe/usr/bin/x86_64-w64-mingw32.static-qmake-qt4 +make clean && make #make CROSS=i686-pc-mingw32- #rel=`svn info | grep Revision | cut -f 2 -d ' '` rel=`git log -1 --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -` #echo ${TARGET}.exe cd release && upx -9v ${TARGET}.exe && zip -9v ${TARGET}-${rel}.zip ${TARGET}.exe + diff --git a/src/about.h b/src/about.h index 1eceedb..cea5530 100644 --- a/src/about.h +++ b/src/about.h @@ -8,7 +8,7 @@ #ifndef __ABOUT_H__ #define __ABOUT_H__ -#include +#include class AboutWindow: public QWidget { diff --git a/src/action.h b/src/action.h index b0ddc14..f456d8f 100644 --- a/src/action.h +++ b/src/action.h @@ -1,7 +1,7 @@ #ifndef __ACTION_H__ #define __ACTION_H__ -#include +#include #include "vector.h" class Object; diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index ad3bc8d..f2dc923 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -129,7 +129,7 @@ void ApplicationWindow::FileOpen(void) if (filename.isEmpty()) return; - FILE * file = fopen(filename.toAscii().data(), "r"); + FILE * file = fopen(filename.toUtf8().data(), "r"); if (file == 0) { @@ -168,7 +168,7 @@ void ApplicationWindow::FileSave(void) documentName = QFileDialog::getSaveFileName(this, tr("Save Drawing"), "", tr("Architektonas drawings (*.drawing)")); - FILE * file = fopen(documentName.toAscii().data(), "w"); + FILE * file = fopen(documentName.toUtf8().data(), "w"); if (file == 0) { @@ -189,7 +189,7 @@ void ApplicationWindow::FileSave(void) msg.setIcon(QMessageBox::Critical); msg.exec(); // In this case, we should unlink the created file, since it's not right... -// unlink(documentName.toAscii().data()); +// unlink(documentName.toUtf8().data()); QFile::remove(documentName); return; } diff --git a/src/applicationwindow.h b/src/applicationwindow.h index e2e4934..339744b 100644 --- a/src/applicationwindow.h +++ b/src/applicationwindow.h @@ -1,7 +1,7 @@ #ifndef __APPLICATIONWINDOW_H__ #define __APPLICATIONWINDOW_H__ -#include +#include // Forward declarations diff --git a/src/baseunittab.h b/src/baseunittab.h index d3a01ba..b600a72 100644 --- a/src/baseunittab.h +++ b/src/baseunittab.h @@ -1,7 +1,7 @@ #ifndef __BASEUNITTAB_H__ #define __BASEUNITTAB_H__ -#include +#include class BaseUnitTab: public QWidget { diff --git a/src/blockitemwidget.h b/src/blockitemwidget.h index f703fbf..3416769 100644 --- a/src/blockitemwidget.h +++ b/src/blockitemwidget.h @@ -1,7 +1,7 @@ #ifndef __BLOCKITEMWIDGET_H__ #define __BLOCKITEMWIDGET_H__ -#include +#include class BlockItemWidget: public QWidget { diff --git a/src/blockwidget.h b/src/blockwidget.h index ce53b9b..d3ac02c 100644 --- a/src/blockwidget.h +++ b/src/blockwidget.h @@ -1,7 +1,7 @@ #ifndef __BLOCKWIDGET_H__ #define __BLOCKWIDGET_H__ -#include +#include class BlockWidget: public QWidget { diff --git a/src/circle.cpp b/src/circle.cpp index 093f533..ed37be3 100644 --- a/src/circle.cpp +++ b/src/circle.cpp @@ -135,6 +135,11 @@ Circle::~Circle() return false; } +/* +Note that we can separate this out in the TLC, and it would probably make more sense +to do it there as then we can be assured that all hit testing is done before we do +any snapping. !!! FIX !!! +*/ // Hit test tells us what we hit (if anything) through boolean variables. It // also tells us whether or not the state changed. SaveHitState(); @@ -183,8 +188,8 @@ Circle::~Circle() double length = Vector::Magnitude(position, point); //printf("Circle::length = %lf, radius = %lf\n", length, radius); //How to translate this into pixels from Document space??? -//Maybe we need to pass a scaling factor in here from the caller? That would make sense, as -//the caller knows about the zoom factor and all that good kinda crap +//Maybe we need to pass a scaling factor in here from the caller? That would make +//sense, as the caller knows about the zoom factor and all that good kinda crap /* Document passes in the correct Cartesian coordinates being pointed to by the mouse. So all we have to be concerned with is properly scaling our hot zones/handle sizes, @@ -198,8 +203,13 @@ pointed at length with our on screen length. if ((length * Painter::zoom) < 8.0) { hitCenter = true; - snapPoint = position; - snapPointIsValid = true; + + // Make sure we don't try to snap to ourselves...! + if (!draggingCenter) + { + snapPoint = position; + snapPointIsValid = true; + } } //wrong: else if ((length < (radius + 2.0)) && (length > (radius - 2.0))) /*NB: The following should be identical to what we have down below, but it doesn't work out that way... :-P */ diff --git a/src/drawingview.cpp b/src/drawingview.cpp index fc30ac8..629999f 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -419,6 +419,16 @@ void DrawingView::mouseMoveEvent(QMouseEvent * event) // This returns true if we've moved over an object... if (document.PointerMoved(point)) { +/* +Now objects handle mouse move snapping as well. The code below mainly works only +for tools; we need to fix it so that objects work as well... + +There's a problem with the object point snapping in that it's dependent on the +order of the objects in the document. Most likely this is because it counts the +selected object last and thus fucks up the algorithm. Need to fix this... + + +*/ // Do object snapping here. Grid snapping on mouse down is done in the // objects themselves, only because we have to hit test the raw point, // not the snapped point. There has to be a better way...! diff --git a/src/drawingview.h b/src/drawingview.h index 2cc4bcd..af0fa92 100644 --- a/src/drawingview.h +++ b/src/drawingview.h @@ -1,7 +1,7 @@ #ifndef __DRAWINGVIEW_H__ #define __DRAWINGVIEW_H__ -#include +#include #include #include "action.h" #include "container.h" diff --git a/src/generaltab.h b/src/generaltab.h index 8dde60a..34182ed 100644 --- a/src/generaltab.h +++ b/src/generaltab.h @@ -1,7 +1,7 @@ #ifndef __GENERALTAB_H__ #define __GENERALTAB_H__ -#include +#include class GeneralTab: public QWidget { diff --git a/src/layeritemwidget.h b/src/layeritemwidget.h index 0ee1119..999cccf 100644 --- a/src/layeritemwidget.h +++ b/src/layeritemwidget.h @@ -1,7 +1,7 @@ #ifndef __LAYERITEMWIDGET_H__ #define __LAYERITEMWIDGET_H__ -#include +#include class LayerItemWidget: public QWidget { diff --git a/src/layerwidget.h b/src/layerwidget.h index 082c81d..914c29c 100644 --- a/src/layerwidget.h +++ b/src/layerwidget.h @@ -1,7 +1,7 @@ #ifndef __LAYERWIDGET_H__ #define __LAYERWIDGET_H__ -#include +#include class LayerWidget: public QWidget { diff --git a/src/main.h b/src/main.h index 2b70ce4..8549fc8 100644 --- a/src/main.h +++ b/src/main.h @@ -1,7 +1,7 @@ #ifndef __MAIN_H__ #define __MAIN_H__ -#include +#include // Forward declarations //class CharWindow; diff --git a/src/painter.h b/src/painter.h index 955e553..178b7db 100644 --- a/src/painter.h +++ b/src/painter.h @@ -1,7 +1,7 @@ #ifndef __PAINTER_H__ #define __PAINTER_H__ -#include +#include #include "vector.h" //#define SCREEN_ZOOM (1.0 / 4.0) diff --git a/src/settingsdialog.h b/src/settingsdialog.h index 941f21d..064ce9a 100644 --- a/src/settingsdialog.h +++ b/src/settingsdialog.h @@ -1,7 +1,7 @@ #ifndef __SETTINGSDIALOG_H__ #define __SETTINGSDIALOG_H__ -#include +#include class GeneralTab; class BaseUnitTab; diff --git a/src/text.h b/src/text.h index 8bba9f8..4e0bbb1 100644 --- a/src/text.h +++ b/src/text.h @@ -2,7 +2,7 @@ #define __TEXT_H__ #include "object.h" -#include +#include class Text: public Object { diff --git a/src/vector.cpp b/src/vector.cpp index 6147c6d..a60c133 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -228,13 +228,13 @@ bool Vector::isZero(double epsilon/*= 1e-6*/) // Class methods -double Vector::Dot(Vector v1, Vector v2) +/*static*/ double Vector::Dot(Vector v1, Vector v2) { return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); } -double Vector::Magnitude(Vector v1, Vector v2) +/*static*/ double Vector::Magnitude(Vector v1, Vector v2) { double xx = v1.x - v2.x; double yy = v1.y - v2.y; @@ -246,7 +246,7 @@ double Vector::Magnitude(Vector v1, Vector v2) // Returns the parameter of a point in space to this vector. If the parameter // is between 0 and 1, the normal of the vector to the point is on the vector. // Note: v1 is the tail, v2 is the head of the line (vector). -double Vector::Parameter(Vector tail, Vector head, Vector p) +/*static*/ double Vector::Parameter(Vector tail, Vector head, Vector p) { // Geometric interpretation: // The parameterized point on the vector lineSegment is where the normal of @@ -262,13 +262,27 @@ double Vector::Parameter(Vector tail, Vector head, Vector p) } -// Return the normal to the linesegment formed by the passed in points. -// (Not sure which is head or tail, or which hand the normal lies) -// [v1 should be the tail, v2 should be the head, in which case the normal should -// rotate anti-clockwise.] +// Return the 2D normal to the linesegment formed by the passed in points. +// The normal thus calculated should rotate anti-clockwise. /*static*/ Vector Vector::Normal(Vector tail, Vector head) { Vector v = (head - tail).Unit(); return Vector(-v.y, v.x); } + +/*static*/ double Vector::AngleBetween(Vector a, Vector b) +{ + // This is done using the following formula: + // (a . b) = ||a|| ||b|| cos(theta) + // However, have to check for two degenerate cases, where a = cb: + // 1, if c > 0, theta = 0; 2, if c < 0, theta = 180°. + // Also, the vectors a & b have to be non-zero. + // Also, have to check using an epsilon because acos will not return an + // exact value if the vectors are orthogonal + if (a.isZero() || b.isZero()) + return 0; + + return acos(a.Dot(b) / (a.Magnitude() * b.Magnitude())); +} + diff --git a/src/vector.h b/src/vector.h index bbc3aa7..6243898 100644 --- a/src/vector.h +++ b/src/vector.h @@ -51,6 +51,7 @@ class Vector static double Magnitude(Vector v1, Vector v2); static double Parameter(Vector v1, Vector v2, Vector p); static Vector Normal(Vector v1, Vector v2); + static double AngleBetween(Vector a, Vector b); public: double x, y, z;