TreeView in material description



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/04/2004 at 06:02, xxxxxxxx wrote:

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

    ---------
    I did read a little about the CustomGuiData and CustomDataTypeClass, but I'm still fighting with it.
    What I want to do: In the description of my material I want to show a TreeView. So far I did lear, that I have to define my own CustomGuiData, which returns a CDialog*, within that one I will have to return my TreeView. The function of it will somehow be compareable with MATASSIGN. It only shows some actual states, but they dont need to be saved to the container. So, do I need a CustomDataTypeClass for the CustomGuiData, or is that not necessary? Can I acess member variables of my material from CustomDataTypeClass? My material contains a list of many basebitmaps and a name for each one. This list is a member variable, is loaded by the material and even saved to an own specific format. Within the TreeView I just want to show the actual assignment of that list, the names according to each bitmap. I want to use a TreeView, because later it can be thousands of little bitmaps within the material, so I want to group the names to several packets, just for a better overview.
    A short description of the steps I will have to do would be nice.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/04/2004 at 00:45, xxxxxxxx wrote:

    So far I found out: You always need a CustomGuiData AND an according CustomDataTypeClass with it.
    I continue working on it, if I know how all of that works, I'll post a howto :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/04/2004 at 02:13, xxxxxxxx wrote:

    Here's an example of a custom GUI: (Originally from MSA. I'm not sure if I've posted it here before.)

        
        
        struct SplinePos : public CustomDataType {...}  
          
        LONG convfrom[] =  
        {  
          ID_GV_VALUE_TYPE_REAL  
        };
        
        
        
        
        LONG convto[] =  
        {  
          ID_GV_VALUE_TYPE_REAL  
        };
        
        
        
        
        class MSASplinePos : public CustomDataTypeClass  
        {  
        INSTANCEOF(MSASplinePos,CustomDataTypeClass)  
        public:  
          virtual LONG GetId() { return MSA_SPLINEPOS_DATATYPE_ID; }
        
        
        
        
          virtual CustomDataType* AllocData() { return gNew SplinePos; };  
          virtual void FreeData(CustomDataType* data) { SplinePos* d = static_cast<SplinePos*>(data); gDelete(d); }
        
        
        
        
          virtual Bool CopyData(const CustomDataType* src, CustomDataType* dst, GeAliasTrans *aliastrans)  
          {   
            const SplinePos* s = static_cast<const SplinePos*>(src);   
            SplinePos* d = static_cast<SplinePos*>(dst);  
            if (!s || !d) return FALSE;   
              
            *d = *s;  
              
            return TRUE;   
          }
        
        
        
        
          virtual LONG Compare(const CustomDataType* d1,const CustomDataType* d2)  
          {   
            const SplinePos* s1 = static_cast<const SplinePos*>(d1);   
            const SplinePos* s2 = static_cast<const SplinePos*>(d2);  
            if (!s1 || !s2) return FALSE; 
        
        
        
        
            return (*s1 == *s2) ? 0 : (*s1 < *s2 ? -1 : 1);   
          }
        
        
        
        
          virtual Bool WriteData(const CustomDataType *t_d,HyperFile *hf)  
          {  
            if (!t_d || !hf) return FALSE;  
            const SplinePos* s = static_cast<const SplinePos*>(t_d);  
              
            // level == 0  
            hf->WriteReal(s->m_value);  
            hf->WriteLong(s->m_unit);
        
        
        
        
            return TRUE;  
          }  
            
          virtual Bool ReadData(CustomDataType *t_d, HyperFile *hf, LONG level)  
          {  
            if (!t_d || !hf) return FALSE;  
            SplinePos* s = static_cast<SplinePos*>(t_d);
        
        
        
        
            if (level >= 0)  
            {  
              hf->ReadReal(&s->m_value);  
              hf->ReadLong(&s->m_unit);  
            }
        
        
        
        
            return TRUE;  
          }
        
        
        
        
          virtual Bool _GetDescription(const CustomDataType *data, Description &res, LONG &flags,  
                                       const BaseContainer &parentdescription, DescID *singledescid)  
          {  
            const SplinePos* s = static_cast<const SplinePos*>(data);  
            if (!s) return FALSE;
        
        
        
        
            BaseContainer value = GetCustomDataTypeDefault(DTYPE_REAL);  
            value.SetString(DESC_NAME, GeLoadString(MSA_SPLINEPOS_VALUE_TEXT));  
            value.SetLong(DESC_UNIT, UnitToFormat(s->m_unit));  
            res.SetParameter(DescLevel(MSA_SPLINEPOS, DTYPE_REAL, MSA_SPLINEPOS_DATATYPE_ID), value, DESCID_ROOT);  
            
            BaseContainer unit = GetCustomDataTypeDefault(DTYPE_LONG);  
            unit.SetString(DESC_NAME, GeLoadString(MSA_SPLINEPOS_UNIT_TEXT));  
            BaseContainer cycle;  
            cycle.SetString(UNIT_METER, "m");  
            cycle.SetString(UNIT_PERCENT, "%");  
            cycle.SetString(UNIT_POINT, "p");  
            unit.SetContainer(DESC_CYCLE, cycle);  
            res.SetParameter(DescLevel(MSA_SPLINEPOS_UNIT, DTYPE_LONG, MSA_SPLINEPOS_DATATYPE_ID), unit, DESCID_ROOT);
        
        
        
        
            flags |= DESCFLAGS_DESC_LOADED;
        
        
        
        
            return SUPER::_GetDescription(data, res, flags, parentdescription, singledescid);  
          }
        
        
        
        
          virtual Bool GetParameter(const CustomDataType *data,const DescID &id,GeData &t_data,LONG &flags)  
          {  
            const SplinePos* s = static_cast<const SplinePos*>(data);  
            if (!s) return FALSE;
        
        
        
        
            if (id[0].id == MSA_SPLINEPOS)  
            {  
              t_data = s->m_value;  
              flags |= DESCFLAGS_PARAM_GET;  
            }  
            else if (id[0].id == MSA_SPLINEPOS_UNIT)  
            {  
              t_data = s->m_unit;  
              flags |= DESCFLAGS_PARAM_GET;  
            }
        
        
        
        
            return SUPER::GetParameter(data, id, t_data, flags);  
          }
        
        
        
        
          virtual Bool SetDParameter(CustomDataType *data,const DescID &id,const GeData &t_data,LONG &flags)  
          {  
            SplinePos* s = static_cast<SplinePos*>(data);  
            if (!s) return FALSE;
        
        
        
        
            if (id[0].id == MSA_SPLINEPOS)  
            {  
              s->m_value = t_data.GetReal();  
              flags |= DESCFLAGS_PARAM_SET;  
            }  
            else if (id[0].id == MSA_SPLINEPOS_UNIT)  
            {  
              s->m_unit = t_data.GetLong();  
              flags |= DESCFLAGS_PARAM_SET;  
            }  
              
            return SUPER::SetDParameter(data, id, t_data, flags);  
          }
        
        
        
        
          
          virtual void GetDefaultProperties(BaseContainer &data)   
          {  
            data.SetLong(DESC_CUSTOMGUI, MSA_SPLINEPOS_GUI_ID);  
            data.SetLong(DESC_ANIMATE, DESC_ANIMATE_ON);  
          }
        
        
        
        
          virtual CHAR *GetResourceSym() { return "MSA_SPLINEPOS"; }
        
        
        
        
          
          virtual LONG GetConversionsFrom(LONG *&table)  
          {  
            table = convfrom;  
            return sizeof(convfrom)/sizeof(LONG);   
          }  
            
          virtual GvError ConvertFromGv(LONG type, const void *const src, LONG cpu_id, CustomDataType *dst)  
          {  
            SplinePos* d = static_cast<SplinePos*>(dst);  
            if (!d) return GV_CALC_ERR_NOT_VALID;
        
        
        
        
            switch (type)  
            {  
            case ID_GV_VALUE_TYPE_REAL:  
              {  
                d->m_value = ((Real* ) src)[cpu_id];  
                d->m_unit = -1;  
              } return GV_CALC_ERR_NONE;  
            }
        
        
        
        
            return SUPER::ConvertFromGv(type, src, cpu_id, dst);  
          }  
            
          virtual LONG GetConversionsTo(LONG *&table)  
          {  
            table = convto;  
            return sizeof(convto)/sizeof(LONG);   
          }  
            
          virtual GvError ConvertToGv(LONG type,const CustomDataType *src,void *dst,LONG cpu_id)  
          {  
            const SplinePos* s = static_cast<const SplinePos*>(src);  
            if (!s) return GV_CALC_ERR_NOT_VALID;
        
        
        
        
            switch (type)  
            {  
            case ID_GV_VALUE_TYPE_REAL:   
              {  
                ((Real* ) dst)[cpu_id] = s->m_value;  
              } return GV_CALC_ERR_NONE;  
            }
        
        
        
        
            return SUPER::ConvertToGv(type,src,dst,cpu_id);  
          }
        
        
        
        
        };
        
        
        
        
        static LONG restypetable[] = { MSA_SPLINEPOS_DATATYPE_ID };
        
        
        
        
        class MSASplinePosDialog : public iCustomGui  
        {  
        INSTANCEOF(MSASplinePosDialog, iCustomGui)  
        private:  
          SplinePos m_pos;  
          Bool m_tristate;
        
        
        
        
        public:  
          MSASplinePosDialog(const BaseContainer &settings, CUSTOMGUIPLUGIN *plugin)   
            : iCustomGui(settings, plugin), m_tristate(false), m_Settings(settings) { }
        
        
        
        
          virtual Bool CreateLayout (void)  
          {  
            return LoadDialogResource(MSA_SPLINEPOS_DIALOG, NULL, 0);  
          }  
            
          virtual Bool InitValues()  
          {  
            switch(m_pos.m_unit)  
            {  
            case UNIT_METER:  
              SetReal(MSA_SPLINEPOS, m_pos.m_value, MINREAL, MAXREAL, 1.0, FORMAT_METER, 0.0, 0.0, FALSE, m_tristate); break;  
            case UNIT_PERCENT:  
              SetReal(MSA_SPLINEPOS, m_pos.m_value, MINREAL, MAXREAL, 0.01, FORMAT_PERCENT, 0.0, 0.0, FALSE, m_tristate); break;  
            case UNIT_POINT:  
            default:  
              SetReal(MSA_SPLINEPOS, m_pos.m_value, MINREAL, MAXREAL, 1.0, FORMAT_REAL, 0.0, 0.0, FALSE, m_tristate); break;  
            }  
            SetLong(MSA_SPLINEPOS_UNIT, m_pos.m_unit);
        
        
        
        
            // We cannot look at the return value from SetReal()/SetLong() since it's broken in 8.503  
            return TRUE;  
          }
        
        
        
        
          virtual Bool Command(LONG id, const BaseContainer& msg)  
          {  
            switch (id)  
            {  
            case MSA_SPLINEPOS:  
            case MSA_SPLINEPOS_UNIT:  
              {  
                BaseContainer m(msg);  
                m.SetLong(BFM_ACTION_ID, GetId());  
                m.RemoveData(BFM_ACTION_VALUE);  
                m.SetData(BFM_ACTION_VALUE, GetData().GetValue());  
                SendParentMessage(m);  
                break;  
              }  
            }
        
        
        
        
            return TRUE;  
          }  
            
          virtual Bool SetData(const TriState<GeData> &tristate)  
          {  
            SplinePos* d = static_cast<SplinePos*>(   
              tristate.GetValue().GetCustomDataType(MSA_SPLINEPOS_DATATYPE_ID));
        
        
        
        
            if (!d) return FALSE;  
              
            m_pos = *d;  
            m_tristate = tristate.GetTri();
        
        
        
        
            return InitValues();  
          }  
            
          virtual TriState<GeData> GetData()  
          {  
            GetLong(MSA_SPLINEPOS_UNIT, m_pos.m_unit);  
            GetReal(MSA_SPLINEPOS, m_pos.m_value);  
              
            return GeData(m_pos);  
          }
        
        
        
        
          
        private:  
          BaseContainer m_Settings;  
        };
        
        
        
        
        class MSASplinePosGUI : public CustomGuiData  
        {  
        public:  
          virtual LONG GetId() { return MSA_SPLINEPOS_GUI_ID; }
        
        
        
        
          virtual CDialog* Alloc(const BaseContainer &settings)  
          {  
            MSASplinePosDialog* dlg = gNew MSASplinePosDialog(settings, GetPlugin());  
            if (!dlg) return NULL;  
              
            CDialog *cdlg = dlg->Get();  
            if (!cdlg) return NULL;  
              
            return cdlg;  
          }
        
        
        
        
          virtual void Free(CDialog *dlg, void *userdata)  
          {  
            if (!dlg || !userdata) return;  
            MSASplinePosDialog *sub = static_cast<MSASplinePosDialog*>(userdata);  
            gDelete(sub);  
          }
        
        
        
        
          virtual CHAR *GetResourceSym()  
          {  
            return "MSA_SPLINEPOS_GUI";  
          }
        
        
        
        
          virtual LONG GetResourceDataType(LONG *&table)   
          {   
            table = restypetable;   
            return sizeof(restypetable)/sizeof(LONG);   
          }  
        };
        
        
        
        
         
        
        
        
        
        Bool RegisterMSASplinePos()  
        {  
          static BaseCustomGuiLib mylib;  
          ClearMem(&mylib,sizeof(mylib));  
          FillBaseCustomGui(mylib);
        
        
        
        
          return InstallLibrary(MSA_SPLINEPOS_GUI_ID, &mylib, 1000, sizeof(mylib))  
              
                 &&  
                   
                 RegisterCustomDataTypePlugin("MSA SplinePos", 0*PLUGINFLAG_HIDE |   
                   CUSTOMDATATYPE_INFO_HASSUBDESCRIPTION |   
                   CUSTOMDATATYPE_INFO_NEEDDATAFORSUBDESC |  
                   CUSTOMDATATYPE_INFO_SUBDESCRIPTIONDISABLEGUI, gNew MSASplinePos, 0)
        
        
        
        
                 &&  
                    
                 RegisterCustomGuiPlugin("MSA SplinePos GUI", 0*PLUGINFLAG_HIDE, gNew MSASplinePosGUI);  
        }
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/04/2004 at 08:12, xxxxxxxx wrote:

    With the source code I'm going on, and my plugin nearly works now. Only one problem is left: The data connection between the data type and the gui. The gui receives data with Bool iGlyphListGui::SetData( const TriState<GeData>& tristate ). I tried to understand in in the example above, I even did compile it, but in the MSA occures the same problem that I have....tristate does not contain data. Before I tried it I thought, SetData receives a GeData, so maybe within my datatype I have to wrap my data into a GeData within ConvertToGeData....but this function is never called.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/04/2004 at 15:56, xxxxxxxx wrote:

    Sorry, I don't understand what the problem could be. The code was literaly pasted from the latest MSA version. What do you mean by "tristate does not contain data"? That tristate.GetValue().GetType()==DA_NIL? Or that tristate.GetValue().GetCustomDataType(YOUR_ID) returns NULL?
    For completeness, here's the left-out part of the code:

        
        
        struct SplinePos : public CustomDataType  
        {  
          SplinePos() : m_value(0.0), m_unit(-1) {}  
          SplinePos(Real value, LONG unit) : m_value(value), m_unit(unit) {}  
          SplinePos(const SplinePos& s) { *this = s; }
        
        
        
        
          Real m_value;  
          LONG m_unit;
        
        
        
        
            
          const SplinePos& operator = (const SplinePos& s)  
          {  
            if (s.m_unit != -1) m_unit = s.m_unit;  
            m_value = s.m_value;  
            return *this;  
          }
        
        
        
        
          operator GeData() const { return GeData(MSA_SPLINEPOS_DATATYPE_ID, *this); }
        
        
        
        
          String ToString() const  
          {  
            return   
              "[" +   
                RealToString(m_value * (m_unit == UNIT_PERCENT ? 100.0 : 1.0)) + " " +   
                (m_unit == UNIT_METER ? "m" : "") +   
                (m_unit == UNIT_PERCENT ? "pct" : "") +   
                (m_unit == UNIT_POINT ? "p" : "") +   
              "]";  
          }
        
        
        
        
          Bool operator<(const SplinePos& rhs) const  
          {  
            return m_unit != rhs.m_unit ? m_unit < rhs.m_unit :  
            m_value != rhs.m_value ? m_value < rhs.m_value : FALSE;  
          }
        
        
        
        
          Bool operator==(const SplinePos& rhs) const  
          {  
            return m_value == rhs.m_value &&   
                   m_unit == rhs.m_unit;  
          }          
        };
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/04/2004 at 23:50, xxxxxxxx wrote:

    Yes, in the MSA example the type is DA_NIL, and GetCustomDataType returns a NULL pointer. I even compiled the above code with it, the result is the same. In fact I dont understand the mechanism how it should work, to receive data, I should first somewhere have to define, what data is put into GeData, but I have no idea where!



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/04/2004 at 00:07, xxxxxxxx wrote:

    One main problem - in my own data class - surely is, that AllocData is never called...haves no idea why



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/04/2004 at 01:09, xxxxxxxx wrote:

    And even in the MSA example, AllocData is never called...this seems to be the reason why it doesn't work.
    I call the MSA examply by
     MSA_SPLINEPOS ID_TEST { }
    in my container....thats ok, isn't it?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/04/2004 at 02:22, xxxxxxxx wrote:

    Aaaah.....
    BaseContainer->InsData ! =)
    Now the AllocData is called....only my gui is now ignored :(



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/04/2004 at 02:33, xxxxxxxx wrote:

    Ok....also my gui is there :)
    And SetData seems to bew the better choice....
    So now I hope I can pass data to my gui...wow what a fight :) Surely the second customgui I will do will be much easier =)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/04/2004 at 04:06, xxxxxxxx wrote:

    Yeeeha!
    SetData
    Fill in Compare and CopyTo....et voila, data reaches SetData =)


Log in to reply