PDA

View Full Version : qwtpolt ticks and ticks of grid on the qwtplot ??



Qt&qwtNoob
17th October 2012, 22:41
Hello everyone,

I have lil knowladge about qwt and qt ghraphics,

I am trying to draw a grid on a qwtpolt using the plot coordiantes, where this grid has its own ticks that i set the start anb end and the interval.

It is lil bite not clear we i descripe it with words so i attached a shot to show what im trying to do.
8315

Uwe
18th October 2012, 07:35
If you question is about having grid lines at different positions than the ticks of the axis scales:

Overload QwtPlotGrid::updateScaleDiv() doing nothing - with the version from SVN trunk you can unset the QwtPlotItem::ScaleInterest flag instead. Then assign your positions using QwtPlotGrid::setXDiv() and QwtPlotGrid::setYDiv().

Uwe

PS: I have absolutely no idea what your image means

Qt&qwtNoob
18th October 2012, 14:45
it is not really undating the plot grid with different scale then the polt ticks,

The pic i attched, simplly i want to draw the blue rect in the middle on qwtpolt including the ticks as well.

1. I have qwt polt with its ticks.

2. draw the rect using the polt coordiantes.

3. then have a grid just in the rect i draw with the my ticks that i set.

hope that made the pic more clear

Uwe
18th October 2012, 15:41
hope that made the pic more clear
Sounds like you want to have another plot painted inside the plot canvas, somehow related to the coordinate system of the first plot - I still have no idea what you want to do.

Uwe

Qt&qwtNoob
19th October 2012, 15:46
Sounds like you want to have another plot painted inside the plot canvas, somehow related to the coordinate system of the first plot Uwe

Well, its something like this.

Lets put an example
let assume we have want to draw a rect with four points :
P1 = (0,0)
p2 = (0,900)
p3 = (900,600)
p4 = (0,600)

so we draw the rect with these points on the polt.

then i want to divide the rect in to grid start from zero and increment by 10

I attched a pic to show how it will looks like... this pic is more realistic as the numbering and every thing just as i would like to draw it.
8332

Uwe
19th October 2012, 23:43
Then you need to have a plot item for the embedded canvas. There are many details to learn, but as a beginner maybe start with something like the RectItem of the navigation example.

If you want to display something related to the coordinate system of your embedded plot ( f.e. a grid ) you have to overload and modify the canvasRect and canvasMap parameters in the draw methods of the plot items ( or in QwtPlot::drawItems for all items above a certain z value ). The geometry of the embedded canvas in widget coordinates ( = the paint intervals you need for the maps ) can be calculated using the original maps.

Uwe

PS: its a plot not a polt !

Qt&qwtNoob
24th October 2012, 16:25
Thanks for the hints.
I finally found the naviagtion example, it was in the playgound folder and its called rescalear in case anyone will need it as well.

I tryied to understand what i can.
the embadded canvesdo u mean by that the plot canves??
can you please explaine more about the canvasMap and canvasRect parameters ?? are they in the origianl implimnataion of the plot ???
as a start i got the RectItem and draw my rect, but i dont know where i need to do the interl ticks on the rect or how can i draw them ???

I attched a test project where I draw the rect ... if you dont mind could you please show me how i draw the ticks on the rect ?? i really fell lost and i don't know where I look.

Thank you so much

Uwe
25th October 2012, 09:05
the embadded canvesdo u mean by that the plot canves
First of all you need to find some terminology that makes it possible to ask and answer questions. I recommend to use the Qwt terminology - when possible - what means you have to learn some basics of Qwt before we continue.

For me it looks like you want to embed a second canvas ( what you call a rect ) inside of a plot canvas. By ticks you probably mean that the embedded canvas has its own coordinate system and you want to have scales/axes showing it. It also looks like you want to display plot items according to the coordinate system of the embedded canvas - at least a grid, but I guess there is more.

This all has not much to do with a question how to display a rectangle on a plot !

Uwe

Qt&qwtNoob
25th October 2012, 15:46
Sorry if i am not using QWt terminology becuase i am new to qwt and even qt it self.
I only used the RectItem of the navigation example, because you recommanded me to start with that. and i don't know what tools/ objects i need to use in qwt to do what i want to do.
but i think things now a lil clear to me than before.


