]> granicus.if.org Git - graphviz/commitdiff
Fix mac app to use cgraph instead of graph.
authorEmden Gansner <erg@research.att.com>
Mon, 30 Jul 2012 19:45:59 +0000 (15:45 -0400)
committerEmden Gansner <erg@research.att.com>
Mon, 30 Jul 2012 19:45:59 +0000 (15:45 -0400)
macosx/GVGraph.h
macosx/GVGraph.m
macosx/GVGraphDefaultAttributes.h
macosx/GVGraphDefaultAttributes.m
macosx/graphviz.xcodeproj/default.pbxuser
macosx/graphviz.xcodeproj/leopard.project.pbxproj
macosx/graphviz.xcodeproj/lion.project.pbxproj
macosx/graphviz.xcodeproj/project.pbxproj
macosx/graphviz.xcodeproj/snowleopard.project.pbxproj

index aa790443455873403046f35586704a7a3a3b9df1..4f696f31a4b5bfec9a86e79e5e75d54f2a65ecf4 100644 (file)
@@ -20,7 +20,9 @@
 
 @interface GVGraph : NSObject
 {
+@public
        graph_t *_graph;
+@protected
        BOOL _freeLastLayout;
        
        GVGraphArguments *_arguments;
index 8fd031fcf1d20b6dcf1fe1172c27a83f8e3f2201..bf305b1c5aae4b9b5f3b13758abede918a224ae9 100644 (file)
@@ -73,7 +73,11 @@ extern char *gvplugin_list(GVC_t * gvc, api_t api, const char *str);
                                return nil;
                        }
                        
+#ifdef WITH_CGRAPH
+                       _graph = agread(file,0);
+#else
                        _graph = agread(file);
+#endif
                        if (!_graph) {
                                if (outError)
                                        *outError = [NSError errorWithDomain:GVGraphvizErrorDomain code:GVFileParseError userInfo:nil];
@@ -84,7 +88,11 @@ extern char *gvplugin_list(GVC_t * gvc, api_t api, const char *str);
                                        parentDir = (char *)[[URL path] fileSystemRepresentation];
                                        ptr = strrchr(parentDir,'/');
                                        *ptr = 0;
+#ifdef WITH_CGRAPH
                                        agraphattr(_graph,"imagepath",parentDir);
+#else
+                                       agattr(_graph,AGRAPH,"imagepath",parentDir);
+#endif
                        }
                        fclose(file);
                }
@@ -111,9 +119,15 @@ extern char *gvplugin_list(GVC_t * gvc, api_t api, const char *str);
 
                _freeLastLayout = NO;
                _arguments = [[GVGraphArguments alloc] initWithGraph:self];
+#ifdef WITH_CGRAPH
+               _graphAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:AGRAPH];
+               _defaultNodeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:AGNODE];
+               _defaultEdgeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:AGEDGE];
+#else
                _graphAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:_graph];
                _defaultNodeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotonode(_graph)];
                _defaultEdgeAttributes = [[GVGraphDefaultAttributes alloc] initWithGraph:self prototype:agprotoedge(_graph)];
+#endif
        }
        
        return self;
index 8fa2bd6192b2fa9e65e1d344e7842e85170f9949..95e1851ee2ccd3ea0741a35e1377ef16e2d273a4 100644 (file)
 
 #import <Foundation/Foundation.h>
 
-#include "types.h"
-#include "graph.h"
+#include "gvc.h"
 
 @class GVGraph;
 
 @interface GVGraphDefaultAttributes : NSMutableDictionary
 {
        GVGraph *_graph;
+#ifdef WITH_CGRAPH
+       int _kind;
+#else
        void *_proto;
+#endif
 }
 
+#ifdef WITH_CGRAPH
+- (id)initWithGraph:(GVGraph *)graph prototype:(int)kind;
+#else
 - (id)initWithGraph:(GVGraph *)graph prototype:(void *)proto;
+#endif
 
 /* dictionary primitive methods */
 - (NSUInteger)count;
index a14aa53f9771b9f277588f5f916cf7eb54128bce..00156524831424d2ce87fbdd31d3de0b1b998452 100644 (file)
 
 @interface GVGraphDefaultAttributeKeyEnumerator : NSEnumerator
 {
+#ifdef WITH_CGRAPH
+       graph_t *_graph;
+       int _kind;
+#else
        void *_proto;
+#endif
        Agsym_t *_nextSymbol;
 }
 
+#ifdef WITH_CGRAPH
+- (id)initWithGraph:(graph_t *)graph prototype:(int)kind;
+#else
 - (id)initWithPrototype:(void *)proto;
+#endif
 - (NSArray *)allObjects;
 - (id)nextObject;
 
 
 @implementation GVGraphDefaultAttributeKeyEnumerator
 
