/* ******************************************************************* * Function: BOOL :CreateIO(CKBehavior* behaviour, CKBehavior* script) * * Description : Check if all the Inputs,Outputs, pIns and pOuts of both behavior are matching * * Parameters : * behaviour Behavior 1, usually the BG wrapper BB. * script Behavior 2, usually the wrapped BG. * * Returns : BOOL * ******************************************************************* */ BOOL GBLCOBGWrapper::CreateIO(CKBehavior* behaviour, CKBehavior* script) { int iIO; int nbPin; // Input nbPin = script->GetInputCount(); for (iIO = 0; iIO < nbPin; iIO++) { CKBehaviorIO* pPin = script->GetInput(iIO); if (pPin == NULL) return FALSE; if (behaviour->AddInput(pPin->GetName()) != iIO) return FALSE; } // Output nbPin = script->GetOutputCount(); for (iIO = 0; iIO < nbPin; iIO++) { CKBehaviorIO* pPin = script->GetOutput(iIO); if (pPin == NULL) return FALSE; if (behaviour->AddOutput(pPin->GetName()) != iIO) return FALSE; } // Parameter In nbPin = script->GetInputParameterCount(); for (iIO = 0; iIO < nbPin; iIO++) { CKParameterIn* pPin = script->GetInputParameter(iIO); if (pPin == NULL) return FALSE; CKParameterIn* pPin2; if ((pPin2 = behaviour->CreateInputParameter(pPin->GetName(), (CKParameterType)pPin->GetType())) == NULL) return FALSE; } // Parameter Out nbPin = script->GetOutputParameterCount(); for (iIO = 0; iIO < nbPin; iIO++) { CKParameterOut* pPin = script->GetOutputParameter(iIO); if (pPin == NULL) return FALSE; if (behaviour->CreateOutputParameter(pPin->GetName(), (CKParameterType)pPin->GetType()) == NULL) return FALSE; } return TRUE; }
/* ******************************************************************* * Function: int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) * * Description : This function sets corresponding outputs with requested argument's * name, type and if the type of arguments is TGBLFCStringFromList, it also * provides designer specified list array with GetDesignerSpecifiedList output. * * Parameters : * behaviourContext r Behavior context reference, which gives * access to frequently used global objects * ( context, level, manager, etc... ) * * nextArgument r Required argument to have parameters provided by the command * * targetBB r Target GBLWaitForCommand building block * * Returns : int, The return value is 0 if no error occured or -1 on error * ******************************************************************* */ int CGBLBuildCommand::GetNextArgument (CKParameter* nextArgument,CKBehavior* targetBB, const CKBehaviorContext& behaviorContext) { CKBehavior* behavior = behaviorContext.Behavior; CKContext* context = behaviorContext.Context; XString typeName = context->GetParameterManager()->ParameterTypeToName(nextArgument->GetType()); XString argumentName = nextArgument->GetName(); if (typeName == "TGBLFCStringFromList") { int inputs = targetBB->GetInputParameterCount(); for (int i=0; i<inputs; i++) { CKParameterIn *parameterInput = targetBB->GetInputParameter(i); if ( argumentName == parameterInput->GetName() ) { CKParameterOut *parameterOutput = behavior->GetOutputParameter(EGBLBuildCommandParamOutputs::GetDesignerSpecifiedList); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterOutput->GetType()), FALSE); context->OutputToConsole(context->GetParameterManager()->ParameterTypeToName(parameterInput->GetType()), FALSE); parameterOutput->CopyValue (parameterInput->GetDirectSource()); break; } } } behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentType, typeName.Str(), strlen (typeName.Str()) + 1 ); behavior->SetOutputParameterValue (EGBLBuildCommandParamOutputs::GetArgumentName, argumentName.Str(), strlen (argumentName.Str()) + 1 ); behavior->ActivateOutput (EGBLBuildCommandBehOutputs::GetNextParameterValue); return 0; }
//************************************ // Method: vt_GetInVal // FullName: vt_GetInVal // Access: public static // Returns: PyObject * // Qualifier: // Parameter: PyObject * self // Parameter: PyObject * args //************************************ static PyObject *vt_GetInVal( PyObject * self, PyObject * args ) { int size = PyTuple_Size(args); int bid, index; PyArg_ParseTuple(args, "ii", &bid, &index); CK_ID cid = bid; CKBehavior *beh = static_cast<CKBehavior*>(pym->m_Context->GetObject(cid)); if (size!=2) { pym->m_Context->OutputToConsole("PyError : This function needs 2 arguments : \n\t bid,index"); Py_RETURN_NONE; } using namespace vtTools; using namespace vtTools::Enums; CKParameterManager *pam = static_cast<CKParameterManager *>(pym->m_Context->GetParameterManager()); if (index < beh->GetInputParameterCount() ) { CKParameterIn *ciIn = beh->GetInputParameter(index); CKParameterType pType = ciIn->GetType(); vtTools::Enums::SuperType sType = ParameterTools::GetVirtoolsSuperType(pym->m_Context,pam->ParameterTypeToGuid(pType)); PyObject *val; switch (sType) { case vtSTRING: { val = PyString_FromString( vtTools::BehaviorTools::GetInputParameterValue<CKSTRING>(beh,index )); break; } case vtFLOAT: { val = PyFloat_FromDouble(static_cast<float>(vtTools::BehaviorTools::GetInputParameterValue<float>(beh,index ))); break; } case vtINTEGER: { val = PyInt_FromLong( static_cast<long>(vtTools::BehaviorTools::GetInputParameterValue<int>(beh,index ))); break; } default : XString err("wrong input parameter type: "); err << ciIn->GetName() << "Only Types derivated from Interger,Float or String are acceptable"; pym->m_Context->OutputToConsole(err.Str(),FALSE ); Py_RETURN_NONE; } if (!val) { Py_DECREF(val); } return val; } Py_RETURN_NONE; }