src/forms/linerelangleoptions.h \
src/forms/mousewidget.h \
src/forms/moverotateoptions.h \
+ src/forms/polylineoptions.h \
src/forms/printpreviewoptions.h \
src/forms/roundoptions.h \
src/forms/selectionwidget.h \
src/forms/linerelangleoptions.cpp \
src/forms/mousewidget.cpp \
src/forms/moverotateoptions.cpp \
+ src/forms/polylineoptions.cpp \
src/forms/printpreviewoptions.cpp \
src/forms/roundoptions.cpp \
src/forms/selectionwidget.cpp \
+// actiondrawpolyline.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actiondrawpolyline.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionDrawPolyline::ActionDrawPolyline(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+ vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionDrawPolyline::~ActionDrawPolyline()
+{
+ if (polyline)
+ delete polyline;
+}
+
+void ActionDrawPolyline::trigger()
+{
+ if (polyline)
+ {
+ container->addEntity(polyline);
+// deleteSnapper();
+
+ if (document)
+ {
+ document->startUndoCycle();
+ document->addUndoable(polyline);
+ document->endUndoCycle();
+ }
+
+ DEBUG->print("ActionDrawPolyline::trigger(): polyline added: %d", polyline->getId());
+ polyline = NULL;
+ }
+}
+
+void ActionDrawPolyline::mouseMoveEvent(QMouseEvent * e)
+{
+ if (vertex.valid && polyline)
+ {
+ Vector v = snapPoint(e);
+ Entity * ent = polyline->addVertex(v);
+ ent->setLayerToActive();
+ ent->setPenToActive();
+
+// deleteSnapper();
+// graphicView->drawEntity(ent);
+// drawSnapper();
+
+ vertex = v;
+ DEBUG->print("ActionDrawPolyline::mouseMoveEvent(): line added: %d", ent->getId());
+ }
+}
+
+void ActionDrawPolyline::mousePressEvent(QMouseEvent * e)
+{
+ if (e->button() == Qt::LeftButton)
+ {
+ vertex = snapPoint(e);
+ polyline = new Polyline(container, PolylineData(vertex, vertex, 0));
+ polyline->setLayerToActive();
+ polyline->setPenToActive();
+ }
+}
+
+void ActionDrawPolyline::mouseReleaseEvent(QMouseEvent * e)
+{
+ if (e->button() == Qt::LeftButton)
+ {
+ vertex = Vector(false);
+ trigger();
+ }
+ else if (e->button() == Qt::RightButton)
+ {
+ if (polyline)
+ {
+ delete polyline;
+ polyline = NULL;
+ }
+
+// deleteSnapper();
+ init(getStatus() - 1);
+ graphicView->redraw(); //hm.
+ }
+}
+
+void ActionDrawPolyline::updateMouseButtonHints()
+{
+ switch (getStatus())
+ {
+ case 0:
+ DIALOGFACTORY->updateMouseWidget(tr("Click and drag to draw a line"), tr("Cancel"));
+ break;
+
+ default:
+ DIALOGFACTORY->updateMouseWidget("", "");
+ break;
+ }
+}
+
+void ActionDrawPolyline::updateMouseCursor()
+{
+ graphicView->setMouseCursor(RS2::CadCursor);
+}
+
+void ActionDrawPolyline::updateToolBar()
+{
+ if (!isFinished())
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ else
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarPolylines);
+}
+
+void ActionDrawPolyline::close()
+{
+#if 0
+//NOTE: We should grey out the "close" button until the conditions for its use are satisfied.
+// Though I can see how this would be called via cmd line... So I guess it's OK
+ if (history.count() > 2 && start.valid)
+ {
+ data.endpoint = start;
+ trigger();
+ setStatus(SetFirstPoint);
+ graphicView->moveRelativeZero(start);
+ }
+ else
+ DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet."));
+#else
+ DIALOGFACTORY->commandMessage(tr("Close functionality not defined yet..."));
+#endif
+}
+
+void ActionDrawPolyline::undo()
+{
+#if 0
+//NOTE: We should grey out the "undo" button until the conditions for its use are satisfied.
+ if (history.count() > 1)
+ {
+ history.removeLast();
+ graphicView->setCurrentAction(new ActionEditUndo(true, *container, *graphicView));
+ data.startpoint = *history.last();
+ graphicView->moveRelativeZero(data.startpoint);
+ graphicView->preview.clear();
+ graphicView->redraw();
+ }
+ else
+ DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet."));
+#else
+ DIALOGFACTORY->commandMessage(tr("Undo functionality not defined yet..."));
+#endif
+}
class Polyline;
/**
- * This action class can handle user events to draw freehand lines.
+ * This class handles polyline creation.
*
* @author James Hammons
*/
class ActionDrawPolyline: public ActionInterface
{
+ public:
+ /** Action States */
+ enum Status
+ {
+ SetFirstPoint = 0, /**< Setting the first point. */
+ SetNextPoint /**< Setting the next point. */
+ };
+
public:
ActionDrawPolyline(EntityContainer & container, GraphicView & graphicView);
~ActionDrawPolyline();
virtual void updateMouseButtonHints();
virtual void updateMouseCursor();
virtual void updateToolBar();
+ void close();
+ void undo();
protected:
Vector vertex;
Polyline * polyline;
+ /** Start point of the series of lines. Used for close function. */
+ Vector start;
+ /** Point history (for undo) */
+//This probably won't work, because of arc segments...
+ QList<Vector *> history;
};
#endif // __ACTIONDRAWPOLYLINE_H__
+// actionpolylineadd.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actionpolylineadd.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionPolylineAdd::ActionPolylineAdd(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+// vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionPolylineAdd::~ActionPolylineAdd()
+{
+ if (polyline)
+ delete polyline;
+}
+
ActionPolylineAdd(EntityContainer & container, GraphicView & graphicView);
~ActionPolylineAdd();
- virtual void init(int status = 0);
- virtual void trigger();
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void updateMouseCursor();
+// virtual void init(int status = 0);
+// virtual void trigger();
+// virtual void mouseMoveEvent(QMouseEvent * e);
+// virtual void mousePressEvent(QMouseEvent * e);
+// virtual void mouseReleaseEvent(QMouseEvent * e);
+// virtual void updateMouseCursor();
protected:
Polyline * polyline;
+// actionpolylineappend.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actionpolylineappend.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionPolylineAppend::ActionPolylineAppend(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+// vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionPolylineAppend::~ActionPolylineAppend()
+{
+ if (polyline)
+ delete polyline;
+}
+
class Polyline;
/**
- * This action class adds a node to an existing polyline.
+ * This action class appends a node to an existing polyline.
*
* @author James Hammons
*/
ActionPolylineAppend(EntityContainer & container, GraphicView & graphicView);
~ActionPolylineAppend();
- virtual void init(int status = 0);
- virtual void trigger();
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void updateMouseCursor();
+// virtual void init(int status = 0);
+// virtual void trigger();
+// virtual void mouseMoveEvent(QMouseEvent * e);
+// virtual void mousePressEvent(QMouseEvent * e);
+// virtual void mouseReleaseEvent(QMouseEvent * e);
+// virtual void updateMouseCursor();
protected:
Polyline * polyline;
+// actionpolylinedel.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actionpolylinedel.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionPolylineDel::ActionPolylineDel(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+// vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionPolylineDel::~ActionPolylineDel()
+{
+ if (polyline)
+ delete polyline;
+}
+
class Polyline;
/**
- * This action class adds a node to an existing polyline.
+ * This action class deletes a node from an existing polyline.
*
* @author James Hammons
*/
ActionPolylineDel(EntityContainer & container, GraphicView & graphicView);
~ActionPolylineDel();
- virtual void init(int status = 0);
- virtual void trigger();
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void updateMouseCursor();
+// virtual void init(int status = 0);
+// virtual void trigger();
+// virtual void mouseMoveEvent(QMouseEvent * e);
+// virtual void mousePressEvent(QMouseEvent * e);
+// virtual void mouseReleaseEvent(QMouseEvent * e);
+// virtual void updateMouseCursor();
protected:
Polyline * polyline;
+// actionpolylinedelbetween.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actionpolylinedelbetween.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionPolylineDelBetween::ActionPolylineDelBetween(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+// vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionPolylineDelBetween::~ActionPolylineDelBetween()
+{
+ if (polyline)
+ delete polyline;
+}
+
class Polyline;
/**
- * This action class adds a node to an existing polyline.
+ * This action class deletes multiple nodes from an existing polyline.
*
* @author James Hammons
*/
ActionPolylineDelBetween(EntityContainer & container, GraphicView & graphicView);
~ActionPolylineDelBetween();
- virtual void init(int status = 0);
- virtual void trigger();
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void updateMouseCursor();
+// virtual void init(int status = 0);
+// virtual void trigger();
+// virtual void mouseMoveEvent(QMouseEvent * e);
+// virtual void mousePressEvent(QMouseEvent * e);
+// virtual void mouseReleaseEvent(QMouseEvent * e);
+// virtual void updateMouseCursor();
protected:
Polyline * polyline;
+// actionpolylinetrim.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+#include "actionpolylinetrim.h"
+
+#include "debug.h"
+#include "dialogfactory.h"
+#include "graphicview.h"
+#include "polyline.h"
+
+ActionPolylineTrim::ActionPolylineTrim(EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw polyline", container, graphicView)
+{
+// vertex = Vector(false);
+ polyline = NULL;
+}
+
+ActionPolylineTrim::~ActionPolylineTrim()
+{
+ if (polyline)
+ delete polyline;
+}
+
class Polyline;
/**
- * This action class adds a node to an existing polyline.
+ * This action class trims nodes on an existing polyline.
*
* @author James Hammons
*/
ActionPolylineTrim(EntityContainer & container, GraphicView & graphicView);
~ActionPolylineTrim();
- virtual void init(int status = 0);
- virtual void trigger();
- virtual void mouseMoveEvent(QMouseEvent * e);
- virtual void mousePressEvent(QMouseEvent * e);
- virtual void mouseReleaseEvent(QMouseEvent * e);
- virtual void updateMouseCursor();
+// virtual void init(int status = 0);
+// virtual void trigger();
+// virtual void mouseMoveEvent(QMouseEvent * e);
+// virtual void mousePressEvent(QMouseEvent * e);
+// virtual void mouseReleaseEvent(QMouseEvent * e);
+// virtual void updateMouseCursor();
protected:
Polyline * polyline;
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>LineOptions</class>
- <widget class="QWidget" name="LineOptions">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>200</width>
- <height>22</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>22</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>280</width>
- <height>22</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>Line Options</string>
- </property>
- <layout class="QHBoxLayout">
- <property name="margin">
- <number>1</number>
- </property>
- <item>
- <widget class="QToolButton" name="bClose">
- <property name="text">
- <string>Close</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="bUndo">
- <property name="text">
- <string>Undo</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Line" name="sep1">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="frameShape">
- <enum>QFrame::VLine</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections>
- <connection>
- <sender>bClose</sender>
- <signal>clicked()</signal>
- <receiver>LineOptions</receiver>
- <slot>close()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>bUndo</sender>
- <signal>clicked()</signal>
- <receiver>LineOptions</receiver>
- <slot>undo()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>20</x>
- <y>20</y>
- </hint>
- <hint type="destinationlabel">
- <x>20</x>
- <y>20</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
--- /dev/null
+// polylineoptions.cpp
+//
+// Part of the Architektonas Project
+// by James L. Hammons
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -----------------------------------------------------------
+// JLH 09/13/2010 Created this file. :-)
+//
+
+// NOTE: Still need to add "Arc" checkbox and "Radius" textedit
+#warning "!!! Still need to add 'Arc' checkbox and 'Radius' textedit !!!"
+
+#include "polylineoptions.h"
+
+#include "enums.h"
+#include "actiondrawpolyline.h"
+#include "actioninterface.h"
+#include "debug.h"
+
+PolylineOptions::PolylineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+ QWidget(parent, flags), action(NULL),
+ bClose(new QToolButton(this)),
+ bUndo(new QToolButton(this))
+{
+ QHBoxLayout * layout = new QHBoxLayout(this);
+ layout->setContentsMargins(0, 0, 0, 0);
+
+ bClose->setText(tr("Close"));
+ bUndo->setText(tr("Undo"));
+
+ layout->addWidget(bClose);
+ layout->addWidget(bUndo);
+
+ connect(bClose, SIGNAL(clicked()), this, SLOT(close()));
+ connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
+
+ // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
+ // nothing will show up on the screen. :-)
+ if (parent)
+ parent->addWidget(this);
+}
+
+PolylineOptions::~PolylineOptions()
+{
+}
+
+void PolylineOptions::setAction(ActionInterface * a, bool & /*unknown*/)
+{
+ if (a && a->rtti() == RS2::ActionDrawPolyline)
+ {
+ action = (ActionDrawPolyline *)a;
+ }
+ else
+ {
+ DEBUG->print(Debug::D_ERROR, "PolylineOptions::setAction: wrong action type");
+ action = NULL;
+ }
+}
+
+void PolylineOptions::close()
+{
+ if (action)
+ action->close();
+}
+
+void PolylineOptions::undo()
+{
+ if (action)
+ action->undo();
+}
--- /dev/null
+#ifndef __POLYLINEOPTIONS_H__
+#define __POLYLINEOPTIONS_H__
+
+#include <QtGui>
+
+class ActionDrawPolyline;
+class ActionInterface;
+
+class PolylineOptions: public QWidget
+{
+ Q_OBJECT
+
+ public:
+ PolylineOptions(QToolBar * parent = 0, Qt::WindowFlags flags = 0);
+ ~PolylineOptions();
+
+ public slots:
+ void setAction(ActionInterface * a, bool &);
+ void close();
+ void undo();
+
+ protected:
+ ActionDrawPolyline * action;
+
+ private:
+ QToolButton * bClose;
+ QToolButton * bUndo;
+};
+
+#endif // __POLYLINEOPTIONS_H__
#include "linerelangleoptions.h"
#include "mousewidget.h"
#include "moverotateoptions.h"
+#include "polylineoptions.h"
#include "printpreviewoptions.h"
#include "roundoptions.h"
#include "selectionwidget.h"
#include "textoptions.h"
#include "trimamountoptions.h"
-#ifdef RS_PROF
-#include "qg_polylineoptions.h"
-#endif
-
#ifdef RS_CAM
#include "camdialog.h"
#endif
*/
void QG_DialogFactory::requestPolylineOptions(ActionInterface * action, bool on, bool update)
{
-#ifdef RS_PROF
static PolylineOptions * toolWidget = NULL;
if (!optionWidget)
toolWidget = new PolylineOptions(optionWidget);
toolWidget->setAction(action, update);
}
-#endif
}
/**