1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 00:39:59 +00:00

on edit mode change clear selection of elements that are not affected by current edit mode (only support for instance for now since we do not have selection for other elements yet)

This commit is contained in:
Marc Zinnschlag 2015-09-29 13:48:04 +02:00
parent 981a8a2cc2
commit 319e3f24a3
8 changed files with 58 additions and 3 deletions

View File

@ -211,3 +211,24 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
return addObjects (start, end);
}
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
{
if (elementMask & Element_Reference)
{
for (std::map<std::string, Object *>::const_iterator iter (mObjects.begin());
iter!=mObjects.end(); ++iter)
{
bool selected = false;
switch (mode)
{
case Selection_Clear: selected = false; break;
case Selection_All: selected = true; break;
case Selection_Invert: selected = !iter->second->getSelected(); break;
}
iter->second->setSelected (selected);
}
}
}

View File

@ -49,6 +49,15 @@ namespace CSVRender
/// \return Have any objects been added?
bool addObjects (int start, int end);
public:
enum Selection
{
Selection_Clear,
Selection_All,
Selection_Invert
};
public:
Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::string& id);
@ -75,6 +84,8 @@ namespace CSVRender
/// \return Did this call result in a modification of the visual representation of
/// this cell?
bool referenceAdded (const QModelIndex& parent, int start, int end);
void setSelection (int elementMask, Selection mode);
};
}

View File

@ -15,6 +15,7 @@ unsigned int CSVRender::EditMode::getInteractionMask() const
void CSVRender::EditMode::activate (CSVWidget::SceneToolbar *toolbar)
{
mWorldspaceWidget->setInteractionMask (mMask);
mWorldspaceWidget->clearSelection (~mMask);
}
void CSVRender::EditMode::updateUserSetting (const QString& name, const QStringList& value)

View File

@ -314,6 +314,13 @@ unsigned int CSVRender::PagedWorldspaceWidget::getVisibilityMask() const
return WorldspaceWidget::getVisibilityMask() | mControlElements->getSelection();
}
void CSVRender::PagedWorldspaceWidget::clearSelection (int elementMask)
{
for (std::map<CSMWorld::CellCoordinates, Cell *>::iterator iter = mCells.begin();
iter!=mCells.end(); ++iter)
iter->second->setSelection (elementMask, Cell::Selection_Clear);
}
CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector (
CSVWidget::SceneToolbar *parent)
{

View File

@ -79,6 +79,9 @@ namespace CSVRender
virtual unsigned int getVisibilityMask() const;
/// \param elementMask Elements to be affected by the clear operation
virtual void clearSelection (int elementMask);
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);

View File

@ -102,6 +102,11 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld:
return true;
}
void CSVRender::UnpagedWorldspaceWidget::clearSelection (int elementMask)
{
mCell->setSelection (elementMask, Cell::Selection_Clear);
}
void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
const QModelIndex& bottomRight)
{

View File

@ -43,6 +43,9 @@ namespace CSVRender
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
DropType type);
/// \param elementMask Elements to be affected by the clear operation
virtual void clearSelection (int elementMask);
private:
virtual void referenceableDataChanged (const QModelIndex& topLeft,

View File

@ -5,10 +5,11 @@
#include <boost/shared_ptr.hpp>
#include "scenewidget.hpp"
#include "../../model/doc/document.hpp"
#include "../../model/world/tablemimedata.hpp"
#include <apps/opencs/model/doc/document.hpp>
#include <apps/opencs/model/world/tablemimedata.hpp>
#include "scenewidget.hpp"
#include "elements.hpp"
namespace CSMWorld
{
@ -104,6 +105,9 @@ namespace CSVRender
virtual void setEditLock (bool locked);
/// \param elementMask Elements to be affected by the clear operation
virtual void clearSelection (int elementMask) = 0;
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool);