~ubuntu-branches/ubuntu/gutsy/plotutils/gutsy

« back to all changes in this revision

Viewing changes to libplot/b_path.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the GNU plotutils package.  Copyright (C) 1995,
 
2
   1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
 
3
 
 
4
   The GNU plotutils package is free software.  You may redistribute it
 
5
   and/or modify it under the terms of the GNU General Public License as
 
6
   published by the Free Software foundation; either version 2, or (at your
 
7
   option) any later version.
 
8
 
 
9
   The GNU plotutils package is distributed in the hope that it will be
 
10
   useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License along
 
15
   with the GNU plotutils package; see the file COPYING.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
 
17
   Boston, MA 02110-1301, USA. */
 
18
 
1
19
/* This file contains the internal paint_path() method, which the public
2
20
   method endpath() is a wrapper around. */
3
21
 
17
35
                          + ((p1).y - (p2).y) * ((p1).y - (p2).y))
18
36
 
19
37
void
20
 
#ifdef _HAVE_PROTOS
21
 
_b_paint_path (S___(Plotter *_plotter))
22
 
#else
23
 
_b_paint_path (S___(_plotter))
24
 
     S___(Plotter *_plotter;)
25
 
#endif
 
38
_pl_b_paint_path (S___(Plotter *_plotter))
26
39
{
27
40
  if (_plotter->drawstate->pen_type == 0
28
41
      && _plotter->drawstate->fill_type == 0)
58
71
            pc = _plotter->drawstate->path->segments[1].pc;
59
72
            
60
73
            /* use libxmi rendering */
61
 
            _b_draw_elliptic_arc (R___(_plotter) p0, p1, pc);
 
74
            _pl_b_draw_elliptic_arc (R___(_plotter) p0, p1, pc);
62
75
 
63
76
            break;
64
77
          }
72
85
            pc = _plotter->drawstate->path->segments[1].pc;
73
86
            
74
87
            /* use libxmi rendering */
75
 
            _b_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc);
 
88
            _pl_b_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc);
76
89
            
77
90
            break;
78
91
          }
82
95
 
83
96
        /* construct point array for libxmi module; convert vertices to
84
97
           device coordinates, removing runs */
85
 
        miPoints = (miPoint *)_plot_xmalloc (_plotter->drawstate->path->num_segments * sizeof(miPoint));
 
98
        miPoints = (miPoint *)_pl_xmalloc (_plotter->drawstate->path->num_segments * sizeof(miPoint));
86
99
 
87
100
        polyline_len = 0;
88
101
        xu_last = 0.0;
124
137
        /* construct an miGC (graphics context for the libxmi module); copy
125
138
           attributes from the Plotter's GC to it */
126
139
        pGC = miNewGC (2, pixels);
127
 
        _set_common_mi_attributes (_plotter->drawstate, (voidptr_t)pGC);
 
140
        _set_common_mi_attributes (_plotter->drawstate, (void *)pGC);
128
141
        
129
142
        if (_plotter->drawstate->fill_type)
130
143
          /* not transparent, will fill */
186
199
                 nothing. */
187
200
              {
188
201
                if (identical_user_coordinates == false
189
 
                    || _plotter->drawstate->cap_type == CAP_ROUND)
 
202
                    || _plotter->drawstate->cap_type == PL_CAP_ROUND)
