Skip to content

Commit

Permalink
typos. show same widget instance
Browse files Browse the repository at this point in the history
  • Loading branch information
IlgarLunin committed Mar 10, 2020
1 parent c96876f commit 6b0afae
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/constants.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef CONSTANTS_H
#define CONSTANTS_H

static const char* WORKSPACE_CONTROL_NAME = "RSMLControl";
static const char* WORKSPACE_CONTROL_NAME = "RSLMControl";
static const char* WIDGET_TITLE = "Rokoko Studio Live";
static const int INITIAL_WINDOW_WIDTH = 400;
static const int MINIMUM_WINDOW_WIDTH = 100;
Expand Down
38 changes: 22 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#pragma comment(lib,"OpenMayaAnim.lib")
#endif

QPointer<QScrollArea> rsmlScrollArea;
QPointer<RootWidget> rsmlWidget;
QPointer<QScrollArea> rslmScrollArea;
QPointer<RootWidget> rslmWidget;
QPointer<QWidget> workspaceControl;


Expand All @@ -36,27 +36,33 @@ class InvokeRSLM : MPxCommand {

MStatus result = MStatus::kSuccess;

if(!rsmlWidget.isNull()) {
if(!rslmWidget.isNull()) {
// do nothing if already visible
if(rsmlWidget->isVisible()) return MStatus::kFailure;
if(rslmWidget->isVisible())
{
std::cout << "Failed to open\n";
return MStatus::kFailure;
}
}


if(workspaceControl.isNull())
{
MString cmd;
char sizeArgs[128];
sprintf(sizeArgs, "-iw %d -mw %d -ih %d -mh %d", INITIAL_WINDOW_WIDTH, MINIMUM_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT, MINIMUM_WINDOW_HEIGHT);
cmd.format("workspaceControl -l \"^1s\" -fl true ^2s \"RSMLControl\";", WIDGET_TITLE, sizeArgs);
cmd.format("workspaceControl -l \"^1s\" -fl true ^2s \"RSLMControl\";", WIDGET_TITLE, sizeArgs);
MGlobal::executeCommand(cmd);

workspaceControl = MQtUtil::findControl(WORKSPACE_CONTROL_NAME);
rslmScrollArea = new QScrollArea(workspaceControl);
rslmWidget = new RootWidget(workspaceControl);
rslmScrollArea->setWidget(rslmWidget);
rslmScrollArea->setWidgetResizable(true);
MQtUtil::addWidgetToMayaLayout(rslmScrollArea, workspaceControl);
} else {
Utils::showWSControl();
}

workspaceControl = MQtUtil::findControl(WORKSPACE_CONTROL_NAME);
rsmlScrollArea = new QScrollArea(workspaceControl);
rsmlWidget = new RootWidget(workspaceControl);
rsmlScrollArea->setWidget(rsmlWidget);
rsmlScrollArea->setWidgetResizable(true);
MQtUtil::addWidgetToMayaLayout(rsmlScrollArea, workspaceControl);

return result;
}
Expand Down Expand Up @@ -92,12 +98,12 @@ MStatus uninitializePlugin(MObject obj)
Utils::removeMayaWSControl();
}

if(!rsmlWidget.isNull()) {
rsmlWidget.clear();
if(!rslmWidget.isNull()) {
rslmWidget.clear();
}

if(!rsmlScrollArea.isNull()) {
rsmlScrollArea.clear();
if(!rslmScrollArea.isNull()) {
rslmScrollArea.clear();
}

Utils::RSLMShutdown();
Expand Down
7 changes: 7 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ void Utils::fillFaceWeightsMap(const MFnBlendShapeDeformer &bsFn, QHash<QString,
}
}

void Utils::showWSControl()
{
// workspaceControl -e -vis true "RSLMControl";
QString cmd = QString("workspaceControl -e -vis true \"RSLMControl\"");
MGlobal::executeCommand(cmd.toStdString().c_str());
}

void Utils::removeMayaWSControl()
{
QString closeCmd = QString("if (`window -ex \"%1\"`); workspaceControl -e -close \"%1\";").arg(WORKSPACE_CONTROL_NAME);
Expand Down
1 change: 1 addition & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Utils {
static MVector rsToMaya(MVector);
static MQuaternion rsToMaya(MQuaternion);
static void fillFaceWeightsMap(const MFnBlendShapeDeformer &bsFn, QHash<QString, MPlug> &map);
static void showWSControl();
static void removeMayaWSControl();
static void RSLMInit();
static void RSLMShutdown();
Expand Down

0 comments on commit 6b0afae

Please sign in to comment.