]> Shamusworld >> Repos - architektonas/commitdiff
Added mouse wheel zoom.
authorShamus Hammons <jlhamm@acm.org>
Sun, 12 Jan 2014 03:47:33 +0000 (21:47 -0600)
committerShamus Hammons <jlhamm@acm.org>
Sun, 12 Jan 2014 03:47:33 +0000 (21:47 -0600)
src/applicationwindow.cpp
src/container.cpp
src/drawingview.cpp
src/drawingview.h
src/ellipse.h
web/atns.css [new file with mode: 0644]
web/index.html [new file with mode: 0644]

index 71e8a087d5618225543d37438e1e5b8c23986d53..cb4f020f5e9ab531217feeef9f62bdd7d076d453 100644 (file)
@@ -178,7 +178,8 @@ 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.toAscii().data());
+               QFile::remove(documentName);
                return;
        }
 
@@ -312,18 +313,14 @@ when zooming in, new origin will be (xCenter - origin.x) / 2, (yCenter - origin.
        Painter::origin = newOrigin;
 
 //printf("Zoom in... level going from %02f to ", Painter::zoom);
-       // This just zooms leaving origin intact... should zoom in at the current center! [DONE]
-       // This should actually be calculated by drawing->gridPixels / grid size.
+       // This just zooms leaving origin intact... should zoom in at the current
+       // center! [DONE]
        Painter::zoom *= zoomFactor;
-//     drawing->gridSpacing = drawing->gridPixels / Painter::zoom;
        Object::gridSpacing = drawing->gridPixels / Painter::zoom;
-//     zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing));
-//     zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(drawing->gridSpacing));
-       zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Object::gridSpacing));
        drawing->UpdateGridBackground();
        drawing->update();
 
-//     baseUnitInput->setText(QString("%1").arg(drawing->gridSpacing));
+       zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Object::gridSpacing));
        baseUnitInput->setText(QString("%1").arg(Object::gridSpacing));
 }
 
@@ -355,17 +352,14 @@ x 2 = (-426, -301)
 //printf("newOrigin=%.2f,%.2f;\n", newOrigin.x, newOrigin.y);
        Painter::origin = newOrigin;
 //printf("Zoom out...\n");
-       // This just zooms leaving origin intact... should zoom out at the current center! [DONE]
+       // This just zooms leaving origin intact... should zoom out at the current
+       // center! [DONE]
        Painter::zoom /= zoomFactor;
-//     drawing->gridSpacing = drawing->gridPixels / Painter::zoom;
        Object::gridSpacing = drawing->gridPixels / Painter::zoom;
-//     zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing));
-//     zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(drawing->gridSpacing));
-       zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Object::gridSpacing));
        drawing->UpdateGridBackground();
        drawing->update();
 
-//     baseUnitInput->setText(QString("%1").arg(drawing->gridSpacing));
+       zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Object::gridSpacing));
        baseUnitInput->setText(QString("%1").arg(Object::gridSpacing));
 }
 
index 976172fb38220f094838a7cc806ab1fa482a9712..6050f3217b73ecea8f7bb33ef63df8ec77d740d4 100644 (file)
@@ -54,22 +54,12 @@ Container & Container::operator=(const Container & from)
                return *this;
 
        Clear();
-
-       // Small problem with this approach: if the copied object goes out of scope,
-       // all of the objects we copied in here will be deleted. D'oh!
-       // For this COPY constructor to be meaningful, we have to actually COPY the
-       // objects in this Container, not just MOVE a copy of the POINTER! D-:
        std::vector<Object *>::const_iterator i;
 
-//     for(uint i=0; i<from.objects.size(); i++)
        for(i=from.objects.begin(); i!=from.objects.end(); i++)
        {
-//             Object * object = from.objects[i];
+printf("Container: Copying object $%08X...\n", *i);
                Object * object = (*i)->Copy();
-
-               // Need to actually COPY the object here, not copy the pointer only!!
-               // (which we do now, above :-P)
-
                objects.push_back(object);
        }
 
