当前位置: 首页>>代码示例>>C++>>正文


C++ MCallbackIdArray::append方法代码示例

本文整理汇总了C++中MCallbackIdArray::append方法的典型用法代码示例。如果您正苦于以下问题:C++ MCallbackIdArray::append方法的具体用法?C++ MCallbackIdArray::append怎么用?C++ MCallbackIdArray::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MCallbackIdArray的用法示例。


在下文中一共展示了MCallbackIdArray::append方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addGenericCallback

MStatus dagMessageCmd::addGenericCallback(MDagPath *dagPath, 
										  MDagMessage::DagMessage msg, 
										  MString cbName)
{
	MStatus status = MS::kFailure;

	if (NULL == dagPath) {
		MCallbackId id = MDagMessage::addDagCallback(	msg,
														userDAGGenericCB, 
														NULL, 
														&status);
		if (MS::kSuccess == status) {
			MString info("Adding a callback for");
			info += cbName;
			info += "on all nodes";
			MGlobal::displayInfo(info);			
			callbackIds.append( id );
		} else {
			MString err("Could not add callback to");
			err += dagPath->fullPathName();
			MGlobal::displayError(err);
		}
	} else {
		MCallbackId id = MDagMessage::addDagCallback(*dagPath,
													msg,
													userDAGGenericCB, 
													NULL, 
													&status);
		if (MS::kSuccess == status) {
			MString info("Adding a callback for");
			info += cbName;
			info += "on ";
			info += dagPath->fullPathName();
			MGlobal::displayInfo(info);			
			callbackIds.append( id );
		} else {
			MString err("Could not add callback to");
			err += dagPath->fullPathName();
			MGlobal::displayError(err);
		}
	}

	return status;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:44,代码来源:dagMessageCmd.cpp

示例2: doIt

MStatus deletedMessage::doIt( const MArgList& args )
{
	MStatus status = MS::kSuccess;

	MArgDatabase argData(syntax(), args);
	MSelectionList objects;
	argData.getObjects(objects);

	for (unsigned int i = 0; i < objects.length(); i++) {
		MObject node;
		objects.getDependNode(i, node);
		
		callbackIds.append(
			MNodeMessage::addNodeAboutToDeleteCallback (node, aboutToDeleteCB, NULL, &status)
		);
		if (!status) {
			MGlobal::displayWarning("Could not attach about to delete callback for node.");
			continue;
		}
		callbackIds.append(
			MNodeMessage::addNodePreRemovalCallback (node, preRemovalCB, NULL, &status)
		);
		if (!status) {
			MGlobal::displayWarning("Could not attach pre-removal callback for node.");
			continue;
		}
		if (!nodeRemovedCBRegistered)
		{
			callbackIds.append(
				MDGMessage::addNodeRemovedCallback(removeCB, "dependNode", NULL, &status)
			);
			if (!status) {
				MGlobal::displayWarning("Could not attach node removal callback.");
				continue;
			}
			nodeRemovedCBRegistered = true;
		}
	}
	
	return status;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:41,代码来源:deletedMsgCmd.cpp

示例3: doIt

MStatus polyMessageCmd::doIt( const MArgList& )
//
// Takes the  nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
    MStatus 		stat;
    MObject 		node;
    MSelectionList 	list;
    MCallbackId     id;

    // Register node callbacks for all nodes on the active list.
    //
    MGlobal::getActiveSelectionList( list );

    for ( unsigned int i=0; i<list.length(); i++ )
    {
        list.getDependNode( i, node );

        MDagPath dp;
        MObject shapeNode = node;
        if ( MS::kSuccess == MDagPath::getAPathTo( node, dp ) )
            if ( MS::kSuccess == dp.extendToShape() )
                shapeNode = dp.node();

        bool wantIdChanges[3];
        wantIdChanges[MPolyMessage::kVertexIndex] = true;
        wantIdChanges[MPolyMessage::kEdgeIndex] = true;
        wantIdChanges[MPolyMessage::kFaceIndex] = true;

        id = MPolyMessage::addPolyComponentIdChangedCallback( shapeNode,
                wantIdChanges, 3,
                userCB,
                NULL,
                &stat);

        // If the callback was successfully added then add the
        // callback id to our callback table so it can be removed
        // when the plugin is unloaded.
        //
        if ( stat ) {
            callbackIds.append( id );
        } else {
            cout << "MPolyMessage.addCallback failed\n";
        }
    }

    return stat;
}
开发者ID:vasilenkomike,项目名称:xray,代码行数:49,代码来源:polyMessageCmd.cpp

示例4: doIt

MStatus nodeMessageCmd::doIt( const MArgList& )
//
// Takes the  nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
	MStatus 		stat;
	MObject 		node;
	MSelectionList 	list;
    MCallbackId     id;
    
	// Register node callbacks for all nodes on the active list.
	//
	MGlobal::getActiveSelectionList( list );

    for ( unsigned int i=0; i<list.length(); i++ )
    {
        list.getDependNode( i, node );
        
	    id = MNodeMessage::addAttributeChangedCallback( node,
                                                        userCB,
                                                        NULL,
                                                        &stat);

    	// If the callback was successfully added then add the
        // callback id to our callback table so it can be removed
        // when the plugin is unloaded.
	    //
	    if ( stat ) {
		    callbackIds.append( id );
    	} else {
	    	cout << "MNodeMessage.addCallback failed\n";
    	}
    }
        
	return stat;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:37,代码来源:nodeMessageCmd.cpp

示例5: doIt

MStatus dagMessageCmd::doIt( const MArgList& args)
//
// Takes the  nodes that are on the active selection list and adds an
// attriubte changed callback to each one.
//
{
	MStatus 		status;
	MSelectionList 	list;
    MArgDatabase argData(syntax(), args);

	status = argData.getObjects(list);
	if (MS::kSuccess != status) {
		MGlobal::displayError("Error getting objects");
		return status;
	}

	//	Get the flags
	//
	bool allDagUsed = argData.isFlagSet(kAllDagFlag);
	bool parentAddedUsed = argData.isFlagSet(kParentAddedFlag);
	bool parentRemovedUsed = argData.isFlagSet(kParentRemovedFlag);
	bool childAddedUsed = argData.isFlagSet(kChildAddedFlag);
	bool childRemovedUsed = argData.isFlagSet(kChildRemovedFlag);
	bool childReorderedUsed = argData.isFlagSet(kChildReorderedFlag);
	bool helpUsed = argData.isFlagSet(kHelpFlag);

	bool nothingSet = (	!allDagUsed && !parentAddedUsed && 
						!parentRemovedUsed && !childAddedUsed && 
						!childRemovedUsed && !childReorderedUsed && 
						!helpUsed);

	if (nothingSet) {
		MGlobal::displayError("A flag must be used. dagMessage -help for availible flags.");
		return MS::kFailure;
	}

	if (argData.isFlagSet(kHelpFlag)) {
		MGlobal::displayInfo("dagMessage -help");
		MGlobal::displayInfo("\tdagMessage adds a callback to the selected nodes,");
		MGlobal::displayInfo("\tor if no nodes are selected, to all nodes. The callback");
		MGlobal::displayInfo("\tprints a message when called. When the plug-in is unloaded");
		MGlobal::displayInfo("\tthe callbacks are removed.");
		MGlobal::displayInfo("");
		MGlobal::displayInfo("\t-h -help : This message is printed");
		MGlobal::displayInfo("\t-ad -allDag : parent changes and child reorders");
		MGlobal::displayInfo("\t-pa -parentAdded : A parent is added");
		MGlobal::displayInfo("\t-pr -parentRemoved : A parent is removed");
		MGlobal::displayInfo("\t-ca -childAdded : A child is added (only for individual nodes)");
		MGlobal::displayInfo("\t-cr -childRemoved : A child is removed (only for individual nodes)");
		MGlobal::displayInfo("\t-cro -childReordered : A child is reordered");
		MGlobal::displayInfo("");
	}

	unsigned nObjs = list.length();
	if (nObjs == 0) {
		//	Add the callback for all changes of the specified type.
		//
		if (allDagUsed) {
			MCallbackId id = MDagMessage::addAllDagChangesCallback(userDAGGenericCB, NULL, &status);
			if (status) {
				callbackIds.append( id );
				MGlobal::displayInfo("Added a callback for all Dag changes on all nodes.\n");
			} else {
				MGlobal::displayError("Could not add a -allDag callback");
				return status;
			}
		}

		if (parentAddedUsed) {
			status = addGenericCallback(NULL, 
										MDagMessage::kParentAdded,
										MString(" parent added "));
			if (MS::kSuccess != status) {
				return status;
			}
		}

		if (parentRemovedUsed) {
			status = addGenericCallback(NULL, 
										MDagMessage::kParentRemoved,
										MString(" parent removed "));
			if (MS::kSuccess != status) {
				return status;
			}
		}		

		if (childAddedUsed) {
			MGlobal::displayError("-childAdded can only be used when a node is selected");
			status = MS::kFailure;
			return status;
		}

		if (childRemovedUsed) {
			MGlobal::displayError("-childRemoved can only be used when a node is selected");
			status = MS::kFailure;
			return status;
		}	

		if (childReorderedUsed) {
			status = addGenericCallback(NULL, 
//.........这里部分代码省略.........
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:101,代码来源:dagMessageCmd.cpp

示例6: installCallback

MCallbackId lockEvent::installCallback( MItSelectionList &iter )
// 
// Description: 
//  Uses given iterator and callback type to attach a new callback on
//  a node, dag path, or plug. The selection iterator must contain a
//  valid selection item for the target callback type (fAttach). That is, 
//  if the callback type is three, then the iterator must contain 
//  a dependency node on it the next list item. 
//
{
	MStatus status; 

	MCallbackId id = 0; 
	MObject node, component; 
	MDagPath path; 

	switch (fAttach) { 
	case 1: { 
		status = iter.getDependNode( node ); 
		if ( status ) { 
			// Try to set the callback. Note: we check the status
			// flag at the end of the switch statement. 
			// 
			id = MLM::setNodeLockQueryCallback( node, lockDecision, 
												NULL, &status );
		}
	}	break;
	case 2: { 
		status = iter.getDagPath( path, component );
		if ( status ) { 
			// Try to set the callback. Note: we check the status
			// flag at the end of the switch statement. 
			// 
			id = MLM::setNodeLockDAGQueryCallback( path, lockDagDecision, 
												   NULL, &status ); 
		}
	} 	break;
	case 3: { 
		status = iter.getDependNode( node ); 
		MStringArray plugName; 
		iter.getStrings( plugName ); 
		// Now we have to parse the plug string. 
		// 
		if ( status && plugName.length() > 0 ) { 
			MFnDependencyNode depNode( node ); 
			MStringArray attrName; 
			plugName[0].split( '.', attrName ); 
			
			MPlug plug = depNode.findPlug( attrName[1], &status ); 
			if ( status ) { 
				// Try to set the callback. Note: we check the status
				// flag at the end of the switch statement. 
				// 
				id = MLM::setPlugLockQueryCallback( plug, plugDecision,	
													NULL,&status );
			}
		} else { 
			status = MS::kFailure; 
		}
	} break;	
	case 4: {
		status = iter.getDependNode( node ); 
		if ( status ) { 
			// Try to set the callback. Note: we check the status
			// flag at the end of the switch statement. 
			// 
			id = MLM::setPlugLockQueryCallback( node, nodePlugDecision, 
												NULL, &status ); 
		}
	} break; 
	default: 
		MGlobal::displayError( "Invalid callback attach type" ); 
		status = MS::kFailure; 
	}; 	

	MFnDependencyNode fnNode( node ); 
	
	// Check the status flag here and report any particular problems 
	// encountered.  It is possible for the callback attach routines 
	// to fail.
	//
	// This typically occurs when a callback has already been attached
	// to the node or plug. 
	//
	if ( !status || !id ) { 
		MString msg; 
		msg = "Unable to add callback for node "; 
		msg += fnNode.name(); 
		MGlobal::displayError( msg );
		status.perror( msg ); 
	} else { 
		// Store the result -- so we can clean up later -- and 
		// echo some useful information. 
		// 
		cerr << "Callback attached to " << fnNode.name(); 	
		cerr << "; attachment type = " << fAttach << endl;  
		callbackIds.append( (int)id ); 
	}
	return id; 
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:100,代码来源:lockEvent.cpp


注:本文中的MCallbackIdArray::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。