Skip to content

Commit

Permalink
draw > centerline cross: add two lines in one transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
qcad committed Dec 16, 2013
1 parent 86ce5d5 commit eaf1d47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion scripts/Help/About/AboutCredits.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var credits =
[ "Robert S.", "Direct distance entry, " +
"Snap > X/Y from Points, " +
"Snap > Y/X from Points, " +
"Snap > Distance Manual" ],
"Snap > Distance Manual" +
"Misc > Drawing > Centerline Cross"],
[ "Tamas Tevesz", "Port to FreeBSD, " +
"various improvements and fixes." ],
],
Expand Down
14 changes: 10 additions & 4 deletions scripts/Misc/MiscDraw/Cross/Cross.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

include("scripts/EAction.js");
//include("scripts/Apollonius.js");
include("scripts/ShapeAlgorithms.js");

/**
Expand Down Expand Up @@ -151,14 +150,17 @@ Cross.prototype.drawCross = function(shape) {
point4 = cp.operator_add(v);
}

var op = new RAddObjectsOperation();
var empty = true;

// draw horizontal line from point1 to point2
if (!point1.equalsFuzzy(point2)) {
var line = new RLineEntity(
this.getDocument(),
new RLineData(point1, point2)
)
var op = new RAddObjectOperation(line);
this.getDocumentInterface().applyOperation(op);
op.addObject(line);
empty = false;
}

// draw vertical line from point3 to point4
Expand All @@ -167,7 +169,11 @@ Cross.prototype.drawCross = function(shape) {
this.getDocument(),
new RLineData(point3, point4)
)
op = new RAddObjectOperation(line);
op.addObject(line);
empty = false;
}

if (!empty) {
this.getDocumentInterface().applyOperation(op);
}
};

0 comments on commit eaf1d47

Please sign in to comment.