c++ - How to create an point of arbitrary size in Qt's QGraphicsView? -


i wish draw period or dot or point in graphicsview that:

  • has arbitrary size, works radius of circle,

  • is affected scaling transformations in position changed according current scale,

  • but arbitrary size not affected scaling.

the problem i'm tackling depicting celestial bodies in solar system visualizer. want make things proper distances each other, space unimaginably empty - trying depict earth-sized object proper radius make hard viewer see if said user zoomed out enough see other planets. therefore, mark locations dots don't scale in diameter, while else (like orbital paths, distances) scales.

i have tried use itemignorestranformations, makes object ignore both size changes , location changes when scale altered. want object noticeable regardless of scale, @ same time in proper place.

alternative solutions welcome.

edit1:

the new code looks so:

ellipse2 = scene->addellipse(0, 0, body.radius,body.radius,blackpen,greenbrush);  ellipse2->setflag(qgraphicsitem::itemignorestransformations); ellipse2->setpos(system.starx+body.getx(date2days(game.date))-body.radius/2.0,                  system.stary+body.gety(date2days(game.date))-body.radius/2.0); 

previously, position put in the place of 0s in addelipse() call. however, there problem - planets' movements don't quite match plotted orbital paths (i simplifying perfect circles constant angular speed, rather elliptical paths variable angular speed). actual paths seem shifted unknown (but scale-dependent) amount towards top-left.

here how looks unzoomed:
before
, here how looks zoomed:
after

this problem not occur if item affected transformations. gives?

found problem. needed adjust planetary radius in rect, not pos.

the correct code looks like:

ellipse2 = scene->addellipse(-body.radius/2,                              -body.radius/2,                              body.radius,body.radius,blackpen,greenbrush); ellipse2->setflag(qgraphicsitem::itemignorestransformations); ellipse2->setpos(system.starx+body.getx(date2days(game.date)),                  system.stary+body.gety(date2days(game.date))); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -