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)

sceneinput
Marc Zinnschlag 9 years ago
parent 981a8a2cc2
commit 319e3f24a3

@ -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);
}
}
}

@ -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);
};
}

@ -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)

@ -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)
{

@ -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);

@ -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)
{

@ -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,

@ -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);

Loading…
Cancel
Save