Permalink
Browse files

updates for Line2P, relative zero

add keycodes for Line2P options tool bar
save / restore relative zero point position per tool
update credits
  • Loading branch information...
1 parent 8f3849e commit 1bb38177538a6977ce7111887d9597fdaa7980b2 @qcad committed Jun 25, 2014
View
21 scripts/Draw/Line/Line2P/Line2P.js
@@ -38,8 +38,6 @@ function Line2P(guiAction) {
this.point1 = undefined;
this.point2 = undefined;
- this.cmd = "";
-
this.setUiOptions(["../Line.ui", "Line2P.ui"]);
}
@@ -110,6 +108,24 @@ Line2P.prototype.escapeEvent = function() {
}
};
+Line2P.prototype.keyPressEvent = function(event) {
+ var di = this.getDocumentInterface();
+
+ if ((event.key() === Qt.Key_Enter.valueOf()) || (event.key() === Qt.Key_Return.valueOf())) {
+ if (this.state === Line2P.State.SettingFirstPoint) {
+ this.point1 = di.getLastPosition();
+ di.setRelativeZero(this.point1);
+ this.setState(Line2P.State.SettingNextPoint);
+ di.clearPreview();
+ di.previewOperation(this.getOperation(true));
+ } else {
+ EAction.prototype.keyPressEvent(event);
+ }
+ } else {
+ EAction.prototype.keyPressEvent(event);
+ }
+};
+
Line2P.prototype.pickCoordinate = function(event, preview) {
var di = this.getDocumentInterface();
@@ -304,7 +320,6 @@ Line2P.prototype.commandEvent = function(event) {
var cmd = event.getCommand();
cmd = cmd.toLowerCase();
- this.cmd = cmd;
str = "close";
if (str.startsWith(cmd)) {
View
9 scripts/Draw/Line/Line2P/Line2P.ui
@@ -26,6 +26,9 @@
<iconset>
<normaloff>CloseSequence.svg</normaloff>CloseSequence.svg</iconset>
</property>
+ <property name="shortcut">
+ <string>,, C</string>
+ </property>
</widget>
</item>
<item>
@@ -50,6 +53,9 @@
<iconset>
<normaloff>UndoSegment.svg</normaloff>UndoSegment.svg</iconset>
</property>
+ <property name="shortcut">
+ <string>,, U</string>
+ </property>
</widget>
</item>
<item>
@@ -67,6 +73,9 @@
<iconset>
<normaloff>RedoSegment.svg</normaloff>RedoSegment.svg</iconset>
</property>
+ <property name="shortcut">
+ <string>,, R</string>
+ </property>
</widget>
</item>
<item>
View
13 scripts/EAction.js
@@ -48,6 +48,7 @@ function EAction(guiAction) {
this.splitUiOptions = false;
this.additionalOptionsToolBars = undefined;
this.optionsToolBarEnabled = true;
+ this.relativeZeroPos = undefined;
}
EAction.prototype = new RActionAdapter();
@@ -245,6 +246,12 @@ EAction.prototype.resumeEvent = function() {
if (!isNull(this.state)) {
this.setState(this.state);
}
+
+ // restore relative zero position when returning from another command:
+ var di = this.getDocumentInterface();
+ if (!isNull(di) && isValidVector(this.relativeZeroPos)) {
+ di.setRelativeZero(this.relativeZeroPos);
+ }
};
/**
@@ -261,6 +268,12 @@ EAction.prototype.suspendEvent = function() {
}
this.hideUiOptions();
+
+ // store relative zero position:
+ var di = this.getDocumentInterface();
+ if (!isNull(di)) {
+ this.relativeZeroPos = di.getRelativeZero();
+ }
};
/**
View
11 scripts/Help/About/AboutCredits.js
@@ -15,18 +15,21 @@ var credits =
"Misc > Drawing > Centerline Cross,<br>" +
"Misc > Drawing > Line from 2 Points (LX)<br>" +
"Edit > Drawing Preferences > General > Point Display<br>" +
- "Modify > Break out Manual"
+ "Modify > Break out Manual<br>" +
+ "Significant contributions to:<br>" +
+ "Draw > Line > Line from 2 Points"
],
[ "Tamas Tevesz", "Port to FreeBSD,<br>" +
"various improvements and fixes." ],
],
[
"Translations",
- [ "Tanaka Hidemune", "Japanese translation and user reference manual." ],
- [ "Miha ('miharix')", "Slovenian translation." ],
+ [ "Tanaka Hidemune", "Japanese (ja) translation and user reference manual." ],
+ [ "Miha ('miharix')", "Slovenian (sl) translation." ],
+ [ "Wang Zhen Zhe", "Chinese (zh_CN) translation." ],
],
[
- "Testing, feedback and minor fixes",
+ "Testing, Feedback and Minor Fixes",
[ "Clive Tubb ('clive')", "" ],
[ "Harald Huesges ('Husky')", "" ],
[ "and many others", "" ],
View
2 src/core/RDocumentInterface.cpp
@@ -62,7 +62,7 @@ RDocumentInterface::RDocumentInterface(RDocument& document)
defaultAction(NULL),
currentSnap(NULL),
currentSnapRestriction(NULL),
- relativeZero(RVector::invalid),
+ relativeZero(RVector(0,0)),
relativeZeroLocked(false),
cursorPosition(RVector::invalid),
suspended(false),

0 comments on commit 1bb3817

Please sign in to comment.