-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathFabricSpliceEditorCmd.cpp
79 lines (66 loc) · 2.1 KB
/
FabricSpliceEditorCmd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "FabricSpliceEditorCmd.h"
#include "FabricSpliceKLSourceCodeWidget.h"
#include "FabricSpliceEditorWidget.h"
#include "plugin.h"
#include <FabricSplice.h>
#include <maya/MGlobal.h>
#include <maya/MArgParser.h>
#include <maya/MArgList.h>
void* FabricSpliceEditorCmd::creator(){
return new FabricSpliceEditorCmd;
}
MSyntax FabricSpliceEditorCmd::newSyntax()
{
MSyntax syntax;
syntax.addFlag("-a", "-action", MSyntax::kString);
syntax.addFlag("-o", "-operator", MSyntax::kString);
syntax.addFlag("-n", "-node", MSyntax::kString);
syntax.enableQuery(true);
syntax.enableEdit(true);
return syntax;
}
MStatus FabricSpliceEditorCmd::doIt(const MArgList &args){
MStatus status = MS::kSuccess;
mayaClearError();
MArgParser argData(syntax(), args, &status);
if(!argData.isFlagSet("action"))
{
mayaLogErrorFunc("Action (-a, -action) not provided by FabricSpliceEditor command.");
return mayaErrorOccured();
}
MString action = argData.flagArgumentString("action", 0);
if(action == "createIfNotOpen")
{
FabricSpliceEditorWidget::getFirstOrOpen(false);
}
else if(action == "setOperator")
{
if(!argData.isFlagSet("operator"))
{
mayaLogErrorFunc("Action 'setOperator' requires the operator (-o, -operator) flag to be provided by FabricSpliceEditor command.");
return mayaErrorOccured();
}
MString opName = argData.flagArgumentString("operator", 0);
FabricSpliceEditorWidget::setAllOperatorNames(opName.asChar(), false);
}
else if(action == "setNode")
{
if(!argData.isFlagSet("node"))
{
mayaLogErrorFunc("Action 'setNode' requires the node (-n, -node) flag to be provided by FabricSpliceEditor command.");
return mayaErrorOccured();
}
MString nodeName = argData.flagArgumentString("node", 0);
FabricSpliceEditorWidget::setAllNodeDropDowns(nodeName.asChar(), false);
}
else if(action == "update")
{
FabricSpliceEditorWidget::updateAll();
}
else
{
mayaLogErrorFunc("Action '" + action + "' not supported by FabricSpliceEditor command.");
return mayaErrorOccured();
}
return mayaErrorOccured();
}