///	\brief	clear undo stack. This is useful for operations that cannot be undone
///	\param	size - unused
///	\param	param - unused
DWORD CUndoRedoComponent::OnUndoClearStack(DWORD size, void *param)
{
	ASSERT(m_pCurrentCommandData == NULL);
	UNDOSTACKINFO *pInfo = reinterpret_cast<UNDOSTACKINFO *>(param);
	VERIFY_MESSAGE_SIZE(size, sizeof(*pInfo));
	if (NULL != pInfo->pStackName)
	{
		StackList::iterator itStack = FindStack(pInfo->pStackName);
		if (itStack == m_Stacks.end())
		{
			m_pToolBox->Log(LOGERROR, _T("%s(%i): Can't find undo stack '%s' for clearing .\n"), __FILE__, __LINE__, pInfo->pStackName->GetString());
			return MSG_ERROR;
		}
		(*itStack)->ClearStack();
	}
	else
	{
		CUndoStack *pStack = GetStack();
		if (pStack == NULL)
		{
			return MSG_ERROR;
		}
		pStack->ClearStack();
	}
	return MSG_HANDLED;
}
///	\brief	unregister new undo stack
///	\param	size - size of UNDOSTACKINFO structure
///	\param	param - pointer to UNDOSTACKINFO structure
DWORD CUndoRedoComponent::OnUndoDeleteStack(DWORD size, void *param)
{
	UNDOSTACKINFO *pInfo = reinterpret_cast<UNDOSTACKINFO *>(param);
	VERIFY_MESSAGE_SIZE(size, sizeof(*pInfo));
	IHashString *pName = pInfo->pStackName;
	StackList::iterator itStack = FindStack(pName);
	if (itStack == m_Stacks.end())
	{
		m_pToolBox->Log(LOGERROR, _T("%s(%i): Can't find undo stack for deletion.\n"), __FILE__, __LINE__);
		return MSG_ERROR;
	}

	DWORD hashName = pName->GetUniqueID();
	View2StackMap::iterator mapIt = m_View2Stack.begin();
	while (mapIt != m_View2Stack.end())
	{
		if (mapIt->second == *itStack)
		{
			mapIt = m_View2Stack.erase(mapIt);
		}
		else
		{
			++mapIt;
		}
	}

	delete *itStack;
	m_Stacks.erase(itStack);
	return MSG_HANDLED;
}
///	\brief	get pointer to stack by stack name
///	\param	pName - pointer to IHashString with name of the stack
///	\return	pointer to found stack or NULL otherwise
CUndoStack *CUndoRedoComponent::GetStack(IHashString *pName)
{
	StackList::iterator it = FindStack(pName);
	if (it == m_Stacks.end())
	{
		m_pToolBox->Log(LOGERROR, _T("%s(%i): Get undo stack by name '%s' failed\n"), __FILE__, __LINE__, pName->GetString());
		return NULL;
	}
	return *it;
}
示例#4
0
void IPCStackEvent(int argc, char** argv, PLSOBJECT Object)
{
	char* Name = argv[0];
	LSTypeDefinition* Type = pLSInterface->FindLSType(argv[1]);
	char* SubType = argv[2];
	char* Method = argv[3];

	LSOBJECT Stackobject;
	if((Stackobject.Ptr = FindStack(Name)) == 0)
	{
		Stackobject.Ptr = new LSStack(Type, SubType);
		AddStack(Name, (LSStack*)Stackobject.Ptr);
	}
	pStackType->GetMethodEx(Stackobject.GetObjectData(), Method, argc - 4, &argv[4]);
}
///	\brief	register new undo stack
///	\param	size - size of UNDOSTACKINFO structure
///	\param	param - pointer to UNDOSTACKINFO structure
DWORD CUndoRedoComponent::OnUndoCreateStack(DWORD size, void *param)
{
	UNDOSTACKINFO *pInfo = reinterpret_cast<UNDOSTACKINFO *>(param);
	VERIFY_MESSAGE_SIZE(size, sizeof(*pInfo));
	IHashString *pName = pInfo->pStackName;
	if (FindStack(pName) != m_Stacks.end())
	{
		m_pToolBox->Log(LOGERROR, _T("%s(%i): Stack with name '%s' already exists.\n"),
							__FILE__, __LINE__, pName->GetString());
		return MSG_ERROR;
	}
	CUndoStack *pStack = new CUndoStack(pName);
	m_Stacks.push_back(pStack);
	return MSG_HANDLED;
}
示例#6
0
文件: GvPath.cpp 项目: geomview/gv2
int GvPath::FindAncestry(Geom *geom)
{
  UtLStack<Geom *>stack;

  (*(stack.Push())) = mpWorld->GetUniverseBase();
  if (FindStack(&stack, geom)) {
    mAncestryLength = stack.Depth();
    for (int i=mAncestryLength-1; i>=0; --i) {
      mAncestry[i] = *(stack.Top());
      stack.Pop();
    }
    return 1;
  } else {
    return 0;
  }
}
示例#7
0
文件: GvPath.cpp 项目: geomview/gv2
int GvPath::FindStack(UtLStack<Geom *> *stack, Geom *geom)
{
  Geom *g = *(stack->Top());
  if ( g == geom ) { return 1; }
  if (g->IsInstanceOf(TYPE_INFO(GeomParent))) {
    GeomParent *p = (GeomParent*)g;
    int nchildren = p->GetChildCount();
    for (int i=0; i<nchildren; ++i) {
      (*(stack->Push())) = p->GetChild(i);
      if (FindStack(stack, geom)) {
	return 1;
      }
      stack->Pop();
    }
  }
  return 0;
}
///	\brief	rename existing undo stack
///	\param	size - size of UNDOSTACKRENAME structure
///	\param	param - pointer to UNDOSTACKRENAME structure
DWORD CUndoRedoComponent::OnUndoRenameStack(DWORD size, void *param)
{
	UNDOSTACKRENAME *pRename = reinterpret_cast<UNDOSTACKRENAME *>(param);
	VERIFY_MESSAGE_SIZE(size, sizeof(*pRename));
	IHashString *pName = pRename->pStackName;
	CUndoStack *pStack = GetStack(pName);
	if (pStack == NULL)
	{
		m_pToolBox->Log(LOGERROR, _T("%s(%i): Can't find stack '%s'.\n"), __FILE__, __LINE__, pName->GetString());
		return MSG_ERROR;
	}
	IHashString *pNewName = pRename->pNewStackName;
	if (FindStack(pNewName) != m_Stacks.end())
	{
		m_pToolBox->Log(LOGERROR, _T("%s(%i): Can't rename stack '%s' to '%s'. Such stack exists already.\n"),
										__FILE__, __LINE__, pName->GetString(), pNewName->GetString());
		return MSG_ERROR;
	}
	pStack->SetName(pRename->pNewStackName);
	return MSG_HANDLED;
}
示例#9
0
bool IPCStackType::GetMethod(LSOBJECTDATA &ObjectData, PLSTYPEMETHOD pMethod, int argc, char *argv[])
{
/*******************************************
 * Parameters
 *
 * [in] LSOBJECTDATA ObjectData: ObjectData is a 32-bit value that can be accessed in any number of different ways
 *        by way of union.  Most commonly, ObjectData.Ptr, ObjectData.DWord, or ObjectData.CharPtr are useful.  This
 *        value is the representation of some object of this object type.  "ipcfoo" works on IPCFoo*
 *        so ObjectData is a IPCFoo*
 *
 * [in] PLSTYPEMETHOD pMethod: pMethod is a pointer to the information on the method to be retrieved, including its
 *        Name and ID.  We use the ID in a switch statement in order to quickly process the method, since the Name
 *        has already been resolved by the LavishScript engine.
 *
 * [in] int argc, char *argv[]: argc and argv are *nearly* standard C console program parameters.  The difference here
 *        is that the name of the method is NOT given as the first argument (in contrast to LavishScript commands).
 *        Therefore, argc is 0 unless arguments are specifically given to the method retrieval.
 */

/*******************************************
 * Return Value
 *
 * The return value for this function is very simple.  If the method execution fails for any reason, OR the object
 * is destroyed during execution, return false.  Otherwise, return true (indicating the object still exists AND
 * the method execution succeeded).
 *
 */
	/* Validate the pointer */
	if (!pStack)
		return false;

	/* Perform the given member retrieval */
	switch(pMethod->ID)
	{
	case Push:
		pStack->Stack->Push(argc, argv);
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "Stack", argc, argv);
		return true;
	case Pop:
		pStack->Stack->Pop();
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "DeStack", argc, argv);
		return true;
	case Clear:
		pStack->Stack->Clear();
		StackRelay(pStack->IPCName, pStack->Type->GetName(), pStack->SubType, "Clear", argc, argv);
		return true;
	case Set:
	case SetIPCName:
		if(argc)
		{
			LSStack *newStack;
			strncpy(pStack->IPCName, argv[0], sizeof(pStack->IPCName));
			if((newStack=FindStack(pStack->IPCName))==0)
			{
				newStack = new LSStack(pStack->Type, pStack->SubType);
				AddStack(pStack->IPCName, newStack);
			}
			pStack->Stack = newStack;
			return true;
		}
		return false;
	case GetIterator:
		LSOBJECT iteratorobject;
		if(argc)
		{
			//printf("%s %s %d", argv[0], pStack->IPCName, pStack->Stack->GetContainerUsed());
			if(pLSInterface->DataParse(argv[0], iteratorobject))
			{
				return InitializeIterator(pStack->Stack, 0, iteratorobject);
			}
		}
		return false;
	}
	return false;
}