Re: drawing graphs with dia



I merged both of your  answers here.
I reply in the text

Lars Clausen wrote:

On Sat, 2005-03-12 at 20:11 +0100, Grégoire Dooms wrote:
Lars Clausen wrote:

First option is exactly what I had in mind for after 0.95.  We have code
that does line-gap well for almost all objects, but only with lines.  The
various straight lines would work well with it, but getting arcs and
beziers to do the right thing would be tricky.


For arc and bezier, I'm not sure what the right thing to do is.
I can suggest two things:
- Connect the endpoint to the central connection point,
 trim the curve at the edge of the connected object
 and draw the arrow like if the endpoint was there
- Preserve the slope the user set when the endpoint was connected to the
 central CP,
connect the curve at the edge such that it aims at the central CP (with the
 same slope).

Let's not worry about the arc yet.

Does that meen go on with bezier ?
If so, could you comment on what is the right way to do it  ?
(one of the two aforementionned propositions ? ).


For the line, the gap is perfect for my intended use, why did you comment out the GUI ?

It was a rather clunky half-solution to a number of problems, and only
implemented for line.  I wanted something more complete.  I know,
perfectionist syndrome.
In a general setting with an auto-gap, what do you think about this:
instead of absolute-gap and fractional_gap we could use gap_offset and gap_proportion (liner factor) where this latter could apply to either the line/curve length or the autogap length.

To sum up:
offset / prop / target
.10 / 0 / self : constant gap of .10
0 / .1 / self : gap is 10% of length
.10 / .1 / self : gap is 10% of length + .10
0 / 0 /auto : arrow touches edge
.10 / 0 / auto : arrow is 10 away from edge
0 / -.5 / auto : arrow is halfway inside the object

positive values always increase the gap, negative decrease the gap.

Forgot to comment on this part.  One of the problems I had with the
existing code was how many options it added.  It's an interesting idea
to have the fractional gap action depend on being connected to the
object, not sure yet if that would be intuitive.  I was pondering if the
gap could be a single number, where you can either give a length or a
percentage, and it behaves in one or the other of the above mentioned
ways.  No way to make the combined gap, but I don't think it'd be used
that much anyway.  I think the constant gap really is the most important
feature, and we should go for that first -- I don't have a good use case
for the fractional gaps yet.

Ok I'll go for gap = offset + (0/1)*auto

The main thing that's been holding me off is that I wanted to let all
objects have the virtual central CP.  Some objects have a dynamic number
of CPs, which makes it trickier.  We have some notes on this problem on
the TWiki.



Why does it need to be virtual ? ie. Why not a real central CP and multiple
lines connected to it like with the ellipse object ?

The idea is to not have it be a normal CP, but a 'default' CP.  When a
line end is dragged onto the object, but not onto one of the line ends,
it connects to the virtual CP in the center, and the line ends at the
edge of the object.  This would make it possible to make many diagrams
without having to worry about CPs or having to rearrange connections.

Maybe I've been overengineering it in my plans, and it really should
just be that CP 0 for elements is special, and all the element objects
just need updating to place it in the middle.

From an UI point of view, could be that if you drop the arrow inside the object it connects to the center with auto-gap by default. A modifier key could allow
for manual placement of the arrow inside an other object.

I would love it if you started looking at this.  I'd want to keep it
entirely #ifdef'ed until 0.95 is out (unless you code well and fast), but
I'm very interested in seeing some action on that front.  I do feel,
though, that it would be unfair not to mention the Graphviz package, which
is made for making graphs.  Doesn't have the editing abilities of Dia, but
is really good at autolayout.


Yeah I use it a lot too. The layout engines allow to output the graph in xdot format (dot format with positions and parmaters for the curves). But there is one awkward thing: if you modify the xdot file there is no way/option to use the graphviz renderer to display the modified graph as it always re-autolayout
it (AFAIK).

Have you noticed that recent versions support Dia format?  Haven't tried
it out yet.

Just tried it out. It renders the nodes as an ellipse grouped with a text
hand-placed at the center. The arc is a bezier patch, most arcs are a single bezier, some are mulltiple segment beziers the end-arrow is a black triangle.

Funny part:
The arcs are connected to several connection points on the edge of the ellipse
but they are hand placed like connected with the center CP and using a gap.
The arrow endpoint is placed about at twice the "radius" of the ellipse with
the slope pointing towards the center.

If one moves an ellipse the arcs are re-rendered touching those edges, which
is not undoable.

Looks like we should really implement this gap code for beziers.
I'll give it a try.
--
Grégoire Dooms




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