forked from redpawfx/curveBrushTool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
brushContextCommand.cpp
executable file
·139 lines (123 loc) · 3.66 KB
/
brushContextCommand.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include "brushContextCommand.h"
#include "brushContext.h"
#include "brushToolCommand.h"
MPxContext *brushContextCommand::makeObj()
{
nBrushContext = new brushContext();
return nBrushContext;
}
void *brushContextCommand::creator()
{
return new brushContextCommand;
}
MStatus brushContextCommand::doEditFlags()
{
MStatus status = MS::kSuccess;
MArgParser argData = parser();
if (argData.isFlagSet(radiusFlag)) {
double userRadius;
status = argData.getFlagArgument(radiusFlag, 0, userRadius);
if (!status)
{
status.perror("radius flag parsing failed.");
return status;
}
nBrushContext->setRadius((float)userRadius);
}
if (argData.isFlagSet(lockBaseFlag)) {
bool nlockbase;
status = argData.getFlagArgument(lockBaseFlag, 0, nlockbase);
if (!status)
{
status.perror("lockBase flag parsing failed.");
return status;
}
nBrushContext->setLockBase(nlockbase);
}
if (argData.isFlagSet(resizeBrushFlag))
{
bool resize;
status=argData.getFlagArgument(resizeBrushFlag, 0,resize);
if (!status) {
status.perror("resizeBrush flag parsing failed");
return status;
}
nBrushContext->setInteractive(resize);
}
if (argData.isFlagSet(intensityFlag))
{
double inten;
status=argData.getFlagArgument(intensityFlag, 0,inten);
if (!status) {
status.perror("intensity flag parsing failed");
return status;
}
nBrushContext->setIntensity(inten);
}
if (argData.isFlagSet(brushModeFlag))
{
int brMode;
status=argData.getFlagArgument(brushModeFlag, 0,brMode);
if (!status) {
status.perror("brushMode flag parsing failed");
return status;
}
nBrushContext->setBrushMode(brMode);
}
return MS::kSuccess;
}
MStatus brushContextCommand::doQueryFlags()
{
MArgParser argData = parser();
if (argData.isFlagSet(radiusFlag))
{
setResult((float) nBrushContext->getRadius());
}
if (argData.isFlagSet(lockBaseFlag))
{
setResult(nBrushContext->getLockBase());
}
if (argData.isFlagSet(resizeBrushFlag))
{
setResult(nBrushContext->getInteractive());
}
if (argData.isFlagSet(intensityFlag))
{
setResult(nBrushContext->getIntensity());
}
if (argData.isFlagSet(brushModeFlag))
{
setResult(nBrushContext->getBrushMode());
}
return MS::kSuccess;
}
MStatus brushContextCommand::appendSyntax()
{
MSyntax mySyntax = syntax();
if (MS::kSuccess != mySyntax.addFlag(radiusFlag, radiusLongFlag,
MSyntax::kDouble))
{
return MS::kFailure;
}
if (MS::kSuccess != mySyntax.addFlag(lockBaseFlag, lockBaseLongFlag,
MSyntax::kBoolean))
{
return MS::kFailure;
}
if (MS::kSuccess != mySyntax.addFlag(resizeBrushFlag, resizeBrushLongFlag,
MSyntax::kBoolean))
{
return MS::kFailure;
}
if (MS::kSuccess != mySyntax.addFlag(intensityFlag, intensityLongFlag,
MSyntax::kDouble))
{
return MS::kFailure;
}
if (MS::kSuccess != mySyntax.addFlag(brushModeFlag, brushModeLongFlag,
MSyntax::kLong))
{
return MS::kFailure;
}
return MS::kSuccess;
}