added visual element selector toolbar button

This commit is contained in:
Marc Zinnschlag 2014-07-31 14:05:27 +02:00
parent a25758c3b1
commit 439ba57d46
7 changed files with 87 additions and 3 deletions

View file

@ -126,7 +126,9 @@ namespace CSVRender
#endif
mWindow = Ogre::Root::getSingleton().createRenderWindow(windowTitle.str(), this->width(), this->height(), false, &params);
mWindow->addViewport(mCamera)->setBackgroundColour(Ogre::ColourValue(0.3,0.3,0.3,1));
mViewport = mWindow->addViewport (mCamera);
mViewport->setBackgroundColour (Ogre::ColourValue (0.3,0.3,0.3,1));
Ogre::Real aspectRatio = Ogre::Real(width()) / Ogre::Real(height());
mCamera->setAspectRatio(aspectRatio);
@ -141,6 +143,11 @@ namespace CSVRender
Ogre::Root::getSingleton().destroySceneManager (mSceneMgr);
}
void SceneWidget::setVisibilityMask (unsigned int mask)
{
mViewport->setVisibilityMask (mask);
}
void SceneWidget::setNavigation (Navigation *navigation)
{
if ((mNavigation = navigation))

View file

@ -14,6 +14,7 @@ namespace Ogre
class Camera;
class SceneManager;
class RenderWindow;
class Viewport;
}
namespace CSVWidget
@ -42,6 +43,8 @@ namespace CSVRender
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
/// is the responsibility of the calling function.
virtual void setVisibilityMask (unsigned int mask);
protected:
void setNavigation (Navigation *navigation);
@ -85,6 +88,7 @@ namespace CSVRender
Ogre::Camera* mCamera;
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
Ogre::Viewport *mViewport;
Navigation *mNavigation;
Lighting *mLighting;

View file

@ -11,6 +11,10 @@
#include "../../model/world/idtable.hpp"
#include "../../model/world/tablemimedata.hpp"
#include "../widget/scenetooltoggle.hpp"
#include "elements.hpp"
void CSVRender::UnpagedWorldspaceWidget::update()
{
const CSMWorld::Record<CSMWorld::Cell>& record =
@ -25,6 +29,14 @@ void CSVRender::UnpagedWorldspaceWidget::update()
flagAsModified();
}
void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle *tool)
{
WorldspaceWidget::addVisibilitySelectorButtons (tool);
tool->addButton (":armor.png", Element_Fog, ":armor.png", "Fog");
}
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
: WorldspaceWidget (document, parent), mCellId (cellId)
{

View file

@ -32,6 +32,10 @@ namespace CSVRender
void update();
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool);
public:
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,

View file

@ -10,6 +10,9 @@
#include "../../model/world/universalid.hpp"
#include "../widget/scenetoolmode.hpp"
#include "../widget/scenetooltoggle.hpp"
#include "elements.hpp"
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
: SceneWidget (parent), mDocument(document)
@ -94,6 +97,21 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
return tool;
}
CSVWidget::SceneToolToggle *CSVRender::WorldspaceWidget::makeSceneVisibilitySelector (CSVWidget::SceneToolbar *parent)
{
mSceneElements= new CSVWidget::SceneToolToggle (parent,
"Scene Element Visibility", ":door.png");
addVisibilitySelectorButtons (mSceneElements);
mSceneElements->setSelection (0xffffffff);
connect (mSceneElements, SIGNAL (selectionChanged()),
this, SLOT (elementSelectionChanged()));
return mSceneElements;
}
CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType (
const std::vector< CSMWorld::UniversalId >& data)
{
@ -147,6 +165,20 @@ CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType (
return output;
}
unsigned int CSVRender::WorldspaceWidget::getElementMask() const
{
return mSceneElements->getSelection();
}
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle *tool)
{
tool->addButton (":activator.png", Element_Reference, ":activator.png", "References");
tool->addButton (":armor.png", Element_Terrain, ":armor.png", "Terrain");
tool->addButton (":armor.png", Element_Water, ":armor.png", "Water");
tool->addButton (":armor.png", Element_Pathgrid, ":armor.png", "Pathgrid");
}
void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
{
event->accept();
@ -157,7 +189,6 @@ void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event)
event->accept();
}
void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
{
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
@ -169,3 +200,8 @@ void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
emit dataDropped(mime->getData());
} //not handling drops from different documents at the moment
}
void CSVRender::WorldspaceWidget::elementSelectionChanged()
{
setVisibilityMask (getElementMask());
}

View file

@ -16,6 +16,7 @@ namespace CSMWorld
namespace CSVWidget
{
class SceneToolMode;
class SceneToolToggle;
class SceneToolbar;
}
@ -28,6 +29,7 @@ namespace CSVRender
CSVRender::Navigation1st m1st;
CSVRender::NavigationFree mFree;
CSVRender::NavigationOrbit mOrbit;
CSVWidget::SceneToolToggle *mSceneElements;
public:
@ -53,6 +55,11 @@ namespace CSVRender
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
/// is the responsibility of the calling function.
/// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function.
CSVWidget::SceneToolToggle *makeSceneVisibilitySelector (
CSVWidget::SceneToolbar *parent);
void selectDefaultNavigationMode();
static dropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
@ -64,8 +71,13 @@ namespace CSVRender
virtual void handleDrop(const std::vector<CSMWorld::UniversalId>& data) = 0;
virtual unsigned int getElementMask() const;
protected:
const CSMDoc::Document& mDocument; //for checking if drop comes from same document
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool);
const CSMDoc::Document& mDocument;
private:
@ -92,6 +104,10 @@ namespace CSVRender
virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0;
protected slots:
void elementSelectionChanged();
signals:
void closeRequest();

View file

@ -19,6 +19,7 @@
#include "../widget/scenetoolbar.hpp"
#include "../widget/scenetoolmode.hpp"
#include "../widget/scenetooltoggle.hpp"
#include "tablebottombox.hpp"
#include "creator.hpp"
@ -107,6 +108,10 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp
CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
toolbar->addTool (lightingTool);
CSVWidget::SceneToolToggle *sceneVisibilityTool =
widget->makeSceneVisibilitySelector (toolbar);
toolbar->addTool (sceneVisibilityTool);
/* Add buttons specific to the type. For now no need for it.
*
switch (type)