@@ -493,7 +483,7 @@ void Container::CopySelectedContentsTo(Container * newContainer)
        if (newContainer == NULL)
                return;
 
-       // Shuffle the contents of this container to the new one
+       // Copy the contents of this container to the new one
        for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
        {
                if ((*i)->state == OSSelected)
index 656545b945c3738442e47513b96878f2843fe2f1..9341a76279044ef78c64e3d21a39f95d85cda41c 100644 (file)
@@ -467,26 +467,44 @@ void DrawingView::mouseReleaseEvent(QMouseEvent * event)
 }
 
 
-void DrawingView::keyPressEvent(QKeyEvent * event)
+void DrawingView::wheelEvent(QWheelEvent * event)
 {
-       if (toolAction)
-       {
-               /*bool needUpdate =*/ toolAction->KeyDown(event->key());
+       double zoomFactor = 1.25;
+       QSize sizeWin = /*drawing->*/size();
+       Vector center(sizeWin.width() / 2.0, sizeWin.height() / 2.0);
+       center = Painter::QtToCartesianCoords(center);
 
-//             if (needUpdate)
-//                     update();
+       if (event->delta() > 0)
+       {
+               Vector newOrigin = center - ((center - Painter::origin) / zoomFactor);
+               Painter::origin = newOrigin;
+               Painter::zoom *= zoomFactor;
        }
+       else
+       {
+               Vector newOrigin = center + ((-center + Painter::origin) * zoomFactor);
+               Painter::origin = newOrigin;
+               Painter::zoom /= zoomFactor;
+       }
+
+//     Object::gridSpacing = /*drawing->*/gridPixels / Painter::zoom;
+       SetGridSize(Object::gridSpacing * Painter::zoom);
+//     /*drawing->*/UpdateGridBackground();
+       /*drawing->*/update();
+//     zoomIndicator->setText(QString("Grid: %1\", BU: Inch").arg(Object::gridSpacing));
 }
 
 
-void DrawingView::keyReleaseEvent(QKeyEvent * event)
+void DrawingView::keyPressEvent(QKeyEvent * event)
 {
        if (toolAction)
-       {
-               /*bool needUpdate =*/ toolAction->KeyReleased(event->key());
+               toolAction->KeyDown(event->key());
+}
 
-//             if (needUpdate)
-//                     update();
-       }
+
+void DrawingView::keyReleaseEvent(QKeyEvent * event)
+{
+       if (toolAction)
+               toolAction->KeyReleased(event->key());
 }
 
index 21220e88a99c4479e28a525ef481638204b480fe..2cc4bcdac8676e0118e2214eff3f5c4ddfbb9e5b 100644 (file)
@@ -30,6 +30,7 @@ class DrawingView: public QWidget
                void mousePressEvent(QMouseEvent * event);
                void mouseMoveEvent(QMouseEvent * event);
                void mouseReleaseEvent(QMouseEvent * event);
+               void wheelEvent(QWheelEvent * event);
                void keyPressEvent(QKeyEvent * event);
                void keyReleaseEvent(QKeyEvent * event);
 
index b200f78027c8e2f042cbc3547412fac371035e97..c58e41fda0a4c978a632124beff3e1fa7b5ea35d 100644 (file)
@@ -7,4 +7,6 @@ We have a separate class for arcs, and those are circle variants too.
 Maybe. The ellipse (and elliptical arc) have two focii and a rotation angle.
 But there's no reason why those extras couldn't go into the Circle class as
 well.
+
+Actually, all that's needed are the two focii and radius...
 */
diff --git a/web/atns.css b/web/atns.css
new file mode 100644 (file)
index 0000000..7bf835e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+
+CSS for Architektonas
+
+*/
+
+body
+{
+       color: #007F00;
+       background-color: #C0FFF0;
+       font: 12.0pt verdana, sans-serif;
+       text-align: center; /* Crappy hack for IE--die, Die, DIE! */
+}
+
+h1
+{
+       font-size: 48pt;
+       font-weight: bold;
+       color: #FF0000;
+}
+
+h2
+{
+       font-size: 20pt;
+       font-weight: bold;
+       color: #FF7F00;
+}
+
+p, ul, h3
+{
+       text-align: left;
+}
+
+p#footer
+{
+       margin-top: 40px;
+       color: #AF0000;
+       font-size: 10pt;
+       font-style: italic;
+}
+
diff --git a/web/index.html b/web/index.html
new file mode 100644 (file)
index 0000000..c48009b
--- /dev/null
@@ -0,0 +1,50 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>Architektonas - Free 2D CAD Software</title>
+
+<meta name="description" content="Architektonas Homepage" />
+<meta name="keywords" content="CAD, software, multi-platform, free, 2D" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="GENERATOR" content="Kate" />
+
+<link rel="stylesheet" href="atns.css" type="text/css" />
+</head>
+
+<body class="mainpage">
+
+<h1>Architektonas</h1>
+
+<h2>Free Multi-platform 2D CAD Software</h2>
+
+<hr />
+
+<h3>History</h3>
+
+<p>From the ashes of QCad Community Edition 2.0.5.0 comes Architektonas! This project arose because Qt version 3 was removed from the Gentoo Portage tree. Coupled with the fact that QCad CE, which depends on Qt3, had not seen an update for quite some time, QCad was also removed from Portage&mdash;and so work began on porting QCad CE from Qt3 to Qt4.</p>
+
+<p>Needless to say, this was a task of Herculean proportions; but soon the effort was starting to pay dividends! At first, simply getting QCad to work with the Qt3Support module in Qt4 was done to see if further work should be carried out. Once positive results were gained in this regard, further work was done to remove all dependencies on Qt3Support in order to make QCad a full fledged Qt4 application.</p>
+
+<p>In time it was determined that while getting QCad to this state would be a worthwhile goal, it would not be the end point of that work. Feature parity with QCad 2.0.5.0 CE, being nice, would also leave users with a good, but not great piece of software. And so the decision was made to go forward and make it even better. And so this would, of course, necessitate a name change: And so the decision was made, and now we have Architektonas!</p>
+
+<h3>Why <i>Architektonas?</i></h3>
+
+<p>When just about every variation on <i>FooCAD</i> or <i>CADFoo</i> has been taken, it&rsquo;s time to start looking for something new! And so after much searching and consideration, Achitektonas was chosen. <i>Architektonas</i> is a rough English transliteration of αρχιτέκτωνας, which is Greek for architect; we believe it to be a fit, if not lofty, name for a CAD program. For a project with lofty goals, a lofty name is needed!</p>
+
+<h3>Current Development</h3>
+
+<p>Currently, Architektonas has not yet reached feature parity with QCad 2.0.5.0 Community Edition, but steady progress is being made towards that goal. We intend to surpass that goal, but that is the first major step. If you don&rsquo;t mind working with semi-broken code, you can check out and compile it on your own. The GIT repository is located at:</p>
+
+<p class="url">https://shamusworld.gotdns.org/git/architektonas</p>
+
+<p>If you choose to go this route, you&rsquo;re on your own for now until I can set up a reliable line of communication. Good Luck!</p>
+
+<p>To those of you following along in GIT, no, we haven&rsquo;t been hacked. We are simply following through on our promise to make something that far surpasses QCad CE and all things built from it. As far as we&rsquo;re concerned, QCad (and its derivatives, such as LibreCAD) is a dead end. If you&rsquo;re curious as to why we feel that way, stay tuned as we will post a comprehensive breakdown in the near future. We are very excited about the direction Architektonas is headed, and we think you will be too!</p>
+
+<hr />
+
+<p id="footer">* If the images and text on this site look wrong and/or strange, then you&rsquo;re probably not using a standards compliant browser. You can get a great one for free <a href="http://www.mozilla.org/products/firefox/">here</a>!</p>
+</body>
+
+</html>