1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Implement "model" view in rwviewer

This commit is contained in:
Daniel Evans 2014-09-21 16:13:01 +01:00
parent 78334aa51b
commit 33afc649c5
4 changed files with 55 additions and 22 deletions

View File

@ -1,42 +1,47 @@
#include "ObjectViewer.hpp" #include "ObjectViewer.hpp"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <models/ObjectListModel.hpp> #include <models/ObjectListModel.hpp>
#include "ViewerWidget.hpp" #include "ViewerWidget.hpp"
#include <QDebug>
ObjectViewer::ObjectViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f) ObjectViewer::ObjectViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f) : QWidget(parent, f)
{ {
mainLayout = new QHBoxLayout;
objectList = new QTableView; objectList = new QTableView;
QHBoxLayout* layout = new QHBoxLayout; mainLayout->addWidget(objectList);
layout->addWidget(objectList);
QVBoxLayout* infoLayout = new QVBoxLayout;
layout->addItem(infoLayout);
previewWidget = viewer; previewWidget = viewer;
previewWidget->setMinimumSize(250,250); previewWidget->setMinimumSize(250,250);
QGridLayout* dataGrid = new QGridLayout; infoLayout = new QGridLayout;
dataGrid->addWidget(previewWidget, 0, 0, 1, 2);
previewID = new QLabel; previewID = new QLabel;
previewModel = new QLabel; previewModel = new QLabel;
previewClass = new QLabel; previewClass = new QLabel;
dataGrid->addWidget(new QLabel("ID"), 1, 0); infoLayout->addWidget(new QLabel("ID"), 1, 0);
dataGrid->addWidget(previewID, 1, 1); infoLayout->addWidget(previewID, 1, 1);
dataGrid->addWidget(new QLabel("Type"), 2, 0); infoLayout->addWidget(new QLabel("Type"), 2, 0);
dataGrid->addWidget(previewClass, 2, 1); infoLayout->addWidget(previewClass, 2, 1);
dataGrid->addWidget(new QLabel("Model"), 3, 0); infoLayout->addWidget(new QLabel("Model"), 3, 0);
dataGrid->addWidget(previewModel, 3, 1); infoLayout->addWidget(previewModel, 3, 1);
infoLayout->addItem(dataGrid); //infoLayout->addStretch(100);
infoLayout->addStretch(100); mainLayout->addLayout(infoLayout);
this->setLayout(layout); this->setLayout(mainLayout);
setViewerWidget(previewWidget);
}
void ObjectViewer::setViewerWidget(ViewerWidget* widget)
{
static size_t c = 0;
//widgetLayout->removeWidget(previewWidget);
previewWidget = widget;
infoLayout->addWidget(previewWidget, 0, 0, 1, 2);
} }
static std::map<ObjectInformation::ObjectClass, QString> gDataType = static std::map<ObjectInformation::ObjectClass, QString> gDataType =

View File

@ -6,6 +6,8 @@
#include <QGLWidget> #include <QGLWidget>
#include <QTableView> #include <QTableView>
#include <QLabel> #include <QLabel>
#include <QGridLayout>
#include <QHBoxLayout>
class ViewerWidget; class ViewerWidget;
@ -16,11 +18,12 @@ class ObjectViewer : public QWidget
QTableView* objectList; QTableView* objectList;
GameWorld* _world; GameWorld* _world;
QHBoxLayout* mainLayout;
QGridLayout* infoLayout;
ViewerWidget* previewWidget; ViewerWidget* previewWidget;
QLabel* previewID; QLabel* previewID;
QLabel* previewModel; QLabel* previewModel;
QLabel* previewClass; QLabel* previewClass;
public: public:
ObjectViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0); ObjectViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
@ -30,6 +33,8 @@ public:
return _world; return _world;
} }
void setViewerWidget( ViewerWidget* widget );
public slots: public slots:
void showItem(qint16 item); void showItem(qint16 item);

View File

@ -49,7 +49,6 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
viewSwitcher = new QStackedWidget; viewSwitcher = new QStackedWidget;
viewSwitcher->addWidget(objectViewer); viewSwitcher->addWidget(objectViewer);
viewSwitcher->addWidget(new QLabel("Model Viewer Not Implemented Yet"));
QMenu* view = mb->addMenu("&View"); QMenu* view = mb->addMenu("&View");
QAction* objectAction = view->addAction("&Object"); QAction* objectAction = view->addAction("&Object");
@ -67,6 +66,13 @@ ViewerWindow::ViewerWindow(QWidget* parent, Qt::WindowFlags flags)
QMenu* anim = mb->addMenu("&Animation"); QMenu* anim = mb->addMenu("&Animation");
anim->addAction("Load &Animations", this, SLOT(openAnimations())); anim->addAction("Load &Animations", this, SLOT(openAnimations()));
modelLayout = new QVBoxLayout;
QWidget* span = new QWidget;
span->setLayout(modelLayout);
viewSwitcher->addWidget(span);
this->setCentralWidget(viewSwitcher); this->setCentralWidget(viewSwitcher);
updateRecentGames(); updateRecentGames();
@ -171,7 +177,19 @@ void ViewerWindow::switchWidget()
{ {
QAction* r = qobject_cast< QAction* >(sender()); QAction* r = qobject_cast< QAction* >(sender());
if(r) { if(r) {
viewSwitcher->setCurrentIndex(r->data().toInt() ); int index = r->data().toInt();
if( index == 0 )
{
modelLayout->removeWidget( viewerWidget );
objectViewer->setViewerWidget( viewerWidget );
}
else if( index == 1 )
{
modelLayout->addWidget( viewerWidget );
}
viewSwitcher->setCurrentIndex( index );
} }
} }

View File

@ -5,6 +5,7 @@
#include <engine/GameWorld.hpp> #include <engine/GameWorld.hpp>
#include <QGLContext> #include <QGLContext>
#include <QStackedWidget> #include <QStackedWidget>
#include <QVBoxLayout>
class ObjectViewer; class ObjectViewer;
class ViewerWidget; class ViewerWidget;
@ -17,7 +18,11 @@ class ViewerWindow : public QMainWindow
/** Contains the OGL context */ /** Contains the OGL context */
ViewerWidget* viewerWidget; ViewerWidget* viewerWidget;
ObjectViewer* objectViewer; ObjectViewer* objectViewer;
QVBoxLayout* modelLayout;
QStackedWidget* viewSwitcher; QStackedWidget* viewSwitcher;
QGLContext* context; QGLContext* context;