Spline gui redraw [SOLVED]



  • On 09/03/2015 at 22:46, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi folks,

    some more spline gui troubles here..!

    I've seen a few topics regarding the spline custom gui object and on how to refresh it, but none of the topics seemed to answer the question on how to trigger a redraw of the spline gui element. I'm wanting to update it's draw when a user fiddles with an input field (e.g. selected knot's x position). The changing of the knot position works fine, but the gui element doesn't redraw. I need to hover my mouse over it for it to redraw with the proper new knot position. Calling MySplineGui->Redraw() doesn't do anything. It looks like others have had similar issues to this before.

    What's the correct way (or 'a' way) of redrawing the spline gui?

    WP.



  • On 12/03/2015 at 08:11, xxxxxxxx wrote:

    Hi,

    can you provide me with some pieces of code, how, where and when you are trying to update your SplineGUI? Then I hope, we'll be able to find at least 'a' way to get this working.



  • On 12/03/2015 at 21:37, xxxxxxxx wrote:

    Hi Andreas,

    sure. Bare with me on this one, the setup is a little in-depth, but I think it's important to paint a picture as you (or anyone else) might spot something that I can't see, or am unaware of! The short of it is this - I've inherited from a dialog class, and in that class I house a spline gui variable. I then use this dialog class as a variable in another main dialog class, which looks a bit like this:

      
    class MyCustomSplineClass : public GeDialog   
    {   
    private:   
      
        SplineCustomGui *Spline_Gui;   
        SplineData *Spline_Data;   
        CustomSplineKnot *Knot;   
        GeDialog *Dialog;   
        int Initial_Enum;   
            
    public:   
      
        // the basic GeDialog overrides here, including:   
            
        virtual bool Command(..);   
        virtual LONG Message(...);   
            
        // then I have some custom spline based functions   
        // here, including the following two:   
            
        Draw_Spline(LONG flags,int Size_x,int size_y)   
        {   
            // Note the use of the Dialog reference   
            // instead of the inherited dialog link   
                 
            Dialog->GroupBegin(Initial_Enum,...);   
            Spline_Gui = (SplineCustomGui* )Dialog->AddCustomGui(Gui_Enum_Id + 1,CUSTOMGUI_SPLINE,...etc...);   
              Dialog->AddEditNumberArrows(Gui_Enum_Id + 2,...etc...);   
            Dialog->GroupEnd();   
                 
            // the edit number field is used for example,   
            // to change a selected points X position   
            // these elements draw/update and send   
            // commands fine.   
        }   
            
        Set_Dialog_Reference(GeDialog* dlg)   
        {   
            Dialog = dlg;   
        }   
            
        void Set_Initial_Enum_id(int e)   
        {   
            Initial_Enum = e;   
        }   
    }   
      
    class MainDialog : public GeDialog   
    {   
    private:   
      
    MyCustomSplineClass MySpline;   
      
    public:   
      
    Bool CreateLayout(void)   
        {   
            ...Make dialog layout etc here, including:   
                 
            MySpline.Set_Initial_Enum_id(ENUM_ID_HERE);   
            MySpline.Set_Dialog_Reference(this);   
            MySpline.Draw_Spline(BFH_SCALEFIT|BFV_SCALEFIT,NULL,NULL);   
                 
            ... finish off dialog layout here   
        }   
    }   
    

    I've set it up like this for three reasons: first it means I only have to edit the one class object in order to update many spline gui objects. Second, it means I can use the custom spline header files in other plugins. And thirdly - I can use the GeDialog's Message() and Command() functions in my custom spline object to catch messages/commands etc.

    The messaging works a little like this: enum id's are tested for inside the main dialog's Command(), and if they meet the various enum id criteria, the command id is passed onto the custom spline object's Command(). I know that it works - the messages etc are all receieved in the custom spline class, I can print things and change other gui elements like the AddEditNumberArrows() fields.

    The way I call the redraw is simple - I use a function called RedrawCurve() in the custom spline object class, which can be triggered from anywhere, such as from inside the custom spline object's Command(). It looks like this:

      
    class MyCustomSplineClass : public GeDialog   
    {   
        SplineCustomGui *Spline_Gui;   
            
        ...   
      
        void RedrawCurve(void)   
        {   
            if(Spline_Gui != NULL)   
            {   
                Spline_Gui->Redraw(); // doesn't work   
                Spline_Gui->LayoutChanged() // doesn't work   
      
                // mousing over the gui however, does work!   
            }   
        }   
    }   
    

    Let me know if you need more. Otherwise, that's the bare bones of it and pretty much it. Everything in the custom spline object works - I can edit real fields, get their values and change spline point positions etc. I'm also using it in two separate plugins. Everything works, everything except for the updating of the spline gui draw itself!

    Cheers,

    WP.



  • On 13/03/2015 at 02:32, xxxxxxxx wrote:

    I'm somewhat missing the code, where you call Spline_Gui->SetSpline().

    Yannick added another hint to use this code:

    BaseContainer splineMsg;
    splineMsg.SetInt32(0, IDC_SPLINE_FRAME_ALL);
      
    pSplineGui->Command(IDC_SPLINE_PRESET_POPUPMENU, splineMsg);
    

    Let me know, if this helped.



  • On 14/03/2015 at 00:53, xxxxxxxx wrote:

    Ah - wonderful! Using the command seems to trigger the redraw. I think this will do enough. Pass on my thanks to Yannick!

    Re - the Spline_Gui->SetSpline(), oops, I missed that one! In my experimental dialog I set a SplineData variable in the custom spline object, which is setup in the constructor. This is then set to the Spline_Gui->SetSpline(.here.) just after the spline gui is allocated. After that, I can set/update it with another SplineData object which I can select via a combo box.

    A big and important part of my plugin is just about complete with this! Big thanks,

    WP.



  • On 14/03/2015 at 02:20, xxxxxxxx wrote:

    Just for completeness, I want to mention, that SetSpline() updates the SplineGui as well. So there may be situations, you don't need the command at all or where it's use might trigger double/redundant updates.


Log in to reply