Jump to content

How Do You Make A Callback For The Gui?


Recommended Posts

I want to make a "reset simulation" button.

In my template list, I'm guessing I need some sort of a template like this:

PRM_Template(PRM_CALLBACK, 1, &names[3], 0, 0, 0, ???);

but I'm a bit lost at the "???" - what goes there? I'm not sure I have the syntax correct. I believe it should be something like "&resetSim" when there is a resetSim func that looks something like:

int SOP_whatever::resetSim(void* foobar, int index, float time, const PRM_Template* foo) {
  cout << "\n\nRESET\n" << endl;
}

but that doesn't want to compile.

q1: is that close to correct?

q2: does the reset need the void* or PRM_Template* params, or can I just pass a NULL if I know I won't use them? What does the void* point to anyway? What is "index"?

Link to comment
Share on other sites

Hi Brian,

I believe you can do something like:

PRM_Template(PRM_CALLBACK, 1, &names[3], 0, 0, 0, SOP_whatever::resetSim)

Your resetSim() function should be declared in the header as such:

static int resetSim(void *data, int index, float t, const PRM_Template *);

Once inside resetSim, you should be able to cast data to (SOP_whatever *) and use it as you'd like.

Hope that helps.

George.

Link to comment
Share on other sites

Guest xionmark

Hi Brian,

Here's an example:

// Declare a name for the "write the file" button
static PRM_Name          names[] = {
...
<SNIP>
	PRM_Name("write_file",  "Write Real Flow File"),
</SNIP>
...
}


// Declare a callback widget for the "write the file" button, include the reference to the callback function
PRM_Template(PRM_CALLBACK,  1, &names[5], 0, 0, 0, 
 SOP_RF_Export::writeTheFile),


// Here's the callback function for the "write the file" button
int SOP_RF_Export::writeTheFile(void *data, int index,  
  float time, const PRM_Template *tplate ) {

    SOP_RF_Export *me = (SOP_RF_Export *) data;

	me->calledFromCallback = true;
	me->myCallBackFlags = 0;

	OP_Context myContext(time);
	myContext.setData(data, OP_GEOMETRY_DATA);

	me->myCallBackError = me->cookMe(myContext);

    return 1;
}

--Mark

Link to comment
Share on other sites

  • 2 years later...
Hi Brian,

Here's an example:

// Declare a name for the "write the file" button
static PRM_Name		  names[] = {
...
<SNIP>
	PRM_Name("write_file",  "Write Real Flow File"),
</SNIP>
...
}
// Declare a callback widget for the "write the file" button, include the reference to the callback function
PRM_Template(PRM_CALLBACK,  1, &names[5], 0, 0, 0, 
 SOP_RF_Export::writeTheFile),
// Here's the callback function for the "write the file" button
int SOP_RF_Export::writeTheFile(void *data, int index,  
  float time, const PRM_Template *tplate ) {

	SOP_RF_Export *me = (SOP_RF_Export *) data;

	me->calledFromCallback = true;
	me->myCallBackFlags = 0;

	OP_Context myContext(time);
	myContext.setData(data, OP_GEOMETRY_DATA);

	me->myCallBackError = me->cookMe(myContext);

	return 1;
}

--Mark

In H9 I seem to have to do this:

PRM_Template(PRM_CALLBACK,  1, &names[5], 0, 0, 0,
&SOP_RF_Export::writeTheFile)

Note the ampersand in front of the function.

I still can't get it to work but this seems to get closer :(

Cheers

PeteR B

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...