Results 1 to 15 of 15

Thread: qwtpolt ticks and ticks of grid on the qwtplot ??

  1. #1
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qwtpolt ticks and ticks of grid on the qwtplot ??

    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.
    grid.jpg

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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

  3. #3
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Quote Originally Posted by Qt&qwtNoob View Post
    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

  5. #5
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Quote Originally Posted by Uwe View Post
    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.
    gridpic.jpg
    Attached Images Attached Images

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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 !

  7. #7
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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
    Attached Files Attached Files
    Last edited by Qt&qwtNoob; 24th October 2012 at 16:25.

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Quote Originally Posted by Qt&qwtNoob View Post
    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

  9. #9
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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

  10. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Quote Originally Posted by Qt&qwtNoob View Post
    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" !

  11. #11
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    •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

  12. #12
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Attached you find an implementation of your plot item - the missing parts should be trivial.

    It can be used this way:

    Qt Code:
    1. CoordinateSystem* system = new CoordinateSystem();
    2. system->setPosition( QPointF( 1.0, 8.0 ) );
    3. system->setSize( QSizeF( 2.0, 2.0 ) );
    4. system->setRotation( 30.0 );
    5. system->setZ( ... );
    6. ...
    7. system->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    8. system->attach( &plot );
    To copy to clipboard, switch view to plain text mode 
    HTH,
    Uwe
    Attached Files Attached Files

  13. The following user says thank you to Uwe for this useful post:

    Qt&qwtNoob (29th October 2012)

  14. #13
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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
    Qt Code:
    1. majorTicks = m_xScaleDiv.ticks(QwtScaleDiv::MajorTick)
    To copy to clipboard, switch view to plain text mode 
    insted of
    Qt Code:
    1. majorTicks = m_yScaleDiv.ticks(QwtScaleDiv::MajorTick)
    To copy to clipboard, switch view to plain text mode 
    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.

  15. #14
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    Quote Originally Posted by Qt&qwtNoob View Post
    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

  16. The following user says thank you to Uwe for this useful post:

    Qt&qwtNoob (30th October 2012)

  17. #15
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qwtpolt ticks and ticks of grid on the qwtplot ??

    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
    Last edited by Qt&qwtNoob; 30th October 2012 at 15:45.

Similar Threads

  1. Lining up Inner and Outer Ticks
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 27th September 2012, 07:31
  2. Replies: 1
    Last Post: 30th July 2010, 07:23
  3. Qslider Ticks not displayed
    By iaguirre in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2010, 05:09
  4. Replies: 1
    Last Post: 16th March 2010, 15:23
  5. Problem with scale ticks
    By gd in forum Qwt
    Replies: 4
    Last Post: 10th December 2009, 08:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.