On Sun, 7 Mar 2004, W. Borgert wrote:
[...]
> > - Dia python plugin / simple XML generator / no parser at all / other ? > > I think, a stand-alone Python programme would be the best > solution, using either the standard Python XML library or > the libxml2 module for Python. There is no much gain in > having it a Dia plugin, right?
I really doubt this : if one can live with the huge Dia dependency one gets the ability to place object dependent on their size - computed by Dia itself. How can any external tool deliver this ?
I don't know, that's why I ask the question. The best approach for me, would be to be able to import some dia module that will handle all the xml stuff for me. My dream would be sth that looks like :
import dia
mygraph = dia.A_new_graph()
router1 = dia.A_new_icon("Cisco router") router2 = dia.A_new_icon("Cisco router") net1 = dia.A_new_icon("Cloud") dia.mygraph.add(router1,(0,0)) dia.mygraph.add(net1,(20,0)) dia.mygraph.add(router1,(40,0)) dia.mygraph.connect(router1, net1) dia.mygraph.connect(router2, net1) dia.mygraph.writefile("mymap.dia")
Maybe something similar like the dirty script below will do the trick.
Note: I'm not including al it's dependencies (they are just working on win32 anyway, _but_ what it does is similar to what I think you want to do. It's based on pydia which is included in the Dia package for a long time now [I've written this plug-in almost two years ago ;-]
Creates a diagram with connected objects (here UML Packackes, which reperenst the dependency tree of a given component) :
#!/usr/bin/env python
import sys
import gtk import dia
# Another HACK to get my tools sys.path.insert(0, r'c:\util\tool')
def dlg_destroy (w):
w.destroy ()def dia_generate_dia_cb (data, flags) :
import os
os.chdir(r'd:\graph\dia\bin')
sModule = 'dia.exe' import deps2dia
deps = {}
deps2dia.GetDeps (sModule, deps)
deps2dia.RemoveWellKnown (deps) maxcnt = 0
bycnt = {}
for s in deps.keys () :
a = deps[s]
n = len(a)
if maxcnt < n :
maxcnt = n
#sys.stderr.write(s + " ")
if bycnt.has_key (n) :
bycnt[n].append(s)
else :
bycnt[n] = [s]dt = dia.get_object_type("UML - LargePackage")
layer = data.layers[0]
# create objects sorted by number of deps
objs = {}
x = 0
y = 0
yofs = len(bycnt.keys())
for i in range(0, maxcnt +1) :
if bycnt.has_key(i) :
x = 0
for s in bycnt[i] :
o, h1, h2 = dt.create(x * 15.0, yofs - y * 10.0)
o.properties["name"] = s
layer.add_object(o)
objs[s] = o
x += 1
y += 1
# add dependencies
dt = dia.get_object_type("UML - Dependency")
for s in objs.keys() :
o1 = objs[s]
for sd in deps[s] :
o2 = objs[sd]
opos = o1.properties['obj_pos'].value
x = opos.x + o1.properties['elem_width'].value / 2
y = opos.y + o1.properties['elem_height'].value
o, h1, h2 = dt.create(x, y)
layer.add_object(o)
# connect it
h1.connect (o1.connections[6])
h2.connect (o2.connections[1]) layer.update_extents()
dia.active_display().add_update_all()dia.register_callback ("Dia Group Properties",
"<Display>/Debug/Dependencies",
dia_generate_dia_cb)and get this diagram :It is, but obviously Dia Python plug-ins can call external tools.
[Cisco icon]--[cloud icon]--[Cisco icon]
Does this exists ? I know there is a dia module, but it is not installed in the python library. I imagine it is only for the python plugin.
Is it ok to use it in external programs ? And how to use it ?
The only way to use pydia in fact is for a Python scripts running embedded in Dia. There are some more or less simple examples in the distribution.
Hans -------- Hans "at" Breuer "dot" Org ----------- Tell me what you need, and I'll tell you how to get along without it. -- Dilbert
_______________________________________________ Dia-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/dia-list FAQ at http://www.lysator.liu.se/~alla/dia/faq.html Main page at http://www.lysator.liu.se/~alla/dia
