About
A ColorSwatchData object can manage multiple color groups. These color groups can be loaded globally from Cinema 4D , a BaseDocument or a preset and saved back to these sources. Local color groups and global color groups are stored separately. The class is defined in the lib_colorchooser.h
header file.
if (colorSwatchData == nullptr )
freeData.
Assign (colorSwatchData);
for (
Int i = 0; i < groupCount; ++i)
{
if (group)
{
for (
Int c = 0; c < colorCount; ++c)
{
if (group->
GetColor (c, color, &selected) && selected)
{
if (mat == nullptr )
const Vector rgb { color.
r , color.
g , color.
b };
}
}
}
}
Allocation/Deallocation
ColorSwatchData instances are created with the usual tools:
Document Colors
Color groups can be stored in a BaseDocument :
if (!colorSwatchData->
Load (doc))
if (loadedDoc == nullptr )
colorSwatchData->
Load (loadedDoc,
true );
colorSwatchData->
Save (doc);
Presets
Color swatches can also be stored in the preset library:
To make work with presets easier these utility functions exist:
const String presetName(
"myColorPreset" );
{
url += presetName;
if (!colorSwatchData->
SavePreset (url,
"User" ,
"This is my preset" ))
}
Color Groups
The color swatches stored in a ColorSwatchData are stored in groups. These groups can either be stored with the document (SWATCH_CATEGORY::DOCUMENT ) or with Cinema 4D itself (SWATCH_CATEGORY::GLOBAL ).
for (
Int i = 0; i < groupCount; ++i)
{
if (group != nullptr )
{
}
}
Further utility functions are:
Further Reading
maxon::Int Int
Definition: ge_sys_math.h:49
Bool SavePreset(const String &name, const String &author=String(), const String &info=String(), Bool forceOverwrite=false)
Definition: lib_colorchooser.h:401
static void Free(ColorSwatchData *&p)
void Assign(TYPE *p)
Definition: ge_autoptr.h:221
Bool Load(BaseDocument *doc, Bool merge=false, Bool loadGlobalColors=false)
Definition: lib_browser.h:54
Manages file and path names.
Definition: c4d_file.h:81
return OK
Definition: apibase.h:2462
Definition: ge_autoptr.h:147
BaseDocument * LoadDocument(const Filename &name, SCENEFILTER loadflags, BaseThread *thread, maxon::String *errorString=nullptr)
Int GetColorCount() const
No check if file exists under case-sensitive drives.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:66
ColorSwatchGroup * GetGroupAtIndex(Int index, SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT)
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
Definition: mmaterial.h:56
Definition: c4d_string.h:36
A color consisting of three components R, G, B and an alpha.
Definition: col4.h:14
void InsertMaterial(BaseMaterial *mat, BaseMaterial *pred=nullptr, Bool checknames=false)
static String IntToString(Int32 v)
Definition: c4d_string.h:493
Bool Save(BaseDocument *doc, Bool saveGlobalColors=false)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
static Bool PresetExists(const String &name, maxon::BaseArray< SDKBrowserURL > *urls=nullptr)
Definition: c4d_basematerial.h:229
static Material * Alloc()
static ColorSwatchData * Alloc(BaseDocument *doc=nullptr, Bool global=false)
Definition: lib_colorchooser.h:213
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:209
static void Free(BaseDocument *&bl)
Int GetGroupCount(SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT) const
maxon::Bool Bool
Definition: ge_sys_math.h:40
ColorSwatchGroup * AddGroup(SWATCH_CATEGORY category=SWATCH_CATEGORY::DOCUMENT, const String &name=String(), Bool selected=false, Int insertAt=-1, const ColorAlphaArray &colors=ColorAlphaArray())
static SDKBrowserURL GetPresetDirectory()
Definition: c4d_basedocument.h:462
Bool GetColor(Int index, maxon::ColorA &color, Bool *selected=nullptr) const
Bool FileSelect(FILESELECTTYPE type, FILESELECT flags, const maxon::String &title, const maxon::String &force_suffix=maxon::String())