1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Fix Model frame widget display

This commit is contained in:
Daniel Evans 2014-06-10 16:47:44 +01:00
parent 1e9e8c4d9c
commit 871804fcb3
7 changed files with 25 additions and 12 deletions

View File

@ -1,7 +1,7 @@
#include "DFFFramesTreeModel.hpp"
#include <render/Model.hpp>
DFFFramesTreeModel::DFFFramesTreeModel(ModelHandle *m, QObject* parent)
DFFFramesTreeModel::DFFFramesTreeModel(Model *m, QObject* parent)
: QAbstractItemModel(parent), model(m)
{
@ -29,7 +29,7 @@ int DFFFramesTreeModel::rowCount(const QModelIndex& parent) const
QModelIndex DFFFramesTreeModel::index(int row, int column, const QModelIndex& parent) const
{
if(parent.row() == -1 && parent.column() == -1) {
return createIndex(row, column, model->model->frames[model->model->rootFrameIdx]);
return createIndex(row, column, model->frames[model->rootFrameIdx]);
}
ModelFrame* f = static_cast<ModelFrame*>(parent.internalPointer());
ModelFrame* p = f->getChildren()[row];

View File

@ -6,10 +6,10 @@
class DFFFramesTreeModel : public QAbstractItemModel
{
ModelHandle* model;
Model* model;
public:
explicit DFFFramesTreeModel(ModelHandle* m, QObject* parent = 0);
explicit DFFFramesTreeModel(Model* m, QObject* parent = 0);
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;

View File

@ -8,7 +8,7 @@ ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
setWidget(tree);
}
void ModelFramesWidget::setModel(ModelHandle *model)
void ModelFramesWidget::setModel(Model *model)
{
if(framemodel) {
delete framemodel;

View File

@ -10,14 +10,16 @@ class ModelFramesWidget : public QDockWidget
{
Q_OBJECT
ModelHandle* gmodel;
Model* gmodel;
DFFFramesTreeModel* framemodel;
QTreeView* tree;
public:
ModelFramesWidget(QWidget* parent = 0, Qt::WindowFlags flags = 0);
void setModel(ModelHandle* model);
public slots:
void setModel(Model *model);
};
#endif

View File

@ -10,7 +10,7 @@
ViewerWidget::ViewerWidget(QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
: QGLWidget(parent, shareWidget, f), gworld(nullptr), dummyObject(nullptr), currentObjectID(0),
cmodel(nullptr), canimation(nullptr), viewDistance(1.f), dragging(false)
_lastModel(nullptr), canimation(nullptr), viewDistance(1.f), dragging(false)
{
}
@ -52,6 +52,14 @@ void ViewerWidget::paintGL()
}
if(dummyObject) {
gworld->_work->update();
if( dummyObject->model->model != _lastModel ) {
_lastModel = dummyObject->model->model;
emit modelChanged(_lastModel);
}
glEnable(GL_DEPTH_TEST);
glm::mat4 m;
@ -129,9 +137,9 @@ void ViewerWidget::exportModel()
}
}
ModelHandle* ViewerWidget::currentModel() const
Model* ViewerWidget::currentModel() const
{
return cmodel;
return _lastModel;
}
void ViewerWidget::setGamePath(const std::string &path)

View File

@ -20,7 +20,7 @@ class ViewerWidget : public QGLWidget
GameObject* dummyObject;
quint16 currentObjectID;
ModelHandle* cmodel;
Model* _lastModel;
Animation* canimation;
float viewDistance;
@ -39,7 +39,7 @@ public:
virtual void paintGL();
ModelHandle *currentModel() const;
Model *currentModel() const;
// TODO: Move this into the main window or elsewhere, doesn't really belong here.
void setGamePath(const std::string& path);
@ -59,6 +59,8 @@ signals:
void fileOpened(const QString& file);
void modelChanged(Model* model);
protected:
virtual void mousePressEvent(QMouseEvent*);

View File

@ -56,6 +56,7 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags): QMainWindow(
connect(itemsWidget, SIGNAL(selectedItemChanged(qint16)), viewer, SLOT(showItem(qint16)));
connect(viewer, SIGNAL(dataLoaded(GameWorld*)), itemsWidget, SLOT(worldLoaded(GameWorld*)));
connect(viewer, SIGNAL(modelChanged(Model*)), frameswidget, SLOT(setModel(Model*)));
connect(animationswidget, SIGNAL(selectedAnimationChanged(Animation*)), viewer, SLOT(showAnimation(Animation*)));
updateRecentGames();