Menu

How to read connection points id from connection line between two shapes

Help
2014-08-28
2014-09-01
  • Aleksandar Stojimirovic

    I am writing application where user will be able to draw network of processing elements and make real time simulation.
    In this situation it is very important to know which connection point from one shape is connected to which connection point of second shape (connection point id would be ideal).

    Connection line parameters (wxSFLineShape) contain information about absolute position of source and target points (GetSrcPoint and GetTrgPoint).

    1. Can we obtain information about source connection point (id) and target connection point (id) within source and target shape ?

    2. How to serialize this information to obtain xml file with connection line properties that contain data about source and target shape (which already exists) and id's of connections of source and destination shapes?

    For each connection line I need this information:

    Connection Line
    Source - SourceConnectionId - Target - TargetConnectionId

    Is there any simple or already implemented way to do this, I suppose I missed something?

    Thank you in advanced,
    Aleksandar

     
  • iwbnwif

    iwbnwif - 2014-09-01

    For (1), unfortunately I don't think there is a simple way (although I agree it would be nice), but it is possible as follows:

    1. Create your own connection points with pre-determined IDs - see wxSFShapeBase::AddConnectionPoint (const wxRealPoint& relpos, long id = -1, bool persistent = true).
    2. Add connections manually using wxSFDiagramManager::CreateConnection (long srcId, long trgId, wxClassInfo lineInfo, bool saveState = true, wxSF::ERRCODE err = NULL)
    3. This will connect the shapes, but you need to adjust the connections to your custom connection points, use wxSFLineShape::SetStartingConnectionPoint and wxSFLineShape::SetEndingConnectionPoint to do this.
    4. You could subclass wxSFLineShape to cache the information that you need.

    With regard to (2), sorry but I haven't got any experience with the serializer. I think it is possible though, take a look at the wxXmlSerializer class and I think you can adapt your custom class discussed in (1) to serialize along with the standard classes.

     

    Last edit: iwbnwif 2014-09-01
  • iwbnwif

    iwbnwif - 2014-09-01

    Sorry I should add that wxSFLineShape::GetSrcShapeId and wxSFLineShape::GetTrgShapeId will get the shapes.

     

Log in to post a comment.