mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
added select all and clear selection features
This commit is contained in:
parent
4a02563708
commit
45e6974266
8 changed files with 82 additions and 5 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include "../../model/world/idtree.hpp"
|
#include "../../model/world/idtree.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include "../widget/scenetoolbar.hpp"
|
#include "../widget/scenetoolbar.hpp"
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mSelectionMode)
|
if (!mSelectionMode)
|
||||||
mSelectionMode = new InstanceSelectionMode (toolbar);
|
mSelectionMode = new InstanceSelectionMode (toolbar, getWorldspaceWidget());
|
||||||
|
|
||||||
EditMode::activate (toolbar);
|
EditMode::activate (toolbar);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
|
|
||||||
#include "instanceselectionmode.hpp"
|
#include "instanceselectionmode.hpp"
|
||||||
|
|
||||||
CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent)
|
#include <QMenu>
|
||||||
: CSVWidget::SceneToolMode (parent, "Selection Mode")
|
#include <QAction>
|
||||||
|
|
||||||
|
#include "worldspacewidget.hpp"
|
||||||
|
|
||||||
|
bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu)
|
||||||
|
{
|
||||||
|
if (menu)
|
||||||
|
{
|
||||||
|
menu->addAction (mSelectAll);
|
||||||
|
menu->addAction (mDeselectAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent,
|
||||||
|
WorldspaceWidget& worldspaceWidget)
|
||||||
|
: CSVWidget::SceneToolMode (parent, "Selection Mode"), mWorldspaceWidget (worldspaceWidget)
|
||||||
{
|
{
|
||||||
addButton (":placeholder", "cube-centre",
|
addButton (":placeholder", "cube-centre",
|
||||||
"Centred cube"
|
"Centred cube"
|
||||||
|
@ -24,4 +41,20 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar
|
||||||
"<li>If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect</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>"
|
"</ul>"
|
||||||
"<font color=Red>Not implemented yet</font color>");
|
"<font color=Red>Not implemented yet</font color>");
|
||||||
|
|
||||||
|
mSelectAll = new QAction ("Select all Instances", this);
|
||||||
|
mDeselectAll = new QAction ("Clear selection", this);
|
||||||
|
|
||||||
|
connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll()));
|
||||||
|
connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceSelectionMode::selectAll()
|
||||||
|
{
|
||||||
|
mWorldspaceWidget.selectAll (Mask_Reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceSelectionMode::clearSelection()
|
||||||
|
{
|
||||||
|
mWorldspaceWidget.clearSelection (Mask_Reference);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,37 @@
|
||||||
|
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
class WorldspaceWidget;
|
||||||
|
|
||||||
class InstanceSelectionMode : public CSVWidget::SceneToolMode
|
class InstanceSelectionMode : public CSVWidget::SceneToolMode
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
WorldspaceWidget& mWorldspaceWidget;
|
||||||
|
QAction *mSelectAll;
|
||||||
|
QAction *mDeselectAll;
|
||||||
|
|
||||||
|
/// 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);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InstanceSelectionMode (CSVWidget::SceneToolbar *parent);
|
InstanceSelectionMode (CSVWidget::SceneToolbar *parent, WorldspaceWidget& worldspaceWidget);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void selectAll();
|
||||||
|
|
||||||
|
void clearSelection();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -509,6 +509,15 @@ void CSVRender::PagedWorldspaceWidget::clearSelection (int elementMask)
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::PagedWorldspaceWidget::selectAll (int elementMask)
|
||||||
|
{
|
||||||
|
for (std::map<CSMWorld::CellCoordinates, Cell *>::iterator iter = mCells.begin();
|
||||||
|
iter!=mCells.end(); ++iter)
|
||||||
|
iter->second->setSelection (elementMask, Cell::Selection_All);
|
||||||
|
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const
|
std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const
|
||||||
{
|
{
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
|
|
|
@ -98,6 +98,9 @@ namespace CSVRender
|
||||||
/// \param elementMask Elements to be affected by the clear operation
|
/// \param elementMask Elements to be affected by the clear operation
|
||||||
virtual void clearSelection (int elementMask);
|
virtual void clearSelection (int elementMask);
|
||||||
|
|
||||||
|
/// \param elementMask Elements to be affected by the select operation
|
||||||
|
virtual void selectAll (int elementMask);
|
||||||
|
|
||||||
virtual std::string getCellId (const osg::Vec3f& point) const;
|
virtual std::string getCellId (const osg::Vec3f& point) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -108,6 +108,12 @@ void CSVRender::UnpagedWorldspaceWidget::clearSelection (int elementMask)
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::UnpagedWorldspaceWidget::selectAll (int elementMask)
|
||||||
|
{
|
||||||
|
mCell->setSelection (elementMask, Cell::Selection_All);
|
||||||
|
flagAsModified();
|
||||||
|
}
|
||||||
|
|
||||||
std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const
|
std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const
|
||||||
{
|
{
|
||||||
return mCellId;
|
return mCellId;
|
||||||
|
|
|
@ -46,6 +46,9 @@ namespace CSVRender
|
||||||
/// \param elementMask Elements to be affected by the clear operation
|
/// \param elementMask Elements to be affected by the clear operation
|
||||||
virtual void clearSelection (int elementMask);
|
virtual void clearSelection (int elementMask);
|
||||||
|
|
||||||
|
/// \param elementMask Elements to be affected by the select operation
|
||||||
|
virtual void selectAll (int elementMask);
|
||||||
|
|
||||||
virtual std::string getCellId (const osg::Vec3f& point) const;
|
virtual std::string getCellId (const osg::Vec3f& point) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -127,6 +127,9 @@ namespace CSVRender
|
||||||
/// \param elementMask Elements to be affected by the clear operation
|
/// \param elementMask Elements to be affected by the clear operation
|
||||||
virtual void clearSelection (int elementMask) = 0;
|
virtual void clearSelection (int elementMask) = 0;
|
||||||
|
|
||||||
|
/// \param elementMask Elements to be affected by the select operation
|
||||||
|
virtual void selectAll (int elementMask) = 0;
|
||||||
|
|
||||||
/// Return the next intersection point with scene elements matched by
|
/// Return the next intersection point with scene elements matched by
|
||||||
/// \a interactionMask based on \a localPos and the camera vector.
|
/// \a interactionMask based on \a localPos and the camera vector.
|
||||||
/// If there is no such point, instead a point "in front" of \a localPos will be
|
/// If there is no such point, instead a point "in front" of \a localPos will be
|
||||||
|
|
Loading…
Reference in a new issue