Hi,
Having some trouble understanding what's going on in following scenario.
For testing purposes I have provided following implementation of two CommandData
and one DescriptionToolData
derived plugins. All are just dummy plugins for demonstration purposes only.
Both CommandData
plugins do activate the DescriptionToolData
from their Execute
method. One does so by performing a CallCommand
, the other one by means of SetAction
.
- When you select the
CommandData
plugin which performs theSetAction
right after launching Cinema you then get the Brush tool's attributes in the Attribute Manager. - Restart Cinema and do the same with the one performing the
CallCommand
and you'll end up with the expected tool in the Attribute Manager.
If you now switch to another tool and then selects theSetAction
plugin you will also end up with the appropriate AM. - Restart Cinema, select a different tool (default scenes start with Move tool active, so select Live Selection), then select the
SetAction
plugin, and again the AM shows the expected tool.
So, why is it that when starting from a default launch (no actions performed yet) will show the Brush tool in the AM when performing a SetAction
?
Is something missing in the registration of the tool plugin, or in the resource, or implementation of the tool? An if so, why is the CallCommand
not affected by this?
I am including the description files only to show they're empty (for testing purposes).
#include "c4d.h"
#define TEST_COMMAND1_PLUGIN_ID 1000001
#define TEST_COMMAND2_PLUGIN_ID 1000002
#define TEST_DESCRIPTIONTOOL_PLUGIN_ID 1000003
// ====================================
// CommandDatas
// ====================================
// MyCommand1 - does perform a CallCommand to active the DescriptionTool
class MyCommand1 : public CommandData
{
INSTANCEOF(MyCommand1, CommandData)
public:
virtual Bool Execute(BaseDocument* doc, GeDialog* parentManager);
};
Bool MyCommand1::Execute(BaseDocument* doc, GeDialog* parentManager)
{
CallCommand(TEST_DESCRIPTIONTOOL_PLUGIN_ID);
return true;
}
// MyCommand2 - does perform a SetAction to active the DescriptionTool
class MyCommand2 : public CommandData
{
INSTANCEOF(MyCommand2, CommandData)
public:
virtual Bool Execute(BaseDocument* doc, GeDialog* parentManager);
};
Bool MyCommand2::Execute(BaseDocument* doc, GeDialog* parentManager)
{
doc->SetAction(TEST_DESCRIPTIONTOOL_PLUGIN_ID);
return true;
}
// ====================================
// DescriptionTool
// ====================================
class MyDescriptionTool : public DescriptionToolData
{
public:
virtual Int32 GetToolPluginId() { return TEST_DESCRIPTIONTOOL_PLUGIN_ID; }
virtual const String GetResourceSymbol() { return String("MyDescriptionTool_desc"_s); } // return the resource description filename (without extension)
virtual Bool InitTool(BaseDocument* doc, BaseContainer& data, BaseThread* bt);
virtual void FreeTool(BaseDocument* doc, BaseContainer& data);
virtual void InitDefaultSettings(BaseDocument* doc, BaseContainer& data);
virtual Int32 GetState(BaseDocument* doc);
virtual Bool GetCursorInfo(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, Float x, Float y, BaseContainer& bc);
virtual TOOLDRAW Draw(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, BaseDrawHelp* bh, BaseThread* bt, TOOLDRAWFLAGS flags);
};
Bool MyDescriptionTool::InitTool(BaseDocument* doc, BaseContainer& data, BaseThread* bt)
{
if (!DescriptionToolData::InitTool(doc, data, bt))
return false;
return true;
}
void MyDescriptionTool::FreeTool(BaseDocument* doc, BaseContainer& data)
{
DescriptionToolData::FreeTool(doc, data);
}
void MyDescriptionTool::InitDefaultSettings(BaseDocument* doc, BaseContainer& data)
{
DescriptionToolData::InitDefaultSettings(doc, data);
}
Int32 MyDescriptionTool::GetState(BaseDocument* doc)
{
return CMD_ENABLED;
}
Bool MyDescriptionTool::GetCursorInfo(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, Float x, Float y, BaseContainer& bc)
{
return true;
}
TOOLDRAW MyDescriptionTool::Draw(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, BaseDrawHelp* bh, BaseThread* bt, TOOLDRAWFLAGS flags)
{
return TOOLDRAW::HANDLES | TOOLDRAW::AXIS;
}
// ====================================
// Plugin Main
// ====================================
Bool PluginStart(void)
{
ApplicationOutput("Test"_s);
if (!RegisterCommandPlugin(TEST_COMMAND1_PLUGIN_ID, "CallCommand"_s, 0, AutoBitmap("Test.png"_s), "MyCommand1"_s, NewObjClear(MyCommand1)))
ApplicationOutput("Test - failed registering CommandData");
if (!RegisterCommandPlugin(TEST_COMMAND2_PLUGIN_ID, "SetAction"_s, 0, AutoBitmap("Test.png"_s), "MyCommand2"_s, NewObjClear(MyCommand2)))
ApplicationOutput("Test - failed registering CommandData");
if (!RegisterToolPlugin(TEST_DESCRIPTIONTOOL_PLUGIN_ID, "Test - MyDescriptionTool"_s, 0, AutoBitmap("Test.png"_s), "MyDescriptionTool"_s, NewObjClear(MyDescriptionTool)))
ApplicationOutput("Test - failed registering DescriptionTool");
return true;
}
void PluginEnd(void)
{
}
Bool PluginMessage(Int32 id, void * data)
{
switch (id) {
case C4DPL_INIT_SYS:
if (!g_resource.Init())
return false;
return true;
case C4DMSG_PRIORITY:
return true;
case C4DPL_BUILDMENU:
break;
case C4DPL_ENDACTIVITY:
return true;
}
return false;
}
res/description/MyDescriptionTool_desc.h
#ifndef MYDESCRIPTIONTOOL_DESC_H__
#define MYDESCRIPTIONTOOL_DESC_H__
#endif // MYDESCRIPTIONTOOL_DESC_H__
res/description/MyDescriptionTool_desc.res
CONTAINER MyDescriptionTool_desc
{
NAME MyDescriptionTool_desc;
}
res/strings_en-US/MyDescriptionTool_desc.str
STRINGTABLE MyDescriptionTool_desc
{
MyDescriptionTool_desc "MyDescriptionTool";
}