+#ifdef WITH_CGRAPH
+- (id)initWithGraph:(graph_t *)graph prototype:(int)kind;
+{
+       if (self = [super init]) {
+               _kind = kind;
+               _graph = graph;
+               _nextSymbol = agnxtattr(_graph, _kind, NULL);
+       }
+       return self;
+}
+
+- (NSArray *)allObjects
+{
+       NSMutableArray* all = [NSMutableArray array];
+       for (; _nextSymbol; _nextSymbol = agnxtattr(_graph, _kind, _nextSymbol)) {
+               char *attributeValue = _nextSymbol->defval;
+               if (attributeValue && *attributeValue)
+                       [all addObject:[NSString stringWithUTF8String:attributeValue]];
+       }
+                       
+       return all;
+}
+
+- (id)nextObject
+{
+       for (; _nextSymbol; _nextSymbol = agnxtattr(_graph, _kind, _nextSymbol)) {
+               char *attributeValue = _nextSymbol->defval;
+               if (attributeValue && *attributeValue)
+                       return [NSString stringWithUTF8String:attributeValue];
+       }
+       return nil;
+}
+#else
 - (id)initWithPrototype:(void *)proto
 {
        if (self = [super init]) {
        }
        return nil;
 }
+#endif
 
 @end
 
 @implementation GVGraphDefaultAttributes
 
+#ifdef WITH_CGRAPH
+- (id)initWithGraph:(GVGraph *)graph prototype:(int)kind
+{
+       if (self = [super init]) {
+               _graph = graph;
+               _kind = kind;
+       }
+       return self;
+}
+
+- (NSUInteger)count
+{
+       NSUInteger symbolCount = 0;
+       Agsym_t *nextSymbol = NULL;
+       for (nextSymbol = agnxtattr(_graph->_graph,_kind, nextSymbol); nextSymbol; nextSymbol = agnxtattr(_graph->_graph, _kind, nextSymbol))
+               if (nextSymbol->defval && *(nextSymbol->defval))
+                       ++symbolCount;
+       return symbolCount;
+}
+
+- (NSEnumerator *)keyEnumerator
+{
+       return [[[GVGraphDefaultAttributeKeyEnumerator alloc] initWithGraph:_graph->_graph prototype:_kind] autorelease];
+}
+
+- (id)objectForKey:(id)aKey
+{
+       id object = nil;
+       Agsym_t *attributeSymbol = agattr(_graph->_graph, _kind, (char*)[aKey UTF8String], 0);
+       if (attributeSymbol) {
+               char *attributeValue = attributeSymbol->defval;
+               if (attributeValue && *attributeValue)
+                       object = [NSString stringWithUTF8String:attributeValue];
+       }
+       return object;
+}
+
+- (void)setObject:(id)anObject forKey:(id)aKey
+{
+       agattr(_graph->_graph, _kind, (char *)[aKey UTF8String], (char *)[anObject UTF8String]);
+       [_graph noteChanged:YES];
+}
+
+- (void)removeObjectForKey:(id)aKey
+{
+       agattr(_graph->_graph, _kind, (char *)[aKey UTF8String], "");
+       [_graph noteChanged:YES];
+}
+#else
 - (id)initWithGraph:(GVGraph *)graph prototype:(void *)proto
 {
        if (self = [super init]) {
        agattr(_proto, (char *)[aKey UTF8String], "");
        [_graph noteChanged:YES];
 }
+#endif
 @end
index ac166bbc79501e67f5745fc91dad61577f5920fc..d966b682ddd3fd50f7bd083cd9e13b63d026317a 100644 (file)
@@ -71,7 +71,7 @@
                        {
                                active = YES;
                                name = DYLD_LIBRARY_PATH;
-                               value = "../lib/cdt/.libs:../lib/pathplan/.libs:../lib/graph/.libs:../lib/gvc/.libs";
+                               value = "../lib/cdt/.libs:../lib/pathplan/.libs:../lib/cgraph/.libs:../lib/gvc/.libs";
                        },
                );
                executableSystemSymbolLevel = 0;
index 66399649d235f6a2ff0618bfb36ef6222e85e911..72d150ac9d4252832df7190bba6ebb58500e1a89 100644 (file)
@@ -85,7 +85,7 @@
                D8798BDD0D5D5BD700CCC6E3 /* GVAttributeSchema.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVAttributeSchema.h; sourceTree = "<group>"; };
                D8798BDE0D5D5BD700CCC6E3 /* GVAttributeSchema.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVAttributeSchema.m; sourceTree = "<group>"; };
                D88584190D54866C00D35701 /* Graphviz.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Graphviz.icns; sourceTree = "<group>"; };
-               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/graph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
+               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/cgraph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
                D88585F90D56D3FB00D35701 /* libgvc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgvc.dylib; path = ../lib/gvc/.libs/libgvc.dylib; sourceTree = SOURCE_ROOT; };
                D885863B0D56DC2C00D35701 /* GVWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVWindowController.h; sourceTree = "<group>"; };
                D885863C0D56DC2C00D35701 /* GVWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVWindowController.m; sourceTree = "<group>"; };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                WRAPPER_EXTENSION = app;
                                ZERO_LINK = YES;
                        };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                VALID_ARCHS = "i386 x86_64";
                                WRAPPER_EXTENSION = app;
                        };
index f98138a85d5d771e0961259ebb06f7f9c575d7cc..57e92b9988e3d187f41882a86020ad5be39cb35d 100644 (file)
@@ -85,7 +85,7 @@
                D8798BDD0D5D5BD700CCC6E3 /* GVAttributeSchema.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVAttributeSchema.h; sourceTree = "<group>"; };
                D8798BDE0D5D5BD700CCC6E3 /* GVAttributeSchema.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVAttributeSchema.m; sourceTree = "<group>"; };
                D88584190D54866C00D35701 /* Graphviz.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Graphviz.icns; sourceTree = "<group>"; };
-               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/graph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
+               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/cgraph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
                D88585F90D56D3FB00D35701 /* libgvc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgvc.dylib; path = ../lib/gvc/.libs/libgvc.dylib; sourceTree = SOURCE_ROOT; };
                D885863B0D56DC2C00D35701 /* GVWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVWindowController.h; sourceTree = "<group>"; };
                D885863C0D56DC2C00D35701 /* GVWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVWindowController.m; sourceTree = "<group>"; };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                VALID_ARCHS = x86_64;
                                WRAPPER_EXTENSION = app;
                                ZERO_LINK = YES;
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                VALID_ARCHS = x86_64;
                                WRAPPER_EXTENSION = app;
                        };
index 66399649d235f6a2ff0618bfb36ef6222e85e911..72d150ac9d4252832df7190bba6ebb58500e1a89 100644 (file)
@@ -85,7 +85,7 @@
                D8798BDD0D5D5BD700CCC6E3 /* GVAttributeSchema.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVAttributeSchema.h; sourceTree = "<group>"; };
                D8798BDE0D5D5BD700CCC6E3 /* GVAttributeSchema.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVAttributeSchema.m; sourceTree = "<group>"; };
                D88584190D54866C00D35701 /* Graphviz.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Graphviz.icns; sourceTree = "<group>"; };
-               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/graph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
+               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/cgraph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
                D88585F90D56D3FB00D35701 /* libgvc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgvc.dylib; path = ../lib/gvc/.libs/libgvc.dylib; sourceTree = SOURCE_ROOT; };
                D885863B0D56DC2C00D35701 /* GVWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVWindowController.h; sourceTree = "<group>"; };
                D885863C0D56DC2C00D35701 /* GVWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVWindowController.m; sourceTree = "<group>"; };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                WRAPPER_EXTENSION = app;
                                ZERO_LINK = YES;
                        };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                VALID_ARCHS = "i386 x86_64";
                                WRAPPER_EXTENSION = app;
                        };
index 8e3f41ac87b85001860425085078d13a05fe7c71..23f64b59064c272a122f244e9bc9a4300568970c 100644 (file)
@@ -85,7 +85,7 @@
                D8798BDD0D5D5BD700CCC6E3 /* GVAttributeSchema.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVAttributeSchema.h; sourceTree = "<group>"; };
                D8798BDE0D5D5BD700CCC6E3 /* GVAttributeSchema.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVAttributeSchema.m; sourceTree = "<group>"; };
                D88584190D54866C00D35701 /* Graphviz.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Graphviz.icns; sourceTree = "<group>"; };
-               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/graph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
+               D88585F70D56D3D700D35701 /* libgraph.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgraph.dylib; path = ../lib/cgraph/.libs/libgraph.dylib; sourceTree = SOURCE_ROOT; };
                D88585F90D56D3FB00D35701 /* libgvc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libgvc.dylib; path = ../lib/gvc/.libs/libgvc.dylib; sourceTree = SOURCE_ROOT; };
                D885863B0D56DC2C00D35701 /* GVWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GVWindowController.h; sourceTree = "<group>"; };
                D885863C0D56DC2C00D35701 /* GVWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GVWindowController.m; sourceTree = "<group>"; };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                WRAPPER_EXTENSION = app;
                                ZERO_LINK = YES;
                        };
                                INSTALL_PATH = "$(HOME)/Applications";
                                LIBRARY_SEARCH_PATHS = (
                                        ../lib/cdt/.libs,
-                                       ../lib/graph/.libs,
+                                       ../lib/cgraph/.libs,
                                        ../lib/gvc/.libs,
                                );
                                PRODUCT_NAME = Graphviz;
-                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/graph ../lib/gvc";
+                               USER_HEADER_SEARCH_PATHS = "../lib/common ../lib/cdt ../lib/pathplan ../lib/cgraph ../lib/gvc";
                                VALID_ARCHS = "i386 x86_64";
                                WRAPPER_EXTENSION = app;
                        };