// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #include #include #include #include #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; }