-
Notifications
You must be signed in to change notification settings - Fork 3
/
Class.m
218 lines (135 loc) · 6.33 KB
/
Class.m
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
(* ::Package:: *)
(*Header comments*)
(* :Title: Class *)
(* :Context: SciDraw` *)
(* :Summary: Class declarations *)
(* :Author: Mark A. Caprio, Department of Physics, University of Notre Dame *)
(* :Copyright: Copyright FIGYEAR, Mark A. Caprio *)
(* :Package Version: FIGVERSION *)
(* :Mathematica Version: MATHVERSION *)
(* :Discussion: FIGDISCUSSION *)
(* :History: See main package file. *)
(*Begin package*)
(*Package context definition*)
BeginPackage["SciDraw`",SciDraw`Private`$ExternalContexts];
Unprotect[Evaluate[$Context<>"*"]];
(*Begin private context*)
Begin["`Private`"];
(*Dependencies*)
(*Class declarations*)
(*Code structuring convention*)
(*This file contains "up front" class definitions for classes which will be used across files within the SciDraw package. This ensures that the symbols for the methods are established in the correct namespace before their first use. It also ensures that the option inheritance is defined before the DefineOptions call for any subsequent daughter class definition refers to the options.*)
(**)
(*Convention: Figure object classes which are *not* to be referenced across files within SciDraw can safely be defined within their own module file. Therefore they *should* be defined in their own module file, not here!*)
(*Set defaults for option resolution*)
(*Option resolution is a major performance factor*)
(*SetOptions[DefineOptions,{TrapUninheritableOptions\[Rule]True,TrapUnknownOptions\[Rule]True}];*)
(*FigAnchor*)
DeclareClass[FigAnchor,{"Point","Angle","Offset"},{},Replace->True];
(*FigElement*)
DeclareClass[FigElement,{"Primatives","SortKey"},{}];
DeclareClass[FigLineElement,FigElement,{},{}];
DeclareClass[FigPolygonElement,FigElement,{},{}];
DeclareClass[FigPointElement,FigElement,{},{}];
DeclareClass[FigVerbatimElement,FigElement,{},{}];
DeclareClass[FigTextElement,FigElement,{"InitialPoint","Center","Radius","Pivot","Rotation"},{}];
DeclareClass[FigTextFrameElement,FigElement,{},{}];
Options[FigCompositeElement]={Show->True,Clip->False,Rasterize->False,ImageResolution->300};
DeclareClass[FigCompositeElement,FigElement,{},{}];
(*FigObject*)
(*DeclareClass[FigObject,{"OptionValues"},{"MakeAnchor","MakeBoundingBox"}];*)
DeclareClass[FigObject,{},{"MakeAnchor","MakeBoundingBox"}];
DefineOptions[FigObject,
{
(* overall appearance *)
Show->True,Color->Black,Opacity->None,
Directives->{},
Layer->Automatic,
(* outline *)
ShowLine->Default,
LineColor->Default,LineOpacity->Default,
LineThickness->1,LineDashing->None,LineCapForm->None,LineJoinForm->{"Miter",3.25},
LineDirectives->{},
(* fill *)
ShowFill->Default, FillColor->Default,FillOpacity->Default,
FillDirectives->{},
(* point *)
ShowPoint->Default, PointColor->Default,PointOpacity->Default,
PointSize->3,
PointDirectives->{},
(* text appearance *)
ShowText->Default,TextColor->Default,TextOpacity->Default,
FontFamily->"Times",FontSize->16,FontWeight->Plain,FontSlant->Plain,FontTracking ->Plain,FontVariations->{},
TextStyleOptions->{}, (* possibly including directives, though interaction with options unpredictable *)
(* text background and frame *)
TextBackground->None,
TextFrame->False,TextFrameColor->Default,TextFrameOpacity->Default,
TextFrameThickness->1,TextFrameDashing->None,
TextRoundingRadius->None,
TextMargin->None,TextPadding->False,
TextFrameDirectives->{},
(* text callout *)
TextCallout->False,
TextCalloutColor->Default,TextCalloutOpacity->Default,
TextCalloutThickness->1,TextCalloutDashing->None,TextCalloutCapForm->None,TextCalloutJoinForm->{"Miter",3.25},
TextCalloutDirectives->{},
(* text positioning *)
TextOffset->Automatic,TextOrientation->Automatic,TextRectify->True,TextBaseBuffer->Automatic,TextBuffer->None,TextNudge->None,
(* style *)
Style->None,
(* accessories *)
Prolog:>None,Epilog:>None,
(* diagnostic *)
Debug->False
(*PrintTiming\[Rule]False*)
}
];
(*FigStyle*)
(*Figure styles will often be defined at global level (outside figures), and users will typically want to fiddle with settings, so clobbering of instances should be allowed (Replace->True).*)
(*
DeclareClass[FigStyle,{"StyleList"},{"SymbolOptions"},Replace\[Rule]True];
DefineOptions[FigStyle,
{
BaseStyle\[Rule]None,
Debug\[Rule]False
}
];
*)
(*FigWindow*)
(*Object declarations are out outermost scope to ensure mutators/accessors are in this scope*)
(*Data:*)
(* TFunction -- transformation function from user coordinates to canvas coordinates*)
(* PreTFunction -- pretransformation function to be applied in transformation returned by TFunction[]*)
(* meant for origin shift, would have to be revisited for effect on DeltaTFunction otherwise,*)
(* does not affect extraction of canvas region from region in user coordinates*)
(* Region -- region in user coordinates*)
(*Methods:*)
(* Region[] access the region in user coordinates.*)
(* CanvasRegion[] converts this region to canvas coordinates, using TFunction.*)
(* TFunction[] gives the transformation function from user coordinates to canvas coordinates.*)
(* DeltaTFunction[] gives the homogeneous part of the transformation from user coordinates to canvas coordinates.*)
(* ScaledTFunction[] gives the transformation function from scaled coordinates to canvas coordinates.*)
(* ScaledDeltaTFunction[] gives the homogeneous part of the transformation function from scaled coordinates to canvas coordinates.*)
DeclareClass[
FigWindow,
{
"TFunction",
"Region"
},
{
"UserRegion",
"CanvasRegion",
"TFunction",
"InverseTFunction",
"DeltaTFunction",
"ScaledTFunction",
"ScaledDeltaTFunction"
}
];
(*End package*)
(*Exit private context*)
End[];
(*Exit package context*)
Protect[Evaluate[$Context<>"*"]];
Unprotect[Evaluate[$Context<>"$*"]];
EndPackage[];