How to add new fields in the inspector for my custom class ?



  • Hi everyone,

    I have created my own custom class that derives from SBStructuralModel and I want to display an important information of my class in the brand new SAMSON inspector. How should I do that ?

    Thanks in advance !
    Yassine



  • Here is an example for a Visual model, you can simply adapt that:

    1 Create and implements the functions

    SBQuantity::length getVal1() const;
    float getVal2() const;
    
    void setVal1(SBQuantity::length val1);
    void setVal2(float val2);
    

    2 Then in the descriptor(you may have to create the descriptor if not already done) of your node, add:

    SB_INTERFACE_BEGIN;
    SB_ATTRIBUTE_READ_WRITE(SBQuantity::length, MyVisualModel, Val1, "value 1", "My Parameter");
    SB_ATTRIBUTE_READ_WRITE(float, MyVisualModel, Val2, "value 2", "My Parameter");
    
    SB_INTERFACE_END;


  • All the getters must be 'const' :

    SBQuantity::length getVal1() const;
    float getVal2() const;
    


  • Indeed, I will edit my answer



  • Awesome !

    Thank you guys, you rock !

    Yassine


Log in to reply
 

Looks like your connection to SAMSON Connect - Forum was lost, please wait while we try to reconnect.