Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

CustomGUI in description

 Post Reply Post Reply
Author
Message
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Topic: CustomGUI in description
    Posted: 2018 Feb 21 at 1:25am

User Information:

Cinema 4D Version:   R16 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hi,

I need to write a new CustomGUI that will go in a description resource for the attribute manager, NOT into a dialog. I can see from the SDK example how to use iCustomGui and iCustomDataType, which I assume is what I need, but the example uses dialogs and I can't see how to add the GUI to a description.

Is this also how it's done for descriptions (i.e. using a GeUserArea in a dialog in a description - seems sort of odd), or is it some different method altogether? I could really use a pointer on how to get started, not having done this before.

Thanks,

Steve


Edited by spedler - 2018 Feb 21 at 1:25am
Back to Top
xNWP View Drop Down
Member
Member
Avatar

Joined: 2017 Jul 20
Location: Canada
Online Status: Offline
Posts: 8
Post Options Post Options   Quote xNWP Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 21 at 2:15am
To use the custom GUI in a description you'll need to use CustomGuiData (which you pass your iCustomGui) to. You can see an example of this here.

You'd still need to use it with an existing datatype i.e.
REAL MY_NEW_ELEMENT { CUSTOMGUI MY_CUSTOM_GUI; }

You can also create a custom datatype with iCustomDataType and register that with CustomDataType.

And then do something like
MY_CUSTOM_DATATYPE MY_NEW_ELEMENT { CUSTOMGUI MY_CUSTOM_GUI; }

Definitely take a look at this, specifically the CustomGUI section.
Hopefully that helps you get started :-)
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 21 at 4:34am
Thank you, that's very helpful. I'll give it a try and see how I get on.

Steve
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 21 at 5:55am
Hm, not getting very far with this. I have the SDK examples built and installed, and this should have a custom GUI which returns the resource symbol 'CUSTOMGUISTRING'. It's base datatype is DTYPE_STRING, so if I understand it correctly, I should be able to to do this in my description resource:

STRING MY_ELEMENT_ID { CUSTOMGUI CUSTOMGUISTRING; }

But trying that just gives a resource error when the object using the resource is created. What am I missing?

Steve
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 21 at 6:30am
NVM, I've got the custom gui dots example from the R18 SDK working fine in my description, so I can work from there. Thanks again for your help, much appreciated.
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1127
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 22 at 3:07am
Hi Steve,

You can find information on descriptions and custom GUIs inside these 2 manuals:




MAXON
Developer Support
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 22 at 4:33am
Thanks Yannick. Those are both helpful. The problem I find with custom guis is that the information is scattered around various places and not easy to find. The SDK example (the dots one) is extremely useful but it doesn't answer all questions.

For example, I can add a custom property to my custom gui as an integer value - call it NUM_SWITCHES. Then unless I'm completely off track I think I can use that in the resource file like so:

MY_CUSTOM_GUI { NUM_SWITCHES 3; }

But I can't see how to retrieve the value of NUM_SWITCHES in my code. It's that sort of thing that the docs and examples don't quite cover.

If anyone at MAXON is looking for a topic to add to the developer blogroll, custom guis would be a great one to do.

Steve
Back to Top
Yannick Puech View Drop Down
Forum Moderator
Forum Moderator


Joined: 2011 Apr 13
Location: Spain
Online Status: Offline
Posts: 1127
Post Options Post Options   Quote Yannick Puech Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 23 at 8:28am
Hi Steve,

If you define a NUM_SWITCHES property for a custom GUI:
CustomProperty mycustomgui_properties[] =
{
  {CUSTOMTYPE_LONG, MYCUSTOMGUI_NUM_SWITCHES, "NUM_SWITCHES"},

  {CUSTOMTYPE_END, 0, nullptr }
};
Returns mycustomgui_properties in the override of CustomDataTypeClass::GetProperties() and CustomGuiData::GetProperties().
With the definition of a member in the custom GUI class:
class MyCustomGui : public iBaseCustomGui
{
  INSTANCEOF(MyCustomGui, iBaseCustomGui)

  ...

private:
  Int32 _numSwitches;
};
Then retrieve NUM_SWITCHES property value in the custom GUI constructor with the settings container:
MyCustomGui::MyCustomGui(const BaseContainer &settings, CUSTOMGUIPLUGIN *plugin) : iBaseCustomGui(settings, plugin)
{
  _numSwitches = settings.GetInt32(MYCUSTOMGUI_NUM_SWITCHES);
}


Thanks for the feedback. It will help us improve the custom GUI examples.

For quite some time now we decided to improve the C++ SDK documentation with manuals instead of posting blog articles.






Edited by Yannick Puech - 2018 Feb 23 at 8:33am
MAXON
Developer Support
Back to Top
spedler View Drop Down
Member
Member


Joined: 2008 Apr 19
Location: United Kingdom
Online Status: Offline
Posts: 680
Post Options Post Options   Quote spedler Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 24 at 12:39am
This is great stuff Yannick, thanks! Sorry but I have two more questions since you're here :-)

First, how would I go about adding a property like a CYCLE or ACCEPT property - which can be followed by a list of ID values? None of the custom types seem to fit for this.

Second, once I get my custom data type working, I'm wondering how to access it from another plugin. So for example, if I add a gradient custom gui to a resource I can access it from code like so:

Gradient *grad = (Gradient*)bc->GetCustomDataType (MY_GRADIENT, CUSTOMDATATYPE_GRADIENT);

I assumed that it was a CustomDataTypeClass that would be returned, so if I had this code snippet:

class MyCustomData : public CustomDataTypeClass

Int32 MyCustomData::GetId()
{
    return MYCUSTOMDATA_ID;    // unique ID
}
// plus other functions of course

Then in a plugin hosting my custom gui I tried this:

MyCustomData *mcd = (MyCustomData*)bc->GetCustomDataType(MY_CUSTOMGUI, MYCUSTOMDATA_ID);
// where MY_CUSTOMGUI is the resource ID for custom gui

But it always returns a null pointer. Is this correct or is GetCustomDataType() trying to find the wrong thing?

Cheers,

Steve
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1364
Post Options Post Options   Quote S_Bach Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 28 at 8:52am
Hello,

attributes like "CYCLE" and "ACCEPT" are hard-coded in the Cinema 4D core and not implemented using the plugin infrastructure. So I'm afraid it is not possible to implement something similar in a custom data type.

To have access to internal data of another plugin, this plugin must expose internal data in the form of a public API. Such a public API is created using the library system. See Creating Libraries. Or look at the source of any existing custom data type in the c4d_customgui folder of your cinema.framework.

When you register your custom GUI you call InstallLibrary(). You can use that library to define functions that give access to internal data and thus your data type. Creating such a library is quite an advanced and complex topic.

best wishes,
Sebastian
SDK Support Engineer
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.109 seconds.