forked from mirror/openmw-tes3mp
Share selection functionality with instance editing mode.
parent
ae0d2c3b9c
commit
e8e915bcde
@ -0,0 +1,71 @@
|
||||
#include "pathgridselectionmode.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include "../../model/world/idtable.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/world/commandmacro.hpp"
|
||||
|
||||
#include "worldspacewidget.hpp"
|
||||
#include "pathgrid.hpp"
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
PathgridSelectionMode::PathgridSelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget)
|
||||
: SelectionMode(parent, worldspaceWidget, Mask_Pathgrid)
|
||||
{
|
||||
mRemoveSelectedNodes = new QAction("Remove selected nodes", this);
|
||||
mRemoveSelectedEdges = new QAction("Remove edges between selected nodes", this);
|
||||
|
||||
connect(mRemoveSelectedNodes, SIGNAL(triggered()), this, SLOT(removeSelectedNodes()));
|
||||
connect(mRemoveSelectedEdges, SIGNAL(triggered()), this, SLOT(removeSelectedEdges()));
|
||||
}
|
||||
|
||||
bool PathgridSelectionMode::createContextMenu(QMenu* menu)
|
||||
{
|
||||
if (menu)
|
||||
{
|
||||
SelectionMode::createContextMenu(menu);
|
||||
|
||||
menu->addAction(mRemoveSelectedNodes);
|
||||
menu->addAction(mRemoveSelectedEdges);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PathgridSelectionMode::removeSelectedNodes()
|
||||
{
|
||||
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid);
|
||||
|
||||
for (std::vector<osg::ref_ptr<TagBase> >::iterator it = selection.begin(); it != selection.end(); ++it)
|
||||
{
|
||||
if (PathgridTag* tag = dynamic_cast<PathgridTag*>(it->get()))
|
||||
{
|
||||
QUndoStack& undoStack = getWorldspaceWidget().getDocument().getUndoStack();
|
||||
QString description = "Remove selected nodes";
|
||||
|
||||
CSMWorld::CommandMacro macro(undoStack, description);
|
||||
tag->getPathgrid()->applyRemoveNodes(macro);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PathgridSelectionMode::removeSelectedEdges()
|
||||
{
|
||||
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getSelection (Mask_Pathgrid);
|
||||
|
||||
for (std::vector<osg::ref_ptr<TagBase> >::iterator it = selection.begin(); it != selection.end(); ++it)
|
||||
{
|
||||
if (PathgridTag* tag = dynamic_cast<PathgridTag*>(it->get()))
|
||||
{
|
||||
QUndoStack& undoStack = getWorldspaceWidget().getDocument().getUndoStack();
|
||||
QString description = "Remove edges between selected nodes";
|
||||
|
||||
CSMWorld::CommandMacro macro(undoStack, description);
|
||||
tag->getPathgrid()->applyRemoveEdges(macro);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
#ifndef CSV_RENDER_PATHGRID_SELECTION_MODE_H
|
||||
#define CSV_RENDER_PATHGRID_SELECTION_MODE_H
|
||||
|
||||
#include "selectionmode.hpp"
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class PathgridSelectionMode : public SelectionMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
PathgridSelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget);
|
||||
|
||||
protected:
|
||||
|
||||
/// Add context menu items to \a menu.
|
||||
///
|
||||
/// \attention menu can be a 0-pointer
|
||||
///
|
||||
/// \return Have there been any menu items to be added (if menu is 0 and there
|
||||
/// items to be added, the function must return true anyway.
|
||||
bool createContextMenu(QMenu* menu);
|
||||
|
||||
private:
|
||||
|
||||
QAction* mRemoveSelectedNodes;
|
||||
QAction* mRemoveSelectedEdges;
|
||||
|
||||
private slots:
|
||||
|
||||
void removeSelectedNodes();
|
||||
void removeSelectedEdges();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,77 @@
|
||||
#include "selectionmode.hpp"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include "worldspacewidget.hpp"
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
SelectionMode::SelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget,
|
||||
unsigned int interactionMask)
|
||||
: SceneToolMode(parent, "Selection mode")
|
||||
, mWorldspaceWidget(worldspaceWidget)
|
||||
, mInteractionMask(interactionMask)
|
||||
{
|
||||
addButton(":placeholder", "cube-centre",
|
||||
"Centred cube"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection cube outwards</li>"
|
||||
"<li>The selection cube is aligned to the word space axis</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
addButton(":placeholder", "cube-corner",
|
||||
"Cube corner to corner"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from one corner of the selection cube to the opposite corner</li>"
|
||||
"<li>The selection cube is aligned to the word space axis</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
addButton(":placeholder", "sphere",
|
||||
"Centred sphere"
|
||||
"<ul><li>Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection sphere outwards</li>"
|
||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</li>"
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
|
||||
mSelectAll = new QAction("Select all", this);
|
||||
mDeselectAll = new QAction("Clear selection", this);
|
||||
mInvertSelection = new QAction("Invert selection", this);
|
||||
|
||||
connect(mSelectAll, SIGNAL(triggered()), this, SLOT(selectAll()));
|
||||
connect(mDeselectAll, SIGNAL(triggered()), this, SLOT(clearSelection()));
|
||||
connect(mInvertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
|
||||
}
|
||||
|
||||
WorldspaceWidget& SelectionMode::getWorldspaceWidget()
|
||||
{
|
||||
return mWorldspaceWidget;
|
||||
}
|
||||
|
||||
bool SelectionMode::createContextMenu (QMenu* menu)
|
||||
{
|
||||
if (menu)
|
||||
{
|
||||
menu->addAction(mSelectAll);
|
||||
menu->addAction(mDeselectAll);
|
||||
menu->addAction(mInvertSelection);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SelectionMode::selectAll()
|
||||
{
|
||||
getWorldspaceWidget().selectAll(mInteractionMask);
|
||||
}
|
||||
|
||||
void SelectionMode::clearSelection()
|
||||
{
|
||||
getWorldspaceWidget().clearSelection(mInteractionMask);
|
||||
}
|
||||
|
||||
void SelectionMode::invertSelection()
|
||||
{
|
||||
getWorldspaceWidget().invertSelection(mInteractionMask);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
#ifndef CSV_RENDER_SELECTION_MODE_H
|
||||
#define CSV_RENDER_SELECTION_MODE_H
|
||||
|
||||
#include "../widget/scenetoolmode.hpp"
|
||||
|
||||
#include "mask.hpp"
|
||||
|
||||
class QAction;
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class WorldspaceWidget;
|
||||
|
||||
class SelectionMode : public CSVWidget::SceneToolMode
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SelectionMode(CSVWidget::SceneToolbar* parent, WorldspaceWidget& worldspaceWidget,
|
||||
unsigned int interactionMask);
|
||||
|
||||
protected:
|
||||
|
||||
WorldspaceWidget& getWorldspaceWidget();
|
||||
|
||||
/// Add context menu items to \a menu.
|
||||
///
|
||||
/// \attention menu can be a 0-pointer
|
||||
///
|
||||
/// \return Have there been any menu items to be added (if menu is 0 and there
|
||||
/// items to be added, the function must return true anyway.
|
||||
virtual bool createContextMenu (QMenu* menu);
|
||||
|
||||
private:
|
||||
|
||||
WorldspaceWidget& mWorldspaceWidget;
|
||||
unsigned int mInteractionMask;
|
||||
QAction* mSelectAll;
|
||||
QAction* mDeselectAll;
|
||||
QAction* mInvertSelection;
|
||||
|
||||
protected slots:
|
||||
|
||||
virtual void selectAll();
|
||||
virtual void clearSelection();
|
||||
virtual void invertSelection();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue