THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 17/08/2009 at 10:32, xxxxxxxx wrote:
Thank you for responding, I really appreciate that.
Yes I did think the MSG_POINTS_CHANGED message would be sent when the position of a point changed.
I have misinterpreted 'The points have changed' entry in the SDK.
What I want to be able to do in an object or tag plugin is make changes to a polygon object as fast as possible.
For example: A tag the user adds to a polygon object and after making a selection of points the user clicks on a button in the tag that effectively lock these points.
The problem is what 'event/message' I should use to implement the freezing.
I have the following code that works, but I am doing something we are not supposed to do: make changes in the structure of an object in the execute member of a TagPlugin (TagData).
Still this example might be the most easiest to explain what I am after, so here is the relevant code:
> \> LONG LockPoints::Execute(PluginTag \*tag, BaseDocument \*doc, BaseObject \*op, BaseThread \*bt, LONG priority, LONG flags) \> { \> PolygonObject\* objPoly =(PolygonObject\* )op; \> ResetPoints(doc,objPoly); \> \> return EXECUTION_RESULT_OK; \> } \> \> Bool LockPoints::Message(GeListNode \*node, LONG type, void \*data) \> { // Receives messages. \> if (type == MSG_DESCRIPTION_COMMAND) \> { DescriptionCommand \*dc = (DescriptionCommand\* ) data; \> PolygonObject\* objPoly; \> \> BaseTag\* tag = (BaseTag\* )node; \> BaseObject\* obj = tag->GetObject(); \> objPoly=(PolygonObject\* )obj; \> \> if (dc->id[0].id==LOCKPOINT_LOCKSELECTED) \> { LockSelected(node->GetDocument(),objPoly); \> } \> if (dc->id[0].id==LOCKPOINT_UNLOCKSELECTED) \> { \> } \> } \> \> if (type == MSG_TRANSLATE_POINTS) \> { // Update the indexes as needed \> } \> return TRUE; \> } \> \> Bool LockPoints::LockSelected(BaseDocument \*doc, PolygonObject\* objPoly) \> { BaseSelect \* objSelPoints; \> LONG lngI; \> LONG \* lngIndex; \> Vector \* posIndex; \> const Vector \* arrPoints; \> \> if (!objPoly->IsInstanceOf(Opolygon)) \> return FALSE; \> objSelPoints=objPoly->GetPointS(); \> LONG lngPointCount=objPoly->GetPointCount(); \> LONG size = sizeof(LONG) \* objSelPoints->GetCount(); \> pointArray = (LONG\* )GeAlloc(size); \> if (!pointArray) \> return FALSE; \> size = sizeof(Vector) \* objSelPoints->GetCount(); \> posArray = (Vector\* )GeAlloc(size); \> arrPoints=objPoly->GetPointR(); \> \> lngIndex = pointArray; \> posIndex = posArray; \> for (lngI=0;lngI<lngPointCount;lngI++) \> { if (objSelPoints->IsSelected(lngI)) \> { \*lngIndex=lngI; \> \*posIndex=arrPoints[lngI]; \> lngIndex++; \> posIndex++; \> } \> } \> lngLockedPoints=objSelPoints->GetCount(); \> \> return TRUE; \> } \> \> Bool LockPoints::ResetPoints(BaseDocument \*doc, PolygonObject\* objPoly) \> { LONG \* lngIndex; \> Vector \* posIndex; \> LONG lngI; \> LONG lngPointCount=objPoly->GetPointCount(); \> Vector \* arrPoints; \> lngIndex = pointArray; \> posIndex = posArray; \> arrPoints=objPoly->GetPointW(); \> \> for (lngI=0;lngI<lngLockedPoints;lngI++) \> { if (arrPoints[\*lngIndex]!=\*posIndex) \> { arrPoints[\*lngIndex]=\*posIndex; \> } \> \> lngIndex++; \> posIndex++; \> } \> \> return TRUE; \> } \>
The ResetPoints function is called from the Execute, and in the important threading information in the SDK it states that this is not allowed.
At least that is how I interpret it, it would be nice if I am wrong.
If a user now selects a 'locked' point and wants to move it he can't because the position is immediately overwritten with the stored position.
Now I have read that you could use the MessageData to capture the EVMSG_CHANGE.
And in this topic I found how you could then call your own plugin again:
Atom array compatibility
But the EVMSG_CHANGE is only fired after the user completes dragging.
So you can move the point and on releasing the mouse, the point jumps back to its locked position.
What I want is a method that makes it look like you cannot move the points, like in my code, but then not violating the rules.
Thanks,
Nebu