[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: arc in shapes



Lars Clausen wrote:

> On Fri, 15 Jun 2001, Elena Zotova wrote:
>
> > In first, in shapes for dia-0.88.1 simbol A in path ansupported. Excuse,
> > if it allow in more new version.  (Quotation from castom-shapes for
> > dia-0.88.1:"The line, polyline, polygon, rect, circle, ellipse, path and
> > g elements are supported.  Note that the path element only supports the
> > M,m,L,l,H,h,V,v,C,c,S,s,Z and z commands.", and my attempt copy this
> > exaple call warning:"** WARNING **: unsupported path codde 'A' " and
> > don't show enithing in this shape).
>
> I see, I didn't actually test that (that's output from exporting to shape).
> I believe you are right, it is unsupported.
>
> > Two, in this example IMHO too many parameters (IMHO 6 enough, against 7
> > in example) and it use is slightly complication.
>
> Nope, 7 is what is specified.  See
> <URL:http://www.w3.org/TR/2000/CR-SVG-20001102/paths.html#PathData>.
> Now actually *implementing* the proper use of these is tricky.  We could
> just have a subset thatcan handle 'our' kinds of arcs, for now.
>
> > And will be good, if path allow build arc across three point, but it is
> > only dream.
> >
> > I made arc as individual svg-node like circle or ellipse. And for more
> > easy in
> > use separately for circle arc and ellipse arc.
> > <svg:carc cx="..." cy="..." r="..." a1="..." a2="..."/>
> >  This is a arc of circle with centre (cx,cy) and radius r from angle a1
> > to angle
> > a2. The angles are measured in degrees counter-clockwise.
> > <svg:earc cx="..." cy="..." r="..." a1="..." a2="..."/>
> >  This is a arc of ellipse with centre (cx,cy) and radius rx in the x
> > direction
> > and ry in the y direction from angle a1 to angle a2. The angles are
> > measured in
> > degrees counter-clockwise.
>
> Problem with this is that SVG doesn't include carc and earc.  We don't want
> to make our own extensions to SVG:)  However, implementing the subset of
> A/a that does what your arcs do ought to be simple, given your code.
>

Sorry, I am is very bad in English and understand not all. This grammar is too
complicated for me.

I anderstand what svg doesn't include carc and earc, but dia don't supported 'A'
in path.
And my patch was very usefull for me.
I attached it. You may see it himself.

And will be very good, if dia allow rotate (90 degree I mean) sapes, but only
flip it.
Is it possible?
diff -uNr ./dia-0.88.1.orig/doc/custom-shapes ./dia-0.88.1/doc/custom-shapes
--- ./dia-0.88.1.orig/doc/custom-shapes	Sun Aug  6 18:10:27 2000
+++ ./dia-0.88.1/doc/custom-shapes	Wed Jun 13 20:50:03 2001
@@ -154,9 +154,18 @@
 <svg:circle cx="..." cy="..." r="..."/>
   This is a circle with centre (cx,cy) and radius r.
 
+<svg:carc cx="..." cy="..." r="..." a1="..." a2="..."/>
+  This is a arc of circle with centre (cx,cy) and radius r from angle a1 
+  to angle a2. The angles are measured in degrees counter-clockwise.
+
 <svg:ellipse cx="..." cy="..." rx="..." ry="..."/>
   This is a ellipse with centre (cx, cy) and radius rx in the x direction
   and ry in the y direction.
+
+<svg:earc cx="..." cy="..." r="..." a1="..." a2="..."/>
+  This is a arc of ellipse with centre (cx,cy) and radius rx in the x 
+  direction and ry in the y direction from angle a1 
+  to angle a2. The angles are measured in degrees counter-clockwise.
 
 <svg:path d="...."/>
   This is the most complicated drawing element.  It describes a path
diff -uNr ./dia-0.88.1.orig/objects/custom/custom_object.c ./dia-0.88.1/objects/custom/custom_object.c
--- ./dia-0.88.1.orig/objects/custom/custom_object.c	Tue May  1 04:56:00 2001
+++ ./dia-0.88.1/objects/custom/custom_object.c	Tue Jun 12 23:57:30 2001
@@ -529,6 +529,13 @@
 				    el->ellipse.height * fabs(custom->yscale),
 				    line_width, point);
       break;
+    case GE_ARC:
+      transform_coord(custom, &el->arc.center, &p1);
+      dist = distance_ellipse_point(&p1,
+				    el->arc.width * fabs(custom->xscale),
+				    el->arc.height * fabs(custom->yscale),
+				    line_width, point);
+      break;
     case GE_PATH:
       g_array_set_size(barr, el->path.npoints);
       for (i = 0; i < el->path.npoints; i++)
@@ -804,6 +811,23 @@
 	renderer->ops->draw_ellipse(renderer, &p1,
 				    el->ellipse.width * fabs(custom->xscale),
 				    el->ellipse.height * fabs(custom->yscale),
+				    &fg);
+      break;
+    case GE_ARC:
+      transform_coord(custom, &el->arc.center, &p1);
+      if (custom->show_background && el->any.s.fill != COLOUR_NONE)
+	renderer->ops->fill_arc(renderer, &p1,
+				    el->arc.width * fabs(custom->xscale),
+				    el->arc.height * fabs(custom->yscale),
+					el->arc.angle1,
+					el->arc.angle2,
+				    &bg);
+      if (el->any.s.stroke != COLOUR_NONE)
+	renderer->ops->draw_arc(renderer, &p1,
+				    el->arc.width * fabs(custom->xscale),
+				    el->arc.height * fabs(custom->yscale),
+					el->arc.angle1,
+					el->arc.angle2,
 				    &fg);
       break;
     case GE_PATH:
