The AddShape() functions use "device positions" so if you want to specify the position of newly added shape in "logical" coordinates, you must re-calculate it in accordance to the current canvas settings. You can do it via wxSFShapeCanvas::LP2DP() function. Please, try the following command:
I have been having problems adding shapes programatically after a diagram has been scaled. Basically they end up in the wrong position.
This is my code:
The last shape added ends up in the wrong position. I can work around the problem by adding a MoveTo, i.e:
I think the problem is in DiagramManager.cpp line 134. If I change it to:
Everything is fine.
The AddShape() functions use "device positions" so if you want to specify the position of newly added shape in "logical" coordinates, you must re-calculate it in accordance to the current canvas settings. You can do it via wxSFShapeCanvas::LP2DP() function. Please, try the following command:
wxSFRectShape shape3 = (wxSFRectShape)m_Manager.AddShape(CLASSINFO(wxSFRectShape), m_pCanvas->LP2DP(wxPoint(300, 300)), false);
Ah thank you for the explanation, your suggestion works fine (with a little bit of rounding errors).
Thanks once again!
Last edit: iwbnwif 2014-03-31