Implement tool button actions
parent
9a6f0c39f8
commit
03a9be6d4f
|
@ -48,6 +48,19 @@ const SkeletonComponent *ComponentListModel::modelIndexToComponent(const QModelI
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dust3d::Uuid ComponentListModel::modelIndexToComponentId(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
const SkeletonComponent *listingComponent = m_document->findComponent(m_listingComponentId);
|
||||||
|
if (nullptr == listingComponent)
|
||||||
|
return dust3d::Uuid();
|
||||||
|
if (index.row() >= (int)listingComponent->childrenIds.size()) {
|
||||||
|
dust3dDebug << "Component list row is out of range, size:" << listingComponent->childrenIds.size() << "row:" << index.row();
|
||||||
|
return dust3d::Uuid();
|
||||||
|
}
|
||||||
|
const auto &componentId = listingComponent->childrenIds[index.row()];
|
||||||
|
return componentId;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant ComponentListModel::data(const QModelIndex &index, int role) const
|
QVariant ComponentListModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
const SkeletonComponent *modelIndexToComponent(const QModelIndex &index) const;
|
const SkeletonComponent *modelIndexToComponent(const QModelIndex &index) const;
|
||||||
|
const dust3d::Uuid modelIndexToComponentId(const QModelIndex &index) const;
|
||||||
const dust3d::Uuid listingComponentId() const;
|
const dust3d::Uuid listingComponentId() const;
|
||||||
public slots:
|
public slots:
|
||||||
void setListingComponentId(const dust3d::Uuid &componentId);
|
void setListingComponentId(const dust3d::Uuid &componentId);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "component_list_model.h"
|
#include "component_list_model.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
|
||||||
ComponentPreviewGridWidget::ComponentPreviewGridWidget(const Document *document, QWidget *parent):
|
ComponentPreviewGridWidget::ComponentPreviewGridWidget(Document *document, QWidget *parent):
|
||||||
PreviewGridView(parent),
|
PreviewGridView(parent),
|
||||||
m_document(document)
|
m_document(document)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,35 @@ std::vector<const SkeletonComponent *> ComponentPreviewGridWidget::getSelectedCo
|
||||||
std::vector<const SkeletonComponent *> components;
|
std::vector<const SkeletonComponent *> components;
|
||||||
QModelIndexList selected = selectionModel()->selectedIndexes();
|
QModelIndexList selected = selectionModel()->selectedIndexes();
|
||||||
for (const auto &it: selected) {
|
for (const auto &it: selected) {
|
||||||
components.push_back(m_componentListModel->modelIndexToComponent(it));
|
const auto &component = m_componentListModel->modelIndexToComponent(it);
|
||||||
|
if (nullptr == component)
|
||||||
|
continue;
|
||||||
|
components.push_back(component);
|
||||||
}
|
}
|
||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<dust3d::Uuid> ComponentPreviewGridWidget::getSelectedComponentIds() const
|
||||||
|
{
|
||||||
|
std::vector<dust3d::Uuid> componentIds;
|
||||||
|
QModelIndexList selected = selectionModel()->selectedIndexes();
|
||||||
|
for (const auto &it: selected) {
|
||||||
|
const auto &componentId = m_componentListModel->modelIndexToComponentId(it);
|
||||||
|
if (componentId.isNull())
|
||||||
|
continue;
|
||||||
|
componentIds.push_back(componentId);
|
||||||
|
}
|
||||||
|
return componentIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<dust3d::Uuid> ComponentPreviewGridWidget::getSelectedPartIds() const
|
||||||
|
{
|
||||||
|
auto selectedComponents = getSelectedComponents();
|
||||||
|
std::vector<dust3d::Uuid> partIds;
|
||||||
|
for (const auto &component: selectedComponents) {
|
||||||
|
if (component->linkToPartId.isNull())
|
||||||
|
continue;
|
||||||
|
partIds.push_back(component->linkToPartId);
|
||||||
|
}
|
||||||
|
return partIds;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define DUST3D_APPLICATION_COMPONENT_PREVIEW_GRID_WIDGET_H_
|
#define DUST3D_APPLICATION_COMPONENT_PREVIEW_GRID_WIDGET_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <dust3d/base/uuid.h>
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include "preview_grid_view.h"
|
#include "preview_grid_view.h"
|
||||||
|
|
||||||
|
@ -12,12 +13,14 @@ class SkeletonComponent;
|
||||||
class ComponentPreviewGridWidget: public PreviewGridView
|
class ComponentPreviewGridWidget: public PreviewGridView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComponentPreviewGridWidget(const Document *document, QWidget *parent=nullptr);
|
ComponentPreviewGridWidget(Document *document, QWidget *parent=nullptr);
|
||||||
ComponentListModel *componentListModel();
|
ComponentListModel *componentListModel();
|
||||||
std::vector<const SkeletonComponent *> getSelectedComponents() const;
|
std::vector<const SkeletonComponent *> getSelectedComponents() const;
|
||||||
|
std::vector<dust3d::Uuid> getSelectedComponentIds() const;
|
||||||
|
std::vector<dust3d::Uuid> getSelectedPartIds() const;
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<ComponentListModel> m_componentListModel;
|
std::unique_ptr<ComponentListModel> m_componentListModel;
|
||||||
const Document *m_document = nullptr;
|
Document *m_document = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
|
||||||
PartManageWidget::PartManageWidget(const Document *document, QWidget *parent):
|
PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_document(document)
|
m_document(document)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,50 @@ PartManageWidget::PartManageWidget(const Document *document, QWidget *parent):
|
||||||
this->m_componentPreviewGridWidget->componentListModel()->setListingComponentId(parent->id);
|
this->m_componentPreviewGridWidget->componentListModel()->setListingComponentId(parent->id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_hideButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartVisibleState(partId, false);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
connect(m_showButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartVisibleState(partId, true);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_unlockButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartLockState(partId, false);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
connect(m_lockButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartLockState(partId, true);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_unlinkButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartDisableState(partId, true);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
connect(m_linkButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &partId: m_componentPreviewGridWidget->getSelectedPartIds())
|
||||||
|
this->m_document->setPartDisableState(partId, false);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_removeButton, &QPushButton::clicked, [this]() {
|
||||||
|
for (const auto &componentId: m_componentPreviewGridWidget->getSelectedComponentIds())
|
||||||
|
this->m_document->removeComponent(componentId);
|
||||||
|
this->m_document->saveSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_document, &Document::partLockStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
|
connect(m_document, &Document::partVisibleStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
|
connect(m_document, &Document::partDisableStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
|
connect(m_document, &Document::componentChildrenChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(toolsLayout);
|
mainLayout->addLayout(toolsLayout);
|
||||||
mainLayout->addWidget(m_componentPreviewGridWidget);
|
mainLayout->addWidget(m_componentPreviewGridWidget);
|
||||||
|
|
|
@ -11,9 +11,9 @@ class PartManageWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PartManageWidget(const Document *document, QWidget *parent=nullptr);
|
PartManageWidget(Document *document, QWidget *parent=nullptr);
|
||||||
private:
|
private:
|
||||||
const Document *m_document = nullptr;
|
Document *m_document = nullptr;
|
||||||
ComponentPreviewGridWidget *m_componentPreviewGridWidget = nullptr;
|
ComponentPreviewGridWidget *m_componentPreviewGridWidget = nullptr;
|
||||||
QPushButton *m_levelUpButton = nullptr;
|
QPushButton *m_levelUpButton = nullptr;
|
||||||
QPushButton *m_lockButton = nullptr;
|
QPushButton *m_lockButton = nullptr;
|
||||||
|
|
|
@ -816,9 +816,9 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combinePartMesh(const std::st
|
||||||
mesh.reset();
|
mesh.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDisabled) {
|
//if (isDisabled) {
|
||||||
mesh.reset();
|
// mesh.reset();
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (target != PartTarget::Model) {
|
if (target != PartTarget::Model) {
|
||||||
mesh.reset();
|
mesh.reset();
|
||||||
|
@ -930,15 +930,17 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combineComponentMesh(const st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto &partCache = m_cacheContext->parts[partIdString];
|
const auto &partCache = m_cacheContext->parts[partIdString];
|
||||||
for (const auto &vertex: partCache.vertices)
|
if (partCache.joined) {
|
||||||
componentCache.noneSeamVertices.insert(vertex);
|
for (const auto &vertex: partCache.vertices)
|
||||||
collectSharedQuadEdges(partCache.vertices, partCache.faces, &componentCache.sharedQuadEdges);
|
componentCache.noneSeamVertices.insert(vertex);
|
||||||
for (const auto &it: partCache.objectNodes)
|
collectSharedQuadEdges(partCache.vertices, partCache.faces, &componentCache.sharedQuadEdges);
|
||||||
componentCache.objectNodes.push_back(it);
|
for (const auto &it: partCache.objectNodes)
|
||||||
for (const auto &it: partCache.objectEdges)
|
componentCache.objectNodes.push_back(it);
|
||||||
componentCache.objectEdges.push_back(it);
|
for (const auto &it: partCache.objectEdges)
|
||||||
for (const auto &it: partCache.objectNodeVertices)
|
componentCache.objectEdges.push_back(it);
|
||||||
componentCache.objectNodeVertices.push_back(it);
|
for (const auto &it: partCache.objectNodeVertices)
|
||||||
|
componentCache.objectNodeVertices.push_back(it);
|
||||||
|
}
|
||||||
ComponentPreview preview;
|
ComponentPreview preview;
|
||||||
if (mesh)
|
if (mesh)
|
||||||
mesh->fetch(preview.vertices, preview.triangles);
|
mesh->fetch(preview.vertices, preview.triangles);
|
||||||
|
@ -946,6 +948,10 @@ std::unique_ptr<MeshCombiner::Mesh> MeshGenerator::combineComponentMesh(const st
|
||||||
preview.metalness = partCache.metalness;
|
preview.metalness = partCache.metalness;
|
||||||
preview.roughness = partCache.roughness;
|
preview.roughness = partCache.roughness;
|
||||||
addComponentPreview(componentId, std::move(preview));
|
addComponentPreview(componentId, std::move(preview));
|
||||||
|
if (!partCache.joined) {
|
||||||
|
if (mesh)
|
||||||
|
mesh.reset();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::pair<CombineMode, std::vector<std::string>>> combineGroups;
|
std::vector<std::pair<CombineMode, std::vector<std::string>>> combineGroups;
|
||||||
int currentGroupIndex = -1;
|
int currentGroupIndex = -1;
|
||||||
|
|
Loading…
Reference in New Issue