]> Shamusworld >> Repos - architektonas/commitdiff
Converted codebase from Qt4 to Qt5.
authorShamus Hammons <jlhamm@acm.org>
Fri, 26 Dec 2014 14:45:08 +0000 (08:45 -0600)
committerShamus Hammons <jlhamm@acm.org>
Fri, 26 Dec 2014 14:45:08 +0000 (08:45 -0600)
22 files changed:
README
architektonas.pro
cross-compile
src/about.h
src/action.h
src/applicationwindow.cpp
src/applicationwindow.h
src/baseunittab.h
src/blockitemwidget.h
src/blockwidget.h
src/circle.cpp
src/drawingview.cpp
src/drawingview.h
src/generaltab.h
src/layeritemwidget.h
src/layerwidget.h
src/main.h
src/painter.h
src/settingsdialog.h
src/text.h
src/vector.cpp
src/vector.h

diff --git a/README b/README
index e749f3f3fc855a5100a8261fba8343b6443a2183..b979c369270703eefaae643770fa3bd5a18f80cb 100644 (file)
--- 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:
index 53c36b2ac9563a652b396ed0d6c8358968e73982..a16a8a8df79d0f66d213d10a4f9d30ba992e0c21 100644 (file)
@@ -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
index 41158258e8a24ef1b7603bac8a332b22eb7a5cf3..cbb56a33da6751c0a21220cec0698a8b3d2bfcf6 100755 (executable)
@@ -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
+
index 1eceedb72a578c711a50bb43063d9f5ce55d6862..cea55309ea2447b08c6c6fdeb6c6d9712a01f720 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef __ABOUT_H__
 #define __ABOUT_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class AboutWindow: public QWidget
 {
index b0ddc1411e1c5921319515d2dd793c697b719345..f456d8f3925833116c7a7e6e47b9b7baea47d66b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __ACTION_H__
 #define __ACTION_H__
 
-#include <QtGui>
+#include <QtWidgets>
 #include "vector.h"
 
 class Object;
index ad3bc8d9ec0b4c209087f7d58d39e8c79c427fc2..f2dc923b5c2313b852ee56109efe0cc9434d8e33 100644 (file)
@@ -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;
        }
index e2e49345bf2015f0f30af62894e3f83195a55153..339744b4ab1756bfc33c5648f861fbe418ff6f68 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __APPLICATIONWINDOW_H__
 #define __APPLICATIONWINDOW_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 // Forward declarations
 
index d3a01bad496bf79d5a3179dbba4f571bf493e59b..b600a72df3b8f858219dade478138dc094a8e6dc 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __BASEUNITTAB_H__
 #define __BASEUNITTAB_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class BaseUnitTab: public QWidget
 {
index f703fbfdf4ac254eaa885bdf05312a886ac56de6..341676917080df695d9f4e22e1be3fd53b5b97ad 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __BLOCKITEMWIDGET_H__
 #define __BLOCKITEMWIDGET_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class BlockItemWidget: public QWidget
 {
index ce53b9b87a2cf46db5c1f5da1e62d9438683e526..d3ac02cf37de6102141e0fd2e04045184ce88f46 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __BLOCKWIDGET_H__
 #define __BLOCKWIDGET_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class BlockWidget: public QWidget
 {
index 093f53395834bd3472a05a3242ad148bd1cc8759..ed37be3fcd7268faf59cfcb3906316f69a447045 100644 (file)
@@ -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 */
index fc30ac8e259ce61a092b35210f2ab6280ce2b457..629999f148b4a83a9bb604bb0360bc502b54d2a1 100644 (file)
@@ -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...!
index 2cc4bcdac8676e0118e2214eff3f5c4ddfbb9e5b..af0fa9265afdade5a85430e35b5a6905aad0dd64 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __DRAWINGVIEW_H__
 #define __DRAWINGVIEW_H__
 
-#include <QtGui>
+#include <QtWidgets>
 #include <stdint.h>
 #include "action.h"
 #include "container.h"
index 8dde60a41af2687ecc755a5c8f0800c28f52c747..34182eddb80be4b6405cd83d02f41b98a4ef2f6b 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __GENERALTAB_H__
 #define __GENERALTAB_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class GeneralTab: public QWidget
 {
index 0ee11191c4d0ac5026a73c3e25bec8aaaff441b7..999cccf5447ba02b5584eb4f1fb2477ae6a11948 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LAYERITEMWIDGET_H__
 #define __LAYERITEMWIDGET_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class LayerItemWidget: public QWidget
 {
index 082c81d47dcfe657db198c98319dfbab660c2efb..914c29ca32c24063dc66e6eddfcd3dfddf69feb2 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __LAYERWIDGET_H__
 #define __LAYERWIDGET_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class LayerWidget: public QWidget
 {
index 2b70ce424a4bac9994cb5f7370fc42aed631fa8b..8549fc870ce1af71a2ba37f7a024475dcd179b57 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __MAIN_H__
 #define __MAIN_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 // Forward declarations
 //class CharWindow;
index 955e553201ba0936ab2a7cdecb33c00d112c0666..178b7dbca605ad772f7b9d9c2f2ffe792c09e2e1 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __PAINTER_H__
 #define __PAINTER_H__
 
-#include <QtGui>
+#include <QtWidgets>
 #include "vector.h"
 
 //#define SCREEN_ZOOM  (1.0 / 4.0)
index 941f21d6a3bd2659c38d7334fbd85f30ec63c9ce..064ce9a6589dd50f3c4537736b019851ffd3b557 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __SETTINGSDIALOG_H__
 #define __SETTINGSDIALOG_H__
 
-#include <QtGui>
+#include <QtWidgets>
 
 class GeneralTab;
 class BaseUnitTab;
index 8bba9f82ac5915776c0b5fb2abc5e4d138d25dca..4e0bbb19a1e785c9a6cfeda767e465df78c28701 100644 (file)
@@ -2,7 +2,7 @@
 #define __TEXT_H__
 
 #include "object.h"
-#include <QtGui>
+#include <QtWidgets>
 
 class Text: public Object
 {
index 6147c6d71d4021c0e10744b482e2b7796bb93c72..a60c1334fd4469897510a350d86c6ccf3d8d37d8 100644 (file)
@@ -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()));
+}
+
index bbc3aa7df88077682ddea1e82022a1dd0aeea738..62438986ef653bd0462d9e600e307105ce592ba3 100644 (file)
@@ -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;