Permalink
Browse files

fix FS#900 - Using text in 3.1.2 freezes QCAD

  • Loading branch information...
1 parent 31f9233 commit 73cb4f18cd06e7986c81ed3c590802576e6bc397 @qcad committed Aug 21, 2013
Showing with 52 additions and 10 deletions.
  1. +10 −10 scripts/File/SvgImport/SvgImport.js
  2. +7 −0 src/core/REntityData.h
  3. +28 −0 src/entity/RTextData.h
  4. +7 −0 src/snap/RSnapIntersection.cpp
@@ -38,18 +38,18 @@ SvgImport.prototype.beginEvent = function() {
this.guiAction.clearArguments();
if (args.length>0) {
fileName = args[0];
- }
- var fi = new QFileInfo(fileName);
- if (!fi.isAbsolute()) {
- fileName = RSettings.getLaunchPath() + QDir.separator + fileName;
- fi = new QFileInfo(fileName);
- }
+ var fi = new QFileInfo(fileName);
+ if (!fi.isAbsolute()) {
+ fileName = RSettings.getLaunchPath() + QDir.separator + fileName;
+ fi = new QFileInfo(fileName);
+ }
- if (!fi.exists()) {
- qWarning("file does not exist: ", fileName);
- this.terminate();
- return;
+ if (!fi.exists()) {
+ qWarning("file does not exist: ", fileName);
+ this.terminate();
+ return;
+ }
}
}
@@ -235,6 +235,13 @@ class QCADCORE_EXPORT REntityData {
virtual RVector getClosestPointOnEntity(const RVector& point,
double range=RNANDOUBLE, bool limited=true) const;
+// /**
+// * Override to disable intersection point
+// */
+// virtual bool intersectionsEnabled() {
+// return true;
+// }
+
virtual QList<RVector> getIntersectionPoints(
const REntityData& other, bool limited = true, bool same = false,
const RBox& queryBox = RDEFAULT_RBOX) const;
@@ -71,6 +71,28 @@ class QCADENTITY_EXPORT RTextData: public REntityData, public RPainterPathSource
double getHeight() const;
virtual RVector getPointOnEntity() const;
+
+ virtual QList<RVector> getEndPoints(const RBox& queryBox = RDEFAULT_RBOX) const {
+ Q_UNUSED(queryBox);
+ return QList<RVector>();
+ }
+ virtual QList<RVector> getMiddlePoints(const RBox& queryBox = RDEFAULT_RBOX) const {
+ Q_UNUSED(queryBox);
+ return QList<RVector>();
+ }
+ virtual QList<RVector> getCenterPoints(const RBox& queryBox = RDEFAULT_RBOX) const {
+ Q_UNUSED(queryBox);
+ return QList<RVector>();
+ }
+ virtual QList<RVector> getPointsWithDistanceToEnd(
+ double distance, RS::From from = RS::FromAny, const RBox& queryBox = RDEFAULT_RBOX) const {
+ Q_UNUSED(distance);
+ Q_UNUSED(from);
+ Q_UNUSED(queryBox);
+
+ return QList<RVector>();
+ }
+
virtual double getDistanceTo(const RVector& point, bool limited = true, double range = 0.0, bool draft = false) const;
virtual bool intersectsWith(const RShape& shape) const;
@@ -215,6 +237,12 @@ class QCADENTITY_EXPORT RTextData: public REntityData, public RPainterPathSource
virtual QList<QSharedPointer<RShape> > getShapes(const RBox& queryBox = RDEFAULT_RBOX) const;
virtual QList<QSharedPointer<RShape> > getExploded() const;
+ virtual QSharedPointer<RShape> getClosestShape(const RVector& pos, double range = RNANDOUBLE) const {
+ Q_UNUSED(pos);
+ Q_UNUSED(range);
+ return QSharedPointer<RShape>();
+ }
+
virtual RVector getClosestPointOnEntity(const RVector& point, double range, bool limited) const;
static QString toEscapedText(const QTextDocument& textDocument, const RColor& initialColor, double fontHeightFactor=1.0);
@@ -77,12 +77,19 @@ RVector RSnapIntersection::snap(
continue;
}
+ if (e1->getType()==RS::EntityText) {
+ continue;
+ }
+
QMap<REntity::Id, QSet<int> >::const_iterator it2;
for (it2=it1; it2!=candidates.end(); it2++) {
QSharedPointer<REntity> e2 = document->queryEntity(it2.key());
if (e2.isNull()) {
continue;
}
+ if (e2->getType()==RS::EntityText) {
+ continue;
+ }
QList<RVector> candidates = e1->getIntersectionPoints(*e2, true, queryBox);

0 comments on commit 73cb4f1

Please sign in to comment.