drawing arc
-
Hi,
I'm trying to understand strange problem with drawing.
We are drawing lines using
QGraphicsLineItem * GItemPtr = scene_->addLinewe need to draw arcs also and because there is no direct addArc on the scene we created own arcItem class that extends QGraphicsItem in which we get access to Painter in paint method.
There we draw arc as
painter->drawArc(x_, y_, w_, h_, 16start_angle_, 16start_angle_-16*end_angle_);But our arcs are slighly shift out of place.
When we debugged where the problem is we drawn bounding box of arc by drawing lines
We draw one inside paint function where arc is drawn using
painter->drawLine();and we draw same lines right before where we construct arc and pass it coordinates.
scene_->addLine();this is the result.
https://www.dropbox.com/s/kg5vd2ypaca0ave/Screenshot 2015-09-25 18.22.40.png?dl=0Box drawn by addLine() directly in scene and box grown by lines usign painter is drawn at slightly different place despite we give it exactly same coordinates.
Using also same pen in both cases set to width 2 and set to cosmetic.One more thing to note is that we draw more arcs on the scene and each of the arc is displaced differently. We could not find any similarity in displacements, seems like its random or what. but each run each arc is displaced the same way so its not completely random, its just different difference between bounding boxes on different coordinates.
Does anyone have a clue how to fix this?
Thnaks a lot.
Stan -
I am on restricted network and can't access picture.
So I can't take it into account,but keep in mind scene related functions work in scene coordinates and item related - in item coordinates.
What you get on the screen is which may be subject to transformation.
And transformation may be a sensitive to the order of operations.For example translate item and then rotate it will have different result then first rotate it then translate.
-
Hi and thanks for hints. We were thinking also about local coordinates of arc being drawn. But considering that when drawing arc in its local space using global scene coordinates and then adding arc into scene at 0.0 would be the same as drawing arc in its local coords at 0.0 and then placing it at some position.
Considering we don't rotate which we don't at this time...Will try to draw at 0.0 and translate in scene afterward. lets see if that'll make a difference.