From: Shamus Hammons Date: Sun, 12 Jan 2014 03:47:33 +0000 (-0600) Subject: Added mouse wheel zoom. X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=architektonas;a=commitdiff_plain;h=c58b8a9f8b1ae5494857fc423ed8e33b2bbcf329 Added mouse wheel zoom. --- diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index 71e8a08..cb4f020 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -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)); } diff --git a/src/container.cpp b/src/container.cpp index 976172f..6050f32 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -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::const_iterator i; -// for(uint i=0; iCopy(); - - // 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::iterator i=objects.begin(); i!=objects.end(); i++) { if ((*i)->state == OSSelected) diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 656545b..9341a76 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -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()); } diff --git a/src/drawingview.h b/src/drawingview.h index 21220e8..2cc4bcd 100644 --- a/src/drawingview.h +++ b/src/drawingview.h @@ -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); diff --git a/src/ellipse.h b/src/ellipse.h index b200f78..c58e41f 100644 --- a/src/ellipse.h +++ b/src/ellipse.h @@ -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 index 0000000..7bf835e --- /dev/null +++ b/web/atns.css @@ -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 index 0000000..c48009b --- /dev/null +++ b/web/index.html @@ -0,0 +1,50 @@ + + + + +Architektonas - Free 2D CAD Software + + + + + + + + + + + +

Architektonas

+ +

Free Multi-platform 2D CAD Software

+ +
+ +

History

+ +

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—and so work began on porting QCad CE from Qt3 to Qt4.

+ +

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.

+ +

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!

+ +

Why Architektonas?

+ +

When just about every variation on FooCAD or CADFoo has been taken, it’s time to start looking for something new! And so after much searching and consideration, Achitektonas was chosen. Architektonas 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!

+ +

Current Development

+ +

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’t mind working with semi-broken code, you can check out and compile it on your own. The GIT repository is located at:

+ +

https://shamusworld.gotdns.org/git/architektonas

+ +

If you choose to go this route, you’re on your own for now until I can set up a reliable line of communication. Good Luck!

+ +

To those of you following along in GIT, no, we haven’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’re concerned, QCad (and its derivatives, such as LibreCAD) is a dead end. If you’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!

+ +
+ + + + +