Results 1 to 16 of 16

Thread: painter's drawPie() function how to draw few sensible PIEZ..

  1. #1
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Cool painter's drawPie() function how to draw few sensible PIEZ..

    Hi
    i have been trying to show the progress as a pie through drawPie function in Painter,so the pie is shown in 4 stages on first button click it is required to be drawn upto 90 degress ,on second button click it is required to draw upto 180 degress and in the same way when fourth button is clicked it should show a whole circle..
    Now what i have achive is the same thing through drawPie but my code is realy messy and the value of cordinates doesnt makes sense,so i have to copy paste my code couple of time
    Qt Code:
    1. painter.drawPie( (MID_POINT_OUTER_X -40 ), (MID_POINT_OUTER_Y-70) ,
    2. ( OUTER_ELLIPSE_WIDTH - (6*INNER_ELLIPSE_WIDTH) ) ,
    3. ( OUTER_ELLIPSE_HEIGHT - (4.5*INNER_ELLIPSE_HEIGHT ) ) ,
    4. 90*16 , -90*16 );
    5. painter.drawPie((MID_POINT_OUTER_X -40 ), (MID_POINT_OUTER_Y-68) ,
    6. ( OUTER_ELLIPSE_WIDTH - (6*INNER_ELLIPSE_WIDTH) ) ,
    7. ( OUTER_ELLIPSE_HEIGHT - (4*INNER_ELLIPSE_HEIGHT ) ) ,
    8. 0*16 , -90*16 );
    9. ..
    10. painter.drawPie( (MID_POINT_OUTER_X -69 ), (MID_POINT_OUTER_Y-70) ,
    11. ( OUTER_ELLIPSE_WIDTH - (6*INNER_ELLIPSE_WIDTH) ) ,
    12. ( OUTER_ELLIPSE_HEIGHT - (4.5*INNER_ELLIPSE_HEIGHT ) ) ,
    13. -180*16 , -90*16 );
    To copy to clipboard, switch view to plain text mode 
    what i require here is that some how i can build a single function and just pass painter pointer and the starting and ending angle as paramters to that fuction but the first four parameters of drawPie in my case dont follow any sensible pattern or sequence so i have to pass seven parameters and do some mess in function,which doesnt make any sense...any idea on this..

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    What do all these constants stand for? What are those 70, 68, etc.? The worst you might need are functions such as tg and ctg to calculate the bounding rectangle of the pie based on the angle you want to draw.

  3. #3
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    i just used the constant because i thought the value of constant would be perfect for every parameter but when i ran my application i saw a few randomly distributed pies,so i started to adjust the cordinate by subtracting the 'MID_POINT..'constant with numbers (69,70 etc)so i can achieve what i want ...this was based on hit and try method and it worked but without any logic
    sorry i cannot understand what you meant by this..
    The worst you might need are functions such as tg and ctg to calculate the bounding rectangle of the pie based on the angle you want to draw.
    what is tg and ctg..?

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    Quote Originally Posted by salmanmanekia View Post
    what is tg and ctg..?
    Tangent and co-tangent (trigonometric functions). They will let you calculate offsets from the center of the pie. Just take a piece of paper, draw an arbitrary pie (assuming you know its angle) and try to calculate bounding rectangle of the pie. Then simply transfer the same calculations into your application.

  5. #5
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    ok,this some how seems to be a good idea,but i cannot understand it fully...
    i understand that i should draw a pie on a piece of paper with an starting and ending angle,it's x and y cordinates and width and height and then i will calculate tan() and inverse tan()...but how can i calculate it ,i mean mathematically i can only calculate these things for a triangle..waiting...

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    Hint : what is a triangle ? A set of 3 points

  7. #7
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    i understand...but i m afraid what does it means

  8. #8
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    any idea of how to implement the tangent and co-tangent .....

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    You don't have to implement them, they are in standard math library.

    Here is a drawing for you... You have to calculate "x" and "y" given all the angles and "l". What is y/a? What is a/l? What is y/l? What is the mysterious angle?
    Attached Images Attached Images

  10. #10
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    thanks for the hint,
    actually in my case i have to draw a 90 degree pie so i suppose 'alpha' would be 90 degree am i right and since i have to calculate y/a so it seems that it means it is perp./base. which is equal to tan..but i am afraid all the three values are unknown or atleast y and a are unknown if i consider 'Q(theta)' to be 45 ,as the sum of all angle is 180 for straight line and since pie is already 90 degree so i can suppose the other two angle to be 45 degree each ..but still its supposition..

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    You don't have to assume anything here, you have all the values you need. Answer all my questions from the previous post and you will see. Especially think what is y/l and for a 90deg. pie you'll almost have a final answer.

  12. #12
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    i am still confused maybe i am not getting the point what you are trying to say..!!

  13. #13
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    maybe it seems y/l = 1..if i consider the angle to be 45 degree..is it somehow useful..!!

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    Good. y/l is always 1, regardless of the angle. So now if you have "l" and the "?" angle, you can calculate "a". And having that you can calculate "x". You already have "y" (which equals "l"), so you have all values needed to pass to drawPie().

  15. #15
    Join Date
    Jan 2008
    Location
    Finland /Pakistan
    Posts
    216
    Thanks
    20
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    y/l is always 1, regardless of the angle.
    hmm..ok..it seems fine
    So now if you have "l" and the "?" angle, you can calculate "a".
    I have supposed the value of "l" to be 10 and angle "?" to be 45,so is it what i should do i mean supposition or should i calculte these values from some other parameters ?
    And having that you can calculate "x".
    since in the above scenario i have considred "l" to be 10 so the value of "x" should be 20 ,am i right
    You already have "y" (which equals "l"),
    if all above things are rite then i guess that this is quite the value i was looking for..

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

    Default Re: painter's drawPie() function how to draw few sensible PIEZ..

    You don't have to assume anything. I take it that you know either "y" or "l" (which is the same) because you know how "big" your pie is to be. The rest can be calculated using trigonometric functions as I have shown above.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

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.