- Group selection (kind done, needs more work though)
- Take movement code out of Objects and put it into top level Container (actually
I think this should be more of the state code handling. Have to see.)
- - Add OSD routines so they don't have to be implemented in Objects
- Add OSD to Object creation
- Add layers
- Add blocks
- Add Arc [Shamus 2013-08-14]
- Fix snap to grid to allow picking up of handles when they are not on a grid
point. [Shamus 2013-08-18]
+ - Add OSD routines so they don't have to be implemented in Objects [Shamus
+ 2013-08-24]
#ifndef __ACTION_H__
#define __ACTION_H__
-#include <QtCore>
+#include <QtGui>
#include "vector.h"
class Object;
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;
signals:
void ObjectReady(Object *);
};
#endif // __ACTION_H__
+
{
drawing = new DrawingView(this);
drawing->setMouseTracking(true); // We want *all* mouse events...!
+ drawing->setFocusPolicy(Qt::StrongFocus);
setCentralWidget(drawing);
aboutWin = new AboutWindow(this);
}
}
+
+/*virtual*/ bool DrawArcAction::KeyDown(int /*key*/)
+{
+ return false;
+}
+
+
+/*virtual*/ bool 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);
private:
int state;
};
#endif // __DRAWARCACTION_H__
+
p1 = p2;
}
}
+
+
+/*virtual*/ bool DrawCircleAction::KeyDown(int /*key*/)
+{
+ return false;
+}
+
+
+/*virtual*/ bool 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);
private:
int state;
};
#endif // __DRAWCIRCLEACTION_H__
+
}
}
+
+/*virtual*/ bool DrawDimensionAction::KeyDown(int /*key*/)
+{
+ return false;
+}
+
+
+/*virtual*/ bool 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);
private:
int state;
};
#endif // __DRAWDIMENSIONACTION_H__
+
}
}
+
+void DrawingView::keyPressEvent(QKeyEvent * event)
+{
+ if (toolAction)
+ {
+ bool needUpdate = toolAction->KeyDown(event->key());
+
+ if (needUpdate)
+ update();
+ }
+}
+
+
+void DrawingView::keyReleaseEvent(QKeyEvent * event)
+{
+ if (toolAction)
+ {
+ bool needUpdate = toolAction->KeyReleased(event->key());
+
+ if (needUpdate)
+ update();
+ }
+}
+
void mousePressEvent(QMouseEvent * event);
void mouseMoveEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent * event);
+ void keyPressEvent(QKeyEvent * event);
+ void keyReleaseEvent(QKeyEvent * event);
private:
QPoint GetAdjustedMousePosition(QMouseEvent * event);
//#include "vector.h"
-#define FIRST_POINT 0
-#define NEXT_POINT 1
+//#define FIRST_POINT 0
+//#define NEXT_POINT 1
+enum { FIRST_POINT, NEXT_POINT };
-DrawLineAction::DrawLineAction(): state(0), line(NULL)
+DrawLineAction::DrawLineAction(): state(FIRST_POINT), line(NULL),
+ shiftWasPressedOnNextPoint(false)
{
}
painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
// I think stuff like crosshairs should be done in the DrawingView, tho
+ // (and it's done there now...)
if (state == FIRST_POINT)
{
painter->DrawHandle(p1);
/*virtual*/ void DrawLineAction::MouseDown(Vector point)
{
+ // Clear our override...
+ shiftWasPressedOnNextPoint = false;
+
if (state == FIRST_POINT)
p1 = point;
else
// We don't need no stinkin' sentinels, when we have signals & slots!
emit ObjectReady(line);
-// p1 = p2;
+ p1 = p2;
+ state = NEXT_POINT;
+ }
+}
+
+
+/*virtual*/ bool DrawLineAction::KeyDown(int key)
+{
+ if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
+ {
+ shiftWasPressedOnNextPoint = true;
+ p1Save = p1;
+ p1 = p2;
state = FIRST_POINT;
+ return true;
+ }
+
+ return false;
+}
+
+
+/*virtual*/ bool DrawLineAction::KeyReleased(int key)
+{
+ if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
+ {
+ shiftWasPressedOnNextPoint = false;
+ p2 = p1;
+ p1 = p1Save;
+ state = NEXT_POINT;
+ return true;
}
+
+ return false;
}
virtual void MouseDown(Vector);
virtual void MouseMoved(Vector);
virtual void MouseReleased(void);
+ virtual bool KeyDown(int);
+ virtual bool KeyReleased(int);
private:
int state;
Line * line;
- Vector p1, p2;
+ Vector p1, p2, p1Save;
+ bool shiftWasPressedOnNextPoint;
};
#endif // __DRAWLINEACTION_H__
+
}
}
+
+/*virtual*/ bool DrawTextAction::KeyDown(int /*key*/)
+{
+ return false;
+}
+
+
+/*virtual*/ bool 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);
private:
int state;
};
#endif // __DRAWTEXTACTION_H__
+