SplineData Callbacks
-
On 30/07/2013 at 08:09, xxxxxxxx wrote:
Thanks Nik,
I gave it a shot. But I'm getting a similar error.
Only this time it's this:
Error: cannot convert parameter 1 from 'Bool (__cdecl * )(LONG,void * )' to 'SplineDataCallback'//The CallBack method Bool mySplineCallBack(LONG id, void *p_data) { switch (id) { case SPLINE_CALLBACK_CURSORINFO: { auto data = (SplineDataCallbackCursorInfo* ) p_data; if (!data) return FALSE; GePrint("Mouse Pos: " + LongToString(data->x) + ", " + LongToString(data->y)); break; } } return TRUE; } ......... //Calling the callback method EXECUTIONRESULT SplineTag::Execute(BaseTag *tag, BaseDocument *doc, BaseObject *op, BaseThread *bt, LONG priority, EXECUTIONFLAGS flags) { GeData d; //Create a variable to hold the data we will get using GetParameter() below if (tag->GetParameter(DescLevel(MY_SPLINE), d, DESCFLAGS_GET_0)) //If the tag with the spline GUI exists { SplineData *myspline = (SplineData* )d.GetCustomDataType(CUSTOMDATATYPE_SPLINE); //Assign a variable to the spline's container so we can access & edit them later on if(myspline) { CustomSplineKnot *knot1 = myspline->GetKnot(0); //Get the first spline's knot in the spline GUI CustomSplineKnot *knot2 = myspline->GetKnot(1); //Get the second spline's knot in the spline GUI if (knot2) { Vector knot1pos = knot1->vPos; //Get the position of the first spline's knot and assign it to a variable Vector knot2pos = knot2->vPos; //Get the position of the second spline's knot and assign it to a variable myspline->SetUserCallback(mySplineCallBack, NULL); } } return EXECUTIONRESULT_OK; }
-ScottA
-
On 30/07/2013 at 08:27, xxxxxxxx wrote:
is MySplineCallback / mySplineCallback intentional ?
-
On 30/07/2013 at 08:32, xxxxxxxx wrote:
^LoL. You caught me before I could update my post. You guys are too quick.
I fixed it. But still I'm having problems getting it to work.-ScottA
-
On 30/07/2013 at 08:52, xxxxxxxx wrote:
1. Why do you only test for knot2 but not knot1? It could be NULL too.
2. What are the new problems you are facing?
3. I think you should only call SetUserCallback() once in SplineTag::Init() where you initialize the Spline GUICheers,
-Nik -
On 30/07/2013 at 08:59, xxxxxxxx wrote:
My problem is getting the callback code to complie and work.
It doesn't work for me as a Bool type either.Error: cannot convert parameter 1 from 'Bool (__cdecl * )(LONG,void * )' to 'SplineDataCallback'
-ScottA
-
On 30/07/2013 at 09:37, xxxxxxxx wrote:
I overlooked this as well: The docs say that the second argument is const void* not void*.
-
On 30/07/2013 at 10:00, xxxxxxxx wrote:
Thanks. That fixed it.
It compiles now. However I'm not getting any results from it.
I wonder if we have to use GetUserCallback() in combination with this to get a result?-ScottA
-
On 30/07/2013 at 10:52, xxxxxxxx wrote:
Never mind. I've got it working.
Apparently you have to call to your spline callback from within the Init() method.
In my mind that seem rather strange. Because it should make it run only once when the tag is created. Then not run anymore.
That's how using the Init() method usually works.But in this case. I guess the callback uses the Init() method to start it up.
And then once it's been started, it will keep on running in the background. And feedback the mouse positions.Thanks a lot for your help Niklas,
-ScottA -
On 30/07/2013 at 11:23, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Apparently you have to call to your spline callback from within the Init() method.
In my mind that seem rather strange. Because it should make it run only once when the tag is created. Then not run anymore.
That's how using the Init() method usually works.By "call to your spline callback from within the Init() method", do you mean the following?
myspline->SetUserCallback(mySplineCallBack, NULL);
You do not call your function here. You only pass it as a parameter and the SplineGUI will call
this method at a later point. Calling your function would look likeSplineDataCallbackDraw data; // fill the data mySplineCallBack(SPLINE_CALLBACK_DRAW, &data);
but you should not do this. The SplineGUI is doing this, but doing this yourself makes no sense.
-Nik
-
On 30/07/2013 at 11:35, xxxxxxxx wrote:
Originally posted by xxxxxxxx
By "call to your spline callback from within the Init() method", do you mean the following?
myspline->SetUserCallback(mySplineCallBack, NULL);
Yes.
The other Callbacks I've used don't work this way.
I have to place them within an Execute, or Message method so that they will continuously update.
But this one acts more a like a windows service. Where once you start it. It will continue to run and update on it's own.CallBacks in general always trip me up.
I'm not very good with them.-ScottA