From 3fb7711dd09975c83de5995d5247cbdd8d150def Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Fri, 22 Mar 2013 19:30:07 +0000 Subject: Add debugging option to Select tool Selecting edges and/or nodes and pressing shift-d will print info about them to the console. --- tikzit/src/common/Edge.h | 4 +++ tikzit/src/common/Edge.m | 10 +++++++ tikzit/src/gtk/SelectTool.m | 69 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) 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); + } } } -- cgit v1.2.3