Added some extra menu actions to allow the user more control over which connected instances are selected
This commit is contained in:
parent
1921fbf5de
commit
d961545309
|
@ -176,12 +176,10 @@ void CSceneViewport::CreateContextMenu()
|
|||
{
|
||||
mpContextMenu = new QMenu(this);
|
||||
|
||||
// Main context menu
|
||||
mpToggleSelectAction = new QAction("ToggleSelect", this);
|
||||
connect(mpToggleSelectAction, SIGNAL(triggered()), this, SLOT(OnToggleSelect()));
|
||||
|
||||
mpSelectConnectedAction = new QAction("Select connected", this);
|
||||
connect(mpSelectConnectedAction, SIGNAL(triggered()), this, SLOT(OnSelectConnected()));
|
||||
|
||||
mpHideSelectionSeparator = new QAction(this);
|
||||
mpHideSelectionSeparator->setSeparator(true);
|
||||
|
||||
|
@ -210,12 +208,30 @@ void CSceneViewport::CreateContextMenu()
|
|||
connect(mpUnhideAllAction, SIGNAL(triggered()), this, SLOT(OnUnhideAll()));
|
||||
|
||||
QList<QAction*> Actions;
|
||||
Actions << mpToggleSelectAction << mpSelectConnectedAction
|
||||
Actions << mpToggleSelectAction
|
||||
<< mpHideSelectionSeparator << mpHideSelectionAction << mpHideUnselectedAction
|
||||
<< mpHideHoverSeparator << mpHideHoverNodeAction << mpHideHoverTypeAction << mpHideHoverLayerAction
|
||||
<< mpUnhideSeparator << mpUnhideAllAction;
|
||||
|
||||
mpContextMenu->addActions(Actions);
|
||||
|
||||
// Select Connected menu
|
||||
mpSelectConnectedMenu = new QMenu("Select connected...", this);
|
||||
|
||||
mpSelectConnectedOutgoingAction = new QAction("...via outgoing links", this);
|
||||
connect(mpSelectConnectedOutgoingAction, SIGNAL(triggered()), this, SLOT(OnSelectConnected()));
|
||||
|
||||
mpSelectConnectedIncomingAction = new QAction("...via incoming links", this);
|
||||
connect(mpSelectConnectedIncomingAction, SIGNAL(triggered()), this, SLOT(OnSelectConnected()));
|
||||
|
||||
mpSelectConnectedAllAction = new QAction("...via all links", this);
|
||||
connect(mpSelectConnectedAllAction, SIGNAL(triggered()), this, SLOT(OnSelectConnected()));
|
||||
|
||||
QList<QAction*> SelectConnectedActions;
|
||||
SelectConnectedActions << mpSelectConnectedOutgoingAction << mpSelectConnectedIncomingAction << mpSelectConnectedAllAction;
|
||||
mpSelectConnectedMenu->addActions(SelectConnectedActions);
|
||||
|
||||
mpContextMenu->insertMenu(mpHideSelectionSeparator, mpSelectConnectedMenu);
|
||||
}
|
||||
|
||||
QMouseEvent CSceneViewport::CreateMouseEvent()
|
||||
|
@ -223,26 +239,32 @@ QMouseEvent CSceneViewport::CreateMouseEvent()
|
|||
return QMouseEvent(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, qApp->mouseButtons(), qApp->keyboardModifiers());
|
||||
}
|
||||
|
||||
void CSceneViewport::FindConnectedObjects(u32 InstanceID, QList<u32>& rIDList)
|
||||
void CSceneViewport::FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList<u32>& rIDList)
|
||||
{
|
||||
CScriptNode *pScript = mpScene->NodeForInstanceID(InstanceID);
|
||||
CScriptObject *pInst = pScript->Object();
|
||||
rIDList << InstanceID;
|
||||
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++)
|
||||
if (SearchOutgoing)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eOutgoing, iLink);
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eOutgoing, iLink);
|
||||
|
||||
if (!rIDList.contains(pLink->ReceiverID()))
|
||||
FindConnectedObjects(pLink->ReceiverID(), rIDList);
|
||||
if (!rIDList.contains(pLink->ReceiverID()))
|
||||
FindConnectedObjects(pLink->ReceiverID(), SearchOutgoing, SearchIncoming, rIDList);
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++)
|
||||
if (SearchIncoming)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eIncoming, iLink);
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eIncoming, iLink);
|
||||
|
||||
if (!rIDList.contains(pLink->SenderID()))
|
||||
FindConnectedObjects(pLink->SenderID(), rIDList);
|
||||
if (!rIDList.contains(pLink->SenderID()))
|
||||
FindConnectedObjects(pLink->SenderID(), SearchOutgoing, SearchIncoming, rIDList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +350,7 @@ void CSceneViewport::ContextMenu(QContextMenuEvent* pEvent)
|
|||
bool IsScriptNode = (mpHoverNode && mpHoverNode->NodeType() == eScriptNode);
|
||||
|
||||
mpToggleSelectAction->setVisible(HasHoverNode);
|
||||
mpSelectConnectedAction->setVisible(IsScriptNode);
|
||||
mpSelectConnectedMenu->menuAction()->setVisible(IsScriptNode);
|
||||
mpHideSelectionSeparator->setVisible(HasHoverNode);
|
||||
mpHideSelectionAction->setVisible(HasSelection);
|
||||
mpHideUnselectedAction->setVisible(HasSelection);
|
||||
|
@ -415,13 +437,16 @@ void CSceneViewport::OnToggleSelect()
|
|||
void CSceneViewport::OnSelectConnected()
|
||||
{
|
||||
QList<u32> InstanceIDs;
|
||||
FindConnectedObjects(static_cast<CScriptNode*>(mpMenuNode)->Object()->InstanceID(), InstanceIDs);
|
||||
bool SearchOutgoing = (sender() == mpSelectConnectedOutgoingAction || sender() == mpSelectConnectedAllAction);
|
||||
bool SearchIncoming = (sender() == mpSelectConnectedIncomingAction || sender() == mpSelectConnectedAllAction);
|
||||
FindConnectedObjects(static_cast<CScriptNode*>(mpMenuNode)->Object()->InstanceID(), SearchOutgoing, SearchIncoming, InstanceIDs);
|
||||
|
||||
QList<CSceneNode*> Nodes;
|
||||
foreach (u32 ID, InstanceIDs)
|
||||
Nodes << mpScene->NodeForInstanceID(ID);
|
||||
|
||||
mpEditor->BatchSelectNodes(Nodes);
|
||||
bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0);
|
||||
mpEditor->BatchSelectNodes(Nodes, ShouldClear, "Select Connected");
|
||||
}
|
||||
|
||||
void CSceneViewport::OnHideSelection()
|
||||
|
|
|
@ -23,7 +23,6 @@ class CSceneViewport : public CBasicViewport
|
|||
// Context Menu
|
||||
QMenu *mpContextMenu;
|
||||
QAction *mpToggleSelectAction;
|
||||
QAction *mpSelectConnectedAction;
|
||||
QAction *mpHideSelectionSeparator;
|
||||
QAction *mpHideSelectionAction;
|
||||
QAction *mpHideUnselectedAction;
|
||||
|
@ -35,6 +34,11 @@ class CSceneViewport : public CBasicViewport
|
|||
QAction *mpUnhideAllAction;
|
||||
CSceneNode *mpMenuNode;
|
||||
|
||||
QMenu *mpSelectConnectedMenu;
|
||||
QAction *mpSelectConnectedOutgoingAction;
|
||||
QAction *mpSelectConnectedIncomingAction;
|
||||
QAction *mpSelectConnectedAllAction;
|
||||
|
||||
// Link Line
|
||||
bool mLinkLineEnabled;
|
||||
CVector3f mLinkLinePoints[2];
|
||||
|
@ -69,7 +73,7 @@ public:
|
|||
protected:
|
||||
void CreateContextMenu();
|
||||
QMouseEvent CreateMouseEvent();
|
||||
void FindConnectedObjects(u32 InstanceID, QList<u32>& rIDList);
|
||||
void FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList<u32>& rIDList);
|
||||
|
||||
signals:
|
||||
void InputProcessed(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
||||
|
|
|
@ -135,19 +135,25 @@ void INodeEditor::SelectNode(CSceneNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes)
|
||||
void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName /*= "Select"*/)
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
{
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
if (!ClearExistingSelection)
|
||||
{
|
||||
if (pNode->IsSelected())
|
||||
Nodes.removeOne(pNode);
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
{
|
||||
if (pNode->IsSelected())
|
||||
Nodes.removeOne(pNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (Nodes.size() > 0)
|
||||
{
|
||||
mUndoStack.beginMacro("Select");
|
||||
mUndoStack.beginMacro(rkCommandName);
|
||||
|
||||
if (ClearExistingSelection)
|
||||
ClearSelection();
|
||||
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
SelectNode(pNode);
|
||||
|
@ -166,7 +172,7 @@ void INodeEditor::DeselectNode(CSceneNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes)
|
||||
void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rkCommandName /*= "Deselect"*/)
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
{
|
||||
|
@ -178,7 +184,7 @@ void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes)
|
|||
|
||||
if (Nodes.size() > 0)
|
||||
{
|
||||
mUndoStack.beginMacro("Deselect");
|
||||
mUndoStack.beginMacro(rkCommandName);
|
||||
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
DeselectNode(pNode);
|
||||
|
|
|
@ -63,9 +63,9 @@ public:
|
|||
ETransformSpace CurrentTransformSpace();
|
||||
|
||||
void SelectNode(CSceneNode *pNode);
|
||||
void BatchSelectNodes(QList<CSceneNode*> Nodes);
|
||||
void BatchSelectNodes(QList<CSceneNode*> Nodes, bool ClearExistingSelection, const QString& rkCommandName = "Select");
|
||||
void DeselectNode(CSceneNode *pNode);
|
||||
void BatchDeselectNodes(QList<CSceneNode*> Nodes);
|
||||
void BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rkCommandName = "Deselect");
|
||||
void ClearSelection();
|
||||
void ClearAndSelectNode(CSceneNode *pNode);
|
||||
void SelectAll(FNodeFlags NodeFlags);
|
||||
|
|
Loading…
Reference in New Issue