Results 1 to 4 of 4

Thread: Decide the arrow graphics item's docking point

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Decide the arrow graphics item's docking point

    Hello forum,

    I have some elliptical graphics items which will be connected by arrow graphics item.

    The user is supposed to draw the arrow item by clicking and moving from the elliptical item with the control modifier. Even if the user clicks over the

    elliptical item i would want to the arrow source start from the border of the elliptical item. The same scenario should happen when the user release the

    mouse button over the another destination elliptical item - the arrow destination lands on the border of the elliptical item.


    I am trying to write a function to return the docking point for the elliptical item - either for the source or the destination item.

    The outline of the function is:

    Qt Code:
    1. QPointF RootGraphicsItem::hierarchyArrowDockingPoint() const
    2. {
    3. return QPointF(0,0);
    4. }
    To copy to clipboard, switch view to plain text mode 


    I need some hint to start ahead.

    Thnak you.



    Regards
    Sajjad

  2. #2
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Decide the arrow graphics item's docking point

    Hello forum,

    Havent got any response yet. It is quite probable that i have not presented the problem properly enough.


    Let me try again.


    I want to draw an arrow line item from the border of the elliptical item even if the use clicks over the elliptical item.


    Any existing reference or examples to solve this ?


    Regards
    Sajjad

  3. #3
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Decide the arrow graphics item's docking point

    Hi forum,

    This may be a more a mathematical question that the qt related one, but i need to post it here just in case some one might know.

    Which point on the ellipse gives the shortest distance from the mouse click position inside the ellipse ?



    Regards
    Sajjad

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Decide the arrow graphics item's docking point

    The Diagram Scene Example does this sort of thing for polygonal objects by looking for the intersection of the arrow line and each line in the polygon. You cannot do this for the ellipse though, and I cannot see an obvious Qt way to do this (there may be one though).

    For ellipses you will need to do more maths. For ellipse where an axis is horizontal then this is trivial: http://mathworld.wolfram.com/Ellipse...ersection.html. For ellipses in other orientations you may need to rotate first. For partial ellipses the problem is much more difficult.

  5. The following user says thank you to ChrisW67 for this useful post:

    sajis997 (17th January 2012)

Similar Threads

  1. How to decide which SIGNAL to emit?
    By TheIndependentAquarius in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2011, 15:09
  2. Graphics item highlight
    By mukunda in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2011, 18:21
  3. Graphics Item
    By Maluko_Da_Tola in forum Newbie
    Replies: 4
    Last Post: 20th July 2010, 14:37
  4. Replies: 1
    Last Post: 29th June 2010, 17:59
  5. Replies: 6
    Last Post: 18th August 2006, 17:50

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.