Added "select connected" action to CSceneViewport context menu
This commit is contained in:
parent
99a64342e9
commit
1921fbf5de
|
@ -179,6 +179,9 @@ void CSceneViewport::CreateContextMenu()
|
|||
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);
|
||||
|
||||
|
@ -207,7 +210,7 @@ void CSceneViewport::CreateContextMenu()
|
|||
connect(mpUnhideAllAction, SIGNAL(triggered()), this, SLOT(OnUnhideAll()));
|
||||
|
||||
QList<QAction*> Actions;
|
||||
Actions << mpToggleSelectAction
|
||||
Actions << mpToggleSelectAction << mpSelectConnectedAction
|
||||
<< mpHideSelectionSeparator << mpHideSelectionAction << mpHideUnselectedAction
|
||||
<< mpHideHoverSeparator << mpHideHoverNodeAction << mpHideHoverTypeAction << mpHideHoverLayerAction
|
||||
<< mpUnhideSeparator << mpUnhideAllAction;
|
||||
|
@ -220,6 +223,29 @@ QMouseEvent CSceneViewport::CreateMouseEvent()
|
|||
return QMouseEvent(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, qApp->mouseButtons(), qApp->keyboardModifiers());
|
||||
}
|
||||
|
||||
void CSceneViewport::FindConnectedObjects(u32 InstanceID, QList<u32>& rIDList)
|
||||
{
|
||||
CScriptNode *pScript = mpScene->NodeForInstanceID(InstanceID);
|
||||
CScriptObject *pInst = pScript->Object();
|
||||
rIDList << InstanceID;
|
||||
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eOutgoing, iLink);
|
||||
|
||||
if (!rIDList.contains(pLink->ReceiverID()))
|
||||
FindConnectedObjects(pLink->ReceiverID(), rIDList);
|
||||
}
|
||||
|
||||
for (u32 iLink = 0; iLink < pInst->NumLinks(eIncoming); iLink++)
|
||||
{
|
||||
CLink *pLink = pInst->Link(eIncoming, iLink);
|
||||
|
||||
if (!rIDList.contains(pLink->SenderID()))
|
||||
FindConnectedObjects(pLink->SenderID(), rIDList);
|
||||
}
|
||||
}
|
||||
|
||||
// ************ PROTECTED SLOTS ************
|
||||
void CSceneViewport::CheckUserInput()
|
||||
{
|
||||
|
@ -302,6 +328,7 @@ void CSceneViewport::ContextMenu(QContextMenuEvent* pEvent)
|
|||
bool IsScriptNode = (mpHoverNode && mpHoverNode->NodeType() == eScriptNode);
|
||||
|
||||
mpToggleSelectAction->setVisible(HasHoverNode);
|
||||
mpSelectConnectedAction->setVisible(IsScriptNode);
|
||||
mpHideSelectionSeparator->setVisible(HasHoverNode);
|
||||
mpHideSelectionAction->setVisible(HasSelection);
|
||||
mpHideUnselectedAction->setVisible(HasSelection);
|
||||
|
@ -385,6 +412,18 @@ void CSceneViewport::OnToggleSelect()
|
|||
mpEditor->SelectNode(mpMenuNode);
|
||||
}
|
||||
|
||||
void CSceneViewport::OnSelectConnected()
|
||||
{
|
||||
QList<u32> InstanceIDs;
|
||||
FindConnectedObjects(static_cast<CScriptNode*>(mpMenuNode)->Object()->InstanceID(), InstanceIDs);
|
||||
|
||||
QList<CSceneNode*> Nodes;
|
||||
foreach (u32 ID, InstanceIDs)
|
||||
Nodes << mpScene->NodeForInstanceID(ID);
|
||||
|
||||
mpEditor->BatchSelectNodes(Nodes);
|
||||
}
|
||||
|
||||
void CSceneViewport::OnHideSelection()
|
||||
{
|
||||
for (CSelectionIterator It(mpEditor->Selection()); It; ++It)
|
||||
|
|
|
@ -23,6 +23,7 @@ class CSceneViewport : public CBasicViewport
|
|||
// Context Menu
|
||||
QMenu *mpContextMenu;
|
||||
QAction *mpToggleSelectAction;
|
||||
QAction *mpSelectConnectedAction;
|
||||
QAction *mpHideSelectionSeparator;
|
||||
QAction *mpHideSelectionAction;
|
||||
QAction *mpHideUnselectedAction;
|
||||
|
@ -68,6 +69,7 @@ public:
|
|||
protected:
|
||||
void CreateContextMenu();
|
||||
QMouseEvent CreateMouseEvent();
|
||||
void FindConnectedObjects(u32 InstanceID, QList<u32>& rIDList);
|
||||
|
||||
signals:
|
||||
void InputProcessed(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
||||
|
@ -85,6 +87,7 @@ protected slots:
|
|||
|
||||
// Menu Actions
|
||||
void OnToggleSelect();
|
||||
void OnSelectConnected();
|
||||
void OnHideSelection();
|
||||
void OnHideUnselected();
|
||||
void OnHideNode();
|
||||
|
|
|
@ -135,6 +135,28 @@ void INodeEditor::SelectNode(CSceneNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
void INodeEditor::BatchSelectNodes(QList<CSceneNode*> Nodes)
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
{
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
{
|
||||
if (pNode->IsSelected())
|
||||
Nodes.removeOne(pNode);
|
||||
}
|
||||
|
||||
if (Nodes.size() > 0)
|
||||
{
|
||||
mUndoStack.beginMacro("Select");
|
||||
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
SelectNode(pNode);
|
||||
|
||||
mUndoStack.endMacro();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void INodeEditor::DeselectNode(CSceneNode *pNode)
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
|
@ -144,6 +166,28 @@ void INodeEditor::DeselectNode(CSceneNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes)
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
{
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
{
|
||||
if (!pNode->IsSelected())
|
||||
Nodes.removeOne(pNode);
|
||||
}
|
||||
|
||||
if (Nodes.size() > 0)
|
||||
{
|
||||
mUndoStack.beginMacro("Deselect");
|
||||
|
||||
foreach (CSceneNode *pNode, Nodes)
|
||||
DeselectNode(pNode);
|
||||
|
||||
mUndoStack.endMacro();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void INodeEditor::ClearSelection()
|
||||
{
|
||||
if (!mSelectionLocked)
|
||||
|
|
|
@ -63,7 +63,9 @@ public:
|
|||
ETransformSpace CurrentTransformSpace();
|
||||
|
||||
void SelectNode(CSceneNode *pNode);
|
||||
void BatchSelectNodes(QList<CSceneNode*> Nodes);
|
||||
void DeselectNode(CSceneNode *pNode);
|
||||
void BatchDeselectNodes(QList<CSceneNode*> Nodes);
|
||||
void ClearSelection();
|
||||
void ClearAndSelectNode(CSceneNode *pNode);
|
||||
void SelectAll(FNodeFlags NodeFlags);
|
||||
|
|
Loading…
Reference in New Issue