From caaac57631bda3df581eac462cddd9473bc05b28 Mon Sep 17 00:00:00 2001 From: akissinger Date: Mon, 16 Jan 2012 17:00:11 +0000 Subject: graphs now store edges and nodes in an array, GraphicsView has actions for re-ordering the z-index of nodes and edges git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@380 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64 --- tikzit/src/common/Graph.h | 86 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 11 deletions(-) (limited to 'tikzit/src/common/Graph.h') diff --git a/tikzit/src/common/Graph.h b/tikzit/src/common/Graph.h index fe8c2e5..f396912 100644 --- a/tikzit/src/common/Graph.h +++ b/tikzit/src/common/Graph.h @@ -46,12 +46,12 @@ by calling applyGraphChange on [change inverse]. */ @interface Graph : NSObject { - NSLock *graphLock; - BOOL dirty; // this bit keeps track of whether nodesCache and edgesCache are up to date - NSMutableSet *nodes; - NSMutableSet *edges; - NSSet *nodesCache; - NSSet *edgesCache; + NSRecursiveLock *graphLock; + BOOL dirty; // keep track of when inEdges and outEdges need an update + NSMutableArray *nodes; + NSMutableArray *edges; +// NSSet *nodesCache; +// NSSet *edgesCache; BasicMapTable *inEdges; BasicMapTable *outEdges; @@ -72,7 +72,7 @@ @details The node set is cached internally, so no need to lock the graph when enumerating. */ -@property (readonly) NSSet *nodes; +@property (readonly) NSArray *nodes; /*! @property edges @@ -80,7 +80,7 @@ @details The edge set is cached internally, so no need to lock the graph when enumerating. */ -@property (readonly) NSSet *edges; +@property (readonly) NSArray *edges; /*! @property boundingBox @@ -188,6 +188,69 @@ */ - (GraphChange*)addEdgeFrom:(Node*)source to:(Node*)target; +/*! + @brief Return the z-index for a given node (lower is farther back). + @param node a node in the graph + @result An int + */ +- (int)indexOfNode:(Node*)node; + +/*! + @brief Set the z-index for a given node (lower is farther back). + @param idx a new z-index + @param node a node in the graph + */ +- (void)setIndex:(int)idx ofNode:(Node*)node; + +/*! + @brief Bring set of nodes forward by one. + @param nodeSet a set of nodes + */ +- (GraphChange*)bringNodesForward:(NSSet*)nodeSet; + +/*! + @brief Bring set of nodes to the front. + @param nodeSet a set of nodes + */ +- (GraphChange*)bringNodesToFront:(NSSet*)nodeSet; + +/*! + @brief Bring set of edges to the front. + @param edgeSet a set of edges + */ +- (GraphChange*)bringEdgesToFront:(NSSet*)edgeSet; + +/*! + @brief Bring set of edges forward by one. + @param edgeSet a set of edges + */ +- (GraphChange*)bringEdgesForward:(NSSet*)edgeSet; + +/*! + @brief Send set of nodes backward by one. + @param nodeSet a set of nodes + */ +- (GraphChange*)sendNodesBackward:(NSSet*)nodeSet; + +/*! + @brief Send set of edges backward by one. + @param edgeSet a set of edges + */ +- (GraphChange*)sendEdgesBackward:(NSSet*)edgeSet; + +/*! + @brief Send set of nodes to back. + @param nodeSet a set of nodes + */ +- (GraphChange*)sendNodesToBack:(NSSet*)nodeSet; + +/*! + @brief Send set of edges to back. + @param edgeSet a set of edges + */ +- (GraphChange*)sendEdgesToBack:(NSSet*)edgeSet; + + /*! @brief Transform every node in the graph to screen space. @param t a transformer @@ -200,7 +263,7 @@ @param p an x and y distance, given as an NSPoint. @result A GraphChange recording this action. */ -- (GraphChange*)shiftNodes:(NSSet*)ns byPoint:(NSPoint)p; +- (GraphChange*)shiftNodes:(id)ns byPoint:(NSPoint)p; /*! @brief Insert the given graph into this one. Used for copy @@ -243,6 +306,7 @@ */ - (NSString*)tikz; + /*! @brief Copy the node set and return a table of copies, whose keys are the original nodes. This is used to save the state @@ -263,10 +327,10 @@ /*! @brief Compute the bounds for a set of nodes. - @param nds a set of nodes. + @param nds an enumerable collection of nodes. @result The bounds. */ -+ (NSRect)boundsForNodeSet:(NSSet *)nds; ++ (NSRect)boundsForNodes:(id)nds; /*! @brief Factory method for constructing graphs. -- cgit v1.2.3