"<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' width='100'><b>Architektonas: </b></td><td>Free, <i>Industrial Strength</i> 2D Computer Aided Design</td></tr>"
+ "<tr><td align='right' width='110'><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>Chief Architect: </b></td><td>James Hammons (shamus)</td></tr>"
CreateToolbars();
// Create status bar
- zoomIndicator = new QLabel("Zoom: 12.5%");
+ zoomIndicator = new QLabel("Grid: 12.0\" Zoom: 12.5%");
statusBar()->addPermanentWidget(zoomIndicator);
statusBar()->showMessage(tr("Ready"));
//printf("Zoom in... level going from %02f to ", Painter::zoom);
// This just zooms leaving origin intact... should zoom in at the current center! [DONE]
Painter::zoom *= zoomFactor;
- zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM));
+ drawing->gridSpacing = 12.0 / Painter::zoom;
+ zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing));
drawing->UpdateGridBackground();
drawing->update();
}
//printf("Zoom out...\n");
// This just zooms leaving origin intact... should zoom out at the current center! [DONE]
Painter::zoom /= zoomFactor;
- zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM));
+ drawing->gridSpacing = 12.0 / Painter::zoom;
+ zoomIndicator->setText(QString("Grid: %2\" Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM).arg(drawing->gridSpacing));
drawing->UpdateGridBackground();
drawing->update();
}
QIcon(":/res/quit.png"), QKeySequence(tr("Ctrl+q")));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
- snapToGridAct = CreateAction(tr("&Snap To Grid"), tr("Snap To Grid"), tr("Snaps mouse cursor to the visible grid when moving/creating objects."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("S,G")), true);
+ snapToGridAct = CreateAction(tr("Snap To &Grid"), tr("Snap To Grid"), tr("Snaps mouse cursor to the visible grid when moving/creating objects."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("S")), true);
connect(snapToGridAct, SIGNAL(triggered()), this, SLOT(SnapToGridTool()));
fixAngleAct = CreateAction(tr("Fix &Angle"), tr("Fix Angle"), tr("Fixes the angle of an object."),
#include "container.h"
#include <QtGui>
+#include "dimension.h"
Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
{
if (objects[i]->Collided(point))
{
+Dimension * dimension = objects[i]->GetAttachedDimension();
+
objects.erase(objects.begin() + i); // Calls the destructor, (deletes the object, I presume... O_o)
+
+// If this object had an attached dimension, reattach it to another object, if any...
+// The only problem with that approach is if the object it gets attached to is deleted,
+// it will call the dimension to use a NULL pointer and BLAMMO
+if (dimension)
+{
+ Vector p1 = dimension->GetPoint1();
+ Vector p2 = dimension->GetPoint2();
+ for(int j=0; j<(int)objects.size(); j++)
+ {
+ Vector * objectP1 = objects[i]->GetPointAt(p1);
+ Vector * objectP2 = objects[i]->GetPointAt(p2);
+
+ if (objectP1)
+ dimension->SetPoint1(objectP1);
+
+ if (objectP2)
+ dimension->SetPoint2(objectP2);
+ }
+}
+
+ // This only allows deleting objects one at a time...
break;
+ // however, this way of doing things could be problematic if we don't
+ // delete one at a time... Need to come up with a better approach.
}
}
}
needUpdate = true;
}
+Vector Dimension::GetPoint1(void)
+{
+ return position;
+}
+
+Vector Dimension::GetPoint2(void)
+{
+ return endpoint;
+}
+
void Dimension::FlipSides(void)
{
#if 0
#endif
needUpdate = true;
}
+
virtual void PointerReleased(void);
void SetPoint1(Vector *);
void SetPoint2(Vector *);
+ Vector GetPoint1(void);
+ Vector GetPoint2(void);
void FlipSides(void);
protected:
gridBackground(256, 256),
scale(1.0), offsetX(-10), offsetY(-10),
document(Vector(0, 0)),
- gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
+// gridSpacing(32.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
+ gridSpacing(12.0), collided(false), rotateTool(false), rx(150.0), ry(150.0),
scrollDrag(false), addLineTool(false), toolAction(NULL)
{
setBackgroundRole(QPalette::Base);
pmp.fillRect(192, 128, 64, 64, Qt::darkGray);
#else
pmp.fillRect(0, 0, 256, 256, QColor(240, 240, 240));
- pmp.setPen(QPen(QColor(190, 190, 255), 2.0, Qt::SolidLine));
+ pmp.setPen(QPen(QColor(210, 210, 255), 2.0, Qt::SolidLine));
for(int i=0; i<255; i+=12)
pmp.drawLine(i, 0, i, 255);
for(int i=0; i<255; i+=12)
Vector pixmapOrigin = Painter::CartesianToQtCoords(Vector());
int x = (int)pixmapOrigin.x;
int y = (int)pixmapOrigin.y;
+ // Use mod arithmetic to grab the correct swatch of background
// Problem with mod 128: Negative numbers screw it up... [FIXED]
x = (x < 0 ? 0 : BG_BRUSH_SPAN - 1) - (x % BG_BRUSH_SPAN);
y = (y < 0 ? 0 : BG_BRUSH_SPAN - 1) - (y % BG_BRUSH_SPAN);
painter.drawLine(-16384, (int)y, 16384, (int)y);
#endif
- painter.SetPen(QPen(Qt::black, 1.0, Qt::SolidLine));
-
- for(double x=0; x<size().width(); x+=gridSpacing)
- for(double y=0; y<size().height(); y+=gridSpacing)
- painter.DrawPoint((int)x, (int)y);
+// painter.SetPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+//
+// for(double x=0; x<size().width(); x+=gridSpacing)
+// for(double y=0; y<size().height(); y+=gridSpacing)
+// painter.DrawPoint((int)x, (int)y);
// The top level document takes care of rendering for us...
document.Draw(&painter);
{
point += gridSpacing / 2.0; // *This* adds to Z!!!
point /= gridSpacing;
+//200% is ok, gridSpacing = 6 in this case...
+//won't run into problems until gridSpacing = 1.5 (zoom = 800%)
+//run into problems with this approach: when zoom level is 200% this truncates to
+//integers, which is *not* what's wanted here...
point.x = floor(point.x);//need to fix this for negative numbers...
point.y = floor(point.y);
point.z = 0; // Make *sure* Z doesn't go anywhere!!!
double scale; // Window scaling factor
int32_t offsetX, offsetY; // Window offsets
Container document;
+ public:
double gridSpacing;
+ private:
bool collided;
//Should this go into Object's class variables???
bool rotateTool;
state = oldState;
}
+// Check to see if the point passed in coincides with any we have. If so, return a
+// pointer to it; otherwise, return NULL.
+/*virtual*/ Vector * Line::GetPointAt(Vector v)
+{
+ if (v == position)
+ return &position;
+ else if (v == endpoint)
+ return &endpoint;
+
+ return 0;
+}
+
#if 0
void Line::SetDimensionOnPoint1(Dimension * dimension)
{
virtual bool Collided(Vector);
virtual void PointerMoved(Vector);
virtual void PointerReleased(void);
+ virtual Vector * GetPointAt(Vector);
// void SetDimensionOnPoint1(Dimension *);
// void SetDimensionOnPoint2(Dimension *);
void SetDimensionOnLine(Dimension * d = 0);
// Main app constructor--we stick globally accessible stuff here...
-Architektonas::Architektonas(int argc, char * argv[]): QApplication(argc, argv)//, charWnd(NULL)
+Architektonas::Architektonas(int & argc, char * argv[]): QApplication(argc, argv)//, charWnd(NULL)
{
mainWindow = new ApplicationWindow;
mainWindow->show();
class Architektonas: public QApplication
{
public:
- Architektonas(int argc, char * argv[]);
+ Architektonas(int & argc, char * argv[]);
public:
// CharWindow * charWnd;
{
}
+// This returns a pointer to the point passed in, if it coincides. Otherwise returns NULL.
+/*virtual*/ Vector * Object::GetPointAt(Vector)
+{
+ return 0;
+}
+
ObjectState Object::GetState(void)
{
return state;
parent = newParent;
}
+Dimension * Object::GetAttachedDimension(void)
+{
+ return attachedDimension;
+}
+
// Class methods...
void Object::SetFixedAngle(bool state/*= true*/)
virtual void Transmute(Object *, Object *);
virtual Object * GetParent(void);
virtual void Add(Object *);
+ virtual Vector * GetPointAt(Vector);
ObjectState GetState(void);
void Reparent(Object *);
+ Dimension * GetAttachedDimension(void);
//Hm. Object * Connect(Object *);
// Class methods
return *this;\r
}\r
\r
+// Check for equality\r
+bool Vector::operator==(Vector const v)\r
+{\r
+ return (x == v.x && y == v.y && z == v.z ? true : false);\r
+}\r
+\r
+// Check for inequality\r
+bool Vector::operator!=(Vector const v)\r
+{\r
+ return (x != v.x || y != v.y || z != v.z ? true : false);\r
+}\r
\r
Vector Vector::Unit(void)\r
{\r
Vector& operator-=(Vector const v); // Vector minus Vector self-assignment\r
Vector& operator-=(double const v); // Vector minus constant self-assignment\r
\r
+ bool operator==(Vector const v); // Check for equality\r
+ bool operator!=(Vector const v); // Check for inequality\r
+\r
Vector Unit(void);\r
double Magnitude(void);\r
double Angle(void);\r