#include <QtGui/QPixmap>
#include <QtCore/QString>
#include <QtWidgets/QWidget>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MQtUtil.h>
#include <maya/MString.h>
#include <saveSwatchesCmd.h>
const MString SaveSwatchesCmd::commandName(
"saveSwatches");
{
+ SaveSwatchesCmd::commandName
+ " renderNode [renderNode ...]"
);
return MS::kInvalidParameter;
}
"window -h 64 -w 64 swatchGrabber;"
"rowLayout -nc 1;"
"string $swatchPort = `swatchDisplayPort -w 64 -h 64 -rs 64`;"
"showWindow;"
"$swatchPort = $swatchPort;"
);
if (swatchPort) {
for (
unsigned int i = 0; i < args.
length(); ++i) {
MString(
"swatchDisplayPort -e -sn ") + renderNode +
" " + swatchPortName
);
QPixmap swatch = QPixmap::grabWidget(swatchPort);
QString fileName = renderNode.
asChar();
fileName += ".png";
swatch.save(fileName, "png", 100);
}
} else {
MString(
"Could not find swatchDisplayPort '") + swatchPortName +
"'"
);
return MS::kFailure;
}
return MS::kSuccess;
}
{
MFnPlugin pluginFn(plugin,
"Autodesk, Inc.",
"1.0",
"Any", &st);
if (!st) {
MString(
"saveSwatchesCmd - could not initialize plugin: ")
);
return st;
}
st = pluginFn.registerCommand(SaveSwatchesCmd::commandName, SaveSwatchesCmd::creator);
if (!st) {
MString(
"saveSwatchesCmd - could not register '")
+ SaveSwatchesCmd::commandName + "' command: "
);
return st;
}
return st;
}
{
MFnPlugin pluginFn(plugin,
"Autodesk, Inc.",
"1.0",
"Any", &st);
if (!st) {
MString(
"saveSwatchesCmd - could not uninitialize plugin: ")
);
return st;
}
st = pluginFn.deregisterCommand(SaveSwatchesCmd::commandName);
if (!st) {
MString(
"saveSwatchesCmd - could not deregister '")
+ SaveSwatchesCmd::commandName + "' command: "
);
return st;
}
return st;
}