summaryrefslogtreecommitdiff
path: root/tikzit/src/gtk/GraphRenderer.h
blob: 4609766d19cc2d190c751e263629d6e1aefb3e91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * Copyright 2011  Alex Merry <dev@randomguy3.me.uk>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#import "TZFoundation.h"
#import <gtk/gtk.h>

// classes
#import "Graph.h"
#import "Grid.h"
#import "PickSupport.h"
#import "TikzDocument.h"

// protocols
#import "Surface.h"

typedef enum {
    NoHandle,
    EastHandle,
    SouthEastHandle,
    SouthHandle,
    SouthWestHandle,
    WestHandle,
    NorthWestHandle,
    NorthHandle,
    NorthEastHandle
} ResizeHandle;

@interface GraphRenderer: NSObject <RenderDelegate> {
    TikzDocument       *doc;
    NSObject<Surface>  *surface;
    Grid               *grid;
    NSRect              selectionBox;
    Node               *halfEdgeOrigin;
    NSPoint             halfEdgeOriginPoint;
    NSPoint             halfEdgeEnd;
    BOOL                showBoundingBoxHandles;
}

- (id) initWithSurface:(NSObject <Surface> *)surface;
- (id) initWithSurface:(NSObject <Surface> *)surface document:(TikzDocument*)document;
- (void) renderWithContext:(id<RenderContext>)context;
- (void) invalidateGraph;
- (void) invalidateNode:(Node*)node;
- (void) invalidateEdge:(Edge*)edge;
- (void) invalidateNodesHitBy:(NSPoint)point;
- (BOOL) point:(NSPoint)p hitsNode:(Node*)node;
- (BOOL) point:(NSPoint)p hitsEdge:(Edge*)edge withFuzz:(float)fuzz;
/**
 * Finds a node at the given screen location.
 *
 * If there is more than one node at this point (because they overlap),
 * an arbitrary one is returned.
 */
- (Node*) anyNodeAt:(NSPoint)p;
/**
 * Finds an edge at the given screen location.
 *
 * If there is more than one edge at this point (because they overlap),
 * an arbitrary one is returned.
 *
 * @param fuzz   the fuzz for detecting edges: this will pick up
 *               edges that are close to the point
 */
- (Edge*) anyEdgeAt:(NSPoint)p withFuzz:(float)fuzz;

- (id<Surface>) surface;
- (Transformer*) transformer;
- (Grid*) grid;
- (PickSupport*) pickSupport;

- (Graph*) graph;

- (TikzDocument*) document;
- (void) setDocument:(TikzDocument*)document;

- (NSRect) selectionBox;
- (void) setSelectionBox:(NSRect)box;
- (void) clearSelectionBox;

- (void) setHalfEdgeFrom:(Node*)origin to:(NSPoint)end;
- (void) clearHalfEdge;

- (BOOL) boundingBoxHandlesShown;
- (void) setBoundingBoxHandlesShown:(BOOL)shown;

- (ResizeHandle) boundingBoxResizeHandleAt:(NSPoint)point;
- (NSRect) boundingBoxResizeHandleRect:(ResizeHandle)handle;

@end

// vim:ft=objc:ts=8:et:sts=4:sw=4