本文整理汇总了C++中UndoManager::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ UndoManager::addAction方法的具体用法?C++ UndoManager::addAction怎么用?C++ UndoManager::addAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UndoManager
的用法示例。
在下文中一共展示了UndoManager::addAction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deleteSelectedDecal
void GuiDecalEditorCtrl::deleteSelectedDecal()
{
if ( !mSELDecal )
return;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
DIDeleteUndoAction *action = new DIDeleteUndoAction("Delete Decal");
action->deleteDecal( *mSELDecal );
action->mEditor = this;
// Submit it.
undoMan->addAction( action );
if ( isMethod( "onDeleteInstance" ) )
{
char buffer[512];
dSprintf(buffer, 512, "%i", mSELDecal->mId);
Con::executef( this, "onDeleteInstance", String(buffer).c_str(), mSELDecal->mDataBlock->lookupName.c_str() );
}
gDecalManager->removeDecal( mSELDecal );
mSELDecal = NULL;
}
示例2: submitUndo
void GuiRoadEditorCtrl::submitUndo( const UTF8 *name )
{
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiRoadEditorCtrl::submitUndo() - EUndoManager not found!" );
return;
}
// Setup the action.
GuiRoadEditorUndoAction *action = new GuiRoadEditorUndoAction( name );
action->mObjId = mSelRoad->getId();
action->mBreakAngle = mSelRoad->mBreakAngle;
action->mMaterialName = mSelRoad->mMaterialName;
action->mSegmentsPerBatch = mSelRoad->mSegmentsPerBatch;
action->mTextureLength = mSelRoad->mTextureLength;
action->mRoadEditor = this;
for( U32 i = 0; i < mSelRoad->mNodes.size(); i++ )
{
action->mNodes.push_back( mSelRoad->mNodes[i] );
}
undoMan->addAction( action );
}
示例3: retargetDecalDatablock
void GuiDecalEditorCtrl::retargetDecalDatablock( String dbFrom, String dbTo )
{
DecalData * ptrFrom = dynamic_cast<DecalData*> ( Sim::findObject(dbFrom.c_str()) );
DecalData * ptrTo = dynamic_cast<DecalData*> ( Sim::findObject(dbTo.c_str()) );
if( !ptrFrom || !ptrTo )
return;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
DBRetargetUndoAction *action = new DBRetargetUndoAction("Retarget Decal Datablock");
action->mEditor = this;
action->mDBFromId = ptrFrom->getId();
action->mDBToId = ptrTo->getId();
Vector<DecalInstance*> mDecalQueue;
Vector<DecalInstance *>::iterator iter;
mDecalQueue.clear();
const Vector<DecalSphere*> &grid = gDecalManager->getDecalDataFile()->getSphereList();
for ( U32 i = 0; i < grid.size(); i++ )
{
const DecalSphere *decalSphere = grid[i];
mDecalQueue.merge( decalSphere->mItems );
}
for ( iter = mDecalQueue.begin();iter != mDecalQueue.end();iter++ )
{
if( !(*iter) )
continue;
if( (*iter)->mDataBlock->lookupName.compare( dbFrom ) == 0 )
{
if( (*iter)->mId != -1 )
{
action->retargetDecal((*iter));
(*iter)->mDataBlock = ptrTo;
forceRedraw((*iter));
}
}
}
undoMan->addAction( action );
}
示例4: _submitUndo
void ForestTool::_submitUndo( UndoAction *action )
{
AssertFatal( action, "ForestTool::_submitUndo() - No undo action!" );
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "ForestTool::_submitUndo() - EUndoManager not found!" );
return;
}
undoMan->addAction( action );
mEditor->updateCollision();
}
示例5: deleteSelectedRiver
void GuiRiverEditorCtrl::deleteSelectedRiver( bool undoAble )
{
AssertFatal( mSelRiver != NULL, "GuiRiverEditorCtrl::deleteSelectedRiver() - No River IS selected" );
// Not undoAble? Just delete it.
if ( !undoAble )
{
mSelRiver->deleteObject();
mIsDirty = true;
Con::executef( this, "onRiverSelected" );
mSelNode = -1;
return;
}
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
// Couldn't find it? Well just delete the River.
Con::errorf( "GuiRiverEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
else
{
// Create the UndoAction.
MEDeleteUndoAction *action = new MEDeleteUndoAction("Deleted River");
action->deleteObject( mSelRiver );
mIsDirty = true;
// Submit it.
undoMan->addAction( action );
}
// ScriptCallback with 'NULL' parameter for no River currently selected.
Con::executef( this, "onRiverSelected" );
// Clear the SelectedNode (it has been deleted along with the River).
setSelectedNode( -1 );
mSelNode = -1;
// SelectedRiver is a SimObjectPtr and will be NULL automatically.
}
示例6: deleteMeshSafe
void ForestEditorCtrl::deleteMeshSafe( ForestItemData *mesh )
{
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "ForestEditorCtrl::deleteMeshSafe() - EUndoManager not found." );
return;
}
// CompoundUndoAction which will delete the ForestItemData, ForestItem(s), and ForestBrushElement(s).
CompoundUndoAction *compoundAction = new CompoundUndoAction( "Delete Forest Mesh" );
// Find ForestItem(s) referencing this datablock and add their deletion
// to the undo action.
if ( mForest )
{
Vector<ForestItem> foundItems;
mForest->getData()->getItems( mesh, &foundItems );
ForestDeleteUndoAction *itemAction = new ForestDeleteUndoAction( mForest->getData(), this );
itemAction->removeItem( foundItems );
compoundAction->addAction( itemAction );
}
// Find ForestBrushElement(s) referencing this datablock.
SimGroup *brushGroup = ForestBrush::getGroup();
sKey = mesh;
Vector<SimObject*> foundElements;
brushGroup->findObjectByCallback( &findMeshReferences, foundElements );
// Add UndoAction to delete the ForestBrushElement(s) and the ForestItemData.
MEDeleteUndoAction *elementAction = new MEDeleteUndoAction();
elementAction->deleteObject( foundElements );
elementAction->deleteObject( mesh );
// Add compound action to the UndoManager. Done.
undoMan->addAction( compoundAction );
updateCollision();
}
示例7: deleteSelectedRoad
void GuiRoadEditorCtrl::deleteSelectedRoad( bool undoAble )
{
AssertFatal( mSelRoad != NULL, "GuiRoadEditorCtrl::deleteSelectedRoad() - No road IS selected" );
// Not undo-able? Just delete it.
if ( !undoAble )
{
DecalRoad *lastRoad = mSelRoad;
setSelectedRoad(NULL);
lastRoad->deleteObject();
mIsDirty = true;
return;
}
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
// Couldn't find it? Well just delete the road.
Con::errorf( "GuiRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
else
{
DecalRoad *lastRoad = mSelRoad;
setSelectedRoad(NULL);
// Create the UndoAction.
MEDeleteUndoAction *action = new MEDeleteUndoAction("Deleted Road");
action->deleteObject( lastRoad );
mIsDirty = true;
// Submit it.
undoMan->addAction( action );
}
}
示例8: deleteDecalDatablock
void GuiDecalEditorCtrl::deleteDecalDatablock( String lookupName )
{
DecalData * datablock = dynamic_cast<DecalData*> ( Sim::findObject(lookupName.c_str()) );
if( !datablock )
return;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
DBDeleteUndoAction *action = new DBDeleteUndoAction("Delete Decal Datablock");
action->mEditor = this;
action->mDatablockId = datablock->getId();
Vector<DecalInstance*> mDecalQueue;
Vector<DecalInstance *>::iterator iter;
mDecalQueue.clear();
const Vector<DecalSphere*> &grid = gDecalManager->getDecalDataFile()->getSphereList();
for ( U32 i = 0; i < grid.size(); i++ )
{
const DecalSphere *decalSphere = grid[i];
mDecalQueue.merge( decalSphere->mItems );
}
for ( iter = mDecalQueue.begin();iter != mDecalQueue.end();iter++ )
{
if( !(*iter) )
continue;
if( (*iter)->mDataBlock->lookupName.compare( lookupName ) == 0 )
{
if( (*iter)->mId != -1 )
{
//make sure to call onDeleteInstance as well
if ( isMethod( "onDeleteInstance" ) )
{
char buffer[512];
dSprintf(buffer, 512, "%i", (*iter)->mId);
Con::executef( this, "onDeleteInstance", String(buffer).c_str(), (*iter)->mDataBlock->lookupName.c_str() );
}
action->deleteDecal( *(*iter) );
if( mSELDecal == (*iter) )
mSELDecal = NULL;
if( mHLDecal == (*iter) )
mHLDecal = NULL;
}
gDecalManager->removeDecal( (*iter) );
}
}
undoMan->addAction( action );
mCurrentDecalData = NULL;
}
示例9: if
void GuiDecalEditorCtrl::on3DMouseDragged(const Gui3DMouseEvent & event)
{
if ( !mSELDecal )
return;
// Doing a drag copy of the decal?
if ( event.modifier & SI_SHIFT && !mPerformedDragCopy )
{
mPerformedDragCopy = true;
DecalInstance *newDecal = gDecalManager->addDecal( mSELDecal->mPosition,
mSELDecal->mNormal,
0.0f,
mSELDecal->mDataBlock,
1.0f,
-1,
PermanentDecal | SaveDecal );
newDecal->mTangent = mSELDecal->mTangent;
newDecal->mSize = mSELDecal->mSize;
newDecal->mTextureRectIdx = mSELDecal->mTextureRectIdx;
// TODO: This is crazy... we should move this sort of tracking
// inside of the decal manager... IdDecal flag maybe or just a
// byproduct of PermanentDecal?
//
newDecal->mId = gDecalManager->mDecalInstanceVec.size();
gDecalManager->mDecalInstanceVec.push_back( newDecal );
selectDecal( newDecal );
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( Sim::findObject( "EUndoManager", undoMan ) )
{
// Create the UndoAction.
DICreateUndoAction *action = new DICreateUndoAction("Create Decal");
action->addDecal( *mSELDecal );
action->mEditor = this;
undoMan->addAction( action );
if ( isMethod( "onCreateInstance" ) )
{
char buffer[512];
dSprintf( buffer, 512, "%i", mSELDecal->mId );
Con::executef( this, "onCreateInstance", buffer, mSELDecal->mDataBlock->lookupName.c_str());
}
}
}
// Update the Gizmo.
if (mGizmo->getSelection() != Gizmo::None)
{
mGizmo->on3DMouseDragged( event );
// Pull out the Gizmo transform
// and position.
const MatrixF &gizmoMat = mGizmo->getTransform();
const Point3F &gizmoPos = gizmoMat.getPosition();
// Get the new projection vector.
VectorF upVec, rightVec;
gizmoMat.getColumn( 0, &rightVec );
gizmoMat.getColumn( 2, &upVec );
const Point3F &scale = mGizmo->getScale();
// Assign the appropriate changed value back to the decal.
if ( mGizmo->getMode() == ScaleMode )
{
// Save old size.
const F32 oldSize = mSELDecal->mSize;
// Set new size.
mSELDecal->mSize = ( scale.x + scale.y ) * 0.5f;
// See if the decal properly clips/projects at this size. If not,
// stick to the old size.
mSELEdgeVerts.clear();
if ( !gDecalManager->clipDecal( mSELDecal, &mSELEdgeVerts ) )
mSELDecal->mSize = oldSize;
}
else if ( mGizmo->getMode() == MoveMode )
mSELDecal->mPosition = gizmoPos;
else if ( mGizmo->getMode() == RotateMode )
{
mSELDecal->mNormal = upVec;
mSELDecal->mTangent = rightVec;
}
gDecalManager->notifyDecalModified( mSELDecal );
Con::executef( this, "syncNodeDetails" );
}
}
示例10: screenPos
//.........这里部分代码省略.........
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
Con::errorf( "GuiDecalRoadEditorCtrl - could not find MissionGroup to add new DecalRoad" );
else
missionGroup->addObject( newRoad );
newRoad->insertNode( tPos, mDefaultWidth, 0 );
U32 newNode = newRoad->insertNode( tPos, mDefaultWidth, 1 );
// Always add to the end of the road, the first node is the start.
mAddNodeIdx = U32_MAX;
setSelectedRoad( newRoad );
setSelectedNode( newNode );
mMode = mAddNodeMode;
// Disable the hover node while in addNodeMode, we
// don't want some random node enlarged.
mHoverNode = -1;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
MECreateUndoAction *action = new MECreateUndoAction("Create Road");
action->addObject( newRoad );
// Submit it.
undoMan->addAction( action );
//send a callback to script after were done here if one exists
if ( isMethod( "onRoadCreation" ) )
Con::executef( this, "onRoadCreation" );
return;
}
else if ( mMode == mAddNodeMode )
{
// Oops the road got deleted, maybe from an undo action?
// Back to NormalMode.
if ( mSelRoad )
{
// A double-click on a node in Normal mode means set AddNode mode.
if ( clickedNodeIdx == 0 )
{
submitUndo( "Add Node" );
mAddNodeIdx = clickedNodeIdx;
mMode = mAddNodeMode;
mSelNode = mSelRoad->insertNode( tPos, mDefaultWidth, mAddNodeIdx );
mIsDirty = true;
setSelectedNode( mSelNode );
return;
}
else
{
if( clickedRoadPtr && clickedNodeIdx == clickedRoadPtr->mNodes.size() - 1 )
{
submitUndo( "Add Node" );
mAddNodeIdx = U32_MAX;
mMode = mAddNodeMode;
示例11: if
//.........这里部分代码省略.........
missionGroup->addObject( newRiver );
Point3F pos( endPnt );
pos.z += mDefaultDepth * 0.5f;
newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 0 );
U32 newNode = newRiver->insertNode( pos, mDefaultWidth, mDefaultDepth, mDefaultNormal, 1 );
// Always add to the end of the road, the first node is the start.
mAddNodeIdx = U32_MAX;
setSelectedRiver( newRiver );
setSelectedNode( newNode );
mMode = mAddNodeMode;
// Disable the hover node while in addNodeMode, we
// don't want some random node enlarged.
mHoverNode = -1;
// Grab the mission editor undo manager.
UndoManager *undoMan = NULL;
if ( !Sim::findObject( "EUndoManager", undoMan ) )
{
Con::errorf( "GuiMeshRoadEditorCtrl::on3DMouseDown() - EUndoManager not found!" );
return;
}
// Create the UndoAction.
MECreateUndoAction *action = new MECreateUndoAction("Create MeshRoad");
action->addObject( newRiver );
// Submit it.
undoMan->addAction( action );
return;
}
else if ( mMode == mAddNodeMode )
{
// Oops the road got deleted, maybe from an undo action?
// Back to NormalMode.
if ( mSelRiver )
{
// A double-click on a node in Normal mode means set AddNode mode.
if ( clickedNodeIdx == 0 )
{
submitUndo( "Add Node" );
mAddNodeIdx = clickedNodeIdx;
mMode = mAddNodeMode;
mSelNode = mSelRiver->insertNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal, mAddNodeIdx );
mIsDirty = true;
setSelectedNode( mSelNode );
return;
}
else
{
if( clickedRiverPtr && clickedNodeIdx == clickedRiverPtr->mNodes.size() - 1 )
{
submitUndo( "Add Node" );
mAddNodeIdx = U32_MAX;
mMode = mAddNodeMode;
U32 newNode = mSelRiver->addNode( tPos, mDefaultWidth, mDefaultDepth, mDefaultNormal);
mIsDirty = true;
setSelectedNode( newNode );