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


C++ MDagModifier::undoIt方法代码示例

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


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

示例1: undoIt

//-----------------------------------------------------------------------------
// Called when the user undoes the command
//-----------------------------------------------------------------------------
MStatus CVstAttachmentCmd::undoIt()
{
	if ( m_undoable )
	{
		MGlobal::setActiveSelectionList( m_mSelectionList );
		m_mSelectionList.clear();

		if ( m_mDagModifier )
		{
			m_mDagModifier->undoIt();
			delete m_mDagModifier;
			m_mDagModifier = NULL;
		}
	}

	return MS::kSuccess;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:20,代码来源:VstAttachmentCmd.cpp

示例2: undoIt

MStatus CVstAimCmd::undoIt()
{
	if ( m_undoable )
	{
		// Undo it... whatever that takes but the scene should be restored
		//            to the exact same state as it was just before doIt()
		//            was called (this includes active selection, etc...)

		MGlobal::setActiveSelectionList( m_mSelectionList );
		m_mSelectionList.clear();

		if ( m_mDagModifier )
		{
			m_mDagModifier->undoIt();
			delete m_mDagModifier;
			m_mDagModifier = NULL;
		}
	}

	return MS::kSuccess;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:21,代码来源:VstAimCmd.cpp

示例3: doConversion

bool ToMayaLocatorConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const
{
	ConstCoordinateSystemPtr coordSys = IECore::runTimeCast<const CoordinateSystem>( from );
	if ( !coordSys )
	{
		IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion",  "The source object is not an IECore::CoordinateSystem." );
		return false;
	}
	
	// check if incoming object is a locator itself
	MObject locatorObj;
	if ( to.hasFn( MFn::kLocator ) )
	{
		locatorObj = to;
	}
	
	// check if incoming object is a parent of an existing locator
	if ( locatorObj.isNull() )
	{
		MFnDagNode fnTo( to );
		for ( unsigned i=0; i < fnTo.childCount(); ++i )
		{
			MObject child = fnTo.child( i );
			if ( child.hasFn( MFn::kLocator ) )
			{
				locatorObj = child;
				break;
			}
		}
	}
	
	// make a new locator and parent it to the incoming object
	if ( locatorObj.isNull() )
	{
		if ( !MFnTransform().hasObj( to ) )
		{
			IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion",  "Unable to create a locator as a child of the input object." );
			return false;
		}
		
		MDagModifier dagMod;
		locatorObj = dagMod.createNode( "locator", to );
		dagMod.renameNode( locatorObj, coordSys->getName().c_str() );
		if ( !dagMod.doIt() )
		{
			IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion",  "Unable to modify the DAG correctly." );
			dagMod.undoIt();
			return false;
		}
	}
	
	if ( locatorObj.isNull() )
	{
		IECore::msg( IECore::Msg::Warning, "ToMayaLocatorConverter::doConversion",  "Unable to find or create a locator from the input object." );
		return false;
	}
	
	MFnDagNode fnLocator( locatorObj );
	
	Imath::M44f m = coordSys->getTransform()->transform();
	Imath::V3f s,h,r,t;
	Imath::extractSHRT(m, s, h, r, t);

	/// obtain local position and scale from locator
	MStatus st;
	MPlug positionPlug = fnLocator.findPlug( "localPositionX", &st );
	if ( !st ) return false;
	positionPlug.setValue(t[0]);
	positionPlug = fnLocator.findPlug( "localPositionY", &st );
	if ( !st ) return false;
	positionPlug.setValue(t[1]);
	positionPlug = fnLocator.findPlug( "localPositionZ", &st );
	if ( !st ) return false;
	positionPlug.setValue(t[2]);

	MPlug scalePlug = fnLocator.findPlug( "localScaleX", &st );
	if ( !st ) return false;
	scalePlug.setValue(s[0]);
	scalePlug = fnLocator.findPlug( "localScaleY", &st );
	if ( !st ) return false;
	scalePlug.setValue(s[1]);
	scalePlug = fnLocator.findPlug( "localScaleZ", &st );
	if ( !st ) return false;
	scalePlug.setValue(s[2]);

	return true;
}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:87,代码来源:ToMayaLocatorConverter.cpp

示例4: redoIt

MStatus CVstAimCmd::redoIt()
{
	MStatus mStatus;

	if ( !mStatus )
	{
		setResult( MString( "Cannot parse command line" ) + mStatus.errorString() );
		return MS::kFailure;
	}

	if ( m_mArgDatabase->isFlagSet( kHelp ) )
	{
		PrintHelp();
	}
	else
	{
		// See if there are two object specified

		MDagPath mDagPath;
		MSelectionList optSelectionList;

		// Validate specified items to whole dag nodes
		{
			MSelectionList tmpSelectionList;
			m_mArgDatabase->getObjects( tmpSelectionList );
			for ( MItSelectionList sIt( tmpSelectionList, MFn::kDagNode ); !sIt.isDone(); sIt.next() )
			{
				if ( sIt.getDagPath( mDagPath ) )
				{
					optSelectionList.add( mDagPath, MObject::kNullObj, true );
				}
			}
		}

		if ( m_mArgDatabase->isFlagSet( "create" ) || optSelectionList.length() >= 2 && m_mArgDatabase->numberOfFlagsUsed() == 0 )
		{
			// Error if there aren't at least two
			if ( optSelectionList.length() < 2 )
			{
				displayError( GetName() + " needs at least two objects specified or selected when -create is used" );
				return MS::kFailure;
			}

			// Get name command line arg
			MString optName;
			if ( m_mArgDatabase->isFlagSet( "name" ) )
			{
				m_mArgDatabase->getFlagArgument( "name", 0, optName );
			}

			m_undoable = true;
			m_mDagModifier = new MDagModifier;

			MObject vstAimObj( m_mDagModifier->MDGModifier::createNode( GetName() ) );
			if ( m_mDagModifier->doIt() != MS::kSuccess )
			{
				displayError( MString( "Couldn't create " ) + GetName() + " node" );
				m_mDagModifier->undoIt();
				delete m_mDagModifier;
				m_mDagModifier = NULL;
				m_undoable = false;

				return MS::kFailure;
			}

			m_mDagModifier->renameNode( vstAimObj, optName.length() ? optName : GetName() );
			if ( m_mDagModifier->doIt() != MS::kSuccess )
			{
				if ( optName.length() )
				{
					displayWarning( MString( "Couldn't rename newly created vstNode \"" ) + optName + "\"" );
				}
			}

			// Set options on the newly create vstAim node

			MFnDependencyNode vstAimFn( vstAimObj );

			MPlug sP;
			MPlug dP;

			if ( m_mArgDatabase->isFlagSet( kAim ) )
			{
				MVector aim;
				m_mArgDatabase->getFlagArgument( kAim, 0, aim.x );
				m_mArgDatabase->getFlagArgument( kAim, 1, aim.y );
				m_mArgDatabase->getFlagArgument( kAim, 2, aim.z );

				sP = vstAimFn.findPlug( "aimX" );
				sP.setValue( aim.x );

				sP = vstAimFn.findPlug( "aimY" );
				sP.setValue( aim.y );

				sP = vstAimFn.findPlug( "aimZ" );
				sP.setValue( aim.z );
			}

			if ( m_mArgDatabase->isFlagSet( kUp ) )
			{
//.........这里部分代码省略.........
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:101,代码来源:VstAimCmd.cpp


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