Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion pygraphviz node coordinates to pyqt4 qgraphicsTextItem coordinates

Received: by 10.50.187.202 with SMTP id fu10mr11855424igc.5.1336416421935;
        Mon, 07 May 2012 11:47:01 -0700 (PDT)
X-BeenThere: pygraphviz-discuss@googlegroups.com
Received: by 10.231.80.134 with SMTP id t6ls3788385ibk.8.gmail; Mon, 07 May
 2012 11:47:01 -0700 (PDT)
Received: by 10.50.135.98 with SMTP id pr2mr11857934igb.2.1336416421475;
        Mon, 07 May 2012 11:47:01 -0700 (PDT)
Received: by 10.50.87.229 with SMTP id bb5msigb;
        Mon, 7 May 2012 11:43:42 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.241.129 with SMTP id wi1mr343220pbc.13.1336416221909; Mon,
 07 May 2012 11:43:41 -0700 (PDT)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
 ranisha...@gmail.com designates internal as permitted sender)
 smtp.mail=ranisha...@gmail.com; dkim=pass
 header...@gmail.com
Received: by ri8g2000pbc.googlegroups.com with HTTP; Mon, 7 May 2012 11:43:41
 -0700 (PDT)
Date: Mon, 7 May 2012 11:43:41 -0700 (PDT)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0.2)
 Gecko/20100101 Firefox/10.0.2,gzip(gfe)
Message-ID: <54edfafb-dd88-4ea2-9bb1-e49d78ba91ef@ri8g2000pbc.googlegroups.com>
Subject: pygraphviz node coordinates to pyqt4 qgraphicsTextItem coordinates
From: shashi <ranisha...@gmail.com>
To: pygraphviz-discuss <pygraphviz-discuss@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

I am trying to convert pygraphviz node/edge coordinates to PyQt4
qgraphicsTextItem, but not success.

I read some blog and it was clear said the pygraphviz nodes are to be
represented by QGraphicsEllipseItem objects
which I did and its perfect one to one match, I mean graphviz layout
and QgraphicsEllipseitem were matched (node and edge were connected at
the right place in pyqt).

I did
G = pygraphviz.AGraph ()
G.add_node(item.id,label=item.'name',style='filled',fontname='Helvetica',fontsize=9)
G.add_edge(src.name,des.name,color='blue')
G.layout(prog='dot')

For transformation  to pyqt4, qgraphicsitem I used

x = node.attr[pos][0]
y = node.attr[pos][1]
width = node.attr[width] *72  (for dpi)
height =node.attr[height] *72 (for dpi)

pItem = QGraphicsEllispeitem(item)
pItem.setRect(x-w/2.0,y-h/2.0,w,h) (x-w/2 and y-h/2 because x and y co-
ordinates are center of the node and to get topleft)
This a perfect match node and edges are connected in pyqt4 as compared
to pygraphviz.

I added shape='box' to node attributes and got x,y,w,h as showned
before but instead of GraphicsEllispeitem I replaced QgraphicsTextItem
at this points, I have set background for qgraphicTextitem which gives
a background box on the Textitem
pItem = QGraphicsTextitem(item)
pItem.setPos(x-w/2.0,y-h/2.0)


But there is  difference when compared to pygraphviz to pyqt4, this
may be because qgraphicsTextitem, width depends on text. Is there a
way to correct this difference or I am doing something wrong?