src/base/script.h \
src/base/scriptlist.h \
src/base/selection.h \
- src/base/snapper.h \
src/base/solid.h \
src/base/spline.h \
src/base/staticgraphicview.h \
src/base/vector.h \
src/base/vectorsolutions.h
+# src/base/snapper.h \
+#
+
SOURCES = \
fparser/fparser.cc \
fparser/fpoptimizer.cc
src/base/script.cpp \
src/base/scriptlist.cpp \
src/base/selection.cpp \
- src/base/snapper.cpp \
src/base/solid.cpp \
src/base/spline.cpp \
src/base/staticgraphicview.cpp \
src/base/vector.cpp \
src/base/vectorsolutions.cpp
+# src/base/snapper.cpp \
+#
+
HEADERS += \
src/actions/actionblocksadd.h \
src/actions/actionblocksattributes.h \
{
}
-#if 0
-QAction * ActionBlocksCreate::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
- QAction * action = new QAction(tr("&Create Block"), 0);
-// QAction* action = new QAction(tr("Create Block"),
-// tr("&Create Block"),
-// QKeySequence(), NULL);
- action->setStatusTip(tr("Create Block"));
-
- return action;
-}
-
-#endif
-
/*virtual*/ RS2::ActionType ActionBlocksCreate::rtti()
{
return RS2::ActionBlocksCreate;
void ActionBlocksCreate::trigger()
{
-// deleteSnapper();
- //deletePreview();
- //clearPreview();
-
- //Modification m(*container, graphicView);
- //m.paste(data.insertionPoint);
- //std::cout << *Clipboard::instance();
-
- if (graphic != NULL)
+ if (graphic)
{
BlockList * blockList = graphic->getBlockList();
- if (blockList != NULL)
+ if (blockList)
{
BlockData d = DIALOGFACTORY->requestNewBlockDialog(blockList);
{
Creation creation(container, graphicView);
creation.createBlock(d, referencePoint, true);
-
InsertData id(d.name, referencePoint, Vector(1.0, 1.0), 0.0, 1, 1, Vector(0.0, 0.0));
creation.createInsert(id);
}
void ActionBlocksCreate::mouseMoveEvent(QMouseEvent * e)
{
-// snapPoint(e);
- graphicView->snapper.snapPoint(e);
+// graphicView->snapper.snapPoint(e);
+ graphicView->SnapPoint(e);
switch (getStatus())
{
{
if (e->button() == Qt::LeftButton)
{
-// Vector ce(snapPoint(e));
- Vector ce(graphicView->snapper.snapPoint(e));
+// Vector ce(graphicView->snapper.snapPoint(e));
+ Vector ce(graphicView->SnapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
{
case SetTargetPoint:
// data.insertionPoint = snapPoint(e);
- data.insertionPoint = graphicView->snapper.snapPoint(e);
+ data.insertionPoint = graphicView->SnapPoint(e);
if (block != NULL)
{
if (e->button() == Qt::LeftButton)
{
// Vector ce(snapPoint(e));
- Vector ce(graphicView->snapper.snapPoint(e));
+ Vector ce(graphicView->SnapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
ActionInterface("Default", container, graphicView)
{
DEBUG->print("ActionDefault::ActionDefault");
- //hm.
-// graphicView.snapper.SetVisible();
-// graphicView.preview.SetVisible();
DEBUG->print("ActionDefault::ActionDefault: OK");
}
ActionInterface::init(status);
v1 = v2 = Vector(false);
- graphicView->snapper.setSnapMode(RS2::SnapFree);
- graphicView->snapper.setSnapRestriction(RS2::RestrictNothing);
+// graphicView->snapper.setSnapMode(RS2::SnapFree);
+// graphicView->snapper.setSnapRestriction(RS2::RestrictNothing);
+ graphicView->setDefaultSnapMode(RS2::SnapFree);
+ graphicView->setSnapRestriction(RS2::RestrictNothing);
restrBak = RS2::RestrictNothing;
DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
{
if (e->key() == Qt::Key_Shift)
{
- restrBak = graphicView->snapper.getSnapRestriction();
- graphicView->snapper.setSnapRestriction(RS2::RestrictOrthogonal);
+// restrBak = graphicView->snapper.getSnapRestriction();
+// graphicView->snapper.setSnapRestriction(RS2::RestrictOrthogonal);
+ restrBak = graphicView->getSnapRestriction();
+ graphicView->setSnapRestriction(RS2::RestrictOrthogonal);
}
}
void ActionDefault::keyReleaseEvent(QKeyEvent * e)
{
if (e->key() == Qt::Key_Shift)
- graphicView->snapper.setSnapRestriction(restrBak);
+// graphicView->snapper.setSnapRestriction(restrBak);
+ graphicView->setSnapRestriction(restrBak);
}
void ActionDefault::mouseMoveEvent(QMouseEvent * e)
{
Vector mouse = graphicView->toGraph(Vector(e->x(), e->y()));
Vector relMouse = mouse - graphicView->getRelativeZero();
-
DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
switch (getStatus())
else
{
// test for an entity to drag:
- Entity * en = graphicView->snapper.catchEntity(v1);
+// Entity * en = graphicView->snapper.catchEntity(v1);
+ Entity * en = graphicView->CatchEntity(v1);
if (en && en->isSelected())
{
graphicView->preview.clear();
graphicView->preview.addSelectionFrom(*container);
graphicView->preview.moveRef(v1, v2 -v1);
- graphicView->snapper.SetVisible();
+// graphicView->snapper.SetVisible();
+ graphicView->SetSnapperVisible();
graphicView->preview.SetVisible();
graphicView->redraw();
break;
graphicView->preview.clear();
graphicView->preview.addSelectionFrom(*container);
graphicView->preview.move(v2 -v1);
- graphicView->snapper.SetVisible();
+// graphicView->snapper.SetVisible();
+ graphicView->SetSnapperVisible();
graphicView->preview.SetVisible();
graphicView->redraw();
break;
DIALOGFACTORY->updateSelectionWidget(container->countSelected());
DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
}
- break;
+ break;
case MovingRef:
{
DIALOGFACTORY->updateSelectionWidget(container->countSelected());
DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
}
- break;
+ break;
default:
break;
case Dragging:
{
// select single entity:
- Entity * en = graphicView->snapper.catchEntity(e);
+// Entity * en = graphicView->snapper.catchEntity(e);
+ Entity * en = graphicView->CatchEntity(e);
if (en)
{
Selection s(*container, graphicView);
s.selectSingle(en);
-
DIALOGFACTORY->updateSelectionWidget(container->countSelected());
-
e->accept();
setStatus(Neutral);
}
default:
// Was either moving entity or point, so clear that shiatsu
- graphicView->snapper.SetVisible(false);
+// graphicView->snapper.SetVisible(false);
+ graphicView->SetSnapperVisible(false);
graphicView->preview.SetVisible(false);
graphicView->redraw();
break;
break;
default:
- graphicView->snapper.SetVisible(false);
+// graphicView->snapper.SetVisible(false);
+ graphicView->SetSnapperVisible(false);
graphicView->preview.SetVisible(false);
DIALOGFACTORY->requestPreviousMenu();
e->accept();
this->fixedAngle = fixedAngle;
lastStatus = SetExtPoint1;
//hm. doesn't work.
- graphicView.snapper.SetVisible();
+// graphicView.snapper.SetVisible();
+ graphicView.SetSnapperVisible();
reset();
}
// graphicView->drawEntity(dim);
// graphicView->moveRelativeZero(rz);
// drawSnapper();
- graphicView->snapper.SetVisible(false);
+ graphicView->SetSnapperVisible(false);
graphicView->redraw();
DEBUG->print("ActionDimLinear::trigger(): dim added: %d", dim->getId());
{
Vector ce(snapPoint(e));
coordinateEvent(&ce);
- graphicView->snapper.SetVisible();
+// graphicView->snapper.SetVisible();
+ graphicView->SetSnapperVisible();
}
else if (e->button() == Qt::RightButton)
{
if (getStatus() == 0)
{
graphicView->preview.SetVisible(false);
- graphicView->snapper.SetVisible(false);
+// graphicView->snapper.SetVisible(false);
+ graphicView->SetSnapperVisible(false);
}
// deletePreview();
pos(Vector(false)), angle(a), length(1.0), fixedAngle(fa), snpPoint(0)
{
reset();
- //hm.
-// graphicView.snapper.SetContainer(&container);
-// graphicView.snapper.SetGraphicView(&graphicView);
-// graphicView.snapper.SetVisible();
-// graphicView.preview.SetVisible();
}
ActionDrawLineAngle::~ActionDrawLineAngle()
if (getStatus() == SetPos)
{
// Vector ce(snapPoint(e));
- Vector ce(graphicView->snapper.snapPoint(e));
+ Vector ce(graphicView->SnapPoint(e));
coordinateEvent(&ce);
}
}
bisector(NULL), line1(NULL), line2(NULL), length(10.0), number(1),
coord1(Vector(false)), coord2(Vector(false)), lastStatus(SetLine1)
{
- graphicView.snapper.SetVisible(false);
+ graphicView.SetSnapperVisible(false);
}
ActionDrawLineBisector::~ActionDrawLineBisector()
ActionInterface("Draw Parallels", container, graphicView),
parallel(NULL), distance(1.0), number(1), coord(Vector(false)), entity(NULL)
{
- graphicView.snapper.SetVisible(false);
+ graphicView.SetSnapperVisible(false);
}
ActionDrawLineParallel::~ActionDrawLineParallel()
if (e->button() == Qt::LeftButton)
{
// Vector ce(snapPoint(e));
- Vector ce(graphicView->snapper.snapPoint(e));
+ Vector ce(graphicView->SnapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
DEBUG->print("ActionDrawPolyline::mouseMoveEvent(): line added: %d", ent->getId());
}
#else
- Vector mouse = graphicView->snapper.snapPoint(e);
+ Vector mouse = graphicView->SnapPoint(e);
if (getStatus() == SetNextPoint && startPoint.valid)
{
{
if (e->button() == Qt::LeftButton)
{
- Vector ce(graphicView->snapper.snapPoint(e));
+ Vector ce(graphicView->SnapPoint(e));
coordinateEvent(&ce);
//let's try this...
case 0:
v1 = snapPoint(e);
// e1 = getKeyEntity();
- e1 = graphicView->snapper.getKeyEntity();
+ e1 = graphicView->GetSnapperEntity();
if (e1)
{
case 1:
v2 = snapPoint(e);
// e2 = getKeyEntity();
- e2 = graphicView->snapper.getKeyEntity();
+ e2 = graphicView->GetSnapperEntity();
if (e2)
trigger();
ActionZoomPan::ActionZoomPan(EntityContainer & container, GraphicView & graphicView):
ActionInterface("Zoom Pan", container, graphicView)
{
- graphicView.snapper.SetVisible(false);
+// graphicView.snapper.SetVisible(false);
+ graphicView.SetSnapperVisible(false);
graphicView.preview.SetVisible(false);
}
and to restore it in the destructor. This, of course, assumes that the actions are
created and used in a certain order, perhaps that needs enforcement? Dunno, but worth
a try as suspend() and resume() seem to fuck it up badly.
+#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__))
+on MS it's: __declspec(deprecated)
*/
/**
{
DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\"", name);
+//This doesn't work properly; not sure why that is...
+//Actually, it's working perfectly. Now we just need to propagate the fixes everywhere. :-/
+ // We'll use snapperVisibility for the save/restore functionality...
+ snapperVisibility = graphicView->SnapperVisible();
+
this->name = name;
status = 0;
finished = false;
document = ec.getDocument();
// \o/ \o/ \o/ BY GRABTHAR'S HAMMER, IT HAS BEEN EXPUNGED!!! \o/ \o/ \o/
+
// This is here until I can figure out a better way to contain all of this
// circular referential nonsense that exists in this codebase. It will be
// expunged, by Grabthar's Hammer!
graphicView->preview.SetVisible();
DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name);
-printf("ActionInterface::ActionInterface() [%08X]\n", this);
+//printf("ActionInterface::ActionInterface() [%08X]\n", this);
}
/**
// would be pure virtual now:
// hideOptions();
//JLH: Only it isn't pure virtual...
-printf("ActionInterface::~ActionInterface() [%08X]\n", this);
+//printf("ActionInterface::~ActionInterface() [%08X]\n", this);
+
+ // We'll use snapperVisibility for the save/restore functionality...
+ graphicView->SetSnapperVisible(snapperVisibility);
}
/**
// hm.
// graphicView->snapper.SetVisible(false);
graphicView->SetSnapperVisible(false);
+//Short circuit the destructor fuxoring with this:
+//snapperVisibility = false;
+//Only it causes other stuff to be fuxorred... Grr... Not sure how to fix this...
graphicView->preview.SetVisible(false);
// graphicView->preview.clear();
graphicView->redraw(); //hm.
// JLH 05/28/2010 Added this text. :-)
//
+// This is only used by the GraphicView class...
+
#include "eventhandler.h"
#include "actioninterface.h"
/**
* Constructor.
*/
-EventHandler::EventHandler(GraphicView * graphicView)
+EventHandler::EventHandler()://GraphicView * graphicView)
+ defaultAction(NULL), actionIndex(-1), coordinateInputEnabled(true)
{
- this->graphicView = graphicView;
- actionIndex = -1;
+// this->graphicView = graphicView;
+// actionIndex = -1;
- for(int i=0; i<RS_MAXACTIONS; ++i)
+ for(int i=0; i<RS_MAXACTIONS; i++)
currentActions[i] = NULL;
- coordinateInputEnabled = true;
- defaultAction = NULL;
+// coordinateInputEnabled = true;
+// defaultAction = NULL;
}
/**
defaultAction = NULL;
}
- killAllActions();
+ KillAllActions();
DEBUG->print("EventHandler::~EventHandler: Deleting all actions..");
}
}
- cleanUp();
+ CleanUp();
DEBUG->print("EventHandler::~EventHandler: Deleting all actions..: OK");
DEBUG->print("EventHandler::~EventHandler: OK");
}
/**
* Go back in current action.
*/
-void EventHandler::back()
+void EventHandler::Back()
{
QMouseEvent e(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::RightButton, Qt::RightButton,
Qt::NoModifier);
- mouseReleaseEvent(&e);
+ MouseReleaseEvent(&e);
}
/**
* Go enter pressed event for current action.
*/
-void EventHandler::enter()
+void EventHandler::Enter()
{
// QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, '\n', 0);
QKeyEvent e(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier, "\n", false, 0);
- keyPressEvent(&e);
+ KeyPressEvent(&e);
}
/**
* Called by GraphicView
*/
-void EventHandler::mousePressEvent(QMouseEvent * e)
+void EventHandler::MousePressEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex] != NULL)
{
/**
* Called by GraphicView
*/
-void EventHandler::mouseReleaseEvent(QMouseEvent * e)
+void EventHandler::MouseReleaseEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex] != NULL
&& !currentActions[actionIndex]->isFinished())
currentActions[actionIndex]->mouseReleaseEvent(e);
// Clean up actions - one might be finished now
- cleanUp();
+ CleanUp();
e->accept();
}
else
/**
* Called by GraphicView
*/
-void EventHandler::mouseMoveEvent(QMouseEvent * e)
+void EventHandler::MouseMoveEvent(QMouseEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* Called by GraphicView
*/
-void EventHandler::mouseLeaveEvent()
+void EventHandler::MouseLeaveEvent()
{
#if 0
if (actionIndex >= 0 && currentActions[actionIndex]
/**
* Called by GraphicView
*/
-void EventHandler::mouseEnterEvent()
+void EventHandler::MouseEnterEvent()
{
#if 0
if (actionIndex >= 0 && currentActions[actionIndex]
/**
* Called by GraphicView
*/
-void EventHandler::keyPressEvent(QKeyEvent * e)
+void EventHandler::KeyPressEvent(QKeyEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* Called by GraphicView
*/
-void EventHandler::keyReleaseEvent(QKeyEvent * e)
+void EventHandler::KeyReleaseEvent(QKeyEvent * e)
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* Handles command line events.
*/
-void EventHandler::commandEvent(CommandEvent * e)
+void EventHandler::HandleCommandEvent(GraphicView * graphicView, CommandEvent * e)
{
DEBUG->print("EventHandler::commandEvent");
QString cmd = e->getCommand();
if (ok1 && ok2)
{
-// DEBUG->print("EventHandler::commandEvent: 005");
-// CoordinateEvent ce(Vector(x, y));
DEBUG->print("EventHandler::commandEvent: 006");
-// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(x, y);
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
{
- if (DIALOGFACTORY != NULL)
+ if (DIALOGFACTORY)
DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
if (ok1 && ok2)
{
-// CoordinateEvent ce(Vector(x,y) + graphicView->getRelativeZero());
-// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(Vector(x,y) + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
else
{
- if (DIALOGFACTORY != NULL)
+ if (DIALOGFACTORY)
DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
{
Vector pos;
pos.setPolar(r,Math::deg2rad(a));
-// CoordinateEvent ce(pos);
-// currentActions[actionIndex]->coordinateEvent(&ce);
currentActions[actionIndex]->coordinateEvent(&pos);
}
else
{
- if (DIALOGFACTORY != NULL)
+ if (DIALOGFACTORY)
DIALOGFACTORY->commandMessage("Expression Syntax Error");
}
if (actionIndex >= 0 && currentActions[actionIndex] !=NULL
&& !currentActions[actionIndex]->isFinished())
{
-// int commaPos = cmd.find('<');
int commaPos = cmd.indexOf('<');
bool ok1, ok2;
double r = Math::eval(cmd.mid(1, commaPos - 1), &ok1);
{
Vector pos;
pos.setPolar(r,Math::deg2rad(a));
-// CoordinateEvent ce(pos + graphicView->getRelativeZero());
-// currentActions[actionIndex]->coordinateEvent(&ce);
Vector ce(pos + graphicView->getRelativeZero());
currentActions[actionIndex]->coordinateEvent(&ce);
}
}
}
- // send command event directly to current action:
+ // Send command event directly to current action:
if (!e->isAccepted())
{
if (actionIndex >= 0 && currentActions[actionIndex]
/**
* Enables coordinate input in the command line.
*/
-void EventHandler::enableCoordinateInput()
+void EventHandler::EnableCoordinateInput()
{
coordinateInputEnabled = true;
}
/**
* Enables coordinate input in the command line.
*/
-void EventHandler::disableCoordinateInput()
+void EventHandler::DisableCoordinateInput()
{
coordinateInputEnabled = false;
}
/**
* @return Current action.
*/
-ActionInterface * EventHandler::getCurrentAction()
+ActionInterface * EventHandler::GetCurrentAction()
{
if (actionIndex >= 0 && currentActions[actionIndex]
&& !currentActions[actionIndex]->isFinished())
/**
* @return The current default action.
*/
-ActionInterface * EventHandler::getDefaultAction()
+ActionInterface * EventHandler::GetDefaultAction()
{
return defaultAction;
}
/**
* Sets the default action.
*/
-void EventHandler::setDefaultAction(ActionInterface * action)
+void EventHandler::SetDefaultAction(ActionInterface * action)
{
if (defaultAction)
{
/**
* Sets the current action.
*/
-void EventHandler::setCurrentAction(ActionInterface * action)
+void EventHandler::SetCurrentAction(ActionInterface * action)
{
DEBUG->print("EventHandler::setCurrentAction");
// Forget about the oldest action and make space for the new action:
if (actionIndex == RS_MAXACTIONS - 1)
{
- // delete oldest action if necessary (usually never happens):
+ // Delete oldest action if necessary (usually never happens):
if (currentActions[0])
{
currentActions[0]->finish();
}
DEBUG->print("EventHandler::setCurrentAction: cleaning up..");
- cleanUp();
+ CleanUp();
DEBUG->print("EventHandler::setCurrentAction: debugging actions");
- debugActions();
+ DebugActions();
DEBUG->print("GraphicView::setCurrentAction: OK");
}
* Kills all running selection actions. Called when a selection action
* is launched to reduce confusion.
*/
-void EventHandler::killSelectActions()
+void EventHandler::KillSelectActions()
{
for(int c=0; c<RS_MAXACTIONS; ++c)
{
/**
* Kills all running actions. Called when a window is closed.
+ * Actually: It does NOTHING
*/
-void EventHandler::killAllActions()
+void EventHandler::KillAllActions()
{
/*
for (int c=0; c<RS_MAXACTIONS; ++c) {
/**
* @return true if there is at least one action in the action stack.
*/
-bool EventHandler::hasAction()
+bool EventHandler::HasAction()
{
if (actionIndex != -1 || defaultAction)
return true;
/**
* Garbage collector for actions.
*/
-void EventHandler::cleanUp()
+void EventHandler::CleanUp()
{
DEBUG->print("EventHandler::cleanUp");
bool doResume = false; // do we need to resume an action
actionIndex = -1;
- debugActions();
+ DebugActions();
do
{
}
while (oldIndex < RS_MAXACTIONS);
- debugActions();
+ DebugActions();
// Resume last used action:
if (doResume)
DEBUG->print("EventHandler::cleanUp: OK");
}
-/**
- * Sets the snap mode for all currently active actions.
- */
-void EventHandler::setSnapMode(RS2::SnapMode sm)
-{
-#if 0
- for(int c=0; c<RS_MAXACTIONS; ++c)
- if (currentActions[c])
- currentActions[c]->setSnapMode(sm);
-
- if (defaultAction)
- defaultAction->setSnapMode(sm);
-#else
-#warning "!!! Not sure if this is going to work correctly..."
-//seems to
- graphicView->snapper.setSnapMode(sm);
-#endif
-}
-
-/**
- * Sets the snap restriction for all currently active actions.
- */
-void EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
-{
-#if 0
- for(int c=0; c<RS_MAXACTIONS; ++c)
- if (currentActions[c])
- currentActions[c]->setSnapRestriction(sr);
-
- if (defaultAction)
- defaultAction->setSnapRestriction(sr);
-#else
-#warning "!!! Not sure if this is going to work correctly..."
-//seems to
- graphicView->snapper.setSnapRestriction(sr);
-#endif
-}
-
-void EventHandler::debugActions()
+void EventHandler::DebugActions()
{
DEBUG->print("---");
#define __EVENTHANDLER_H__
#include <QtGui>
-#include "enums.h"
#define RS_MAXACTIONS 16
class EventHandler
{
public:
- EventHandler(GraphicView * graphicView);
+ EventHandler();
~EventHandler();
- void back();
- void enter();
- void mousePressEvent(QMouseEvent * e);
- void mouseReleaseEvent(QMouseEvent * e);
- void mouseMoveEvent(QMouseEvent * e);
- void mouseLeaveEvent();
- void mouseEnterEvent();
- void keyPressEvent(QKeyEvent * e);
- void keyReleaseEvent(QKeyEvent * e);
- void commandEvent(CommandEvent * e);
- void enableCoordinateInput();
- void disableCoordinateInput();
- void setDefaultAction(ActionInterface * action);
- ActionInterface * getDefaultAction();
- void setCurrentAction(ActionInterface * action);
- ActionInterface * getCurrentAction();
- void killSelectActions();
- void killAllActions();
- bool hasAction();
- void cleanUp();
- void debugActions();
- void setSnapMode(RS2::SnapMode sm);
- void setSnapRestriction(RS2::SnapRestriction sr);
+ void Back();
+ void Enter();
+ void MousePressEvent(QMouseEvent * e);
+ void MouseReleaseEvent(QMouseEvent * e);
+ void MouseMoveEvent(QMouseEvent * e);
+ void MouseLeaveEvent();
+ void MouseEnterEvent();
+ void KeyPressEvent(QKeyEvent * e);
+ void KeyReleaseEvent(QKeyEvent * e);
+ void HandleCommandEvent(GraphicView *, CommandEvent * e);
+ void EnableCoordinateInput();
+ void DisableCoordinateInput();
+ void SetDefaultAction(ActionInterface * action);
+ ActionInterface * GetDefaultAction();
+ void SetCurrentAction(ActionInterface * action);
+ ActionInterface * GetCurrentAction();
+ void KillSelectActions();
+ void KillAllActions();
+ bool HasAction();
+ void CleanUp();
+ void DebugActions();
protected:
- GraphicView * graphicView;
ActionInterface * defaultAction;
ActionInterface * currentActions[RS_MAXACTIONS];
int actionIndex;
+++ /dev/null
-// snapper.cpp
-//
-// Part of the Architektonas Project
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// Portions copyright (C) 2001-2003 RibbonSoft
-// 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 05/21/2010 Added this text. :-)
-// JLH 10/18/2010 Commented out all functions in preparation for deprecating
-// this class.
-//
-
-#include "snapper.h"
-
-#include "dialogfactory.h"
-#include "drawing.h"
-#include "entitycontainer.h"
-#include "graphicview.h"
-#include "grid.h"
-#include "information.h"
-#include "paintinterface.h"
-#include "settings.h"
-
-/**
- * Constructor.
- */
-Snapper::Snapper(EntityContainer & c, GraphicView & gv):
- container(&c), graphicView(&gv), finished(false)
-{
-#if 0
- init();
-#endif
-}
-
-Snapper::Snapper(void):
- container(NULL), graphicView(NULL), finished(false)
-{
-#if 0
- init();
-#endif
-}
-
-/**
- * Destructor.
- */
-Snapper::~Snapper()
-{
-}
-
-/**
- * Initialize (called by all constructors)
- */
-void Snapper::init()
-{
-#if 0
- if (graphicView)
- {
- snapMode = graphicView->getDefaultSnapMode();
- snapRes = graphicView->getSnapRestriction();
- }
-
- keyEntity = NULL;
- snapSpot = Vector(false);
- snapCoord = Vector(false);
- visible = false;
- distance = 1.0;
-
- settings.beginGroup("Snap");
- snapRange = settings.value("Range", 20).toInt();
- settings.endGroup();
- settings.beginGroup("Appearance");
- showCrosshairs = settings.value("ShowCrosshairs", true).toBool();
- settings.endGroup();
-
- // Sanity check
- if (snapRange < 2)
- snapRange = 20;
-#endif
-}
-
-void Snapper::finish()
-{
-#if 0
- finished = true;
-#endif
-}
-
-//bleh
-void Snapper::SetContainer(EntityContainer * c)
-{
-#if 0
- container = c;
-#endif
-}
-
-//bleh
-void Snapper::SetGraphicView(GraphicView * v)
-{
-#if 0
- graphicView = v;
-#endif
-}
-
-/**
- * @return Pointer to the entity which was the key entity for the last
- * successful snapping action. If the snap mode is "end point" the key entity
- * is the entity whose end point was caught. If the snap mode didn't require an
- * entity (e.g. free, grid) this method will return NULL.
- */
-Entity * Snapper::getKeyEntity()
-{
-#if 0
- return keyEntity;
-#endif
- return NULL;
-}
-
-/** Sets a new snap mode. */
-void Snapper::setSnapMode(RS2::SnapMode snapMode)
-{
-#if 0
- this->snapMode = snapMode;
-#endif
-}
-
-/** Sets a new snap restriction. */
-void Snapper::setSnapRestriction(RS2::SnapRestriction snapRes)
-{
-#if 0
- this->snapRes = snapRes;
-#endif
-}
-
-RS2::SnapMode Snapper::getSnapMode(void)
-{
-#if 0
- return snapMode;
-#endif
- return RS2::SnapFree;
-}
-
-RS2::SnapRestriction Snapper::getSnapRestriction(void)
-{
-#if 0
- return snapRes;
-#endif
- return RS2::RestrictNothing;
-}
-
-/**
- * Sets the snap range in pixels for catchEntity().
- *
- * @see catchEntity()
- */
-void Snapper::setSnapRange(int r)
-{
-#if 0
- snapRange = r;
-#endif
-}
-
-#if 0
-This should get moved into GraphicView...
-#endif
-/**
- * Snap to a coordinate in the drawing using the current snap mode.
- *
- * @param e A mouse event.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapPoint(QMouseEvent * e)
-{
-#if 0
- DEBUG->print("Snapper::snapPoint");
- snapSpot = Vector(false);
-
- if (!e)
- {
- DEBUG->print(Debug::D_WARNING, "Snapper::snapPoint: event is NULL");
- return snapSpot;
- }
-
- Vector mouseCoord = graphicView->toGraph(e->x(), e->y());
-
- switch (snapMode)
- {
- case RS2::SnapFree:
- snapSpot = snapFree(mouseCoord);
- break;
-
- case RS2::SnapEndpoint:
- snapSpot = snapEndpoint(mouseCoord);
- break;
-
- case RS2::SnapGrid:
- snapSpot = snapGrid(mouseCoord);
- break;
-
- case RS2::SnapOnEntity:
- snapSpot = snapOnEntity(mouseCoord);
- break;
-
- case RS2::SnapCenter:
- snapSpot = snapCenter(mouseCoord);
- break;
-
- case RS2::SnapMiddle:
- snapSpot = snapMiddle(mouseCoord);
- break;
-
- case RS2::SnapDist:
- snapSpot = snapDist(mouseCoord);
- break;
-
- case RS2::SnapIntersection:
- snapSpot = snapIntersection(mouseCoord);
- break;
-
- default:
- break;
- }
-
- // Handle snap restrictions that can be activated in addition to the ones above:
- switch (snapRes)
- {
- case RS2::RestrictOrthogonal:
- snapCoord = restrictOrthogonal(snapSpot);
- break;
- case RS2::RestrictHorizontal:
- snapCoord = restrictHorizontal(snapSpot);
- break;
- case RS2::RestrictVertical:
- snapCoord = restrictVertical(snapSpot);
- break;
- default:
- case RS2::RestrictNothing:
- snapCoord = snapSpot;
- break;
- }
-
- if (DIALOGFACTORY)
- DIALOGFACTORY->updateCoordinateWidget(snapCoord, snapCoord - graphicView->getRelativeZero());
-
- DEBUG->print("Snapper::snapPoint: OK");
-
- return snapCoord;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to a free coordinate.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapFree(Vector coord)
-{
-#if 0
- keyEntity = NULL;
- return coord;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to the closest endpoint.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapEndpoint(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestEndpoint(coord, NULL);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to a grid point.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapGrid(Vector coord)
-{
-#if 0
- DEBUG->print("Snapper::snapGrid begin");
-
- Vector vec(false);
- double dist = 0.0;
-
- Grid * grid = graphicView->getGrid();
-
- DEBUG->print("Snapper::snapGrid 001");
-
- if (grid)
- {
- DEBUG->print("Snapper::snapGrid 002");
- Vector * pts = grid->getPoints();
- DEBUG->print("Snapper::snapGrid 003");
- int closest = -1;
- dist = 32000.00;
- DEBUG->print("Snapper::snapGrid 004");
-
- for(int i=0; i<grid->count(); ++i)
- {
- double d = pts[i].distanceTo(coord);
-
- if (d < dist)
- {
- closest = i;
- dist = d;
- }
- }
-
- DEBUG->print("Snapper::snapGrid 005");
-
- if (closest >= 0)
- vec = pts[closest];
-
- DEBUG->print("Snapper::snapGrid 006");
- }
-
- keyEntity = NULL;
-
- DEBUG->print("Snapper::snapGrid end");
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to a point on an entity.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapOnEntity(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestPointOnEntity(coord, true, NULL, &keyEntity);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to the closest center.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapCenter(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestCenter(coord, NULL);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to the closest middle.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapMiddle(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestMiddle(coord, NULL);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to the closest point with a given distance to the endpoint.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapDist(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestDist(distance, coord, NULL);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * Snaps to the closest intersection point.
- *
- * @param coord The mouse coordinate.
- * @return The coordinates of the point or an invalid vector.
- */
-Vector Snapper::snapIntersection(Vector coord)
-{
-#if 0
- Vector vec(false);
- vec = container->getNearestIntersection(coord, NULL);
-
- return vec;
-#endif
- return Vector(false);
-}
-
-/**
- * 'Corrects' the given coordinates to 0, 90, 180, 270 degrees relative to
- * the current relative zero point.
- *
- * @param coord The uncorrected coordinates.
- * @return The corrected coordinates.
- */
-Vector Snapper::restrictOrthogonal(Vector coord)
-{
-#if 0
- Vector rz = graphicView->getRelativeZero();
- Vector ret(coord);
-
- Vector retx = Vector(rz.x, ret.y);
- Vector rety = Vector(ret.x, rz.y);
-
- if (retx.distanceTo(ret) > rety.distanceTo(ret))
- ret = rety;
- else
- ret = retx;
-
- return ret;
-#endif
- return Vector(false);
-}
-
-/**
- * 'Corrects' the given coordinates to 0, 180 degrees relative to
- * the current relative zero point.
- *
- * @param coord The uncorrected coordinates.
- * @return The corrected coordinates.
- */
-Vector Snapper::restrictHorizontal(Vector coord)
-{
-#if 0
- Vector rz = graphicView->getRelativeZero();
-
- return Vector(coord.x, rz.y);
-#endif
- return Vector(false);
-}
-
-/**
- * 'Corrects' the given coordinates to 90, 270 degrees relative to
- * the current relative zero point.
- *
- * @param coord The uncorrected coordinates.
- * @return The corrected coordinates.
- */
-Vector Snapper::restrictVertical(Vector coord)
-{
-#if 0
- Vector rz = graphicView->getRelativeZero();
-
- return Vector(rz.x, coord.y);
-#endif
- return Vector(false);
-}
-
-/**
- * Catches an entity which is close to the given position 'pos'.
- *
- * @param pos A graphic coordinate.
- * @param level The level of resolving for iterating through the entity
- * container
- * @return Pointer to the entity or NULL.
- */
-Entity * Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
-{
-#if 0
- DEBUG->print("Snapper::catchEntity");
-
- // Set default distance for points inside solids
- double dist = graphicView->toGraphDX(snapRange) * 0.9;
- Entity * entity = container->getNearestEntity(pos, &dist, level);
- int idx = -1;
-
- if (entity && entity->getParent())
- idx = entity->getParent()->findEntity(entity);
-
- if (entity && dist <= graphicView->toGraphDX(snapRange))
- {
- // Highlight:
- DEBUG->print("Snapper::catchEntity: found: %d", idx);
- return entity;
- }
-// else
-// {
- DEBUG->print("Snapper::catchEntity: not found");
- return NULL;
-// }
-
-// DEBUG->print("Snapper::catchEntity: OK");
-#endif
- return NULL;
-}
-
-/**
- * Catches an entity which is close to the mouse cursor.
- *
- * @param e A mouse event.
- * @param level The level of resolving for iterating through the entity
- * container
- * @return Pointer to the entity or NULL.
- */
-Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
-{
-#if 0
- return catchEntity(Vector(graphicView->toGraphX(e->x()),
- graphicView->toGraphY(e->y())), level);
-#endif
- return NULL;
-}
-
-#if 0
-I think that these suspend() & resume() functions are not used anymore...
-#endif
-/**
- * Suspends this snapper while another action takes place.
- */
-/*virtual*/ void Snapper::suspend()
-{
-#if 0
-#warning "!!! This may need to have SetVisibility() called !!!"
-// deleteSnapper();
- snapSpot = snapCoord = Vector(false);
-#endif
-}
-
-/**
- * Resumes this snapper after it has been suspended.
- */
-/*virtual*/ void Snapper::resume()
-{
-#if 0
-#warning "!!! This may need to have SetVisibility() called !!!"
-// drawSnapper();
-#endif
-}
-
-/**
- * Hides the snapper options.
- */
-/*virtual*/ void Snapper::hideOptions()
-{
-#if 0
- if (snapMode == RS2::SnapDist && DIALOGFACTORY)
- DIALOGFACTORY->requestSnapDistOptions(distance, false);
-#endif
-}
-
-/**
- * Shows the snapper options.
- */
-/*virtual*/ void Snapper::showOptions()
-{
-#if 0
- if (snapMode == RS2::SnapDist && DIALOGFACTORY)
- DIALOGFACTORY->requestSnapDistOptions(distance, true);
-#endif
-}
-
-void Snapper::SetVisible(bool visibility/*= true*/)
-{
-#if 0
- visible = visibility;
-#endif
-}
-
-bool Snapper::Visible(void)
-{
-#if 0
- return visible;
-#endif
-}
-
-/*
-We need to figure out how to kick the GraphicView out of this class. Perhaps we
-need to move the toGuiX/Y() functions into another class as static functions.
-Further inspection seems to rule this out as they are pretty well coupled to the
-GraphicView class... What to do?
-*/
-void Snapper::Draw(GraphicView * view, PaintInterface * painter)
-{
-#if 0
- if (finished || !snapSpot.valid || !snapCoord.valid)
- return;
-
-//hm, I don't like graphicView kicking around in here, especially since it now
-//lives inside GraphicView... How to !!! FIX !!!?
-//We'll pass it in for now...
- // Snap point (need to make sure the brush is NULL!)
-// painter->setPen(Pen(Color(0, 127, 255), RS2::Width00, RS2::DashLine));
- painter->setPen(Pen(Color(255, 127, 0), RS2::Width00, RS2::DashLine));
- painter->drawCircle(view->toGui(snapCoord), 4);
-
- // Crosshairs
- if (showCrosshairs)
- {
- painter->setPen(Pen(Color(0, 255, 255), RS2::Width00, RS2::DashLine));
- painter->drawLine(Vector(0, view->toGuiY(snapCoord.y)),
- Vector(view->getWidth(), view->toGuiY(snapCoord.y)));
- painter->drawLine(Vector(view->toGuiX(snapCoord.x), 0),
- Vector(view->toGuiX(snapCoord.x), view->getHeight()));
- }
-
- if (snapCoord != snapSpot)
- {
- painter->drawLine(view->toGui(snapSpot) + Vector(-5, 0),
- view->toGui(snapSpot) + Vector(-1, 4));
- painter->drawLine(view->toGui(snapSpot) + Vector(0, 5),
- view->toGui(snapSpot) + Vector(4, 1));
- painter->drawLine(view->toGui(snapSpot) + Vector(5, 0),
- view->toGui(snapSpot) + Vector(1, -4));
- painter->drawLine(view->toGui(snapSpot) + Vector(0, -5),
- view->toGui(snapSpot) + Vector(-4, -1));
- }
-#endif
-}
+++ /dev/null
-#ifndef __SNAPPER_H__
-#define __SNAPPER_H__
-
-#include <QtCore>
-#include "enums.h"
-#include "vector.h"
-
-class Entity;
-class EntityContainer;
-class GraphicView;
-class PaintInterface;
-
-/**
- * This class is used for snapping functions in a graphic view.
- * Actions are usually derrived from this base class if they need
- * to catch entities or snap to coordinates. Use the methods to
- * retrieve a graphic coordinate from a mouse coordinate.
- *
- * Possible snapping functions are described in RS_SnapMode.
- *
- * @author Andrew Mustun
- */
-class Snapper
-{
- public:
- Snapper(EntityContainer & container, GraphicView & graphicView);
- Snapper();
- virtual ~Snapper();
-
- void init();
- void finish();
-
- void SetContainer(EntityContainer *);
- void SetGraphicView(GraphicView *);
- Entity * getKeyEntity();
- void setSnapMode(RS2::SnapMode snapMode);
- void setSnapRestriction(RS2::SnapRestriction snapRes);
- RS2::SnapMode getSnapMode(void);
- RS2::SnapRestriction getSnapRestriction(void);
- void setSnapRange(int r);
-
- Vector snapPoint(QMouseEvent * e);
- Vector snapFree(Vector coord);
- Vector snapEndpoint(Vector coord);
- Vector snapGrid(Vector coord);
- Vector snapOnEntity(Vector coord);
- Vector snapCenter(Vector coord);
- Vector snapMiddle(Vector coord);
- Vector snapDist(Vector coord);
- Vector snapIntersection(Vector coord);
-
- Vector restrictOrthogonal(Vector coord);
- Vector restrictHorizontal(Vector coord);
- Vector restrictVertical(Vector coord);
-
- Entity * catchEntity(const Vector & pos, RS2::ResolveLevel level = RS2::ResolveNone);
- Entity * catchEntity(QMouseEvent * e, RS2::ResolveLevel level = RS2::ResolveNone);
-
- virtual void suspend();
- virtual void resume();
- virtual void hideOptions();
- virtual void showOptions();
-
-// void drawSnapper();
-// void deleteSnapper();
-
-/*
-How should we handle this? All rendering goes through the GraphicView (QG_GraphicView to be
-precise, soon to be merged in) as it should. So shouldn't we control the snapper through
-that class as well? Unfortunately, all actions derive from this class...
-
-Should they?
-
-Not 100% sure. It does seem to make more sense to have them be a part of the GraphicView,
-since snapping is a function of the grid and the entities contained in the view. (This would
-also hold for the preview as well.)
-
-On to the interface:
-
-For allowing the crosshairs to be drawn, we'd have
-void ShowSnapper(void)
-
-and
-void HideSnapper(void)
-
-to hide it. Maybe
-void SetSnapperCoords(Vector, Vector)
-
-for setting the coordinates?
-*/
- public://for now
- void SetVisible(bool visibility = true);
- bool Visible(void);
- void Draw(GraphicView *, PaintInterface *);
-
-// private:
-// void xorSnapper();
-
- protected:
- EntityContainer * container;
- GraphicView * graphicView;
- Entity * keyEntity;
- Vector snapCoord;
- Vector snapSpot;
- RS2::SnapMode snapMode;
- RS2::SnapRestriction snapRes;
- /**
- * Snap distance for snaping to points with a
- * given distance from endpoints.
- */
- double distance;
- /**
- * Keeps track of the drawings in XOR mode.
- */
- bool visible;
- /**
- * Snap range for catching entities.
- */
- int snapRange;
- /**
- * Show large cross hairs.
- */
- bool showCrosshairs;
- bool finished;
-};
-
-#endif
printing = false;
deleteMode = false;
factor = Vector(1.0, 1.0);
- offsetX = 0;
- offsetY = 0;
+ offsetX = offsetY = 0;
previousFactor = Vector(1.0, 1.0);
- previousOffsetX = 0;
- previousOffsetY = 0;
+ previousOffsetX = previousOffsetY = 0;
container = NULL;
- eventHandler = new EventHandler(this);
+ eventHandler = new EventHandler();
gridColor = Qt::gray;
metaGridColor = Color(64, 64, 64);
grid = new Grid(this);
draftMode = false;
painter = NULL;
- borderLeft = 0;
- borderTop = 0;
- borderRight = 0;
- borderBottom = 0;
+ borderLeft = borderTop = borderRight = borderBottom = 0;
relativeZero = Vector(false);
relativeZeroLocked = false;
*/
ActionInterface * GraphicView::getDefaultAction()
{
- if (eventHandler != NULL)
- return eventHandler->getDefaultAction();
- else
- return NULL;
+ if (eventHandler)
+ return eventHandler->GetDefaultAction();
+
+ return NULL;
}
/**
void GraphicView::setDefaultAction(ActionInterface * action)
{
if (eventHandler)
- eventHandler->setDefaultAction(action);
+ eventHandler->SetDefaultAction(action);
}
/**
ActionInterface * GraphicView::getCurrentAction()
{
if (eventHandler)
- return eventHandler->getCurrentAction();
+ return eventHandler->GetCurrentAction();
else
return NULL;
}
DEBUG->print("GraphicView::setCurrentAction");
if (eventHandler)
- eventHandler->setCurrentAction(action);
+ eventHandler->SetCurrentAction(action);
DEBUG->print("GraphicView::setCurrentAction: OK");
}
void GraphicView::killSelectActions()
{
if (eventHandler)
- eventHandler->killSelectActions();
+ eventHandler->KillSelectActions();
}
/**
*/
void GraphicView::killAllActions()
{
+ //KillAll does nothing...
if (eventHandler)
- eventHandler->killAllActions();
+ eventHandler->KillAllActions();
}
/**
*/
void GraphicView::back()
{
- if (eventHandler && eventHandler->hasAction())
- eventHandler->back();
+ if (eventHandler && eventHandler->HasAction())
+ eventHandler->Back();
else if (DIALOGFACTORY)
DIALOGFACTORY->requestPreviousMenu();
}
*/
void GraphicView::enter()
{
- if (eventHandler && eventHandler->hasAction())
- eventHandler->enter();
+ if (eventHandler && eventHandler->HasAction())
+ eventHandler->Enter();
}
/**
void GraphicView::mousePressEvent(QMouseEvent * e)
{
if (eventHandler)
- eventHandler->mousePressEvent(e);
+ eventHandler->MousePressEvent(e);
}
/**
if (!eventHandler)
return;
- if (e->button() != Qt::RightButton || eventHandler->hasAction())
+ if (e->button() != Qt::RightButton || eventHandler->HasAction())
{
- eventHandler->mouseReleaseEvent(e);
+ eventHandler->MouseReleaseEvent(e);
}
else
{
{
DEBUG->print("GraphicView::mouseMoveEvent begin");
- Drawing * graphic = NULL;
+ Drawing * drawing = NULL;
if (container->rtti() == RS2::EntityGraphic)
- graphic = (Drawing *)container;
+ drawing = (Drawing *)container;
DEBUG->print("GraphicView::mouseMoveEvent 001");
DEBUG->print("GraphicView::mouseMoveEvent 002");
if (eventHandler)
- eventHandler->mouseMoveEvent(e);
+ eventHandler->MouseMoveEvent(e);
DEBUG->print("GraphicView::mouseMoveEvent 003");
- if (!eventHandler || !eventHandler->hasAction() && graphic)
+ if (!eventHandler || !eventHandler->HasAction() && drawing)
{
- Vector mouse = toGraph(Vector(mx, my));
- Vector relMouse = mouse - getRelativeZero();
-
if (DIALOGFACTORY)
+ {
+ Vector mouse = toGraph(Vector(mx, my));
+ Vector relMouse = mouse - getRelativeZero();
DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse);
+ }
}
DEBUG->print("GraphicView::mouseMoveEvent end");
void GraphicView::mouseLeaveEvent()
{
if (eventHandler)
- eventHandler->mouseLeaveEvent();
+ eventHandler->MouseLeaveEvent();
}
/**
void GraphicView::mouseEnterEvent()
{
if (eventHandler)
- eventHandler->mouseEnterEvent();
+ eventHandler->MouseEnterEvent();
}
/**
void GraphicView::keyPressEvent(QKeyEvent * e)
{
if (eventHandler)
- eventHandler->keyPressEvent(e);
+ eventHandler->KeyPressEvent(e);
}
/**
void GraphicView::keyReleaseEvent(QKeyEvent * e)
{
if (eventHandler)
- eventHandler->keyReleaseEvent(e);
+ eventHandler->KeyReleaseEvent(e);
}
/**
void GraphicView::commandEvent(CommandEvent * e)
{
if (eventHandler)
- eventHandler->commandEvent(e);
+ eventHandler->HandleCommandEvent(this, e);
}
/**
void GraphicView::enableCoordinateInput()
{
if (eventHandler)
- eventHandler->enableCoordinateInput();
+ eventHandler->EnableCoordinateInput();
}
/**
void GraphicView::disableCoordinateInput()
{
if (eventHandler)
- eventHandler->disableCoordinateInput();
+ eventHandler->DisableCoordinateInput();
}
/**
return;
Vector c = center;
+
if (c.valid == false)
c = toGraph(Vector(getWidth() / 2, getHeight() / 2));
{
defaultSnapMode = sm;
+// Don't need this shiaut anymore
+#if 0
if (eventHandler)
eventHandler->setSnapMode(sm);
//us up, hm notwithstanding. [and it does. :-)]
//hm.
snapper.setSnapMode(sm);
+#endif
}
/**
{
defaultSnapRes = sr;
+// Don't need this shiaut anymore
+#if 0
if (eventHandler != NULL)
eventHandler->setSnapRestriction(sr);
+#endif
}
/**
return CatchEntity(Vector(toGraphX(e->x()), toGraphY(e->y())), level);
}
+/**
+ * @return Pointer to the entity which was the key entity for the last
+ * successful snapping action. If the snap mode is "end point" the key entity
+ * is the entity whose end point was caught. If the snap mode didn't require an
+ * entity (e.g. free, grid) this method will return NULL.
+ */
+Entity * GraphicView::GetSnapperEntity()
+{
+ return snapEntity;
+}
+
/**
* Snap to a coordinate in the drawing using the current snap mode.
*
finished = true;
}
-/**
- * @return Pointer to the entity which was the key entity for the last
- * successful snapping action. If the snap mode is "end point" the key entity
- * is the entity whose end point was caught. If the snap mode didn't require an
- * entity (e.g. free, grid) this method will return NULL.
- */
-Entity * Snapper::getKeyEntity()
-{
- return keyEntity;
-}
-
/** Sets a new snap mode. */
void Snapper::setSnapMode(RS2::SnapMode snapMode)
{
Entity * CatchEntity(const Vector &, RS2::ResolveLevel level = RS2::ResolveNone);
Entity * CatchEntity(QMouseEvent *, RS2::ResolveLevel level = RS2::ResolveNone);
+ Entity * GetSnapperEntity(void);
Vector SnapPoint(QMouseEvent *);
Vector SnapGrid(Vector);
void DrawSnapper(PaintInterface *);
public://for now
// We use this here instead of deriving ActionInterface from it because
// this makes more sense.
- Snapper snapper;
+// Snapper snapper;
+//yer next
Preview preview;
//QG