THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/03/2006 at 04:47, xxxxxxxx wrote:
Okay, here is my pathetic attempt so far. Note that AddPortIsOK() always returns false. Talk about 'being the mushroom'. I am blindly attempting blind attempts at blind code. Hmmm, could you pretty please provide several (dozen) examples in the next SDK release, please...
// IPPDial.ResolveMasterDials
// - Convert Channel MasterDialEntries into Active MasterDials (XPresso tags)
//*---------------------------------------------------------------------------*
Bool IPPDial::ResolveMasterDials(BaseDocument* doc, AtomArray* atomArray, BaseObject* ippBase, BaseTag* tag, BOOL doUndo)
//*---------------------------------------------------------------------------*
{
XPressoTag* xtag;
GvNodeMaster* nodeMaster;
GvNode* root;
// Driver
GvNode* snode;
GvPort* sport;
// RangeMapper
GvNode* rnode;
GvPort* riport;
GvPort* roport;
// Driven
GvNode* dnode;
GvPort* dport;
BaseObject* driver;
BaseTag* dial;
BaseContainer* bc = tag->GetDataInstance();
BaseContainer* nbc;
LONG sindex;
LONG dindex = bc->GetLong(IPPDIAL_INDEX);
ULONG flags;
LONG x = 8, y = 8;
String nodeName = ippBase->GetDataInstance()->GetString(IPP_INTERNALNAME)+"."+bc->GetString(IPPDIAL_DIALNAME);
for (MasterDialEntry* md = firstMaster; md != lastMaster; md++)
{
// Find Driver slider
driver = md->bodypart.GetObject(atomArray);
if (!(driver && driver->IsInstanceOf(ID_IPPBASE))) continue;
// - Get Dial and index
for (dial = driver->GetFirstTag(); dial; dial = dial->GetNext())
{
if (!(dial->IsInstanceOf(ID_IPPDIALTAG) || dial->IsInstanceOf(ID_IPPMORPHTAG))) continue;
bc = dial->GetDataInstance();
if (bc->GetString(IPPDIAL_DIALNAME) == md->dialName) break;
}
if (!dial) continue;
sindex = bc->GetLong(IPPDIAL_INDEX);
// Create an XPresso tag on the dial tag's ippBase
xtag = static_cast<XPressoTag*>(ippBase->GetTag(Texpresso));
if (!(xtag && (xtag->GetName() == "IPP Slaved")))
{
xtag = XPressoTag::Alloc();
if (!xtag) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.xtag");
ippBase->InsertTag(xtag);
xtag->SetName("IPP Slaved");
}
// Create, Link, and Configure nodes
nodeMaster = xtag->GetNodeMaster();
if (!nodeMaster) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.nodeMaster");
root = nodeMaster->GetRoot();
if (!root) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.root");
snode = nodeMaster->CreateNode(root, ID_OPERATOR_OBJECT, NULL, x, y);
if (!snode) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.snode");
rnode = nodeMaster->CreateNode(root, ID_OPERATOR_RANGEMAPPER, NULL, x+144, y);
if (!rnode) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.rnode");
dnode = nodeMaster->CreateNode(root, ID_OPERATOR_OBJECT, NULL, x+288, y);
if (!dnode) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.dnode");
nbc = snode->GetOpContainerInstance();
nbc->SetLink(GV_OBJECT_OBJECT_ID, driver);
nbc->SetLong(GV_OBJECT_PATH_TYPE, GV_OBJECT_PATH_TYPE_ABSOLUTE);
nbc = dnode->GetOpContainerInstance();
nbc->SetLink(GV_OBJECT_OBJECT_ID, ippBase);
nbc->SetLong(GV_OBJECT_PATH_TYPE, GV_OBJECT_PATH_TYPE_RELATIVE);
// - Add Ports
if (snode->AddPortIsOK(GV_PORT_OUTPUT, sindex)) sport = snode->AddPort(GV_PORT_OUTPUT, sindex);
else return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.sport");
if (dnode->AddPortIsOK(GV_PORT_INPUT, dindex)) dport = dnode->AddPort(GV_PORT_INPUT, dindex);
else return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.dport");
roport = rnode->GetOutPort(0);
if (!roport) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.roport");
riport = rnode->GetInPort(0);
if (!riport) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.riport");
/*
// - Connect Driver to RangeMapper
if (!nodeMaster->IsConnectionValid(snode, sport, rnode, riport, snode, sport, rnode, riport)) { GePrint("InvalidConnection 1"); return FALSE; }
if (!snode->AddConnection(snode, sport, rnode, riport)) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.AddConnection");
// - Connect RangeMapper to Driven
if (!nodeMaster->IsConnectionValid(rnode, roport, dnode, dport, rnode, roport, dnode, dport)) { GePrint("InvalidConnection 2"); return FALSE; }
if (!rnode->AddConnection(rnode, roport, dnode, dport)) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPDial.ResolveMasterDials.AddConnection");
*/
// Mark Driver as having Slaves
flags = (ULONG)bc->GetLong(IPPDIAL_TYPESUBFLAGS);
bc->SetLong(IPPDIAL_TYPESUBFLAGS, (LONG)(flags & DIAL_FLAGS_SLAVES));
y += 80;
}
EventAdd();
GeFree(firstMaster);
firstMaster = NULL;
return TRUE;
}