For me it looks like you want to embed a second canvas ( what you call a rect ) inside of a plot canvas
Yes i think this will be the right object to represent my rect.
but can I draw the the embedded canves using four points according the the polt coordiante system ??


By ticks you probably mean that the embedded canvas has its own coordinate system and you want to have scales/axes showing it

Yes, but how can i do that ??


It also looks like you want to display plot items according to the coordinate system of the embedded canvas - at least a grid, but I guess there is more.


Yes, i wan to display a gird according to the embedded canves coordiante system. but other poltItems will be displayed accoding to the polt coordiante system, which mostly will be on the area of the embedded canvas (rect).

Thank you for your patience and help

Uwe
26th October 2012, 09:03
Yes, i wan to display a gird according to the embedded canves coordiante system. but other poltItems will be displayed accoding to the polt coordiante system, which mostly will be on the area of the embedded canvas (rect).

Is the geometry of the embedded canvas really aligned to the coordinate system of the plot or is it more like that you want to have it relative to the geometry of the canvas ( f.e somewhere in the top/right corner ) ?
Beside the grid: what type of information do you want to display according to the coordinate system of the embedded canvas ?


Uwe

PS: once more, it is "plot" not "polt" !

Qt&qwtNoob
29th October 2012, 13:39
•Is the geometry of the embedded canvas really aligned to the coordinate system of the plot or is it more like that you want to have it relative to the geometry of the canvas ( f.e somewhere in the top/right corner ) ?

I should be aligned to coodinate system of the plot, i dont want it to be in the top/right corner, as it should be anywhere on the plot and it could be even rotated with some angle , that is why i asked if i can set the canves using four points as a rect. so i can rotate it as i want.



Beside the grid: what type of information do you want to display according to the coordinate system of the embedded canvas ?

actully the embedded canves will has only the gird and the scales, other plotItems with be drawn using the plot coordiante system so i can see these items will be located on the area of the "rect" the embedded canves or not, and if it does then i can see in which place exactlly located according to the embedded canves coordiantes system.
so the embedded canves and the scales shown on it are only informative way , and its not used to draw any other plotItems.

the only coordiate system we use to draw other items is the plot coordiante system which also used to draw the embedded canves (the rect).

thank you so much

Uwe
29th October 2012, 17:11
Attached you find an implementation of your plot item - the missing parts should be trivial.

It can be used this way:


CoordinateSystem* system = new CoordinateSystem();
system->setPosition( QPointF( 1.0, 8.0 ) );
system->setSize( QSizeF( 2.0, 2.0 ) );
system->setRotation( 30.0 );
system->setZ( ... );
...
system->setRenderHint( QwtPlotItem::RenderAntialiased, true );
system->attach( &plot );
HTH,
Uwe

Qt&qwtNoob
29th October 2012, 20:47
THANK YOU, THANK YOU, THANK YOU Uwe,

This is really amazing, im really greatful to you and for your help.

I was playing around with it, trying to understand it more and how you implemented it.

There was lil bug which is when you draw the grid.
It was painting same number of lines for both x and y .. using the majorticks for x..

when you were painting the lines for y... you just set

majorTicks = m_xScaleDiv.ticks(QwtScaleDiv::MajorTick)
insted of

majorTicks = m_yScaleDiv.ticks(QwtScaleDiv::MajorTick)
just wanted to mention it incase someother one want to use it and so he know that.

I was just wondring if i want to change the number of majorticks for x and y when i zoom in and out .. so it displays more ticks when im zoomed in and less majorticks when i zoom out ?? how can i link it ?

Thank you again thank you soooooooooooooooooooooooo much, thank you for your time and your help I really really appriciate it.

Uwe
30th October 2012, 05:36
I was just wondring if i want to change the number of majorticks for x and y when i zoom in and out .. so it displays more ticks when im zoomed in and less majorticks when i zoom out ??
Implement CoordinateSystem::updateScaleDiv() and adjust your scales depending on the incoming ranges.

HTH,
Uwe

Qt&qwtNoob
30th October 2012, 15:45
Thank you :))

Added after 1 59 minutes:

sorry, but can i use different painters to paint the rect , x and y scale and grid for x and y ??

because i want to use different line style for the grid and different colors for each x and y

thanks