custom layer select cycle



  • On 04/10/2015 at 01:44, xxxxxxxx wrote:

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

    ---------
    Hi,

    in my Plugin i need to have a select cycle that contains all layers in the scene, just like Cinema's right click in OM -> 'add to layer' select. I can dynamically add each layer to my cycle in GetDDescription, but whats missing is the color of the layer.

    I already have the list of layers from the documents layerRoot, but i cant figure out how to add the color icons to my select cycle..

    here's the relevant code:

    // get list of all layers currently in the document
    		vector<LayerObject*> layerList;
    		getLayerList(doc->GetLayerObjectRoot(),layerList);
      
    		// get cycle-container from description that we want to add the layers to
    		BaseContainer*    bc = description->GetParameterI(CLONE_LAYER, NULL);
    		if(bc==NULL) return;
    		bc->SetParameter(DESC_NAME, GeData("Layer"));
    		BaseContainer cycleNames, cycleIcons;
      
    		// add static select options 'none' and 'new'
    		cycleNames.SetParameter(0L, GeData("none"));
    		cycleIcons.SetParameter(0L, GeData(Ocube));		// test-icon-id
    		cycleNames.SetParameter(1L, GeData("new parent layer"));
    		cycleIcons.SetParameter(1L, GeData(Osphere));	// test-icon-id
      
    		// add dynamic select option for each layer in the scene		
    		for(unsigned int i=0; i<layerList.size(); i++) {
    			    // set select option name
    			    cycleNames.SetParameter(2L + i,GeData(layerList[i]->GetName()));
      
    			    // set select option color
    			    // ..
    		}
      
    		// put cycle names and icons back into the description
    		bc->SetParameter(DESC_CYCLE, GeData(cycleNames));
    		bc->SetParameter(DESC_CYCLEICONS, GeData(cycleIcons));
    

    When you add a normal icon to the cycle,you just put in a GeData with the object id that references the icon you want to show, but how to display a color instead of an icon ?

    I tried putting in the bitmap of the corresponding layerIcon and also the color vector of the layer, but the GeData Constructor wont take that..

    Anybody know how to pull this off ?



  • On 06/10/2015 at 01:59, xxxxxxxx wrote:

    Hello,

    the DESC_CYCLEICONS container only includes the IDs of icons; the drop down menu only shows icons and not colors. So I think you have to create the needed color icons yourself to use them in your drop down menu.

    Best wishes,
    Sebastian



  • On 16/10/2015 at 09:44, xxxxxxxx wrote:

    Hello cineast,

    was your question answered?

    Best wishes,
    Sebastian



  • On 17/10/2015 at 00:42, xxxxxxxx wrote:

    Hello Sebastian,

    thank you for your answer!

    Does this mean i have to draw a icon myself for each color i want to use and then 'register' that in Cinema4D ?

    I need a color-icon for each layer in the scene so there are actually unlimited possibilities ;-)
    I think there must be some way to generate those icons dynamically, as was probably done for the built-in'add to layer' submenu.

    greets,
      Daniel



  • On 19/10/2015 at 09:20, xxxxxxxx wrote:

    Hello,

    The "Add to Layer" menu is a different kind of GUI element so it works differently and is implemented differently.

    You can use GetIcon() to fill an IconData object from the given LayerObject. But then you still have to register the icons because DESC_CYCLEICONS is expected to store Icon IDs.

    To store pointers etc. please do not use the standard library but Cinema's own classes like BaseArray.

    Best wishes,
    Sebastian


Log in to reply