diff -uNr ./dia-0.88.1.orig/objects/custom/shape_info.c ./dia-0.88.1/objects/custom/shape_info.c
--- ./dia-0.88.1.orig/objects/custom/shape_info.c	Tue May  1 04:56:00 2001
+++ ./dia-0.88.1/objects/custom/shape_info.c	Thu Jun 14 19:27:25 2001
@@ -669,7 +669,49 @@
 	  setlocale(LC_NUMERIC, old_locale);
 	free(str);
       }
-    } else if (!strcmp(node->name, "ellipse")) {
+    }
+	else if (!strcmp(node->name, "carc")) {
+      GraphicElementArc *arc = g_new0(GraphicElementArc, 1);
+
+      el = (GraphicElement *)arc;
+      arc->type = GE_ARC;
+      str = xmlGetProp(node, "cx");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->center.x = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "cy");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->center.y = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "r");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->width = arc->height = 2 * strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "a1");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->angle1 = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "a2");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->angle2 = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+    }
+	else if (!strcmp(node->name, "ellipse")) {
       GraphicElementEllipse *ellipse = g_new0(GraphicElementEllipse, 1);
 
       el = (GraphicElement *)ellipse;
@@ -702,7 +744,56 @@
 	setlocale(LC_NUMERIC, old_locale);
 	free(str);
       }
-    } else if (!strcmp(node->name, "path")) {
+    } 
+	else if (!strcmp(node->name, "earc")) {
+      GraphicElementArc *arc = g_new0(GraphicElementArc, 1);
+
+      el = (GraphicElement *)arc;
+      arc->type = GE_ARC;
+      str = xmlGetProp(node, "cx");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->center.x = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "cy");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->center.y = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "rx");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->width = 2 * strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "ry");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->height = 2 * strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "a1");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->angle1 = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+      str = xmlGetProp(node, "a2");
+      if (str) {
+	old_locale = setlocale(LC_NUMERIC, "C");
+	arc->angle2 = strtod(str, NULL);
+	setlocale(LC_NUMERIC, old_locale);
+	free(str);
+      }
+    }
+	else if (!strcmp(node->name, "path")) {
       str = xmlGetProp(node, "d");
       if (str) {
 	parse_path(info, str, &s);
@@ -758,6 +849,15 @@
       check_point(info, &(el->rect.corner1));
       check_point(info, &(el->rect.corner2));
       break;
+	case GE_ARC:
+	  pt = el->arc.center;
+      pt.x -= el->arc.width / 2.0;
+	  pt.y -= el->arc.height / 2.0;
+      check_point(info, &pt);
+      pt.x += el->arc.width;
+	  pt.y += el->arc.height;	  
+      check_point(info, &pt);
+	  break;  
     case GE_ELLIPSE:
       pt = el->ellipse.center;
       pt.x -= el->ellipse.width / 2.0;
@@ -1046,6 +1146,11 @@
       g_print("  ellipse: center=(%g, %g) width=%g height=%g\n",
 	      el->ellipse.center.x, el->ellipse.center.y,
 	      el->ellipse.width, el->ellipse.height);
+      break;
+    case GE_ARC:
+      g_print("  arc: center=(%g, %g) width=%g height=%g angle1=%g angle2=%g\n",
+	      el->arc.center.x, el->arc.center.y,
+	      el->arc.width, el->arc.height, el->arc.angle1, el->arc.angle2);
       break;
     case GE_PATH:
       g_print("  path:");
diff -uNr ./dia-0.88.1.orig/objects/custom/shape_info.h ./dia-0.88.1/objects/custom/shape_info.h
--- ./dia-0.88.1.orig/objects/custom/shape_info.h	Wed Mar 21 03:48:15 2001
+++ ./dia-0.88.1/objects/custom/shape_info.h	Tue Jun 12 19:55:21 2001
@@ -34,6 +34,7 @@
   GE_POLYGON,
   GE_RECT,
   GE_ELLIPSE,
+  GE_ARC,
   GE_PATH,
   GE_SHAPE
 } GraphicElementType;
@@ -45,6 +46,7 @@
 typedef struct _GraphicElementPoly GraphicElementPoly;
 typedef struct _GraphicElementRect GraphicElementRect;
 typedef struct _GraphicElementEllipse GraphicElementEllipse;
+typedef struct _GraphicElementArc GraphicElementArc;
 typedef struct _GraphicElementPath GraphicElementPath;
 
 /* special colours */
@@ -99,6 +101,12 @@
   real width, height;
 };
 
+struct _GraphicElementArc {
+  SHAPE_INFO_COMMON;
+  Point center;
+  real width, height, angle1, angle2;
+};
+
 struct _GraphicElementPath {
   SHAPE_INFO_COMMON;
   int npoints;
@@ -114,6 +122,7 @@
   GraphicElementPoly polygon;
   GraphicElementRect rect;
   GraphicElementEllipse ellipse;
+  GraphicElementArc arc;
   GraphicElementPath path;
   GraphicElementPath shape;
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK