All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Canvas.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/antigrain/Canvas.cpp
22 
23  \brief A canvas built on top of Anti Grain Geometry.
24  */
25 //#include <windows.h>
26 // TerraLib
27 #include "../annotationtext/Attributes.h"
28 #include "../annotationtext/Element.h"
29 #include "../annotationtext/Text.h"
30 #include "../common/StringUtils.h"
31 #include "../geometry/Coord2D.h"
32 #include "../geometry/Geometry.h"
33 #include "../geometry/GeometryCollection.h"
34 #include "../geometry/LineString.h"
35 #include "../geometry/LinearRing.h"
36 #include "../geometry/MultiLineString.h"
37 #include "../geometry/MultiPoint.h"
38 #include "../geometry/MultiPolygon.h"
39 #include "../geometry/Point.h"
40 #include "../geometry/PointM.h"
41 #include "../geometry/PointZ.h"
42 #include "../geometry/PointZM.h"
43 #include "../geometry/Polygon.h"
44 #include "../postgis/EWKBReader.h"
45 #include "../postgis/Utils.h"
46 
47 #include "../common/FileDirUtils.h"
48 #include "Canvas.h"
49 //#include "Platform.h"
50 //#include "Utils.h"
51 
52 #include <agg_renderer_markers.h>
53 //#include <agg_path_storage.h>
54 #include <agg_conv_transform.h>
55 #include <agg_conv_stroke.h>
56 #include <agg_renderer_scanline.h>
57 #include <agg_image_accessors.h>
58 #include <agg_span_pattern_rgb.h>
59 #include <agg_span_allocator.h>
60 #include <agg_conv_smooth_poly1.h>
61 #include <agg_pattern_filters_rgba.h>
62 #include <agg_renderer_outline_image.h>
63 #include <agg_renderer_outline_aa.h>
64 #include <agg_rasterizer_outline_aa.h>
65 #include <agg_span_interpolator_linear.h>
66 #include <agg_span_image_filter_rgba.h>
67 #include <agg_trans_single_path.h>
68 #include <stdlib.h>
69 #include <time.h>
70 
71 // STL
72 #include <cassert>
73 
74 //struct trans_roundoff
75 //{
76 // static void transform(double* x, double* y)
77 // {
78 // *x = floor(*x + 0.5);
79 // *y = floor(*y + 0.5);
80 // }
81 //};
82 static agg::int8u brightness_to_alpha[256 * 3] =
83 {
84  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
85  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
86  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
87  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
88  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
89  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
90  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
91  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
92  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
93  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254,
94  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
95  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
96  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
97  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
98  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
99  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
100  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
101  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
102  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
103  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
104  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
105  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
106  255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
107  254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, 253,
108  253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 252,
109  252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 251, 251, 251, 251, 251,
110  251, 251, 251, 251, 250, 250, 250, 250, 250, 250, 250, 250, 249, 249, 249, 249,
111  249, 249, 249, 248, 248, 248, 248, 248, 248, 248, 247, 247, 247, 247, 247, 246,
112  246, 246, 246, 246, 246, 245, 245, 245, 245, 245, 244, 244, 244, 244, 243, 243,
113  243, 243, 243, 242, 242, 242, 242, 241, 241, 241, 241, 240, 240, 240, 239, 239,
114  239, 239, 238, 238, 238, 238, 237, 237, 237, 236, 236, 236, 235, 235, 235, 234,
115  234, 234, 233, 233, 233, 232, 232, 232, 231, 231, 230, 230, 230, 229, 229, 229,
116  228, 228, 227, 227, 227, 226, 226, 225, 225, 224, 224, 224, 223, 223, 222, 222,
117  221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 215, 214, 214,
118  213, 213, 212, 212, 211, 211, 210, 210, 209, 209, 208, 207, 207, 206, 206, 205,
119  204, 204, 203, 203, 202, 201, 201, 200, 200, 199, 198, 198, 197, 196, 196, 195,
120  194, 194, 193, 192, 192, 191, 190, 190, 189, 188, 188, 187, 186, 186, 185, 184,
121  183, 183, 182, 181, 180, 180, 179, 178, 177, 177, 176, 175, 174, 174, 173, 172,
122  171, 171, 170, 169, 168, 167, 166, 166, 165, 164, 163, 162, 162, 161, 160, 159,
123  158, 157, 156, 156, 155, 154, 153, 152, 151, 150, 149, 148, 148, 147, 146, 145,
124  144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129,
125  128, 128, 127, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113,
126  112, 111, 110, 109, 108, 107, 106, 105, 104, 102, 101, 100, 99, 98, 97, 96,
127  95, 94, 93, 91, 90, 89, 88, 87, 86, 85, 84, 82, 81, 80, 79, 78,
128  77, 75, 74, 73, 72, 71, 70, 69, 67, 66, 65, 64, 63, 61, 60, 59,
129  58, 57, 56, 54, 53, 52, 51, 50, 48, 47, 46, 45, 44, 42, 41, 40,
130  39, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 20,
131  19, 18, 17, 15, 14, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1
132 };
133 
135 {
136 public:
137  pattern_src_brightness_to_alpha_rgba8(agg::rendering_buffer& rb) :
138  m_rb(&rb), m_pf(*m_rb) {}
139 
140  unsigned width() const { return m_pf.width(); }
141  unsigned height() const { return m_pf.height(); }
142  agg::rgba8 pixel(int x, int y) const
143  {
144  agg::rgba8 c = m_pf.pixel(x, y);
145  c.a = brightness_to_alpha[c.r + c.g + c.b];
146  return c;
147  }
148 
149 private:
150  agg::rendering_buffer* m_rb;
152 };
153 
155  : m_dwidth(w),
156  m_dheight(h),
157  m_wllx(0.0),
158  m_wlly(0.0),
159  m_wurx(0.0),
160  m_wury(0.0)
161 {
162  m_hdc = ::GetDC(0);
163  m_fontEngine = new agg::font_engine_win32_tt_int16(m_hdc);
164  m_fontManager = new agg::font_cache_manager<agg::font_engine_win32_tt_int16>(*m_fontEngine);
165  m_fontEngine->create_font("Verdana", agg::glyph_ren_outline);
166  m_fontEngine->height(16.);
167 
168  m_buffer = new unsigned char[m_dwidth * m_dheight * DEPTH/8];
169  m_renderingBuffer = agg::rendering_buffer(m_buffer, m_dwidth, m_dheight, -m_dwidth * DEPTH/8);
171  m_rendererBase = agg::renderer_base<pixfmt>(*m_pixfmt);
172 
173  m_bgColor = color_type(255, 255, 255, 0);
174  memset(m_buffer, 255, m_dwidth * m_dheight * DEPTH/8);
175 // clear();
176 
180  m_ptPatternBuffer = 0;
181 
182  m_polyFillColor = color_type(255, 0, 0, 255);
183  m_polyPatternWidth = 20;
184  m_polyContourColor = color_type(0, 0, 0, 255);
185  m_polyContourWidth = 1.;
186 
187  m_lineColor = color_type(100, 255, 255, 255);
188  m_lineWidth = 1.;
189 
190  m_ptColor = color_type(255, 0, 255, 255);
191  m_ptMarkerType = (agg::marker_e)MarkerTriangleUp;
192  m_ptWidth = 16;
193 
194  m_txColor = color_type(0, 0, 255, 255);
195  m_txBoundaryWidth = 1.;
196  m_txBoundaryColor = color_type(255, 0, 255, 255);
197  m_txDecorationColor = color_type(255, 0, 0, 255);
198  m_txDecorationWidth = 1.;
199  m_txXScale = 1.;
200 }
201 
203 {
204  delete m_fontManager;
205  delete m_fontEngine;
206  ::ReleaseDC(0, m_hdc);
207 
208  delete m_pixfmt;
209  delete m_buffer;
210  delete m_polyPatternBuffer;
211  delete m_contourPatternBuffer;
212  delete m_linePatternBuffer;
213  delete m_ptPatternBuffer;
214 }
215 
216 void te::ag::Canvas::setWindow(const double& llx, const double& lly,
217  const double& urx, const double& ury)
218 {
219  m_wllx = llx;
220  m_wlly = lly;
221  m_wurx = urx;
222  m_wury = ury;
223 
224  double xScale = static_cast<double>(m_dwidth) / (urx - llx);
225  double yScale = static_cast<double>(m_dheight) / (ury - lly);
226 
227  m_matrix.reset();
228  m_matrix *= agg::trans_affine_translation(-m_wllx, -m_wlly);
229  m_matrix *= agg::trans_affine_scaling(xScale, yScale);
230 }
231 
232 void te::ag::Canvas::adjustWorldWindow(double& llx, double& lly, double& urx, double& ury,
233  const HAlignType& ha, const VAlignType& va)
234 {
235  double ww = urx - llx;
236  double wh = ury - lly;
237  double widthByHeight = (double)getWidth()/(double)getHeight();
238  if(widthByHeight > ww/wh)
239  {
240  double v = ww;
241  ww = wh * widthByHeight;
242 
243  if(ha == Left)
244  urx = llx + ww;
245  else if(ha == Right)
246  llx = urx - ww;
247  else
248  {
249  llx = llx - (ww - v) / 2.;
250  urx = llx + ww;
251  }
252  }
253  else
254  {
255  double v = wh;
256  wh = ww / widthByHeight;
257 
258  if(va == Top)
259  lly = ury - wh;
260  else if(va == Bottom)
261  ury = lly + wh;
262  else
263  {
264  lly = lly - (wh - v) / 2.;
265  ury = lly + wh;
266  }
267  }
268  setWindow(llx, lly, urx, ury);
269 }
270 
272 {
273  m_bgColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
274 }
275 
277 {
278  return te::color::RGBAColor(m_bgColor.r, m_bgColor.g, m_bgColor.b, m_bgColor.a);
279 }
280 
282 {
283  m_rendererBase.clear(m_bgColor);
284 }
285 
286 void te::ag::Canvas::resize(int w, int h)
287 {
288  m_dwidth = w;
289  m_dheight = h;
290  delete m_buffer;
291  delete m_pixfmt;
292 
293  m_buffer = new unsigned char[m_dwidth * m_dheight * DEPTH/8];
294  memset(m_buffer, 255, m_dwidth * m_dheight * DEPTH/8);
295  m_renderingBuffer = agg::rendering_buffer(m_buffer, m_dwidth, m_dheight, -m_dwidth * DEPTH/8);
296  m_pixfmt = new pixfmt(m_renderingBuffer);
297  m_rendererBase = agg::renderer_base<pixfmt>(*m_pixfmt);
298 
299  clear();
300 }
301 
303 {
304  unsigned int wkbGeomType = *((unsigned int*)(geom + 1)); // skip: 1 (byte order)
305 
306  te::pgis::Convert2OGCWKBType(wkbGeomType);
307 
308  te::gm::GeomType geomType = (te::gm::GeomType)(wkbGeomType);
309 
310  switch(geomType)
311  {
313  return drawMultiPolygon(geom);
314 
315  case te::gm::PolygonType:
316  return drawPolygon(geom);
317 
318  case te::gm::PointType:
319  return drawPoint(geom);
320 
322  return drawMultiLineString(geom);
323 
325  return drawMultiPoint(geom);
326 
328  return drawLineString(geom);
329 
330  case te::gm::PointZType:
331  return drawPointZ(geom);
332 
333  case te::gm::PointMType:
334  return drawPointM(geom);
335 
336  case te::gm::PointZMType:
337  return drawPointZM(geom);
338 
340  return drawGeometryCollection(geom);
341 
342  default:
343  assert(false);
344  return 0;
345  }
346 }
347 
348 char* te::ag::Canvas::drawPoint(char* point)
349 {
350  if((*(unsigned int*)(point + 1)) & TE_EWKB_SRID_FLAG)
351  point += 4;
352 
353  double x = *((double*)(point + 5)); // skip: 1 byte order + sizeof(unsigned int) (geom type = point)
354  double y = *((double*)(point + 13)); // skip: 1 byte order + sizeof(unsigned int) (geom type = point) + sizeof(double)
355 
356  m_matrix.transform(&x, &y);
357  if(m_ptPatternBuffer == 0)
358  {
359  agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(m_rendererBase);
360  m_rendMarker.fill_color(m_ptColor);
361  m_rendMarker.line_color(m_ptColor);
362  m_rendMarker.marker((int)x, (int)y, m_ptWidth/2, m_ptMarkerType);
363  }
364  else
365  {
366  //x -= (double)m_ptPatternRenderingBuffer.width()/2.;
367  //y -= (double)m_ptPatternRenderingBuffer.height()/2.;
368  //m_rendererBase.copy_from(m_ptPatternRenderingBuffer, 0, (int)x, (int)y);
369  pixfmt pixf_img(m_ptPatternRenderingBuffer);
370 
371  pixfmt_pre pixf_pre(m_renderingBuffer);
372  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
373 
374  int w = m_ptWidth / 2;
375  int h = m_ptPatternRenderingBuffer.height() * m_ptWidth / m_ptPatternRenderingBuffer.width() / 2;
376  m_rasterizer.reset();
377  m_rasterizer.move_to_d(x-w, y-h);
378  m_rasterizer.line_to_d(x+w, y-h);
379  m_rasterizer.line_to_d(x+w, y+h);
380  m_rasterizer.line_to_d(x-w, y+h);
381 
382  typedef agg::span_allocator<color_type> span_alloc_type;
383  span_alloc_type sa;
384  agg::image_filter_bilinear filter_kernel;
385  agg::image_filter_lut filter(filter_kernel, true);
386 
387  typedef agg::image_accessor_clone<pixfmt> source_type;
388  source_type source(pixf_img);
389 
390  agg::trans_affine tr;
391  tr.translate(-(x-w), -(y-h));
392  double scale = (double)pixf_img.width() / (double)m_ptWidth;
393  tr.scale(scale, scale);
394 
395  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
396  interpolator_type interpolator(tr);
397 
398  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
399  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
400  }
401 
402  point += 21; // skip: 1 byte order + sizeof(unsigned int == geom type == point) + 2 * sizeof(double)
403 
404  return point;
405 }
406 
407 char* te::ag::Canvas::drawPointZ(char* point)
408 {
409  point = drawPoint(point);
410 
411  return (point + 8); // skip: point + sizeof(double == z coordinate)
412 }
413 
414 char* te::ag::Canvas::drawPointM(char* point)
415 {
416  point = drawPoint(point);
417 
418  return (point + 8); // skip: point + sizeof(double == m coordinate)
419 }
420 
421 char* te::ag::Canvas::drawPointZM(char* point)
422 {
423  point = drawPoint(point);
424 
425  return (point + 16); // skip: point + 2 * sizeof(double == m coordinate + z coordinate)
426 }
427 
429 {
430  if((*(unsigned int*)(mpoint + 1)) & TE_EWKB_SRID_FLAG)
431  mpoint += 4;
432 
433  mpoint += 5; // skip: 1 (byte order) + 4 (geom type == MultiPoint)
434 
435 // let's know how many points we have in the MultiPoint
436  const unsigned int nPts = *((unsigned int*)(mpoint));
437 
438  mpoint += 4; // skip: 4 (num points)
439 
440  for(register unsigned int i = 0; i != nPts; ++i)
441  mpoint = drawPoint(mpoint);
442 
443  return mpoint;
444 }
445 
447 {
448  if((*(unsigned int*)(line + 1)) & TE_EWKB_SRID_FLAG)
449  line += 4;
450 
451 // let's know how many points we have in the line
452  const unsigned int nPoints = *((unsigned int*)(line + 5)); // skip: 1 (byte order) + 4 (geom type = LineString)
453 
454  assert(nPoints >= 2);
455 
456 // let's go to the first point
457  line += 9; // skip: 1 (byte order) + 4 (geom type = LineString) + 4 (number of points)
458 
459  size_t size = nPoints*2;
460  double* v = new double[size];
461 
462  te::gm::Coord2D* coords = (te::gm::Coord2D*)line;
463 
464  int j = 0;
465  for(register unsigned int i = 0; i != nPoints; ++i)
466  {
467  v[j++] = coords[i].x;
468  v[j++] = coords[i].y;
469  }
470 
471  drawLineString(v, size);
472 
473  line += 16 * nPoints; // skip: 2 * sizeof(double) * number of points
474  return line;
475 }
476 
478 {
479  if((*(unsigned int*)(mline + 1)) & TE_EWKB_SRID_FLAG)
480  mline += 4;
481 
482  mline += 5; // skip: 1 (byte order) + 4 (geom type = MultiLineString)
483 
484 // let's know how many lines we have in the MultiLineString
485  const unsigned int nLines = *((unsigned int*)(mline));
486 
487  mline += 4; // skip: 4 (num lines)
488 
489  for(register unsigned int i = 0; i != nLines; ++i)
490  mline = drawLineString(mline);
491 
492  return mline;
493 }
494 
496 {
497  if((*(unsigned int*)(poly + 1)) & TE_EWKB_SRID_FLAG)
498  poly += 4;
499 
500 // let's know how many rings we have in the polygon
501  const unsigned int nRings = *((unsigned int*)(poly + 5)); // skip: 1 (byte order) + 4 (geom type = Polygon)
502 
503  assert(nRings > 0);
504 
505  agg::path_storage path;
506  int pathIndex = path.start_new_path();
507 
508 // let's go the first ring
509  char* ptr = poly + 9; // skip: 1 (byte order) + 4 (geom type = Polygon) + 4 (number of rings)
510 
511  for(register unsigned int i = 0; i != nRings; ++i)
512  {
513  const unsigned int nPoints = *((unsigned int*)ptr);
514 
515  assert(nPoints > 3);
516 
517  ptr += 4; // skip: sizeof(unsigned int) => nPoints
518 
519  double* v = new double[nPoints*2];
520  memcpy(v, (double*)ptr, 16 * nPoints);
521 
522  ptr += (16 * nPoints); // skip: sizeof(unsigned int) (number of points) + 2 * sizeof(double) * nPts
523 
524  path.concat_poly(v, nPoints, true);
525  delete []v;
526  }
527 
528  drawPolygon(path, pathIndex);
529 
530  return ptr;
531 }
532 
534 {
535  if((*(unsigned int*)(mpoly + 1)) & TE_EWKB_SRID_FLAG)
536  mpoly += 4;
537 
538  mpoly += 5; // skip: 1 (byte order) + 4 (geom type = MultiPolygon)
539 
540  const unsigned int nPolygons = *((unsigned int*)mpoly);
541 
542  assert(nPolygons > 0);
543 
544  mpoly += 4; // skip: 4 (num polygons)
545 
546  for(unsigned int i = 0; i != nPolygons; ++i)
547  mpoly = drawPolygon(mpoly);
548 
549  return mpoly;
550 }
551 
553 {
554  if((*(unsigned int*)(g + 1)) & TE_EWKB_SRID_FLAG)
555  g += 4;
556 
557  g += 5; // skip: 1 (byte order) + 4 (geom type = GeometryCollection)
558 
559  const unsigned int nGeoms = *((unsigned int*)g);
560 
561  assert(nGeoms > 0);
562 
563  g += 4; // skip: 4 (num geometries)
564 
565  for(register unsigned int i = 0; i != nGeoms; ++i)
566  g = drawGeometry(g);
567 
568  return g;
569 }
570 
572 {
573  switch(geom->getGeomTypeId())
574  {
579  draw(static_cast<te::gm::MultiPolygon*>(geom));
580  break;
581 
582  case te::gm::PointType:
583  case te::gm::PointZType:
584  case te::gm::PointMType:
585  case te::gm::PointZMType:
586  draw(static_cast<te::gm::Point*>(geom));
587  break;
588 
593  draw(static_cast<te::gm::LineString*>(geom));
594  break;
595 
596  case te::gm::PolygonType:
600  draw(static_cast<te::gm::Polygon*>(geom));
601  break;
602 
607  draw(static_cast<te::gm::MultiLineString*>(geom));
608  break;
609 
614  draw(static_cast<te::gm::MultiPoint*>(geom));
615  break;
616 
621  draw(static_cast<te::gm::GeometryCollection*>(geom));
622  break;
623 
624  default:
625  break;
626  }
627 }
628 
630 {
631  double x = point->getX();
632  double y = point->getY();
633 
634  m_matrix.transform(&x, &y);
635  if(m_ptPatternBuffer == 0)
636  {
637  agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(m_rendererBase);
638  m_rendMarker.fill_color(m_ptColor);
639  m_rendMarker.line_color(m_ptColor);
640  m_rendMarker.marker((int)x, (int)y, m_ptWidth/2, m_ptMarkerType);
641  }
642  else
643  {
644  pixfmt pixf_img(m_ptPatternRenderingBuffer);
645 
646  pixfmt_pre pixf_pre(m_renderingBuffer);
647  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
648 
649  int w = m_ptWidth / 2;
650  int h = m_ptPatternRenderingBuffer.height() * m_ptWidth / m_ptPatternRenderingBuffer.width() / 2;
651  m_rasterizer.reset();
652  m_rasterizer.move_to_d(x-w, y-h);
653  m_rasterizer.line_to_d(x+w, y-h);
654  m_rasterizer.line_to_d(x+w, y+h);
655  m_rasterizer.line_to_d(x-w, y+h);
656 
657  typedef agg::span_allocator<color_type> span_alloc_type;
658  span_alloc_type sa;
659  agg::image_filter_bilinear filter_kernel;
660  agg::image_filter_lut filter(filter_kernel, true);
661 
662  typedef agg::image_accessor_clone<pixfmt> source_type;
663  source_type source(pixf_img);
664 
665  agg::trans_affine tr;
666  tr.translate(-(x-w), -(y-h));
667  double scale = (double)pixf_img.width() / (double)m_ptWidth;
668  tr.scale(scale, scale);
669 
670  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
671  interpolator_type interpolator(tr);
672 
673  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
674  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
675  }
676 }
677 
679 {
680  draw((te::gm::Point*)point);
681 }
682 
684 {
685  draw((te::gm::Point*)point);
686 }
687 
689 {
690  draw((te::gm::Point*)point);
691 }
692 
694 {
695  size_t size = mpoint->getNumGeometries();
696 
697  switch(mpoint->getGeomTypeId())
698  {
699  case te::gm::PointType :
701  for(size_t i = 0; i < size; ++i)
702  draw(static_cast<te::gm::Point*>(mpoint->getGeometryN(i)));
703  break;
704 
705  case te::gm::PointZType :
707  for(size_t i = 0; i < size; ++i)
708  draw(static_cast<te::gm::PointZ*>(mpoint->getGeometryN(i)));
709  break;
710 
711  case te::gm::PointMType :
713  for(size_t i = 0; i < size; ++i)
714  draw(static_cast<te::gm::PointM*>(mpoint->getGeometryN(i)));
715  break;
716 
717  case te::gm::PointZMType :
719  for(size_t i = 0; i < size; ++i)
720  draw(static_cast<te::gm::PointZM*>(mpoint->getGeometryN(i)));
721  break;
722 
723  default:
724  assert(false);
725  break;
726  }
727 }
728 
730 {
731  te::gm::Coord2D* coords = line->getCoordinates();
732  size_t size = line->getNPoints();
733  double* v = new double[size*2];
734 
735  int j = 0;
736  for(register size_t i = 0; i != size; ++i)
737  {
738  v[j++] = coords[i].x;
739  v[j++] = coords[i].y;
740  }
741 
742  drawLineString(v, size);
743 }
744 
745 void te::ag::Canvas::drawLineString(double* v, const size_t& size)
746 {
747  if(m_linePatternBuffer == 0) // draw solid color with alpha
748  {
749  agg::path_storage path;
750  int pathIndex = path.start_new_path();
751  path.concat_poly(v, size, false);
752  delete []v;
753 
754  m_rasterizer.gamma(agg::gamma_threshold(.4));
755 
756  agg::conv_transform<agg::path_storage> fill(path, m_matrix);
757  agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
758 
759  stroke.width(m_lineWidth);
760  m_rasterizer.add_path(stroke, pathIndex); // without roundoff
761  agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_lineColor); // with anti aliase
762  path.free_all();
763  path.remove_all();
764  }
765  else // draw with pattern
766  {
767  pattern_src_brightness_to_alpha_rgba8 p1(m_linePatternRenderingBuffer);
768 
769  agg::pattern_filter_bilinear_rgba8 fltr; // Filtering functor
770 
771  // agg::line_image_pattern is the main container for the patterns. It creates
772  // a copy of the patterns extended according to the needs of the filter.
773  // agg::line_image_pattern can operate with arbitrary image width, but if the
774  // width of the pattern is power of 2, it's better to use the modified
775  // version agg::line_image_pattern_pow2 because it works about 15-25 percent
776  // faster than agg::line_image_pattern (because of using simple masking instead
777  // of expensive '%' operation).
778  typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
779  typedef agg::renderer_base<pixfmt> base_ren_type;
780  typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
781  typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
782 
783  typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
784  typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
785 
786  //-- Create uninitialized and set the source
787  pattern_type patt(fltr);
788  patt.create(p1);
789  renderer_img_type ren_img(m_rendererBase, patt);
790  rasterizer_img_type ras_img(ren_img);
791 
792  //-- create uninitialized and set parameters
793  agg::line_profile_aa profile;
794  profile.smoother_width(p1.height()); //optional
795  profile.width(p1.height()-4); //mandatory!
796  renderer_line_type ren_line(m_rendererBase, profile);
797  ren_line.color(agg::rgba8(200,200,200)); //mandatory!
798  rasterizer_line_type ras_line(ren_line);
799  //ras_line.round_cap(true); //optional
800  //ras_line.line_join(agg::outline_no_join); //optional
801 
802  ren_img.scale_x(1.);
803  ren_img.start_x(p1.width()/2.);
804 
805  agg::poly_plain_adaptor<double> vs(v, size, false);
806  agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs, m_matrix);
807  ras_line.add_path(trans);
808  ras_img.add_path(trans);
809 
810  delete []v;
811  }
812 }
813 
815 {
816  size_t size = mline->getNumGeometries();
817 
818  for(size_t i = 0; i < size; ++i)
819  draw(static_cast<te::gm::LineString*>(mline->getGeometryN(i)));
820 }
821 
823 {
824  size_t nRings = poly->getNumRings();
825 
826  assert(nRings > 0);
827 
828  agg::path_storage path;
829  int pathIndex = path.start_new_path();
830 
831  for(register size_t i = 0; i != nRings; ++i)
832  {
833  te::gm::LinearRing* ring = static_cast<te::gm::LinearRing*>(poly->getRingN(i));
834 
835  const size_t nPoints = ring->getNPoints();
836 
837  assert(nPoints > 3);
838 
839  double* v = new double[nPoints*2];
840  memcpy(v, (double*)(ring->getCoordinates()), 16 * nPoints);
841 
842  path.concat_poly(v, nPoints, true);
843  delete []v;
844  }
845 
846  drawPolygon(path, pathIndex);
847 }
848 
849 void te::ag::Canvas::drawPolygon(agg::path_storage& path, const int& index)
850 {
851  agg::conv_transform<agg::path_storage> transPath(path, m_matrix);
852 
853  if(m_polyPatternBuffer == 0) // fill solid color with alpha
854  {
855  m_rasterizer.gamma(agg::gamma_threshold(.4));
856  m_rasterizer.filling_rule(agg::fill_even_odd);
857 
858  m_rasterizer.add_path(transPath, index); // without roundoff
859  agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_polyFillColor); // with anti aliase
860  }
861  else // fill with pattern with alpha
862  {
863  if(m_polyPatternWidth != m_polyPatternRenderingBuffer.width()) // adjust pattern size
864  {
865  int width = m_polyPatternWidth;
866  int height = m_polyPatternRenderingBuffer.height() * m_polyPatternWidth / m_polyPatternRenderingBuffer.width();
867  agg::int8u* buf = new agg::int8u[width * height * DEPTH/8];
868  memset(buf, 0, width * height * DEPTH/8);
869  agg::rendering_buffer rbuf(buf, width, height, -width * DEPTH/8);
870 
871  pixfmt pixf_img(m_polyPatternRenderingBuffer);
872  pixfmt_pre pixf_pre(rbuf);
873  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
874 
875  m_rasterizer.reset();
876  m_rasterizer.move_to_d(0, 0);
877  m_rasterizer.line_to_d(width, 0);
878  m_rasterizer.line_to_d(width-1, height-1);
879  m_rasterizer.line_to_d(0, height-1);
880 
881  typedef agg::span_allocator<color_type> span_alloc_type;
882  span_alloc_type sa;
883  agg::image_filter_bilinear filter_kernel;
884  agg::image_filter_lut filter(filter_kernel, true);
885 
886  typedef agg::image_accessor_clone<pixfmt> source_type;
887  source_type source(pixf_img);
888 
889  agg::trans_affine tr;
890  double scale = (double)pixf_img.width() / (double)width;
891  tr.scale(scale, scale);
892 
893  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
894  interpolator_type interpolator(tr);
895 
896  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
897  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
898  delete m_polyPatternBuffer;
899  m_polyPatternBuffer = buf;
900  m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, width, height, -width * DEPTH/8);
901  }
902 
903  // fill pattern with alpha
904  pixfmt_pre* pixf_pre = new pixfmt_pre(m_renderingBuffer);
905  agg::renderer_base<pixfmt_pre> rb_pre(*pixf_pre);
906 
907  typedef agg::wrap_mode_repeat_auto_pow2 repeat_x_type;
908  typedef agg::wrap_mode_repeat_auto_pow2 repeat_y_type;
909  typedef agg::image_accessor_wrap<pixfmt, repeat_x_type, repeat_y_type> img_source_type;
910  typedef agg::span_pattern_rgb<img_source_type> span_gen_type;
911 
912  agg::span_allocator<color_type> sa;
913  pixfmt img_pixf(m_polyPatternRenderingBuffer);
914  img_source_type img_src(img_pixf);
915  span_gen_type sg(img_src, 0, 0); // 0, 0 eh o inicio do pattern
916 
917  // esta opacidade tem que ser a mesma da opacidade usada no pattern
918  sg.alpha(span_gen_type::value_type(m_polyPatternOpacity));
919 
920  m_rasterizer.add_path(transPath);
921  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
922  }
923 
924  if(m_contourPatternBuffer == 0) // draw simple contour
925  {
926  agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(transPath);
927  stroke.width(m_polyContourWidth);
928  m_rasterizer.add_path(stroke, index); // without roundoff
929  agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_polyContourColor); // with anti aliase
930  }
931  else // draw pattern contour
932  {
933  pattern_src_brightness_to_alpha_rgba8 p1(m_contourPatternRenderingBuffer);
934 
935  agg::pattern_filter_bilinear_rgba8 fltr; // Filtering functor
936 
937  // agg::line_image_pattern is the main container for the patterns. It creates
938  // a copy of the patterns extended according to the needs of the filter.
939  // agg::line_image_pattern can operate with arbitrary image width, but if the
940  // width of the pattern is power of 2, it's better to use the modified
941  // version agg::line_image_pattern_pow2 because it works about 15-25 percent
942  // faster than agg::line_image_pattern (because of using simple masking instead
943  // of expensive '%' operation).
944  typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
945  typedef agg::renderer_base<pixfmt> base_ren_type;
946  typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
947  typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
948 
949  typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
950  typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
951 
952  //-- Create uninitialized and set the source
953  pattern_type patt(fltr);
954  patt.create(p1);
955  renderer_img_type ren_img(m_rendererBase, patt);
956  rasterizer_img_type ras_img(ren_img);
957 
958  //-- create uninitialized and set parameters
959  agg::line_profile_aa profile;
960  profile.smoother_width(p1.height()); //optional
961  profile.width(p1.height()-4); //mandatory!
962  renderer_line_type ren_line(m_rendererBase, profile);
963  ren_line.color(agg::rgba8(200,200,200)); //mandatory!
964  rasterizer_line_type ras_line(ren_line);
965  //ras_line.round_cap(true); //optional
966  //ras_line.line_join(agg::outline_no_join); //optional
967 
968  ren_img.scale_x(1.);
969  ren_img.start_x(p1.width()/2.);
970 
971  double *v = 0;
972  double x, y;
973  int i, j, k, n;
974  path.rewind(index);
975  int size = path.total_vertices();
976 
977  for(k = i = 0; i < size; ++i)
978  {
979  if(path.vertex(i, &x, &y) != 79)
980  continue;
981  j = k;
982  k = i - k;
983  v = new double[(k+1)<<1];
984  n = 0;
985  while(j < i)
986  {
987  path.vertex(j, &x, &y);
988  v[n++] = x;
989  v[n++] = y;
990  ++j;
991  }
992  v[n++] = v[0];
993  v[n++] = v[1];
994 
995  agg::poly_plain_adaptor<double> vs(v, k+1, false);
996  agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs, m_matrix);
997  ras_line.add_path(trans);
998  ras_img.add_path(trans);
999  delete []v;
1000  ++k;
1001  }
1002  }
1003  path.free_all();
1004  path.remove_all();
1005 }
1006 
1008 {
1009  size_t size = mpoly->getNumGeometries();
1010 
1011  for(size_t i = 0; i < size; ++i)
1012  draw(static_cast<te::gm::Polygon*>(mpoly->getGeometryN(i)));
1013 }
1014 
1016 {
1017  size_t size = g->getNumGeometries();
1018 
1019  for(size_t i = 0; i < size; ++i)
1020  draw(g->getGeometryN(i));
1021 }
1022 
1024 {
1025  //if(!m_device)
1026  // return 0;
1027 
1028  //if(m_device->devType() == 4)
1029  // return 0;
1030 
1031  //QByteArray bytes;
1032  //QBuffer buffer(&bytes);
1033  //buffer.open(QIODevice::WriteOnly);
1034 
1035  //switch(t)
1036  //{
1037  // case PNG:
1038  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_pngFmt);
1039  // break;
1040 
1041  // case JPEG:
1042  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_jpegFmt);
1043  // break;
1044 
1045  // case GIF:
1046  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_gifFmt);
1047  // break;
1048 
1049  // case BMP:
1050  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_bmpFmt);
1051  // break;
1052 
1053  // case XPM:
1054  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_xpmFmt);
1055  // break;
1056 
1057  // case XBM:
1058  // ((QPixmap*)m_device)->save(&buffer, Platform::sm_xbmFmt);
1059  // break;
1060 
1061  // default:
1062  // return 0;
1063  //};
1064 
1065  //int nbytes = bytes.size();
1066 
1067  //char* result = new char[nbytes];
1068 
1069  //memcpy(result, bytes.data(), nbytes);
1070 
1071  //size = nbytes;
1072 
1073  //return result;
1074  return 0;
1075 }
1076 
1077 void te::ag::Canvas::freeImage(char* img) const
1078 {
1079  delete [] img;
1080 }
1081 
1083 {
1084 }
1085 
1087 {
1088  int i, j, k, n;
1089 
1090  agg::int8u* buf = new agg::int8u[h * w * DEPTH/8];
1091  for(i = 0; i < h; ++i)
1092  {
1093  k = i * 4 * w;
1094  for(j = 0; j < w; ++j)
1095  {
1096  te::color::RGBAColor c = src[i][j];
1097  n = k + 4 * j;
1098  buf[n] = (agg::int8u)c.getRed();
1099  buf[n + 1] = (agg::int8u)c.getGreen();
1100  buf[n + 2] = (agg::int8u)c.getBlue();
1101  buf[n + 3] = (agg::int8u)c.getAlpha();
1102  }
1103  }
1104  agg::rendering_buffer rbuf(buf, w, h, -w * DEPTH/8);
1105 
1106  pixfmt pixf_img(rbuf);
1107  pixfmt_pre pixf_pre(m_renderingBuffer);
1108  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1109 
1110  typedef agg::span_allocator<color_type> span_alloc_type;
1111  span_alloc_type sa;
1112  agg::image_filter_bilinear filter_kernel;
1113  agg::image_filter_lut filter(filter_kernel, true);
1114 
1115  typedef agg::image_accessor_clone<pixfmt> source_type;
1116  source_type source(pixf_img);
1117 
1118  agg::trans_affine tr;
1119  int ty = m_dheight - rbuf.height();
1120  tr.translate(0, -ty);
1121  tr.scale(1., 1.);
1122  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1123  interpolator_type interpolator(tr);
1124 
1125  m_rasterizer.reset();
1126  m_rasterizer.move_to_d(0, ty);
1127  m_rasterizer.line_to_d(w, ty);
1128  m_rasterizer.line_to_d(w, ty + rbuf.height());
1129  m_rasterizer.line_to_d(0, ty + rbuf.height());
1130 
1131  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1132  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1133  delete buf;
1134 }
1135 
1136 void te::ag::Canvas::drawImage(int x, int y, char* src, int size, te::map::Canvas::ImageType t)
1137 {
1138  //QPixmap pix;
1139  //const char* f = GetFormat(t);
1140  //pix.loadFromData((unsigned char*)src, size, f);
1141  //m_painter.setWorldMatrixEnabled(false);
1142  //m_painter.drawPixmap(x, y, pix);
1143  //m_painter.setWorldMatrixEnabled(true);
1144 }
1145 
1146 void te::ag::Canvas::drawImage(int x, int y, te::color::RGBAColor** src, int w, int h)
1147 {
1148  int i, j, k, n;
1149 
1150  agg::int8u* buf = new agg::int8u[h * w * DEPTH/8];
1151  for(i = 0; i < h; ++i)
1152  {
1153  k = i * 4 * w;
1154  for(j = 0; j < w; ++j)
1155  {
1156  te::color::RGBAColor c = src[i][j];
1157  n = k + 4 * j;
1158  buf[n] = (agg::int8u)c.getRed();
1159  buf[n + 1] = (agg::int8u)c.getGreen();
1160  buf[n + 2] = (agg::int8u)c.getBlue();
1161  buf[n + 3] = (agg::int8u)c.getAlpha();
1162  }
1163  }
1164  agg::rendering_buffer rbuf(buf, w, h, -w * DEPTH/8);
1165 
1166  pixfmt pixf_img(rbuf);
1167  pixfmt_pre pixf_pre(m_renderingBuffer);
1168  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1169 
1170  typedef agg::span_allocator<color_type> span_alloc_type;
1171  span_alloc_type sa;
1172  agg::image_filter_bilinear filter_kernel;
1173  agg::image_filter_lut filter(filter_kernel, true);
1174 
1175  typedef agg::image_accessor_clone<pixfmt> source_type;
1176  source_type source(pixf_img);
1177 
1178  agg::trans_affine tr;
1179  int ty = m_dheight - rbuf.height() -y;
1180  tr.translate(-x, -ty);
1181  tr.scale(1., 1.);
1182  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1183  interpolator_type interpolator(tr);
1184 
1185  m_rasterizer.reset();
1186  m_rasterizer.move_to_d(x, ty);
1187  m_rasterizer.line_to_d(x+w, ty);
1188  m_rasterizer.line_to_d(x+w, ty + rbuf.height());
1189  m_rasterizer.line_to_d(x, ty + rbuf.height());
1190 
1191  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1192  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1193  delete buf;
1194 }
1195 
1196 void te::ag::Canvas::drawImage(int x, int y, int w, int h, char* src, int size, te::map::Canvas::ImageType t)
1197 {
1198  //QPixmap pix;
1199  //const char* f = GetFormat(t);
1200  //pix.loadFromData((unsigned char*)src, size, f);
1201  //m_painter.setWorldMatrixEnabled(false);
1202  //m_painter.drawPixmap(x, y, w, h, pix);
1203  //m_painter.setWorldMatrixEnabled(true);
1204 }
1205 
1206 void te::ag::Canvas::drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int srcw, int srch)
1207 {
1208  int i, j, k, n;
1209 
1210  agg::int8u* buf = new agg::int8u[srch * srcw * DEPTH/8];
1211  for(i = 0; i < srch; ++i)
1212  {
1213  k = i * 4 * srcw;
1214  for(j = 0; j < srcw; ++j)
1215  {
1216  te::color::RGBAColor c = src[i][j];
1217  n = k + 4 * j;
1218  buf[n] = (agg::int8u)c.getRed();
1219  buf[n + 1] = (agg::int8u)c.getGreen();
1220  buf[n + 2] = (agg::int8u)c.getBlue();
1221  buf[n + 3] = (agg::int8u)c.getAlpha();
1222  }
1223  }
1224  agg::rendering_buffer rbuf(buf, srcw, srch, -srcw * DEPTH/8);
1225 
1226  pixfmt pixf_img(rbuf);
1227  pixfmt_pre pixf_pre(m_renderingBuffer);
1228  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1229 
1230  typedef agg::span_allocator<color_type> span_alloc_type;
1231  span_alloc_type sa;
1232  agg::image_filter_bilinear filter_kernel;
1233  agg::image_filter_lut filter(filter_kernel, true);
1234 
1235  typedef agg::image_accessor_clone<pixfmt> source_type;
1236  source_type source(pixf_img);
1237 
1238  agg::trans_affine tr;
1239  double xscale = (double)pixf_img.width() / (double)w;
1240  double yscale = (double)pixf_img.height() / (double)h;
1241  int nh = (int)((double)(rbuf.height())/yscale + .5);
1242  int ty = m_dheight - nh - y;
1243  tr.translate(-x, -ty);
1244  tr.scale(xscale, yscale);
1245 
1246  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1247  interpolator_type interpolator(tr);
1248 
1249  m_rasterizer.reset();
1250  m_rasterizer.move_to_d(x, ty);
1251  m_rasterizer.line_to_d(x+w, ty);
1252  m_rasterizer.line_to_d(x+w, ty+h);
1253  m_rasterizer.line_to_d(x, ty+h);
1254 
1255  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1256  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1257  delete buf;
1258 }
1259 
1260 void te::ag::Canvas::drawImage(int x, int y, int w, int h, char* src, int size, te::map::Canvas::ImageType t, int sx, int sy, int sw, int sh)
1261 {
1262  //QPixmap pix;
1263  //const char* f = GetFormat(t);
1264  //pix.loadFromData((unsigned char*)src, size, f);
1265  //m_painter.setWorldMatrixEnabled(false);
1266  //m_painter.drawPixmap(x, y, w, h, pix, sx, sy, sw, sh);
1267  //m_painter.setWorldMatrixEnabled(true);
1268 }
1269 
1270 void te::ag::Canvas::drawImage(int x, int y, int w, int h, te::color::RGBAColor** src, int sx, int sy, int sw, int sh)
1271 {
1272  int i, j, k, n;
1273 
1274  agg::int8u* buf = new agg::int8u[sh * sw * DEPTH/8];
1275  for(i = sy; i < sh; ++i)
1276  {
1277  k = (i - sy) * 4 * sw;
1278  for(j = sx; j < sw; ++j)
1279  {
1280  te::color::RGBAColor c = src[i][j];
1281  n = k + 4 * (j - sx);
1282  buf[n] = (agg::int8u)c.getRed();
1283  buf[n + 1] = (agg::int8u)c.getGreen();
1284  buf[n + 2] = (agg::int8u)c.getBlue();
1285  buf[n + 3] = (agg::int8u)c.getAlpha();
1286  }
1287  }
1288  agg::rendering_buffer rbuf(buf, sw, sh, -sw * DEPTH/8);
1289 
1290  pixfmt pixf_img(rbuf);
1291  pixfmt_pre pixf_pre(m_renderingBuffer);
1292  agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1293 
1294  typedef agg::span_allocator<color_type> span_alloc_type;
1295  span_alloc_type sa;
1296  agg::image_filter_bilinear filter_kernel;
1297  agg::image_filter_lut filter(filter_kernel, true);
1298 
1299  typedef agg::image_accessor_clone<pixfmt> source_type;
1300  source_type source(pixf_img);
1301 
1302  agg::trans_affine tr;
1303  double xscale = (double)pixf_img.width() / (double)w;
1304  double yscale = (double)pixf_img.height() / (double)h;
1305  int nh = (int)((double)(rbuf.height())/yscale + .5);
1306  int ty = m_dheight - nh - y;
1307  tr.translate(-x, -ty);
1308  tr.scale(xscale, yscale);
1309 
1310  typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1311  interpolator_type interpolator(tr);
1312 
1313  m_rasterizer.reset();
1314  m_rasterizer.move_to_d(x, ty);
1315  m_rasterizer.line_to_d(x+w, ty);
1316  m_rasterizer.line_to_d(x+w, ty+h);
1317  m_rasterizer.line_to_d(x, ty+h);
1318 
1319  agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1320  agg::render_scanlines_aa(m_rasterizer, m_scanline, rb_pre, sa, sg);
1321  delete buf;}
1322 
1323 void te::ag::Canvas::drawPixel(int x, int y)
1324 {
1325  int yy = m_dheight - y - 1;
1326  m_rendererBase.blend_pixel(x, yy, m_ptColor, agg::cover_full);
1327 }
1328 
1329 void te::ag::Canvas::drawPixel(int x, int y, const te::color::RGBAColor& color)
1330 {
1331  int yy = m_dheight - y - 1;
1332  color_type cor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
1333  m_rendererBase.blend_pixel(x, yy, cor, agg::cover_full);
1334 }
1335 
1336 void te::ag::Canvas::drawText(int x, int y,
1337  const std::string& tx,
1338  float angle,
1341 {
1342  agg::trans_affine matrix;
1343  matrix.scale(m_txXScale, 1.);
1344  m_fontEngine->transform(matrix);
1345  double xa = 0.;
1346  double ya = 0.;
1347  const char* p = tx.c_str();
1348 
1349  while(*p)
1350  {
1351  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1352  if(glyph)
1353  {
1354  m_fontManager->add_kerning(&xa, &ya);
1355  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1356 
1357  // increment pen position
1358  xa += glyph->advance_x;
1359  ya += glyph->advance_y;
1360  }
1361  ++p;
1362  }
1363  double txWidth = xa;
1364 
1365  double xi = x;
1366  double yi = y;
1367  matrix.reset();
1368  matrix.translate(-xi, -yi);
1369  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1370  matrix.translate(xi, yi);
1371 
1372  if(hAlign == te::at::CenterH)
1373  xi = x + txWidth / 2.;
1374  else if(hAlign == te::at::End)
1375  xi = x + txWidth;
1376 
1377  if(vAlign == te::at::Top)
1378  yi = y + m_fontEngine->height();
1379  else if(vAlign == te::at::CenterV)
1380  yi = y + m_fontEngine->height() * 3. /8.;
1381  else if(vAlign == te::at::Bottom)
1382  yi = y - m_fontEngine->height() / 4.;
1383 
1384  matrix.transform(&xi, &yi);
1385 
1386  //int size = 2;
1387  double xx = x - (xi - x);
1388  double yy = m_dheight - yi;
1389  double xf = xx + (m_dwidth<<2);
1390  double yf = yy;
1391  matrix.reset();
1392  matrix.translate(-xx, -yy);
1393  matrix.scale(m_txXScale, 1.);
1394  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1395  matrix.translate(xx, yy);
1396  matrix.transform(&xf, &yf);
1397 
1398  agg::path_storage path;
1399  int pathIndex = path.start_new_path();
1400  path.move_to(xx, yy);
1401  path.line_to(xf, yf);
1402 
1403  agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1404 
1405  agg::trans_single_path tcurve;
1406  tcurve.add_path(path);
1407  tcurve.preserve_x_scale(true);
1408 
1409  conv_font_curve_type fcurves(m_fontManager->path_adaptor());
1410 
1411  conv_font_segm_type fsegm(fcurves);
1412  conv_font_trans_type ftrans(fsegm, tcurve);
1413  fsegm.approximation_scale(3.0);
1414  fcurves.approximation_scale(2.0);
1415 
1416  xa = 0.;
1417  ya = 0.;
1418  p = tx.c_str();
1419 
1420  while(*p)
1421  {
1422  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1423  if(glyph)
1424  {
1425  if(xa > tcurve.total_length())
1426  break;
1427 
1428  m_fontManager->add_kerning(&xa, &ya);
1429  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1430 
1431  if(glyph->data_type == agg::glyph_data_outline)
1432  {
1433  m_rasterizer.reset();
1434  m_rasterizer.add_path(ftrans);
1435  rendererSolid.color(m_txColor);
1436  agg::render_scanlines(m_rasterizer, m_scanline, rendererSolid);
1437  }
1438 
1439  // increment pen position
1440  xa += glyph->advance_x;
1441  ya += glyph->advance_y;
1442  }
1443  ++p;
1444  }
1445  path.free_all();
1446  path.remove_all();
1447 
1448  if(m_txDecorationType > 0)
1449  {
1450  matrix.reset();
1451  matrix.translate(-xx, -yy);
1452  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1453  matrix.translate(xx, yy);
1454 
1455  xf = xx + xa;
1456  yf = yy + ya + m_fontEngine->height();
1457  yy -= m_fontEngine->height()/4.;
1458 
1459  if(m_txDecorationType == 1)
1460  yy += m_fontEngine->height()/4.;
1461  else if(m_txDecorationType == 2)
1462  yy += m_fontEngine->height() + m_fontEngine->height()/4.;
1463  else if(m_txDecorationType == 3)
1464  yy += (m_fontEngine->height() + m_fontEngine->height()/4.) / 2.;
1465 
1466  pathIndex = path.start_new_path();
1467  double a, b;
1468  a = xx;
1469  b = yy;
1470  matrix.transform(&a, &b);
1471  path.move_to(a, b);
1472  a = xf;
1473  b = yy;
1474  matrix.transform(&a, &b);
1475  path.line_to(a, b);
1476  path.close_polygon(false);
1477  matrix.reset();
1478  m_rasterizer.gamma(agg::gamma_threshold(.4));
1479  agg::conv_transform<agg::path_storage> fill(path, matrix);
1480  agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1481  stroke.width(m_txDecorationWidth);
1482  m_rasterizer.add_path(stroke, pathIndex); // without roundoff
1483  agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_txDecorationColor); // with anti aliase
1484 
1485  path.free_all();
1486  path.remove_all();
1487  }
1488 }
1489 
1490 void te::ag::Canvas::drawText(double* vin, const int& size, const agg::trans_affine& matrix, const std::string& tx)
1491 {
1492  int fontSize = 24;
1493  int distx = 0;
1494  int disty = 0;
1495  int i, s = size<<1;
1496  //char buf[200];
1497  //FILE* fp = fopen("C:\\lixo\\testetxt.txt", "a");
1498  double *v = 0;
1499  if(matrix.is_identity() == false)
1500  {
1501  v = new double[size<<1];
1502  double x, y;
1503  int i = 0;
1504  while(i < s)
1505  {
1506  x = vin[i];
1507  y = vin[i+1];
1508  matrix.transform(&x, &y);
1509  v[i++] = (int)(x+.5);
1510  v[i++] = (int)(y+.5);
1511  if(i > 3)
1512  {
1513  distx += abs((int)(v[i-2] - v[i-4]));
1514  disty += abs((int)(v[i-1] - v[i-3]));
1515  }
1516  //sprintf(buf, "%d %d\n", (int)x, (int)y);
1517  //fwrite(buf, 1, strlen(buf), fp);
1518  }
1519  //fwrite("\n\n\n", 1, strlen("\n\n\n"), fp);
1520  //fclose(fp);
1521  delete []vin;
1522 
1523  if(distx == 0 && disty == 0)
1524  {
1525  delete []v;
1526  return;
1527  }
1528  }
1529  else
1530  {
1531  v = vin;
1532  i = 4;
1533  while(i <= s)
1534  {
1535  distx += abs((int)(v[i-2] - v[i-4]));
1536  disty += abs((int)(v[i-1] - v[i-3]));
1537  i += 2;
1538  }
1539  }
1540 
1541  int len = (int)tx.size() * fontSize/2;
1542  int dist = (int)sqrt((double)(distx * distx + disty * disty));
1543  if(len > dist)
1544  {
1545  delete []v;
1546  return;
1547  }
1548 
1549  agg::path_storage path;
1550  path.start_new_path();
1551  //int pathIndex = path.start_new_path();
1552  path.concat_poly(v, size, false);
1553  delete []v;
1554 
1555  agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1556 
1557  agg::trans_single_path tcurve;
1558  tcurve.add_path(path);
1559  tcurve.preserve_x_scale(true);
1560 
1561  conv_font_curve_type fcurves(m_fontManager->path_adaptor());
1562 
1563  conv_font_segm_type fsegm(fcurves);
1564  conv_font_trans_type ftrans(fsegm, tcurve);
1565  fsegm.approximation_scale(3.0);
1566  fcurves.approximation_scale(2.0);
1567 
1568  m_fontEngine->height(fontSize);
1569 
1570  bool b = true;
1571  std::string font = m_fontEngine->font_signature();
1572  if(font.find("Californian FB") == std::string::npos)
1573  b = m_fontEngine->create_font("Californian FB", agg::glyph_ren_outline);
1574 
1575  if(b)
1576  {
1577  double x = (double)dist/2. - (double)len/2.; // distancia horizontal do texto em relacao ao inicio da linha
1578  double y = 2.0; // distancia vertical do texto em relacao aa linha
1579  const char* p = tx.c_str();
1580 
1581  while(*p)
1582  {
1583  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1584  if(glyph)
1585  {
1586  if(x > tcurve.total_length())
1587  break;
1588 
1589  m_fontManager->add_kerning(&x, &y);
1590  m_fontManager->init_embedded_adaptors(glyph, x, y);
1591 
1592  if(glyph->data_type == agg::glyph_data_outline)
1593  {
1594  m_rasterizer.reset();
1595  m_rasterizer.add_path(ftrans);
1596  rendererSolid.color(agg::rgba8(0, 0, 0));
1597  agg::render_scanlines(m_rasterizer, m_scanline, rendererSolid);
1598  }
1599 
1600  // increment pen position
1601  x += glyph->advance_x;
1602  y += glyph->advance_y;
1603  }
1604  ++p;
1605  }
1606  }
1607  path.free_all();
1608  path.remove_all();
1609 }
1610 
1612  const std::string& tx,
1613  float angle,
1616 {
1617  double x = wp.getX();
1618  double y = wp.getY();
1619 
1620  m_matrix.transform(&x, &y);
1621  drawText((int)x, (int)y, tx, angle, hAlign, vAlign);
1622 }
1623 
1624 void te::ag::Canvas::drawText(const double& xi, const double& yi,
1625  const std::string& tx,
1626  float angle,
1629 {
1630  double x = xi;
1631  double y = yi;
1632 
1633  m_matrix.transform(&x, &y);
1634  drawText((int)x, (int)y, tx, angle, hAlign, vAlign);
1635 }
1636 
1638 {
1639  size_t size = tx->getElements().size();
1640  if(size == 0)
1641  return;
1642 
1643  size_t i = 0;
1644  while(tx->getElements()[i]->getAttributes() == 0 && i < size)
1645  ++i;
1646 
1649 
1650  while(i < size)
1651  {
1652  // set attributes
1653  te::at::Element* element = tx->getElements()[i];
1655  if(atr)
1656  {
1657  // get font family
1658  std::string family = ((te::at::Attributes*)atr)->getFamily();
1659  setFontFamily(family);
1660 
1661  // get font point size
1662  const double& pointSize = atr->getPointSize();
1663  setTextPointSize(pointSize);
1664 
1665  // get font weight
1666  const te::at::FontWeight& weight = atr->getWeight();
1667  setTextWeight(weight);
1668 
1669  // get font style
1670  const te::at::FontStyle& style = atr->getStyle();
1671  setTextStyle(style);
1672 
1673  // get font decoration
1674  const te::at::TextDecoration& decoration = atr->getDecoration();
1675  if(decoration == te::at::None)
1676  {
1677  setTextUnderline(false);
1678  setTextOverline(false);
1679  setTextStrikeOut(false);
1680  }
1681  else if(decoration == te::at::Overline)
1682  setTextOverline(true);
1683  else if(style == te::at::Underline)
1684  setTextUnderline(true);
1685  else
1686  setTextStrikeOut(true);
1687 
1688  // get letter spacing
1689  m_textLetterSpacing = atr->getLetterSpacing();
1690  // nao sei o que fazer ????????????
1691 
1692  // get word spacing
1693  m_textWordSpacing = atr->getLetterSpacing();
1694  // nao sei o que fazer ????????????
1695 
1696  // get text color and opacity
1697  //const std::string& cor = atr->getTextColor();
1698  //QColor qcor(cor.c_str());
1699  int opacity = (int)(atr->getTextOpacity() * 255.);
1700  setTextOpacity(opacity);
1701 
1702  // // get stroke color and opacity
1703  // const std::string& sCor = atr->getTextStrokeColor();
1704  // QColor qscor(sCor.c_str());
1705  // int sOpacity = atr->getTextStrokeOpacity() * 255.;
1706  // qscor.setAlpha(sOpacity);
1707  // m_textPen = QPen(qscor);
1708 
1709  // // get stroke width
1710  // m_textPen.setWidth(10. * atr->getTextStrokeWidth() * (double)getResolution() / 72.);
1711 
1712  // get horizontal alignment
1713  hAlign = atr->getHorizontalAlignment();
1714 
1715  // get vertical alignment
1716  vAlign = atr->getVerticalAlignment();
1717 
1718  // get multi line justification
1719  m_textLineJustification = atr->getLineJustification();
1720  // parece haver confusao entre horizontal alignment e line justification ????????????
1721  // por enquanto estou usando somente horizontal aligment.
1722 
1723  // get multi line spacing
1724  m_textLineSpacing = atr->getLineSpacing();
1725  // como usar isto (0...1) ????????????
1726  }
1727 
1728  if(element->getLeaderLine() == 0) // without leaderLine
1729  {
1730  //supondo que location e' do tipo ponto
1731  const te::gm::Point* pt = static_cast<const te::gm::Point*>(element->getLocation());
1732  std::string text = element->getValue();
1733  size_t p = text.find("\n");
1734  double hline = 10.;
1735  te::gm::Point* pclone = 0;
1736  if(p != std::string::npos)
1737  {
1740  hline = env->m_ury - env->m_lly;
1741  hline *= m_textLineSpacing;
1742  pclone = (te::gm::Point*)pt->clone();
1743  delete poly;
1744  delete env;
1745  }
1746  while(p != std::string::npos) // multiline text
1747  {
1748  std::string t = text.substr(0, p);
1749  drawText(*pclone, t, 0., hAlign, vAlign);
1750  text = text.substr(p+1);
1751  p = text.find("\n");
1752  pclone->setY(pclone->getY() - hline); // next line
1753  }
1754  if(pclone) // multiline
1755  drawText(*pclone, text, 0., hAlign, vAlign);
1756  else
1757  drawText(*pt, text, 0., hAlign, vAlign);
1758  }
1759  else // with leaderLine
1760  {
1761  }
1762 
1763  ++i;
1764  }
1765 }
1766 
1767 void te::ag::Canvas::drawTextBoundary(int x, int y, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
1768 {
1769  agg::trans_affine matrix;
1770  matrix.scale(m_txXScale, 1.);
1771  m_fontEngine->transform(matrix);
1772  double xa = 0.;
1773  double ya = 0.;
1774  const char* p = tx.c_str();
1775 
1776  while(*p)
1777  {
1778  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1779  if(glyph)
1780  {
1781  m_fontManager->add_kerning(&xa, &ya);
1782  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1783 
1784  // increment pen position
1785  xa += glyph->advance_x;
1786  ya += glyph->advance_y;
1787  }
1788  ++p;
1789  }
1790  double txWidth = xa;
1791 
1792  double xi = x;
1793  double yi = y;
1794  matrix.reset();
1795  matrix.translate(-xi, -yi);
1796  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1797  matrix.translate(xi, yi);
1798 
1799  if(hAlign == te::at::CenterH)
1800  xi = x + txWidth / 2.;
1801  else if(hAlign == te::at::End)
1802  xi = x + txWidth;
1803 
1804  if(vAlign == te::at::Top)
1805  yi = y + m_fontEngine->height();
1806  else if(vAlign == te::at::CenterV)
1807  yi = y + m_fontEngine->height() * 3. /8.;
1808  else if(vAlign == te::at::Bottom)
1809  yi = y - m_fontEngine->height() / 4.;
1810 
1811  matrix.transform(&xi, &yi);
1812 
1813  //int size = 2;
1814  double xx = x - (xi - x);
1815  double yy = m_dheight - yi;
1816  double xf = xx + (m_dwidth<<2);
1817  double yf = yy;
1818  matrix.reset();
1819  matrix.translate(-xx, -yy);
1820  matrix.scale(m_txXScale, 1.);
1821  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1822  matrix.translate(xx, yy);
1823  matrix.transform(&xf, &yf);
1824 
1825  agg::path_storage path;
1826  int pathIndex = path.start_new_path();
1827  path.move_to(xx, yy);
1828  path.line_to(xf, yf);
1829 
1830  agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1831 
1832  agg::trans_single_path tcurve;
1833  tcurve.add_path(path);
1834  tcurve.preserve_x_scale(true);
1835 
1836  conv_font_curve_type fcurves(m_fontManager->path_adaptor());
1837 
1838  conv_font_segm_type fsegm(fcurves);
1839  conv_font_trans_type ftrans(fsegm, tcurve);
1840  fsegm.approximation_scale(3.0);
1841  fcurves.approximation_scale(2.0);
1842 
1843  xa = 0.;
1844  ya = 0.;
1845  p = tx.c_str();
1846 
1847  while(*p)
1848  {
1849  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1850  if(glyph)
1851  {
1852  m_fontManager->add_kerning(&xa, &ya);
1853  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1854 
1855  // increment pen position
1856  xa += glyph->advance_x;
1857  ya += glyph->advance_y;
1858  }
1859  ++p;
1860  }
1861  path.free_all();
1862  path.remove_all();
1863 
1864  // calculo do poligono envolvente
1865  matrix.reset();
1866  matrix.translate(-xx, -yy);
1867  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1868  matrix.translate(xx, yy);
1869 
1870  xf = xx + xa;
1871  yf = yy + ya + m_fontEngine->height();
1872  yy -= m_fontEngine->height()/4.;
1873 
1874 
1875  pathIndex = path.start_new_path();
1876  double a, b;
1877  a = xx;
1878  b = yy;
1879  matrix.transform(&a, &b);
1880  path.move_to(a, b);
1881  a = xf;
1882  b = yy;
1883  matrix.transform(&a, &b);
1884  path.line_to(a, b);
1885  a = xf;
1886  b = yf;
1887  matrix.transform(&a, &b);
1888  path.line_to(a, b);
1889  a = xx;
1890  b = yf;
1891  matrix.transform(&a, &b);
1892  path.line_to(a, b);
1893  path.close_polygon(true);
1894 
1895  matrix.reset();
1896  m_rasterizer.gamma(agg::gamma_threshold(.4));
1897  agg::conv_transform<agg::path_storage> fill(path, matrix);
1898  agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1899  stroke.width(m_txBoundaryWidth);
1900  m_rasterizer.add_path(stroke, pathIndex); // without roundoff
1901  agg::render_scanlines_aa_solid(m_rasterizer, m_scanline, m_rendererBase, m_txBoundaryColor); // with anti aliase
1902 
1903  path.free_all();
1904  path.remove_all();
1905 }
1906 
1907 void te::ag::Canvas::drawTextBoundary(const te::gm::Point& wp, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
1908 {
1909  double x = wp.getX();
1910  double y = wp.getY();
1911 
1912  m_matrix.transform(&x, &y);
1913  drawTextBoundary((int)x, (int)y, tx, angle, hAlign, vAlign);
1914 }
1915 
1916 void te::ag::Canvas::drawTextBoundary(const double& xi, const double& yi, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
1917 {
1918  double x = xi;
1919  double y = yi;
1920 
1921  m_matrix.transform(&x, &y);
1922  drawTextBoundary((int)x, (int)y, tx, angle, hAlign, vAlign);
1923 }
1924 
1925 te::gm::Polygon* te::ag::Canvas::getTextBoundary(int x, int y, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
1926 {
1927  agg::trans_affine matrix;
1928  matrix.scale(m_txXScale, 1.);
1929  m_fontEngine->transform(matrix);
1930  double xa = 0.;
1931  double ya = 0.;
1932  const char* p = tx.c_str();
1933 
1934  while(*p)
1935  {
1936  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
1937  if(glyph)
1938  {
1939  m_fontManager->add_kerning(&xa, &ya);
1940  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
1941 
1942  // increment pen position
1943  xa += glyph->advance_x;
1944  ya += glyph->advance_y;
1945  }
1946  ++p;
1947  }
1948  double txWidth = xa;
1949 
1950  double xi = x;
1951  double yi = y;
1952  matrix.reset();
1953  matrix.translate(-xi, -yi);
1954  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1955  matrix.translate(xi, yi);
1956 
1957  if(hAlign == te::at::CenterH)
1958  xi = x + txWidth / 2.;
1959  else if(hAlign == te::at::End)
1960  xi = x + txWidth;
1961 
1962  if(vAlign == te::at::Top)
1963  yi = y + m_fontEngine->height();
1964  else if(vAlign == te::at::CenterV)
1965  yi = y + m_fontEngine->height() * 3. /8.;
1966  else if(vAlign == te::at::Bottom)
1967  yi = y - m_fontEngine->height() / 4.;
1968 
1969  matrix.transform(&xi, &yi);
1970 
1971  //int size = 2;
1972  double xx = x - (xi - x);
1973  double yy = m_dheight - yi;
1974  double xf = xx + (m_dwidth<<2);
1975  double yf = yy;
1976  matrix.reset();
1977  matrix.translate(-xx, -yy);
1978  matrix.scale(m_txXScale, 1.);
1979  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
1980  matrix.translate(xx, yy);
1981  matrix.transform(&xf, &yf);
1982 
1983  agg::path_storage path;
1984  path.start_new_path();
1985  //int pathIndex = path.start_new_path();
1986  path.move_to(xx, yy);
1987  path.line_to(xf, yf);
1988 
1989  agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(m_rendererBase);
1990 
1991  agg::trans_single_path tcurve;
1992  tcurve.add_path(path);
1993  tcurve.preserve_x_scale(true);
1994 
1995  conv_font_curve_type fcurves(m_fontManager->path_adaptor());
1996 
1997  conv_font_segm_type fsegm(fcurves);
1998  conv_font_trans_type ftrans(fsegm, tcurve);
1999  fsegm.approximation_scale(3.0);
2000  fcurves.approximation_scale(2.0);
2001 
2002  xa = 0.;
2003  ya = 0.;
2004  p = tx.c_str();
2005 
2006  while(*p)
2007  {
2008  const agg::glyph_cache* glyph = m_fontManager->glyph(*p);
2009  if(glyph)
2010  {
2011  m_fontManager->add_kerning(&xa, &ya);
2012  m_fontManager->init_embedded_adaptors(glyph, xa, ya);
2013 
2014  // increment pen position
2015  xa += glyph->advance_x;
2016  ya += glyph->advance_y;
2017  }
2018  ++p;
2019  }
2020  path.free_all();
2021  path.remove_all();
2022 
2023  // calculo do poligono envolvente
2024  matrix.reset();
2025  matrix.translate(-xx, -yy);
2026  matrix.rotate(-angle * PI / 180.); // -angle ou nao???????????
2027  matrix.translate(xx, yy);
2028 
2029  xf = xx + xa;
2030  yf = yy + ya + m_fontEngine->height();
2031  yy -= m_fontEngine->height()/4.;
2032 
2035  poly->setRingN(0, lr);
2036 
2037  double a, b;
2038  a = xx;
2039  b = yy;
2040  matrix.transform(&a, &b);
2041  m_matrix.invert().transform(&a, &b);
2042  lr->setPoint(0, a, b);
2043 
2044  a = xf;
2045  b = yy;
2046  matrix.transform(&a, &b);
2047  m_matrix.invert().transform(&a, &b);
2048  lr->setPoint(1, a, b);
2049 
2050  a = xf;
2051  b = yf;
2052  matrix.transform(&a, &b);
2053  m_matrix.invert().transform(&a, &b);
2054  lr->setPoint(2, a, b);
2055 
2056  a = xx;
2057  b = yf;
2058  matrix.transform(&a, &b);
2059  m_matrix.invert().transform(&a, &b);
2060  lr->setPoint(3, a, b);
2061 
2062  return poly;
2063 }
2064 
2066 {
2067  double x = wp.getX();
2068  double y = wp.getY();
2069 
2070  m_matrix.transform(&x, &y);
2071  return getTextBoundary((int)x, (int)y, tx, angle, hAlign, vAlign);
2072 }
2073 
2074 te::gm::Polygon* te::ag::Canvas::getTextBoundary(const double& xi, const double& yi, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
2075 {
2076  double x = xi;
2077  double y = yi;
2078 
2079  m_matrix.transform(&x, &y);
2080  return getTextBoundary((int)x, (int)y, tx, angle, hAlign, vAlign);
2081 }
2082 
2084 {
2085  m_txColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2086 }
2087 
2088 void te::ag::Canvas::setTextOpacity(const int& opacity)
2089 {
2090  double v = (double)opacity/255.;
2091  m_txColor.opacity(v);
2092 }
2093 
2094 void te::ag::Canvas::setFontFamily(const std::string& family)
2095 {
2096  if(m_fontEngine->create_font(family.c_str(), agg::glyph_ren_outline) == false)
2097  m_fontEngine->create_font("Verdana", agg::glyph_ren_outline);
2098 }
2099 
2101 {
2102  double size = 1.8 * psize; // para tentar ficar igual ao QT
2103  m_fontEngine->height(size);
2104  std::string f = m_fontEngine->font_signature();
2105  size_t i = f.find(",");
2106  if(i != std::string::npos)
2107  f.erase(i);
2108  setFontFamily(f);
2109 }
2110 
2112 {
2113  if(style == te::at::NormalStyle)
2114  m_fontEngine->italic(false);
2115  else
2116  m_fontEngine->italic(true);
2117 
2118  std::string f = m_fontEngine->font_signature();
2119  size_t i = f.find(",");
2120  if(i != std::string::npos)
2121  f.erase(i);
2122  setFontFamily(f);
2123 }
2124 
2126 {
2127  m_fontEngine->weight(weight);
2128  std::string f = m_fontEngine->font_signature();
2129  size_t i = f.find(",");
2130  if(i != std::string::npos)
2131  f.erase(i);
2132  setFontFamily(f);
2133 }
2134 
2136 {
2137  m_txXScale = (double)stretch/100.;
2138 }
2139 
2141 {
2142  if(b)
2143  m_txDecorationType = 1;
2144  else if(m_txDecorationType == 1)
2145  m_txDecorationType = 0;
2146 }
2147 
2149 {
2150  if(b)
2151  m_txDecorationType = 2;
2152  else if(m_txDecorationType == 2)
2153  m_txDecorationType = 0;
2154 }
2155 
2157 {
2158  if(b)
2159  m_txDecorationType = 3;
2160  else if(m_txDecorationType == 3)
2161  m_txDecorationType = 0;
2162 }
2163 
2165 {
2166  m_txDecorationColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2167 }
2168 
2170 {
2171  m_txDecorationWidth = width;
2172 }
2173 
2175 {
2176  m_txBoundaryColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2177 }
2178 
2180 {
2181  double v = (double)opacity/255.;
2182  m_txBoundaryColor.opacity(v);
2183 }
2184 
2186 {
2187  m_txBoundaryWidth = (double)width;
2188 }
2189 
2191 {
2192  m_textLineJustification = (int)just;
2193 }
2194 
2196 {
2197  m_textLineSpacing = spacing;
2198 }
2199 
2201 {
2202  m_ptColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2203  delete []m_ptPatternBuffer;
2204  m_ptPatternBuffer = 0;
2205 }
2206 
2208 {
2209  m_ptWidth = w;
2210 }
2211 
2212 void te::ag::Canvas::setPointMarkerType(const ptMarkerType& type)
2213 {
2214  m_ptMarkerType = (agg::marker_e)type;
2215 }
2216 
2217 void te::ag::Canvas::setPointStyle(te::color::RGBAColor** style, int ncols, int nrows)
2218 {
2219  int i, j, k, n;
2220  delete [] m_ptPatternBuffer;
2221  unsigned int tam = ncols * nrows * DEPTH/8;
2222  m_ptPatternBuffer = new agg::int8u[tam];
2223  for(i = 0; i < nrows; ++i)
2224  {
2225  k = i * 4 * ncols;
2226  for(j = 0; j < ncols; ++j)
2227  {
2228  te::color::RGBAColor c = style[i][j];
2229  n = k + 4 * j;
2230  m_ptPatternBuffer[n] = (agg::int8u)c.getRed();
2231  m_ptPatternBuffer[n + 1] = (agg::int8u)c.getGreen();
2232  m_ptPatternBuffer[n + 2] = (agg::int8u)c.getBlue();
2233  m_ptPatternBuffer[n + 3] = (agg::int8u)c.getAlpha();
2234  }
2235  }
2236  m_ptPatternRenderingBuffer.attach(m_ptPatternBuffer, ncols, nrows, -ncols * DEPTH/8);
2237 }
2238 
2240 {
2241  //const char* format = te::ag:GetFormat(t);
2242  //QImage ima(2, 2, QImage::Format_ARGB32);
2243 
2244  //bool b = ima.loadFromData((const uchar*)style, size, format);
2245  //if(b)
2246  //{
2247  // QMatrix matrix = m_matrix.inverted();
2248  // QBrush brush;
2249  // brush.setTextureImage(ima);
2250  // brush.setMatrix(matrix);
2251  // m_ptPen.setBrush(brush);
2252  // m_painter.setPen(m_ptPen);
2253  // m_ptPattern.clear();
2254  //}
2255 }
2256 
2257 void te::ag::Canvas::setPointStyle(const std::string& fileName)
2258 {
2259  int i, j, wdata, hdata;
2260  unsigned char* data = (unsigned char*)getData(fileName, wdata, hdata);
2261  if(data == 0)
2262  return;
2263 
2264  delete [] m_ptPatternBuffer;
2265  unsigned int tam = wdata * hdata * DEPTH/8;
2266  m_ptPatternBuffer = new agg::int8u[tam];
2267  memset(m_ptPatternBuffer, 0, tam); // 0 de opacidade
2268 
2269  for(i = 0; i < hdata; ++i)
2270  {
2271  int c = i * 3 * wdata;
2272  int d = i * 4 * wdata;
2273  for(j = 0; j < wdata; ++j)
2274  {
2275  int a = c+j*3;
2276  int b = d+j*4;
2277  if(data[a] != 0 && data[a+1] != 0 && data[a+2] != 0)
2278  {
2279  m_ptPatternBuffer[b] = data[a];
2280  m_ptPatternBuffer[b+1] = data[a+1];
2281  m_ptPatternBuffer[b+2] = data[a+2];
2282  m_ptPatternBuffer[b+3] = 255;
2283  }
2284  }
2285  }
2286  delete []data;
2287  m_ptPatternRenderingBuffer.attach(m_ptPatternBuffer, wdata, hdata, -wdata * DEPTH/8);
2288 }
2289 
2291 {
2292  m_lineColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2293  delete []m_linePatternBuffer;
2294  m_linePatternBuffer = 0;
2295 }
2296 
2297 void te::ag::Canvas::setLineStyle(te::color::RGBAColor** style, int ncols, int nrows)
2298 {
2299  int i, j, k, n;
2300  delete [] m_linePatternBuffer;
2301  unsigned int tam = ncols * nrows * DEPTH/8;
2302  m_linePatternBuffer = new agg::int8u[tam];
2303  for(i = 0; i < nrows; ++i)
2304  {
2305  k = i * 4 * ncols;
2306  for(j = 0; j < ncols; ++j)
2307  {
2308  te::color::RGBAColor c = style[i][j];
2309  n = k + 4 * j;
2310  m_linePatternBuffer[n] = (agg::int8u)c.getRed();
2311  m_linePatternBuffer[n + 1] = (agg::int8u)c.getGreen();
2312  m_linePatternBuffer[n + 2] = (agg::int8u)c.getBlue();
2313  m_linePatternBuffer[n + 3] = 255;
2314  }
2315  }
2316  m_linePatternRenderingBuffer.attach(m_linePatternBuffer, ncols, nrows, -ncols * DEPTH/8);
2317 }
2318 
2320 {
2321  //const char* format = te::ag:GetFormat(t);
2322  //QImage ima(2, 2, QImage::Format_ARGB32);
2323 
2324  //bool b = ima.loadFromData((const uchar*)style, size, format);
2325  //if(b)
2326  //{
2327  // QMatrix matrix = m_matrix.inverted();
2328  // QBrush brush;
2329  // brush.setTextureImage(ima);
2330  // double scale = (double)m_lnPen.width() / (double)ima.width();
2331  // matrix.scale(scale, scale);
2332  // brush.setMatrix(matrix);
2333  // m_lnPen.setBrush(brush);
2334  // m_painter.setPen(m_lnPen);
2335  //}
2336 }
2337 
2338 void te::ag::Canvas::setLineStyle(const std::string& fileName)
2339 {
2340  int i, j, wdata, hdata;
2341  unsigned char* data = (unsigned char*)getData(fileName, wdata, hdata);
2342  if(data == 0)
2343  return;
2344 
2345  delete []m_linePatternBuffer;
2346  m_linePatternBuffer = new agg::int8u[wdata * hdata * DEPTH/8];
2347 
2348  for(i = 0; i < hdata; ++i)
2349  {
2350  int c = i * 3 * wdata;
2351  int d = i * 4 * wdata;
2352  for(j = 0; j < wdata; ++j)
2353  {
2354  int a = c+j*3;
2355  int b = d+j*4;
2356  m_linePatternBuffer[b] = data[a];
2357  m_linePatternBuffer[b+1] = data[a+1];
2358  m_linePatternBuffer[b+2] = data[a+2];
2359  m_linePatternBuffer[b+3] = 255;
2360  }
2361  }
2362  delete []data;
2363  m_linePatternRenderingBuffer.attach(m_linePatternBuffer, wdata, hdata, -wdata * DEPTH/8);
2364 }
2365 
2367 {
2368  m_lineWidth = w;
2369 }
2370 
2372 {
2373  m_polyFillColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2374  delete []m_polyPatternBuffer;
2375  m_polyPatternBuffer = 0;
2376 }
2377 
2379 {
2380  m_polyContourColor = color_type(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
2381  delete []m_contourPatternBuffer;
2382  m_contourPatternBuffer = 0;
2383 }
2384 
2386 {
2387  int i, j, k, n;
2388  delete [] m_polyPatternBuffer;
2389  unsigned int tam = ncols * nrows * DEPTH/8;
2390  m_polyPatternBuffer = new agg::int8u[tam];
2391  for(i = 0; i < nrows; ++i)
2392  {
2393  k = i * 4 * ncols;
2394  for(j = 0; j < ncols; ++j)
2395  {
2396  te::color::RGBAColor c = style[i][j];
2397  n = k + 4 * j;
2398  m_polyPatternBuffer[n] = (agg::int8u)c.getRed();
2399  m_polyPatternBuffer[n + 1] = (agg::int8u)c.getGreen();
2400  m_polyPatternBuffer[n + 2] = (agg::int8u)c.getBlue();
2401  m_polyPatternBuffer[n + 3] = m_polyPatternOpacity;
2402  }
2403  }
2404  m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, ncols, nrows, -ncols * DEPTH/8);
2405 }
2406 
2408 {
2409  //const char* format = te::ag:GetFormat(t);
2410  //QImage ima(2, 2, QImage::Format_ARGB32);
2411 
2412  //bool b = ima.loadFromData((const uchar*)style, size, format);
2413  //if(b)
2414  //{
2415  // QMatrix matrix = m_matrix.inverted();
2416  // double scale = (double)m_polyPatternWidth / (double)ima.width();
2417  // matrix.scale(scale, scale);
2418  // m_polyBrush.setMatrix(matrix);
2419  // m_polyBrush.setTextureImage(ima);
2420  // m_painter.setBrush(m_polyBrush);
2421  //}
2422 }
2423 
2424 void te::ag::Canvas::setPolygonFillStyle(const std::string& fileName)
2425 {
2426  int a, b, c, d, i, j, wdata, hdata;
2427  unsigned char* data = (unsigned char*)getData(fileName, wdata, hdata);
2428  if(data == 0)
2429  return;
2430 
2431  delete [] m_polyPatternBuffer;
2432  m_polyPatternBuffer = new agg::int8u[wdata * hdata * DEPTH/8];
2433  memset(m_polyPatternBuffer, 0, wdata * hdata * DEPTH/8); // 0 de opacidade
2434  for(i = 0; i < hdata; ++i)
2435  {
2436  c = i * 3 * wdata;
2437  d = i * 4 * wdata;
2438  for(j = 0; j < wdata; ++j)
2439  {
2440  a = c+j*3;
2441  b = d+j*4;
2442  m_polyPatternBuffer[b] = data[a];
2443  m_polyPatternBuffer[b+1] = data[a+1];
2444  m_polyPatternBuffer[b+2] = data[a+2];
2445  m_polyPatternBuffer[b+3] = m_polyPatternOpacity;
2446  }
2447  }
2448  delete []data;
2449  m_polyPatternRenderingBuffer.attach(m_polyPatternBuffer, wdata, hdata, -wdata * DEPTH/8);
2450 
2451 //teste.............................................................../////
2452  //char* buf = new char[wdata * hdata * 3];
2453  //for(i = 0; i < hdata; ++i)
2454  //{
2455  // int c = i * 3 * wdata;
2456  // int d = i * 4 * wdata;
2457  // for(j = 0; j < wdata; ++j)
2458  // {
2459  // int a = c+j*3;
2460  // int b = d+j*4;
2461  // buf[a] = m_polyPatternBuffer[b+0];
2462  // buf[a+1] = m_polyPatternBuffer[b+1];
2463  // buf[a+2] = m_polyPatternBuffer[b+2];
2464  // }
2465  //}
2466 
2467  //std::string name = fileName;
2468  //size_t p = name.find(".");
2469  //name.insert(p, "_pattern");
2470  //FILE* fp = fopen(name.c_str(), "wb");
2471  //if(fp)
2472  //{
2473  // fprintf(fp, "P6 %d %d 255 ", wdata, hdata);
2474  // fwrite(buf, 1, wdata * hdata * 3, fp);
2475  // fclose(fp);
2476  // delete []buf;
2477  // return;
2478  //}
2479  //delete []buf;
2480 //teste.............................................................../////
2481 }
2482 
2484 {
2485  m_polyPatternWidth = w;
2486 }
2487 
2488 void te::ag::Canvas::setPolygonPatternOpacity(const unsigned char& opac)
2489 {
2490  m_polyPatternOpacity = opac;
2491 }
2492 
2494 {
2495  int i, j, k, n;
2496  delete [] m_contourPatternBuffer;
2497  unsigned int tam = ncols * nrows * DEPTH/8;
2498  m_contourPatternBuffer = new agg::int8u[tam];
2499  for(i = 0; i < nrows; ++i)
2500  {
2501  k = i * 4 * ncols;
2502  for(j = 0; j < ncols; ++j)
2503  {
2504  te::color::RGBAColor c = style[i][j];
2505  n = k + 4 * j;
2506  m_contourPatternBuffer[n] = (agg::int8u)c.getRed();
2507  m_contourPatternBuffer[n + 1] = (agg::int8u)c.getGreen();
2508  m_contourPatternBuffer[n + 2] = (agg::int8u)c.getBlue();
2509  m_contourPatternBuffer[n + 3] = 255;
2510  }
2511  }
2512  m_contourPatternRenderingBuffer.attach(m_contourPatternBuffer, ncols, nrows, -ncols * DEPTH/8);
2513 }
2514 
2516 {
2517  //const char* format = te::ag:GetFormat(t);
2518  //QImage ima(2, 2, QImage::Format_ARGB32);
2519 
2520  //bool b = ima.loadFromData((const uchar*)style, size, format);
2521  //if(b)
2522  //{
2523  // QMatrix matrix = m_matrix.inverted();
2524  // QBrush brush;
2525  // brush.setTextureImage(ima);
2526  // double scale = (double)m_polyPen.width() / (double)ima.width();
2527  // matrix.scale(scale, scale);
2528  // brush.setMatrix(matrix);
2529  // m_polyPen.setBrush(brush);
2530  // m_painter.setPen(m_polyPen);
2531  //}
2532 }
2533 
2534 void te::ag::Canvas::setPolygonContourStyle(const std::string& fileName)
2535 {
2536  int i, j, wdata, hdata;
2537  unsigned char* data = (unsigned char*)getData(fileName, wdata, hdata);
2538  if(data == 0)
2539  return;
2540 
2541  delete []m_contourPatternBuffer;
2542  m_contourPatternBuffer = new agg::int8u[wdata * hdata * DEPTH/8];
2543 
2544  for(i = 0; i < hdata; ++i)
2545  {
2546  int c = i * 3 * wdata;
2547  int d = i * 4 * wdata;
2548  for(j = 0; j < wdata; ++j)
2549  {
2550  int a = c+j*3;
2551  int b = d+j*4;
2552  m_contourPatternBuffer[b] = data[a];
2553  m_contourPatternBuffer[b+1] = data[a+1];
2554  m_contourPatternBuffer[b+2] = data[a+2];
2555  m_contourPatternBuffer[b+3] = 255;
2556  }
2557  }
2558  delete []data;
2559  m_contourPatternRenderingBuffer.attach(m_contourPatternBuffer, wdata, hdata, -wdata * DEPTH/8);
2560 }
2561 
2563 {
2564  m_polyContourWidth = w;
2565 }
2566 
2567 void te::ag::Canvas::save(const char* fileName,
2569  int quality,
2570  int fg) const
2571 {
2572  //if(m_device->devType() != 4)
2573  // ((QPixmap*)m_device)->save(fileName, GetFormat(t), quality);
2574 }
2575 
2576 //void te::ag::Canvas::drawText(const QPoint& p,
2577 // const std::string& tx,
2578 // float angle,
2579 // te::at::HorizontalAlignment hAlign,
2580 // te::at::VerticalAlignment vAlign)
2581 //{
2582 // if(tx.empty())
2583 // return;
2584 //
2585 // double ax, ay; // alignment position
2586 // QString qtx(tx.c_str());
2587 // QPainterPath path;
2588 // QFontMetrics fm(m_font);
2589 // QRectF rec(fm.boundingRect(qtx));
2590 //
2591 // if(hAlign == te::at::Start)
2592 // ax = rec.left();
2593 // else if(hAlign == te::at::CenterH)
2594 // ax = rec.center().x();
2595 // else
2596 // ax = rec.right();
2597 //
2598 // if(vAlign == te::at::Bottom)
2599 // ay = rec.bottom();
2600 // else if(vAlign == te::at::CenterV)
2601 // ay = rec.center().y();
2602 // else if(vAlign == te::at::Top)
2603 // ay = rec.top();
2604 // else
2605 // ay = 0.;
2606 //
2607 // path.addText(-ax, -ay, m_font, qtx);
2608 //
2609 // m_painter.resetMatrix();
2610 // m_painter.translate(p);
2611 // if(angle != 0.)
2612 // m_painter.rotate(angle);
2613 // m_painter.fillPath(path, m_textBrush);
2614 //
2615 // if(m_textPen.width() != 0)
2616 // {
2617 // m_painter.setPen(m_textPen);
2618 // m_painter.drawPath(path);
2619 // }
2620 // m_painter.setMatrix(m_matrix);
2621 //}
2622 //
2623 //void te::ag::Canvas::drawTextBoundary(const QPoint& p, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
2624 //{
2625 // if(tx.empty())
2626 // return;
2627 //
2628 // double ax, ay; // alignment position
2629 // QString qtx(tx.c_str());
2630 // QPainterPath path;
2631 // QFontMetrics fm(m_font);
2632 // QRectF rec(fm.boundingRect(qtx));
2633 // QRectF wrec(m_matrix.inverted().mapRect(rec));
2634 //
2635 // if(hAlign == te::at::Start)
2636 // ax = wrec.left();
2637 // else if(hAlign == te::at::CenterH)
2638 // ax = wrec.center().x();
2639 // else
2640 // ax = wrec.right();
2641 //
2642 //// reverse top-bottom
2643 // if(vAlign == te::at::Bottom)
2644 // ay = wrec.top();
2645 // else if(vAlign == te::at::CenterV)
2646 // ay = wrec.center().y();
2647 // else if(vAlign == te::at::Top)
2648 // ay = wrec.bottom();
2649 // else // Baseline
2650 // ay = m_matrix.inverted().map(QPoint(0, 0)).y();
2651 //
2652 // wrec.translate(-ax, -ay); // rotation point on text alignment
2653 // QPolygonF polf(wrec);
2654 //
2655 // if(angle != 0.)
2656 // {
2657 // QMatrix m;
2658 // m.rotate(-angle);
2659 // polf = m.map(polf);
2660 // }
2661 // QPointF wp = m_matrix.inverted().map(QPointF(p));
2662 // polf.translate(wp.x(), wp.y()); // translate to entry point
2663 //
2664 // m_painter.setPen(m_textPen);
2665 // m_painter.drawPolygon(polf);
2666 //}
2667 //
2668 //te::gm::Polygon* te::ag::Canvas::getTextBoundary(const QPoint& p, const std::string& tx, float angle, te::at::HorizontalAlignment hAlign, te::at::VerticalAlignment vAlign)
2669 //{
2670 // if(tx.empty())
2671 // return 0;
2672 //
2673 // double ax, ay; // alignment position
2674 // QString qtx(tx.c_str());
2675 // QPainterPath path;
2676 // QFontMetrics fm(m_font);
2677 // QRectF rec(fm.boundingRect(qtx));
2678 // QRectF wrec(m_matrix.inverted().mapRect(rec));
2679 //
2680 // if(hAlign == te::at::Start)
2681 // ax = wrec.left();
2682 // else if(hAlign == te::at::CenterH)
2683 // ax = wrec.center().x();
2684 // else
2685 // ax = wrec.right();
2686 //
2687 //// reverse top-bottom
2688 // if(vAlign == te::at::Bottom)
2689 // ay = wrec.top();
2690 // else if(vAlign == te::at::CenterV)
2691 // ay = wrec.center().y();
2692 // else if(vAlign == te::at::Top)
2693 // ay = wrec.bottom();
2694 // else // Baseline
2695 // ay = m_matrix.inverted().map(QPoint(0, 0)).y();
2696 //
2697 // wrec.translate(-ax, -ay); // rotation point on text alignment
2698 // QPolygonF polf(wrec);
2699 //
2700 // if(angle != 0.)
2701 // {
2702 // QMatrix m;
2703 // m.rotate(-angle);
2704 // polf = m.map(polf);
2705 // }
2706 // QPointF wp = m_matrix.inverted().map(QPointF(p));
2707 // polf.translate(wp.x(), wp.y()); // translate to entry point
2708 //
2709 ////converter QPolygon para te::gm::Polygon. Como fazer isso?
2710 // te::gm::LinearRing* lr = new te::gm::LinearRing(4, te::gm::LineStringType);
2711 // te::gm::Polygon* poly = new te::gm::Polygon(1, te::gm::PolygonType);
2712 // poly->setRingN(0, lr);
2713 // lr->setPoint(0, polf.at(0).x(), polf.at(0).y());
2714 // lr->setPoint(1, polf.at(1).x(), polf.at(1).y());
2715 // lr->setPoint(2, polf.at(2).x(), polf.at(2).y());
2716 // lr->setPoint(3, polf.at(3).x(), polf.at(3).y());
2717 // return poly;
2718 //}
2719 //
2720 //QPixmap* te::ag::Canvas::getPixmap() const
2721 //{
2722 // return m_pixmap;
2723 //}
2724 //
2725 //void te::ag::Canvas::setDevice(QPaintDevice* device)
2726 //{
2727 // m_painter.end();
2728 // if(device)
2729 // m_device = device;
2730 // else
2731 // m_device = m_pixmap;
2732 // m_painter.begin(m_device);
2733 // m_dwidth = m_device->width();
2734 // m_dheight = m_device->height();
2735 //}
2736 //
2737 //int te::ag::Canvas::getResolution()
2738 //{
2739 // if(m_device->devType() == 4)
2740 // return ((QPrinter*)m_device)->resolution();
2741 // else
2742 // return m_device->logicalDpiX();
2743 //}
2744 //
2745 //QMatrix te::ag::Canvas::getMatrix()
2746 //{
2747 // return m_matrix;
2748 //}
2749 
2750 unsigned char* te::ag::Canvas::getBuffer() const
2751 {
2752  return m_buffer;
2753 }
2754 
2756 {
2757  int i, j, k, n;
2758  te::color::RGBAColor** colors;
2759 
2760  if(x == 0 && y == 0 && w == 0 && h == 0)
2761  {
2762  colors = new te::color::RGBAColor*[m_dheight];
2763  for(i = 0; i < m_dheight; ++i)
2764  colors[i] = new te::color::RGBAColor[m_dwidth];
2765 
2766  for(i = 0; i < m_dheight; ++i)
2767  {
2768  k = (i<<2) * m_dwidth;
2769  for(j = 0; j < m_dwidth; ++j)
2770  {
2771  n = k + (j<<2);
2772  te::color::RGBAColor cor(m_buffer[n], m_buffer[n+1], m_buffer[n+2], m_buffer[n+3]);
2773  colors[i][j] = cor;
2774  }
2775  }
2776  }
2777  else
2778  {
2779  colors = new te::color::RGBAColor*[h];
2780  for(i = 0; i < h; ++i)
2781  colors[i] = new te::color::RGBAColor[w];
2782 
2783  for(i = 0; i < h; ++i)
2784  {
2785  k = ((y+i)<<2) * m_dwidth;
2786  for(j = 0; j < w; ++j)
2787  {
2788  n = k + ((x+j)<<2);
2789  te::color::RGBAColor cor(m_buffer[n], m_buffer[n+1], m_buffer[n+2], m_buffer[n+3]);
2790  colors[i][j] = cor;
2791  }
2792  }
2793  }
2794  return colors;
2795 }
2796 
2797 bool te::ag::Canvas::write_ppm(const std::string& file_name)
2798 {
2799  if(DEPTH == 24)
2800  {
2801  FILE* fp = fopen(file_name.c_str(), "wb");
2802  if(fp)
2803  {
2804  fprintf(fp, "P6 %d %d 255 ", m_dwidth, m_dheight);
2805  fwrite(m_buffer, 1, m_dwidth * m_dheight * 3, fp);
2806  fclose(fp);
2807  return true;
2808  }
2809  return false;
2810  }
2811  else
2812  {
2813  char* buf = new char[m_dwidth * m_dheight * 3];
2814  int i, j;
2815  for(i = 0; i < m_dheight; ++i)
2816  {
2817  int c = i * 3 * m_dwidth;
2818  int d = i * 4 * m_dwidth;
2819  for(j = 0; j < m_dwidth; ++j)
2820  {
2821  int a = c+j*3;
2822  int b = d+j*4;
2823  buf[a] = m_buffer[b+0];
2824  buf[a+1] = m_buffer[b+1];
2825  buf[a+2] = m_buffer[b+2];
2826  }
2827  }
2828 
2829  FILE* fp = fopen(file_name.c_str(), "wb");
2830  if(fp)
2831  {
2832  fprintf(fp, "P6 %d %d 255 ", m_dwidth, m_dheight);
2833  fwrite(buf, 1, m_dwidth * m_dheight * 3, fp);
2834  fclose(fp);
2835  delete []buf;
2836  return true;
2837  }
2838  delete []buf;
2839  return false;
2840  }
2841 }
2842 
2843 char* te::ag::Canvas::getData(const std::string& fileName, int& w, int &h)
2844 {
2845  std::string fe = te::common::GetFileExtension(fileName);
2846  fe = te::common::Convert2UCase(fe);
2847  if(fe != "PPM")
2848  return 0;
2849 
2850  size_t p, pp;
2851  int size;
2852  char c, buf[256];
2853  std::string s, ss;
2854 
2855  FILE* fp = fopen(fileName.c_str(), "rb");
2856  if(fp == 0)
2857  return 0;
2858 
2859  fread(buf, 1, 256, fp);
2860  s = buf;
2861  c = buf[2];
2862  if(c == ' ')
2863  {
2864  p = s.find(c);
2865  pp = p + 1;
2866  p = s.find(c, pp);
2867  ss = s.substr(pp, p-pp);
2868  sscanf(ss.c_str(), "%d", &w);
2869  pp = p + 1;
2870  p = s.find(c, pp);
2871  ss = s.substr(pp, p-pp);
2872  sscanf(ss.c_str(), "%d", &h);
2873  size = w * h * 3;
2874  p = s.find(c, p+1);
2875  }
2876  else
2877  {
2878  p = s.find(c);
2879  p = s.find(c, p+1);
2880  pp = p + 1;
2881  p = s.find(c, pp);
2882  ss = s.substr(pp, p-pp);
2883  sscanf(ss.c_str(), "%d %d", &w, &h);
2884  size = w * h * 3;
2885  pp = p + 1;
2886  p = s.find(c, pp);
2887  }
2888  fseek(fp, p+1, 0);
2889 
2890  char* data = new char[size];
2891  fread(data, 1, size, fp);
2892  fclose(fp);
2893  return data;
2894 }
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void setFontFamily(const std::string &family)
It sets the text font family.
Definition: Canvas.cpp:2094
char * drawPointZ(char *point)
It draws the point in WKB format on canvas.
Definition: Canvas.cpp:407
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
Definition: Enums.h:38
A canvas built on top of Anti Grain Geometry.
void save(const char *fileName, te::map::Canvas::ImageType t, int quality=75, int fg=0) const
It saves the canvas content to a file image in the specified format type.
Definition: Canvas.cpp:2567
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
void setBackgroundColor(const te::color::RGBAColor &color)
It sets the canvas background color.
Definition: Canvas.cpp:271
Canvas()
Constructor.
Definition: Canvas.h:101
TextDecoration getDecoration() const
It returns the font decoration.
Definition: Attributes.cpp:164
double m_txXScale
Definition: Canvas.h:1289
void setPolygonFillStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the polygon fill style.
Definition: Canvas.cpp:2385
font_engine_type * m_fontEngine
Definition: Canvas.h:1284
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
const double & getLetterSpacing() const
It returns the letter spacing.
Definition: Attributes.cpp:174
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
Definition: Canvas.cpp:216
double y
y-coordinate.
Definition: Coord2D.h:114
FontWeight
Font weight for drawing text.
Definition: Enums.h:50
char * getImage(te::map::Canvas::ImageType t, size_t &size) const
It returns the internal contents as an image.
Definition: Canvas.cpp:1023
const double & getTextOpacity() const
It returns the text opacity.
Definition: Attributes.cpp:204
void setLineStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the line style.
Definition: Canvas.cpp:2297
void transform(int srid)
It converts the coordinate values of the geometry to the new spatial reference system.
void adjustWorldWindow(double &llx, double &lly, double &urx, double &ury, const HAlignType &ha=HCenter, const VAlignType &va=VCenter)
It adjusts the world (or window) coordinates area (supposing a cartesian reference system)...
Definition: Canvas.cpp:232
int m_dwidth
The device width.
Definition: Canvas.h:1242
int getRed() const
It returns the red component color value (a value from 0 to 255).
Definition: RGBAColor.h:295
te::color::RGBAColor getBackgroundColor() const
It returns the canvas background color.
Definition: Canvas.cpp:276
#define TE_EWKB_SRID_FLAG
Definition: Config.h:163
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
Definition: LineString.h:456
void setPolygonContourStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the pen style used to draw the boundary of polygon geometries.
Definition: Canvas.cpp:2493
color_type m_ptColor
Point color.
Definition: Canvas.h:1273
double x
x-coordinate.
Definition: Coord2D.h:113
#define PI
Definition: Canvas.h:29
void setTextStyle(te::at::FontStyle style)
It sets the text style.
Definition: Canvas.cpp:2111
void drawPixel(int x, int y)
It sets a pixel using the point pen.
Definition: Canvas.cpp:1323
const std::string & getFamily() const
It returns the font family.
Definition: Attributes.cpp:124
LineJustification
Line justification for drawing multi line text.
Definition: Enums.h:106
color_type m_polyFillColor
Polygon fill color.
Definition: Canvas.h:1258
FontStyle
Font style for drawing text.
Definition: Enums.h:38
unsigned char * getBuffer() const
It gets a RGBA colors from buffer.
Definition: Canvas.cpp:2750
agg::rendering_buffer * m_rb
Definition: Canvas.cpp:150
int m_dheight
The device height.
Definition: Canvas.h:1243
color_type m_bgColor
Canvas background color. Defaults: white fully transparent.
Definition: Canvas.h:1256
void clear()
It clears the canvas content and fills with the background color.
Definition: Canvas.cpp:281
const double & getPointSize() const
It returns the font point size.
Definition: Attributes.cpp:134
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
Definition: RGBAColor.h:305
char * drawGeometry(char *geom)
It draws the geometry in WKB format on canvas.
Definition: Canvas.cpp:302
int getGreen() const
It returns the green component color value (a value from 0 to 255).
Definition: RGBAColor.h:300
agg::int8u * m_contourPatternBuffer
Definition: Canvas.h:1265
color_type m_polyContourColor
Polygon contoyr color.
Definition: Canvas.h:1259
void drawImage(char *src, int size, te::map::Canvas::ImageType t)
It draws the src pixmap over the canvas.
Definition: Canvas.cpp:1082
agg::conv_transform< conv_font_segm_type, agg::trans_single_path > conv_font_trans_type
Definition: Canvas.h:1283
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
Definition: StringUtils.h:163
agg::conv_segmentator< conv_font_curve_type > conv_font_segm_type
Definition: Canvas.h:1282
A Text may contain 1 or more Text Elements.
Definition: Text.h:51
static agg::int8u brightness_to_alpha[256 *3]
Definition: Canvas.cpp:82
font_manager_type * m_fontManager
Definition: Canvas.h:1285
unsigned int m_polyPatternWidth
The pattern width used to fill a polygon.
Definition: Canvas.h:1261
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
void setPointStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the point style.
Definition: Canvas.cpp:2217
HorizontalAlignment getHorizontalAlignment() const
It returns the horizontal text alignment.
Definition: Attributes.cpp:244
char * drawMultiPolygon(char *mpoly)
It draws the MultiPolygon in WKB format on canvas.
Definition: Canvas.cpp:533
agg::int8u * m_ptPatternBuffer
Definition: Canvas.h:1276
A point with a z-coordinate value and an associated measurement.
Definition: PointZM.h:51
virtual Geometry * getBoundary() const
It returns the geometry boundary.
Definition: Geometry.cpp:202
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
Definition: Canvas.cpp:2378
void setPolygonPatternWidth(const int &w)
It sets the polycon brush icon width.
Definition: Canvas.cpp:2483
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
Definition: Canvas.cpp:2290
const Attributes * getAttributes() const
it returns the text attributes.
Definition: Element.cpp:102
const te::gm::Geometry * getLeaderLine() const
it returns the text leader line.
Definition: Element.cpp:91
A point with an associated measure.
Definition: PointM.h:51
color_type m_txBoundaryColor
Text boundary color.
Definition: Canvas.h:1287
FontStyle getStyle() const
It returns the font style.
Definition: Attributes.cpp:144
TextDecoration
Text decoration for drawing text.
Definition: Enums.h:68
void draw(te::gm::Geometry *geom)
It draws the geometry on canvas.
Definition: Canvas.cpp:571
void setTextWeight(te::at::FontWeight weight)
It sets the text weight.
Definition: Canvas.cpp:2125
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
char * drawMultiPoint(char *mpoint)
It draws the multipoint in WKB format on canvas.
Definition: Canvas.cpp:428
agg::rgba8 color_type
Definition: Canvas.h:49
void setLineWidth(const int &w)
It sets the line width.
Definition: Canvas.cpp:2366
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
void setTextMultiLineSpacing(const int &spacing)
It sets the multi line text spacing.
Definition: Canvas.cpp:2195
void setTextColor(const te::color::RGBAColor &color)
It sets the text drawing color.
Definition: Canvas.cpp:2083
char * getData(const std::string &file_name, int &w, int &h)
Definition: Canvas.cpp:2843
A point with z-coordinate value.
Definition: PointZ.h:51
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
char * drawPolygon(char *poly)
It draws the polygon in WKB format on canvas.
Definition: Canvas.cpp:495
HorizontalAlignment
Horizontal alignment for drawing text.
Definition: Enums.h:81
bool write_ppm(const std::string &file_name)
It draws a text.
Definition: Canvas.cpp:2797
void setTextUnderline(bool b)
It sets the text underline flag.
Definition: Canvas.cpp:2140
te::gm::Polygon * getTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It returns text boundary.
Definition: Canvas.cpp:1925
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:150
void setTextBoundaryWidth(const int &width)
It sets the text boundary width.
Definition: Canvas.cpp:2185
A point with x and y coordinate values.
Definition: Point.h:50
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Definition: LineString.cpp:353
VerticalAlignment getVerticalAlignment() const
It returns the vertical text alignment.
Definition: Attributes.cpp:254
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual te::dt::AbstractData * clone() const
It clones the point.
Definition: Point.cpp:71
void setTextOpacity(const int &opacity)
It sets the text opacity.
Definition: Canvas.cpp:2088
agg::marker_e m_ptMarkerType
Definition: Canvas.h:1275
const std::vector< Element * > & getElements() const
It returns the elements.
Definition: Text.cpp:85
const double & getLineSpacing() const
It returns the multi line spacing.
Definition: Attributes.cpp:274
void drawText(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws a text.
Definition: Canvas.cpp:1336
char * drawLineString(char *line)
It draws the line string in WKB format on canvas.
Definition: Canvas.cpp:446
agg::pixfmt_rgba32_pre pixfmt_pre
Definition: Canvas.h:48
agg::int8u * m_polyPatternBuffer
Definition: Canvas.h:1262
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
Definition: RGBAColor.h:310
void setTextDecorationColor(const te::color::RGBAColor &color)
It sets the text strike out flag.
Definition: Canvas.cpp:2164
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
Definition: Canvas.cpp:2200
void drawTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws the text boundary.
Definition: Canvas.cpp:1767
const std::string & getValue() const
it returns the text string.
Definition: Element.cpp:69
char * drawPointM(char *point)
It draws the point in WKB format on canvas.
Definition: Canvas.cpp:414
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Definition: Geometry.h:178
void setTextOverline(bool b)
It sets the text overline flag.
Definition: Canvas.cpp:2148
agg::int8u * m_linePatternBuffer
Definition: Canvas.h:1270
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
void setTextMultiLineJustification(const te::at::LineJustification &just)
It sets the multi line text justification.
Definition: Canvas.cpp:2190
FontWeight getWeight() const
It returns the font weight.
Definition: Attributes.cpp:154
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
agg::pixfmt_rgba32 pixfmt
Definition: Canvas.h:47
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
void setTextPointSize(double psize)
It sets the text Point Size.
Definition: Canvas.cpp:2100
MultiLineString is a MultiCurve whose elements are LineStrings.
pattern_src_brightness_to_alpha_rgba8(agg::rendering_buffer &rb)
Definition: Canvas.cpp:137
unsigned char * m_buffer
Definition: Canvas.h:1248
void setTextDecorationWidth(int width)
It sets the text strike out flag.
Definition: Canvas.cpp:2169
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
te::color::RGBAColor ** getColorsFromBuffer(int x=0, int y=0, int w=0, int h=0) const
It gets a RGBA colors from buffer.
Definition: Canvas.cpp:2755
void setTextStrikeOut(bool b)
It sets the text strike out flag.
Definition: Canvas.cpp:2156
VerticalAlignment
Vertical alignment for drawing text.
Definition: Enums.h:93
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
Definition: Canvas.cpp:2371
void Convert2OGCWKBType(unsigned int &gType)
It converts the PostGIS geometry type to a pure OGC WKB code.
Definition: Utils.h:900
char * drawPointZM(char *point)
It draws the point in WKB format on canvas.
Definition: Canvas.cpp:421
const te::gm::Geometry * getLocation() const
it returns the text location.
Definition: Element.cpp:80
~Canvas()
Destructor.
Definition: Canvas.cpp:202
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
color_type m_txColor
Text color.
Definition: Canvas.h:1286
#define DEPTH
Definition: Canvas.h:43
void setTextBoundaryColor(const te::color::RGBAColor &color)
It sets the text boundary drawing color.
Definition: Canvas.cpp:2174
LineJustification getLineJustification() const
It returns the multi line justification.
Definition: Attributes.cpp:264
double m_txBoundaryWidth
Text boundary color.
Definition: Canvas.h:1288
double m_lineWidth
Line width.
Definition: Canvas.h:1269
char * drawPoint(char *point)
It draws the point in WKB format on canvas.
Definition: Canvas.cpp:348
agg::rendering_buffer m_renderingBuffer
Definition: Canvas.h:1249
void setPointMarkerType(const ptMarkerType &type)
It sets the point marker type.
Definition: Canvas.cpp:2212
agg::rgba8 pixel(int x, int y) const
Definition: Canvas.cpp:142
double m_polyContourWidth
Polygon contour width.
Definition: Canvas.h:1260
pixfmt * m_pixfmt
Definition: Canvas.h:1250
void setPolygonContourWidth(const int &w)
It sets the polycon contour width.
Definition: Canvas.cpp:2562
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:157
color_type m_lineColor
Line color.
Definition: Canvas.h:1268
int m_ptWidth
Point width.
Definition: Canvas.h:1274
It is a collection of other geometric objects.
agg::conv_curve< font_manager_type::path_adaptor_type > conv_font_curve_type
Definition: Canvas.h:1281
char * drawGeometryCollection(char *g)
It draws the GeometryCollection in WKB format on canvas.
Definition: Canvas.cpp:552
char * drawMultiLineString(char *mline)
It draws the MultiLineString in WKB format on canvas.
Definition: Canvas.cpp:477
color_type m_txDecorationColor
Definition: Canvas.h:1291
void freeImage(char *img) const
This is the method that you should use to release a image generated by the canvas.
Definition: Canvas.cpp:1077
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:136
void resize(int w, int h)
It adjusts the canvas size (width and height).
Definition: Canvas.cpp:286
void setTextBoundaryOpacity(const int &opacity)
It sets the text boundary opacity.
Definition: Canvas.cpp:2179
void setPolygonPatternOpacity(const unsigned char &opac)
It sets the polycon brush icon width.
Definition: Canvas.cpp:2488
double m_txDecorationWidth
Definition: Canvas.h:1292
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193
void setTextStretch(size_t stretch)
It sets the text stretch.
Definition: Canvas.cpp:2135
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
agg::renderer_base< pixfmt > m_rendererBase
Definition: Canvas.h:1251
void setPointWidth(int w)
It sets the point drawing color.
Definition: Canvas.cpp:2207