3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
coat::ui Class Reference

operate over the Coat's ui More...

#include <CoreAPI.h>

Static Public Member Functions

static bool cmd (const char *id, std::function< void()> process_in_modal_dialog=0)
 execute some action in UI as if you pressed on some control
 
static bool cmd (const char *id, pybind11::object fn=pybind11::none())
 execute some action in UI as if you pressed on some control
 
static bool wait (const char *id, float max_seconds)
 wait till the element id will appear in the UI. The element will not be clicked. The max wait time is max_seconds.
 
static bool presentInUI (const char *id)
 Check if the elemnt present in the UI.
 
static void highlight (const char *id, float milliseconds)
 highlight the UI element for a while
 
static void enablePenChannel (int i, bool enabled)
 enable or disable the pen channel
 
static bool isEnabledPenChannel (int i)
 check if the pen channel is enabled
 
static bool setSliderValue (const char *id, float value)
 Set the value for the the slider (if exists in UI)
 
static float getSliderValue (const char *id)
 get the value of the slider
 
static bool setEditBoxValue (const char *id, const char *value)
 set the edit box value
 
static bool setEditBoxValue (const char *id, int value)
 set the edit box value
 
static bool setEditBoxValue (const char *id, float value)
 set the edit box value
 
static bool getEditBoxValue (const char *id, str &result)
 get the edit box value
 
static const char * getEditBoxValue (const char *id)
 
static void apply ()
 pess ENTER, acts as Apply usually
 
static void setFileForFileDialog (const char *filename)
 Set the file for the next file dialog that will be triggered by user. If you will use coat::ui:cmd(...) to trigger some command that shows the file dialog this command allows to substitute the filename for that dialog instead of showing the dialog. This acts only for ONE next dialog.
 
static bool getBoolField (const char *id)
 Get the bool field from the checkbox in UI.
 
static bool setBoolValue (const char *id, bool value)
 Set the value for the checkbox in UI.
 
static const char * currentRoom ()
 get the current room name
 
static bool isInRoom (const char *name)
 check if we are in the specified room
 
static void toRoom (const char *name, bool Force=false)
 switch to the room
 
static int roomsCount ()
 returns the rooms count
 
static const char * roomName (int index)
 get the room name by index
 
static const char * roomID (int index)
 get the text identifier of the room
 
static void toolParam (BaseClass *B)
 show the class B as the part of the tools params panel
 
static void removeToolParam (BaseClass *B=nullptr)
 remove the class from the tools params
 
static const char * getOption (const char *id)
 get the option from preferences
 
static bool setOption (const char *id, const char *value)
 set the value to preferences
 
static bool setOption (const char *id, bool value)
 
static bool setOption (const char *id, float value)
 
static void hideDontShowAgainMessage (const char *id)
 Hides the "Don't show again dialog" for the current session (not forever)
 
static void showInfoMessage (const char *infoID, int milliseconds)
 Show the floating information message for the some time period.
 
static void insertInMenu (const char *Menu, const char *ID_in_menu, const char *script_path)
 Insert the scripted command into the main menu.
 
static void insertInToolset (const char *roomID, const char *section, const char *toolID, const char *script_path="")
 Insert the script-based tool into the toolset.
 
static void removeCommandFromMenu (const char *ID_in_menu)
 remove the command from the menu
 
static bool checkIfMenuItemInserted (const char *ID_in_menu)
 Check if the command inserted somewhere into the menu.
 
static void addExtension (const char *roomID, const char *section, pybind11::object &obj)
 Add the extension (new tool) into the room. Look the GeneratorExample.py.
 
static bool checkIfExtensionPresent (const char *extension_ID)
 Check if extension named as extension_ID is present in the 3DCoat.
 
static void addTranslation (const char *id, const char *text)
 Add the translation for the text identifier.
 
static const std::string getIdTranslation (const char *id)
 Get the translation for the text identifier.
 
static const std::string getCurrentLanguage ()
 Get the current language file name (without the XML extension)
 
static void switchToLanguage (const char *language)
 Switch the layout to the language.
 
static float scale ()
 returns the scale in comparison to the smallest UI theme
 
static std::string inputString (const char *text, int min_length=0)
 input text under the mouse position
 
static void nomodalInput (str *text, std::function< void()> on_change=nullptr)
 
static bool nomodalInputActive ()
 
