summaryrefslogtreecommitdiff
path: root/tikzit/src/common/Graph.m
diff options
context:
space:
mode:
authorAlex Merry <dev@randomguy3.me.uk>2013-08-25 20:34:38 +0100
committerAlex Merry <dev@randomguy3.me.uk>2013-08-25 20:34:38 +0100
commite707060efcf1cb751b7f1a0e26051bc6b93b123f (patch)
tree0a1c53e72f502f0c07be446b6795e3fe86963777 /tikzit/src/common/Graph.m
parent778d71f996a91273da7fa4625d0c66ceacb4cd63 (diff)
Recalculate edge properties when shapes are refreshed
Shape sizes can change (if you're actively editing a shape), which can mean that some edge properties need to be recalculated. We do this at the graph, rather than edge, level to avoid the overhead of installing a notification for every single edge.
Diffstat (limited to 'tikzit/src/common/Graph.m')
-rw-r--r--tikzit/src/common/Graph.m20
1 files changed, 20 insertions, 0 deletions
diff --git a/tikzit/src/common/Graph.m b/tikzit/src/common/Graph.m
index 33a81f6..258ece4 100644
--- a/tikzit/src/common/Graph.m
+++ b/tikzit/src/common/Graph.m
@@ -23,6 +23,11 @@
#import "Graph.h"
#import "TikzGraphAssembler.h"
+#import "Shape.h"
+
+@interface Graph (Private)
+- (void) shapeDictionaryReplaced:(NSNotification*)notification;
+@end
@implementation Graph
@@ -36,6 +41,11 @@
edges = [[NSMutableArray alloc] initWithCapacity:10];
inEdges = nil;
outEdges = nil;
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(shapeDictionaryReplaced:)
+ name:@"ShapeDictionaryReplaced"
+ object:[Shape class]];
}
return self;
}
@@ -56,6 +66,8 @@
}
- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
[graphLock lock];
[inEdges release];
[outEdges release];
@@ -837,4 +849,12 @@
@end
+@implementation Graph (Private)
+- (void) shapeDictionaryReplaced:(NSNotification*)notification {
+ for (Edge *e in edges) {
+ [e recalculateProperties];
+ }
+}
+@end
+
// vi:ft=objc:ts=4:noet:sts=4:sw=4