ToolData::GetDDescription() redundant call, why?
-
Hi,
I have a questions about behavior of ToolData class member function GetDDescription().
I can't find any example and I don't understand why Cinema is calling this function several times after each user event in GUI.Below is the code of overridden member function.
I am filling description with controls every time now. (function LoadControls())Bool LwCadToolData::GetDDescription (BaseDocument* doc, BaseContainer& data, Description* description, DESCFLAGS_DESC& flags) { // validation if (description == nullptr) return false; ApplicationOutput("GetDDescription flags: @", flags); // initialize controls LoadControls(C4dControls(description, description->GetSingleDescID())); // controls loaded into tool description flags |= DESCFLAGS_DESC::LOADED; //--------------------- // base return SUPER::GetDDescription(doc, data, description, flags); }
Problem is that after each mouse event , this function is executed several times, always a different description pointer.
Below is the list of calls after a single click.GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: NONE
GetDDescription flags: RESOLVEMULTIPLEDATA|MAPTAGS
GetDDescription flags: NONECould you please give me a hint, how to optimize this properly?
Optimal way is to fill description only once.
Is it necessary fill it every time the GetDDescription() function is executed?Thanks!
-
Cinema will call GetDDescription() whenever it feels like.
But you can optimize by checking for GetSingleDescID(). You find a snippet here: https://developers.maxon.net/docs/cpp/2023_2/page_manual_description.html#page_manual_description_content_edit
-
Hi @WTools3D,
thank you for reaching out to us. @PluginStudent already gave you the full answer. You cannot throttle the number of calls Cinema does make to your tag's
GetDDescription
, but you can limit modifications of the description withGetSingleDescID
to only carry them out when they are being requested.Cheers,
Ferdinand -
Thank you guys for quick reply.
But I was probably not clear enough with the question.I do understated the concept of setting panel description via GetDDescription() callback.
I already did the checks for whether it is request for full description of just single id.
As it is listed in the example below (it is member function of C4dControls class from previous snippetvoid C4dControls::AddIntChoice(int id, int gid, const String& name, const BaseContainer& items) { const DescID cid = DescLevel(id, DTYPE_LONG, 0); //--------------------------------------------------------------------- if (ex_descr && (!ex_singleid || cid.IsPartOf(*ex_singleid, nullptr)) ) { BaseContainer bc = GetCustomDataTypeDefault(DTYPE_LONG); //--------------------------------------------- bc.SetInt32 (DESC_CUSTOMGUI, ID_QUICKTABSRADIO_GADGET); bc.SetString(DESC_NAME, name); bc.SetInt32 (DESC_SCALEH, 1); // animate OFF bc.SetInt32 (DESC_ANIMATE, DESC_ANIMATE_OFF); //--------------------------------------------- bc.SetContainer(DESC_CYCLE, items); //--------------------------------------------- ex_descr->SetParameter(cid, bc, DescLevel(gid)); } }
But it is still calling to rewrite each control description several times after any event in GUI.
What confuses me the most, is that each series of calls is with the different pointer to description (Description* description)
For example there are five different pointers to description when ToolData::GetDDescription() is executed for the same event. (after mouse click into attribute manager)Is this the way how it really works?
There are more versions of description for the same panel, and all of them have to be initialized repeatedly after each event?Thanks!
Viktor