3DCoat Core API
The 3DCoat API documentation.
|
BaseClass used for serialization and UI forms designing without direct UI programming.
You should derive your class from BaseClass. Very typical example of usage:
You may separate registration and class definition:
Class may be used for UI elements registration and for serialization, see BaseClass::Save, BaseClass::Load
In this case you may defile UI and serialization sections separately
You may register members conditionally using usual if... else ... commands.
You may use different prefixes to modify registered members. See REG_OPT, INVISIBLE, NOSAVE, RENAME, ets commands.
Use BaseClass::Load, BaseClass::Save, BaseClass::SaveBin, BaseClass::LoadBin to serialize.
Use BaseClass::FullCopy to copy BaseClass derived classes.
Use BaseClass::GetElement, BaseClass::FindElement to get access to class members list.
use BaseClass::reset_class to clear registered fields.
FUNCTION_CALL(...) - register function call as button.
ICON_BUTTON/3/4(...) - add icon button.
REG_AUTO(variable) - register almost any field by default. Use REG_AUTO(variable, "new_name") to rename variable.
SLIDER(variable, ...) - int or float variable as slider in UI.
REG_TEXTURE(tex) - register integer variable as texture selection control.
FILEPATH(str) - register cStr as control to choose file path.
REG_DROPLIST(fieldID, name, EnumID) - register droplist.
MAKE_ENUMERATOR(ID,List) - create Enumerator.
BCPrintf(...) - printf - like syntax to make own dynamic custom name for the field.
See also REG_RCT(...), REG_VECTOR2D(...), REG_VECTOR3D(...), REG_VECTOR4D(...), REG_MATRIX3D(...), REG_MATRIX4D(...).
_MAKE_ONCE {...} - make some action within brackets once
UI_LAYOUT(...) - define columns.
You may use ...MODIFIERS... REG_AUTO(...) or ...MODIFIERS... FUNCTION_CALL(...) to modify how registration works.
Commans | Description |
---|---|
INVISIBLE() | An element which invisible in UI, but use in serialization. |
READONLY() | An unediting element. |
NOSAVE() | An element which visible in UI, but not use in serialization. |
NORESET() | Element will not be initialised during reset_class |
NONAME() | ID of the element is invisible in UI |
RENAME(new_name) | assign other ID in UI for the control |
ICON(path_to_file) | Insert icon if control supports. If icon is in material.io/icons/black/ then just write the icon name without extension. |
CHK_GROUP(g) | specify group for checkbox. |
APPLYSCALE() | apply scene scale to this control |
SKIPHINT() | suppress hint for this element |
DEFHOTKEY(combination) | assign default hotkey to the UI element, like HOTKEY("CTRL E") |
LEFTALIGN() | force left-align to the control |
Examples:
You may pass new field name using
RENAME(new_name_there) REG_AUTO(field)
or
REG_AUTO(field, new_name_there)
new_name_there may contain special characters that modify how it is shown/handled in UI. There is the list of modificators -
Value | Description |
---|---|
{0xHEXADECMAIL_VALUE} | set background color. |
{fc0xHEXADECMAIL_VALUE} | set font color. |
[scale=floating_value] | set additional scale for the field. |
`intger_value | checkbox group identifier. |
% | apply scene scale to this control. |
{hotkey hotkey_id} | The hotkey will be assigned as default hotkey to the button. Like {hotkey CTRL ALT SHIFT A} |
# | don't show hint. |
~ | The function is inaccessible in demo mode. |
* | mandatory left align. |
$ | don't show field name in UI. |
! | hide field, read only. |
^ | read only field. |
{icon filename_path} | show icon. If icon is in material.io/icons/black/ then just write the icon name without extension. |
Class members are actually not stored anywhere. The virtual function
BaseClass::CountObjects
used to get dynamic information about the class. But usually you should never call or create it directly. This function is automatically created using SERIALISE() {...} section. You may need to override this function only if you make own container for objects (like ClassArray or ClassPtr).
Usual way to walk through all members of the class looks like:
You may also get element-wise access, but it is a bit slower, use it only if you don't need to walk through all memebers.
Remember that
The good examples of containers are ClassArray, ClassPtr and StringsList
The key point is that you should override functions
Previously SAVE_SECTION(mask) and GetClassMask() was extensively used to mask fields. It still works, but should be replaced with realtime checks using if...else... as soon as possible.