~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to components/aggpas/src/agg_vcgen_bspline.pas

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//----------------------------------------------------------------------------
2
 
// Anti-Grain Geometry - Version 2.4 (Public License)
3
 
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4
 
//
5
 
// Anti-Grain Geometry - Version 2.4 Release Milano 3 (AggPas 2.4 RM3)
6
 
// Pascal Port By: Milan Marusinec alias Milano
7
 
//                 milan@marusinec.sk
8
 
//                 http://www.aggpas.org
9
 
// Copyright (c) 2005-2006
10
 
//
11
 
// Permission to copy, use, modify, sell and distribute this software
12
 
// is granted provided this copyright notice appears in all copies.
13
 
// This software is provided "as is" without express or implied
14
 
// warranty, and with no claim as to its suitability for any purpose.
15
 
//
16
 
//----------------------------------------------------------------------------
17
 
// Contact: mcseem@antigrain.com
18
 
//          mcseemagg@yahoo.com
19
 
//          http://www.antigrain.com
20
 
//
21
 
// [Pascal Port History] -----------------------------------------------------
22
 
//
23
 
// 19.01.2006-Milano: Complete Unit Port
24
 
// 18.01.2006-Milano: Unit port establishment
25
 
//
26
 
{ agg_vcgen_bspline.pas }
27
 
unit
28
 
 agg_vcgen_bspline ;
29
 
 
30
 
INTERFACE
31
 
 
32
 
{$I agg_mode.inc }
33
 
 
34
 
uses
35
 
 agg_basics ,
36
 
 agg_bspline ,
37
 
 agg_array ,
38
 
 agg_vertex_source ;
39
 
 
40
 
{ TYPES DEFINITION }
41
 
type
42
 
 status_e = (initial ,ready ,polygon ,end_poly ,stop );
43
 
 
44
 
 vcgen_bspline_ptr = ^vcgen_bspline;
45
 
 vcgen_bspline = object(vertex_source )
46
 
   m_src_vertices : pod_deque;
47
 
 
48
 
   m_spline_x ,
49
 
   m_spline_y : bspline;
50
 
 
51
 
   m_interpolation_step : double;
52
 
 
53
 
   m_closed : unsigned;
54
 
   m_status : status_e;
55
 
 
56
 
   m_src_vertex : unsigned;
57
 
 
58
 
   m_cur_abscissa ,
59
 
   m_max_abscissa : double;
60
 
 
61
 
   constructor Construct;
62
 
   destructor  Destruct; virtual;
63
 
 
64
 
   procedure interpolation_step_(v : double );
65
 
   function  _interpolation_step : double;
66
 
 
67
 
  // Vertex Generator Interface
68
 
   procedure remove_all; virtual;
69
 
   procedure add_vertex(x ,y : double; cmd : unsigned ); virtual;
70
 
 
71
 
  // Vertex Source Interface
72
 
   procedure rewind(path_id : unsigned ); virtual;
73
 
   function  vertex(x ,y : double_ptr ) : unsigned; virtual;
74
 
 
75
 
  end;
76
 
 
77
 
{ GLOBAL PROCEDURES }
78
 
 
79
 
 
80
 
IMPLEMENTATION
81
 
{ LOCAL VARIABLES & CONSTANTS }
82
 
{ UNIT IMPLEMENTATION }
83
 
{ CONSTRUCT }
84
 
constructor vcgen_bspline.Construct;
85
 
begin
86
 
 inherited Construct;
87
 
 
88
 
 m_src_vertices.Construct(sizeof(point_type ) ,6 );
89
 
 m_spline_x.Construct;
90
 
 m_spline_y.Construct;
91
 
 
92
 
 m_interpolation_step:=1.0 / 50.0;
93
 
 
94
 
 m_closed:=0;
95
 
 m_status:=initial;
96
 
 
97
 
 m_src_vertex:=0;
98
 
 
99
 
end;
100
 
 
101
 
{ DESTRUCT }
102
 
destructor vcgen_bspline.Destruct;
103
 
begin
104
 
 inherited Destruct;
105
 
 
106
 
 m_src_vertices.Destruct;
107
 
 m_spline_x.Destruct;
108
 
 m_spline_y.Destruct;
109
 
 
110
 
end;
111
 
 
112
 
{ INTERPOLATION_STEP_ }
113
 
procedure vcgen_bspline.interpolation_step_;
114
 
begin
115
 
 m_interpolation_step:=v;
116
 
 
117
 
end;
118
 
 
119
 
{ _INTERPOLATION_STEP }
120
 
function vcgen_bspline._interpolation_step;
121
 
begin
122
 
 result:=m_interpolation_step;
123
 
 
124
 
end;
125
 
 
126
 
{ REMOVE_ALL }
127
 
