PDA

View Full Version : Painter brush question



maverick_pol
21st August 2008, 12:19
Hi guys,

When no scaling is done I can draw using Qt::DenseXPattern without any problem;
There is a need for scaling my graphcisscene about 90times ( scene rect is 90times smaller) and I have to fill a rect(in the drawBackground method) with the Qt::denseXPattern and no brush is shown;
I can only use Solid brushes with the same result despite the current scene scale;
Maybe this is a trivial questions, but can't find the answer.
If anyone has the answer I would really appreciate a short piece of code or an example app showing that the brush may look the same despite the scene rect size;

Any ideas?

wysota
21st August 2008, 16:10
If the scene is smaller then you see everything magnified, correct? And then the brush is transparent? Could you post a screenshot of what you get and what you would expect to see?

maverick_pol
9th October 2008, 22:54
Hi,

This is a pretty simple code, used for checking drawing:
Assume I have a list of polygons: PolygonList;
Assume the polygons are inside 0.5 of a degree, and the whole scene is a rect (-180,-90, 360,180), so polygons are invisible when the whole scene is drawn, but I have to zoom in about 200 times, etc.


// First I have some code to set brush color
QBrush br = _painter->brush();
br.setStyle(Qt::Dense4Pattern);
_painter->setBrush(br);
for(int i=0;i<PolygonList.size();++i)
{
_painter->drawPolygon(PolygonList.at(i));
}

What this code does is:
When I fit my chart(set of polygons) into scene, so all polygons are visible the brush is ok, and my polygons are filled with the given brush, but when I zoom in the polygons are not filled with any color, are transparent. Then, when I zoom out, and zoom out, and zoom out, the polygons are filled with color. Still, when I fit my chart in the scene and try to zoom in the polygons are not filled with any color.

THIS IS BASICALLY WHAT I need to to achieve: the same brush no matter the scale of the chart(zooming in /out )
Should the brush be scaled as well as the scene? I have started Brush in depth study, so this question may be trivial.

Any ideas.

Thanks

wysota
10th October 2008, 00:10
I don't think there is a way to make the pattern transformation invariant. You can make the whole item transformation invariant and manipulate its geometry when zooming or implement your own pattern that will consider the level of detail.

maverick_pol
10th October 2008, 08:28
Hi,

Yes, you're right. The brush is used for drawing some parts of the the scene's background. I can't change to an item. I tried scaling the the brush along zooming in, but is has the same effect as without scaling the brush. It's a bit strange, but I am sure it can be done. How? yet do not know : )

THank you

Kacper

maverick_pol
22nd October 2008, 07:39
In Munich I was given an advice to use a QImage as a pattern and scale it along zooming in/out.
I am currently working on it and will reply when it's working; and paste the code.