1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00
openrw/rwviewer/widgets/ModelFramesWidget.cpp

70 lines
1.9 KiB
C++
Raw Normal View History

2014-02-12 07:42:07 +01:00
#include "ModelFramesWidget.hpp"
#include <data/Model.hpp>
2014-06-10 21:26:04 +02:00
#include <glm/gtx/string_cast.hpp>
void ModelFramesWidget::updateInfoBox(Model* model, ModelFrame *f)
2014-06-10 21:26:04 +02:00
{
if( f == nullptr ) {
_frameLabel->setText("");
}
else {
auto labText = QString("Name: %1\nTranslation: %2\nTextures:%3")
2014-06-10 21:26:04 +02:00
.arg(QString::fromStdString(f->getName()))
.arg(QString::fromStdString(glm::to_string(f->getDefaultTranslation())));
QString geomString;
for(size_t gi : f->getGeometries()) {
auto& g = model->geometries[gi];
//for(Model::SubGeometry& sg : g->subgeom)
for(Model::Material& m : g->materials) {
for(Model::Texture& t : m.textures) {
geomString += QString("\n %1 (%2)")
.arg(t.name.c_str())
.arg(t.alphaName.c_str());
}
}
}
labText = labText.arg(geomString);
2014-06-10 21:26:04 +02:00
_frameLabel->setText(labText);
}
}
void ModelFramesWidget::selectedModelChanged(const QModelIndex & n, const QModelIndex &)
{
updateInfoBox( gmodel, (ModelFrame*) n.internalPointer() );
selectedFrameChanged( (ModelFrame*) n.internalPointer() );
2014-06-10 21:26:04 +02:00
}
2014-02-12 07:42:07 +01:00
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
2015-04-13 02:48:29 +02:00
: QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr)
2014-02-12 07:42:07 +01:00
{
setWindowTitle("Frames");
2014-06-10 21:26:04 +02:00
2015-04-13 02:48:29 +02:00
_layout = new QVBoxLayout;
2014-06-10 21:26:04 +02:00
tree = new QTreeView(this);
_layout->addWidget(tree);
_frameLabel = new QLabel(this);
_layout->addWidget(_frameLabel);
2015-04-13 02:48:29 +02:00
setLayout(_layout);
2014-02-12 07:42:07 +01:00
}
void ModelFramesWidget::setModel(Model *model, Skeleton* skeleton)
2014-02-12 07:42:07 +01:00
{
if(framemodel) {
delete framemodel;
framemodel = nullptr;
tree->setModel(nullptr);
}
gmodel = model;
if(model != nullptr) {
framemodel = new DFFFramesTreeModel(model, skeleton, this);
2014-02-12 07:42:07 +01:00
tree->setModel(framemodel);
2014-03-01 02:13:52 +01:00
tree->setDisabled(false);
2014-06-10 21:26:04 +02:00
connect(tree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
SLOT(selectedModelChanged(QModelIndex,QModelIndex)));
2014-02-12 07:42:07 +01:00
}
else {
tree->setDisabled(true);
}
}