X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmainapp%2Fgraphicview.cpp;h=d29de4a7817b81689bea7c7d3cd50ad7991bfe3d;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=5b633b2b3a56af1859772b16f4941bf5ac659f10;hpb=92c8661cef41f1109908bf645c0a171e34680183;p=architektonas diff --git a/src/mainapp/graphicview.cpp b/src/mainapp/graphicview.cpp index 5b633b2..d29de4a 100644 --- a/src/mainapp/graphicview.cpp +++ b/src/mainapp/graphicview.cpp @@ -35,13 +35,11 @@ GraphicView::GraphicView(): background(), foreground() 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); @@ -50,10 +48,7 @@ GraphicView::GraphicView(): background(), foreground() draftMode = false; painter = NULL; - borderLeft = 0; - borderTop = 0; - borderRight = 0; - borderBottom = 0; + borderLeft = borderTop = borderRight = borderBottom = 0; relativeZero = Vector(false); relativeZeroLocked = false; @@ -452,10 +447,10 @@ void GraphicView::updateView() */ ActionInterface * GraphicView::getDefaultAction() { - if (eventHandler != NULL) - return eventHandler->getDefaultAction(); - else - return NULL; + if (eventHandler) + return eventHandler->GetDefaultAction(); + + return NULL; } /** @@ -464,7 +459,7 @@ ActionInterface * GraphicView::getDefaultAction() void GraphicView::setDefaultAction(ActionInterface * action) { if (eventHandler) - eventHandler->setDefaultAction(action); + eventHandler->SetDefaultAction(action); } /** @@ -473,7 +468,7 @@ void GraphicView::setDefaultAction(ActionInterface * action) ActionInterface * GraphicView::getCurrentAction() { if (eventHandler) - return eventHandler->getCurrentAction(); + return eventHandler->GetCurrentAction(); else return NULL; } @@ -486,7 +481,7 @@ void GraphicView::setCurrentAction(ActionInterface * action) DEBUG->print("GraphicView::setCurrentAction"); if (eventHandler) - eventHandler->setCurrentAction(action); + eventHandler->SetCurrentAction(action); DEBUG->print("GraphicView::setCurrentAction: OK"); } @@ -498,7 +493,7 @@ void GraphicView::setCurrentAction(ActionInterface * action) void GraphicView::killSelectActions() { if (eventHandler) - eventHandler->killSelectActions(); + eventHandler->KillSelectActions(); } /** @@ -506,8 +501,9 @@ void GraphicView::killSelectActions() */ void GraphicView::killAllActions() { + //KillAll does nothing... if (eventHandler) - eventHandler->killAllActions(); + eventHandler->KillAllActions(); } /** @@ -515,8 +511,8 @@ void GraphicView::killAllActions() */ void GraphicView::back() { - if (eventHandler && eventHandler->hasAction()) - eventHandler->back(); + if (eventHandler && eventHandler->HasAction()) + eventHandler->Back(); else if (DIALOGFACTORY) DIALOGFACTORY->requestPreviousMenu(); } @@ -526,8 +522,8 @@ void GraphicView::back() */ void GraphicView::enter() { - if (eventHandler && eventHandler->hasAction()) - eventHandler->enter(); + if (eventHandler && eventHandler->HasAction()) + eventHandler->Enter(); } /** @@ -537,7 +533,7 @@ void GraphicView::enter() void GraphicView::mousePressEvent(QMouseEvent * e) { if (eventHandler) - eventHandler->mousePressEvent(e); + eventHandler->MousePressEvent(e); } /** @@ -551,9 +547,9 @@ void GraphicView::mouseReleaseEvent(QMouseEvent * 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 { @@ -572,10 +568,10 @@ void GraphicView::mouseMoveEvent(QMouseEvent * e) { 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"); @@ -588,17 +584,18 @@ void GraphicView::mouseMoveEvent(QMouseEvent * e) 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"); @@ -611,7 +608,7 @@ void GraphicView::mouseMoveEvent(QMouseEvent * e) void GraphicView::mouseLeaveEvent() { if (eventHandler) - eventHandler->mouseLeaveEvent(); + eventHandler->MouseLeaveEvent(); } /** @@ -621,7 +618,7 @@ void GraphicView::mouseLeaveEvent() void GraphicView::mouseEnterEvent() { if (eventHandler) - eventHandler->mouseEnterEvent(); + eventHandler->MouseEnterEvent(); } /** @@ -631,7 +628,7 @@ void GraphicView::mouseEnterEvent() void GraphicView::keyPressEvent(QKeyEvent * e) { if (eventHandler) - eventHandler->keyPressEvent(e); + eventHandler->KeyPressEvent(e); } /** @@ -641,7 +638,7 @@ void GraphicView::keyPressEvent(QKeyEvent * e) void GraphicView::keyReleaseEvent(QKeyEvent * e) { if (eventHandler) - eventHandler->keyReleaseEvent(e); + eventHandler->KeyReleaseEvent(e); } /** @@ -650,7 +647,7 @@ void GraphicView::keyReleaseEvent(QKeyEvent * e) void GraphicView::commandEvent(CommandEvent * e) { if (eventHandler) - eventHandler->commandEvent(e); + eventHandler->HandleCommandEvent(this, e); } /** @@ -659,7 +656,7 @@ void GraphicView::commandEvent(CommandEvent * e) void GraphicView::enableCoordinateInput() { if (eventHandler) - eventHandler->enableCoordinateInput(); + eventHandler->EnableCoordinateInput(); } /** @@ -668,7 +665,7 @@ void GraphicView::enableCoordinateInput() void GraphicView::disableCoordinateInput() { if (eventHandler) - eventHandler->disableCoordinateInput(); + eventHandler->DisableCoordinateInput(); } /** @@ -686,6 +683,7 @@ void GraphicView::zoomIn(double f, const Vector & center) return; Vector c = center; + if (c.valid == false) c = toGraph(Vector(getWidth() / 2, getHeight() / 2)); @@ -2096,6 +2094,8 @@ void GraphicView::setDefaultSnapMode(RS2::SnapMode sm) { defaultSnapMode = sm; +// Don't need this shiaut anymore +#if 0 if (eventHandler) eventHandler->setSnapMode(sm); @@ -2104,6 +2104,7 @@ void GraphicView::setDefaultSnapMode(RS2::SnapMode sm) //us up, hm notwithstanding. [and it does. :-)] //hm. snapper.setSnapMode(sm); +#endif } /** @@ -2113,8 +2114,11 @@ void GraphicView::setSnapRestriction(RS2::SnapRestriction sr) { defaultSnapRes = sr; +// Don't need this shiaut anymore +#if 0 if (eventHandler != NULL) eventHandler->setSnapRestriction(sr); +#endif } /** @@ -2397,6 +2401,17 @@ Entity * GraphicView::CatchEntity(QMouseEvent * e, RS2::ResolveLevel level) 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. * @@ -2617,17 +2632,6 @@ void Snapper::finish() 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) {