[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dia-list
Subject:    Re: pydia & umlattribute: access to right/left connection
From:       Hans Breuer <hans () breuer ! org>
Date:       2011-08-19 17:08:47
Message-ID: 4E4E989F.9030608 () breuer ! org
[Download RAW message or body]

At 17.08.2011 12:46, Pierre-Louis Bonicoli wrote:
> Hi,
>
> Right_connection and left_connection members of the UMLAttribute
> structure are not available from bindings.
>
The connections are available on the object level, getting the one matching 
a specific attribute is possible already, although more difficult than your 
approach. See attached pydia sample.

> Here is a patch which allows to access to these connection points with
> pydia.
>
The patch looks basically right on the implementation level to me. But I 
didn't apply it yet. Bad things would of course happen, if the 
connectionpoint property would be set. But you rightly do not implement that.

But on the design level I wonder if the extra convenience your patch offers 
really justifies all the extra complexity.

> In attachement, test.py is an example of use.
>
> Comments are welcome :)
>
Thanks,
	Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert

["test_connects.py" (text/plain)]

#encoding: utf-8

import dia

def test(data, flags):
	classes = []
	layer = dia.active_display().diagram.data.layers[0]
	for obj in layer.objects:
		if obj.type.name == "UML - Class":
			print "\nobject", obj
			CP_ATTR_OFS = 8 # not including the mainpoint
			i = 0
			connections = []
			for cpt in obj.connections : # connection points
				for co in cpt.connected : # connected objects in this point
					connections.append ((i, co))
				i += 1
			attrs = obj.properties['attributes'].value
			for con in connections :
				n = con[0] - CP_ATTR_OFS
				attr = attrs[n/2]
				if (n % 2) == 0 :
					print n, "\t %s left: connected to %s" % (attr[0], con[1])
				else :
					print n, "\t %s right: connected to %s" % (attr[0], con[1])
					
 			#for attr in obj.properties['attributes'].value:
				# attr is a tuple, len(attr) == 9
				# left_connection: attr[7] -> ConnectionPoint
				# right_connection: attr[8] -> ConnectionPoint
			#	if attr[7].connected:
			#		print "\t %s left: connected to %s" % (attr[0],
			#				attr[7].connected)
			#	if attr[8].connected:
			#		print "\t %s right: connected to %s" % (attr[0],
			#				attr[8].connected)
			classes.append(obj)

#dia.register_callback("Test", "<Display>/Debug/AttConns", test)
dia.register_action ("TestAttConns", "Attribute connections", 
                     "/DisplayMenu/Debug/DebugExtensionStart", 
                     test)



_______________________________________________
dia-list mailing list
dia-list@gnome.org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic