PDA

View Full Version : Overloading Shape Paint change on scene zoom



matteo.boscolo
5th September 2010, 11:18
Hi ,

Look at the following image and as you can see the two image are taken at a difference zooming level on the some entity.
At certain zooming level the arc painted is smaller than the shape one.
I use the some value for both the paint and shape method.
The only difference is that for the shape I use the painterPath.arcTo and for the paint i use the painter.drawArc

51375138



def arcRect(self):
return QtCore.QRectF(self.xc,
self.yc,
self.h,
self.h)


def drawShape(self, painterPath):
"""
called from shape method
"""
r=self.h/2.0
x=r*math.cos(self.sa)
y=r*math.sin(self.sa)
xc, yc=self.center
x=xc+x
y=(yc+y)*-1.0
painterPath.moveTo(x, y)
painterPath.arcTo(self.arcRect(),self.startAngle/16.0,self.spanAngle/16.0)
#painterPath.moveTo(x, y)
#painterPath.addRect(self.arcRect())

def drawGeometry(self, painter, option, widget):
"""
called from the paint method
"""
#Create Arc/Circle

painter.drawArc(self.xc,self.yc ,self.h ,self.h ,self.startAngle, self.spanAngle)
is it a qt Bug or I did something wrong ?
Regards,
Matteo

matteo.boscolo
6th September 2010, 07:15
Solved ..

In may code the arc whose created with this code :

painter.drawArc(self.xc,self.yc ,self.h ,self.h ,self.startAngle, self.spanAngle)
this accept only integer so the self.xc self.yc where double ..

I change the code as follow:

painter.drawArc(self.arcRect(),self.startAngle, self.spanAngle)
where self.arcRect() is a QRectF
I hope this helps someone

Regards,
Matteo