mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-07-04 12:15:58 +00:00
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);
|
mpContextMenu = new QMenu(this);
|
||||||
|
|
||||||
|
// Main context menu
|
||||||
mpToggleSelectAction = new QAction("ToggleSelect", this);
|
mpToggleSelectAction = new QAction("ToggleSelect", this);
|
||||||
connect(mpToggleSelectAction, SIGNAL(triggered()), this, SLOT(OnToggleSelect()));
|
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 = new QAction(this);
|
||||||
mpHideSelectionSeparator->setSeparator(true);
|
mpHideSelectionSeparator->setSeparator(true);
|
||||||
|
|
||||||
@ -210,12 +208,30 @@ void CSceneViewport::CreateContextMenu()
|
|||||||
connect(mpUnhideAllAction, SIGNAL(triggered()), this, SLOT(OnUnhideAll()));
|
connect(mpUnhideAllAction, SIGNAL(triggered()), this, SLOT(OnUnhideAll()));
|
||||||
|
|
||||||
QList<QAction*> Actions;
|
QList<QAction*> Actions;
|
||||||
Actions << mpToggleSelectAction << mpSelectConnectedAction
|
Actions << mpToggleSelectAction
|
||||||
<< mpHideSelectionSeparator << mpHideSelectionAction << mpHideUnselectedAction
|
<< mpHideSelectionSeparator << mpHideSelectionAction << mpHideUnselectedAction
|
||||||
<< mpHideHoverSeparator << mpHideHoverNodeAction << mpHideHoverTypeAction << mpHideHoverLayerAction
|
<< mpHideHoverSeparator << mpHideHoverNodeAction << mpHideHoverTypeAction << mpHideHoverLayerAction
|
||||||
<< mpUnhideSeparator << mpUnhideAllAction;
|
<< mpUnhideSeparator << mpUnhideAllAction;
|
||||||
|
|
||||||
mpContextMenu->addActions(Actions);
|
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()
|
QMouseEvent CSceneViewport::CreateMouseEvent()
|
||||||
@ -223,26 +239,32 @@ QMouseEvent CSceneViewport::CreateMouseEvent()
|
|||||||
return QMouseEvent(QEvent::MouseMove, mapFromGlobal(QCursor::pos()), Qt::NoButton, qApp->mouseButtons(), qApp->keyboardModifiers());
|
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);
|
CScriptNode *pScript = mpScene->NodeForInstanceID(InstanceID);
|
||||||
CScriptObject *pInst = pScript->Object();
|
CScriptObject *pInst = pScript->Object();
|
||||||
rIDList << InstanceID;
|
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()))
|
if (!rIDList.contains(pLink->ReceiverID()))
|
||||||
FindConnectedObjects(pLink->ReceiverID(), rIDList);
|
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()))
|
if (!rIDList.contains(pLink->SenderID()))
|
||||||
FindConnectedObjects(pLink->SenderID(), rIDList);
|
FindConnectedObjects(pLink->SenderID(), SearchOutgoing, SearchIncoming, rIDList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +350,7 @@ void CSceneViewport::ContextMenu(QContextMenuEvent* pEvent)
|
|||||||
bool IsScriptNode = (mpHoverNode && mpHoverNode->NodeType() == eScriptNode);
|
bool IsScriptNode = (mpHoverNode && mpHoverNode->NodeType() == eScriptNode);
|
||||||
|
|
||||||
mpToggleSelectAction->setVisible(HasHoverNode);
|
mpToggleSelectAction->setVisible(HasHoverNode);
|
||||||
mpSelectConnectedAction->setVisible(IsScriptNode);
|
mpSelectConnectedMenu->menuAction()->setVisible(IsScriptNode);
|
||||||
mpHideSelectionSeparator->setVisible(HasHoverNode);
|
mpHideSelectionSeparator->setVisible(HasHoverNode);
|
||||||
mpHideSelectionAction->setVisible(HasSelection);
|
mpHideSelectionAction->setVisible(HasSelection);
|
||||||
mpHideUnselectedAction->setVisible(HasSelection);
|
mpHideUnselectedAction->setVisible(HasSelection);
|
||||||
@ -415,13 +437,16 @@ void CSceneViewport::OnToggleSelect()
|
|||||||
void CSceneViewport::OnSelectConnected()
|
void CSceneViewport::OnSelectConnected()
|
||||||
{
|
{
|
||||||
QList<u32> InstanceIDs;
|
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;
|
QList<CSceneNode*> Nodes;
|
||||||
foreach (u32 ID, InstanceIDs)
|
foreach (u32 ID, InstanceIDs)
|
||||||
Nodes << mpScene->NodeForInstanceID(ID);
|
Nodes << mpScene->NodeForInstanceID(ID);
|
||||||
|
|
||||||
mpEditor->BatchSelectNodes(Nodes);
|
bool ShouldClear = ((qApp->keyboardModifiers() & Qt::ControlModifier) == 0);
|
||||||
|
mpEditor->BatchSelectNodes(Nodes, ShouldClear, "Select Connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSceneViewport::OnHideSelection()
|
void CSceneViewport::OnHideSelection()
|
||||||
|
@ -23,7 +23,6 @@ class CSceneViewport : public CBasicViewport
|
|||||||
// Context Menu
|
// Context Menu
|
||||||
QMenu *mpContextMenu;
|
QMenu *mpContextMenu;
|
||||||
QAction *mpToggleSelectAction;
|
QAction *mpToggleSelectAction;
|
||||||
QAction *mpSelectConnectedAction;
|
|
||||||
QAction *mpHideSelectionSeparator;
|
QAction *mpHideSelectionSeparator;
|
||||||
QAction *mpHideSelectionAction;
|
QAction *mpHideSelectionAction;
|
||||||
QAction *mpHideUnselectedAction;
|
QAction *mpHideUnselectedAction;
|
||||||
@ -35,6 +34,11 @@ class CSceneViewport : public CBasicViewport
|
|||||||
QAction *mpUnhideAllAction;
|
QAction *mpUnhideAllAction;
|
||||||
CSceneNode *mpMenuNode;
|
CSceneNode *mpMenuNode;
|
||||||
|
|
||||||
|
QMenu *mpSelectConnectedMenu;
|
||||||
|
QAction *mpSelectConnectedOutgoingAction;
|
||||||
|
QAction *mpSelectConnectedIncomingAction;
|
||||||
|
QAction *mpSelectConnectedAllAction;
|
||||||
|
|
||||||
// Link Line
|
// Link Line
|
||||||
bool mLinkLineEnabled;
|
bool mLinkLineEnabled;
|
||||||
CVector3f mLinkLinePoints[2];
|
CVector3f mLinkLinePoints[2];
|
||||||
@ -69,7 +73,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void CreateContextMenu();
|
void CreateContextMenu();
|
||||||
QMouseEvent CreateMouseEvent();
|
QMouseEvent CreateMouseEvent();
|
||||||
void FindConnectedObjects(u32 InstanceID, QList<u32>& rIDList);
|
void FindConnectedObjects(u32 InstanceID, bool SearchOutgoing, bool SearchIncoming, QList<u32>& rIDList);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void InputProcessed(const SRayIntersection& rkIntersect, QMouseEvent *pEvent);
|
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)
|
if (!mSelectionLocked)
|
||||||
{
|
{
|
||||||
foreach (CSceneNode *pNode, Nodes)
|
if (!ClearExistingSelection)
|
||||||
{
|
{
|
||||||
if (pNode->IsSelected())
|
foreach (CSceneNode *pNode, Nodes)
|
||||||
Nodes.removeOne(pNode);
|
{
|
||||||
|
if (pNode->IsSelected())
|
||||||
|
Nodes.removeOne(pNode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Nodes.size() > 0)
|
if (Nodes.size() > 0)
|
||||||
{
|
{
|
||||||
mUndoStack.beginMacro("Select");
|
mUndoStack.beginMacro(rkCommandName);
|
||||||
|
|
||||||
|
if (ClearExistingSelection)
|
||||||
|
ClearSelection();
|
||||||
|
|
||||||
foreach (CSceneNode *pNode, Nodes)
|
foreach (CSceneNode *pNode, Nodes)
|
||||||
SelectNode(pNode);
|
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)
|
if (!mSelectionLocked)
|
||||||
{
|
{
|
||||||
@ -178,7 +184,7 @@ void INodeEditor::BatchDeselectNodes(QList<CSceneNode*> Nodes)
|
|||||||
|
|
||||||
if (Nodes.size() > 0)
|
if (Nodes.size() > 0)
|
||||||
{
|
{
|
||||||
mUndoStack.beginMacro("Deselect");
|
mUndoStack.beginMacro(rkCommandName);
|
||||||
|
|
||||||
foreach (CSceneNode *pNode, Nodes)
|
foreach (CSceneNode *pNode, Nodes)
|
||||||
DeselectNode(pNode);
|
DeselectNode(pNode);
|
||||||
|
@ -63,9 +63,9 @@ public:
|
|||||||
ETransformSpace CurrentTransformSpace();
|
ETransformSpace CurrentTransformSpace();
|
||||||
|
|
||||||
void SelectNode(CSceneNode *pNode);
|
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 DeselectNode(CSceneNode *pNode);
|
||||||
void BatchDeselectNodes(QList<CSceneNode*> Nodes);
|
void BatchDeselectNodes(QList<CSceneNode*> Nodes, const QString& rkCommandName = "Deselect");
|
||||||
void ClearSelection();
|
void ClearSelection();
|
||||||
void ClearAndSelectNode(CSceneNode *pNode);
|
void ClearAndSelectNode(CSceneNode *pNode);
|
||||||
void SelectAll(FNodeFlags NodeFlags);
|
void SelectAll(FNodeFlags NodeFlags);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user