setCentralWidget(drawing);
// ((TTEdit *)qApp)->charWnd = new CharWindow(this);
-// editWnd = new EditWindow(this);
-// setCentralWidget(editWnd);
+
setWindowIcon(QIcon(":/res/atns-icon.png"));
setWindowTitle("Architektonas");
CreateActions();
CreateMenus();
CreateToolbars();
-#if 0
-// createActions();
- newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
- newAct->setShortcuts(QKeySequence::New);
- newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
-
- openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
- openAct->setShortcuts(QKeySequence::Open);
- openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
-
- aboutQtAct = new QAction(tr("About &Qt"), this);
- aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
-
-// createMenus();
- fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(newAct);
- fileMenu->addAction(openAct);
- fileMenu->addAction(saveAct);
- fileMenu->addAction(saveAsAct);
- fileMenu->addSeparator();
- fileMenu->addAction(exitAct);
-
- editMenu = menuBar()->addMenu(tr("&Edit"));
- editMenu->addAction(cutAct);
- editMenu->addAction(copyAct);
- editMenu->addAction(pasteAct);
-
- menuBar()->addSeparator();
-
- helpMenu = menuBar()->addMenu(tr("&Help"));
- helpMenu->addAction(aboutAct);
- helpMenu->addAction(aboutQtAct);
-
-// createToolBars();
- fileToolBar = addToolBar(tr("File"));
- fileToolBar->addAction(newAct);
- fileToolBar->addAction(openAct);
- fileToolBar->addAction(saveAct);
-
- editToolBar = addToolBar(tr("Edit"));
- editToolBar->addAction(cutAct);
- editToolBar->addAction(copyAct);
- editToolBar->addAction(pasteAct);
-#endif
// Create status bar
statusBar()->showMessage(tr("Ready"));
Object::SetFixedLength(fixLengthAct->isChecked());
}
+void ApplicationWindow::DeleteTool(void)
+{
+ Object::SetDeleteActive(deleteAct->isChecked());
+}
+
void ApplicationWindow::CreateActions(void)
{
exitAct = CreateAction(tr("&Quit"), tr("Quit"), tr("Exits the application."),
fixLengthAct = CreateAction(tr("Fix &Length"), tr("Fix Length"), tr("Fixes the length of an object."),
QIcon(":/res/fix-length.png"), QKeySequence(tr("F,L")), true);
connect(fixLengthAct, SIGNAL(triggered()), this, SLOT(FixLength()));
+
+ 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/generic-tool.png"), QKeySequence());
+
+ addLineAct = CreateAction(tr("Add &Line"), tr("Add Line"), tr("Adds a line to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence());
+
+ addCircleAct = CreateAction(tr("Add &Circle"), tr("Add Circle"), tr("Adds a circle to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence());
+
+ addArcAct = CreateAction(tr("Add &Arc"), tr("Add Arc"), tr("Adds an arc to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence());
}
//
menu = menuBar()->addMenu(tr("&Edit"));
menu->addAction(fixAngleAct);
menu->addAction(fixLengthAct);
+ menu->addSeparator();
+ menu->addAction(deleteAct);
+ menu->addSeparator();
+ menu->addAction(addLineAct);
+ menu->addAction(addCircleAct);
+ menu->addAction(addArcAct);
+ menu->addAction(addDimensionAct);
+
// editMenu = menuBar()->addMenu(tr("&Edit"));
// editMenu->addAction(cutAct);
// editMenu->addAction(copyAct);
toolbar = addToolBar(tr("Edit"));
toolbar->addAction(fixAngleAct);
toolbar->addAction(fixLengthAct);
+ toolbar->addAction(deleteAct);
+ toolbar->addAction(addLineAct);
+ toolbar->addAction(addCircleAct);
+ toolbar->addAction(addArcAct);
+ toolbar->addAction(addDimensionAct);
}
void ApplicationWindow::ReadSettings(void)
// JLH 03/22/2011 Created this file
// JLH 04/11/2011 Fixed attached dimensions to stay at correct length when
// "Fixed Length" button is down
+// JLH 04/27/2011 Fixed attached dimension to stay a correct length when
+// "Fixed Length" button is *not* down ;-)
//
#include "line.h"
Line::Line(Vector p1, Vector p2, Object * p/*= NULL*/): Object(p1, p), endpoint(p2),
dragging(false), draggingHandle1(false), draggingHandle2(false), //needUpdate(false),
- length(p2.Magnitude())
+ length(Vector::Magnitude(p2, p1))
{
}
if (needUpdate)
{
-// should only do this if "Fixed Length" is set... !!! FIX !!!
+// should only do this if "Fixed Length" is set... !!! FIX !!! [DONE]
Vector point1 = (draggingHandle1 ? endpoint : position);
Vector point2 = (draggingHandle1 ? position : endpoint);
- Vector current(point2 - point1);
+ Vector current(point2, point1);
Vector v = current.Unit() * length;
Vector v2 = point1 + v;
dp2 = n1 . v2 = -by1 * bx2 + bx1 * by2;
ratio = dp1 / dp2;
-crossing vector = v1 * rat;
+crossing vector = v1 * ratio;
And that's it.