THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/11/2009 at 01:49, xxxxxxxx wrote:
Sorry, I was absent for a week and just returned.
I've tried EventAdd(EVENT_FORCEREDRAW) and EventAdd(EVENT_DOCUMENTRECALCULATED), but both don't show any effect. I guess those events force the view window to be updated, but not the attribute manager's view.
Here is my Message function:
Bool C4DMyTag::Message(GeListNode *fp_node, LONG l_type, void *fp_data)
{
switch (l_type)
{
case MSG_DESCRIPTION_REMOVE_ENTRY:
{
// a gui-element is removed, find out which one...
DescriptionCommand &lr;_descriptionCommand(*(DescriptionCommand* )(fp_data));
if (lr_descriptionCommand.id.GetDepth() != 2)
break;
if ((lr_descriptionCommand.id[0].id != TMYTAG_DATA_USE)
&& (lr_descriptionCommand.id[0].id != TMYTAG_DATA_VALUE))
break;
if (lr_descriptionCommand.id[1].id < 1000)
break;
LONG l_index = (lr_descriptionCommand.id[1].id - 1000);
loginfo << "removing entry #" << l_index << endlog;
removeEntry(l_index);
}
break;
case MSG_DESCRIPTION_COMMAND:
{
//
// a gui-button was pressed, find out which one...
DescriptionCommand &lr;_descriptionCommand(*(DescriptionCommand* )(fp_data));
if (lr_descriptionCommand.id == TMYTAG_ADD)
addEntry();
}
break;
}
return SUPER::Message(fp_node, l_type, fp_data);
}
What happens in addEntry and removeEntry is that it adds or removes an entry from a list of entries (in a basecontainer) and then calls the updateAttributeManager-function:
void C4DMyTag::updateAttributeManager()
{
BaseTag *lp_tag = (BaseTag* )Get();
BaseObject *lp_object((lp_tag)?lp_tag->GetObject() :0);
if (lp_tag)
{
lp_tag->Message(MSG_UPDATE);
lp_tag->Message(MSG_CHANGE);
}
if (lp_object)
{
lp_object->Message(MSG_UPDATE);
lp_object->Message(MSG_CHANGE);
}
EventAdd(EVENT_FORCEREDRAW);
EventAdd(EVMSG_DOCUMENTRECALCULATED);
}
As you can see, the updateAttributeManager-function should do something to make the attribute manager call the tag's GetDDescription function which is responsible for actually updating the entries which are shown in the attribute manager.
Bool C4DMyTag::GetDDescription(GeListNode* fp_node, Description* fp_description, LONG& fr_flags)
{
if (!fp_description->LoadDescription(fp_node->GetType())) return FALSE;
fr_flags |= DESCFLAGS_DESC_LOADED;
BaseTag *lp_tag = (BaseTag* )Get();
BaseContainer *lp_data = (lp_tag)?lp_tag->GetDataInstance() :0;
BaseContainer *lp_subcontainerUse = (lp_data)?lp_data->GetContainerInstance(TMYTAG_DATA_USE) :0;
BaseContainer *lp_subcontainerLink = (lp_data)?lp_data->GetContainerInstance(TMYTAG_DATA_LINK) :0;
if (lp_subcontainerUse)
{
LONG i=0;
LONG l_id;
while ((l_id = lp_subcontainerUse->GetIndexId(i++)) != NOTOK)
{
if (l_id < 1000)
continue;
LONG l_index = l_id - 1000;
String l_name("");
//
// get the name from the object
BaseLink *lp_link((lp_subcontainerLink)?lp_subcontainerLink->GetBaseLink(1000+l_index) :0);
BaseList2D *lp_object((lp_link)?lp_link->GetLink(lp_tag->GetDocument(), Obase) :0);
if (lp_link && lp_object)
l_name = lp_object->GetName() + " ";
BaseContainer l_bcUse = GetCustomDataTypeDefault(DTYPE_BOOL);
l_bcUse.SetString(DESC_NAME, l_name+"Enabled");
l_bcUse.SetString(DESC_SHORT_NAME, " ");
l_bcUse.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_BOOL);
l_bcUse.SetLong(DESC_ANIMATE, DESC_ANIMATE_ON);
l_bcUse.SetBool(DESC_REMOVEABLE, TRUE);
if (!fp_description->SetParameter(DescID(DescLevel(TMYTAG_DATA_USE), DescLevel(1000+l_index, DTYPE_BOOL, 0)), l_bcUse, DescLevel(TMYTAG_SGROUP))) return FALSE;
BaseContainer l_bcValue = GetCustomDataTypeDefault(DTYPE_REAL);
l_bcValue.SetString(DESC_NAME, l_name+"Value");
l_bcValue.SetString(DESC_SHORT_NAME, " ");
l_bcValue.SetLong(DESC_CUSTOMGUI, CUSTOMGUI_REALSLIDER);
l_bcValue.SetReal(DESC_MIN, 0.0);
l_bcValue.SetReal(DESC_MAX, 1.0);
l_bcValue.SetReal(DESC_STEP, 0.01);
l_bcValue.SetLong(DESC_UNIT, DESC_UNIT_PERCENT);
l_bcValue.SetLong(DESC_ANIMATE, DESC_ANIMATE_ON);
l_bcValue.SetBool(DESC_REMOVEABLE, TRUE);
if (!fp_description->SetParameter(DescID(DescLevel(TMYTAG_DATA_VALUE), DescLevel(1000+l_index, DTYPE_REAL, 0)), l_bcValue, DescLevel(TMYTAG_SGROUP))) return FALSE;
}
}
return SUPER::GetDDescription(fp_node, fp_description, fr_flags);
}
...but the GetDDescription function is only called when I click on another object and then back to my tag to show its attributes again.
What I want is to show the newly added or removed entry while the tag's attributes are visible. Otherwise the user clicks on the button to add an entry and nothing seems to happen.
So what I'm searching for is how I can trigger the attribute manager in my updateAttributeManager-function to call GetDDescription again.
cheers
Joachim