- Add fill/hatch to Objects
- Fix zooming to be more intuitive
- Add other Dimension types, like radial, diametric, leader
- - Mirror tool (started, needs actual mirroring implementation)
- Restrict movement horizontal/vertical tool
- - Trim tool
- Fix Arc manipulator. Idea: split edge handles so that the inner half controls
arc sizing, outer half controls rotation. That way you can grab either handle
and know what it's supposed to do.
- Fix loading and saving code
- Add Drawing Properties dialog (separate from Application Settings)
+ - Trim tool
- Trim/Slice tool (to be able to click on a line segment crossing another, and
remove it and it only, or to cut the entity at other entities crossing)
+ - Make Architektonas an MDI application
Stuff That's Done
point. [Shamus 2013-08-18]
- Add OSD routines so they don't have to be implemented in Objects [Shamus
2013-08-24]
+ - Mirror tool (started, needs actual mirroring implementation) (Rotate tool is
+ also done :-D) [Shamus 2013-09-01]
virtual void MouseDown(Vector) = 0;
virtual void MouseMoved(Vector) = 0;
virtual void MouseReleased(void) = 0;
- virtual bool KeyDown(int) = 0;
- virtual bool KeyReleased(int) = 0;
+ virtual void KeyDown(int) = 0;
+ virtual void KeyReleased(int) = 0;
signals:
void ObjectReady(Object *);
+ void NeedRefresh(void);
};
#endif // __ACTION_H__
return;
// Shuffle the contents of this container to the new one
-// for(unsigned int i=0; i<objects.size(); i++)
for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
{
newContainer->Add(*i);
}
+void Container::CopyContentsTo(Container * newContainer)
+{
+ // Sanity check
+ if (newContainer == NULL)
+ return;
+
+ // Shuffle the contents of this container to the new one
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+ newContainer->Add((*i)->Copy());
+}
+
+
void Container::MoveSelectedContentsTo(Container * newContainer)
{
// Sanity check
}
+/*virtual*/ void Container::Rotate(Point point, double angle)
+{
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+ (*i)->Rotate(point, angle);
+}
+
+
+/*virtual*/ void Container::RotateSelected(Point point, double angle)
+{
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+ {
+ if ((*i)->state == OSSelected)
+ (*i)->Rotate(point, angle);
+ }
+}
+
+
/*virtual*/ void Container::Mirror(Point p1, Point p2)
{
for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
}
+/*virtual*/ void Container::MirrorSelected(Point p1, Point p2)
+{
+ for(std::vector<Object *>::iterator i=objects.begin(); i!=objects.end(); i++)
+ {
+ if ((*i)->state == OSSelected)
+ (*i)->Mirror(p1, p2);
+ }
+}
+
+
/*virtual*/ void Container::Save(void)
{
Object::Save();
virtual QRectF Extents(void);
virtual void Enumerate(FILE *);
virtual Object * Copy(void);
+ virtual void Rotate(Point, double);
+ virtual void RotateSelected(Point, double);
virtual void Mirror(Point, Point);
+ virtual void MirrorSelected(Point, Point);
virtual void Save(void);
virtual void Restore(void);
void Delete(Object *);
int ItemsSelected(void);
Object * SelectedItem(unsigned int);
void MoveContentsTo(Container *);
+ void CopyContentsTo(Container *);
void MoveSelectedContentsTo(Container *);
void CopySelectedContentsTo(Container *);
void ResizeAllDimensions(double);
#include "arc.h"
#include "mathconstants.h"
#include "painter.h"
-//#include "vector.h"
enum { FIRST_POINT, SECOND_POINT, THIRD_POINT };
}
-/*virtual*/ bool DrawArcAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawArcAction::KeyDown(int /*key*/)
{
- return false;
}
-/*virtual*/ bool DrawArcAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawArcAction::KeyReleased(int /*key*/)
{
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
#include "vector.h"
-#define FIRST_POINT 0
-#define NEXT_POINT 1
+enum { FIRST_POINT, NEXT_POINT };
DrawCircleAction::DrawCircleAction(): state(0), circle(NULL)
}
-/*virtual*/ bool DrawCircleAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawCircleAction::KeyDown(int /*key*/)
{
- return false;
}
-/*virtual*/ bool DrawCircleAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawCircleAction::KeyReleased(int /*key*/)
{
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
#include "drawdimensionaction.h"
#include "dimension.h"
#include "painter.h"
-//#include "vector.h"
-#define FIRST_POINT 0
-#define NEXT_POINT 1
+enum { FIRST_POINT, NEXT_POINT };
DrawDimensionAction::DrawDimensionAction(): state(0), dimension(NULL)
{
// We create the new object here, and then pass it off to the
// DrawingView which stuffs it into the document.
-// line = new Line(p1, p2);
dimension = new Dimension(p1, p2);
// We don't need no stinkin' sentinels, when we have signals & slots!
emit ObjectReady(dimension);
state = FIRST_POINT;
-// p1 = p2;
}
}
-/*virtual*/ bool DrawDimensionAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawDimensionAction::KeyDown(int /*key*/)
{
- return false;
}
-/*virtual*/ bool DrawDimensionAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawDimensionAction::KeyReleased(int /*key*/)
{
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
#define BACKGROUND_MAX_SIZE 512
+// Class variable
+//Container DrawingView::document(Vector(0, 0));
+
DrawingView::DrawingView(QWidget * parent/*= NULL*/): QWidget(parent),
// The value in the settings file will override this.
toolAction = action;
connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
SLOT(AddNewObjectToDocument(Object *)));
+ connect(toolAction, SIGNAL(NeedRefresh()), this, SLOT(HandleActionUpdate()));
}
}
}
+void DrawingView::HandleActionUpdate(void)
+{
+ update();
+}
+
+
void DrawingView::SetCurrentLayer(int layer)
{
Object::currentLayer = layer;
{
if (toolAction)
{
- bool needUpdate = toolAction->KeyDown(event->key());
+ /*bool needUpdate =*/ toolAction->KeyDown(event->key());
- if (needUpdate)
- update();
+// if (needUpdate)
+// update();
}
}
{
if (toolAction)
{
- bool needUpdate = toolAction->KeyReleased(event->key());
+ /*bool needUpdate =*/ toolAction->KeyReleased(event->key());
- if (needUpdate)
- update();
+// if (needUpdate)
+// update();
}
}
public slots:
void AddNewObjectToDocument(Object *);
+ void HandleActionUpdate(void);
void SetCurrentLayer(int);
protected:
public:
Action * toolAction;
+
+// public:
+// static Container document;
};
#endif // __DRAWINGVIEW_H__
+
#include "drawlineaction.h"
#include "line.h"
#include "painter.h"
-//#include "vector.h"
-//#define FIRST_POINT 0
-//#define NEXT_POINT 1
enum { FIRST_POINT, NEXT_POINT };
}
-/*virtual*/ bool DrawLineAction::KeyDown(int key)
+/*virtual*/ void DrawLineAction::KeyDown(int key)
{
if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
{
p1Save = p1;
p1 = p2;
state = FIRST_POINT;
- return true;
+ emit(NeedRefresh());
}
-
- return false;
}
-/*virtual*/ bool DrawLineAction::KeyReleased(int key)
+/*virtual*/ void DrawLineAction::KeyReleased(int key)
{
if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
{
p2 = p1;
p1 = p1Save;
state = NEXT_POINT;
- return true;
+ emit(NeedRefresh());
}
-
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
}
-/*virtual*/ bool DrawTextAction::KeyDown(int /*key*/)
+/*virtual*/ void DrawTextAction::KeyDown(int /*key*/)
{
- return false;
}
-/*virtual*/ bool DrawTextAction::KeyReleased(int /*key*/)
+/*virtual*/ void DrawTextAction::KeyReleased(int /*key*/)
{
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
MirrorAction::MirrorAction(): state(FIRST_POINT), line(NULL),
- shiftWasPressedOnNextPoint(false), mirror(new Container(Vector()))
+ shiftWasPressedOnNextPoint(false), ctrlWasPressed(false),
+ mirror(new Container(Vector()))
{
-// ApplicationWindow::drawing->document.CopySelectedContentsTo(selected);
ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
-
-// for(std::vector<Object *>::iterator i=mirror->objects.begin(); i!=mirror->objects.end(); i++)
-// (*i)->Save();
mirror->Save();
}
QString text = QChar(0x2221) + QObject::tr(": %1");
text = text.arg(absAngle);
-// QString text = tr("Length: %1 in.");
-// text = text.arg(Vector::Magnitude(p1, p2));
+
+ if (ctrlWasPressed)
+ text += " (Copy)";
+
painter->DrawInformativeText(text);
// Draw the mirror only if there's been a line to mirror around
else
{
p2 = point;
-
- for(std::vector<Object *>::iterator i=mirror->objects.begin(); i!=mirror->objects.end(); i++)
- {
- (*i)->Restore();
- (*i)->Mirror(p1, p2);
- }
+ mirror->Restore();
+ mirror->Mirror(p1, p2);
}
}
}
else if (state == NEXT_POINT)
{
- state = FIRST_POINT;
-
- std::vector<Object *> & objs = ApplicationWindow::drawing->document.objects;
+ if (!ctrlWasPressed)
+ {
+ state = FIRST_POINT;
+ ApplicationWindow::drawing->document.MirrorSelected(p1, p2);
- for(std::vector<Object *>::iterator i=objs.begin(); i!=objs.end(); i++)
+ mirror->Clear();
+ ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
+ mirror->Save();
+ }
+ else
{
- if ((*i)->state == OSSelected)
- (*i)->Mirror(p1, p2);
+ mirror->CopyContentsTo(&(ApplicationWindow::drawing->document));
+// mirror->CopyContentsTo(&(DrawingView.document));
}
-
- mirror->Clear();
- ApplicationWindow::drawing->document.CopySelectedContentsTo(mirror);
- mirror->Save();
}
}
-/*virtual*/ bool MirrorAction::KeyDown(int key)
+/*virtual*/ void MirrorAction::KeyDown(int key)
{
if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
{
p1Save = p1;
p1 = p2;
state = FIRST_POINT;
- return true;
+ emit(NeedRefresh());
+ }
+ else if (key == Qt::Key_Control)
+ {
+ ctrlWasPressed = true;
+ emit(NeedRefresh());
}
-
- return false;
}
-/*virtual*/ bool MirrorAction::KeyReleased(int key)
+/*virtual*/ void MirrorAction::KeyReleased(int key)
{
if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
{
p2 = p1;
p1 = p1Save;
state = NEXT_POINT;
- return true;
+ emit(NeedRefresh());
+ }
+ else if (key == Qt::Key_Control)
+ {
+ ctrlWasPressed = false;
+ emit(NeedRefresh());
}
-
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
Line * line;
Vector p1, p2, p1Save;
bool shiftWasPressedOnNextPoint;
-// Container * selected;
+ bool ctrlWasPressed;
Container * mirror;
};
#include "line.h"
#include "mathconstants.h"
#include "painter.h"
-//#include "vector.h"
-//#define FIRST_POINT 0
-//#define NEXT_POINT 1
enum { FIRST_POINT, NEXT_POINT };
RotateAction::RotateAction(): state(FIRST_POINT), line(NULL),
- shiftWasPressedOnNextPoint(false), spin(new Container(Vector()))
+ shiftWasPressedOnNextPoint(false), ctrlWasPressed(false),
+ spin(new Container(Vector()))
{
-// ApplicationWindow::drawing->document.CopySelectedContentsTo(selected);
ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
-
-// for(std::vector<Object *>::iterator i=spin->objects.begin(); i!=spin->objects.end(); i++)
-// (*i)->Save();
spin->Save();
}
}
else
{
-// Vector reflectedP2 = -(p2 - p1);
-// Point newP2 = p1 + reflectedP2;
- painter->DrawLine(p1, p2);
painter->DrawHandle(p1);
- double absAngle = (Vector(p2 - p1).Angle()) * RADIANS_TO_DEGREES;
+ // Draw the rotated objects only if there's been a line to spin around
+ if (p1 == p2)
+ return;
- // Keep the angle between 0 and 180 degrees
-// if (absAngle > 180.0)
-// absAngle -= 180.0;
+ painter->DrawLine(p1, p2);
+
+ double absAngle = (Vector(p2 - p1).Angle()) * RADIANS_TO_DEGREES;
QString text = QChar(0x2221) + QObject::tr(": %1");
text = text.arg(absAngle);
-// QString text = tr("Length: %1 in.");
-// text = text.arg(Vector::Magnitude(p1, p2));
+
+ if (ctrlWasPressed)
+ text += " (Copy)";
+
painter->DrawInformativeText(text);
- // Draw the rotated objects only if there's been a line to spin around
- if (p1 != p2)
- spin->Draw(painter);
+// this does nothing, because the objects override any color set here with
+// their own pens... :-/
+// Which means we have to have a flag in the object to tell it not to color itself.
+// if (ctrlWasPressed)
+// painter->SetPen(QPen(Qt::green, 3.0, Qt::SolidLine));
+
+ spin->Draw(painter);
}
}
{
p2 = point;
double angle = Vector(p2, p1).Angle();
-
- for(std::vector<Object *>::iterator i=spin->objects.begin(); i!=spin->objects.end(); i++)
- {
- (*i)->Restore();
- (*i)->Rotate(p1, angle);
- }
+ spin->Restore();
+ spin->Rotate(p1, angle);
}
}
}
else if (state == NEXT_POINT)
{
- state = FIRST_POINT;
-
- std::vector<Object *> & objs = ApplicationWindow::drawing->document.objects;
- double angle = Vector(p2, p1).Angle();
+ if (!ctrlWasPressed)
+ {
+ state = FIRST_POINT;
+ double angle = Vector(p2, p1).Angle();
+ ApplicationWindow::drawing->document.RotateSelected(p1, angle);
- for(std::vector<Object *>::iterator i=objs.begin(); i!=objs.end(); i++)
+ spin->Clear();
+ ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
+ spin->Save();
+ }
+ else
{
- if ((*i)->state == OSSelected)
- (*i)->Rotate(p1, angle);
+ spin->CopyContentsTo(&(ApplicationWindow::drawing->document));
}
-
- spin->Clear();
- ApplicationWindow::drawing->document.CopySelectedContentsTo(spin);
- spin->Save();
}
}
-/*virtual*/ bool RotateAction::KeyDown(int key)
+/*virtual*/ void RotateAction::KeyDown(int key)
{
if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
{
p1Save = p1;
p1 = p2;
state = FIRST_POINT;
- return true;
+ emit(NeedRefresh());
+ }
+ else if (key == Qt::Key_Control)
+ {
+ ctrlWasPressed = true;
+ emit(NeedRefresh());
}
-
- return false;
}
-/*virtual*/ bool RotateAction::KeyReleased(int key)
+/*virtual*/ void RotateAction::KeyReleased(int key)
{
if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
{
p2 = p1;
p1 = p1Save;
state = NEXT_POINT;
- return true;
+ emit(NeedRefresh());
+ }
+ else if (key == Qt::Key_Control)
+ {
+ ctrlWasPressed = false;
+ emit(NeedRefresh());
}
-
- return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
- virtual bool KeyDown(int);
- virtual bool KeyReleased(int);
+ virtual void KeyDown(int);
+ virtual void KeyReleased(int);
private:
int state;
Line * line;
Point p1, p2, p1Save;
bool shiftWasPressedOnNextPoint;
+ bool ctrlWasPressed;
// Container * selected;
Container * spin;
};