2 #include "AL/maya/Common.h"
4 #include "maya/MString.h"
5 #include "maya/MPxCommand.h"
15 typedef MStringArray (*GenerateListFn)(
const MString& context);
25 AL_MAYA_DECLARE_COMMAND();
33 static int32_t
registerListFunc(GenerateListFn generateListFunc,
const MString& menuName);
36 bool isUndoable()
const override {
return false; }
37 MStatus doIt(
const MArgList& args)
override;
38 static std::vector<std::pair<MString, GenerateListFn>> m_funcs;
107 CommandGuiHelper(
const char* commandName,
const char* windowTitle,
const char* doitLabel,
const char* menuItemPath,
bool hasOptionBox =
true);
114 CommandGuiHelper(
const char* commandName,
const char* menuItemPath,
bool checkBoxValue =
false);
124 void addFlagOption(
const char* commandFlag,
const char* label,
bool defaultVal,
bool persist =
true);
131 void addBoolOption(
const char* commandFlag,
const char* label,
bool defaultVal,
bool persist =
true);
138 void addIntOption(
const char* commandFlag,
const char* label, int32_t defaultVal,
bool persist =
true);
147 void addIntSliderOption(
const char* commandFlag,
const char* label, int32_t minVal, int32_t maxVal, int32_t defaultVal,
bool persist =
true);
154 void addInt2Option(
const char* commandFlag,
const char* label,
const int32_t defaultVal[2],
bool persist =
true);
162 void addInt2Option(
const char* commandFlag,
const char* label,
const int32_t a,
const int32_t b,
bool persist =
true)
164 const int32_t temp[] = {a, b};
173 void addInt3Option(
const char* commandFlag,
const char* label,
const int32_t defaultVal[3],
bool persist =
true);
182 void addInt3Option(
const char* commandFlag,
const char* label,
const int32_t a,
const int32_t b,
const int32_t c,
bool persist =
true)
184 const int32_t temp[] = {a, b, c};
193 void addInt4Option(
const char* commandFlag,
const char* label,
const int32_t defaultVal[4],
bool persist =
true);
203 void addInt4Option(
const char* commandFlag,
const char* label,
const int32_t a,
const int32_t b,
const int32_t c,
const int32_t d,
bool persist =
true)
205 const int32_t temp[] = {a, b, c, d};
218 void addListOption(
const char* commandFlag,
const char* label, GenerateListFn generateList);
240 const char* commandFlag,
243 const char*
const enumNames[],
244 const int32_t enumValues[],
246 bool passAsString =
false);
269 const char* commandFlag,
272 const char*
const enumNames[],
273 const int32_t enumValues[],
275 bool passAsString =
false);
282 void addDoubleOption(
const char* commandFlag,
const char* label,
double defaultVal,
bool persist =
true);
291 void addDoubleSliderOption(
const char* commandFlag,
const char* label,
double minVal,
double maxVal,
double defaultVal,
bool persist =
true);
298 void addVec2Option(
const char* commandFlag,
const char* label,
const double defaultVal[2],
bool persist =
true);
306 void addVec2Option(
const char* commandFlag,
const char* label,
const double a,
const double b,
bool persist =
true)
308 const double temp[] = {a, b};
317 void addVec3Option(
const char* commandFlag,
const char* label,
const double defaultVal[3],
bool persist =
true);
326 void addVec3Option(
const char* commandFlag,
const char* label,
const double a,
const double b,
const double c,
bool persist =
true)
328 const double temp[] = {a, b, c};
337 void addVec4Option(
const char* commandFlag,
const char* label,
const double defaultVal[4],
bool persist =
true);
347 void addVec4Option(
const char* commandFlag,
const char* label,
const double a,
const double b,
const double c,
const double d,
bool persist =
true)
349 const double temp[] = {a, b, c, d};
358 void addColourOption(
const char* commandFlag,
const char* label,
const double defaultVal[3],
bool persist =
true);
367 void addColourOption(
const char* commandFlag,
const char* label,
const double a,
const double b,
const double c,
bool persist =
true)
369 const double temp[] = {a, b, c};
390 std::ostringstream m_global;
391 std::ostringstream m_init;
392 std::ostringstream m_save;
393 std::ostringstream m_load;
394 std::ostringstream m_reset;
395 std::ostringstream m_execute;
396 std::ostringstream m_labels;
397 std::ostringstream m_controls;
398 std::string m_commandName;
400 bool m_checkBoxCommand;
void addInt2Option(const char *commandFlag, const char *label, const int32_t a, const int32_t b, bool persist=true)
add a 2D integer option value to the GUI
Definition: CommandGuiHelper.h:162
void addInt2Option(const char *commandFlag, const char *label, const int32_t defaultVal[2], bool persist=true)
add a 2D integer option value to the GUI
void addListOption(const char *commandFlag, const char *label, GenerateListFn generateList)
adds a dynamic drop down list of items that will be displayed within an optionMenu control...
A method used by the generated command GUI code to retrieve a list of items from C++.
Definition: CommandGuiHelper.h:21
void addVec2Option(const char *commandFlag, const char *label, const double a, const double b, bool persist=true)
add a 2D vector option value to the GUI
Definition: CommandGuiHelper.h:306
a directory dialog, but displays files.
Definition: CommandGuiHelper.h:87
void addColourOption(const char *commandFlag, const char *label, const double defaultVal[3], bool persist=true)
add a colour option value to the GUI
void addColourOption(const char *commandFlag, const char *label, const double a, const double b, const double c, bool persist=true)
add a colour option value to the GUI
Definition: CommandGuiHelper.h:367
a directory dialog
Definition: CommandGuiHelper.h:88
void addVec2Option(const char *commandFlag, const char *label, const double defaultVal[2], bool persist=true)
add a 2D vector option value to the GUI
void addVec3Option(const char *commandFlag, const char *label, const double defaultVal[3], bool persist=true)
add a 3D vector option value to the GUI
void addInt4Option(const char *commandFlag, const char *label, const int32_t a, const int32_t b, const int32_t c, const int32_t d, bool persist=true)
add a 4D integer option value to the GUI
Definition: CommandGuiHelper.h:203
void addRadioButtonGroupOption(const char *commandFlag, const char *label, int defaultIndex, const char *const enumNames[], const int32_t enumValues[], bool persist=true, bool passAsString=false)
Similar to the enum option, but this time with radio buttons. THE MAXIMUM NUMBER OF OPTIONS IS 4...
void addBoolOption(const char *commandFlag, const char *label, bool defaultVal, bool persist=true)
add a boolean option value to the GUI
This class isn't really a wrapper around command options as such, it's mainly just a helper to auto g...
Definition: CommandGuiHelper.h:78
void addIntOption(const char *commandFlag, const char *label, int32_t defaultVal, bool persist=true)
add an integer option value to the GUI
a save file dialog
Definition: CommandGuiHelper.h:85
static int32_t registerListFunc(GenerateListFn generateListFunc, const MString &menuName)
Internal method. Registers a custom list function with this command so that MEL can request a custom ...
void addDoubleOption(const char *commandFlag, const char *label, double defaultVal, bool persist=true)
add a double precision option value to the GUI
void addVec3Option(const char *commandFlag, const char *label, const double a, const double b, const double c, bool persist=true)
add a 3D vector option value to the GUI
Definition: CommandGuiHelper.h:326
StringPolicy
determines if a text string argument is optional (e.g. a name of the object if specified, but falls back to a default if not), or whether it must exist (e.g. for a file to open)
Definition: CommandGuiHelper.h:94
void addInt4Option(const char *commandFlag, const char *label, const int32_t defaultVal[4], bool persist=true)
add a 4D integer option value to the GUI
if the string is empty, it is an error.
Definition: CommandGuiHelper.h:97
void addFlagOption(const char *commandFlag, const char *label, bool defaultVal, bool persist=true)
add a boolean option value to the GUI
~CommandGuiHelper()
dtor - auto generates, and executes the GUI code.
a load file dialog
Definition: CommandGuiHelper.h:86
void addVec4Option(const char *commandFlag, const char *label, const double defaultVal[4], bool persist=true)
add a 4D vector option value to the GUI
void addIntSliderOption(const char *commandFlag, const char *label, int32_t minVal, int32_t maxVal, int32_t defaultVal, bool persist=true)
add an integer option value to the GUI (with min/max, displayed as a slider)
FileMode
Used to describe the type of file dialog that should be used for a file path attribute.
Definition: CommandGuiHelper.h:83
void addStringOption(const char *commandFlag, const char *label, MString defaultVal, bool persist=true, StringPolicy policy=kStringOptional)
add a string option value to the GUI
multiple input files
Definition: CommandGuiHelper.h:89
void addVec4Option(const char *commandFlag, const char *label, const double a, const double b, const double c, const double d, bool persist=true)
add a 4D vector option value to the GUI
Definition: CommandGuiHelper.h:347
void addDoubleSliderOption(const char *commandFlag, const char *label, double minVal, double maxVal, double defaultVal, bool persist=true)
add a double precision option value to the GUI (with min/max, displayed as a slider) ...
CommandGuiHelper(const char *commandName, const char *windowTitle, const char *doitLabel, const char *menuItemPath, bool hasOptionBox=true)
ctor
void addEnumOption(const char *commandFlag, const char *label, int defaultIndex, const char *const enumNames[], const int32_t enumValues[], bool persist=true, bool passAsString=false)
add an enum option value to the GUI
void addInt3Option(const char *commandFlag, const char *label, const int32_t defaultVal[3], bool persist=true)
add a 3D integer option value to the GUI
if the string value is empty, the flag will be omitted.
Definition: CommandGuiHelper.h:96
void addInt3Option(const char *commandFlag, const char *label, const int32_t a, const int32_t b, const int32_t c, bool persist=true)
add a 3D integer option value to the GUI
Definition: CommandGuiHelper.h:182
void addFilePathOption(const char *commandFlag, const char *label, FileMode fileMode, const char *filter="All files (*) (*)", StringPolicy policy=kStringOptional)
add a file path option value to the GUI