Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to communicate with iCustomGui?

    SDK Help
    0
    28
    16.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 03/03/2014 at 12:29, xxxxxxxx wrote:

      Originally posted by xxxxxxxx

      Are you asking how to do something like this?

      -ScottA

      Hi Scott,
      could you show us how you have done this?

      -Pim

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 03/03/2014 at 13:49, xxxxxxxx wrote:

        Hi Pim,

        It's done by creating a iCustomDataType plugin. Which adds the slider to the list of available UserData gizmos.
        I'd be happy to post the plugin on my site for anyone that wants it. But Niklas provided most of the code I'm using in it. And I wouldn't feel right posting it without his consent.

        There is an example in the SDK called datatype.cpp that you can try to learn from.
        But it's a bit hard to follow because there's no comments in it like I put in my plugins.

        -ScottA

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 03/03/2014 at 14:13, xxxxxxxx wrote:

          Hi Scott,
          I would be very interested to see how you implemented this. Because I thought I did not need that "datatype" at all, to make this work.
          Any information on the iCustomGui and related objects / classes / structures is very much welcome. As a starter, an overview on what they do, and why they are needed, would be very welcome. The SDK docs have a few lines, for me that is far from enough, I do not really understand the purpose of some of the classes. Not to mention how to use them.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 03/03/2014 at 14:31, xxxxxxxx wrote:

            Well...Talk to Niklas guys.
            If he doesn't mind me posting a plugin that's 95% his code. I'll post it.
            It's really up to him.

            -ScottA

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 03/03/2014 at 22:50, xxxxxxxx wrote:

              Thank you Scott for waiting for my permission. Yes, you may make it public 🙂

              Best,
              -Niklas

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 04/03/2014 at 00:47, xxxxxxxx wrote:

                Great, thanks guys.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

                  On 04/03/2014 at 01:27, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  Thank you Scott for waiting for my permission. Yes, you may make it public 🙂

                  Fantastic, thanks! 🙂

                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 04/03/2014 at 08:53, xxxxxxxx wrote:

                    Ok guys. You can grab it here.
                    https://sites.google.com/site/scottayersmedia/plugins

                    I don't own a mac. So it's only compiled for Windows.
                    But the source code is what you really want anyway. 😉

                    -ScottA

                    1 Reply Last reply Reply Quote 0
                    • H
                      Helper
                      last edited by

                      On 04/03/2014 at 10:41, xxxxxxxx wrote:

                      Originally posted by xxxxxxxx

                      Ok guys. You can grab it here.
                      But the source code is what you really want anyway. 😉

                      Right! And thank you so much! I have seen similar things, like Niklas' Tristate example. The comments in the source code are what makes it so valuable, so I learnt from  this!

                      What I am after, and what I meant with the thread topic title, is how to communicate with the iCustomGui when you have several gadgets in the same iCustmGui.
                      Look here, I extended Scott's User Data, by adding a Real Slider:

                      	virtual Bool CreateLayout()
                      	{
                      		//Attach the User Area to the custom GUI gizmo
                      		AddUserArea(1000, BFH_SCALEFIT, 0, 0);
                      		AttachUserArea(ua, 1000);
                      		 **AddEditSlider(1001, BFH_SCALEFIT, 80);**
                      		return TRUE;
                      	}
                      

                      But when using xpresso, I only have access to Scott's slider, not the added slider:

                       
                      This is not a topic when using UserData like this. But it becomes interesting when using it in a RES file, to add gadgets to you tag.
                      While I now can send a few real values back and forth between my tag and the iCustomGui, I cannot replicate the SplineData behaviour, if you are familiar with that one.

                      So my initial question in this thread remains, I do not know how to properly send data from my tag plugin to my iCustomGui, and read those data back, when the iCustomGui has several gadgets.
                      I have managed to do it somehow, but, I am almost sure, in an inadequate way.

                      A full working example on how to do this, is what I want, with all files involved. It doesn't have to be fancy, actually just two Real gadgets wold do. I must be able to set the values of both from my tag, read back the values again, after they are changed by the user. And they must remember their positions when
                      a) the project is saved and closed, b) another tag is selected so that it loses focus.

                      I am still almost in start position on this task, unfortunately.

                      1 Reply Last reply Reply Quote 0
                      • H
                        Helper
                        last edited by

                        On 04/03/2014 at 11:32, xxxxxxxx wrote:

                        Yeah.
                        Controlling the gizmo if it's added within the .res file and not with the UserData is still not known to me yet.
                        And one reason why I keep asking Maxon for an example of their slider gui code. So we can see what they're doing in there to make that work.
                        I get turned down every time I ask them for the code.

                        -ScottA

                        1 Reply Last reply Reply Quote 0
                        • H
                          Helper
                          last edited by

                          On 04/03/2014 at 12:22, xxxxxxxx wrote:

                          Originally posted by xxxxxxxx

                          Yeah.
                          Controlling the gizmo if it's added within the .res file and not with the UserData is still not known to me yet.

                          I know how to do it in a way, but I doubt it is the correct way.

                          Originally posted by xxxxxxxx

                          Yeah.
                          And one reason why I keep asking Maxon for an example of their slider gui code. So we can see what they're doing in there to make that work.
                          I get turned down every time I ask them for the code.

                          Well, I sent a mail ti dev support, - total silence..
                          One might think it would benefit Maxon, the end user - and us plugin writers - if we were taught how to do it the correct way. Well, maybe they do not have working examples, and I guess they have their days filled up..

                          1 Reply Last reply Reply Quote 0
                          • H
                            Helper
                            last edited by

                            On 04/03/2014 at 12:39, xxxxxxxx wrote:

                            Oh shoot.
                            I forgot to add this to the notes in the code. But I do know how to poll the slider's values when using this gizmo when it's created in the .res file instead of the UserData pallet.
                            I know you want to go the other direction and control the slider itself.
                            But this is how to get the value of the custom slider if it's been created in a .res file.

                            Lets say that you're creating a tag plugin and you want to use this custom slider by creating it in the tag's .res file.
                            This is what the .res file should look like:

                            CONTAINER tsimpletag  
                            {  
                              NAME tsimpletag;  
                              INCLUDE Texpression;  
                                
                                
                              GROUP ID_TAGPROPERTIES   //The default tab named "TAB"  
                              {  
                                 //"MYSLIDER" is the ID for the CUSTOMGUI gizmo hard coded within it's source code  
                                 LONG MY_SLIDER_GIZMO { CUSTOMGUI MYSLIDER; MIN 0;}    
                              }  
                            }
                            

                            Then in one of your tag's methods you can get the value of the slider like this:

                            Bool MyTag::Message(GeListNode *node, LONG type, void *data)  
                            {  
                              BaseTag *tag = (BaseTag* )node;                                    //Get the tag and assign it to a variable  
                              BaseContainer *tagdata = ((BaseList2D* )node)->GetDataInstance();  //Get the container for the tag  
                              
                              LONG sv = tagdata->GetLong(MY_SLIDER_GIZMO);  
                              
                              //The value is very large(in pixels) so we chop it down to return 0-10  
                              sv = sv/200000000;  
                              GePrint(LongToString(sv));  
                               
                              tag->SetDirty(DIRTYFLAGS_DATA); //Used to update a Tag's AM GUI items  
                              return TRUE;  
                            }
                            

                            Not really what you're asking for.
                            But most people will probably just want to get the value of the slider. And that how to do it.
                            I should have included that information in the notes.

                            -ScottA

                            1 Reply Last reply Reply Quote 0
                            • H
                              Helper
                              last edited by

                              On 25/03/2014 at 03:22, xxxxxxxx wrote:

                              Originally posted by xxxxxxxx

                              What I am after, and what I meant with the thread topic title, is how to communicate with the iCustomGui when you have several gadgets in the same iCustmGui.
                              Look here, I extended Scott's User Data, by adding a Real Slider:

                              	virtual Bool CreateLayout()
                              	{
                              		//Attach the User Area to the custom GUI gizmo
                              		AddUserArea(1000, BFH_SCALEFIT, 0, 0);
                              		AttachUserArea(ua, 1000);
                              		 **AddEditSlider(1001, BFH_SCALEFIT, 80);**
                              		return TRUE;
                              	}
                              

                              But when using xpresso, I only have access to Scott's slider, not the added slider:

                               
                              This is not a topic when using UserData like this. But it becomes interesting when using it in a RES file, to add gadgets to you tag.
                              While I now can send a few real values back and forth between my tag and the iCustomGui, I cannot replicate the SplineData behaviour, if you are familiar with that one.

                              So my initial question in this thread remains, I do not know how to properly send data from my tag plugin to my iCustomGui, and read those data back, when the iCustomGui has several gadgets.
                              I have managed to do it somehow, but, I am almost sure, in an inadequate way.

                              A full working example on how to do this, is what I want, with all files involved. It doesn't have to be fancy, actually just two Real gadgets wold do. I must be able to set the values of both from my tag, read back the values again, after they are changed by the user. And they must remember their positions when
                              a) the project is saved and closed, b) another tag is selected so that it loses focus.

                              I am still almost in start position on this task, unfortunately.

                              Have you created an iCustomDataType for your iCustomGUI? Since you now display two values in
                              your GUI, it can not be represented by a single float value anymore which is why it needs its own
                              new datatype.

                              Best,
                              -Niklas

                              1 Reply Last reply Reply Quote 0
                              • H
                                Helper
                                last edited by

                                On 25/03/2014 at 03:37, xxxxxxxx wrote:

                                Hi Niklas,
                                > Have you created an iCustomDataType for your iCustomGUI?
                                Yes, I tried at least.

                                _> Since you now display two values in  your GUI, it can not be _
                                > represented by a single float value anymore
                                I understand this!

                                > which is why it needs its own new datatype.
                                I understand this too!

                                What I need, is a fully working example on how to do this.
                                It is a long time since I posted my first question in this thread, and in the mean time, I have found a sort of a solution by passing a BaseContainer between my Tag plugin, and my iCustomGui. But I still do not know how to employ the iCustomDataType.

                                So on my wishlist is a fully working example on how to communuiate between a BaseTag and a iCustomGui, using the iCustomDataType. Because this is still Greek to me..

                                1 Reply Last reply Reply Quote 0
                                • H
                                  Helper
                                  last edited by

                                  On 25/03/2014 at 03:52, xxxxxxxx wrote:

                                  Hi Ingvar,

                                  out of interest, how do you communicate between your Tag and iCustomGui?

                                  I'll try to make an example this week, it is on my Todo list.

                                  Best,
                                  -Niklas

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    Helper
                                    last edited by

                                    On 25/03/2014 at 04:24, xxxxxxxx wrote:

                                    Hi Niklas

                                    virtual Bool SetData(const TriState<GeData> &tristate)
                                    {
                                    		const GeData &value = tristate.GetValue();
                                    		if(value.GetContainer())
                                    		{
                                    			BaseContainer* bc = value.GetContainer();
                                    			Real fooReal = bc->GetReal(12345);
                                    			LONG fooLong = bc->GetLong(6789);
                                    			Bool fooBool = bc->GetBool(654321);
                                    		}
                                    }
                                    
                                    virtual Bool GetData(const TriState<GeData> &tristate)
                                    {
                                    		BaseContainer bc;
                                    		bc.SetReal(12345, 3.14);
                                    		bc.SetLong(6789, 2014);
                                    		bc.SetBool(654321, TRUE);
                                    		GeData geContainer(bc);
                                    		return TriState<GeData>(geContainer);
                                    }
                                    

                                    By passing a BaseContainer between the tag and the custom GUI, I can send a bunch of data in one operation.
                                    When reading this code, you have to take into consideration that it is simplified, I have removed all the normal validity and safety checks.
                                    In the tag, I can just use SetParameter() and use a BaseContainer that I create on the fly, fill it up with data, and use it as the second parameter. The first parameter is the ID of the Custom GUI.
                                    For the record, I had to concentrate on other tasks the last couple of weeks, so this topic is out of my head at the moment, but I will come back.

                                    I am really looking forward to a working example. Please use the BaseTag plugin type, and no Dialog or Command plugin. I do understand the iCustomDatatype if the user needs to add CustomData to the tag. But I do not understand the purpose of it when communicating between the tag and the GUI.

                                    And - keep the example simple, if possible 🙂

                                    1 Reply Last reply Reply Quote 0
                                    • H
                                      Helper
                                      last edited by

                                      On 25/03/2014 at 16:07, xxxxxxxx wrote:

                                      Hi ingvar,

                                      I see, thanks for the info. 🙂 Didn't think of containers for that use case, neat workaround.

                                      By the way, it just appeared to me that the SDK example in source/datatype/datatype.cpp actually
                                      does what you want, exposing the parameters to XPresso. It lacks the comments completely,
                                      though. I'll still be making an example.

                                      Best,
                                      -Niklas

                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        Helper
                                        last edited by

                                        On 25/03/2014 at 16:46, xxxxxxxx wrote:

                                        Hi Niklas,
                                        I found the datatype.cpp example some weeks ago. And I have turned the datatype.cpp inside out, upside down, das ganze auf den Kopf gestellt - I still do not see how that can help me communicate with the custom GUI.
                                        For the User data - I can understand its purpose, but not for the communication between a BaseTag and a CustomGui.

                                        Please note this: We might be talking about different things.
                                        It is not about the User Data, like the image you posted above. It is about making a Custom Gui for my tag. I want to make a custom gui, like the SplineData GUI, just as an example.
                                        My concern is the communication between the BaseTag and the CustomGui. Which I somehow have solved, using the BaseContainer.

                                        But let us look at the SplineData Custom Gui.
                                        If I had Maxon's soure code for this, I might understand how it works. Have you seen all the code you need to write in order to programmatically add knots to the SplineData Custom GUI?  
                                        I know how to write the code in C++ for doing this, add knots and set the tangents. Because I found the source code for doing this here in this forum, or elsewhere on the Internet.
                                        But I have absolutely no clue whatsoever why it has to be done this way.

                                        1 Reply Last reply Reply Quote 0
                                        • H
                                          Helper
                                          last edited by

                                          On 01/04/2014 at 11:33, xxxxxxxx wrote:

                                          Originally posted by xxxxxxxx

                                          Hi Niklas,
                                          I found the datatype.cpp example some weeks ago. And I have turned the datatype.cpp inside out, upside down, das ganze auf den Kopf gestellt - I still do not see how that can help me communicate with the custom GUI.
                                          For the User data - I can understand its purpose, but not for the communication between a BaseTag and a CustomGui.

                                          Please note this: We might be talking about different things.
                                          It is not about the User Data, like the image you posted above. It is about making a Custom Gui for my tag. I want to make a custom gui, like the SplineData GUI, just as an example.
                                          My concern is the communication between the BaseTag and the CustomGui. Which I somehow have solved, using the BaseContainer.

                                          But let us look at the SplineData Custom Gui.
                                          If I had Maxon's soure code for this, I might understand how it works. Have you seen all the code you need to write in order to programmatically add knots to the SplineData Custom GUI?  
                                          I know how to write the code in C++ for doing this, add knots and set the tangents. Because I found the source code for doing this here in this forum, or elsewhere on the Internet.
                                          But I have absolutely no clue whatsoever why it has to be done this way.

                                          Hi ingvar, I am working on an example for you. Your BaseContainer approach is not bad at all
                                          actually, less work than implementing your own CustomDataType.

                                          The only way to communicate between your tag and your CustomGUI is by passing the appropriate
                                          data from the tag to your CustomGUI. You solved it with a BaseContainer, the SplineGUI has its
                                          own CustomDataType.

                                          The BitmapButtonCustomGui is a very good example for this. Its custom datatype has a pointer
                                          to the BaseList2D (in your case the tag) that uses the custom GUI. The Custom GUI uses this
                                          pointer to invoke the MSG_DESCRIPTION_GETBITMAP message on it.

                                          Originally posted by xxxxxxxx

                                          Have you seen all the code you need to write in order to programmatically add knots to the SplineData Custom GUI?

                                          I don't think I do understand what you mean. I don't see where there is much code to write
                                          to add knots to a SplineData. Would you mind pointing that out for me?

                                          Best,
                                          -Niklas

                                          1 Reply Last reply Reply Quote 0
                                          • H
                                            Helper
                                            last edited by

                                            On 01/04/2014 at 12:51, xxxxxxxx wrote:

                                            Hi Niklas,
                                            where can I find the source code for the BitmapButtonCustomGui?

                                            Originally posted by xxxxxxxx

                                            I don't think I do understand what you mean. I don't see where there is much code to write
                                            to add knots to a SplineData.

                                                GeData gdSplineData(CUSTOMDATATYPE_SPLINE, DEFAULTVALUE);                             //Stores the data gotten from SplineData
                                                SplineData *spd = (SplineData* )gdSplineData.GetCustomDataType(CUSTOMDATATYPE_SPLINE); //Creates an instance of the SplineData class
                                                if (!spd) 
                                                  return;
                                            //    spd->SetUserCallback(FooGetUserCallback(3, NULL), NULL);  
                                                
                                                CustomSplineKnot *knot1;   //The first spline knot
                                                CustomSplineKnot *knot2;   //The second spline knot
                                              
                                                spd->MakeLinearSplineBezier(2);
                                                
                                                //Real xmin, Real xmax, Real xsteps, Real ymin, Real ymax, Real ysteps
                                                spd->SetRange(0.0, 1.0, 0.01, 0.0, 1.0, 0.01);
                                              
                                                //Set The first spline knot's position to 0,0,0
                                                knot1 = spd->GetKnot(0);
                                                knot1->vPos = Vector(0, 0, 0);
                                                knot1->lFlagsSettings |= FLAG_KNOT_LOCK_X|ADD_KNOT_ADAPT_TANGENTS;
                                                knot1->vTangentRight = Vector(0.2, 0.1, 0);
                                              
                                                //Set The second spline knot's position to 100,100,0
                                                knot2 = spd->GetKnot(1);
                                                knot2->vPos = Vector(1, 1, 0);
                                                knot2->lFlagsSettings |= FLAG_KNOT_LOCK_X|ADD_KNOT_ADAPT_TANGENTS;
                                                knot2->vTangentLeft = Vector(-0.3, 0.3, 0);
                                              
                                                Bool success = node->SetParameter(FOO_SPLINE, gdSplineData,
                                            	 DESCFLAGS_SET_0);
                                            

                                            Maybe it is the naming convention in C4D that collides with my way of thinking. But I still do not understand how to write my own Custom Data type, and use it the way it is being used for SplineData. I spent many (too many) hours trying to do it myself, but it will always crash at some stage, and not do what SplineData does.

                                            A working example would be just great! Keep it simple! Do not introduce new things that are not strictly necessary to explain things. What also is needed (in my opinion) is an overall description of what the various classes / structures do, what their purposes are, what roles they play and so on. I have read the SDK docs, regarding this. But I did not get much wiser than I was when I started.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post