-
首页
-
C4D R23.110 C++ SDK
ColorSwatchData 类参考
Library
»
ColorChooser 库
#include <lib_colorchooser.h>
详细描述
This class handles the Swatch Data stored globally, in a
BaseDocument
or a preset. It holds 2 kinds of groups:
-
A global color group that is shared between all
Cinema 4D
documents and has special methods to handle it.
-
Document-based color groups stored in a
Cinema 4D
document.
-
由于
-
R18
公共成员函数
|
Bool
|
Load
(
BaseDocument
*doc,
Bool
merge=false,
Bool
loadGlobalColors=false)
|
Bool
|
Save
(
BaseDocument
*doc,
Bool
saveGlobalColors=false)
|
Bool
|
LoadPreset
(const
String
&name,
Bool
merge=true)
|
Bool
|
LoadPreset
(const
SDKBrowserURL
&url,
Bool
merge=true)
|
Bool
|
SavePreset
(const
String
&name, const
String
&author=
String
(), const
String
&info=
String
(),
Bool
forceOverwrite=false)
|
Bool
|
SavePreset
(const
SDKBrowserURL
&url, const
String
&author=
String
(), const
String
&info=
String
(),
Bool
forceOverwrite=false)
|
Bool
|
Merge
(
ColorSwatchData
*data,
Bool
mergeGlobalColors=false)
|
Bool
|
CopyFrom
(
ColorSwatchData
*data)
|
Int
|
GetGroupCount
(
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
) const
|
ColorSwatchGroup
*
|
GetGroupAtIndex
(
Int
index,
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
)
|
Bool
|
SetGroupAtIndex
(
Int
index,
ColorSwatchGroup
*group,
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
)
|
ColorSwatchGroup
*
|
AddGroup
(
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
, const
String
&name=
String
(),
Bool
selected=false,
Int
insertAt=-1, const
ColorAlphaArray
&colors=
ColorAlphaArray
())
|
Bool
|
InsertGroup
(
ColorSwatchGroup
*group,
Int
insertAt=-1,
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
)
|
Bool
|
RemoveGroup
(
Int
index,
SWATCH_CATEGORY
category=
SWATCH_CATEGORY::DOCUMENT
)
|
Bool
|
RemoveSelectedItems
()
|
void
|
重置
()
|
构造函数 & 析构函数文档编制
◆
ColorSwatchData()
◆
~ColorSwatchData()
成员函数文档编制
◆
Alloc()
Allocates a swatch data. Destroy the allocated swatch data with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in]
|
doc
|
Optional document to load swatches from.
|
[in]
|
global
|
若
true
the Global Swatch Group will be loaded.
|
-
返回
-
The allocated swatch data, or
nullptr
if the allocation failed.
◆
Free()
Destructs swatch data allocated with
Alloc()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in]
|
p
|
The swatch data to destruct. If the pointer is
nullptr
nothing happens. The pointer is assigned
nullptr
afterwards.
|
◆
Load()
Loads color groups from the given document and/or global colors.
-
参数
-
[in]
|
doc
|
The given document. Can be nullptr if only global colors must be loaded.
|
[in]
|
merge
|
若
true
the colors are merged with the stored colors. Otherwise the
|
[in]
|
loadGlobalColors
|
若
true
the global colors are loaded.existing colors are discarded.
|
-
返回
-
true
if success, otherwise
false
.
◆
Save()
Saves the color groups to the given document and/or the global colors.
-
参数
-
[in]
|
doc
|
The document to store the color groups. Can be nullptr if only global colors must be saved.
|
[in]
|
saveGlobalColors
|
若
true
the global colors are saved.
|
-
返回
-
true
if success, otherwise
false
.
◆
LoadPreset()
[1/2]
Loads the document-based swatch groups of the first preset with given name found in the user's Color Swatch Preset directory, including subdirectories.
-
另请参阅
-
GetPresetDirectory()
-
参数
-
[in]
|
name
|
The preset name to load.
|
[in]
|
merge
|
Set to
true
to merge the preset data with current data, set to
false
to replace data.
|
-
返回
-
true
if success, otherwise
false
.
◆
LoadPreset()
[2/2]
Loads the document-based swatch groups of the given preset.
-
参数
-
[in]
|
url
|
The preset url.
|
[in]
|
merge
|
Set to
true
to merge the preset data with current data, set to
false
to replace data.
|
-
返回
-
true
if success, otherwise
false
.
◆
SavePreset()
[1/2]
Saves the document-based groups as a Color Swatch preset.
-
参数
-
[in]
|
name
|
The preset name.
|
[in]
|
author
|
The preset author.
|
[in]
|
info
|
Preset additional info.
|
[in]
|
forceOverwrite
|
Set to
true
to force overwriting the preset in case it already exists.
|
-
返回
-
true
if data was saved, otherwise
false
.
◆
SavePreset()
[2/2]
Saves the document-based groups as a Color Swatch preset.
-
参数
-
[in]
|
url
|
The url to save preset to. Must include the preset name and must point to an existing library. Example:
SDKBrowserURL presetToSaveURL = ColorSwatchData::GetPresetDirectory() + "MyPreset"
|
[in]
|
author
|
The preset author.
|
[in]
|
info
|
Preset additional info.
|
[in]
|
forceOverwrite
|
Set to
true
to force overwrite the preset in case it already exists.
|
-
返回
-
true
if data was saved, otherwise
false
.
◆
PresetExists()
Checks if any preset with given name exists at user's Color Swatch Preset directory, including subdirectories.
-
参数
-
[in]
|
name
|
The preset name.
|
[in]
|
urls
|
Optionally set here a pointer to an array that will be filled with all urls pointing to a Color Swatch preset with the given name.
|
-
返回
-
true
if any preset with the given name found, otherwise
false
.
◆
ValidPreset()
Checks if the given URL points to a valid Color Swatch preset.
-
参数
-
[in]
|
url
|
The url to check.
|
-
返回
-
true
if the URL points to a valid Color Swatch preset, otherwise
false
.
◆
GetPresetDirectory()
Gets the user's default Color Swatch Preset directory.
-
返回
-
The preset directory.
◆
Merge()
Merges groups from
data
.
-
参数
-
[in]
|
data
|
The data to merge groups from.
|
[in]
|
mergeGlobalColors
|
若
true
the global colors will be merged inside the global group.
|
-
返回
-
true
if successful, otherwise
false
.
◆
CopyFrom()
Copies color swatch data.
-
参数
-
[in]
|
data
|
Swatch data to copy from.
|
-
返回
-
true
if successful, otherwise
false
.
◆
GetGroupCount()
Returns the number of groups stored in
category
.
-
参数
-
[in]
|
category
|
The group category.
|
-
返回
-
The number of color groups.
◆
GetGroupAtIndex()
Returns the document-based group at the given
index
.
-
参数
-
[in]
|
index
|
The
index
of the color group. Must be 0 <=
index
<
GetGroupCount()
.
|
[in]
|
category
|
The group category.
|
-
返回
-
The Swatch group or
nullptr
. Swatch data owns the pointed object.
◆
SetGroupAtIndex()
Replaces the group at given
index
.
-
参数
-
[in]
|
index
|
The index of the color group. Must be 0 <=
index
<
GetGroupCount()
.
|
[in]
|
group
|
The group to copy from.
|
[in]
|
category
|
The group category.
|
-
返回
-
true
if successful, otherwise
false
.
◆
AddGroup()
Adds a new document-based group.
-
参数
-
[in]
|
category
|
The category where the group will be inserted.
|
[in]
|
name
|
The name of the new group. If empty the default string "Untitled" will be used.
|
[in]
|
selected
|
The initial selection state of the new group.
|
[in]
|
insertAt
|
The index of the new group (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list.
|
[in]
|
colors
|
Colors to fill the group with.
|
-
返回
-
The new Swatch Group or
nullptr
. The Swatch Data owns the pointed Swatch Group.
◆
InsertGroup()
Adds a group.
-
参数
-
[in]
|
group
|
The group to copy from.
|
[in]
|
insertAt
|
The index of the new group (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list.
|
[in]
|
category
|
The group category.
|
-
返回
-
true
if successful, otherwise
false
.
◆
RemoveGroup()
Removes the group from
category
at the given
index
.
-
参数
-
[in]
|
index
|
The index of the color group. Must be 0 <=
index
<
GetGroupCount()
.
|
[in]
|
category
|
The group category.
|
-
返回
-
true
if the group was successfully removed, otherwise
false
.
◆
RemoveSelectedItems()
Bool
RemoveSelectedItems
|
(
|
|
)
|
|
Removes all selected groups and colors, including selected global colors.
-
返回
-
true
if any item was successfully removed, otherwise
false
.
◆
Reset()
Removes all groups and colors, including globals.
Member Data Documentation
◆
browserPresetType
const
Int32
browserPresetType
static
|
|
Color Swatch Browser Preset ID.
-
另请参阅
-
SDKBrowserPluginInterface::GetPluginID()