procedure vcgen_bspline.remove_all;
128
 
begin
129
 
 m_src_vertices.remove_all;
130
 
 
131
 
 m_closed:=0;
132
 
 m_status:=initial;
133
 
 
134
 
 m_src_vertex:=0;
135
 
 
136
 
end;
137
 
 
138
 
{ ADD_VERTEX }
139
 
procedure vcgen_bspline.add_vertex;
140
 
var
141
 
 pt : point_type;
142
 
 
143
 
begin
144
 
 m_status:=initial;
145
 
 
146
 
 if is_move_to(cmd ) then
147
 
  begin
148
 
   pt.x:=x;
149
 
   pt.y:=y;
150
 
 
151
 
   m_src_vertices.modify_last(@pt );
152
 
 
153
 
  end
154
 
 else
155
 
  if is_vertex(cmd ) then
156
 
   begin
157
 
    pt.x:=x;
158
 
    pt.y:=y;
159
 
 
160
 
    m_src_vertices.add(@pt );
161
 
 
162
 
   end
163
 
  else
164
 
   m_closed:=get_close_flag(cmd );
165
 
 
166
 
end;
167
 
 
168
 
{ REWIND }
169
 
procedure vcgen_bspline.rewind;
170
 
var
171
 
 i : unsigned;
172
 
 x : double;
173
 
 
174
 
begin
175
 
 m_cur_abscissa:=0.0;
176
 
 m_max_abscissa:=0.0;
177
 
 
178
 
 m_src_vertex:=0;
179
 
 
180
 
 if (m_status = initial ) and
181
 
    (m_src_vertices.size > 2 ) then
182
 
  begin
183
 
   if m_closed <> 0 then
184
 
    begin
185
 
     m_spline_x.init(m_src_vertices.size + 8 );
186
 
     m_spline_y.init(m_src_vertices.size + 8 );
187
 
 
188
 
     m_spline_x.add_point(0.0 ,point_type_ptr(m_src_vertices.prev(m_src_vertices.size - 3 ) )^.x );
189
 
     m_spline_y.add_point(0.0 ,point_type_ptr(m_src_vertices.prev(m_src_vertices.size - 3 ) )^.y );
190
 
     m_spline_x.add_point(1.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 3 ) )^.x );
191
 
     m_spline_y.add_point(1.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 3 ) )^.y );
192
 
     m_spline_x.add_point(2.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 2 ) )^.x );
193
 
     m_spline_y.add_point(2.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 2 ) )^.y );
194
 
     m_spline_x.add_point(3.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 1 ) )^.x );
195
 
     m_spline_y.add_point(3.0 ,point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 1 ) )^.y );
196
 
 
197
 
    end
198
 
   else
199
 
    begin
200
 
     m_spline_x.init(m_src_vertices.size );
201
 
     m_spline_y.init(m_src_vertices.size );
202
 
 
203
 
    end;
204
 
 
205
 
   for i:=0 to m_src_vertices.size - 1 do
206
 
    begin
207
 
     if m_closed <> 0 then
208
 
      x:=i + 4
209
 
     else
210
 
      x:=i;
211
 
 
212
 
     m_spline_x.add_point(x ,point_type_ptr(m_src_vertices.array_operator(i ) )^.x );
213
 
     m_spline_y.add_point(x ,point_type_ptr(m_src_vertices.array_operator(i ) )^.y );
214
 
 
215
 
    end;
216
 
 
217
 
   m_cur_abscissa:=0.0;
218
 
   m_max_abscissa:=m_src_vertices.size - 1;
219
 
 
220
 
   if m_closed <> 0 then
221
 
    begin
222
 
     m_cur_abscissa:=4.0;
223
 
     m_max_abscissa:=m_max_abscissa + 5.0;
224
 
 
225
 
     m_spline_x.add_point(
226
 
      m_src_vertices.size + 4 ,
227
 
      point_type_ptr(m_src_vertices.array_operator(0 ) )^.x );
228
 
 
229
 
     m_spline_y.add_point(
230
 
      m_src_vertices.size + 4 ,
231
 
      point_type_ptr(m_src_vertices.array_operator(0 ) )^.y );
232
 
 
233
 
     m_spline_x.add_point(
234
 
      m_src_vertices.size + 5 ,
235
 
      point_type_ptr(m_src_vertices.array_operator(1 ) )^.x );
236
 
 
237
 
     m_spline_y.add_point(
238
 
      m_src_vertices.size + 5 ,
239
 
      point_type_ptr(m_src_vertices.array_operator(1 ) )^.y );
240
 
 
241
 
     m_spline_x.add_point(
242
 
      m_src_vertices.size + 6 ,
243
 
      point_type_ptr(m_src_vertices.array_operator(2 ) )^.x );