static int inputInt (int initial_value)
 input the integer value under the mouse position
 
static float inputFloat (float initial_value)
 inputh the float value under the mouse position
 

Detailed Description

operate over the Coat's ui

Member Function Documentation

◆ addExtension()

static void coat::ui::addExtension ( const char * roomID,
const char * section,
pybind11::object & obj )
static

Add the extension (new tool) into the room. Look the GeneratorExample.py.

Parameters
roomIDroomID the room identifier, same as folders names in Documents/3DCoat/UserPrefs/Rooms/CustomRooms/
sectionsection the section name. This string may be empty to add beyond sections (anyway, at the end) or in any existing section. To get section name, pres RMB+MMB over the section name in the toolset. You will get something like "*Adjust" in the clipboard. The "Adjust" in this case is the section name.
objthe object that contains the extension. Look the GeneratorExample.py

◆ addTranslation()

static void coat::ui::addTranslation ( const char * id,
const char * text )
static

Add the translation for the text identifier.

Parameters
idthe identifier
textthe translation

◆ checkIfExtensionPresent()

static bool coat::ui::checkIfExtensionPresent ( const char * extension_ID)
static

Check if extension named as extension_ID is present in the 3DCoat.

Parameters
extension_IDthe identifier of the extension
Returns
True if the extension installed

◆ checkIfMenuItemInserted()

static bool coat::ui::checkIfMenuItemInserted ( const char * ID_in_menu)
static

Check if the command inserted somewhere into the menu.

Parameters
ID_in_menuthe ID of the command in the menu, look the list in C:/Users\andre\OneDrive\Documents\3DCoat/UserPrefs\Scripts\ExtraMenuItems\menu_sections.txt it is the english text or the identifier of the command
Returns
true if the command is inserted

◆ cmd() [1/2]

static bool coat::ui::cmd ( const char * id,
pybind11::object fn = pybind11::none() )
static

execute some action in UI as if you pressed on some control

The ID may be taken from the UI by clicking RMB+MMB, then the ID will appear in the clipboard (look Edit->Prferences->General->Script info type). If the element triggers modal dialog, the execution will be paused till the modal dialog will be closed, but the callback will be called each frame in modal dialog, so you will be able to control what happens in the modal dialog.

Parameters
idthe identifier taken from the UI
fnthe callback/lambda that will be called each frame till you are within the modal dialog. It looks like
def _callback():
cmd("#id_to_press")
...code...
static bool cmd(const char *id, std::function< void()> process_in_modal_dialog=0)
execute some action in UI as if you pressed on some control
Returns
True if the element found and the operation executed

◆ cmd() [2/2]

static bool coat::ui::cmd ( const char * id,
std::function< void()> process_in_modal_dialog = 0 )
static

execute some action in UI as if you pressed on some control

The ID may be taken from the UI by clicking RMB+MMB, then the ID will appear in the clipboard (look Edit->Prferences->General->Script info type). If the element triggers modal dialog, the execution will be paused till the modal dialog will be closed, but the callback will be called each frame in modal dialog, so you will be able to control what happens in the modal dialog.

Parameters
idthe identifier taken from the UI. It looks like "$SOMETHING_THERE". If you will call the cmd with ID = "$[page_]SOMETHING_THERE" then only current page UI elements will be searched. Other-vice, the item will be searched globally among the all UI elements.
process_in_modal_dialogthe callback/lambda that will be called each frame till you are within the modal dialog
Returns
true if the element found and the operation executed
Examples
TreesGenerator.cpp, and ui_command.cpp.

◆ currentRoom()

static const char * coat::ui::currentRoom ( )
static

get the current room name

Returns
the name

◆ enablePenChannel()

static void coat::ui::enablePenChannel ( int i,
bool enabled )
static

enable or disable the pen channel

Parameters
ithe channel: 0 - depth, 1 - color, 3 - gloss, 2 - currently unused
enabledtrue to enable

◆ getBoolField()

static bool coat::ui::getBoolField ( const char * id)
static

Get the bool field from the checkbox in UI.

Parameters
idthe element identifier
Returns
the checkbox value

◆ getCurrentLanguage()

static const std::string coat::ui::getCurrentLanguage ( )
static

Get the current language file name (without the XML extension)

Returns
the language file name (without the XML extension)

◆ getEditBoxValue()

