aboutsummaryrefslogtreecommitdiff
path: root/mayaPlug/shaveBrushCtxCmd.cpp
blob: fc3a92c3f3dc254edc3e76eaf9ba426e166e9866 (plain) (blame)
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
// Shave and a Haircut
// (c) 2019 Epic Games
// US Patent 6720962

#include <maya/MArgParser.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MSyntax.h>

#include "shaveBrushCtx.h"
#include "shaveBrushCtxCmd.h"
#include "shaveCursorCtxCmd.h"

const MString shaveBrushCtxCmd::commandName = "shaveBrushCtx";

static const char*	flMode				= "-mode";
static const char*	fsMode				= "-m";


shaveBrushCtxCmd::shaveBrushCtxCmd()
{}


shaveBrushCtxCmd::~shaveBrushCtxCmd()
{}


MStatus shaveBrushCtxCmd::appendSyntax()
{
	MSyntax	s = syntax();
	MStatus	st = shaveCursorCtxCmd::appendSyntax();

	if (st)
		s.addFlag(fsMode, flMode, MSyntax::kUnsigned);

	return st;
}


MStatus shaveBrushCtxCmd::doEditFlags()
{
	MStatus	st = shaveCursorCtxCmd::doEditFlags();

	if (st && mCtx)
	{
		MArgParser	args = parser();

		if (args.isFlagSet(fsMode))
		{
			unsigned	mode;
			args.getFlagArgument(fsMode, 0, mode);

			if (mode > kBrushClump)
			{
				MString	msg = "Invalid brush mode.  Cannot be greater than ";
				msg += (int)kBrushClump;
				MGlobal::displayError(msg);
				return MS::kInvalidParameter;
			}

			((shaveBrushCtx*)mCtx)->setBrushMode((BRUSH_MODE)mode);
		}
	}

	return st;
}


MStatus shaveBrushCtxCmd::doQueryFlags()
{
	MStatus	st = shaveCursorCtxCmd::doQueryFlags();

	if (st && mCtx)
	{
		MArgParser	args = parser();

		if (args.isFlagSet(fsMode))
			setResult((int)((shaveBrushCtx*)mCtx)->getBrushMode());
	}

	return st;
}


shaveCursorCtx* shaveBrushCtxCmd::createContext()
{
	return new shaveBrushCtx;
}