container, graphicView)
{
RS_DEBUG->print("ActionDefault::ActionDefault");
+ //hm.
+ graphicView.snapper.SetVisible();
+ graphicView.preview.SetVisible();
RS_DEBUG->print("ActionDefault::ActionDefault: OK");
}
ActionInterface::init(status);
v1 = v2 = Vector(false);
-// snapMode = RS2::SnapFree;
-// snapRes = RS2::RestrictNothing;
+ graphicView->snapper.setSnapMode(RS2::SnapFree);
+ 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");
}
{
if (e->key() == Qt::Key_Shift)
{
-// restrBak = snapRes;
-// setSnapRestriction(RS2::RestrictOrthogonal);
+ restrBak = graphicView->snapper.getSnapRestriction();
+ graphicView->snapper.setSnapRestriction(RS2::RestrictOrthogonal);
}
}
void ActionDefault::keyReleaseEvent(QKeyEvent * e)
{
-// if (e->key() == Qt::Key_Shift)
-// setSnapRestriction(restrBak);
+ if (e->key() == Qt::Key_Shift)
+ graphicView->snapper.setSnapRestriction(restrBak);
}
void ActionDefault::mouseMoveEvent(QMouseEvent * e)
if (ref.valid && graphicView->toGuiDX(dist) < 8)
{
- RS_DEBUG->print("ActionDefault::mouseMoveEvent: "
- "moving reference point");
+ RS_DEBUG->print("ActionDefault::mouseMoveEvent: moving reference point");
setStatus(MovingRef);
v1 = ref;
graphicView->moveRelativeZero(v1);
if (en && en->isSelected())
{
- RS_DEBUG->print("ActionDefault::mouseMoveEvent: "
- "moving entity");
+ RS_DEBUG->print("ActionDefault::mouseMoveEvent: moving entity");
setStatus(Moving);
v1 = en->getNearestRef(v1);
graphicView->moveRelativeZero(v1);
case MovingRef:
v2 = snapPoint(e);
-// deletePreview();
// clearPreview();
// preview->addSelectionFrom(*container);
// preview->moveRef(v1, v2 - v1);
// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addSelectionFrom(*container);
+ graphicView->preview.moveRef(v1, v2 -v1);
+ graphicView->snapper.SetVisible();
+ graphicView->preview.SetVisible();
+ graphicView->redraw();
break;
case Moving:
v2 = snapPoint(e);
-// deletePreview();
// clearPreview();
// preview->addSelectionFrom(*container);
// preview->move(v2 - v1);
// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addSelectionFrom(*container);
+ graphicView->preview.move(v2 -v1);
+ graphicView->snapper.SetVisible();
+ graphicView->preview.SetVisible();
+ graphicView->redraw();
break;
case SetCorner2:
{
v2 = mouse;
-// deletePreview();
-// clearPreview();
+ graphicView->preview.clear();
-// preview->addEntity(new RS_Line(preview,
-// RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
-// preview->addEntity(new RS_Line(preview,
-// RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
-// preview->addEntity(new RS_Line(preview,
-// RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
-// preview->addEntity(new RS_Line(preview,
-// RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
-// drawPreview();
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+ RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+ RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+ RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+ RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));
+
+ graphicView->preview.SetVisible();
+ graphicView->redraw();
}
default:
else
setStatus(SetCorner2);
}
- break;
+ break;
case SetCorner2:
{
// deleteSnapper();
// deletePreview();
// clearPreview();
+ graphicView->preview.SetVisible(false);
bool cross = (v2.y > v1.y);
RS_Selection s(*container, graphicView);
setStatus(Neutral);
e->accept();
}
- break;
+ break;
default:
+ // Was either moving entity or point, so clear that shiatsu
+ graphicView->snapper.SetVisible(false);
+ graphicView->preview.SetVisible(false);
+ graphicView->redraw();
break;
}
}
void ActionDimension::reset()
{
data = RS_DimensionData(Vector(false), Vector(false), RS2::VAlignMiddle,
- RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
+ RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
diameter = false;
}
{
ActionInterface::hideOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, false);
}
{
ActionInterface::showOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
}
void ActionDimension::updateToolBar()
{
- if (RS_DIALOGFACTORY != NULL)
- {
- if (!isFinished())
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
- else
- RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
- }
+ if (!RS_DIALOGFACTORY)
+ return;
+
+ if (!isFinished())
+ RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
+ else
+ RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
}
QString ActionDimension::getText()
/*static*/ bool ActionDimension::isDimensionAction(RS2::ActionType type)
{
return (type == RS2::ActionDimAligned
- || type == RS2::ActionDimLinear
- || type == RS2::ActionDimAngular
- || type == RS2::ActionDimDiametric
- || type == RS2::ActionDimRadial);
+ || type == RS2::ActionDimLinear
+ || type == RS2::ActionDimAngular
+ || type == RS2::ActionDimDiametric
+ || type == RS2::ActionDimRadial);
}
-
* @param fixedAngle true: The user can't change the angle.
* false: The user can change the angle in a option widget.
*/
-ActionDimLinear::ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
+ActionDimLinear::ActionDimLinear(RS_EntityContainer & container,
+ GraphicView & graphicView, double angle, bool fixedAngle):
ActionDimension("Draw linear dimensions", container, graphicView)
{
edata.angle = angle;
this->fixedAngle = fixedAngle;
lastStatus = SetExtPoint1;
+ //hm. doesn't work.
+ graphicView.snapper.SetVisible();
reset();
}
ActionDimension::reset();
edata = RS_DimLinearData(Vector(false), Vector(false), (fixedAngle ? edata.angle : 0.0), 0.0);
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
}
container->addEntity(dim);
// upd. undo list:
- if (document != NULL)
+ if (document)
{
document->startUndoCycle();
document->addUndoable(dim);
document->endUndoCycle();
}
- deleteSnapper();
- Vector rz = graphicView->getRelativeZero();
- graphicView->moveRelativeZero(Vector(0.0, 0.0));
- graphicView->drawEntity(dim);
- graphicView->moveRelativeZero(rz);
- drawSnapper();
+// deleteSnapper();
+// Vector rz = graphicView->getRelativeZero();
+// graphicView->moveRelativeZero(Vector(0.0, 0.0));
+// graphicView->drawEntity(dim);
+// graphicView->moveRelativeZero(rz);
+// drawSnapper();
+ graphicView->snapper.SetVisible(false);
+ graphicView->redraw();
RS_DEBUG->print("ActionDimLinear::trigger(): dim added: %d", dim->getId());
}
Vector dirV;
dirV.setPolar(100.0, edata.angle + M_PI / 2.0);
- RS_ConstructionLine cl(
- NULL, RS_ConstructionLineData(
- edata.extensionPoint2,
- edata.extensionPoint2 + dirV));
+ RS_ConstructionLine cl(NULL, RS_ConstructionLineData(edata.extensionPoint2,
+ edata.extensionPoint2 + dirV));
- data.definitionPoint =
- cl.getNearestPointOnEntity(data.definitionPoint);
+ data.definitionPoint = cl.getNearestPointOnEntity(data.definitionPoint);
}
void ActionDimLinear::mouseMoveEvent(QMouseEvent * e)
switch (getStatus())
{
case SetExtPoint1:
+// graphicView->snapper.SetVisible();
+// graphicView->redraw();
break;
case SetExtPoint2:
if (edata.extensionPoint1.valid)
{
- deletePreview();
- clearPreview();
+// deletePreview();
+// clearPreview();
// preview->addEntity(new RS_Line(preview,
// RS_LineData(edata.extensionPoint1, mouse)));
- drawPreview();
+// drawPreview();
+ graphicView->preview.clear();
+ graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+ RS_LineData(edata.extensionPoint1, mouse)));
+ graphicView->preview.SetVisible();
+ graphicView->redraw();
}
+
break;
case SetDefPoint:
if (edata.extensionPoint1.valid && edata.extensionPoint2.valid)
{
- deletePreview();
- clearPreview();
+// deletePreview();
+// clearPreview();
data.definitionPoint = mouse;
-
- preparePreview();
-
+// preparePreview();
// RS_DimLinear * dim = new RS_DimLinear(preview, data, edata);
// dim->update();
// preview->addEntity(dim);
- drawPreview();
+// drawPreview();
+ graphicView->preview.clear();
+ preparePreview();
+ RS_DimLinear * dim = new RS_DimLinear(&(graphicView->preview), data, edata);
+ dim->update();
+ graphicView->preview.addEntity(dim);
+ graphicView->preview.SetVisible();
+ graphicView->redraw();
}
+
break;
}
{
Vector ce(snapPoint(e));
coordinateEvent(&ce);
+ graphicView->snapper.SetVisible();
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- deleteSnapper();
+ if (getStatus() == 0)
+ {
+ graphicView->preview.SetVisible(false);
+ graphicView->snapper.SetVisible(false);
+ }
+
+// deletePreview();
+// deleteSnapper();
init(getStatus() - 1);
}
}
void ActionDimLinear::coordinateEvent(Vector * e)
{
- if (e == NULL)
+ if (!e)
return;
Vector pos = *e;
if (checkCommand("help", c))
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
+ getAvailableCommands().join(", "));
return;
case SetText:
setText(c);
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
+
graphicView->enableCoordinateInput();
setStatus(lastStatus);
break;
- case SetAngle: {
+ case SetAngle:
+ {
bool ok;
double a = RS_Math::eval(c, &ok);
- if (ok == true)
+ if (ok)
setAngle(RS_Math::deg2rad(a));
- else if (RS_DIALOGFACTORY != NULL)
+ else if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
+
setStatus(lastStatus);
}
- break;
+ break;
default:
lastStatus = (Status)getStatus();
- deleteSnapper();
- deletePreview();
- clearPreview();
+// deleteSnapper();
+// deletePreview();
+// clearPreview();
if (checkCommand("text", c))
{
}
else if (!fixedAngle && (checkCommand("angle", c)))
setStatus(SetAngle);
+
break;
}
}
if (!fixedAngle)
cmd += command("angle");
+
break;
default:
void ActionDimLinear::updateMouseButtonHints()
{
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
{
switch (getStatus())
{
{
ActionInterface::showOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, true, true);
}
{
ActionInterface::hideOptions();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->requestOptions(this, false);
}
};
public:
- ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+ ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView,
+ double angle = 0.0, bool fixedAngle = false);
~ActionDimLinear();
virtual RS2::ActionType rtti();
* Is the angle fixed?
*/
bool fixedAngle;
-
/** Last status before entering text or angle. */
Status lastStatus;
};
this->name = name;
status = 0;
finished = false;
- //triggerOnResume = false;
// Graphic provides a pointer to the graphic if the entity container is a
//graphic (i.e. can also hold layers).
// Document pointer will be used for undo / redo
document = c.getDocument();
- //this->cursor = cursor;
- //setSnapMode(graphicView.getDefaultSnapMode());
+ // 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->snapper.SetContainer(container);
+ graphicView->snapper.SetGraphicView(graphicView); // <-- THIS is what I mean! INSANE!
RS_DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name);
}
RS_Block * RS_BlockList::find(const QString & name)
{
//RS_DEBUG->print("RS_BlockList::find");
- RS_Block * ret = NULL;
- for(uint i=0; i<count(); ++i)
+ for(uint i=0; i<count(); i++)
{
RS_Block * b = at(i);
if (b->getName() == name)
- {
- ret = b;
- break;
- }
+ return b;
}
- return ret;
+ return NULL;
}
/**
void RS_Dimension::updateCreateDimensionLine(const Vector & p1,
const Vector & p2, bool arrow1, bool arrow2, bool forceAutoText)
{
+#if 0
+printf("RS_Dimension::updateCreateDimensionLine()...\n");
+#endif
// text height (DIMTXT)
double dimtxt = getTextHeight();
// text distance to line (DIMGAP)
double dimgap = getDimensionLineGap();
-
// length of dimension line:
double distance = p1.distanceTo(p2);
-
// do we have to put the arrows outside of the line?
- bool outsideArrows = (distance<getArrowSize()*2.5);
-
+ bool outsideArrows = (distance < getArrowSize() * 2.5);
// arrow angles:
double arrowAngle1, arrowAngle2;
dimensionLine->setLayer(NULL);
addEntity(dimensionLine);
- if (outsideArrows == false)
+ if (!outsideArrows)
{
arrowAngle1 = dimensionLine->getAngle2();
arrowAngle2 = dimensionLine->getAngle1();
else
{
textPos = dimensionLine->getMiddlepoint();
-
Vector distV;
// rotate text so it's readable from the bottom or right (ISO)
// quadrant 1 & 4
if (corrected)
- {
distV.setPolar(dimgap + dimtxt / 2.0, dimAngle1 - M_PI / 2.0);
- }
else
- {
distV.setPolar(dimgap + dimtxt / 2.0, dimAngle1 + M_PI / 2.0);
- }
// move text away from dimension line:
textPos += distV;
textData = RS_TextData(textPos, dimtxt, 30.0, RS2::VAlignMiddle, RS2::HAlignCenter,
RS2::LeftToRight, RS2::Exact, 1.0, getLabel(), "standard", textAngle);
+#if 0
+printf("--> %s\n", getLabel().toAscii().data());
+#endif
RS_Text * text = new RS_Text(this, textData);
if (text->getUsedTextWidth() > distance)
{
- distH.setPolar(text->getUsedTextWidth() / 2.0
- + distance / 2.0 + dimgap, textAngle);
+ distH.setPolar(text->getUsedTextWidth() / 2.0 + distance / 2.0 + dimgap, textAngle);
text->move(distH);
}
{
public:
/**
- * Default constructor. Leaves the data object uninitialized.
- */
+ * Default constructor. Leaves the data object uninitialized.
+ */
RS_DimensionData() {}
/**
- * Constructor with initialisation.
- *
- * @param definitionPoint Definition point.
- * @param middleOfText Middle point of dimension text.
- * @param valign Vertical alignment.
- * @param halign Horizontal alignment.
- * @param lineSpacingStyle Line spacing style.
- * @param lineSpacingFactor Line spacing factor.
- * @param text Text string entered explicitly by user or null
- * or "<>" for the actual measurement or " " (one blank space).
- * for supressing the text.
- * @param style Dimension style name.
- * @param angle Rotation angle of dimension text away from
- * default orientation.
- */
- RS_DimensionData(const Vector& definitionPoint,
- const Vector& middleOfText,
+ * Constructor with initialisation.
+ *
+ * @param definitionPoint Definition point.
+ * @param middleOfText Middle point of dimension text.
+ * @param valign Vertical alignment.
+ * @param halign Horizontal alignment.
+ * @param lineSpacingStyle Line spacing style.
+ * @param lineSpacingFactor Line spacing factor.
+ * @param text Text string entered explicitly by user or null
+ * or "<>" for the actual measurement or " " (one blank space).
+ * for supressing the text.
+ * @param style Dimension style name.
+ * @param angle Rotation angle of dimension text away from
+ * default orientation.
+ */
+ RS_DimensionData(const Vector & definitionPoint,
+ const Vector & middleOfText,
RS2::VAlign valign,
RS2::HAlign halign,
RS2::TextLineSpacingStyle lineSpacingStyle,
/** Line spacing factor */
double lineSpacingFactor;
/**
- * Text string entered explicitly by user or null
- * or "<>" for the actual measurement or " " (one blank space)
- * for supressing the text.
- */
+ * Text string entered explicitly by user or null
+ * or "<>" for the actual measurement or " " (one blank space)
+ * for supressing the text.
+ */
QString text;
/** Dimension style name */
QString style;
void setLabel(const QString & l);
/**
- * Needs to be implemented by the dimension class to return the
- * measurement of the dimension (e.g. 10.5 or 15'14").
- */
+ * Needs to be implemented by the dimension class to return the
+ * measurement of the dimension (e.g. 10.5 or 15'14").
+ */
virtual QString getMeasuredLabel() = 0;
/**
- * Must be overwritten by implementing dimension entity class
- * to update the subentities which make up the dimension entity.
- */
+ * Must be overwritten by implementing dimension entity class
+ * to update the subentities which make up the dimension entity.
+ */
virtual void update(bool autoText = false) = 0;
void updateCreateDimensionLine(const Vector & p1, const Vector & p2,
double getExtensionLineOffset();
double getDimensionLineGap();
double getTextHeight();
- double getGraphicVariable(const QString& key, double defMM, int code);
+ double getGraphicVariable(const QString & key, double defMM, int code);
virtual double getLength();
virtual void move(Vector offset);
virtual void rotate(Vector center, double angle);
QString ret;
- if (graphic != NULL)
- {
+ if (graphic)
ret = RS_Units::formatLinear(dist, graphic->getUnit(),
graphic->getLinearFormat(), graphic->getLinearPrecision());
- }
else
- {
ret = QString("%1").arg(dist);
- }
//It's properly creating the label...
//printf("RS_DimLinear::getMeasuredLabel: label=\"%s\"\n", ret.toAscii().data());
double dimexe = getExtensionLineExtension();
RS_LineData ld;
- double extAngle = edata.angle + (M_PI/2.0);
+ double extAngle = edata.angle + (M_PI / 2.0);
// direction of dimension line
Vector dirDim;
return closestPoint;
}
+Vector RS_EntityContainer::getNearestPointOnEntity(const Vector & coord,
+ bool onEntity, double * dist, RS_Entity ** entity)
+{
+ Vector point(false);
+ RS_Entity * e = getNearestEntity(coord, dist, RS2::ResolveNone);
-Vector RS_EntityContainer::getNearestPointOnEntity(const Vector& coord,
- bool onEntity, double* dist, RS_Entity** entity) {
-
- Vector point(false);
-
- RS_Entity* e = getNearestEntity(coord, dist, RS2::ResolveNone);
-
- if (e!=NULL && e->isVisible()) {
- point = e->getNearestPointOnEntity(coord, onEntity, dist, entity);
- }
+ if (e && e->isVisible())
+ point = e->getNearestPointOnEntity(coord, onEntity, dist, entity);
- return point;
+ return point;
}
+Vector RS_EntityContainer::getNearestCenter(const Vector & coord, double * dist)
+{
+ Vector point(false);
+ RS_Entity * closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
+ if (closestEntity)
+ point = closestEntity->getNearestCenter(coord, dist);
-Vector RS_EntityContainer::getNearestCenter(const Vector& coord,
- double* dist) {
-
- Vector point(false);
- RS_Entity* closestEntity;
-
- //closestEntity = getNearestEntity(coord, NULL, RS2::ResolveAll);
- closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
-
- if (closestEntity!=NULL) {
- point = closestEntity->getNearestCenter(coord, dist);
- }
-
- return point;
+ return point;
}
+Vector RS_EntityContainer::getNearestMiddle(const Vector & coord, double * dist)
+{
+ Vector point(false);
+ RS_Entity * closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
+ if (closestEntity)
+ point = closestEntity->getNearestMiddle(coord, dist);
-Vector RS_EntityContainer::getNearestMiddle(const Vector& coord,
- double* dist) {
-
- Vector point(false);
- RS_Entity* closestEntity;
-
- closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
-
- if (closestEntity!=NULL) {
- point = closestEntity->getNearestMiddle(coord, dist);
- }
-
- return point;
-
-
- /*
- double minDist = RS_MAXDOUBLE; // minimum measured distance
- double curDist; // currently measured distance
- Vector closestPoint; // closest found endpoint
- Vector point; // endpoint found
-
- for (RS_Entity* en = firstEntity();
- en != NULL;
- en = nextEntity()) {
-
- if (en->isVisible()) {
- point = en->getNearestMiddle(coord, &curDist);
- if (curDist<minDist) {
- closestPoint = point;
- minDist = curDist;
- if (dist!=NULL) {
- *dist = curDist;
- }
- }
- }
- }
-
- return closestPoint;
- */
+ return point;
}
+Vector RS_EntityContainer::getNearestDist(double distance, const Vector & coord,
+ double * dist)
+{
+ Vector point(false);
+ RS_Entity * closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
+ if (closestEntity)
+ point = closestEntity->getNearestDist(distance, coord, dist);
-Vector RS_EntityContainer::getNearestDist(double distance,
- const Vector& coord,
- double* dist) {
-
- Vector point(false);
- RS_Entity* closestEntity;
-
- closestEntity = getNearestEntity(coord, NULL, RS2::ResolveNone);
-
- if (closestEntity!=NULL) {
- point = closestEntity->getNearestDist(distance, coord, dist);
- }
-
- return point;
+ return point;
}
-
-
/**
* @return The intersection which is closest to 'coord'
*/
-Vector RS_EntityContainer::getNearestIntersection(const Vector& coord,
- double* dist) {
-
- double minDist = RS_MAXDOUBLE; // minimum measured distance
- double curDist; // currently measured distance
- Vector closestPoint(false); // closest found endpoint
- Vector point; // endpoint found
- VectorSolutions sol;
- RS_Entity* closestEntity;
-
- closestEntity = getNearestEntity(coord, NULL, RS2::ResolveAll);
-
- if (closestEntity!=NULL) {
- for (RS_Entity* en = firstEntity(RS2::ResolveAll);
- en != NULL;
- en = nextEntity(RS2::ResolveAll)) {
-
- if (en->isVisible() && en!=closestEntity) {
- sol = RS_Information::getIntersection(closestEntity,
- en,
- true);
-
- for (int i=0; i<4; i++) {
- point = sol.get(i);
- if (point.valid) {
- curDist = coord.distanceTo(point);
-
- if (curDist<minDist) {
- closestPoint = point;
- minDist = curDist;
- if (dist!=NULL) {
- *dist = curDist;
- }
- }
- }
- }
- }
- }
- //}
- }
-
- return closestPoint;
-}
+Vector RS_EntityContainer::getNearestIntersection(const Vector & coord,
+ double * dist)
+{
+ double minDist = RS_MAXDOUBLE; // minimum measured distance
+ double curDist; // currently measured distance
+ Vector closestPoint(false); // closest found endpoint
+ Vector point; // endpoint found
+ VectorSolutions sol;
+ RS_Entity * closestEntity;
+ closestEntity = getNearestEntity(coord, NULL, RS2::ResolveAll);
+ if (closestEntity)
+ {
+ for(RS_Entity * en=firstEntity(RS2::ResolveAll); en!=NULL;
+ en = nextEntity(RS2::ResolveAll))
+ {
+ if (en->isVisible() && en!=closestEntity)
+ {
+ sol = RS_Information::getIntersection(closestEntity, en, true);
-Vector RS_EntityContainer::getNearestRef(const Vector& coord,
- double* dist) {
+ for(int i=0; i<4; i++)
+ {
+ point = sol.get(i);
- double minDist = RS_MAXDOUBLE; // minimum measured distance
- double curDist; // currently measured distance
- Vector closestPoint(false); // closest found endpoint
- Vector point; // endpoint found
+ if (point.valid)
+ {
+ curDist = coord.distanceTo(point);
- for (RS_Entity* en = firstEntity();
- en != NULL;
- en = nextEntity()) {
+ if (curDist < minDist)
+ {
+ closestPoint = point;
+ minDist = curDist;
- if (en->isVisible()) {
- point = en->getNearestRef(coord, &curDist);
- if (point.valid && curDist<minDist) {
- closestPoint = point;
- minDist = curDist;
- if (dist!=NULL) {
- *dist = curDist;
- }
- }
- }
- }
+ if (dist)
+ *dist = curDist;
+ }
+ }
+ }
+ }
+ }
+ }
- return closestPoint;
+ return closestPoint;
}
+Vector RS_EntityContainer::getNearestRef(const Vector & coord, double * dist)
+{
+ double minDist = RS_MAXDOUBLE; // minimum measured distance
+ double curDist; // currently measured distance
+ Vector closestPoint(false); // closest found endpoint
+ Vector point; // endpoint found
-Vector RS_EntityContainer::getNearestSelectedRef(const Vector& coord,
- double* dist) {
-
- double minDist = RS_MAXDOUBLE; // minimum measured distance
- double curDist; // currently measured distance
- Vector closestPoint(false); // closest found endpoint
- Vector point; // endpoint found
+ for(RS_Entity * en=firstEntity(); en!=NULL; en=nextEntity())
+ {
+ if (en->isVisible())
+ {
+ point = en->getNearestRef(coord, &curDist);
- for (RS_Entity* en = firstEntity();
- en != NULL;
- en = nextEntity()) {
+ if (point.valid && curDist < minDist)
+ {
+ closestPoint = point;
+ minDist = curDist;
- if (en->isVisible() && en->isSelected() && !en->isParentSelected()) {
- point = en->getNearestSelectedRef(coord, &curDist);
- if (point.valid && curDist<minDist) {
- closestPoint = point;
- minDist = curDist;
- if (dist!=NULL) {
- *dist = curDist;
- }
- }
- }
- }
+ if (dist)
+ *dist = curDist;
+ }
+ }
+ }
- return closestPoint;
+ return closestPoint;
}
+Vector RS_EntityContainer::getNearestSelectedRef(const Vector & coord,
+ double * dist)
+{
+ double minDist = RS_MAXDOUBLE; // minimum measured distance
+ double curDist; // currently measured distance
+ Vector closestPoint(false); // closest found endpoint
+ Vector point; // endpoint found
-double RS_EntityContainer::getDistanceToPoint(const Vector& coord,
- RS_Entity** entity,
- RS2::ResolveLevel level,
- double solidDist) {
+ for(RS_Entity * en=firstEntity(); en!=NULL; en=nextEntity())
+ {
+ if (en->isVisible() && en->isSelected() && !en->isParentSelected())
+ {
+ point = en->getNearestSelectedRef(coord, &curDist);
- RS_DEBUG->print("RS_EntityContainer::getDistanceToPoint");
+ if (point.valid && curDist < minDist)
+ {
+ closestPoint = point;
+ minDist = curDist;
- double minDist = RS_MAXDOUBLE; // minimum measured distance
- double curDist; // currently measured distance
- RS_Entity* closestEntity = NULL; // closest entity found
- RS_Entity* subEntity = NULL;
+ if (dist)
+ *dist = curDist;
+ }
+ }
+ }
- //int k=0;
- for (RS_Entity* e = firstEntity(level);
- e != NULL;
- e = nextEntity(level)) {
+ return closestPoint;
+}
- if (e->isVisible()) {
- RS_DEBUG->print("entity: getDistanceToPoint");
- RS_DEBUG->print("entity: %d", e->rtti());
- curDist = e->getDistanceToPoint(coord, &subEntity, level, solidDist);
+double RS_EntityContainer::getDistanceToPoint(const Vector & coord,
+ RS_Entity ** entity, RS2::ResolveLevel level, double solidDist)
+{
+ RS_DEBUG->print("RS_EntityContainer::getDistanceToPoint");
- RS_DEBUG->print("entity: getDistanceToPoint: OK");
+ double minDist = RS_MAXDOUBLE; // minimum measured distance
+ double curDist; // currently measured distance
+ RS_Entity * closestEntity = NULL; // closest entity found
+ RS_Entity * subEntity = NULL;
- if (curDist<minDist) {
- if (level!=RS2::ResolveAll) {
- closestEntity = e;
- } else {
- closestEntity = subEntity;
- }
- minDist = curDist;
- }
- }
- }
-
- if (entity!=NULL) {
- *entity = closestEntity;
- }
- RS_DEBUG->print("RS_EntityContainer::getDistanceToPoint: OK");
+ //int k=0;
+ for(RS_Entity * e=firstEntity(level); e!=NULL; e=nextEntity(level))
+ {
+ if (e->isVisible())
+ {
+ RS_DEBUG->print("entity: getDistanceToPoint");
+ RS_DEBUG->print("entity: %d", e->rtti());
+ curDist = e->getDistanceToPoint(coord, &subEntity, level, solidDist);
+ RS_DEBUG->print("entity: getDistanceToPoint: OK");
- return minDist;
-}
+ if (curDist<minDist)
+ {
+ if (level != RS2::ResolveAll)
+ closestEntity = e;
+ else
+ closestEntity = subEntity;
+ minDist = curDist;
+ }
+ }
+ }
+ if (entity)
+ *entity = closestEntity;
-RS_Entity* RS_EntityContainer::getNearestEntity(const Vector& coord,
- double* dist,
- RS2::ResolveLevel level) {
+ RS_DEBUG->print("RS_EntityContainer::getDistanceToPoint: OK");
+ return minDist;
+}
- RS_DEBUG->print("RS_EntityContainer::getNearestEntity");
+RS_Entity * RS_EntityContainer::getNearestEntity(const Vector & coord,
+ double * dist, RS2::ResolveLevel level)
+{
+ RS_DEBUG->print("RS_EntityContainer::getNearestEntity");
+ RS_Entity * e = NULL;
- RS_Entity* e = NULL;
+ // distance for points inside solids:
+ double solidDist = RS_MAXDOUBLE;
- // distance for points inside solids:
- double solidDist = RS_MAXDOUBLE;
- if (dist!=NULL) {
- solidDist = *dist;
- }
+ if (dist)
+ solidDist = *dist;
- double d = getDistanceToPoint(coord, &e, level, solidDist);
+ double d = getDistanceToPoint(coord, &e, level, solidDist);
- if (e!=NULL && e->isVisible()==false) {
- e = NULL;
- }
+ if (e && e->isVisible() == false)
+ e = NULL;
- // if d is negative, use the default distance (used for points inside solids)
- if (dist!=NULL) {
- *dist = d;
- }
- RS_DEBUG->print("RS_EntityContainer::getNearestEntity: OK");
+ // if d is negative, use the default distance (used for points inside solids)
+ if (dist)
+ *dist = d;
- return e;
+ RS_DEBUG->print("RS_EntityContainer::getNearestEntity: OK");
+ return e;
}
-
-
/**
* Rearranges the atomic entities in this container in a way that connected
* entities are stored in the right order and direction.
* @retval true all contours were closed
* @retval false at least one contour is not closed
*/
-bool RS_EntityContainer::optimizeContours() {
-
- RS_DEBUG->print("RS_EntityContainer::optimizeContours");
-
- Vector current(false);
- Vector start(false);
- RS_EntityContainer tmp;
-
- bool changed = false;
- bool closed = true;
+bool RS_EntityContainer::optimizeContours()
+{
+ RS_DEBUG->print("RS_EntityContainer::optimizeContours");
- for (uint ci=0; ci<count(); ++ci) {
- RS_Entity* e1=entityAt(ci);
+ Vector current(false);
+ Vector start(false);
+ RS_EntityContainer tmp;
- if (e1!=NULL && e1->isEdge() && !e1->isContainer() &&
- !e1->isProcessed()) {
+ bool changed = false;
+ bool closed = true;
- RS_AtomicEntity* ce = (RS_AtomicEntity*)e1;
+ for(uint ci=0; ci<count(); ++ci)
+ {
+ RS_Entity * e1=entityAt(ci);
- // next contour start:
- ce->setProcessed(true);
- tmp.addEntity(ce->clone());
- current = ce->getEndpoint();
- start = ce->getStartpoint();
+ if (e1 && e1->isEdge() && !e1->isContainer() && !e1->isProcessed())
+ {
+ RS_AtomicEntity * ce = (RS_AtomicEntity *)e1;
- // find all connected entities:
- bool done;
- do {
- done = true;
- for (uint ei=0; ei<count(); ++ei) {
- RS_Entity* e2=entityAt(ei);
+ // next contour start:
+ ce->setProcessed(true);
+ tmp.addEntity(ce->clone());
+ current = ce->getEndpoint();
+ start = ce->getStartpoint();
- if (e2!=NULL && e2->isEdge() && !e2->isContainer() &&
- !e2->isProcessed()) {
+ // find all connected entities:
+ bool done;
- RS_AtomicEntity* e = (RS_AtomicEntity*)e2;
+ do
+ {
+ done = true;
+ for(uint ei=0; ei<count(); ++ei)
+ {
+ RS_Entity * e2=entityAt(ei);
- if (e->getStartpoint().distanceTo(current) <
- 1.0e-4) {
+ if (e2 != NULL && e2->isEdge() && !e2->isContainer() &&
+ !e2->isProcessed())
+ {
+ RS_AtomicEntity * e = (RS_AtomicEntity *)e2;
- e->setProcessed(true);
- tmp.addEntity(e->clone());
- current = e->getEndpoint();
+ if (e->getStartpoint().distanceTo(current) < 1.0e-4)
+ {
+ e->setProcessed(true);
+ tmp.addEntity(e->clone());
+ current = e->getEndpoint();
+ done = false;
+ }
+ else if (e->getEndpoint().distanceTo(current) < 1.0e-4)
+ {
+ e->setProcessed(true);
+ RS_AtomicEntity * cl = (RS_AtomicEntity *)e->clone();
+ cl->reverse();
+ tmp.addEntity(cl);
+ current = cl->getEndpoint();
+ changed = true;
+ done = false;
+ }
+ }
+ }
- done=false;
- } else if (e->getEndpoint().distanceTo(current) <
- 1.0e-4) {
+ if (!done)
+ changed = true;
+ }
+ while (!done);
- e->setProcessed(true);
- RS_AtomicEntity* cl = (RS_AtomicEntity*)e->clone();
- cl->reverse();
- tmp.addEntity(cl);
- current = cl->getEndpoint();
+ if (current.distanceTo(start) > 1.0e-4)
+ closed = false;
+ }
+ }
- changed = true;
- done=false;
- }
- }
- }
- if (!done) {
- changed = true;
- }
- } while (!done);
+ // remove all atomic entities:
+ bool done;
- if (current.distanceTo(start)>1.0e-4) {
- closed = false;
- }
- }
- }
+ do
+ {
+ done = true;
- // remove all atomic entities:
- bool done;
- do {
- done = true;
- for (RS_Entity* en=firstEntity(); en!=NULL; en=nextEntity()) {
- if (!en->isContainer()) {
- removeEntity(en);
- done = false;
- break;
- }
- }
- } while (!done);
+ for(RS_Entity * en=firstEntity(); en!=NULL; en=nextEntity())
+ {
+ if (!en->isContainer())
+ {
+ removeEntity(en);
+ done = false;
+ break;
+ }
+ }
+ }
+ while (!done);
- // add new sorted entities:
- for (RS_Entity* en=tmp.firstEntity(); en!=NULL; en=tmp.nextEntity()) {
- en->setProcessed(false);
- addEntity(en->clone());
- }
+ // add new sorted entities:
+ for(RS_Entity * en=tmp.firstEntity(); en!=NULL; en=tmp.nextEntity())
+ {
+ en->setProcessed(false);
+ addEntity(en->clone());
+ }
- RS_DEBUG->print("RS_EntityContainer::optimizeContours: OK");
- return closed;
+ RS_DEBUG->print("RS_EntityContainer::optimizeContours: OK");
+ return closed;
}
+bool RS_EntityContainer::hasEndpointsWithinWindow(Vector v1, Vector v2)
+{
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ {
+ if (e->hasEndpointsWithinWindow(v1, v2))
+ return true;
+ }
-bool RS_EntityContainer::hasEndpointsWithinWindow(Vector v1, Vector v2) {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- if (e->hasEndpointsWithinWindow(v1, v2)) {
- return true;
- }
- }
-
- return false;
+ return false;
}
+void RS_EntityContainer::move(Vector offset)
+{
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->move(offset);
-void RS_EntityContainer::move(Vector offset) {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->move(offset);
- }
- if (autoUpdateBorders) {
- calculateBorders();
- }
+ if (autoUpdateBorders)
+ calculateBorders();
}
+void RS_EntityContainer::rotate(Vector center, double angle)
+{
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->rotate(center, angle);
-
-void RS_EntityContainer::rotate(Vector center, double angle) {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->rotate(center, angle);
- }
- if (autoUpdateBorders) {
- calculateBorders();
- }
+ if (autoUpdateBorders)
+ calculateBorders();
}
+void RS_EntityContainer::scale(Vector center, Vector factor)
+{
+ if (fabs(factor.x) > RS_TOLERANCE && fabs(factor.y) > RS_TOLERANCE)
+ {
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->scale(center, factor);
+ }
-
-void RS_EntityContainer::scale(Vector center, Vector factor) {
- if (fabs(factor.x)>RS_TOLERANCE && fabs(factor.y)>RS_TOLERANCE) {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->scale(center, factor);
- }
- }
- if (autoUpdateBorders) {
- calculateBorders();
- }
+ if (autoUpdateBorders)
+ calculateBorders();
}
-
-
-void RS_EntityContainer::mirror(Vector axisPoint1, Vector axisPoint2) {
- if (axisPoint1.distanceTo(axisPoint2)>1.0e-6) {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->mirror(axisPoint1, axisPoint2);
- }
- }
+void RS_EntityContainer::mirror(Vector axisPoint1, Vector axisPoint2)
+{
+ if (axisPoint1.distanceTo(axisPoint2) > 1.0e-6)
+ {
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->mirror(axisPoint1, axisPoint2);
+ }
}
+void RS_EntityContainer::stretch(Vector firstCorner, Vector secondCorner,
+ Vector offset)
+{
+ if (getMin().isInWindow(firstCorner, secondCorner) &&
+ getMax().isInWindow(firstCorner, secondCorner))
+ {
+ move(offset);
+ }
+ else
+ {
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->stretch(firstCorner, secondCorner, offset);
+ }
-void RS_EntityContainer::stretch(Vector firstCorner,
- Vector secondCorner,
- Vector offset) {
-
- if (getMin().isInWindow(firstCorner, secondCorner) &&
- getMax().isInWindow(firstCorner, secondCorner)) {
-
- move(offset);
- } else {
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->stretch(firstCorner, secondCorner, offset);
- }
- }
-
- // some entitiycontainers might need an update (e.g. RS_Leader):
- update();
+ // some entitiycontainers might need an update (e.g. RS_Leader):
+ update();
}
+void RS_EntityContainer::moveRef(const Vector & ref, const Vector & offset)
+{
+ for(RS_Entity* e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->moveRef(ref, offset);
-
-void RS_EntityContainer::moveRef(const Vector& ref,
- const Vector& offset) {
-
- for (RS_Entity* e=firstEntity(RS2::ResolveNone);
- e!=NULL;
- e=nextEntity(RS2::ResolveNone)) {
- e->moveRef(ref, offset);
- }
- if (autoUpdateBorders) {
- calculateBorders();
- }
+ if (autoUpdateBorders)
+ calculateBorders();
}
void RS_EntityContainer::moveSelectedRef(const Vector & ref, const Vector & offset)
{
- for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
- e->moveSelectedRef(ref, offset);
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+ e->moveSelectedRef(ref, offset);
if (autoUpdateBorders)
- calculateBorders();
+ calculateBorders();
}
void RS_EntityContainer::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
- if (painter == NULL || view == NULL)
+ if (!painter || !view)
return;
- for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e = nextEntity(RS2::ResolveNone))
+ for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
+#if 0
+{
+if (e->rtti() == RS2::EntityText)
+{
+ std::cout << "About to draw TEXT entity... "
+ << "TEXT=\"" << ((RS_Text *)e)->getText().toAscii().data() << "\"" << std::endl;
+}
+//OK, we have text, but no insert entities at least none that are drawn...
+//Ah! But with a standard text entity, it DOES have them!
+else if (e->rtti() == RS2::EntityInsert)
+{
+ std::cout << "About to draw INSERT entity... "
+ << "INSERT=\"" << ((RS_Insert *)e)->getData().name.toAscii().data() << "\"" << std::endl;
+}
+#endif
view->drawEntity(e);
+#if 0
+}
+#endif
}
/**
std::ostream & operator<<(std::ostream & os, RS_EntityContainer & ec)
{
static int indent = 0;
-
char * tab = new char[indent * 2 + 1];
- for(int i=0; i<indent*2; ++i)
+ for(int i=0; i<indent*2; i++)
tab[i] = ' ';
tab[indent * 2] = '\0';
-
- ++indent;
-
+ indent++;
unsigned long int id = ec.getId();
os << tab << "EntityContainer[" << id << "]: \n";
<< ec.minV << " - " << ec.maxV << "\n";
//os << tab << "Unit[" << id << "]: "
//<< RS_Units::unit2string (ec.unit) << "\n";
- if (ec.getLayer() != NULL)
+ if (ec.getLayer())
{
os << tab << "Layer[" << id << "]: "
- << ec.getLayer()->getName().toLatin1().data() << "\n";
+ << ec.getLayer()->getName().toLatin1().data() << "\n";
}
else
{
}
os << tab << "\n\n";
- --indent;
+ indent--;
delete[] tab;
return os;
}
-
protected:
/** entities in the container */
-// Q3PtrList<RS_Entity> entities;
QList<RS_Entity *> entities;
/** sub container used only temporarly for iteration. */
}
// Open cxf file:
- QFile f(path);
+ QFile file(path);
- if (!f.open(QIODevice::ReadOnly))
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Font::loadFont: Cannot open font file: %s",
path.toLatin1().data());
RS_DEBUG->print("RS_Font::loadFont: Successfully opened font file: %s", path.toLatin1().data());
}
- QTextStream ts(&f);
+ QTextStream ts(&file);
QString line;
// Read line by line until we find a new letter:
- while (!f.atEnd())
+//I think this is wrong... We're mixing classes here...
+//AND THAT WAS THE PROBLEM!!!
+// while (!file.atEnd())
+ while (!ts.atEnd())
{
line = ts.readLine();
-
+//printf("\"%s\"\n", line.toAscii().data());
if (line.isEmpty())
continue;
if (list.size() >= 2)
value = list[1].simplified();//.toLower();
#endif
+//printf("--> identifier=\"%s\", value=\"%s\"\n", identifier.toAscii().data(), value.toAscii().data());
if (identifier == "letterspacing")
letterSpacing = value.toDouble();
}
}
- f.close();
+ file.close();
loaded = true;
RS_DEBUG->print("RS_Font::loadFont OK");
this->snapRes = snapRes;
}
+RS2::SnapMode RS_Snapper::getSnapMode(void)
+{
+ return snapMode;
+}
+
+RS2::SnapRestriction RS_Snapper::getSnapRestriction(void)
+{
+ return snapRes;
+}
+
/**
-* Sets the snap range in pixels for catchEntity().
-*
-* @see catchEntity()
-*/
+ * Sets the snap range in pixels for catchEntity().
+ *
+ * @see catchEntity()
+ */
void RS_Snapper::setSnapRange(int r)
{
snapRange = r;
Vector RS_Snapper::snapEndpoint(Vector coord)
{
Vector vec(false);
- vec = container->getNearestEndpoint(coord, NULL/*, &keyEntity*/);
+ vec = container->getNearestEndpoint(coord, NULL);
return vec;
}
*/
/*virtual*/ void RS_Snapper::suspend()
{
- deleteSnapper();
+#warning "!!! This may need to have SetVisibility() called !!!"
+// deleteSnapper();
snapSpot = snapCoord = Vector(false);
}
*/
/*virtual*/ void RS_Snapper::resume()
{
- drawSnapper();
+#warning "!!! This may need to have SetVisibility() called !!!"
+// drawSnapper();
}
/**
RS_DIALOGFACTORY->requestSnapDistOptions(distance, true);
}
-/**
- * Draws the snapper on the screen.
- */
-void RS_Snapper::drawSnapper()
-{
-printf("RS_Snapper::drawSnapper(): Using DEPRECATED function!!!\n");
- if (!visible)
- xorSnapper();
-}
-
-/**
- * Deletes the snapper from the screen.
- */
-void RS_Snapper::deleteSnapper()
-{
-printf("RS_Snapper::deleteSnapper(): Using DEPRECATED function!!!\n");
- if (visible)
- {
- xorSnapper();
- snapSpot = Vector(false);
- snapCoord = Vector(false);
- }
-}
-
-/**
- * Draws / deletes the current snapper spot.
- */
-void RS_Snapper::xorSnapper()
-{
-#warning "!!! RS_Snapper::xorSnapper() is DEPRECATED !!!"
-//Not completely true...
-//#warning "!!! xorSnapper() not working AT ALL !!!"
-#if 0
- if (!finished && snapSpot.valid)
- {
- RS_Painter * painter = graphicView->createDirectPainter();
- painter->setPreviewMode();
-
- if (snapCoord.valid)
- {
- // snap point
- painter->drawCircle(graphicView->toGui(snapCoord), 4);
-
- // crosshairs:
- if (showCrosshairs == true)
- {
- painter->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width00, RS2::DashLine));
- painter->drawLine(Vector(0, graphicView->toGuiY(snapCoord.y)),
- Vector(graphicView->getWidth(), graphicView->toGuiY(snapCoord.y)));
- painter->drawLine(Vector(graphicView->toGuiX(snapCoord.x), 0),
- Vector(graphicView->toGuiX(snapCoord.x), graphicView->getHeight()));
- }
- }
-
- if (snapCoord.valid && snapCoord != snapSpot)
- {
- painter->drawLine(graphicView->toGui(snapSpot) + Vector(-5, 0),
- graphicView->toGui(snapSpot) + Vector(-1, 4));
- painter->drawLine(graphicView->toGui(snapSpot) + Vector(0, 5),
- graphicView->toGui(snapSpot) + Vector(4, 1));
- painter->drawLine(graphicView->toGui(snapSpot) + Vector(5, 0),
- graphicView->toGui(snapSpot) + Vector(1, -4));
- painter->drawLine(graphicView->toGui(snapSpot) + Vector(0, -5),
- graphicView->toGui(snapSpot) + Vector(-4, -1));
- }
-
- graphicView->destroyPainter();
- visible = !visible;
- }
-//#else
- if (finished || !snapSpot.valid || !graphicView)
- return;
-
- graphicView->SetSnapperDraw(true);
- graphicView->SetSnapperVars(snapSpot, snapCoord, showCrosshairs);
-//Apparently, this gets hit anyway by the preview code...
-// graphicView->redraw();
-
- visible = !visible;
-#endif
-}
-
void RS_Snapper::SetVisible(bool visibility/*= true*/)
{
visible = visibility;
RS_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 snapMiddle(Vector coord);
Vector snapDist(Vector coord);
Vector snapIntersection(Vector coord);
- //Vector snapDirect(Vector coord, bool abs);
Vector restrictOrthogonal(Vector coord);
Vector restrictHorizontal(Vector coord);
virtual void hideOptions();
virtual void showOptions();
- void drawSnapper();
- void deleteSnapper();
+// void drawSnapper();
+// void deleteSnapper();
/*
How should we handle this? All rendering goes through the GraphicView (QG_GraphicView to be
bool Visible(void);
void Draw(GraphicView *, PaintInterface *);
- private:
- void xorSnapper();
+// private:
+// void xorSnapper();
protected:
RS_EntityContainer * container;
{
int c = 1;
- for(int i=0; i<(int)data.text.length(); ++i)
+ for(int i=0; i<(int)data.text.length(); i++)
{
if (data.text.at(i).unicode() == 0x0A)
- {
c++;
- }
}
return c;
*/
void RS_Text::update()
{
+#if 0
+printf("RS_Text::update(): ");
+#endif
RS_DEBUG->print("RS_Text::update");
-
clear();
+#if 0
+printf("isUndone=%s, ", (isUndone() ? "true" : "false"));
+#endif
if (isUndone())
return;
usedTextWidth = 0.0;
usedTextHeight = 0.0;
+#if 0
+printf("data.style=\"%s\", ", data.style.toAscii().data());
+#endif
RS_Font * font = RS_FONTLIST->requestFont(data.style);
- if (font == NULL)
+#if 0
+printf("font=%08X\n", (unsigned int)font);
+#endif
+ if (!font)
return;
Vector letterPos = Vector(0.0, -9.0);
// add texts:
RS_Text * upper = new RS_Text(oneLine,
- RS_TextData(letterPos + Vector(0.0, 9.0),
- 4.0, 100.0, RS2::VAlignTop,
- RS2::HAlignLeft,
- RS2::LeftToRight, RS2::Exact,
- 1.0, up, data.style,
- 0.0, RS2::Update));
+ RS_TextData(letterPos + Vector(0.0, 9.0), 4.0, 100.0,
+ RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight,
+ RS2::Exact, 1.0, up, data.style, 0.0, RS2::Update));
upper->setLayer(NULL);
upper->setPen(RS_Pen(RS2::FlagInvalid));
oneLine->addEntity(upper);
RS_Text * lower = new RS_Text(oneLine,
- RS_TextData(letterPos+Vector(0.0, 4.0),
- 4.0, 100.0, RS2::VAlignTop,
- RS2::HAlignLeft,
- RS2::LeftToRight, RS2::Exact,
- 1.0, dw, data.style,
- 0.0, RS2::Update));
+ RS_TextData(letterPos+Vector(0.0, 4.0), 4.0, 100.0,
+ RS2::VAlignTop, RS2::HAlignLeft, RS2::LeftToRight,
+ RS2::Exact, 1.0, dw, data.style, 0.0, RS2::Update));
lower->setLayer(NULL);
lower->setPen(RS_Pen(RS2::FlagInvalid));
oneLine->addEntity(lower);
default:
{
+// Regular text works because the .style is "normallatin1" while the dimensions are done
+// using "standard"... So that's why it doesn't work.
+// "standard" exists, but it seems that no characters are loaded from it...
+//count() == 0...
+//printf("--> default: pos=%d, char=%04X, font size=%d\n", i, data.text.at(i).unicode(), font->getLetterList()->count());
// One Letter:
- if (font->findLetter(QString(data.text.at(i))) != NULL)
+//#warning "!!! font->findLetter() not working correctly !!!"
+ if (font->findLetter(QString(data.text.at(i))))
{
- RS_DEBUG->print("RS_Text::update: insert a "
- "letter at pos: %f/%f", letterPos.x, letterPos.y);
-
+//We ain't getting here:
+/*
+About to draw TEXT entity... TEXT="107.25"
+RS_Dimension::updateCreateDimensionLine()...
+--> 107.25
+RS_Text::update(): isUndone=false, font=094C1020
+--> default: pos=0, char=0031
+--> default: pos=1, char=0030
+--> default: pos=2, char=0037
+--> default: pos=3, char=002E
+--> default: pos=4, char=0032
+--> default: pos=5, char=0035
+*/
+//printf(" char=%s\n", QString(data.text.at(i)).toAscii().data());
+ RS_DEBUG->print("RS_Text::update: insert a letter at pos: %f/%f", letterPos.x, letterPos.y);
RS_InsertData d(QString(data.text.at(i)), letterPos, Vector(1.0, 1.0),
- 0.0, 1,1, Vector(0.0, 0.0), font->getLetterList(), RS2::NoUpdate);
+ 0.0, 1, 1, Vector(0.0, 0.0), font->getLetterList(), RS2::NoUpdate);
RS_Insert * letter = new RS_Insert(this, d);
letter->setPen(RS_Pen(RS2::FlagInvalid));
//letterWidth = Vector(letter->getSize().x, 0.0);
// from 2.0.4.6:
Vector letterWidth = Vector(letter->getMax().x - letterPos.x, 0.0);
-
oneLine->addEntity(letter);
// next letter position:
Vector RS_Text::getNearestRef(const Vector & coord, double * dist)
{
- //return getRefPoints().getClosest(coord, dist);
return RS_Entity::getNearestRef(coord, dist);
}