Results 1 to 11 of 11

Thread: Zooming a selected region on QCanvasView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Zooming a selected region on QCanvasView

    Quote Originally Posted by luffy27 View Post
    So I can't just give these text a inverted matrix.
    Why not?
    Qt Code:
    1. void Coordinate::draw ( QPainter & painter ){
    2. QWMatrix m = painter.worldMatrix();
    3. QWMatrix invm = m.invert();
    4. //...
    5. }
    To copy to clipboard, switch view to plain text mode 


    So is there any possible way to solve the problem so that I can get a good performance after scaling these small-pointSize-texts ?
    Try the one above.


    About the second way to do the job, I couldn't fully understand how to work with this method. Dose that mean, I should add another widget into the canvasview to show these texts?
    Not to the view but next to the view. Just like the scrollbars are. Unfortunately I don't see a simple way to set your own scrollbars (this would be the best), but you need to look for something simmilar.

    But if I do it as this, it can't make sure that after the canvas being scaled these texts still have accordingly position to the coordinate.
    Text won't be scaled. Only the "lines" of the ruler will. And knowing the scale of the view it should be easy to synchronise the scale and knowing position of scrollbars it should be easy to synchronise the translation.

  2. #2
    Join Date
    Nov 2006
    Posts
    58
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    1

    Default Re: Zooming a selected region on QCanvasView

    Quote Originally Posted by wysota View Post
    Why not?
    Qt Code:
    1. void Coordinate::draw ( QPainter & painter ){
    2. QWMatrix m = painter.worldMatrix();
    3. QWMatrix invm = m.invert();
    4. //...
    5. }
    To copy to clipboard, switch view to plain text mode 
    Could you explain to me that where should I add these code in my app?
    In my zoomIn() slot or somewhere?

    And I have another question about the code you give me. Besides these texts my own Coordinate also has some solid-lines, dash-lines as the attached picture show. Of course, I use the QPainter draw these lines as well as these texts. So I think that changing the painter's matrix will also affect these lines' size. As a result, texts will not be scaled, but lines will have the same thing.
    That is not what I want.
    Is that ture?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Zooming a selected region on QCanvasView

    Quote Originally Posted by luffy27 View Post
    Could you explain to me that where should I add these code in my app?
    In my zoomIn() slot or somewhere?
    In the method where you draw your ruler (Coordinate?) items. drawShape() in your case probably...

    So I think that changing the painter's matrix will also affect these lines' size.
    Not if you set the matrix after drawing lines and before drawing text.

  4. #4
    Join Date
    Sep 2007
    Posts
    29
    Qt products
    Qt3
    Platforms
    Unix/X11
    Thanks
    8

    Default Re: Zooming a selected region on QCanvasView

    maybe this helps a little, put it at the end:

    Qt Code:
    1. def main(args):
    2. app = qt.QApplication(args)
    3. demo = make()
    4. app.setMainWidget(demo)
    5.  
    6. #zoom
    7. zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom,
    8. Qwt.QwtPlot.yLeft,
    9. Qwt.QwtPicker.DragSelection,
    10. Qwt.QwtPicker.AlwaysOff,
    11. demo.canvas())
    12. zoomer.setRubberBandPen(qt.QPen(qt.Qt.green))
    13. #mouse coordinates
    14. picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom,
    15. Qwt.QwtPlot.yLeft,
    16. Qwt.QwtPicker.NoSelection,
    17. Qwt.QwtPlotPicker.CrossRubberBand,
    18. Qwt.QwtPicker.AlwaysOn,
    19. demo.canvas())
    20. picker.setTrackerPen(qt.QPen(qt.Qt.black))
    21.  
    22. sys.exit(app.exec_loop())
    23.  
    24. # main()
    25.  
    26.  
    27. # Admire
    28. if __name__ == '__main__':
    29. main(sys.argv)
    30.  
    31. # Local Variables: ***
    32. # mode: python ***
    33. # End: ***
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Zooming a paricular selected region
    By Kapil in forum Newbie
    Replies: 8
    Last Post: 9th May 2006, 15:41

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
  •  
Qt is a trademark of The Qt Company.