static bool coat::ui::getEditBoxValue ( const char * id,
str & result )
static

get the edit box value

Parameters
idthe ID of the element
resultthe string the will get the result
Returns
true if the element exists

◆ getIdTranslation()

static const std::string coat::ui::getIdTranslation ( const char * id)
static

Get the translation for the text identifier.

Parameters
idthe text identifier
Returns
the translation or the id

◆ getOption()

static const char * coat::ui::getOption ( const char * id)
static

get the option from preferences

Parameters
idthe identifier of english text of the option
Returns
the value as string

◆ getSliderValue()

static float coat::ui::getSliderValue ( const char * id)
static

get the value of the slider

Parameters
idthe ID of the element
Returns
the value

◆ hideDontShowAgainMessage()

static void coat::ui::hideDontShowAgainMessage ( const char * id)
static

Hides the "Don't show again dialog" for the current session (not forever)

Parameters
idthe identifier, for example "AttachTextureHint", look the currently hidden list as files names in Docs/3DCoat/data/Temp/*.dontshow

◆ highlight()

static void coat::ui::highlight ( const char * id,
float milliseconds )
static

highlight the UI element for a while

Parameters
idthe ID of the element
millisecondsthe time to highlight, milliseconds

◆ inputFloat()

static float coat::ui::inputFloat ( float initial_value)
static

inputh the float value under the mouse position

Parameters
initial_valuethe initial float value
Returns
the changed value (if the user pressed OK) or the initial value other vice.

◆ inputInt()

static int coat::ui::inputInt ( int initial_value)
static

input the integer value under the mouse position

Parameters
initial_valuethe initial integer value
Returns
the changed value (if the user pressed OK) or the initial value other vice.

◆ inputString()

static std::string coat::ui::inputString ( const char * text,
int min_length = 0 )
static

input text under the mouse position

Parameters
textthe initial text value
min_lengththe minimal width of the input field, if zero passed the width taken from the parent control (if exists)
Returns
the changed text (if the user pressed OK) or the initial text other vice.

◆ insertInMenu()

static void coat::ui::insertInMenu ( const char * Menu,
const char * ID_in_menu,
const char * script_path )
static

Insert the scripted command into the main menu.

Parameters
MenuOne of main menu items, look the list in Documents/3DCoat/UserPrefs/Scripts/ExtraMenuItems/menu_sections.txt
ID_in_menuthe ID of the command in the menu, it is the english text or the identifier of the command
script_paththe full or relative path to the script file, if relative, it is relative to the 3DCoat root folder If it comes without path, it is assumed to be in same folder as the script that calls this function. If this parameter is empty, this script will be called.

◆ insertInToolset()

static void coat::ui::insertInToolset ( const char * roomID,
const char * section,
const char * toolID,
const char * script_path = "" )
static

Insert the script-based tool into the toolset.

Parameters
roomIDthe room identifier, same as folders names in Documents/3DCoat/UserPrefs/Rooms/CustomRooms/
sectionthe section name. This string may be empty to add beyond sections (anyway, at the end) or in any existing section. To get section name, pres RMB+MMB over the section name in the toolset. You will get something like "*Adjust" in the clipboard. The "Adjust" in this case is the section name.
toolIDthe tool identifier, how it will appear in UI. You may provide the text for the identifier using the addTranslation(...) Also, if there is image in the data/Textures/icons64/ named as toolID.png, it will be used as the icon for the tool.
script_paththe full or relative path to the script file, if relative, it is relative to the 3DCoat root folder If it comes without path, it is assumed to be in same folder as the script that calls this function. If this parameter is empty, this script will be called.

◆ isEnabledPenChannel()

static bool coat::ui::isEnabledPenChannel ( int i)
static

check if the pen channel is enabled

Parameters
ithe cannel: 0 - depth, 1 - color, 3 - gloss, 2 - currently unused
Returns
true if the channel is enabled

◆ isInRoom()

static bool coat::ui::isInRoom ( const char * name)
static

check if we are in the specified room

Parameters
namethe room name to check
Returns
true if we are in that room

◆ presentInUI()

static bool coat::ui::presentInUI ( const char * id)
static

Check if the elemnt present in the UI.

Parameters
idthe identifier
Returns
true if the element is present

◆ removeCommandFromMenu()

static void coat::ui::removeCommandFromMenu ( const char * ID_in_menu)
static

remove the command from the menu

Parameters
ID_in_menuthe ID of the command in the menu, it is the english text or the identifier of the command

◆ removeToolParam()

static void coat::ui::removeToolParam ( BaseClass * B = nullptr)
static

remove the class from the tools params

Parameters
Bthe class pointer

◆ roomID()

static const char * coat::ui::roomID ( int index)
static

get the text identifier of the room

Parameters
indexthe room index
Returns
"" if index outside the range or the room identifier if the index is valid

◆ roomName()

static const char * coat::ui::roomName ( int index)
static

get the room name by index

Parameters
indexthe room index
Returns
"" if index outside the range or the room name if the index is valid

◆ roomsCount()

static int coat::ui::roomsCount ( )
static

returns the rooms count

Returns
the number

◆ scale()

static float coat::ui::scale ( )
static

returns the scale in comparison to the smallest UI theme

Returns
the scale factor > 1

◆ setBoolValue()

static bool coat::ui::setBoolValue ( const char * id,
bool value )
static

Set the value for the checkbox in UI.

Parameters
idthe element identifier
valuethe value to set
Returns
true if successful and the element exists

◆ setEditBoxValue() [1/3]

static bool coat::ui::setEditBoxValue ( const char * id,
const char * value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists
Examples
ui_command.cpp.

◆ setEditBoxValue() [2/3]

static bool coat::ui::setEditBoxValue ( const char * id,
float value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists

◆ setEditBoxValue() [3/3]

static bool coat::ui::setEditBoxValue ( const char * id,
int value )
static

set the edit box value

Parameters
idthe ID of the element
valuethe value to set
Returns
true if the element exists

◆ setFileForFileDialog()

static void coat::ui::setFileForFileDialog ( const char * filename)
static

Set the file for the next file dialog that will be triggered by user. If you will use coat::ui:cmd(...) to trigger some command that shows the file dialog this command allows to substitute the filename for that dialog instead of showing the dialog. This acts only for ONE next dialog.

Parameters
filenamethe filename to substitute.

◆ setOption()

static bool coat::ui::setOption ( const char * id,
const char * value )
static

set the value to preferences

Parameters
idthe value identifier or english text
value
Returns

◆ setSliderValue()

static bool coat::ui::setSliderValue ( const char * id,
float value )
static

Set the value for the the slider (if exists in UI)

Parameters
idthe ID of the element
valuethe value to set
Returns
true if successful
Examples
ui_command.cpp.

◆ showInfoMessage()

static void coat::ui::showInfoMessage ( const char * infoID,
int milliseconds )
static

Show the floating information message for the some time period.

Parameters
infoIDthe message or message identifier (from language files)
millisecondshow ling to display the message

◆ switchToLanguage()

static void coat::ui::switchToLanguage ( const char * language)
static

Switch the layout to the language.

Parameters
languagethe language identifier, actually it is the file name (withot the XML extension) in the data/Languages/ folder

◆ toolParam()

static void coat::ui::toolParam ( BaseClass * B)
static

show the class B as the part of the tools params panel

Parameters
Bthe class pointer

◆ toRoom()

static void coat::ui::toRoom ( const char * name,
bool Force = false )
static

switch to the room

Parameters
namethe room name. Pay attention, you may pass the name or identifier, but name has bigger priory.
Forceset true to switch even if we are in the tool that corresponds to the destination room
Examples
BrickWall.cpp, HelloWorld3D.cpp, HoneyComb.cpp, OlympicRings.cpp, RollingPin.cpp, WindRose.cpp, bolt_binary.cpp, bolt_rim.cpp, boltheads.cpp, capsule.cpp, cup.cpp, ellipses.cpp, ffBlob.cpp, ffCube.cpp, ffCylinder.cpp, gear.cpp, meshes.cpp, meshes_surface_merge.cpp, metaballs.cpp, nut.cpp, screw.cpp, spheres.cpp, spiral.cpp, tube.cpp, ui_command.cpp, and washer.cpp.

◆ wait()

static bool coat::ui::wait ( const char * id,
float max_seconds )
static

wait till the element id will appear in the UI. The element will not be clicked. The max wait time is max_seconds.

Parameters
idThe ID we wait to appear
max_secondsthe max wait time (seconds)
Returns
true if the element appeared

The documentation for this class was generated from the following file: