Results 1 to 6 of 6

Thread: SVG suggestion

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default SVG suggestion

    Hello,
    I am switching to svg in my app but before that i have some clarifications to be cleared.

    Basically i have lots of items on scene arranged as per the required circuit. If i inherit the classes corresponding to these items from QGraphicsSvgItem now, each item inturn inherits QObject - so more bulkier the items become. I don't want this sideeffect.
    So i thought of rendering the items using QSvgRenderer on my own. Now here goes my doubts

    1) Is it necessary to update the item on QSvgRenderer's repaintNeeded() signal for static(no animation i mean) items ?

    2) Should i use different renderers for each type of item or just use a single renderer to render all types of items ?

    3) When should i update cache ? (for eg should i update when i do any transformation on item)
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SVG suggestion

    1. No, for static svg items you don't need that signal.
    2. I have one word for you(well, maybe two): QGraphicsSVGItem::setSharedRenderer()
    3. What cache would be that?

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: SVG suggestion

    Quote Originally Posted by marcel View Post
    1. No, for static svg items you don't need that signal.
    Ok. Infact the code corresponding to QGraphicsSvgItem::setSharedRenderer() doesn't connect the signal at all while it is so done in the constructor! Is it a bug ?

    2. I have one word for you(well, maybe two): QGraphicsSVGItem::setSharedRenderer()
    I don't want to use QGraphicsSvgItem at all But what i mean to say is, should i have separate renderer's for resistors(shared for all resistors), capacitors.. or all of them in one. Does it make any big difference ?

    3. What cache would be that?
    Sorry, i didn't clearly state that. By cache i meant QPixmapCache to cache the svg so that i don't need to render everytime. I had a look at the code of QGraphicsSvgItem but i am not sure when am i supposed to update cache ? When exactly should i dirty and reload to cache ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  4. #4
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: SVG suggestion

    How can i use level of detail flag while rendering svg items ? Can someone help me when to do what at what ratios for level of details ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SVG suggestion

    You'll have to sublcass QGraphicsSvgItem and override paint. Modify the levelofdetail form the style option and call the base class version of paint(the one from QGraphicsSvgItem) with the modified style option.

    I don't really know what effects has the level of detail in practice, but you can play with it and find out.

  6. #6
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: SVG suggestion

    http://labs.trolltech.com/page/Proje...ys/DevDays2007
    The GraphicsView presentation is really great and gives some info on how you can use level of detail(in optimization section)
    My question is what to draw when the level of detail is very less ? In the example the code is as follows

    Qt Code:
    1. void MyItem::paint(QPainter *painter, const QStyleOption...
    2. {
    3. int lod = option->levelOfDetail;
    4. if (lod >= 1) {
    5. // 1:1 or closer
    6. painter->drawRoundRect(0, 0, 100, 100);
    7. } else if (lod >= 0.5) {
    8. // 1:2 to 1:1
    9. painter->drawRect(0, 0, 100, 100);
    10. } else if (lod >= 0.25) {
    11. // 1:4 to 1:2
    12. painter->fillRect(0, 0, 100, 100);
    13. } else {
    14. // Don't draw at all
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

Similar Threads

  1. suggestion for qrc file
    By Lele in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2006, 22:23
  2. need a widget suggestion
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2006, 18: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.