src/actions/actionsetsnapmode.h \
src/actions/actionsetsnaprestriction.h \
src/actions/actionsnapintersectionmanual.h \
- src/actions/actiontoolregeneratedimensions.h \
src/actions/actionzoomauto.h \
src/actions/actionzoomautoy.h \
src/actions/actionzoomin.h \
src/actions/actionsetsnapmode.cpp \
src/actions/actionsetsnaprestriction.cpp \
src/actions/actionsnapintersectionmanual.cpp \
- src/actions/actiontoolregeneratedimensions.cpp \
src/actions/actionzoomauto.cpp \
src/actions/actionzoomautoy.cpp \
src/actions/actionzoomin.cpp \
* Constructor.
*/
ActionDefault::ActionDefault(RS_EntityContainer & container,
- GraphicView & graphicView): ActionInterface("Default",
- container, graphicView)
+ GraphicView & graphicView):
+ ActionInterface("Default", container, graphicView)
{
RS_DEBUG->print("ActionDefault::ActionDefault");
//hm.
- graphicView.snapper.SetVisible();
- graphicView.preview.SetVisible();
+// graphicView.snapper.SetVisible();
+// graphicView.preview.SetVisible();
RS_DEBUG->print("ActionDefault::ActionDefault: OK");
}
graphicView->snapper.setSnapRestriction(RS2::RestrictNothing);
restrBak = RS2::RestrictNothing;
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-//hm. Nope.
-// graphicView->snapper.SetVisible();
-// graphicView->preview.SetVisible();
RS_DEBUG->print("ActionDefault::init: OK");
}
RS_DEBUG->print("ActionDrawLine::ActionDrawLine");
reset();
//hm.
- graphicView.snapper.SetContainer(&container);
- graphicView.snapper.SetGraphicView(&graphicView);
- graphicView.snapper.SetVisible();
- graphicView.preview.SetVisible();
+// graphicView.snapper.SetContainer(&container);
+// graphicView.snapper.SetGraphicView(&graphicView);
+// graphicView.snapper.SetVisible();
+// graphicView.preview.SetVisible();
RS_DEBUG->print("ActionDrawLine::ActionDrawLine: OK");
}
void ActionDrawLine::init(int status)
{
RS_DEBUG->print("ActionDrawLine::init");
-// ActionInterface::init(status);
ActionInterface::init(status);
reset();
RS_DEBUG->print("ActionDrawLine::init: OK");
}
else if (e->button() == Qt::RightButton)
{
- if (getStatus() == 0)
- {
- graphicView->snapper.SetVisible(false);
- graphicView->preview.SetVisible(false);
- }
+// if (getStatus() == 0)
+// {
+// graphicView->snapper.SetVisible(false);
+// graphicView->preview.SetVisible(false);
+// }
init(getStatus() - 1);
}
void ActionDrawLine::showOptions()
{
RS_DEBUG->print("ActionDrawLine::showOptions");
-// ActionInterface::showOptions();
ActionInterface::showOptions();
RS_DIALOGFACTORY->requestOptions(this, true);
RS_DEBUG->print("ActionDrawLine::showOptions: OK");
void ActionDrawLine::hideOptions()
{
-// ActionInterface::hideOptions();
ActionInterface::hideOptions();
RS_DIALOGFACTORY->requestOptions(this, false);
}
#include "graphicview.h"
#include "rs_preview.h"
-ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
- ActionInterface("Draw lines with given angle",
- container, graphicView)
+ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container,
+ GraphicView & graphicView, double a, bool fa):
+ ActionInterface("Draw lines with given angle", container, graphicView),
+ pos(Vector(false)), angle(a), length(1.0), fixedAngle(fa), snpPoint(0)
{
- this->angle = angle;
- length = 1.0;
- snpPoint = 0;
- this->fixedAngle = fixedAngle;
- pos = Vector(false);
reset();
+ //hm.
+// graphicView.snapper.SetContainer(&container);
+// graphicView.snapper.SetGraphicView(&graphicView);
+// graphicView.snapper.SetVisible();
+// graphicView.preview.SetVisible();
}
ActionDrawLineAngle::~ActionDrawLineAngle()
void ActionDrawLineAngle::init(int status)
{
ActionInterface::init(status);
-
reset();
}
void ActionDrawLineAngle::trigger()
{
ActionInterface::trigger();
-
preparePreview();
RS_Line * line = new RS_Line(container, data);
line->setLayerToActive();
line->setPenToActive();
container->addEntity(line);
- // upd. undo list:
+ // Update undo list:
if (document)
{
document->startUndoCycle();
document->endUndoCycle();
}
- deleteSnapper();
+// deleteSnapper();
graphicView->moveRelativeZero(Vector(0.0, 0.0));
graphicView->drawEntity(line);
graphicView->moveRelativeZero(data.startpoint);
- RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d",
- line->getId());
+ graphicView->redraw();
+ RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d", line->getId());
}
void ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e)
if (getStatus() == SetPos)
{
pos = snapPoint(e);
- deletePreview();
- clearPreview();
- preparePreview();
+// deletePreview();
+// clearPreview();
+// preparePreview();
// preview->addEntity(new RS_Line(preview, data));
- drawPreview();
+// drawPreview();
+ preparePreview();
+ graphicView->preview.clear();
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data));
}
+ graphicView->redraw();
RS_DEBUG->print("ActionDrawLineAngle::mouseMoveEvent end");
}
{
if (getStatus() == SetPos)
{
- Vector ce(snapPoint(e));
+// Vector ce(snapPoint(e));
+ Vector ce(graphicView->snapper.snapPoint(e));
coordinateEvent(&ce);
}
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+// deletePreview();
+// deleteSnapper();
init(getStatus() - 1);
}
+
+ graphicView->preview.clear(); // Remove entities from container
+ graphicView->redraw();
}
void ActionDrawLineAngle::preparePreview()
void ActionDrawLineAngle::coordinateEvent(Vector * e)
{
- if (e == NULL)
+ if (!e)
return;
switch (getStatus())
switch (getStatus())
{
case SetPos:
-
if (!fixedAngle && checkCommand("angle", c))
{
- deleteSnapper();
- deletePreview();
- clearPreview();
+// deleteSnapper();
+// deletePreview();
+// clearPreview();
setStatus(SetAngle);
}
else if (checkCommand("length", c))
{
- deleteSnapper();
- deletePreview();
- clearPreview();
+// deleteSnapper();
+// deletePreview();
+// clearPreview();
setStatus(SetLength);
}
break;
- case SetAngle: {
+ case SetAngle:
+ {
bool ok;
double a = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
angle = RS_Math::deg2rad(a);
else
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
RS_DIALOGFACTORY->requestOptions(this, true, true);
setStatus(SetPos);
}
- break;
+ break;
- case SetLength: {
+ case SetLength:
+ {
bool ok;
double l = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
length = l;
else
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
RS_DIALOGFACTORY->requestOptions(this, true, true);
setStatus(SetPos);
}
- break;
+ break;
default:
break;
switch (getStatus())
{
case SetPos:
-
if (!fixedAngle)
cmd += command("angle");
+
cmd += command("length");
break;
switch (getStatus())
{
case SetPos:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
- tr("Cancel"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"), tr("Cancel"));
break;
case SetAngle:
void ActionDrawLineAngle::showOptions()
{
ActionInterface::showOptions();
-
RS_DIALOGFACTORY->requestOptions(this, true);
}
void ActionDrawLineAngle::hideOptions()
{
ActionInterface::hideOptions();
-
RS_DIALOGFACTORY->requestOptions(this, false);
}
void ActionDrawLineAngle::setSnapPoint(int sp)
{
snpPoint = sp;
+// graphicView->redraw();
}
int ActionDrawLineAngle::getSnapPoint()
void ActionDrawLineAngle::setAngle(double a)
{
angle = a;
+// graphicView->redraw();
}
double ActionDrawLineAngle::getAngle()
void ActionDrawLineAngle::setLength(double l)
{
length = l;
+// graphicView->redraw();
}
double ActionDrawLineAngle::getLength()
SetLength /**< Setting length in the command line. */
};
- ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+ ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView,
+ double angle = 0.0, bool fixedAngle = false);
~ActionDrawLineAngle();
virtual RS2::ActionType rtti();
bool hasFixedAngle();
protected:
- /**
- * Line data defined so far.
- */
+ /** Line data defined so far. */
RS_LineData data;
- /**
- * Position.
- */
+ /** Position. */
Vector pos;
- /**
- * Line angle.
- */
+ /** Line angle. */
double angle;
- /**
- * Line length.
- */
+ /** Line length. */
double length;
- /**
- * Is the angle fixed?
- */
+ /** Is the angle fixed? */
bool fixedAngle;
- /**
- * Snap point (start, middle, end).
- */
+ /** Snap point (start, middle, end). */
int snpPoint;
};
#include "graphicview.h"
#include "rs_preview.h"
-ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container, GraphicView & graphicView):
- ActionInterface("Draw Bisectors", container, graphicView)
+ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container,
+ GraphicView & graphicView):
+ ActionInterface("Draw Bisectors", container, graphicView),
+ bisector(NULL), line1(NULL), line2(NULL), length(10.0), number(1),
+ coord1(Vector(false)), coord2(Vector(false)), lastStatus(SetLine1)
{
- bisector = NULL;
- length = 10.0;
- line1 = NULL;
- line2 = NULL;
- number = 1;
- coord1 = Vector(false);
- coord2 = Vector(false);
- lastStatus = SetLine1;
+ graphicView.snapper.SetVisible(false);
}
ActionDrawLineBisector::~ActionDrawLineBisector()
void ActionDrawLineBisector::trigger()
{
ActionInterface::trigger();
-
- //if (bisector!=NULL) {
RS_Creation creation(container, graphicView);
- creation.createBisector(coord1,
- coord2,
- length,
- number,
- line1,
- line2);
- /*RS_Entity* newEntity = NULL;
-
- newEntity = new RS_Line(container,
- bisector->getData());
-
- if (newEntity!=NULL) {
- newEntity->setLayerToActive();
- newEntity->setPenToActive();
- container->addEntity(newEntity);
-
- // upd. undo list:
- if (document!=NULL) {
- document->startUndoCycle();
- document->addUndoable(newEntity);
- document->endUndoCycle();
- }
- graphicView->drawEntity(newEntity);
- setStatus(SetLine1);
- }
- //reset();
- delete bisector;
- bisector = NULL;
- */
- /*} else {
- RS_DEBUG->print("ActionDrawLineBisector::trigger:"
- " Entity is NULL\n");
- }*/
+ creation.createBisector(coord1, coord2, length, number, line1, line2);
+ graphicView->redraw();
}
void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent begin");
Vector mouse = Vector(graphicView->toGraphX(e->x()),
- graphicView->toGraphY(e->y()));
+ graphicView->toGraphY(e->y()));
switch (getStatus())
{
if (en && en->rtti() == RS2::EntityLine)
{
-// line2 = (RS_Line *)en;
-//
-// deletePreview();
-// clearPreview();
-//
-// RS_Creation creation(preview, NULL, false);
-// creation.createBisector(coord1, coord2, length, number, line1, line2);
-// drawPreview();
+ line2 = (RS_Line *)en;
+ graphicView->preview.clear();
+ RS_Creation creation(&(graphicView->preview), NULL, false);
+ creation.createBisector(coord1, coord2, length, number, line1, line2);
}
}
break;
break;
}
+ graphicView->redraw();
RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent end");
}
{
if (e->button() == Qt::RightButton)
{
- deletePreview();
- clearPreview();
+// deletePreview();
+// clearPreview();
init(getStatus() - 1);
}
else
coord1 = mouse;
RS_Entity * en = catchEntity(e, RS2::ResolveAll);
- if (en != NULL && en->rtti() == RS2::EntityLine)
+ if (en && en->rtti() == RS2::EntityLine)
+ {
line1 = (RS_Line *)en;
+ setStatus(SetLine2);
+ }
}
- setStatus(SetLine2);
break;
case SetLine2:
if (checkCommand("length", c))
{
- deleteSnapper();
- deletePreview();
- clearPreview();
+// deleteSnapper();
+// deletePreview();
+// clearPreview();
setStatus(SetLength);
}
else if (checkCommand("number", c))
{
- deleteSnapper();
- deletePreview();
- clearPreview();
+// deleteSnapper();
+// deletePreview();
+// clearPreview();
setStatus(SetNumber);
}
+
break;
- case SetLength: {
+ case SetLength:
+ {
bool ok;
double l = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
length = l;
else
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
RS_DIALOGFACTORY->requestOptions(this, true, true);
setStatus(lastStatus);
}
- break;
+ break;
- case SetNumber: {
+ case SetNumber:
+ {
bool ok;
int n = (int)RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
number = n;
else
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
RS_DIALOGFACTORY->requestOptions(this, true, true);
setStatus(lastStatus);
}
- break;
+ break;
default:
break;
switch (getStatus())
{
case SetLine1:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
- tr("Cancel"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"), tr("Cancel"));
break;
case SetLine2:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
- tr("Back"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"), tr("Back"));
break;
case SetLength:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"),
- tr("Back"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), tr("Back"));
break;
case SetNumber:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"),
- tr("Back"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), tr("Back"));
break;
default:
void ActionDrawLineBisector::showOptions()
{
ActionInterface::showOptions();
-
RS_DIALOGFACTORY->requestOptions(this, true);
}
void ActionDrawLineBisector::hideOptions()
{
ActionInterface::hideOptions();
-
RS_DIALOGFACTORY->requestOptions(this, false);
}
}
// upd. view
- deleteSnapper();
+// deleteSnapper();
graphicView->moveRelativeZero(Vector(0.0, 0.0));
for(int i=0; i<4; i++)
{
graphicView->drawEntity(line[i]);
- RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d",
- line[i]->getId());
+ RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", line[i]->getId());
}
+
graphicView->moveRelativeZero(corner2);
+ graphicView->redraw();
}
void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e)
if (getStatus() == SetCorner2 && corner1.valid)
{
corner2 = mouse;
- deletePreview();
- clearPreview();
-
- preparePreview();
+// deletePreview();
+// clearPreview();
+// preparePreview();
// for(int i=0; i<4; i++)
// preview->addEntity(new RS_Line(preview, data[i]));
- drawPreview();
+// drawPreview();
+ preparePreview();
+ graphicView->preview.clear();
+
+ for(int i=0; i<4; i++)
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data[i]));
}
+ graphicView->redraw();
RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end");
}
{
if (e->button() == Qt::LeftButton)
{
- Vector ce(snapPoint(e));
+// Vector ce(snapPoint(e));
+ Vector ce(graphicView->snapper.snapPoint(e));
coordinateEvent(&ce);
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+// deletePreview();
+// deleteSnapper();
init(getStatus() - 1);
}
+
+ graphicView->preview.clear(); // Remove entities from container
+ graphicView->redraw();
}
void ActionDrawLineRectangle::preparePreview()
void ActionDrawLineRectangle::coordinateEvent(Vector * e)
{
- if (e == NULL)
+ if (!e)
return;
Vector mouse = *e;
if (checkCommand("help", c))
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
void ActionDrawLineRectangle::updateMouseButtonHints()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
switch (getStatus())
{
case SetCorner1:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
- tr("Cancel"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), tr("Cancel"));
break;
case SetCorner2:
- RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
- tr("Back"));
+ RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), tr("Back"));
break;
default:
void ActionDrawLineRectangle::updateToolBar()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
if (!isFinished())
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
}
}
-
-
virtual void updateToolBar();
protected:
- /**
- * Line data for the 4 lines.
- */
+ /** Line data for the 4 lines. */
RS_LineData data[4];
- /**
- * 1st corner.
- */
+ /** 1st corner. */
Vector corner1;
- /**
- * 2nd corner.
- */
+ /** 2nd corner. */
Vector corner2;
};
+++ /dev/null
-// actiontoolregeneratedimensions.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 06/05/2010 Added this text. :-)
-//
-
-#include "actiontoolregeneratedimensions.h"
-
-#include "rs_debug.h"
-#include "rs_dialogfactory.h"
-#include "rs_dimension.h"
-#include "graphicview.h"
-#include "rs_information.h"
-
-ActionToolRegenerateDimensions::ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView):
- ActionInterface("Tool Regen Dim", container, graphicView)
-{
-}
-
-ActionToolRegenerateDimensions::~ActionToolRegenerateDimensions()
-{
-}
-
-void ActionToolRegenerateDimensions::init(int status)
-{
- ActionInterface::init(status);
- trigger();
-}
-
-void ActionToolRegenerateDimensions::trigger()
-{
- RS_DEBUG->print("ActionToolRegenerateDimensions::trigger()");
-
- int num = 0;
-
- for(RS_Entity * e = container->firstEntity(RS2::ResolveNone);
- e != NULL; e = container->nextEntity(RS2::ResolveNone))
- {
- if (RS_Information::isDimension(e->rtti()) && e->isVisible())
- {
- num++;
-
- if (((RS_Dimension *)e)->getLabel() == ";;")
- ((RS_Dimension *)e)->setLabel("");
-
- ((RS_Dimension *)e)->update(true);
- }
- }
-
- if (num > 0)
- {
- graphicView->redraw();
- RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
- }
- else
- RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
-
- finish();
-}
-
-
+++ /dev/null
-#ifndef __ACTIONTOOLREGENERATEDIMENSIONS_H__
-#define __ACTIONTOOLREGENERATEDIMENSIONS_H__
-
-#include "actioninterface.h"
-
-/**
- * This action class can handle user events to regenerate dimensions.
- *
- * @author James Hammons
- * @author Andrew Mustun
- */
-class ActionToolRegenerateDimensions: public ActionInterface
-{
- public:
- ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView);
- ~ActionToolRegenerateDimensions();
-
- virtual void init(int status = 0);
- virtual void trigger();
-};
-
-#endif // __ACTIONTOOLREGENERATEDIMENSIONS_H__
ActionZoomPan::ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView):
ActionInterface("Zoom Pan", container, graphicView)
{
+ graphicView.snapper.SetVisible(false);
+ graphicView.preview.SetVisible(false);
}
ActionZoomPan::~ActionZoomPan()
void ActionZoomPan::mousePressEvent(QMouseEvent * e)
{
- if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton)
+ if (e->button() == Qt::LeftButton || e->button() == Qt::MidButton)
{
x1 = e->x();
y1 = e->y();
void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
{
- if (e->button() == Qt::RightButton)
+ // Right button? Why?
+ // Is this a regular tool? Is this why? (yup, it is. but lame nonetheless.)
+ // It doesn't revert the cursor correctly if this is not in...
+ // So... We need to fix this... [DONE]
+ /*if (e->button() == Qt::RightButton)
init(getStatus() - 1);
- else if (e->button() == Qt::MidButton)
+ else*/ if (e->button() == Qt::MidButton || e->button() == Qt::RightButton)
init(-1);
else
- setStatus(0);
+ setStatus(0); // Qt::LeftButton
}
void ActionZoomPan::updateMouseCursor()
// expunged, by Grabthar's Hammer!
graphicView->snapper.SetContainer(container);
graphicView->snapper.SetGraphicView(graphicView); // <-- THIS is what I mean! INSANE!
+ graphicView->snapper.SetVisible();
+ graphicView->preview.SetVisible();
RS_DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name);
}
updateMouseCursor();
updateToolBar();
}
+ else // status < 0, e.g. this action is finished
+ {
+ graphicView->snapper.SetVisible(false);
+ graphicView->preview.SetVisible(false);
+ }
}
/**
* @return Pointer to the first bisector created or NULL if no bisectors
* were created.
*/
-RS_Line* RS_Creation::createBisector(const Vector& coord1,
- const Vector& coord2,
- double length,
- int num,
- RS_Line* l1,
- RS_Line* l2) {
+RS_Line * RS_Creation::createBisector(const Vector & coord1, const Vector & coord2,
+ double length, int num, RS_Line * l1, RS_Line * l2)
+{
+ // check given entities:
+ if (!l1 || !l2 || l1->rtti() != RS2::EntityLine || l2->rtti() != RS2::EntityLine)
+ return NULL;
- VectorSolutions sol;
+ // intersection between entities:
+ VectorSolutions sol = RS_Information::getIntersection(l1, l2, false);
+ Vector inters = sol.get(0);
- // check given entities:
- if (l1==NULL || l2==NULL ||
- l1->rtti()!=RS2::EntityLine || l2->rtti()!=RS2::EntityLine) {
- return NULL;
- }
+ if (!inters.valid)
+ return NULL;
- // intersection between entities:
- sol = RS_Information::getIntersection(l1, l2, false);
- Vector inters = sol.get(0);
- if (inters.valid==false) {
- return NULL;
- }
+ double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1));
+ double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2));
+ double angleDiff = RS_Math::getAngleDifference(angle1, angle2);
- double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1));
- double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2));
- double angleDiff = RS_Math::getAngleDifference(angle1, angle2);
- if (angleDiff>M_PI) {
- angleDiff = angleDiff - 2*M_PI;
- }
- RS_Line* ret = NULL;
+ if (angleDiff > M_PI)
+ angleDiff = angleDiff - 2 * M_PI;
- if (document!=NULL && handleUndo) {
- document->startUndoCycle();
- }
+ RS_Line * ret = NULL;
- for (int n=1; n<=num; ++n) {
+ if (document && handleUndo)
+ document->startUndoCycle();
- double angle = angle1 +
- (angleDiff / (num+1) * n);
+ for(int n=1; n<=num; n++)
+ {
+ double angle = angle1 + (angleDiff / (num + 1) * n);
+ Vector v;
+ v.setPolar(length, angle);
+ RS_LineData d = RS_LineData(inters, inters + v);
+ RS_Line * newLine = new RS_Line(container, d);
- RS_LineData d;
- Vector v;
+ if (container)
+ {
+ newLine->setLayerToActive();
+ newLine->setPenToActive();
+ container->addEntity(newLine);
+ }
- Vector c;
- v.setPolar(length, angle);
- d = RS_LineData(inters, inters + v);
+ if (document && handleUndo)
+ document->addUndoable(newLine);
- RS_Line* newLine = new RS_Line(container, d);
- if (container!=NULL) {
- newLine->setLayerToActive();
- newLine->setPenToActive();
- container->addEntity(newLine);
- }
- if (document!=NULL && handleUndo) {
- document->addUndoable(newLine);
- }
- if (graphicView!=NULL) {
- graphicView->drawEntity(newLine);
- }
- if (ret==NULL) {
- ret = newLine;
- }
- }
- if (document!=NULL && handleUndo) {
- document->endUndoCycle();
- }
+ if (graphicView)
+ graphicView->drawEntity(newLine);
- return ret;
+ if (!ret)
+ ret = newLine;
+ }
+
+ if (document && handleUndo)
+ document->endUndoCycle();
+
+ return ret;
}
QList<RS_FilterInterface *> getFilterList();
RS_FilterInterface * getImportFilter(RS2::FormatType t);
RS_FilterInterface * getExportFilter(RS2::FormatType t);
-
bool fileImport(Drawing & graphic, const QString & file,
RS2::FormatType type = RS2::FormatUnknown);
-
bool fileExport(Drawing & graphic, const QString & file,
RS2::FormatType type = RS2::FormatUnknown);
-
RS2::FormatType detectFormat(const QString & file);
protected:
void LineAngleOptions::setAction(ActionInterface * a, bool update)
{
- if (a != NULL && a->rtti() == RS2::ActionDrawLineAngle)
+ if (a && a->rtti() == RS2::ActionDrawLineAngle)
{
action = (ActionDrawLineAngle *)a;
leAngle->hide();
}
- QString sa;
- QString sl;
+ QString sa, sl;
int sp;
// settings from action:
void LineAngleOptions::updateAngle(const QString & a)
{
- if (action != NULL && !action->hasFixedAngle())
+ if (action && !action->hasFixedAngle())
action->setAngle(RS_Math::deg2rad(RS_Math::eval(a)));
}
void LineAngleOptions::updateLength(const QString & l)
{
- if (action != NULL)
+ if (action)
action->setLength(RS_Math::eval(l));
}
void LineAngleOptions::updateSnapPoint(int sp)
{
- if (action != NULL)
+ if (action)
action->setSnapPoint(sp);
}
#include "actionsetsnapmode.h"
#include "actionsetsnaprestriction.h"
#include "actionsnapintersectionmanual.h"
-#include "actiontoolregeneratedimensions.h"
#include "actionzoomauto.h"
#include "actionzoomin.h"
#include "actionzoompan.h"
// Tool actions:
//
- case RS2::ActionToolRegenerateDimensions:
- a = new ActionToolRegenerateDimensions(*doc, *gv);
- break;
+//no
+// case RS2::ActionToolRegenerateDimensions:
+// a = new ActionToolRegenerateDimensions(*doc, *gv);
+// break;
// Zooming actions:
//