244
 
 
245
 
     m_spline_y.add_point(
246
 
      m_src_vertices.size + 6 ,
247
 
      point_type_ptr(m_src_vertices.array_operator(2 ) )^.y );
248
 
 
249
 
     m_spline_x.add_point(
250
 
      m_src_vertices.size + 7 ,
251
 
      point_type_ptr(m_src_vertices.next(2 ) )^.x );
252
 
 
253
 
     m_spline_y.add_point(
254
 
      m_src_vertices.size + 7 ,
255
 
      point_type_ptr(m_src_vertices.next(2 ) )^.y );
256
 
 
257
 
    end;
258
 
 
259
 
   m_spline_x.prepare;
260
 
   m_spline_y.prepare;
261
 
 
262
 
  end;
263
 
 
264
 
 m_status:=ready;
265
 
 
266
 
end;
267
 
 
268
 
{ VERTEX }
269
 
function vcgen_bspline.vertex;
270
 
var
271
 
 cmd : unsigned;
272
 
 
273
 
label
274
 
 _next ,_ready ,_polygon ;
275
 
 
276
 
begin
277
 
 cmd:=path_cmd_line_to;
278
 
 
279
 
_next:
280
 
 while not is_stop(cmd ) do
281
 
  case m_status of
282
 
   initial :
283
 
    begin
284
 
     rewind(0 );
285
 
 
286
 
     goto _ready;
287
 
 
288
 
    end;
289
 
 
290
 
   ready :
291
 
   _ready:
292
 
    begin
293
 
     if m_src_vertices.size < 2 then
294
 
      begin
295
 
       cmd:=path_cmd_stop;
296
 
 
297
 
       goto _next;
298
 
 
299
 
      end;
300
 
 
301
 
     if m_src_vertices.size = 2 then
302
 
      begin
303
 
       x^:=point_type_ptr(m_src_vertices.array_operator(m_src_vertex ) )^.x;
304
 
       y^:=point_type_ptr(m_src_vertices.array_operator(m_src_vertex ) )^.y;
305
 
 
306
 
       inc(m_src_vertex );
307
 
 
308
 
       if m_src_vertex = 1 then
309
 
        begin
310
 
         result:=path_cmd_move_to;
311
 
 
312
 
         exit;
313
 
 
314
 
        end;
315
 
 
316
 
       if m_src_vertex = 2 then
317
 
        begin
318
 
         result:=path_cmd_line_to;
319
 
 
320
 
         exit;
321
 
 
322
 
        end;
323
 
 
324
 
       cmd:=path_cmd_stop;
325
 
 
326
 
       goto _next;   
327
 
 
328
 
      end;
329
 
 
330
 
     cmd:=path_cmd_move_to;
331
 
 
332
 
     m_status:=polygon;
333
 
 
334
 
     m_src_vertex:=0;
335
 
 
336
 
     goto _polygon;
337
 
 
338
 
    end;
339
 
 
340
 
   polygon :
341
 
   _polygon:
342
 
    begin
343
 
     if m_cur_abscissa >= m_max_abscissa then
344
 
      if m_closed <> 0 then
345
 
       begin
346
 
        m_status:=end_poly;
347
 
 
348
 
        goto _next;
349
 
 
350
 
       end
351
 
      else
352
 
       begin
353
 
        x^:=point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 1 ) )^.x;
354
 
        y^:=point_type_ptr(m_src_vertices.array_operator(m_src_vertices.size - 1 ) )^.y;
355
 
 
356
 
        m_status:=end_poly;
357
 
        result  :=path_cmd_line_to;
358
 
 
359
 
        exit;
360
 
 
361
 
       end;
362
 
 
363
 
     x^:=m_spline_x.get_stateful(m_cur_abscissa );
364
 
     y^:=m_spline_y.get_stateful(m_cur_abscissa );
365
 
 
366
 
     inc(m_src_vertex );
367
 
 
368
 
     m_cur_abscissa:=m_cur_abscissa + m_interpolation_step;
369
 
 
370
 
     if m_src_vertex = 1 then
371
 
      result:=path_cmd_move_to
372
 
     else
373
 
      result:=path_cmd_line_to;
374
 
 
375
 
     exit; 
376
 
 
377
 
    end;
378
 
 
379
 
   end_poly :
380
 
    begin
381
 
     m_status:=stop;
382
 
     result  :=path_cmd_end_poly or m_closed;
383
 
 
384
 
     exit;
385
 
 
386
 
    end;
387
 
 
388
 
   stop :
389
 
    begin
390
 
     result:=path_cmd_stop;
391
 
 
392
 
     exit;
393
 
 
394
 
    end;
395
 
 
396
 
  end;
397
 
 
398
 
 result:=cmd;
399
 
 
400
 
end;
401
 
 
402
 
END.
403