summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2013-03-22 19:30:07 +0000
committerAlex Merry <dev@randomguy3.me.uk>2013-03-22 19:30:07 +0000
commit3fb7711dd09975c83de5995d5247cbdd8d150def (patch)
treeccb8f903ededd89f50acac51c283523aeebef4c8
parent7a639879e0446bd355fa52e2e347735f57d7abf9 (diff)
Add debugging option to Select tool
Selecting edges and/or nodes and pressing shift-d will print info about them to the console.
-rw-r--r--tikzit/src/common/Edge.h4
-rw-r--r--tikzit/src/common/Edge.m10
-rw-r--r--tikzit/src/gtk/SelectTool.m69
3 files changed, 83 insertions, 0 deletions
diff --git a/tikzit/src/common/Edge.h b/tikzit/src/common/Edge.h
index cc636dd..64da138 100644
--- a/tikzit/src/common/Edge.h
+++ b/tikzit/src/common/Edge.h
@@ -222,6 +222,8 @@ typedef enum {
*/
@property (readonly) NSPoint rightNormal;
+@property (readonly) NSPoint headTan;
+
/*!
@property leftHeadNormal
*/
@@ -232,6 +234,8 @@ typedef enum {
*/
@property (readonly) NSPoint rightHeadNormal;
+@property (readonly) NSPoint tailTan;
+
/*!
@property leftTailNormal
*/
diff --git a/tikzit/src/common/Edge.m b/tikzit/src/common/Edge.m
index f9cb9b5..cabf860 100644
--- a/tikzit/src/common/Edge.m
+++ b/tikzit/src/common/Edge.m
@@ -228,6 +228,11 @@
return NSMakePoint(mid.x - (mid.y - midTan.y), mid.y + (mid.x - midTan.x));
}
+- (NSPoint)headTan {
+ [self updateControls];
+ return headTan;
+}
+
- (NSPoint)leftHeadNormal {
[self updateControls];
return NSMakePoint(headTan.x + (head.y - headTan.y), headTan.y - (head.x - headTan.x));
@@ -238,6 +243,11 @@
return NSMakePoint(headTan.x - (head.y - headTan.y), headTan.y + (head.x - headTan.x));
}
+- (NSPoint)tailTan {
+ [self updateControls];
+ return tailTan;
+}
+
- (NSPoint)leftTailNormal {
[self updateControls];
return NSMakePoint(tailTan.x + (tail.y - tailTan.y), tailTan.y - (tail.x - tailTan.x));
diff --git a/tikzit/src/gtk/SelectTool.m b/tikzit/src/gtk/SelectTool.m
index d5c482f..c821162 100644
--- a/tikzit/src/gtk/SelectTool.m
+++ b/tikzit/src/gtk/SelectTool.m
@@ -368,6 +368,75 @@ static void drag_select_mode_cb (GtkToggleButton *button, SelectTool *tool);
[self setDragSelectMode:DragSelectsEdges];
} else if (keyVal == GDK_KEY_B && mask == ShiftMask) {
[self setDragSelectMode:DragSelectsBoth];
+ } else if (keyVal == GDK_KEY_D && (!mask || mask == ShiftMask)) {
+ PickSupport *ps = [[self doc] pickSupport];
+ for (Node* node in [ps selectedNodes]) {
+ NSRect b = [node boundingRect];
+ NSLog(@"%@ @ (%f,%f) {style=%@, label=%@, data=%@, bounds=(%f,%f),(%fx%f)}",
+ [node name],
+ [node point].x,
+ [node point].y,
+ [[node style] name],
+ [node label],
+ [[node data] tikzList],
+ b.origin.x, b.origin.y, b.size.width, b.size.height);
+ }
+ for (Edge* edge in [ps selectedEdges]) {
+ NSRect b = [edge boundingRect];
+ NSLog(@"%@:%@->%@:%@ {\n"
+ @" style=%@, data=%@,\n"
+ @" bend=%d, weight=%f, inAngle=%d, outAngle=%d, bendMode=%d,\n"
+ @" head=(%f,%f), headTan=(%f,%f) leftHeadNormal=(%f,%f), rightHeadNormal=(%f,%f),\n"
+ @" cp1=(%f,%f),\n"
+ @" mid=(%f,%f), midTan=(%f,%f), leftNormal=(%f,%f), rightNormal=(%f,%f)\n"
+ @" cp2=(%f,%f),\n"
+ @" tail=(%f,%f), tailTan=(%f,%f), leftTailNormal=(%f,%f), rightTailNormal=(%f,%f),\n"
+ @" isSelfLoop=%s, isStraight=%s,\n"
+ @" bounds=(%f,%f),(%fx%f)\n"
+ @"}",
+ [[edge source] name],
+ [edge sourceAnchor],
+ [[edge target] name],
+ [edge targetAnchor],
+ [[edge style] name],
+ [[edge data] tikzList],
+ [edge bend],
+ [edge weight],
+ [edge inAngle],
+ [edge outAngle],
+ [edge bendMode],
+ [edge head].x,
+ [edge head].y,
+ [edge headTan].x,
+ [edge headTan].y,
+ [edge leftHeadNormal].x,
+ [edge leftHeadNormal].y,
+ [edge rightHeadNormal].x,
+ [edge rightHeadNormal].y,
+ [edge cp1].x,
+ [edge cp1].y,
+ [edge mid].x,
+ [edge mid].y,
+ [edge midTan].x,
+ [edge midTan].y,
+ [edge leftNormal].x,
+ [edge leftNormal].y,
+ [edge rightNormal].x,
+ [edge rightNormal].y,
+ [edge cp2].x,
+ [edge cp2].y,
+ [edge tail].x,
+ [edge tail].y,
+ [edge tailTan].x,
+ [edge tailTan].y,
+ [edge leftTailNormal].x,
+ [edge leftTailNormal].y,
+ [edge rightTailNormal].x,
+ [edge rightTailNormal].y,
+ [edge isSelfLoop] ? "yes" : "no",
+ [edge isStraight] ? "yes" : "no",
+ b.origin.x, b.origin.y, b.size.width, b.size.height);
+ }
}
}