forked from teamnwah/openmw-tes3coop
prewview subview
parent
ef1364878f
commit
c36dfef972
@ -0,0 +1,45 @@
|
||||
|
||||
#include "previewwidget.hpp"
|
||||
|
||||
#include <OgreSceneManager.h>
|
||||
|
||||
#include "../../model/world/data.hpp"
|
||||
|
||||
void CSVRender::PreviewWidget::setup (const std::string& id)
|
||||
{
|
||||
setNavigation (&mOrbit);
|
||||
|
||||
int column = mData.getReferenceables().findColumnIndex (CSMWorld::Columns::ColumnId_Model);
|
||||
|
||||
int row = mData.getReferenceables().getIndex (id);
|
||||
|
||||
QVariant value = mData.getReferenceables().getData (row, column);
|
||||
|
||||
if (!value.isValid())
|
||||
return;
|
||||
|
||||
std::string model = value.toString().toUtf8().constData();
|
||||
|
||||
if (model.empty())
|
||||
return;
|
||||
|
||||
Ogre::SceneNode* node = getSceneManager()->getRootSceneNode()->createChildSceneNode();
|
||||
node->setPosition (Ogre::Vector3 (0, 0, 0));
|
||||
|
||||
mObject = NifOgre::Loader::createObjects (node, "Meshes\\" + model);
|
||||
}
|
||||
|
||||
CSVRender::PreviewWidget::PreviewWidget (const CSMWorld::Data& data,
|
||||
const std::string& referenceableId, QWidget *parent)
|
||||
: SceneWidget (parent), mData (data)
|
||||
{
|
||||
setup (referenceableId);
|
||||
}
|
||||
|
||||
CSVRender::PreviewWidget::PreviewWidget (const CSMWorld::Data& data,
|
||||
const std::string& referenceableId, const std::string& referenceId, QWidget *parent)
|
||||
: SceneWidget (parent), mData (data)
|
||||
{
|
||||
setup (referenceableId);
|
||||
/// \todo apply reference modifications (scale, rotation)
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#ifndef OPENCS_VIEW_PREVIEWWIDGET_H
|
||||
#define OPENCS_VIEW_PREVIEWWIDGET_H
|
||||
|
||||
#include <components/nifogre/ogrenifloader.hpp>
|
||||
|
||||
#include "scenewidget.hpp"
|
||||
|
||||
#include "navigationorbit.hpp"
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class Data;
|
||||
}
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class PreviewWidget : public SceneWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
const CSMWorld::Data& mData;
|
||||
CSVRender::NavigationOrbit mOrbit;
|
||||
NifOgre::ObjectScenePtr mObject;
|
||||
|
||||
void setup (const std::string& id);
|
||||
///< \param id ID of the referenceable to be viewed
|
||||
|
||||
public:
|
||||
|
||||
PreviewWidget (const CSMWorld::Data& data, const std::string& referenceableId,
|
||||
QWidget *parent = 0);
|
||||
|
||||
PreviewWidget (const CSMWorld::Data& data, const std::string& referenceableId,
|
||||
const std::string& referenceId, QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void closeRequest();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,50 @@
|
||||
|
||||
#include "previewsubview.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "../render/scenewidget.hpp"
|
||||
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
#include "../render/previewwidget.hpp"
|
||||
|
||||
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: SubView (id)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||
|
||||
if (document.getData().getReferenceables().searchId (id.getId())==-1)
|
||||
{
|
||||
std::string referenceableId =
|
||||
document.getData().getReferences().getRecord (id.getId()).get().mRefID;
|
||||
|
||||
mScene =
|
||||
new CSVRender::PreviewWidget (document.getData(), referenceableId, id.getId(), this);
|
||||
}
|
||||
else
|
||||
mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), this);
|
||||
|
||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||
|
||||
layout->addWidget (toolbar, 0);
|
||||
|
||||
layout->addWidget (mScene, 1);
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
|
||||
widget->setLayout (layout);
|
||||
|
||||
setWidget (widget);
|
||||
|
||||
connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
|
||||
}
|
||||
|
||||
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
||||
|
||||
void CSVWorld::PreviewSubView::closeRequest()
|
||||
{
|
||||
deleteLater();
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#ifndef CSV_WORLD_PREVIEWSUBVIEW_H
|
||||
#define CSV_WORLD_PREVIEWSUBVIEW_H
|
||||
|
||||
#include "../doc/subview.hpp"
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace CSVRender
|
||||
{
|
||||
class PreviewWidget;
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class PreviewSubView : public CSVDoc::SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSVRender::PreviewWidget *mScene;
|
||||
|
||||
public:
|
||||
|
||||
PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
private slots:
|
||||
|
||||
void closeRequest();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue