mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 11:39:44 +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/commands.hpp"
|
||||
|
||||
|
||||
#include "../widget/scenetoolbar.hpp"
|
||||
#include "../widget/scenetoolmode.hpp"
|
||||
|
||||
|
@ -52,7 +51,7 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
|
|||
}
|
||||
|
||||
if (!mSelectionMode)
|
||||
mSelectionMode = new InstanceSelectionMode (toolbar);
|
||||
mSelectionMode = new InstanceSelectionMode (toolbar, getWorldspaceWidget());
|
||||
|
||||
EditMode::activate (toolbar);
|
||||
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
|
||||
#include "instanceselectionmode.hpp"
|
||||
|
||||
CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent)
|
||||
: CSVWidget::SceneToolMode (parent, "Selection Mode")
|
||||
#include <QMenu>
|
||||
#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",
|
||||
"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>"
|
||||
"</ul>"
|
||||
"<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"
|
||||
|
||||
class QAction;
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class WorldspaceWidget;
|
||||
|
||||
class InstanceSelectionMode : public CSVWidget::SceneToolMode
|
||||
{
|
||||
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:
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
const int cellSize = 8192;
|
||||
|
|
|
@ -98,6 +98,9 @@ namespace CSVRender
|
|||
/// \param elementMask Elements to be affected by the clear operation
|
||||
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;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -108,6 +108,12 @@ void CSVRender::UnpagedWorldspaceWidget::clearSelection (int elementMask)
|
|||
flagAsModified();
|
||||
}
|
||||
|
||||
void CSVRender::UnpagedWorldspaceWidget::selectAll (int elementMask)
|
||||
{
|
||||
mCell->setSelection (elementMask, Cell::Selection_All);
|
||||
flagAsModified();
|
||||
}
|
||||
|
||||
std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const
|
||||
{
|
||||
return mCellId;
|
||||
|
|
|
@ -46,6 +46,9 @@ namespace CSVRender
|
|||
/// \param elementMask Elements to be affected by the clear operation
|
||||
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;
|
||||
|
||||
private:
|
||||
|
|
|
@ -127,6 +127,9 @@ namespace CSVRender
|
|||
/// \param elementMask Elements to be affected by the clear operation
|
||||
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
|
||||
/// \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
|
||||
|
|
Loading…
Reference in a new issue