// Who When What
// --- ---------- -----------------------------------------------------------
// JLH 06/03/2010 Added this text. :-)
+// JLH 09/17/2010 Fixed preview/snapper rendering.
//
#include "actiondrawarctangential.h"
#include "graphicview.h"
#include "preview.h"
-ActionDrawArcTangential::ActionDrawArcTangential(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw arcs tangential",
- container, graphicView)
+ActionDrawArcTangential::ActionDrawArcTangential(EntityContainer & container, GraphicView & graphicView):
+ ActionInterface("Draw arcs tangential", container, graphicView)
{
reset();
}
if (point.valid == false || baseEntity == NULL)
{
- RS_DEBUG->print("ActionDrawArcTangential::trigger: "
+ DEBUG->print("ActionDrawArcTangential::trigger: "
"conditions not met");
return;
}
preparePreview();
- RS_Arc * arc = new RS_Arc(container, data);
+ Arc * arc = new Arc(container, data);
arc->setLayerToActive();
arc->setPenToActive();
container->addEntity(arc);
// upd. undo list:
- if (document != NULL)
+ if (document)
{
document->startUndoCycle();
document->addUndoable(arc);
document->endUndoCycle();
}
- deleteSnapper();
- graphicView->moveRelativeZero(Vector(0.0, 0.0));
- graphicView->drawEntity(arc);
+// deleteSnapper();
+// graphicView->moveRelativeZero(Vector(0.0, 0.0));
+// graphicView->drawEntity(arc);
graphicView->moveRelativeZero(arc->getCenter());
- drawSnapper();
-
+// drawSnapper();
+ graphicView->redraw(); //hm.
setStatus(SetBaseEntity);
reset();
}
void ActionDrawArcTangential::preparePreview()
{
- if (baseEntity != NULL && point.valid)
+ if (baseEntity && point.valid)
{
Vector startPoint;
double direction;
if (isStartPoint)
{
startPoint = baseEntity->getStartpoint();
- direction = RS_Math::correctAngle(baseEntity->getDirection1() + M_PI);
+ direction = Math::correctAngle(baseEntity->getDirection1() + M_PI);
}
else
{
startPoint = baseEntity->getEndpoint();
- direction = RS_Math::correctAngle(baseEntity->getDirection2() + M_PI);
+ direction = Math::correctAngle(baseEntity->getDirection2() + M_PI);
}
- RS_Arc arc(NULL, RS_ArcData());
+ Arc arc(NULL, ArcData());
bool suc = arc.createFrom2PDirectionRadius(startPoint, point, direction, data.radius);
if (suc)
if (data.isValid())
{
-// RS_Arc * arc = new RS_Arc(preview, data);
+// Arc * arc = new Arc(preview, data);
// deletePreview();
// clearPreview();
// preview->addEntity(arc);
// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addEntity(new Arc(&(graphicView->preview), data));
+ graphicView->redraw();
}
break;
case SetBaseEntity:
{
Vector coord = graphicView->toGraph(e->x(), e->y());
- RS_Entity * entity = catchEntity(coord, RS2::ResolveAll);
+ Entity * entity = catchEntity(coord, RS2::ResolveAll);
- if (entity != NULL)
+ if (entity)
{
if (entity->isAtomic())
{
- baseEntity = (RS_AtomicEntity *)entity;
+ baseEntity = (AtomicEntity *)entity;
if (baseEntity->getStartpoint().distanceTo(coord)
< baseEntity->getEndpoint().distanceTo(coord))
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+// deletePreview();
+ // deleteSnapper();
init(getStatus() - 1);
+ graphicView->redraw(); //hm.
}
}
}
}
-void ActionDrawArcTangential::commandEvent(RS_CommandEvent * e)
+void ActionDrawArcTangential::commandEvent(CommandEvent * e)
{
QString c = e->getCommand().toLower();
if (checkCommand("help", c))
{
- RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
}
{
ActionInterface::showOptions();
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->requestOptions(this, true);
+ if (DIALOGFACTORY != NULL)
+ DIALOGFACTORY->requestOptions(this, true);
updateMouseButtonHints();
}
{
ActionInterface::hideOptions();
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->requestOptions(this, false);
+ if (DIALOGFACTORY != NULL)
+ DIALOGFACTORY->requestOptions(this, false);
}
void ActionDrawArcTangential::updateMouseButtonHints()
switch (getStatus())
{
case SetBaseEntity:
- RS_DIALOGFACTORY->updateMouseWidget(
+ DIALOGFACTORY->updateMouseWidget(
tr("Specify base entity"),
tr("Cancel"));
break;
case SetEndAngle:
- RS_DIALOGFACTORY->updateMouseWidget(
+ DIALOGFACTORY->updateMouseWidget(
tr("Specify end angle"), tr("Back"));
break;
default:
- RS_DIALOGFACTORY->updateMouseWidget("", "");
+ DIALOGFACTORY->updateMouseWidget("", "");
break;
}
}
void ActionDrawArcTangential::updateToolBar()
{
if (!isFinished())
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
else
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
+ DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs);
}
void ActionDrawArcTangential::setRadius(double r)