Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit af2b543

Browse files
committed
Addingn DrawKit 1.0.1.
1 parent 354803b commit af2b543

File tree

134 files changed

+16857
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+16857
-1
lines changed

DKDrawKit.framework/DKDrawKit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Versions/Current/DKDrawKit

DKDrawKit.framework/Headers

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Versions/Current/Headers

DKDrawKit.framework/Resources

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Versions/Current/Resources
1.68 MB
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* CurveFit.h
3+
/// DrawKit ©2005-2008 Apptree.net
4+
*
5+
* Created by graham on 05/11/2006.
6+
* Copyright 2006 Apptree.net. All rights reserved.
7+
*
8+
*/
9+
10+
// utils:
11+
12+
#ifdef qUseCurveFit
13+
14+
#import <Cocoa/Cocoa.h>
15+
16+
#ifdef __cplusplus
17+
extern "C"
18+
{
19+
#endif
20+
21+
// curve fit vector paths using bezier curve fitting:
22+
23+
NSBezierPath* curveFitPath(NSBezierPath* inPath, float epsilon);
24+
NSBezierPath* smartCurveFitPath( NSBezierPath* inPath, float epsilon, float cornerAngleThreshold );
25+
26+
#ifdef __cplusplus
27+
}
28+
#endif
29+
30+
// curve fit vector path using poTrace smoothing algorithm:
31+
32+
33+
#ifndef SIGN
34+
#define SIGN(x) ((x) > 0? 1 : (x) < 0? -1 : 0)
35+
#endif
36+
37+
38+
#define kDKDefaultCornerThreshold (pi / 6)
39+
40+
#endif /* defined(qUseCurveFit) */
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
@author Graham Cox, Apptree.net
3+
@author Graham Miln, miln.eu
4+
@author Contributions from the community
5+
@date 2005-2014
6+
@copyright This software is released subject to licensing conditions as detailed in DRAWKIT-LICENSING.TXT, which must accompany this source file.
7+
*/
8+
9+
#import "DKDrawablePath.h"
10+
11+
// shape types this class supports:
12+
13+
typedef enum {
14+
kDKArcPathOpenArc = 0,
15+
kDKArcPathWedge,
16+
kDKArcPathCircle
17+
} DKArcPathType;
18+
19+
// the class:
20+
21+
@interface DKArcPath : DKDrawablePath <NSCopying, NSCoding> {
22+
@private
23+
CGFloat mRadius;
24+
CGFloat mStartAngle;
25+
CGFloat mEndAngle;
26+
NSPoint mCentre;
27+
DKArcPathType mArcType;
28+
}
29+
30+
- (void)setRadius:(CGFloat)rad;
31+
- (CGFloat)radius;
32+
33+
- (void)setStartAngle:(CGFloat)sa;
34+
- (CGFloat)startAngle;
35+
36+
- (void)setEndAngle:(CGFloat)ea;
37+
- (CGFloat)endAngle;
38+
39+
/** @brief Sets the arc type, which affects the path geometry
40+
@param arcType the required type
41+
*/
42+
- (void)setArcType:(DKArcPathType)arcType;
43+
44+
/** @brief Returns the arc type, which affects the path geometry
45+
@return the current arc type
46+
*/
47+
- (DKArcPathType)arcType;
48+
49+
- (IBAction)convertToPath:(id)sender;
50+
51+
@end
52+
53+
// partcodes this class defines - note that the implicit partcodes used by DKDrawablePath are not used by this class,
54+
// so we don't need to ensure these are out of range. The numbers here are entirely arbitrary, but the code does assume
55+
// they are consecutive, continuous, and ordered thus:
56+
57+
enum {
58+
kDKArcPathRadiusPart = 2,
59+
kDKArcPathStartAnglePart,
60+
kDKArcPathEndAnglePart,
61+
kDKArcPathRotationKnobPart,
62+
kDKArcPathCentrePointPart,
63+
};
64+
65+
// the simple creation mode can be set (rather than, say, kDKPathCreateModeArcSegment) to create arcs in a one-step process
66+
// which simply drags out the radius of an arc 45 degrees centred on the horizontal axis. The arc is editable in
67+
// exactly the same way afterwards so there is no functionality lost doing it this way. It might be found to be easier to use
68+
// than the 2-stage arc creation process.
69+
70+
enum {
71+
kDKArcSimpleCreationMode = 7
72+
};
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/**
2+
@author Graham Cox, Apptree.net
3+
@author Graham Miln, miln.eu
4+
@author Contributions from the community
5+
@date 2005-2014
6+
@copyright This software is released subject to licensing conditions as detailed in DRAWKIT-LICENSING.TXT, which must accompany this source file.
7+
*/
8+
9+
#import "DKStroke.h"
10+
11+
// arrow head kinds - each end can be specified independently:
12+
13+
typedef enum {
14+
kDKArrowHeadNone = 0,
15+
kDKArrowHeadStandard = 1,
16+
kDKArrowHeadInflected = 2,
17+
kDKArrowHeadRound = 3,
18+
kDKArrowHeadSingleFeather = 4,
19+
kDKArrowHeadDoubleFeather = 5,
20+
kDKArrowHeadTripleFeather = 6,
21+
kDKArrowHeadDimensionLine = 7,
22+
kDKArrowHeadDimensionLineAndBar = 8,
23+
kDKArrowHeadSquare = 9,
24+
kDKArrowHeadDiamond = 10
25+
} DKArrowHeadKind;
26+
27+
// positioning of dimension label, or none:
28+
29+
typedef enum {
30+
kDKDimensionNone = 0,
31+
kDKDimensionPlaceAboveLine = 1,
32+
kDKDimensionPlaceInLine = 2,
33+
kDKDimensionPlaceBelowLine = 3
34+
} DKDimensioningLineOptions;
35+
36+
// dimension kind - sets additional embellishments on the dimension text:
37+
38+
typedef enum {
39+
kDKDimensionLinear = 0,
40+
kDKDimensionDiameter = 1,
41+
kDKDimensionRadius = 2,
42+
kDKDimensionAngle = 3
43+
} DKDimensionTextKind;
44+
45+
// tolerance options:
46+
47+
typedef enum {
48+
kDKDimensionToleranceNotShown = 0,
49+
kDKDimensionToleranceShown = 1
50+
} DKDimensionToleranceOption;
51+
52+
// the class:
53+
54+
/** @brief DKArrowStroke is a rasterizer that implements arrowheads on the ends of paths.
55+
56+
DKArrowStroke is a rasterizer that implements arrowheads on the ends of paths. The heads are drawn by filling the
57+
arrowhead using the same colour as the stroke, thus seamlessly blending the head into the path. Where multiple
58+
strokes are used, the resulting effect should be correct when angles are kept the same and lengths are calculated
59+
from the stroke width.
60+
*/
61+
@interface DKArrowStroke : DKStroke <NSCoding, NSCopying> {
62+
@private
63+
DKArrowHeadKind mArrowHeadAtStart;
64+
DKArrowHeadKind mArrowHeadAtEnd;
65+
CGFloat m_arrowLength;
66+
CGFloat m_arrowWidth;
67+
DKDimensioningLineOptions mDimensionOptions;
68+
NSNumberFormatter* m_dims_formatter;
69+
NSColor* m_outlineColour;
70+
CGFloat m_outlineWidth;
71+
DKDimensionTextKind mDimTextKind;
72+
DKDimensionToleranceOption mDimToleranceOptions;
73+
}
74+
75+
+ (void)setDimensioningLineTextAttributes:(NSDictionary*)attrs;
76+
+ (NSDictionary*)dimensioningLineTextAttributes;
77+
+ (DKArrowStroke*)standardDimensioningLine;
78+
+ (NSNumberFormatter*)defaultDimensionLineFormatter;
79+
80+
// head kind at each end
81+
82+
- (void)setArrowHeadAtStart:(DKArrowHeadKind)kind;
83+
- (void)setArrowHeadAtEnd:(DKArrowHeadKind)kind;
84+
- (DKArrowHeadKind)arrowHeadAtStart;
85+
- (DKArrowHeadKind)arrowHeadAtEnd;
86+
87+
// head widths and lengths (some head kinds may set these also)
88+
89+
- (void)setArrowHeadWidth:(CGFloat)width;
90+
- (CGFloat)arrowHeadWidth;
91+
- (void)setArrowHeadLength:(CGFloat)length;
92+
- (CGFloat)arrowHeadLength;
93+
94+
- (void)standardArrowForStrokeWidth:(CGFloat)sw;
95+
96+
#ifdef DRAWKIT_DEPRECATED
97+
- (void)setOutlineColour:(NSColor*)colour width:(CGFloat)width;
98+
#endif
99+
100+
- (void)setOutlineColour:(NSColor*)colour;
101+
- (NSColor*)outlineColour;
102+
- (void)setOutlineWidth:(CGFloat)width;
103+
- (CGFloat)outlineWidth;
104+
105+
- (NSImage*)arrowSwatchImageWithSize:(NSSize)size strokeWidth:(CGFloat)width;
106+
- (NSImage*)standardArrowSwatchImage;
107+
108+
- (NSBezierPath*)arrowPathFromOriginalPath:(NSBezierPath*)inPath fromObject:(id)obj;
109+
110+
// dimensioning lines:
111+
112+
- (void)setFormatter:(NSNumberFormatter*)fmt;
113+
- (NSNumberFormatter*)formatter;
114+
- (void)setFormat:(NSString*)format;
115+
116+
- (void)setDimensioningLineOptions:(DKDimensioningLineOptions)dimOps;
117+
- (DKDimensioningLineOptions)dimensioningLineOptions;
118+
119+
- (NSAttributedString*)dimensionTextForObject:(id)obj;
120+
- (CGFloat)widthOfDimensionTextForObject:(id)obj;
121+
- (NSString*)toleranceTextForObject:(id)object;
122+
123+
- (void)setDimensionTextKind:(DKDimensionTextKind)kind;
124+
- (DKDimensionTextKind)dimensionTextKind;
125+
126+
- (void)setDimensionToleranceOption:(DKDimensionToleranceOption)option;
127+
- (DKDimensionToleranceOption)dimensionToleranceOption;
128+
129+
- (void)setTextAttributes:(NSDictionary*)dict;
130+
- (NSDictionary*)textAttributes;
131+
- (void)setFont:(NSFont*)font;
132+
- (NSFont*)font;
133+
134+
@end
135+
136+
/** @brief informal protocol for requesting dimension information from an object.
137+
138+
If it does not respond, the rasterizer infers the values from the path length and its internal values.
139+
*/
140+
@interface NSObject (DKArrowSrokeDimensioning)
141+
142+
- (NSDictionary*)dimensionValuesForArrowStroke:(DKArrowStroke*)arrowStroke;
143+
144+
@end
145+
146+
#define kDKStandardArrowSwatchImageSize (NSMakeSize(80.0, 9.0))
147+
#define kDKStandardArrowSwatchStrokeWidth 3.0
148+
149+
extern NSString* kDKPositiveToleranceKey;
150+
extern NSString* kDKNegativeToleranceKey;
151+
extern NSString* kDKDimensionValueKey;
152+
extern NSString* kDKDimensionUnitsKey;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
@author Graham Cox, Apptree.net
3+
@author Graham Miln, miln.eu
4+
@author Contributions from the community
5+
@date 2005-2014
6+
@copyright This software is released subject to licensing conditions as detailed in DRAWKIT-LICENSING.TXT, which must accompany this source file.
7+
*/
8+
9+
#import <Cocoa/Cocoa.h>
10+
#import "DKBSPObjectStorage.h"
11+
12+
@class DKBSPDirectTree;
13+
14+
/**
15+
This uses a similar algorithm to DKBSPObjectStorage but instead of indexing the objects it stores them directly by retaining them in additional arrays
16+
within the BSP tree. This is likely to be faster than the indexing approach though profiling is needed to confirm this.
17+
18+
To facilitate correct z-ordering, each object stores its own Z-position and the objects are sorted on this property when necessary. Objects need to be
19+
renumbered when indexes change.
20+
21+
The trade-off here is that drawing speed should be faster but object insertion, deletion and changing of Z-position may be slower.
22+
*/
23+
@interface DKBSPDirectObjectStorage : DKLinearObjectStorage {
24+
@private
25+
DKBSPDirectTree* mTree;
26+
NSUInteger mTreeDepth;
27+
NSUInteger mLastItemCount;
28+
BOOL mAutoRebuild;
29+
}
30+
31+
- (void)setTreeDepth:(NSUInteger)aDepth;
32+
- (id)tree;
33+
- (NSBezierPath*)debugStorageDivisions;
34+
35+
@end
36+
37+
#pragma mark -
38+
39+
/// tree object
40+
41+
@interface DKBSPDirectTree : DKBSPIndexTree {
42+
@public
43+
id<DKStorableObject> mObj;
44+
NSMutableArray* mFoundObjects;
45+
NSUInteger mObjectCount;
46+
NSView* mViewRef;
47+
NSRect mRect;
48+
}
49+
50+
- (void)insertItem:(id<DKStorableObject>)obj withRect:(NSRect)rect;
51+
- (void)removeItem:(id<DKStorableObject>)obj withRect:(NSRect)rect;
52+
- (void)removeAllObjects;
53+
- (NSUInteger)count;
54+
55+
// tree returns mutable results so that they can be sorted in place without needing to be copied
56+
57+
- (NSMutableArray*)objectsIntersectingRects:(const NSRect*)rects count:(NSUInteger)count inView:aView;
58+
- (NSMutableArray*)objectsIntersectingRect:(NSRect)rect;
59+
- (NSMutableArray*)objectsIntersectingPoint:(NSPoint)point;
60+
61+
@end

0 commit comments

Comments
 (0)