]> Shamusworld >> Repos - architektonas/commitdiff
Phase two of adding polyline functionality...
authorShamus Hammons <jlhamm@acm.org>
Tue, 14 Sep 2010 03:49:57 +0000 (03:49 +0000)
committerShamus Hammons <jlhamm@acm.org>
Tue, 14 Sep 2010 03:49:57 +0000 (03:49 +0000)
17 files changed:
architektonas.pro
src/actions/actiondrawpolyline.cpp
src/actions/actiondrawpolyline.h
src/actions/actionpolylineadd.cpp
src/actions/actionpolylineadd.h
src/actions/actionpolylineappend.cpp
src/actions/actionpolylineappend.h
src/actions/actionpolylinedel.cpp
src/actions/actionpolylinedel.h
src/actions/actionpolylinedelbetween.cpp
src/actions/actionpolylinedelbetween.h
src/actions/actionpolylinetrim.cpp
src/actions/actionpolylinetrim.h
src/forms/lineoptions.ui [deleted file]
src/forms/polylineoptions.cpp [new file with mode: 0644]
src/forms/polylineoptions.h [new file with mode: 0644]
src/widgets/qg_dialogfactory.cpp

index 1c0c8a50270f3f4196cded9a60fa154e913a1a5f..417a853fe1de7483916eb0095fe57a2621e80590 100644 (file)
@@ -475,6 +475,7 @@ HEADERS += \
        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 \
@@ -563,6 +564,7 @@ SOURCES += \
        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 \
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f4f81a4c3bebb7d5b2bb7902e3e78abb8648307e 100644 (file)
@@ -0,0 +1,169 @@
+// 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
+}
index 5ed5a1ae07ea0348762ab383f35d6c9d006ad8dc..6902f40d3d29fdcd6ff8abd16175044e77e7433c 100644 (file)
@@ -7,12 +7,20 @@
 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();
@@ -24,10 +32,17 @@ class ActionDrawPolyline: public ActionInterface
                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__
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6188943feea8fdfc4837aefe7eb6ec043e622f51 100644 (file)
@@ -0,0 +1,35 @@
+// 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;
+}
+
index f07be9191b9e4a902e00b0f90285b5fe527fd7f0..630be491c63ba8fb4c7383e8d7acf0a068031487 100644 (file)
@@ -16,12 +16,12 @@ class ActionPolylineAdd: public ActionInterface
                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;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8a936f8ea965de9a8b04850f2acdc34b2debe81f 100644 (file)
@@ -0,0 +1,35 @@
+// 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;
+}
+
index 01e5d2829c04ab60a70ed3dec33f9cf56181fc8e..0921402c755028c507429641269ef0407a3753e8 100644 (file)
@@ -6,7 +6,7 @@
 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
  */
@@ -16,12 +16,12 @@ class ActionPolylineAppend: public ActionInterface
                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;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..078e57b5d8778fc8d68c1b7bb83a0e9dcc5cbac3 100644 (file)
@@ -0,0 +1,35 @@
+// 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;
+}
+
index 46f021b0f92409613cbaccd42af210211808cc4d..3c7d78d4182f97c6402407fa02329ab35889dec8 100644 (file)
@@ -6,7 +6,7 @@
 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
  */
@@ -16,12 +16,12 @@ class ActionPolylineDel: public ActionInterface
                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;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..09b096ae8415a6e06dd289f3d4e93a82482694ec 100644 (file)
@@ -0,0 +1,35 @@
+// 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;
+}
+
index 63d240e1dd912a95e5c0229dcf7bd6558570b82c..dd8f7ae77bfa123ee3092a24d2e1dd0c38bb0d7e 100644 (file)
@@ -6,7 +6,7 @@
 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
  */
@@ -16,12 +16,12 @@ class ActionPolylineDelBetween: public ActionInterface
                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;
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ea12e6fd9156489aed1d0b45d167467776d60b35 100644 (file)
@@ -0,0 +1,35 @@
+// 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;
+}
+
index a07acbcb688a2b4734209f880bb546f9449c0afe..b1d82c1a7ed77993c498f46228af319fb06b1dea 100644 (file)
@@ -6,7 +6,7 @@
 class Polyline;
 
 /**
- * This action class adds a node to an existing polyline.
+ * This action class trims nodes on an existing polyline.
  *
  * @author James Hammons
  */
@@ -16,12 +16,12 @@ class ActionPolylineTrim: public ActionInterface
                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;
diff --git a/src/forms/lineoptions.ui b/src/forms/lineoptions.ui
deleted file mode 100644 (file)
index 0883619..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?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>
diff --git a/src/forms/polylineoptions.cpp b/src/forms/polylineoptions.cpp
new file mode 100644 (file)
index 0000000..5c185ae
--- /dev/null
@@ -0,0 +1,75 @@
+// 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();
+}
diff --git a/src/forms/polylineoptions.h b/src/forms/polylineoptions.h
new file mode 100644 (file)
index 0000000..ba224cf
--- /dev/null
@@ -0,0 +1,30 @@
+#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__
index d0944b0e1875c2680df759129daa898bb77bde35..b0a9248535322c4d68ee2b421b380acb50768d84 100644 (file)
@@ -74,6 +74,7 @@
 #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
@@ -895,7 +892,6 @@ them over and over. May need to do some more refactoring based on this idea...
  */
 void QG_DialogFactory::requestPolylineOptions(ActionInterface * action, bool on, bool update)
 {
-#ifdef RS_PROF
        static PolylineOptions * toolWidget = NULL;
 
        if (!optionWidget)
@@ -912,7 +908,6 @@ void QG_DialogFactory::requestPolylineOptions(ActionInterface * action, bool on,
                toolWidget = new PolylineOptions(optionWidget);
                toolWidget->setAction(action, update);
        }
-#endif
 }
 
 /**