190
203
                  {
191
204
                    unsigned int sp_size 
192
205
                      = (unsigned int)_plotter->drawstate->quantized_device_line_width; 
293
306
 
294
307
        /* draw ellipse (elliptic arc aligned with the coordinate axes, arc
295
308
           range = 64*360 64'ths of a degree) */
296
 
        _b_draw_elliptic_arc_internal (R___(_plotter) 
 
309
        _pl_b_draw_elliptic_arc_internal (R___(_plotter) 
297
310
                                          xorigin, yorigin, 
298
311
                                          squaresize_x, squaresize_y, 
299
312
                                          0, 64 * 360);
313
326
   device frame, of the sort that libxmi supports. */
314
327
 
315
328
void
316
 
#ifdef _HAVE_PROTOS
317
 
_b_draw_elliptic_arc (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
318
 
#else
319
 
_b_draw_elliptic_arc (R___(_plotter) p0, p1, pc)
320
 
     S___(Plotter *_plotter;)
321
 
     plPoint p0, p1, pc;
322
 
#endif
 
329
_pl_b_draw_elliptic_arc (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
323
330
{
324
331
  double radius;
325
332
  double theta0, theta1;
377
384
  startangle = IROUND(64 * theta0 * 180.0); /* in 64'ths of a degree */
378
385
  anglerange = IROUND(64 * (theta1 - theta0) * 180.0); /* likewise */
379
386
 
380
 
  _b_draw_elliptic_arc_internal (R___(_plotter)
381
 
                                 xorigin, yorigin, 
382
 
                                 squaresize_x, squaresize_y, 
383
 
                                 startangle, anglerange);
 
387
  _pl_b_draw_elliptic_arc_internal (R___(_plotter)
 
388
                                    xorigin, yorigin, 
 
389
                                    squaresize_x, squaresize_y, 
 
390
                                    startangle, anglerange);
384
391
}
385
392
 
386
393
/* Use libxmi rendering to draw what would be a quarter-ellipse in the user
390
397
   either or both axes).  So it will be a quarter-ellipse in the device
391
398
   frame, of the sort that libxmi supports. */
392
399
void
393
 
#ifdef _HAVE_PROTOS
394
 
_b_draw_elliptic_arc_2 (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
395
 
#else
396
 
_b_draw_elliptic_arc_2 (R___(_plotter) p0, p1, pc)
397
 
     S___(Plotter *_plotter;)
398
 
     plPoint p0, p1, pc;
399
 
#endif
 
400
_pl_b_draw_elliptic_arc_2 (R___(Plotter *_plotter) plPoint p0, plPoint p1, plPoint pc)
400
401
{
401
402
  double rx, ry;
402
403
  double x0, y0, x1, y1, xc, yc;
467
468
  startangle *= 64;
468
469
  anglerange *= 64;
469
470
 
470
 
  _b_draw_elliptic_arc_internal (R___(_plotter)
471
 
                                 xorigin, yorigin, 
472
 
                                 squaresize_x, squaresize_y, 
473
 
                                 startangle, anglerange);
 
471
  _pl_b_draw_elliptic_arc_internal (R___(_plotter)
 
472
                                    xorigin, yorigin, 
 
473
                                    squaresize_x, squaresize_y, 
 
474
                                    startangle, anglerange);
474
475
}
475
476
 
476
477
/* Draw an elliptic arc aligned with the coordinate axes, by invoking
481
482
   since miFillArcs() and miDrawArcs() do not support them. */
482
483
 
483
484
void
484
 
#ifdef _HAVE_PROTOS
485
 
_b_draw_elliptic_arc_internal (R___(Plotter *_plotter) int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange)
486
 
#else
487
 
_b_draw_elliptic_arc_internal (R___(_plotter) xorigin, yorigin, squaresize_x, squaresize_y, startangle, anglerange)
488
 
     S___(Plotter *_plotter;)
489
 
     int xorigin, yorigin; 
490
 
     unsigned int squaresize_x, squaresize_y; 
491
 
     int startangle, anglerange;
492
 
#endif
 
485
_pl_b_draw_elliptic_arc_internal (R___(Plotter *_plotter) int xorigin, int yorigin, unsigned int squaresize_x, unsigned int squaresize_y, int startangle, int anglerange)
493
486
{
494
487
  miGC *pGC;
495
488
  miArc arc;
509
502
  /* construct an miGC (graphics context for the libxmi module); copy
510
503
     attributes from the Plotter's GC to it */
511
504
  pGC = miNewGC (2, pixels);
512
 
  _set_common_mi_attributes (_plotter->drawstate, (voidptr_t)pGC);
 
505
  _set_common_mi_attributes (_plotter->drawstate, (void *)pGC);
513
506
  
514
507
  /* libxmi's definition of an elliptic arc aligned with the axes */
515
508
  arc.x = xorigin;
653
646
}
654
647
 
655
648
bool
656
 
#ifdef _HAVE_PROTOS
657
 
_b_paint_paths (S___(Plotter *_plotter))
658
 
#else
659
 
_b_paint_paths (S___(_plotter))
660
 
     S___(Plotter *_plotter;)
661
 
#endif
 
649
_pl_b_paint_paths (S___(Plotter *_plotter))
662
650
{
663
651
  return false;
664
652
}