<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/res">
+ <file>about-logo.png</file>
<file>atns-icon.png</file>
<file>dimension-tool.png</file>
<file>fix-angle.png</file>
"</ul>"
));
#else
-// QString s = QString(tr("(Last full build was on %1 %2)<br>")).arg(__DATE__).arg(__TIME__);
- QString s = QString(tr("<body style='background-image::/res/atns-icon.png'>"//<img src=':/res/atns-icon.png' style='float:right'>"//));
-// s.append(tr(
-//"This is some random text. I wonder if it will be rendered correctly or not???</p>"
-// "<table><tr><td valign='middle'>"
- "<table style='float:left'>"
+ QString s = QString(tr(
+ "<table>"
+ "<tr>"
+ "<td><img src=':/res/about-logo.png' style='float:left; margin-right:20px'></td>"
+ "<td>"
+ "<table>"
+// "<tr><td align='right'><b>Architektonas: </b></td><td width='100'>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
"<tr><td align='right'><b>Architektonas: </b></td><td>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
"<tr><td align='right'><b>Version: </b></td><td>1.0.0</td></tr>"
"<tr><td align='right'><b>License: </b></td><td>GPL v3 or later</td></tr>"
// "<tr><td align='right'><b>Testers: </b></td><td>shamus</td></tr>"
"<tr><td align='right'><b>Homepage: </b></td><td>http://shamusworld.gotdns.org/architektonas/</td></tr>"
"</table>"
-"<img src=':/res/atns-icon.png' style='float:right'>"
-// "</td>"
-// "<td><img src=':/res/atns-icon.png'></td></tr></table>"
"<br><br>"
"<i>The authors of Architektonas would like to express their heartfelt gratitude to:</i>"
-// "<br>"
"<ul>"
"<li>The authors of <b>Inkscape</b>, whose incredible GUI was a huge inspiration for us</li>"
"<li><b>QCad</b> for sucking so bad that we just <i>had</i> to write something better</li>"
"<li>Every other 2D CAD package out there that's mired in a legacy of the bad old days of pencil and paper, and all the attendant horrors that came along with that. We couldn't have done it without you!</li>"
- "</ul></body>"
+ "</ul>"
+ "</td>"
+ "</tr>"
+ "</table>"
));
#endif
text = new QLabel(s);
text->setWordWrap(true);
+// text->setMinimumWidth(480);
// text->setMaximumWidth(800);
layout->addWidget(text);
}
Object::SetDimensionActive(addDimensionAct->isChecked());
}
+void ApplicationWindow::RotateTool(void)
+{
+ drawing->SetRotateToolActive(rotateAct->isChecked());
+}
+
void ApplicationWindow::HelpAbout(void)
{
aboutWin->show();
deleteAct = CreateAction(tr("&Delete"), tr("Delete Object"), tr("Deletes selected objects."), QIcon(":/res/generic-tool.png"), QKeySequence(), true);
connect(deleteAct, SIGNAL(triggered()), this, SLOT(DeleteTool()));
- addDimensionAct = CreateAction(tr("Add &Dimension"), tr("Add Dimension"), tr("Adds a dimension to the drawing."), QIcon(":/res/dimension-tool.png"), QKeySequence("D, I"), true);
+ addDimensionAct = CreateAction(tr("Add &Dimension"), tr("Add Dimension"), tr("Adds a dimension to the drawing."), QIcon(":/res/dimension-tool.png"), QKeySequence("D,I"), true);
connect(addDimensionAct, SIGNAL(triggered()), this, SLOT(DimensionTool()));
addLineAct = CreateAction(tr("Add &Line"), tr("Add Line"), tr("Adds a line to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(), true);
aboutAct = CreateAction(tr("About &Architektonas"), tr("About Architektonas"), tr("Gives information about this program."), QIcon(":/res/generic-tool.png"), QKeySequence());
connect(aboutAct, SIGNAL(triggered()), this, SLOT(HelpAbout()));
- //Hm.
+ rotateAct = CreateAction(tr("&Rotate Objects"), tr("Rotate"), tr("Rotate object(s) around an arbitrary center."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("R,O")), true);
+ connect(rotateAct, SIGNAL(triggered()), this, SLOT(RotateTool()));
+
+ fileNewAct = CreateAction(tr("&New Drawing"), tr("New Drawing"), tr("Creates a new drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+n")));
+
+ fileOpenAct = CreateAction(tr("&Open Drawing"), tr("Open Drawing"), tr("Opens an existing drawing from a file."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+o")));
+
+ fileSaveAct = CreateAction(tr("&Save Drawing"), tr("Save Drawing"), tr("Saves the current drawing to a file."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+s")));
+
+ fileSaveAsAct = CreateAction(tr("Save Drawing &As"), tr("Save As"), tr("Saves the current drawing to a file with a different name."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+Shift+s")));
+
+ fileCloseAct = CreateAction(tr("&Close Drawing"), tr("Close Drawing"), tr("Closes the current drawing."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("Ctrl+w")));
+
+ settingsAct = CreateAction(tr("&Settings"), tr("Settings"), tr("Change certain defaults for Architektonas."), QIcon(":/res/generic-tool.png"), QKeySequence());
+
+//Hm. I think we'll have to have separate logic to do the "Radio Group Toolbar" thing...
/* QActionGroup * group = new QActionGroup(this);
group->addAction(deleteAct);
group->addAction(addDimensionAct);
void ApplicationWindow::CreateMenus(void)
{
QMenu * menu = menuBar()->addMenu(tr("&File"));
-// fileMenu->addAction(newAct);
-// fileMenu->addAction(openAct);
-// fileMenu->addAction(saveAct);
-// fileMenu->addAction(saveAsAct);
-// fileMenu->addSeparator();
+ menu->addAction(fileNewAct);
+ menu->addAction(fileOpenAct);
+ menu->addAction(fileSaveAct);
+ menu->addAction(fileSaveAsAct);
+ menu->addAction(fileCloseAct);
+ menu->addSeparator();
menu->addAction(exitAct);
menu = menuBar()->addMenu(tr("&Edit"));
menu->addAction(fixAngleAct);
menu->addAction(fixLengthAct);
+ menu->addAction(rotateAct);
menu->addSeparator();
menu->addAction(deleteAct);
menu->addSeparator();
menu->addAction(addCircleAct);
menu->addAction(addArcAct);
menu->addAction(addDimensionAct);
+ menu->addSeparator();
+ menu->addAction(settingsAct);
// editMenu = menuBar()->addMenu(tr("&Edit"));
// editMenu->addAction(cutAct);
toolbar = addToolBar(tr("Edit"));
toolbar->addAction(fixAngleAct);
toolbar->addAction(fixLengthAct);
+ toolbar->addAction(rotateAct);
toolbar->addAction(deleteAct);
toolbar->addAction(addLineAct);
toolbar->addAction(addCircleAct);
{
QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
QSize size = settings.value("size", QSize(400, 400)).toSize();
+ drawing->useAntialiasing = settings.value("useAntialiasing", true).toBool();
resize(size);
move(pos);
// pos = settings.value("charWndPos", QPoint(0, 0)).toPoint();
{
settings.setValue("pos", pos());
settings.setValue("size", size());
+ settings.setValue("useAntialiasing", drawing->useAntialiasing);
// settings.setValue("charWndPos", ((TTEdit *)qApp)->charWnd->pos());
// settings.setValue("charWndSize", ((TTEdit *)qApp)->charWnd->size());
}
void FixLength(void);
void DeleteTool(void);
void DimensionTool(void);
+ void RotateTool(void);
void HelpAbout(void);
private:
QSettings settings;
+ QAction * fileNewAct;
+ QAction * fileOpenAct;
+ QAction * fileSaveAct;
+ QAction * fileSaveAsAct;
+ QAction * fileCloseAct;
QAction * exitAct;
+ QAction * settingsAct;
QAction * fixAngleAct;
QAction * fixLengthAct;
QAction * deleteAct;
QAction * addCircleAct;
QAction * addArcAct;
QAction * aboutAct;
+ QAction * rotateAct;
};
#endif // __APPLICATIONWINDOW_H__
// WHO WHEN WHAT
// --- ---------- ------------------------------------------------------------
// JLH 03/30/2011 Created this file
+// JLH 06/02/2011 Added code to delete objects in this container when they go
+// out of scope
//
#include "container.h"
Container::~Container()
{
+ // No memory leaks!
+ while (objects.size() > 0)
+ {
+ delete objects[0];
+ objects.erase(objects.begin());
+ }
}
/*virtual*/ void Container::Draw(QPainter * painter)
DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
+ // The value in the settings file will override this.
+ useAntialiasing(true),
// scale(1.0), offsetX(-10), offsetY(-10), tool(TOOLSelect),
// ptHighlight(-1), oldPtHighlight(-1), ptNextHighlight(-1), oldPtNextHighlight(-1),
// polyFirstPoint(true)
scale(1.0), offsetX(-10), offsetY(-10),
document(Vector(0, 0)),
- gridSpacing(32.0), collided(false)
+ gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0)
{
setBackgroundRole(QPalette::Base);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
#endif
}
+void DrawingView::SetRotateToolActive(bool state/*= true*/)
+{
+ rotateTool = state;
+ update();
+}
+
QPoint DrawingView::GetAdjustedMousePosition(QMouseEvent * event)
{
// This is undoing the transform, e.g. going from client coords to local coords.
void DrawingView::paintEvent(QPaintEvent * /*event*/)
{
QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
+
+ if (useAntialiasing)
+ painter.setRenderHint(QPainter::Antialiasing);
#if 0
painter.translate(QPoint(-offsetX, size.height() - (-offsetY)));
painter.drawLine(0, -16384, 0, 16384);
painter.drawLine(-16384, 0, 16384, 0);
+ // Draw supplemental (tool related) points
+
+ if (rotateTool)
+ {
+ painter.setPen(QPen(QColor(0, 200, 0), 2.0, Qt::SolidLine));
+ painter.drawLine(rx - 10, ry, rx + 10, ry);
+ painter.drawLine(rx, ry - 10, rx, ry + 10);
+ }
+
// Maybe we can make the grid into a background brush instead, and let Qt deal
// with it???
// Draw grid
public:
DrawingView(QWidget * parent = NULL);
+ public:
+ void SetRotateToolActive(bool state = true);
+
protected:
void paintEvent(QPaintEvent * event);
void mousePressEvent(QMouseEvent * event);
QPoint GetAdjustedMousePosition(QMouseEvent * event);
QPoint GetAdjustedClientPosition(int x, int y);
+ public:
+ bool useAntialiasing;
+
private:
double scale; // Window scaling factor
int32_t offsetX, offsetY; // Window offsets
Container document;
double gridSpacing;
bool collided;
+//Should this go into Object's class variables???
+ bool rotateTool;
+ double rx, ry;
/* QSize minimumSizeHint() const;
QSize sizeHint() const;
// "Fixed Length" button is down
// JLH 04/27/2011 Fixed attached dimension to stay a correct length when
// "Fixed Length" button is *not* down ;-)
-// JLH 05/29/2011 Added mouseover hints
+// JLH 05/29/2011 Added (some) mouseover hints
//
#include "line.h"
Line::~Line()
{
+ // If there are any attached Dimensions, we must set the attachment points
+ // to NULL since they will no longer be valid.
+ if (attachedDimension)
+ {
+ attachedDimension->SetPoint1(NULL);
+ attachedDimension->SetPoint2(NULL);
+ }
+ // IT WOULD BE NICE to have any object points attached to this line automagically
+ // connect to this dimension object at this point, instead of just becoming
+ // detached.
}
/*virtual*/ void Line::Draw(QPainter * painter)
to only one point while at the same time you can have a dimension sitting on this line.
Since there's only *one* dimPoint for each point, this can be problematic...
+We solve this by allowing only *one* Dimension object to be attached to the Line,
+Arc, etc. and by giving the Dimension object a pointer to our endpoints.
+
+Problem still arises when we delete this object; The attached Dimension object will
+then have bad pointers! What is *should* do is delete the object if and only if this
+line is not attached to any other object. If it is, then one of those attachment
+points should be sent to the dimension object (done for position & endpoint).
+
+NOTE: The STL vector<T> *does not* take ownership of pointers, therefore is suitable
+ for our purposes
+
Also: It would be nice to have a preview of the dimension being drawn, with a modifier
key to make it draw/show on the other side...
#ifndef __OBJECT_H__
#define __OBJECT_H__
-#include "vector.h"
+#include <vector> // This is a container
+#include "vector.h" // This is the mathematical construct
class QPainter;
class QFont;
virtual Object * GetParent(void);
virtual void Add(Object *);
ObjectState GetState(void);
+//Hm. Object * Connect(Object *);
// Class methods
static void SetFixedAngle(bool state = true);
ObjectState oldState;
bool needUpdate;
Dimension * attachedDimension;
+ std::vector<Object *> connected;
// Class variables
static QFont * font;