Apply webkit style clang format on code base

master
Jeremy HU 2022-10-18 20:35:04 +11:00
parent 73f0404c2e
commit 57b1a802f3
213 changed files with 7933 additions and 8534 deletions

View File

@ -1,10 +1,10 @@
#include <QOpenGLFunctions>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QOpenGLFunctions>
#include "about_widget.h"
#include "version.h"
#include "model_widget.h"
#include "version.h"
AboutWidget::AboutWidget()
{

View File

@ -3,8 +3,7 @@
#include <QDialog>
class AboutWidget : public QDialog
{
class AboutWidget : public QDialog {
Q_OBJECT
public:
AboutWidget();

View File

@ -1,9 +1,9 @@
#include <QtGlobal>
#include <QMatrix4x4>
#include <QDebug>
#include <cmath>
#include <QtMath>
#include "ccd_ik_resolver.h"
#include <QDebug>
#include <QMatrix4x4>
#include <QtGlobal>
#include <QtMath>
#include <cmath>
CcdIkSolver::CcdIkSolver()
{
@ -113,10 +113,8 @@ void CcdIkSolver::iterate()
continue;
const auto& parent = m_nodes[parentIndex];
const auto& child = m_nodes[childIndex];
QVector3D angleFrom = (QVector3D(0.0, parent.position.y(), parent.position.z()) -
QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
QVector3D angleTo = (QVector3D(0.0, child.position.y(), child.position.z()) -
QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
QVector3D angleFrom = (QVector3D(0.0, parent.position.y(), parent.position.z()) - QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
QVector3D angleTo = (QVector3D(0.0, child.position.y(), child.position.z()) - QVector3D(0.0, origin.position.y(), origin.position.z())).normalized();
float degrees = angleInRangle360BetweenTwoVectors(angleFrom, angleTo, QVector3D(1.0, 0.0, 0.0));
if (degrees < origin.minLimitDegrees) {
auto quaternion = QQuaternion::fromAxisAndAngle(QVector3D(1.0, 0.0, 0.0), origin.minLimitDegrees - degrees);

View File

@ -1,20 +1,18 @@
#ifndef DUST3D_APPLICATION_CCD_IK_SOLVER_H_
#define DUST3D_APPLICATION_CCD_IK_SOLVER_H_
#include <vector>
#include <QVector3D>
#include <QQuaternion>
#include <QVector3D>
#include <vector>
struct CcdIkNode
{
struct CcdIkNode {
QVector3D position;
QVector3D axis;
double minLimitDegrees;
double maxLimitDegrees;
};
class CcdIkSolver
{
class CcdIkSolver {
public:
CcdIkSolver();
void setMaxRound(int maxRound);
@ -26,6 +24,7 @@ public:
void setNodeHingeConstraint(int nodeIndex,
const QVector3D& axis, double minLimitDegrees, double maxLimitDegrees);
void setSolveFrom(int fromNodeIndex);
private:
float angleInRangle360BetweenTwoVectors(QVector3D a, QVector3D b, QVector3D planeNormal);
void iterate();

View File

@ -1,11 +1,11 @@
#include <QAbstractListModel>
#include <dust3d/base/debug.h>
#include "component_list_model.h"
#include "document.h"
#include <QAbstractListModel>
#include <dust3d/base/debug.h>
ComponentListModel::ComponentListModel(const Document *document, QObject *parent):
QAbstractListModel(parent),
m_document(document)
ComponentListModel::ComponentListModel(const Document* document, QObject* parent)
: QAbstractListModel(parent)
, m_document(document)
{
connect(m_document, &Document::componentPreviewPixmapChanged, [this](const dust3d::Uuid& componentId) {
auto findIndex = this->m_componentIdToIndexMap.find(componentId);
@ -103,8 +103,7 @@ QVariant ComponentListModel::data(const QModelIndex &index, int role) const
if (nullptr != component) {
return component->name;
}
}
break;
} break;
case Qt::DecorationRole: {
const SkeletonComponent* component = modelIndexToComponent(index);
if (nullptr != component) {
@ -119,8 +118,7 @@ QVariant ComponentListModel::data(const QModelIndex &index, int role) const
}
return component->previewPixmap;
}
}
break;
} break;
}
return QVariant();
}

View File

@ -1,18 +1,18 @@
#ifndef DUST3D_APPLICATION_COMPONENT_LIST_MODEL_H_
#define DUST3D_APPLICATION_COMPONENT_LIST_MODEL_H_
#include <unordered_map>
#include <dust3d/base/uuid.h>
#include <QAbstractListModel>
#include <dust3d/base/uuid.h>
#include <unordered_map>
class Document;
class SkeletonComponent;
class ComponentListModel: public QAbstractListModel
{
class ComponentListModel : public QAbstractListModel {
Q_OBJECT
signals:
void listingComponentChanged(const dust3d::Uuid& componentId);
public:
ComponentListModel(const Document* document, QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const;
@ -25,6 +25,7 @@ public:
public slots:
void setListingComponentId(const dust3d::Uuid& componentId);
void reload();
private:
const Document* m_document = nullptr;
dust3d::Uuid m_listingComponentId;

View File

@ -1,11 +1,11 @@
#include <memory>
#include "component_preview_grid_widget.h"
#include "component_list_model.h"
#include "document.h"
#include <memory>
ComponentPreviewGridWidget::ComponentPreviewGridWidget(Document *document, QWidget *parent):
PreviewGridView(parent),
m_document(document)
ComponentPreviewGridWidget::ComponentPreviewGridWidget(Document* document, QWidget* parent)
: PreviewGridView(parent)
, m_document(document)
{
m_componentListModel = std::make_unique<ComponentListModel>(m_document);
setModel(m_componentListModel.get());

View File

@ -1,27 +1,28 @@
#ifndef DUST3D_APPLICATION_COMPONENT_PREVIEW_GRID_WIDGET_H_
#define DUST3D_APPLICATION_COMPONENT_PREVIEW_GRID_WIDGET_H_
#include <memory>
#include <dust3d/base/uuid.h>
#include <QAbstractListModel>
#include "preview_grid_view.h"
#include "component_list_model.h"
#include "preview_grid_view.h"
#include <QAbstractListModel>
#include <dust3d/base/uuid.h>
#include <memory>
class Document;
class SkeletonComponent;
class ComponentPreviewGridWidget: public PreviewGridView
{
class ComponentPreviewGridWidget : public PreviewGridView {
Q_OBJECT
signals:
void unselectAllOnCanvas();
void selectPartOnCanvas(const dust3d::Uuid& partId);
public:
ComponentPreviewGridWidget(Document* document, QWidget* parent = nullptr);
ComponentListModel* componentListModel();
std::vector<const SkeletonComponent*> getSelectedComponents() const;
std::vector<dust3d::Uuid> getSelectedComponentIds() const;
std::vector<dust3d::Uuid> getSelectedPartIds() const;
private:
std::unique_ptr<ComponentListModel> m_componentListModel;
Document* m_document = nullptr;

View File

@ -1,7 +1,7 @@
#include <dust3d/base/debug.h>
#include <QPainter>
#include "theme.h"
#include "component_preview_images_decorator.h"
#include "theme.h"
#include <QPainter>
#include <dust3d/base/debug.h>
ComponentPreviewImagesDecorator::ComponentPreviewImagesDecorator(std::unique_ptr<std::vector<PreviewInput>> previewInputs)
{

View File

@ -1,17 +1,15 @@
#ifndef DUST3D_APPLICATION_COMPONENT_PREVIEW_IMAGES_DECORATOR_H_
#define DUST3D_APPLICATION_COMPONENT_PREVIEW_IMAGES_DECORATOR_H_
#include <QImage>
#include <dust3d/base/uuid.h>
#include <memory>
#include <unordered_map>
#include <dust3d/base/uuid.h>
#include <QImage>
class ComponentPreviewImagesDecorator: public QObject
{
class ComponentPreviewImagesDecorator : public QObject {
Q_OBJECT
public:
struct PreviewInput
{
struct PreviewInput {
dust3d::Uuid id;
std::unique_ptr<QImage> image;
bool isDirectory = false;
@ -23,6 +21,7 @@ signals:
void finished();
public slots:
void process();
private:
std::unique_ptr<std::vector<PreviewInput>> m_previewInputs;
std::unique_ptr<std::unordered_map<dust3d::Uuid, std::unique_ptr<QImage>>> m_resultImages;

View File

@ -1,20 +1,20 @@
#include <unordered_set>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include "component_property_widget.h"
#include "document.h"
#include "float_number_widget.h"
#include "theme.h"
#include <QColorDialog>
#include <QGroupBox>
#include "component_property_widget.h"
#include "float_number_widget.h"
#include "document.h"
#include "theme.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QVBoxLayout>
#include <unordered_set>
ComponentPropertyWidget::ComponentPropertyWidget(Document* document,
const std::vector<dust3d::Uuid>& componentIds,
QWidget *parent):
QWidget(parent),
m_document(document),
m_componentIds(componentIds)
QWidget* parent)
: QWidget(parent)
, m_document(document)
, m_componentIds(componentIds)
{
preparePartIds();
m_color = lastColor();

View File

@ -1,14 +1,13 @@
#ifndef DUST3D_APPLICATION_COMPONENT_PROPERTY_WIDGET_H_
#define DUST3D_APPLICATION_COMPONENT_PROPERTY_WIDGET_H_
#include <dust3d/base/uuid.h>
#include <QWidget>
#include <dust3d/base/uuid.h>
class Document;
class SkeletonPart;
class ComponentPropertyWidget: public QWidget
{
class ComponentPropertyWidget : public QWidget {
Q_OBJECT
signals:
void beginColorPicking();
@ -22,12 +21,14 @@ signals:
void setPartRoundState(const dust3d::Uuid& partId, bool rounded);
void setPartCutRotation(const dust3d::Uuid& partId, float cutRotation);
void groupOperationAdded();
public:
ComponentPropertyWidget(Document* document,
const std::vector<dust3d::Uuid>& componentIds,
QWidget* parent = nullptr);
public slots:
void showColorDialog();
private:
Document* m_document = nullptr;
std::vector<dust3d::Uuid> m_componentIds;

View File

@ -1,7 +1,7 @@
#include <QPainter>
#include <QPainterPath>
#include "cut_face_preview.h"
#include "theme.h"
#include <QPainter>
#include <QPainterPath>
static std::map<int, QImage*> g_standardCutFaceMap;

View File

@ -1,10 +1,10 @@
#include <QtGlobal>
#include <QFile>
#include <QDebug>
#include <QtEndian>
#include <QByteArray>
#include <QOpenGLPixelTransferOptions>
#include "dds_file.h"
#include <QByteArray>
#include <QDebug>
#include <QFile>
#include <QOpenGLPixelTransferOptions>
#include <QtEndian>
#include <QtGlobal>
#ifndef _WIN32
typedef quint32 DWORD;
@ -366,8 +366,8 @@ typedef struct {
DDS_HEADER_DXT10 header10;
} DDS_FILE_HEADER;
DdsFileReader::DdsFileReader(const QString &filename) :
m_filename(filename)
DdsFileReader::DdsFileReader(const QString& filename)
: m_filename(filename)
{
}

View File

@ -1,16 +1,16 @@
#ifndef DUST3D_APPLICATION_DDS_FILE_H_
#define DUST3D_APPLICATION_DDS_FILE_H_
#include <memory>
#include <QString>
#include <QOpenGLTexture>
#include <QString>
#include <memory>
class DdsFileReader
{
class DdsFileReader {
public:
DdsFileReader(const QString& filename);
QOpenGLTexture* createOpenGLTexture();
std::unique_ptr<std::vector<std::unique_ptr<QOpenGLTexture>>> createOpenGLTextures();
private:
QString m_filename;
};

View File

@ -1,28 +1,28 @@
#include <QFileDialog>
#include <QDebug>
#include <QThread>
#include <QGuiApplication>
#include <QClipboard>
#include <QMimeData>
#include <QApplication>
#include <QVector3D>
#include <functional>
#include <QtCore/qbuffer.h>
#include <QElapsedTimer>
#include <queue>
#include <dust3d/base/snapshot_xml.h>
#include <dust3d/base/texture_type.h>
#include "document.h"
#include "image_forever.h"
#include "material_previews_generator.h"
#include "mesh_generator.h"
#include "mesh_result_post_processor.h"
#include "texture_generator.h"
#include "material_previews_generator.h"
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QElapsedTimer>
#include <QFileDialog>
#include <QGuiApplication>
#include <QMimeData>
#include <QThread>
#include <QVector3D>
#include <QtCore/qbuffer.h>
#include <dust3d/base/snapshot_xml.h>
#include <dust3d/base/texture_type.h>
#include <functional>
#include <queue>
unsigned long Document::m_maxSnapshot = 1000;
Document::Document() :
SkeletonDocument()
Document::Document()
: SkeletonDocument()
{
}
@ -104,8 +104,7 @@ void Document::setNodeCutFaceLinkedId(dust3d::Uuid nodeId, dust3d::Uuid linkedId
qDebug() << "Node not found:" << nodeId;
return;
}
if (node->second.cutFace == dust3d::CutFace::UserDefined &&
node->second.cutFaceLinkedId == linkedId)
if (node->second.cutFace == dust3d::CutFace::UserDefined && node->second.cutFaceLinkedId == linkedId)
return;
node->second.setCutFaceLinkedId(linkedId);
auto part = partMap.find(node->second.partId);
@ -207,8 +206,7 @@ void Document::toSnapshot(dust3d::Snapshot *snapshot, const std::set<dust3d::Uui
DocumentToSnapshotFor forWhat,
const std::set<dust3d::Uuid>& limitMaterialIds) const
{
if (DocumentToSnapshotFor::Document == forWhat ||
DocumentToSnapshotFor::Nodes == forWhat) {
if (DocumentToSnapshotFor::Document == forWhat || DocumentToSnapshotFor::Nodes == forWhat) {
std::set<dust3d::Uuid> limitPartIds;
std::set<dust3d::Uuid> limitComponentIds;
for (const auto& nodeId : limitNodeIds) {
@ -308,9 +306,7 @@ void Document::toSnapshot(dust3d::Snapshot *snapshot, const std::set<dust3d::Uui
for (const auto& edgeIt : edgeMap) {
if (edgeIt.second.nodeIds.size() != 2)
continue;
if (!limitNodeIds.empty() &&
(limitNodeIds.find(edgeIt.second.nodeIds[0]) == limitNodeIds.end() ||
limitNodeIds.find(edgeIt.second.nodeIds[1]) == limitNodeIds.end()))
if (!limitNodeIds.empty() && (limitNodeIds.find(edgeIt.second.nodeIds[0]) == limitNodeIds.end() || limitNodeIds.find(edgeIt.second.nodeIds[1]) == limitNodeIds.end()))
continue;
std::map<std::string, std::string> edge;
edge["id"] = edgeIt.second.id.toString();
@ -357,8 +353,7 @@ void Document::toSnapshot(dust3d::Snapshot *snapshot, const std::set<dust3d::Uui
snapshot->rootComponent["children"] = children;
}
}
if (DocumentToSnapshotFor::Document == forWhat ||
DocumentToSnapshotFor::Materials == forWhat) {
if (DocumentToSnapshotFor::Document == forWhat || DocumentToSnapshotFor::Materials == forWhat) {
for (const auto& materialId : materialIdList) {
if (!limitMaterialIds.empty() && limitMaterialIds.find(materialId) == limitMaterialIds.end())
continue;
@ -403,14 +398,11 @@ void Document::toSnapshot(dust3d::Snapshot *snapshot, const std::set<dust3d::Uui
void Document::addFromSnapshot(const dust3d::Snapshot& snapshot, enum SnapshotSource source)
{
bool isOriginChanged = false;
if (SnapshotSource::Paste != source &&
SnapshotSource::Import != source) {
if (SnapshotSource::Paste != source && SnapshotSource::Import != source) {
const auto& originXit = snapshot.canvas.find("originX");
const auto& originYit = snapshot.canvas.find("originY");
const auto& originZit = snapshot.canvas.find("originZ");
if (originXit != snapshot.canvas.end() &&
originYit != snapshot.canvas.end() &&
originZit != snapshot.canvas.end()) {
if (originXit != snapshot.canvas.end() && originYit != snapshot.canvas.end() && originZit != snapshot.canvas.end()) {
setOriginX(dust3d::String::toFloat(originXit->second));
setOriginY(dust3d::String::toFloat(originYit->second));
setOriginZ(dust3d::String::toFloat(originZit->second));
@ -550,11 +542,7 @@ void Document::addFromSnapshot(const dust3d::Snapshot &snapshot, enum SnapshotSo
}
}
for (const auto& nodeKv : snapshot.nodes) {
if (nodeKv.second.find("radius") == nodeKv.second.end() ||
nodeKv.second.find("x") == nodeKv.second.end() ||
nodeKv.second.find("y") == nodeKv.second.end() ||
nodeKv.second.find("z") == nodeKv.second.end() ||
nodeKv.second.find("partId") == nodeKv.second.end())
if (nodeKv.second.find("radius") == nodeKv.second.end() || nodeKv.second.find("x") == nodeKv.second.end() || nodeKv.second.find("y") == nodeKv.second.end() || nodeKv.second.find("z") == nodeKv.second.end() || nodeKv.second.find("partId") == nodeKv.second.end())
continue;
dust3d::Uuid oldNodeId = dust3d::Uuid(nodeKv.first);
SkeletonNode node(nodeMap.find(oldNodeId) == nodeMap.end() ? oldNodeId : dust3d::Uuid::createUuid());
@ -589,9 +577,7 @@ void Document::addFromSnapshot(const dust3d::Snapshot &snapshot, enum SnapshotSo
newAddedNodeIds.insert(node.id);
}
for (const auto& edgeKv : snapshot.edges) {
if (edgeKv.second.find("from") == edgeKv.second.end() ||
edgeKv.second.find("to") == edgeKv.second.end() ||
edgeKv.second.find("partId") == edgeKv.second.end())
if (edgeKv.second.find("from") == edgeKv.second.end() || edgeKv.second.find("to") == edgeKv.second.end() || edgeKv.second.find("partId") == edgeKv.second.end())
continue;
dust3d::Uuid oldEdgeId = dust3d::Uuid(edgeKv.first);
SkeletonEdge edge(edgeMap.find(oldEdgeId) == edgeMap.end() ? oldEdgeId : dust3d::Uuid::createUuid());
@ -1330,8 +1316,7 @@ void Document::setPartCutFaceLinkedId(dust3d::Uuid partId, dust3d::Uuid linkedId
qDebug() << "Part not found:" << partId;
return;
}
if (part->second.cutFace == dust3d::CutFace::UserDefined &&
part->second.cutFaceLinkedId == linkedId)
if (part->second.cutFace == dust3d::CutFace::UserDefined && part->second.cutFaceLinkedId == linkedId)
return;
part->second.setCutFaceLinkedId(linkedId);
part->second.dirty = true;
@ -1459,14 +1444,10 @@ bool Document::isEdgeEditable(dust3d::Uuid edgeId) const
bool Document::isExportReady() const
{
if (m_meshGenerator ||
m_textureGenerator ||
m_postProcessor)
if (m_meshGenerator || m_textureGenerator || m_postProcessor)
return false;
if (m_isResultMeshObsolete ||
m_isTextureObsolete ||
m_isPostProcessResultObsolete)
if (m_isResultMeshObsolete || m_isTextureObsolete || m_isPostProcessResultObsolete)
return false;
return true;

View File

@ -1,38 +1,36 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_H_
#define DUST3D_APPLICATION_DOCUMENT_H_
#include <QObject>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <QImage>
#include <cmath>
#include <algorithm>
#include <QPolygon>
#include <dust3d/base/uuid.h>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/combine_mode.h>
#include "material_layer.h"
#include "model_mesh.h"
#include "monochrome_mesh.h"
#include "theme.h"
#include "skeleton_document.h"
#include "material_layer.h"
#include "theme.h"
#include <QImage>
#include <QObject>
#include <QPolygon>
#include <algorithm>
#include <cmath>
#include <deque>
#include <dust3d/base/combine_mode.h>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/uuid.h>
#include <map>
#include <set>
#include <vector>
class MaterialPreviewsGenerator;
class TextureGenerator;
class MeshGenerator;
class MeshResultPostProcessor;
class HistoryItem
{
class HistoryItem {
public:
dust3d::Snapshot snapshot;
};
class Material
{
class Material {
public:
Material()
{
@ -56,20 +54,19 @@ public:
return nullptr;
return new ModelMesh(*m_previewMesh);
}
private:
Q_DISABLE_COPY(Material);
ModelMesh* m_previewMesh = nullptr;
};
enum class DocumentToSnapshotFor
{
enum class DocumentToSnapshotFor {
Document = 0,
Nodes,
Materials
};
class Document : public SkeletonDocument
{
class Document : public SkeletonDocument {
Q_OBJECT
signals:
void nodeCutRotationChanged(dust3d::Uuid nodeId);
@ -121,6 +118,7 @@ signals:
void postProcessing();
void textureGenerating();
void textureChanged();
public: // need initialize
QImage* textureImage = nullptr;
QByteArray* textureImageByteArray = nullptr;
@ -135,6 +133,7 @@ public: // need initialize
bool weldEnabled = true;
float brushMetalness = ModelMesh::m_defaultMetalness;
float brushRoughness = ModelMesh::m_defaultRoughness;
public:
Document();
~Document();
@ -152,8 +151,7 @@ public:
DocumentToSnapshotFor forWhat = DocumentToSnapshotFor::Document,
const std::set<dust3d::Uuid>& limitMaterialIds = std::set<dust3d::Uuid>()) const;
void fromSnapshot(const dust3d::Snapshot& snapshot);
enum class SnapshotSource
{
enum class SnapshotSource {
Unknown,
Paste,
Import
@ -233,6 +231,7 @@ public slots:
void removeMaterial(dust3d::Uuid materialId);
void setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(dust3d::Uuid materialId, QString name);
private:
void resolveSnapshotBoundingBox(const dust3d::Snapshot& snapshot, QRectF* mainProfile, QRectF* sideProfile);
void settleOrigin();
@ -257,6 +256,7 @@ private:
quint64 m_meshGenerationId = 0;
quint64 m_nextMeshGenerationId = 0;
void* m_generatedCacheContext = nullptr;
private:
static unsigned long m_maxSnapshot;
std::deque<HistoryItem> m_undoItems;

View File

@ -1,17 +1,17 @@
#include <set>
#include "document_saver.h"
#include "image_forever.h"
#include <QGuiApplication>
#include <QtCore/qbuffer.h>
#include <dust3d/base/ds3_file.h>
#include <dust3d/base/snapshot_xml.h>
#include "document_saver.h"
#include "image_forever.h"
#include <set>
DocumentSaver::DocumentSaver(const QString* filename,
dust3d::Snapshot* snapshot,
QByteArray *turnaroundPngByteArray) :
m_filename(filename),
m_snapshot(snapshot),
m_turnaroundPngByteArray(turnaroundPngByteArray)
QByteArray* turnaroundPngByteArray)
: m_filename(filename)
, m_snapshot(snapshot)
, m_turnaroundPngByteArray(turnaroundPngByteArray)
{
}

View File

@ -1,16 +1,15 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_SAVER_H_
#define DUST3D_APPLICATION_DOCUMENT_SAVER_H_
#include <QString>
#include <QObject>
#include <QByteArray>
#include <QObject>
#include <QString>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/uuid.h>
#include <map>
#include <set>
#include <dust3d/base/uuid.h>
#include <dust3d/base/snapshot.h>
class DocumentSaver : public QObject
{
class DocumentSaver : public QObject {
Q_OBJECT
public:
DocumentSaver(const QString* filename,
@ -26,6 +25,7 @@ signals:
void finished();
public slots:
void process();
private:
const QString* m_filename = nullptr;
dust3d::Snapshot* m_snapshot = nullptr;

View File

@ -1,53 +1,53 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QGridLayout>
#include <QToolBar>
#include <QPushButton>
#include <QFileDialog>
#include <QTabWidget>
#include <QtCore/qbuffer.h>
#include <QMessageBox>
#include <QTimer>
#include <QMenuBar>
#include <QPointer>
#include "document_window.h"
#include "about_widget.h"
#include "cut_face_preview.h"
#include "document.h"
#include "document_saver.h"
#include "fbx_file.h"
#include "float_number_widget.h"
#include "flow_layout.h"
#include "glb_file.h"
#include "horizontal_line_widget.h"
#include "image_forever.h"
#include "log_browser.h"
#include "material_manage_widget.h"
#include "part_manage_widget.h"
#include "preferences.h"
#include "skeleton_graphics_widget.h"
#include "spinnable_toolbar_icon.h"
#include "texture_generator.h"
#include "theme.h"
#include "updates_check_widget.h"
#include "version.h"
#include <QApplication>
#include <map>
#include <QDesktopServices>
#include <QDockWidget>
#include <QWidgetAction>
#include <QGraphicsOpacityEffect>
#include <QDir>
#include <QDockWidget>
#include <QFileDialog>
#include <QFileInfo>
#include <QFormLayout>
#include <QTextBrowser>
#include <QGraphicsOpacityEffect>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QMenuBar>
#include <QMessageBox>
#include <QMimeData>
#include <QPixmap>
#include <QPointer>
#include <QPushButton>
#include <QTabWidget>
#include <QTextBrowser>
#include <QTimer>
#include <QToolBar>
#include <QVBoxLayout>
#include <QWidgetAction>
#include <QtCore/qbuffer.h>
#include <dust3d/base/debug.h>
#include <dust3d/base/ds3_file.h>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/snapshot_xml.h>
#include <dust3d/base/debug.h>
#include "document_window.h"
#include "skeleton_graphics_widget.h"
#include "theme.h"
#include "log_browser.h"
#include "about_widget.h"
#include "version.h"
#include "glb_file.h"
#include "part_manage_widget.h"
#include "material_manage_widget.h"
#include "image_forever.h"
#include "spinnable_toolbar_icon.h"
#include "fbx_file.h"
#include "float_number_widget.h"
#include "updates_check_widget.h"
#include "document_saver.h"
#include "document.h"
#include "preferences.h"
#include "flow_layout.h"
#include "cut_face_preview.h"
#include "horizontal_line_widget.h"
#include "texture_generator.h"
#include <map>
LogBrowser* g_logBrowser = nullptr;
std::map<DocumentWindow*, dust3d::Uuid> g_documentWindows;
@ -63,7 +63,8 @@ void outputMessage(QtMsgType type, const QMessageLogContext &context, const QStr
g_logBrowser->outputMessage(type, msg, context.file, context.line);
}
void ensureFileExtension(QString* filename, const QString extension) {
void ensureFileExtension(QString* filename, const QString extension)
{
if (!filename->endsWith(extension)) {
filename->append(extension);
}
@ -219,7 +220,6 @@ DocumentWindow::DocumentWindow()
toolButtonLayout->addSpacing(20);
toolButtonLayout->addWidget(m_inprogressIndicator);
QLabel* verticalLogoLabel = new QLabel;
QImage verticalLogoImage;
verticalLogoImage.load(":/resources/dust3d-vertical.png");
@ -693,11 +693,7 @@ DocumentWindow::DocumentWindow()
void DocumentWindow::updateInprogressIndicator()
{
bool inprogress = m_document->isMeshGenerating() ||
m_document->isPostProcessing() ||
m_document->isTextureGenerating() ||
nullptr != m_componentPreviewImagesGenerator ||
nullptr != m_componentPreviewImagesDecorator;
bool inprogress = m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating() || nullptr != m_componentPreviewImagesGenerator || nullptr != m_componentPreviewImagesDecorator;
if (inprogress == m_inprogressIndicator->isSpinning())
return;
m_inprogressIndicator->showSpinner(inprogress);
@ -886,7 +882,8 @@ void DocumentWindow::mousePressEvent(QMouseEvent *event)
void DocumentWindow::changeTurnaround()
{
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
tr("Image Files (*.png *.jpg *.bmp)")).trimmed();
tr("Image Files (*.png *.jpg *.bmp)"))
.trimmed();
if (fileName.isEmpty())
return;
QImage image;
@ -918,8 +915,7 @@ void DocumentWindow::saveTo(const QString &saveAsFilename)
m_document->toSnapshot(&snapshot);
if (DocumentSaver::save(&filename,
&snapshot,
(!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) ?
&m_document->turnaroundPngByteArray : nullptr)) {
(!m_document->turnaround.isNull() && m_document->turnaroundPngByteArray.size() > 0) ? &m_document->turnaroundPngByteArray : nullptr)) {
setCurrentFilename(filename);
}
QApplication::restoreOverrideCursor();
@ -1093,8 +1089,7 @@ void DocumentWindow::exportGlbToFilename(const QString &filename)
}
QApplication::setOverrideCursor(Qt::WaitCursor);
dust3d::Object skeletonResult = m_document->currentPostProcessedObject();
QImage *textureMetalnessRoughnessAmbientOcclusionImage =
TextureGenerator::combineMetalnessRoughnessAmbientOcclusionImages(m_document->textureMetalnessImage,
QImage* textureMetalnessRoughnessAmbientOcclusionImage = TextureGenerator::combineMetalnessRoughnessAmbientOcclusionImages(m_document->textureMetalnessImage,
m_document->textureRoughnessImage,
m_document->textureAmbientOcclusionImage);
GlbFileWriter glbFileWriter(skeletonResult, filename,
@ -1246,8 +1241,7 @@ void DocumentWindow::decorateComponentPreviewImages()
previewInputs->emplace_back(ComponentPreviewImagesDecorator::PreviewInput {
component.first,
std::make_unique<QImage>(*component.second.previewImage),
!component.second.childrenIds.empty()
});
!component.second.childrenIds.empty() });
}
m_componentPreviewImagesDecorator = std::make_unique<ComponentPreviewImagesDecorator>(std::move(previewInputs));
m_componentPreviewImagesDecorator->moveToThread(thread);
@ -1402,9 +1396,7 @@ void DocumentWindow::toggleRenderColor()
{
m_modelRemoveColor = !m_modelRemoveColor;
ModelMesh* mesh = nullptr;
if (m_document->isMeshGenerating() ||
m_document->isPostProcessing() ||
m_document->isTextureGenerating()) {
if (m_document->isMeshGenerating() || m_document->isPostProcessing() || m_document->isTextureGenerating()) {
mesh = m_document->takeResultMesh();
} else {
mesh = m_document->takeResultTextureMesh();

View File

@ -1,21 +1,21 @@
#ifndef DUST3D_APPLICATION_DOCUMENT_WINDOW_H_
#define DUST3D_APPLICATION_DOCUMENT_WINDOW_H_
#include <memory>
#include <QMainWindow>
#include <QShowEvent>
#include <QPushButton>
#include <QString>
#include <QMenu>
#include <QAction>
#include <map>
#include <QStringList>
#include <QLabel>
#include <QShortcut>
#include "model_widget.h"
#include "component_preview_images_decorator.h"
#include "graphics_container_widget.h"
#include "mesh_preview_images_generator.h"
#include "component_preview_images_decorator.h"
#include "model_widget.h"
#include <QAction>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
#include <QPushButton>
#include <QShortcut>
#include <QShowEvent>
#include <QString>
#include <QStringList>
#include <map>
#include <memory>
class Document;
class SkeletonGraphicsWidget;
@ -23,14 +23,14 @@ class PartManageWidget;
class ToolbarButton;
class SpinnableToolbarIcon;
class DocumentWindow : public QMainWindow
{
class DocumentWindow : public QMainWindow {
Q_OBJECT
signals:
void initialized();
void uninialized();
void waitingExportFinished(const QString& filename, bool isSuccessful);
void workingStatusChanged(bool isWorking);
public:
DocumentWindow();
~DocumentWindow();
@ -44,6 +44,7 @@ public:
static void showSupporters();
static void showAbout();
static size_t total();
protected:
void showEvent(QShowEvent* event);
void closeEvent(QCloseEvent* event);
@ -92,6 +93,7 @@ public slots:
void openRecentFile();
void updateRecentFileActions();
void toggleRenderColor();
private:
void setCurrentFilename(const QString& filename);
void updateTitle();
@ -176,4 +178,3 @@ private:
};
#endif

View File

@ -1,13 +1,13 @@
#include "fbx_file.h"
#include "document.h"
#include "version.h"
#include <QByteArray>
#include <QDateTime>
#include <QFileInfo>
#include <QtCore/qbuffer.h>
#include <QtMath>
#include <fbxnode.h>
#include <fbxproperty.h>
#include <QDateTime>
#include <QtMath>
#include <QtCore/qbuffer.h>
#include <QByteArray>
#include <QFileInfo>
#include "fbx_file.h"
#include "version.h"
#include "document.h"
using namespace fbx;
@ -2204,9 +2204,9 @@ FbxFileWriter::FbxFileWriter(dust3d::Object &object,
QImage* normalImage,
QImage* metalnessImage,
QImage* roughnessImage,
QImage *ambientOcclusionImage) :
m_filename(filename),
m_baseName(QFileInfo(m_filename).baseName())
QImage* ambientOcclusionImage)
: m_filename(filename)
, m_baseName(QFileInfo(m_filename).baseName())
{
createFbxHeader();
createFileId();
@ -2402,8 +2402,7 @@ FbxFileWriter::FbxFileWriter(dust3d::Object &object,
int64_t skinId = 0;
int64_t armatureId = 0;
if (deformerCount > 0)
{
if (deformerCount > 0) {
poseId = m_next64Id++;
pose.addProperty(poseId);
pose.addProperty(std::vector<uint8_t>({ 'u', 'n', 'a', 'm', 'e', 'd', 0, 1, 'P', 'o', 's', 'e' }), 'S');
@ -3315,8 +3314,7 @@ FbxFileWriter::FbxFileWriter(dust3d::Object &object,
p.addProperty((int64_t)0);
connections.addChild(p);
}
if (armatureId > 0)
{
if (armatureId > 0) {
FBXNode p("C");
p.addProperty("OO");
p.addProperty(armatureId);
@ -3330,8 +3328,7 @@ FbxFileWriter::FbxFileWriter(dust3d::Object &object,
p.addProperty(modelId);
connections.addChild(p);
}
if (skinId > 0)
{
if (skinId > 0) {
FBXNode p("C");
p.addProperty("OO");
p.addProperty(skinId);

View File

@ -1,16 +1,15 @@
#ifndef DUST3D_APPLICATION_FBX_FILE_H_
#define DUST3D_APPLICATION_FBX_FILE_H_
#include <map>
#include <QString>
#include "fbxdocument.h"
#include <QImage>
#include <QMatrix4x4>
#include <QQuaternion>
#include <QImage>
#include <QString>
#include <dust3d/base/object.h>
#include "fbxdocument.h"
#include <map>
class FbxFileWriter : public QObject
{
class FbxFileWriter : public QObject {
Q_OBJECT
public:
FbxFileWriter(dust3d::Object& object,
@ -51,4 +50,3 @@ private:
};
#endif

View File

@ -1,11 +1,11 @@
#include <QtWidgets>
#include "float_number_widget.h"
#include "theme.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "float_number_widget.h"
#include <QtWidgets>
FloatNumberWidget::FloatNumberWidget(QWidget *parent, bool singleLine) :
QWidget(parent)
FloatNumberWidget::FloatNumberWidget(QWidget* parent, bool singleLine)
: QWidget(parent)
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100);

View File

@ -6,8 +6,7 @@
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSlider)
class FloatNumberWidget : public QWidget
{
class FloatNumberWidget : public QWidget {
Q_OBJECT
public:
explicit FloatNumberWidget(QWidget* parent = nullptr, bool singleLine = true);

View File

@ -53,13 +53,16 @@
#include "flow_layout.h"
FlowLayout::FlowLayout(QWidget* parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
: QLayout(parent)
, m_hSpace(hSpacing)
, m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: m_hSpace(hSpacing), m_vSpace(vSpacing)
: m_hSpace(hSpacing)
, m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}

View File

@ -55,8 +55,7 @@
#include <QRect>
#include <QStyle>
class FlowLayout : public QLayout
{
class FlowLayout : public QLayout {
public:
explicit FlowLayout(QWidget* parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);

View File

@ -1,13 +1,13 @@
#include <QFile>
#include <QQuaternion>
#include "glb_file.h"
#include "model_mesh.h"
#include "version.h"
#include <QByteArray>
#include <QDataStream>
#include <QFileInfo>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QQuaternion>
#include <QtCore/qbuffer.h>
#include "glb_file.h"
#include "version.h"
#include "model_mesh.h"
bool GlbFileWriter::m_enableComment = false;
@ -15,8 +15,8 @@ GlbFileWriter::GlbFileWriter(dust3d::Object &object,
const QString& filename,
QImage* textureImage,
QImage* normalImage,
QImage *ormImage) :
m_filename(filename)
QImage* ormImage)
: m_filename(filename)
{
const std::vector<std::vector<dust3d::Vector3>>* triangleVertexNormals = object.triangleVertexNormals();
if (m_outputNormal) {
@ -291,9 +291,7 @@ bool GlbFileWriter::save()
uint32_t headerSize = 12;
uint32_t chunk0DescriptionSize = 8;
uint32_t chunk1DescriptionSize = 8;
uint32_t fileSize = headerSize +
chunk0DescriptionSize + m_jsonByteArray.size() +
chunk1DescriptionSize + m_binByteArray.size();
uint32_t fileSize = headerSize + chunk0DescriptionSize + m_jsonByteArray.size() + chunk1DescriptionSize + m_binByteArray.size();
qDebug() << "Chunk 0 data size:" << m_jsonByteArray.size();
qDebug() << "Chunk 1 data size:" << m_binByteArray.size();

View File

@ -1,19 +1,18 @@
#ifndef DUST3D_APPLICATION_GLB_FILE_H_
#define DUST3D_APPLICATION_GLB_FILE_H_
#include <QObject>
#include <QString>
#include <QByteArray>
#include <QMatrix4x4>
#include <vector>
#include <QQuaternion>
#include <QImage>
#include <dust3d/base/object.h>
#include "json.hpp"
#include "document.h"
#include "json.hpp"
#include <QByteArray>
#include <QImage>
#include <QMatrix4x4>
#include <QObject>
#include <QQuaternion>
#include <QString>
#include <dust3d/base/object.h>
#include <vector>
class GlbFileWriter : public QObject
{
class GlbFileWriter : public QObject {
Q_OBJECT
public:
GlbFileWriter(dust3d::Object& object,
@ -22,14 +21,17 @@ public:
QImage* normalImage = nullptr,
QImage* ormImage = nullptr);
bool save();
private:
QString m_filename;
bool m_outputNormal = true;
bool m_outputUv = true;
QByteArray m_binByteArray;
QByteArray m_jsonByteArray;
private:
nlohmann::json m_json;
public:
static bool m_enableComment;
};

View File

@ -1,28 +1,30 @@
#ifndef DUST3D_APPLICATION_GRAPHICS_CONTAINER_WIDGET_H_
#define DUST3D_APPLICATION_GRAPHICS_CONTAINER_WIDGET_H_
#include <QWidget>
#include <QResizeEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include "model_widget.h"
#include "skeleton_graphics_widget.h"
#include <QMouseEvent>
#include <QResizeEvent>
#include <QWheelEvent>
#include <QWidget>
class GraphicsContainerWidget : public QWidget
{
class GraphicsContainerWidget : public QWidget {
Q_OBJECT
signals:
void containerSizeChanged(QSize size);
public:
GraphicsContainerWidget();
void setGraphicsWidget(SkeletonGraphicsWidget* graphicsWidget);
void setModelWidget(ModelWidget* modelWidget);
protected:
void resizeEvent(QResizeEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
private:
ModelWidget* m_modelWidget = nullptr;
SkeletonGraphicsWidget* m_graphicsWidget = nullptr;

View File

@ -1,7 +1,7 @@
#include "horizontal_line_widget.h"
HorizontalLineWidget::HorizontalLineWidget() :
QWidget()
HorizontalLineWidget::HorizontalLineWidget()
: QWidget()
{
setFixedHeight(1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

View File

@ -3,8 +3,7 @@
#include <QWidget>
class HorizontalLineWidget : public QWidget
{
class HorizontalLineWidget : public QWidget {
Q_OBJECT
public:
HorizontalLineWidget();

View File

@ -1,11 +1,10 @@
#include <map>
#include "image_forever.h"
#include <QMutex>
#include <QMutexLocker>
#include <QtCore/qbuffer.h>
#include "image_forever.h"
#include <map>
struct ImageForeverItem
{
struct ImageForeverItem {
QImage* image;
dust3d::Uuid id;
QByteArray* imageByteArray;

View File

@ -1,12 +1,11 @@
#ifndef DUST3D_APPLICATION_IMAGE_FOREVER_H_
#define DUST3D_APPLICATION_IMAGE_FOREVER_H_
#include <QImage>
#include <QByteArray>
#include <QImage>
#include <dust3d/base/uuid.h>
class ImageForever
{
class ImageForever {
public:
static const QImage* get(const dust3d::Uuid& id);
static void copy(const dust3d::Uuid& id, QImage& image);

View File

@ -1,8 +1,8 @@
#include <QPainter>
#include "image_preview_widget.h"
#include <QPainter>
ImagePreviewWidget::ImagePreviewWidget(QWidget *parent) :
QWidget(parent)
ImagePreviewWidget::ImagePreviewWidget(QWidget* parent)
: QWidget(parent)
{
}
@ -30,4 +30,3 @@ void ImagePreviewWidget::paintEvent(QPaintEvent *event)
else
painter.fillRect(QRect(0, 0, width(), height()), QBrush(m_backgroundColor));
}

View File

@ -1,16 +1,16 @@
#ifndef DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
#define DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
#include <QWidget>
#include <QImage>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QWidget>
class ImagePreviewWidget : public QWidget
{
class ImagePreviewWidget : public QWidget {
Q_OBJECT
signals:
void clicked();
public:
ImagePreviewWidget(QWidget* parent = nullptr);
void updateImage(const QImage& image);

View File

@ -1,9 +1,9 @@
#include <QHBoxLayout>
#include "info_label.h"
#include "theme.h"
#include <QHBoxLayout>
InfoLabel::InfoLabel(const QString &text, QWidget *parent) :
QWidget(parent)
InfoLabel::InfoLabel(const QString& text, QWidget* parent)
: QWidget(parent)
{
m_icon = new QLabel(QChar(fa::infocircle));
Theme::initAwesomeLabel(m_icon);

View File

@ -1,15 +1,15 @@
#ifndef DUST3D_APPLICATION_INFO_LABEL_H_
#define DUST3D_APPLICATION_INFO_LABEL_H_
#include <QLabel>
#include <QIcon>
#include <QLabel>
#include <QWidget>
class InfoLabel : public QWidget
{
class InfoLabel : public QWidget {
public:
InfoLabel(const QString& text = QString(), QWidget* parent = nullptr);
void setText(const QString& text);
private:
QLabel* m_label = nullptr;
QLabel* m_icon = nullptr;

View File

@ -1,11 +1,11 @@
#include <QtWidgets>
#include "int_number_widget.h"
#include "theme.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "theme.h"
#include "int_number_widget.h"
#include <QtWidgets>
IntNumberWidget::IntNumberWidget(QWidget *parent, bool singleLine) :
QWidget(parent)
IntNumberWidget::IntNumberWidget(QWidget* parent, bool singleLine)
: QWidget(parent)
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setRange(0, 100);

View File

@ -6,8 +6,7 @@
QT_FORWARD_DECLARE_CLASS(QLabel)
QT_FORWARD_DECLARE_CLASS(QSlider)
class IntNumberWidget : public QWidget
{
class IntNumberWidget : public QWidget {
Q_OBJECT
public:
explicit IntNumberWidget(QWidget* parent = nullptr, bool singleLine = true);

View File

@ -1,12 +1,12 @@
#include <QMetaType>
#include <QDir>
#include "log_browser.h"
#include "log_browser_dialog.h"
#include <QDir>
#include <QMetaType>
bool LogBrowser::m_enableOutputToFile = true;
LogBrowser::LogBrowser(QObject *parent) :
QObject(parent)
LogBrowser::LogBrowser(QObject* parent)
: QObject(parent)
{
qRegisterMetaType<QtMsgType>("QtMsgType");
m_browserDialog = new LogBrowserDialog;

View File

@ -6,8 +6,7 @@
class LogBrowserDialog;
class LogBrowser : public QObject
{
class LogBrowser : public QObject {
Q_OBJECT
public:
explicit LogBrowser(QObject* parent = 0);

View File

@ -1,20 +1,20 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTextBrowser>
#include <QPushButton>
#include <QFileDialog>
#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QTextStream>
#include <QCloseEvent>
#include <QKeyEvent>
#include "version.h"
#include "log_browser_dialog.h"
#include "document_window.h"
#include "version.h"
#include <QCloseEvent>
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QMessageBox>
#include <QPushButton>
#include <QTextBrowser>
#include <QTextStream>
#include <QVBoxLayout>
LogBrowserDialog::LogBrowserDialog(QWidget *parent) :
QDialog(parent)
LogBrowserDialog::LogBrowserDialog(QWidget* parent)
: QDialog(parent)
{
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
@ -47,13 +47,10 @@ LogBrowserDialog::LogBrowserDialog(QWidget *parent) :
hide();
}
LogBrowserDialog::~LogBrowserDialog()
{
}
void LogBrowserDialog::outputMessage(QtMsgType type, const QString& msg, const QString& source, int line)
{
switch (type) {
@ -79,7 +76,6 @@ void LogBrowserDialog::outputMessage(QtMsgType type, const QString &msg, const Q
}
}
void LogBrowserDialog::save()
{
QString saveFileName = QFileDialog::getSaveFileName(this,

View File

@ -6,8 +6,7 @@
class QTextBrowser;
class QPushButton;
class LogBrowserDialog : public QDialog
{
class LogBrowserDialog : public QDialog {
Q_OBJECT
public:
LogBrowserDialog(QWidget* parent = 0);

View File

@ -1,13 +1,13 @@
#include <QApplication>
#include <QSurfaceFormat>
#include <QDebug>
#include <iostream>
#include <cstdio>
#include <dust3d/base/string.h>
#include "document_window.h"
#include "document.h"
#include "document_window.h"
#include "theme.h"
#include "version.h"
#include <QApplication>
#include <QDebug>
#include <QSurfaceFormat>
#include <cstdio>
#include <dust3d/base/string.h>
#include <iostream>
int main(int argc, char* argv[])
{
@ -34,8 +34,7 @@ int main(int argc, char *argv[])
bool toggleColor = false;
for (int i = 1; i < argc; ++i) {
if ('-' == argv[i][0]) {
if (0 == strcmp(argv[i], "-output") ||
0 == strcmp(argv[i], "-o")) {
if (0 == strcmp(argv[i], "-output") || 0 == strcmp(argv[i], "-o")) {
++i;
if (i < argc)
waitingExportList.append(argv[i]);
@ -79,8 +78,7 @@ int main(int argc, char *argv[])
for (auto& it : windowList)
it->toggleRenderColor();
}
if (!waitingExportList.empty() &&
openFileList.size() == 1) {
if (!waitingExportList.empty() && openFileList.size() == 1) {
totalExportFileNum = openFileList.size() * waitingExportList.size();
for (int i = 0; i < openFileList.size(); ++i) {
QObject::connect(windowList[i], &DocumentWindow::workingStatusChanged, &app, checkToSafelyExit);

View File

@ -2,12 +2,11 @@
#define DUST3D_APPLICATION_MATERIAL_H_
#include <QImage>
#include <dust3d/base/uuid.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/snapshot.h>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/uuid.h>
struct MaterialTextures
{
struct MaterialTextures {
const QImage* textureImages[(int)dust3d::TextureType::Count - 1] = { nullptr };
};

View File

@ -1,22 +1,21 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include "material_edit_widget.h"
#include "document.h"
#include "float_number_widget.h"
#include "horizontal_line_widget.h"
#include "image_forever.h"
#include "theme.h"
#include "version.h"
#include <QFileDialog>
#include <QFormLayout>
#include <QGridLayout>
#include <QMenu>
#include <QWidgetAction>
#include <QLineEdit>
#include <QMessageBox>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QMessageBox>
#include <QThread>
#include "theme.h"
#include "material_edit_widget.h"
#include "float_number_widget.h"
#include "version.h"
#include "image_forever.h"
#include "document.h"
#include "horizontal_line_widget.h"
#include <QVBoxLayout>
#include <QWidgetAction>
ImagePreviewWidget* MaterialEditWidget::createMapButton()
{
@ -29,7 +28,8 @@ ImagePreviewWidget *MaterialEditWidget::createMapButton()
QImage* MaterialEditWidget::pickImage()
{
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
tr("Image Files (*.png *.jpg *.bmp)")).trimmed();
tr("Image Files (*.png *.jpg *.bmp)"))
.trimmed();
if (fileName.isEmpty())
return nullptr;
QImage* image = new QImage();
@ -38,9 +38,9 @@ QImage *MaterialEditWidget::pickImage()
return image;
}
MaterialEditWidget::MaterialEditWidget(const Document *document, QWidget *parent) :
QDialog(parent),
m_document(document)
MaterialEditWidget::MaterialEditWidget(const Document* document, QWidget* parent)
: QDialog(parent)
, m_document(document)
{
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);

View File

@ -1,26 +1,24 @@
#ifndef DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
#include <QDialog>
#include <map>
#include <QCloseEvent>
#include <QLineEdit>
#include "model_widget.h"
#include "material_previews_generator.h"
#include "image_preview_widget.h"
#include "float_number_widget.h"
#include "image_preview_widget.h"
#include "material_layer.h"
#include "material_previews_generator.h"
#include "model_widget.h"
#include <QCloseEvent>
#include <QDialog>
#include <QLineEdit>
#include <map>
class Document;
enum class PopupWidgetType
{
enum class PopupWidgetType {
PitchYawRoll,
Intersection
};
class MaterialEditWidget : public QDialog
{
class MaterialEditWidget : public QDialog {
Q_OBJECT
signals:
void addMaterial(dust3d::Uuid materialId, QString name, std::vector<MaterialLayer> layers);
@ -28,6 +26,7 @@ signals:
void setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers);
void renameMaterial(dust3d::Uuid materialId, QString name);
void layersAdjusted();
public:
MaterialEditWidget(const Document* document, QWidget* parent = nullptr);
~MaterialEditWidget();
@ -40,10 +39,12 @@ public slots:
void save();
void clearUnsaveState();
void previewReady();
protected:
QSize sizeHint() const override;
void closeEvent(QCloseEvent* event) override;
void reject() override;
private:
void updateMapButtonBackground(ImagePreviewWidget* button, const QImage* image);
ImagePreviewWidget* createMapButton();

View File

@ -1,19 +1,17 @@
#ifndef DUST3D_APPLICATION_MATERIAL_LAYER_H_
#define DUST3D_APPLICATION_MATERIAL_LAYER_H_
#include <vector>
#include <dust3d/base/texture_type.h>
#include <dust3d/base/uuid.h>
#include <vector>
class MaterialMap
{
class MaterialMap {
public:
dust3d::TextureType forWhat;
dust3d::Uuid imageId;
};
class MaterialLayer
{
class MaterialLayer {
public:
std::vector<MaterialMap> maps;
float tileScale = 1.0;

View File

@ -1,15 +1,15 @@
#include "material_list_widget.h"
#include "document.h"
#include <QApplication>
#include <QClipboard>
#include <QGuiApplication>
#include <QMenu>
#include <QXmlStreamWriter>
#include <QClipboard>
#include <QApplication>
#include <dust3d/base/snapshot_xml.h>
#include "material_list_widget.h"
#include "document.h"
MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) :
QTreeWidget(parent),
m_document(document)
MaterialListWidget::MaterialListWidget(const Document* document, QWidget* parent)
: QTreeWidget(parent)
, m_document(document)
{
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
setFocusPolicy(Qt::NoFocus);
@ -161,8 +161,7 @@ void MaterialListWidget::mousePressEvent(QMouseEvent *event)
bool MaterialListWidget::isMaterialSelected(dust3d::Uuid materialId)
{
return (m_currentSelectedMaterialId == materialId ||
m_selectedMaterialIds.find(materialId) != m_selectedMaterialIds.end());
return (m_currentSelectedMaterialId == materialId || m_selectedMaterialIds.find(materialId) != m_selectedMaterialIds.end());
}
void MaterialListWidget::showContextMenu(const QPoint& pos)

View File

@ -1,21 +1,21 @@
#ifndef DUST3D_APPLICATION_MATERIAL_LIST_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_LIST_WIDGET_H_
#include "material_widget.h"
#include <QMouseEvent>
#include <QTreeWidget>
#include <map>
#include <QMouseEvent>
#include "material_widget.h"
class Document;
class MaterialListWidget : public QTreeWidget
{
class MaterialListWidget : public QTreeWidget {
Q_OBJECT
signals:
void removeMaterial(dust3d::Uuid materialId);
void modifyMaterial(dust3d::Uuid materialId);
void cornerButtonClicked(dust3d::Uuid materialId);
void currentSelectedMaterialChanged(dust3d::Uuid materialId);
public:
MaterialListWidget(const Document* document, QWidget* parent = nullptr);
bool isMaterialSelected(dust3d::Uuid materialId);
@ -28,9 +28,11 @@ public slots:
void selectMaterial(dust3d::Uuid materialId, bool multiple = false);
void copy();
void setHasContextMenu(bool hasContextMenu);
protected:
void resizeEvent(QResizeEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
private:
int calculateColumnCount();
void updateMaterialSelectState(dust3d::Uuid materialId, bool selected);

View File

@ -1,15 +1,15 @@
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include "material_manage_widget.h"
#include "theme.h"
#include "material_edit_widget.h"
#include "info_label.h"
#include "document.h"
#include "info_label.h"
#include "material_edit_widget.h"
#include "theme.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QVBoxLayout>
MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) :
QWidget(parent),
m_document(document)
MaterialManageWidget::MaterialManageWidget(const Document* document, QWidget* parent)
: QWidget(parent)
, m_document(document)
{
QPushButton* addMaterialButton = new QPushButton(Theme::awesome()->icon(fa::plus), tr("Add Material..."));

View File

@ -1,25 +1,27 @@
#ifndef DUST3D_APPLICATION_MATERIAL_MANAGE_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_MANAGE_WIDGET_H_
#include <QWidget>
#include "material_list_widget.h"
#include <QWidget>
class Document;
class MaterialManageWidget : public QWidget
{
class MaterialManageWidget : public QWidget {
Q_OBJECT
signals:
void registerDialog(QWidget* widget);
void unregisterDialog(QWidget* widget);
public:
MaterialManageWidget(const Document* document, QWidget* parent = nullptr);
MaterialListWidget* materialListWidget();
protected:
virtual QSize sizeHint() const;
public slots:
void showAddMaterialDialog();
void showMaterialDialog(dust3d::Uuid materialId);
private:
const Document* m_document = nullptr;
MaterialListWidget* m_materialListWidget = nullptr;

View File

@ -1,14 +1,14 @@
#include <QGuiApplication>
#include <QElapsedTimer>
#include "material_previews_generator.h"
#include "image_forever.h"
#include "mesh_generator.h"
#include "mesh_result_post_processor.h"
#include "texture_generator.h"
#include <QDebug>
#include <QElapsedTimer>
#include <QFile>
#include <QGuiApplication>
#include <dust3d/base/ds3_file.h>
#include <dust3d/base/snapshot_xml.h>
#include "material_previews_generator.h"
#include "mesh_generator.h"
#include "texture_generator.h"
#include "image_forever.h"
#include "mesh_result_post_processor.h"
MaterialPreviewsGenerator::MaterialPreviewsGenerator()
{

View File

@ -1,14 +1,13 @@
#ifndef DUST3D_APPLICATION_MATERIAL_PREVIEWS_GENERATOR_H_
#define DUST3D_APPLICATION_MATERIAL_PREVIEWS_GENERATOR_H_
#include "material_layer.h"
#include "model_mesh.h"
#include <QObject>
#include <map>
#include <vector>
#include "model_mesh.h"
#include "material_layer.h"
class MaterialPreviewsGenerator : public QObject
{
class MaterialPreviewsGenerator : public QObject {
Q_OBJECT
public:
MaterialPreviewsGenerator();
@ -21,6 +20,7 @@ signals:
void finished();
public slots:
void process();
private:
std::vector<std::pair<dust3d::Uuid, std::vector<MaterialLayer>>> m_materials;
std::map<dust3d::Uuid, ModelMesh*> m_previews;

View File

@ -1,10 +1,10 @@
#include <QVBoxLayout>
#include "material_widget.h"
#include "document.h"
#include <QVBoxLayout>
MaterialWidget::MaterialWidget(const Document *document, dust3d::Uuid materialId) :
m_materialId(materialId),
m_document(document)
MaterialWidget::MaterialWidget(const Document* document, dust3d::Uuid materialId)
: m_materialId(materialId)
, m_document(document)
{
setObjectName("MaterialFrame");

View File

@ -1,23 +1,24 @@
#ifndef DUST3D_APPLICATION_MATERIAL_WIDGET_H_
#define DUST3D_APPLICATION_MATERIAL_WIDGET_H_
#include <QFrame>
#include <QLabel>
#include <QIcon>
#include <QPushButton>
#include "model_widget.h"
#include <QFrame>
#include <QIcon>
#include <QLabel>
#include <QPushButton>
class Document;
class MaterialWidget : public QFrame
{
class MaterialWidget : public QFrame {
Q_OBJECT
signals:
void modifyMaterial(dust3d::Uuid materialId);
public:
MaterialWidget(const Document* document, dust3d::Uuid materialId);
static int preferredHeight();
ModelWidget* previewWidget();
protected:
void mouseDoubleClickEvent(QMouseEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
@ -26,6 +27,7 @@ public slots:
void updatePreview(dust3d::Uuid materialId);
void updateName(dust3d::Uuid materialId);
void updateCheckedState(bool checked);
private:
dust3d::Uuid m_materialId;
const Document* m_document = nullptr;

View File

@ -1,13 +1,13 @@
#include <dust3d/mesh/smooth_normal.h>
#include <dust3d/mesh/trim_vertices.h>
#include <QElapsedTimer>
#include <QDebug>
#include "mesh_generator.h"
#include "cut_face_preview.h"
#include <QDebug>
#include <QElapsedTimer>
#include <dust3d/mesh/smooth_normal.h>
#include <dust3d/mesh/trim_vertices.h>
MeshGenerator::MeshGenerator(dust3d::Snapshot *snapshot) :
dust3d::MeshGenerator(snapshot)
MeshGenerator::MeshGenerator(dust3d::Snapshot* snapshot)
: dust3d::MeshGenerator(snapshot)
{
}
@ -50,8 +50,7 @@ void MeshGenerator::process()
previewTriangleNormals.emplace_back(dust3d::Vector3::normal(
it->second.vertices[face[0]],
it->second.vertices[face[1]],
it->second.vertices[face[2]]
));
it->second.vertices[face[2]]));
}
std::vector<std::vector<dust3d::Vector3>> previewTriangleVertexNormals;
dust3d::smoothNormal(it->second.vertices,
@ -80,4 +79,3 @@ ModelMesh *MeshGenerator::takeResultMesh()
{
return m_resultMesh.release();
}

View File

@ -1,15 +1,14 @@
#ifndef DUST3D_APPLICATION_MESH_GENERATOR_H_
#define DUST3D_APPLICATION_MESH_GENERATOR_H_
#include <memory>
#include <QObject>
#include <QImage>
#include <dust3d/mesh/mesh_generator.h>
#include "model_mesh.h"
#include "monochrome_mesh.h"
#include <QImage>
#include <QObject>
#include <dust3d/mesh/mesh_generator.h>
#include <memory>
class MeshGenerator : public QObject, public dust3d::MeshGenerator
{
class MeshGenerator : public QObject, public dust3d::MeshGenerator {
Q_OBJECT
public:
MeshGenerator(dust3d::Snapshot* snapshot);
@ -21,6 +20,7 @@ public slots:
void process();
signals:
void finished();
private:
std::unique_ptr<ModelMesh> m_resultMesh;
std::unique_ptr<std::map<dust3d::Uuid, std::unique_ptr<ModelMesh>>> m_componentPreviewMeshes;

View File

@ -1,6 +1,6 @@
#include <QDebug>
#include "mesh_preview_images_generator.h"
#include "theme.h"
#include <QDebug>
void MeshPreviewImagesGenerator::addInput(const dust3d::Uuid& inputId, std::unique_ptr<ModelMesh> previewMesh, bool useFrontView)
{

View File

@ -1,24 +1,22 @@
#ifndef DUST3D_APPLICATION_MESH_PREVIEW_IMAGES_GENERATOR_H_
#define DUST3D_APPLICATION_MESH_PREVIEW_IMAGES_GENERATOR_H_
#include <QObject>
#include <QImage>
#include <memory>
#include <map>
#include <dust3d/base/uuid.h>
#include "model_offscreen_render.h"
#include <QImage>
#include <QObject>
#include <dust3d/base/uuid.h>
#include <map>
#include <memory>
class MeshPreviewImagesGenerator : public QObject
{
class MeshPreviewImagesGenerator : public QObject {
Q_OBJECT
public:
MeshPreviewImagesGenerator(ModelOffscreenRender *modelOffscreenRender) :
m_offscreenRender(modelOffscreenRender)
MeshPreviewImagesGenerator(ModelOffscreenRender* modelOffscreenRender)
: m_offscreenRender(modelOffscreenRender)
{
}
struct PreviewInput
{
struct PreviewInput {
std::unique_ptr<ModelMesh> mesh;
bool useFrontView = false;
};
@ -35,6 +33,7 @@ signals:
void finished();
public slots:
void process();
private:
std::map<dust3d::Uuid, PreviewInput> m_previewInputMap;
ModelOffscreenRender* m_offscreenRender = nullptr;

View File

@ -1,7 +1,7 @@
#include <QGuiApplication>
#include <dust3d/uv/unwrap_uv.h>
#include <dust3d/mesh/resolve_triangle_tangent.h>
#include "mesh_result_post_processor.h"
#include <QGuiApplication>
#include <dust3d/mesh/resolve_triangle_tangent.h>
#include <dust3d/uv/unwrap_uv.h>
MeshResultPostProcessor::MeshResultPostProcessor(const dust3d::Object& object)
{

View File

@ -4,8 +4,7 @@
#include <QObject>
#include <dust3d/base/object.h>
class MeshResultPostProcessor : public QObject
{
class MeshResultPostProcessor : public QObject {
Q_OBJECT
public:
MeshResultPostProcessor(const dust3d::Object& object);
@ -16,6 +15,7 @@ signals:
void finished();
public slots:
void process();
private:
dust3d::Object* m_object = nullptr;
};

View File

@ -1,20 +1,19 @@
#include <assert.h>
#include <QTextStream>
#include <QFile>
#include <cmath>
#include "model_mesh.h"
#include "version.h"
#include <QFile>
#include <QTextStream>
#include <assert.h>
#include <cmath>
float ModelMesh::m_defaultMetalness = 0.0;
float ModelMesh::m_defaultRoughness = 1.0;
ModelMesh::ModelMesh(const ModelMesh &mesh) :
m_triangleVertices(nullptr),
m_triangleVertexCount(0),
m_textureImage(nullptr)
ModelMesh::ModelMesh(const ModelMesh& mesh)
: m_triangleVertices(nullptr)
, m_triangleVertexCount(0)
, m_textureImage(nullptr)
{
if (nullptr != mesh.m_triangleVertices &&
mesh.m_triangleVertexCount > 0) {
if (nullptr != mesh.m_triangleVertices && mesh.m_triangleVertexCount > 0) {
this->m_triangleVertices = new ModelOpenGLVertex[mesh.m_triangleVertexCount];
this->m_triangleVertexCount = mesh.m_triangleVertexCount;
for (int i = 0; i < mesh.m_triangleVertexCount; i++)
@ -61,10 +60,10 @@ void ModelMesh::removeColor()
}
}
ModelMesh::ModelMesh(ModelOpenGLVertex *triangleVertices, int vertexNum) :
m_triangleVertices(triangleVertices),
m_triangleVertexCount(vertexNum),
m_textureImage(nullptr)
ModelMesh::ModelMesh(ModelOpenGLVertex* triangleVertices, int vertexNum)
: m_triangleVertices(triangleVertices)
, m_triangleVertexCount(vertexNum)
, m_textureImage(nullptr)
{
}
@ -117,10 +116,10 @@ ModelMesh::ModelMesh(const std::vector<dust3d::Vector3> &vertices,
}
}
ModelMesh::ModelMesh(dust3d::Object &object) :
m_triangleVertices(nullptr),
m_triangleVertexCount(0),
m_textureImage(nullptr)
ModelMesh::ModelMesh(dust3d::Object& object)
: m_triangleVertices(nullptr)
, m_triangleVertexCount(0)
, m_textureImage(nullptr)
{
m_meshId = object.meshId;
m_vertices = object.vertices;
@ -184,10 +183,10 @@ ModelMesh::ModelMesh(dust3d::Object &object) :
}
}
ModelMesh::ModelMesh() :
m_triangleVertices(nullptr),
m_triangleVertexCount(0),
m_textureImage(nullptr)
ModelMesh::ModelMesh()
: m_triangleVertices(nullptr)
, m_triangleVertexCount(0)
, m_textureImage(nullptr)
{
}

View File

@ -1,17 +1,16 @@
#ifndef DUST3D_APPLICATION_MODEL_MESH_H_
#define DUST3D_APPLICATION_MODEL_MESH_H_
#include <QObject>
#include <vector>
#include "model_opengl_vertex.h"
#include <QImage>
#include <QObject>
#include <QTextStream>
#include <dust3d/base/vector3.h>
#include <dust3d/base/color.h>
#include <dust3d/base/object.h>
#include "model_opengl_vertex.h"
#include <dust3d/base/vector3.h>
#include <vector>
class ModelMesh
{
class ModelMesh {
public:
ModelMesh(const std::vector<dust3d::Vector3>& vertices,
const std::vector<std::vector<size_t>>& triangles,
@ -53,6 +52,7 @@ public:
quint64 meshId() const;
void setMeshId(quint64 id);
void removeColor();
private:
ModelOpenGLVertex* m_triangleVertices = nullptr;
int m_triangleVertexCount = 0;

View File

@ -2,10 +2,10 @@
#include "model_opengl_object.h"
#include "model_opengl_program.h"
ModelOffscreenRender::ModelOffscreenRender(const QSurfaceFormat &format, QScreen *targetScreen):
QOffscreenSurface(targetScreen),
m_context(nullptr),
m_mesh(nullptr)
ModelOffscreenRender::ModelOffscreenRender(const QSurfaceFormat& format, QScreen* targetScreen)
: QOffscreenSurface(targetScreen)
, m_context(nullptr)
, m_mesh(nullptr)
{
setFormat(format);
create();

View File

@ -1,14 +1,13 @@
#ifndef DUST3D_APPLICATION_MODEL_OFFSCREEN_RENDER_H_
#define DUST3D_APPLICATION_MODEL_OFFSCREEN_RENDER_H_
#include "model_mesh.h"
#include <QOffscreenSurface>
#include <QOpenGLFramebufferObject>
#include <QSurfaceFormat>
#include <QVector3D>
#include "model_mesh.h"
class ModelOffscreenRender: public QOffscreenSurface
{
class ModelOffscreenRender : public QOffscreenSurface {
public:
ModelOffscreenRender(const QSurfaceFormat& format, QScreen* targetScreen = Q_NULLPTR);
~ModelOffscreenRender();
@ -20,6 +19,7 @@ public:
void setRenderThread(QThread* thread);
void updateMesh(ModelMesh* mesh);
QImage toImage(const QSize& size);
private:
int m_xRot = 0;
int m_yRot = 0;

View File

@ -1,7 +1,7 @@
#include <dust3d/base/debug.h>
#include <QOpenGLFunctions>
#include <QOpenGLContext>
#include "model_opengl_object.h"
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <dust3d/base/debug.h>
void ModelOpenGLObject::update(std::unique_ptr<ModelMesh> mesh)
{

View File

@ -1,17 +1,17 @@
#ifndef DUST3D_APPLICATION_MODEL_OPENGL_OBJECT_H_
#define DUST3D_APPLICATION_MODEL_OPENGL_OBJECT_H_
#include <memory>
#include <QMutex>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include "model_mesh.h"
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <memory>
class ModelOpenGLObject
{
class ModelOpenGLObject {
public:
void update(std::unique_ptr<ModelMesh> mesh);
void draw();
private:
void copyMeshToOpenGL();
QOpenGLVertexArrayObject m_vertexArrayObject;

View File

@ -1,9 +1,9 @@
#include <QOpenGLFunctions>
#include <QFile>
#include <QMutexLocker>
#include <dust3d/base/debug.h>
#include "model_opengl_program.h"
#include "dds_file.h"
#include <QFile>
#include <QMutexLocker>
#include <QOpenGLFunctions>
#include <dust3d/base/debug.h>
static const QString& loadShaderSource(const QString& name)
{

View File

@ -1,14 +1,13 @@
#ifndef DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
#define DUST3D_APPLICATION_MODEL_OPENGL_PROGRAM_H_
#include <memory>
#include <QOpenGLShaderProgram>
#include <QOpenGLShader>
#include <QOpenGLTexture>
#include <QMutex>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <memory>
class ModelOpenGLProgram: public QOpenGLShaderProgram
{
class ModelOpenGLProgram : public QOpenGLShaderProgram {
public:
void load(bool isCoreProfile = false);
int getUniformLocationByName(const std::string& name);

View File

@ -1,11 +1,11 @@
#include <QMouseEvent>
#include <QCoreApplication>
#include <QGuiApplication>
#include <cmath>
#include <QVector4D>
#include <QSurfaceFormat>
#include "model_widget.h"
#include "dds_file.h"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QMouseEvent>
#include <QSurfaceFormat>
#include <QVector4D>
#include <cmath>
float ModelWidget::m_minZoomRatio = 5.0;
float ModelWidget::m_maxZoomRatio = 80.0;
@ -18,8 +18,8 @@ QString ModelWidget::m_openGLVersion = "";
QString ModelWidget::m_openGLShadingLanguageVersion = "";
bool ModelWidget::m_openGLIsCoreProfile = false;
ModelWidget::ModelWidget(QWidget *parent) :
QOpenGLWidget(parent)
ModelWidget::ModelWidget(QWidget* parent)
: QOpenGLWidget(parent)
{
setAttribute(Qt::WA_AlwaysStackOnTop);
setAttribute(Qt::WA_TranslucentBackground);
@ -194,8 +194,7 @@ bool ModelWidget::inputMousePressEventFromOtherWidget(QMouseEvent *event, bool n
{
bool shouldStartMove = false;
if (event->button() == Qt::LeftButton) {
if ((notGraphics || QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) &&
!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
if ((notGraphics || QGuiApplication::queryKeyboardModifiers().testFlag(Qt::AltModifier)) && !QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
shouldStartMove = m_moveEnabled;
}
if (!shouldStartMove && !m_mousePickTargetPositionInModelSpace.isNull())
@ -251,8 +250,7 @@ bool ModelWidget::inputMouseMoveEventFromOtherWidget(QMouseEvent *event)
int dx = pos.x() - m_lastPos.x();
int dy = pos.y() - m_lastPos.y();
if ((event->buttons() & Qt::MidButton) ||
(m_moveStarted && (event->buttons() & Qt::LeftButton))) {
if ((event->buttons() & Qt::MidButton) || (m_moveStarted && (event->buttons() & Qt::LeftButton))) {
if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) {
if (m_moveStarted) {
if (m_moveAndZoomByWindow) {

View File

@ -1,24 +1,23 @@
#ifndef DUST3D_APPLICATION_MODEL_WIDGET_H_
#define DUST3D_APPLICATION_MODEL_WIDGET_H_
#include <memory>
#include <QOpenGLWidget>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include "model_mesh.h"
#include "model_opengl_object.h"
#include "model_opengl_program.h"
#include "monochrome_mesh.h"
#include "monochrome_opengl_object.h"
#include "monochrome_opengl_program.h"
#include <QMatrix4x4>
#include <QMutex>
#include <QVector2D>
#include <QTimer>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include <QOpenGLWidget>
#include <QString>
#include "model_mesh.h"
#include "model_opengl_program.h"
#include "model_opengl_object.h"
#include "monochrome_mesh.h"
#include "monochrome_opengl_program.h"
#include "monochrome_opengl_object.h"
#include <QTimer>
#include <QVector2D>
#include <memory>
class ModelWidget : public QOpenGLWidget
{
class ModelWidget : public QOpenGLWidget {
Q_OBJECT
signals:
void mouseRayChanged(const QVector3D& near, const QVector3D& far);
@ -31,6 +30,7 @@ signals:
void zRotationChanged(int angle);
void eyePositionChanged(const QVector3D& eyePosition);
void moveToPositionChanged(const QVector3D& moveToPosition);
public:
ModelWidget(QWidget* parent = 0);
~ModelWidget();
@ -70,6 +70,7 @@ public slots:
void setMousePickRadius(float radius);
void reRender();
void canvasResized();
protected:
void initializeGL() override;
void paintGL() override;
@ -78,6 +79,7 @@ protected:
void mouseMoveEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
private:
int m_xRot = m_defaultXRotation;
int m_yRot = m_defaultYRotation;
@ -116,6 +118,7 @@ private:
void normalizeAngle(int& angle);
void drawModel();
void drawWireframe();
public:
static int m_defaultXRotation;
static int m_defaultYRotation;

View File

@ -1,5 +1,5 @@
#include <set>
#include "monochrome_mesh.h"
#include <set>
MonochromeMesh::MonochromeMesh(const MonochromeMesh& mesh)
{
@ -43,13 +43,11 @@ MonochromeMesh::MonochromeMesh(const dust3d::Object &object)
m_lineVertices.emplace_back(MonochromeOpenGLVertex {
(GLfloat)from.x(),
(GLfloat)from.y(),
(GLfloat)from.z()
});
(GLfloat)from.z() });
m_lineVertices.emplace_back(MonochromeOpenGLVertex {
(GLfloat)to.x(),
(GLfloat)to.y(),
(GLfloat)to.z()
});
(GLfloat)to.z() });
}
}

View File

@ -1,21 +1,20 @@
#ifndef DUST3D_APPLICATION_MONOCHROME_MESH_H_
#define DUST3D_APPLICATION_MONOCHROME_MESH_H_
#include <memory>
#include <dust3d/base/object.h>
#include "monochrome_opengl_vertex.h"
#include <dust3d/base/object.h>
#include <memory>
class MonochromeMesh
{
class MonochromeMesh {
public:
MonochromeMesh(const MonochromeMesh& mesh);
MonochromeMesh(MonochromeMesh&& mesh);
MonochromeMesh(const dust3d::Object& object);
const MonochromeOpenGLVertex* lineVertices();
int lineVertexCount();
private:
std::vector<MonochromeOpenGLVertex> m_lineVertices;
};
#endif

View File

@ -1,7 +1,7 @@
#include <dust3d/base/debug.h>
#include <QOpenGLFunctions>
#include <QOpenGLContext>
#include "monochrome_opengl_object.h"
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <dust3d/base/debug.h>
void MonochromeOpenGLObject::update(std::unique_ptr<MonochromeMesh> mesh)
{

View File

@ -1,17 +1,17 @@
#ifndef DUST3D_APPLICATION_MONOCHROME_OPENGL_OBJECT_H_
#define DUST3D_APPLICATION_MONOCHROME_OPENGL_OBJECT_H_
#include <memory>
#include <QMutex>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include "monochrome_mesh.h"
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <memory>
class MonochromeOpenGLObject
{
class MonochromeOpenGLObject {
public:
void update(std::unique_ptr<MonochromeMesh> mesh);
void draw();
private:
void copyMeshToOpenGL();
QOpenGLVertexArrayObject m_vertexArrayObject;

View File

@ -1,7 +1,7 @@
#include <QOpenGLFunctions>
#include <QFile>
#include <dust3d/base/debug.h>
#include "monochrome_opengl_program.h"
#include <QFile>
#include <QOpenGLFunctions>
#include <dust3d/base/debug.h>
static const QString& loadShaderSource(const QString& name)
{

View File

@ -1,12 +1,11 @@
#ifndef DUST3D_APPLICATION_MONOCHROME_OPENGL_PROGRAM_H_
#define DUST3D_APPLICATION_MONOCHROME_OPENGL_PROGRAM_H_
#include <memory>
#include <QOpenGLShaderProgram>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <memory>
class MonochromeOpenGLProgram: public QOpenGLShaderProgram
{
class MonochromeOpenGLProgram : public QOpenGLShaderProgram {
public:
void load(bool isCoreProfile = false);
int getUniformLocationByName(const std::string& name);

View File

@ -1,16 +1,16 @@
#include <QVBoxLayout>
#include <QWidgetAction>
#include <QMenu>
#include "part_manage_widget.h"
#include "component_list_model.h"
#include "component_preview_grid_widget.h"
#include "component_property_widget.h"
#include "component_list_model.h"
#include "theme.h"
#include "document.h"
#include "theme.h"
#include <QMenu>
#include <QVBoxLayout>
#include <QWidgetAction>
PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
QWidget(parent),
m_document(document)
PartManageWidget::PartManageWidget(Document* document, QWidget* parent)
: QWidget(parent)
, m_document(document)
{
setContextMenuPolicy(Qt::CustomContextMenu);
@ -147,8 +147,7 @@ void PartManageWidget::showSelectedComponentProperties()
x = QCursor::pos().x();
menu->exec(QPoint(
x - propertyWidget->width(),
QCursor::pos().y()
));
QCursor::pos().y()));
}
void PartManageWidget::selectComponentByPartId(const dust3d::Uuid& partId)

View File

@ -1,16 +1,15 @@
#ifndef DUST3D_APPLICATION_PART_MANAGE_WIDGET_H_
#define DUST3D_APPLICATION_PART_MANAGE_WIDGET_H_
#include <dust3d/base/uuid.h>
#include <QWidget>
#include <dust3d/base/uuid.h>
class Document;
class ComponentPreviewGridWidget;
class ComponentPropertyWidget;
class QPushButton;
class PartManageWidget: public QWidget
{
class PartManageWidget : public QWidget {
Q_OBJECT
signals:
void unselectAllOnCanvas();
@ -22,8 +21,10 @@ public slots:
void selectComponentByPartId(const dust3d::Uuid& partId);
void showSelectedComponentProperties();
void showContextMenu(const QPoint& pos);
public:
PartManageWidget(Document* document, QWidget* parent = nullptr);
private:
Document* m_document = nullptr;
ComponentPreviewGridWidget* m_componentPreviewGridWidget = nullptr;

View File

@ -5,8 +5,7 @@
#include <QSize>
#include <QStringList>
class Preferences : public QObject
{
class Preferences : public QObject {
Q_OBJECT
public:
static Preferences& instance();
@ -18,6 +17,7 @@ public:
public slots:
void setCurrentFile(const QString& fileName);
void reset();
private:
QSettings m_settings;
void loadDefault();

View File

@ -1,8 +1,8 @@
#include "preview_grid_view.h"
#include "theme.h"
PreviewGridView::PreviewGridView(QWidget *parent):
QListView(parent)
PreviewGridView::PreviewGridView(QWidget* parent)
: QListView(parent)
{
QPalette viewPalette = palette();
viewPalette.setColor(QPalette::Window, Qt::transparent);
@ -13,9 +13,7 @@ PreviewGridView::PreviewGridView(QWidget *parent):
auto margin = Theme::previewIconMargin;
auto borderRadius = Theme::previewIconBorderRadius;
setStyleSheet(
"QListView::item {border:" + QString::number(borderSize) + "px solid transparent; margin:" + QString::number(margin) + "px; background-color: " + Theme::gray.name() +"; border-radius: " + QString::number(borderRadius) + ";}" +
"QListView::item:selected {border-color: " + Theme::red.name() + ";}"
);
"QListView::item {border:" + QString::number(borderSize) + "px solid transparent; margin:" + QString::number(margin) + "px; background-color: " + Theme::gray.name() + "; border-radius: " + QString::number(borderRadius) + ";}" + "QListView::item:selected {border-color: " + Theme::red.name() + ";}");
setViewMode(QListView::IconMode);
setGridSize(QSize(Theme::partPreviewImageSize, Theme::partPreviewImageSize));

View File

@ -3,8 +3,7 @@
#include <QListView>
class PreviewGridView: public QListView
{
class PreviewGridView : public QListView {
Q_OBJECT
public:
PreviewGridView(QWidget* parent = nullptr);

View File

@ -1,5 +1,5 @@
#include <QDebug>
#include "skeleton_document.h"
#include <QDebug>
const SkeletonNode* SkeletonDocument::findNode(dust3d::Uuid nodeId) const
{
@ -206,8 +206,7 @@ void SkeletonDocument::removeEdge(dust3d::Uuid edgeId)
removePart(oldPartId);
if (!newPartNodeNumMap.empty()) {
std::sort(newPartNodeNumMap.begin(), newPartNodeNumMap.end(), [&](
const std::pair<dust3d::Uuid, size_t> &first, const std::pair<dust3d::Uuid, size_t> &second) {
std::sort(newPartNodeNumMap.begin(), newPartNodeNumMap.end(), [&](const std::pair<dust3d::Uuid, size_t>& first, const std::pair<dust3d::Uuid, size_t>& second) {
return first.second > second.second;
});
updateLinkedPart(oldPartId, newPartNodeNumMap[0].first);
@ -279,8 +278,7 @@ void SkeletonDocument::removeNode(dust3d::Uuid nodeId)
removePart(oldPartId);
if (!newPartNodeNumMap.empty()) {
std::sort(newPartNodeNumMap.begin(), newPartNodeNumMap.end(), [&](
const std::pair<dust3d::Uuid, size_t> &first, const std::pair<dust3d::Uuid, size_t> &second) {
std::sort(newPartNodeNumMap.begin(), newPartNodeNumMap.end(), [&](const std::pair<dust3d::Uuid, size_t>& first, const std::pair<dust3d::Uuid, size_t>& second) {
return first.second > second.second;
});
updateLinkedPart(oldPartId, newPartNodeNumMap[0].first);

View File

@ -1,35 +1,34 @@
#ifndef DUST3D_APPLICATION_SKELETON_DOCUMENT_H_
#define DUST3D_APPLICATION_SKELETON_DOCUMENT_H_
#include <QObject>
#include <QString>
#include <cmath>
#include <QImage>
#include <QByteArray>
#include <QDebug>
#include <QVector3D>
#include <QPixmap>
#include <dust3d/base/uuid.h>
#include <dust3d/base/cut_face.h>
#include <dust3d/base/part_target.h>
#include <dust3d/base/part_base.h>
#include <dust3d/base/combine_mode.h>
#include "theme.h"
#include "model_mesh.h"
#include "debug.h"
#include "mesh_generator.h"
#include "model_mesh.h"
#include "theme.h"
#include <QByteArray>
#include <QDebug>
#include <QImage>
#include <QObject>
#include <QPixmap>
#include <QString>
#include <QVector3D>
#include <cmath>
#include <dust3d/base/combine_mode.h>
#include <dust3d/base/cut_face.h>
#include <dust3d/base/part_base.h>
#include <dust3d/base/part_target.h>
#include <dust3d/base/uuid.h>
class SkeletonNode
{
class SkeletonNode {
public:
SkeletonNode(const dust3d::Uuid &withId=dust3d::Uuid()) :
radius(0),
cutRotation(0.0),
cutFace(dust3d::CutFace::Quad),
hasCutFaceSettings(false),
m_x(0),
m_y(0),
m_z(0)
SkeletonNode(const dust3d::Uuid& withId = dust3d::Uuid())
: radius(0)
, cutRotation(0.0)
, cutFace(dust3d::CutFace::Quad)
, hasCutFaceSettings(false)
, m_x(0)
, m_y(0)
, m_z(0)
{
id = withId.isNull() ? dust3d::Uuid::createUuid() : withId;
}
@ -123,14 +122,14 @@ public:
dust3d::Uuid cutFaceLinkedId;
bool hasCutFaceSettings;
std::vector<dust3d::Uuid> edgeIds;
private:
float m_x;
float m_y;
float m_z;
};
class SkeletonEdge
{
class SkeletonEdge {
public:
SkeletonEdge(const dust3d::Uuid& withId = dust3d::Uuid())
{
@ -148,8 +147,7 @@ public:
}
};
class SkeletonPart
{
class SkeletonPart {
public:
dust3d::Uuid id;
QString name;
@ -180,30 +178,30 @@ public:
float hollowThickness;
bool countershaded;
bool smooth;
SkeletonPart(const dust3d::Uuid &withId=dust3d::Uuid()) :
visible(true),
locked(false),
subdived(false),
disabled(false),
xMirrored(false),
base(dust3d::PartBase::Average),
deformThickness(1.0),
deformWidth(1.0),
deformUnified(false),
rounded(false),
chamfered(false),
color(Qt::white),
hasColor(false),
dirty(true),
cutRotation(0.0),
cutFace(dust3d::CutFace::Quad),
target(dust3d::PartTarget::Model),
colorSolubility(0.0),
metalness(0.0),
roughness(1.0),
hollowThickness(0.0),
countershaded(false),
smooth(false)
SkeletonPart(const dust3d::Uuid& withId = dust3d::Uuid())
: visible(true)
, locked(false)
, subdived(false)
, disabled(false)
, xMirrored(false)
, base(dust3d::PartBase::Average)
, deformThickness(1.0)
, deformWidth(1.0)
, deformUnified(false)
, rounded(false)
, chamfered(false)
, color(Qt::white)
, hasColor(false)
, dirty(true)
, cutRotation(0.0)
, cutFace(dust3d::CutFace::Quad)
, target(dust3d::PartTarget::Model)
, colorSolubility(0.0)
, metalness(0.0)
, roughness(1.0)
, hollowThickness(0.0)
, countershaded(false)
, smooth(false)
{
id = withId.isNull() ? dust3d::Uuid::createUuid() : withId;
}
@ -382,12 +380,12 @@ public:
smooth = other.smooth;
hollowThickness = other.hollowThickness;
}
private:
Q_DISABLE_COPY(SkeletonPart);
};
enum class SkeletonDocumentEditMode
{
enum class SkeletonDocumentEditMode {
Add = 0,
Select,
Paint,
@ -396,15 +394,13 @@ enum class SkeletonDocumentEditMode
ZoomOut
};
enum class SkeletonProfile
{
enum class SkeletonProfile {
Unknown = 0,
Main,
Side
};
class SkeletonComponent
{
class SkeletonComponent {
public:
SkeletonComponent()
{
@ -555,13 +551,13 @@ public:
return nullptr;
return new ModelMesh(*m_previewMesh);
}
private:
std::unique_ptr<ModelMesh> m_previewMesh;
std::set<dust3d::Uuid> m_childrenIdSet;
};
class SkeletonDocument : public QObject
{
class SkeletonDocument : public QObject {
Q_OBJECT
signals:
void partAdded(dust3d::Uuid partId);
@ -590,6 +586,7 @@ signals:
void ylockStateChanged();
void zlockStateChanged();
void radiusLockStateChanged();
public:
SkeletonDocumentEditMode editMode = SkeletonDocumentEditMode::Select;
bool xlocked = false;

View File

@ -1,20 +1,20 @@
#include <QDebug>
#include <QScrollBar>
#include <QGuiApplication>
#include <cmath>
#include <QtGlobal>
#include <algorithm>
#include <QVector2D>
#include <QMenu>
#include <QApplication>
#include <QMatrix4x4>
#include <queue>
#include <QBitmap>
#include "skeleton_graphics_widget.h"
#include "theme.h"
#include <QApplication>
#include <QBitmap>
#include <QDebug>
#include <QGuiApplication>
#include <QMatrix4x4>
#include <QMenu>
#include <QScrollBar>
#include <QVector2D>
#include <QtGlobal>
#include <algorithm>
#include <cmath>
#include <queue>
SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document) :
m_document(document)
SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument* document)
: m_document(document)
{
setRenderHint(QPainter::Antialiasing, false);
setBackgroundBrush(QBrush(QWidget::palette().color(QWidget::backgroundRole()), Qt::SolidPattern));
@ -101,8 +101,7 @@ void SkeletonGraphicsWidget::shortcutEscape()
if (!isVisible())
return;
if (SkeletonDocumentEditMode::Add == m_document->editMode ||
SkeletonDocumentEditMode::Paint == m_document->editMode) {
if (SkeletonDocumentEditMode::Add == m_document->editMode || SkeletonDocumentEditMode::Paint == m_document->editMode) {
emit setEditMode(SkeletonDocumentEditMode::Select);
return;
}
@ -783,8 +782,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event)
}
}
if (SkeletonDocumentEditMode::Select == m_document->editMode ||
SkeletonDocumentEditMode::Add == m_document->editMode) {
if (SkeletonDocumentEditMode::Select == m_document->editMode || SkeletonDocumentEditMode::Add == m_document->editMode) {
//
// > For overlapping nodes, you can make it a bit better by selecting the node center nearest the mouse, rather than simply checking against the wider circle.
@ -1374,11 +1372,7 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event)
} else if (SkeletonDocumentEditMode::Add == m_document->editMode) {
if (m_cursorNodeItem->isVisible()) {
if (m_addFromNodeItem) {
if (m_hoveredNodeItem && m_addFromNodeItem &&
m_hoveredNodeItem != m_addFromNodeItem &&
m_hoveredNodeItem->profile() == m_addFromNodeItem->profile() &&
!m_document->findEdgeByNodes(m_addFromNodeItem->id(), m_hoveredNodeItem->id()) &&
m_document->isNodeEditable(m_hoveredNodeItem->id())) {
if (m_hoveredNodeItem && m_addFromNodeItem && m_hoveredNodeItem != m_addFromNodeItem && m_hoveredNodeItem->profile() == m_addFromNodeItem->profile() && !m_document->findEdgeByNodes(m_addFromNodeItem->id(), m_hoveredNodeItem->id()) && m_document->isNodeEditable(m_hoveredNodeItem->id())) {
if (m_document->isNodeConnectable(m_hoveredNodeItem->id())) {
emit addEdge(m_addFromNodeItem->id(), m_hoveredNodeItem->id());
emit groupOperationAdded();
@ -1436,8 +1430,7 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event)
processed = true;
}
} else {
if ((nullptr == m_hoveredNodeItem || m_rangeSelectionSet.find(m_hoveredNodeItem) == m_rangeSelectionSet.end()) &&
(nullptr == m_hoveredEdgeItem || m_rangeSelectionSet.find(m_hoveredEdgeItem) == m_rangeSelectionSet.end())) {
if ((nullptr == m_hoveredNodeItem || m_rangeSelectionSet.find(m_hoveredNodeItem) == m_rangeSelectionSet.end()) && (nullptr == m_hoveredEdgeItem || m_rangeSelectionSet.find(m_hoveredEdgeItem) == m_rangeSelectionSet.end())) {
if (!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) {
clearRangeSelection();
}
@ -1774,8 +1767,7 @@ void SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
hasSelection()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && hasSelection()) {
rotateSelected(-1);
emit groupOperationAdded();
}
@ -1786,8 +1778,7 @@ void SkeletonGraphicsWidget::shortcutRotateSelectedBy1()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
hasSelection()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && hasSelection()) {
rotateSelected(1);
emit groupOperationAdded();
}
@ -1862,8 +1853,7 @@ void SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
hasSelection()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && hasSelection()) {
scaleSelected(-1);
emit groupOperationAdded();
}
@ -1874,8 +1864,7 @@ void SkeletonGraphicsWidget::shortcutScaleSelectedBy1()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
hasSelection()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && hasSelection()) {
scaleSelected(1);
emit groupOperationAdded();
}
@ -1886,8 +1875,7 @@ void SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
hasSelection()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && hasSelection()) {
switchProfileOnRangeSelection();
}
}
@ -1914,8 +1902,7 @@ void SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partDisabled = part && part->disabled;
emit setPartDisableState(m_lastCheckedPart, !partDisabled);
@ -1928,8 +1915,7 @@ void SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partLocked = part && part->locked;
emit setPartLockState(m_lastCheckedPart, !partLocked);
@ -1942,8 +1928,7 @@ void SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partXmirrored = part && part->xMirrored;
emit setPartXmirrorState(m_lastCheckedPart, !partXmirrored);
@ -1956,8 +1941,7 @@ void SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partSubdived = part && part->subdived;
emit setPartSubdivState(m_lastCheckedPart, !partSubdived);
@ -1970,8 +1954,7 @@ void SkeletonGraphicsWidget::shortcutChamferedOrNotSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partChamfered = part && part->chamfered;
emit setPartChamferState(m_lastCheckedPart, !partChamfered);
@ -1992,8 +1975,7 @@ void SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart()
if (!isVisible())
return;
if ((SkeletonDocumentEditMode::Select == m_document->editMode) &&
!m_lastCheckedPart.isNull()) {
if ((SkeletonDocumentEditMode::Select == m_document->editMode) && !m_lastCheckedPart.isNull()) {
const SkeletonPart* part = m_document->findPart(m_lastCheckedPart);
bool partRounded = part && part->rounded;
emit setPartRoundState(m_lastCheckedPart, !partRounded);
@ -2004,10 +1986,7 @@ void SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart()
bool SkeletonGraphicsWidget::keyPress(QKeyEvent* event)
{
if (event->key() == Qt::Key_Space) {
if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode ||
SkeletonDocumentEditMode::ZoomOut == m_document->editMode ||
SkeletonDocumentEditMode::Select == m_document->editMode ||
SkeletonDocumentEditMode::Add == m_document->editMode) {
if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode || SkeletonDocumentEditMode::ZoomOut == m_document->editMode || SkeletonDocumentEditMode::Select == m_document->editMode || SkeletonDocumentEditMode::Add == m_document->editMode) {
m_inTempDragMode = true;
m_modeBeforeEnterTempDragMode = m_document->editMode;
emit setEditMode(SkeletonDocumentEditMode::Drag);
@ -2814,8 +2793,7 @@ void SkeletonGraphicsWidget::ikMoveReady()
{
unsigned long long movedUpdateVersion = m_ikMover->getUpdateVersion();
if (movedUpdateVersion == m_ikMoveUpdateVersion &&
!m_ikMoveEndEffectorId.isNull()) {
if (movedUpdateVersion == m_ikMoveUpdateVersion && !m_ikMoveEndEffectorId.isNull()) {
emit batchChangeBegin();
for (const auto& it : m_ikMover->ikNodes()) {
if (m_rotated)
@ -2830,8 +2808,7 @@ void SkeletonGraphicsWidget::ikMoveReady()
delete m_ikMover;
m_ikMover = nullptr;
if (movedUpdateVersion != m_ikMoveUpdateVersion &&
!m_ikMoveEndEffectorId.isNull()) {
if (movedUpdateVersion != m_ikMoveUpdateVersion && !m_ikMoveEndEffectorId.isNull()) {
ikMove(m_ikMoveEndEffectorId, m_ikMoveTarget);
}
}

View File

@ -1,32 +1,31 @@
#ifndef DUST3D_APPLICATION_SKELETON_GRAPHICS_VIEW_H_
#define DUST3D_APPLICATION_SKELETON_GRAPHICS_VIEW_H_
#include <map>
#include <QMouseEvent>
#include <QKeyEvent>
#include "model_widget.h"
#include "skeleton_document.h"
#include "skeleton_ik_mover.h"
#include "theme.h"
#include "turnaround_loader.h"
#include <QGraphicsEllipseItem>
#include <QGraphicsLineItem>
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QGraphicsPolygonItem>
#include <QGraphicsView>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QThread>
#include <cmath>
#include <set>
#include <QTimer>
#include "skeleton_document.h"
#include "turnaround_loader.h"
#include "theme.h"
#include "skeleton_ik_mover.h"
#include "model_widget.h"
#include <cmath>
#include <map>
#include <set>
class SkeletonGraphicsOriginItem : public QGraphicsPolygonItem
{
class SkeletonGraphicsOriginItem : public QGraphicsPolygonItem {
public:
SkeletonGraphicsOriginItem(SkeletonProfile profile=SkeletonProfile::Unknown) :
m_profile(profile),
m_hovered(false),
m_checked(false),
m_rotated(false)
SkeletonGraphicsOriginItem(SkeletonProfile profile = SkeletonProfile::Unknown)
: m_profile(profile)
, m_hovered(false)
, m_checked(false)
, m_rotated(false)
{
setData(0, "origin");
}
@ -38,8 +37,7 @@ public:
{
QColor color = Theme::white;
switch (m_profile)
{
switch (m_profile) {
case SkeletonProfile::Unknown:
break;
case SkeletonProfile::Main:
@ -99,6 +97,7 @@ public:
{
return m_hovered;
}
private:
SkeletonProfile m_profile;
bool m_hovered;
@ -107,8 +106,7 @@ private:
bool m_rotated;
};
class SkeletonGraphicsSelectionItem : public QGraphicsRectItem
{
class SkeletonGraphicsSelectionItem : public QGraphicsRectItem {
public:
SkeletonGraphicsSelectionItem()
{
@ -124,16 +122,15 @@ public:
}
};
class SkeletonGraphicsNodeItem : public QGraphicsEllipseItem
{
class SkeletonGraphicsNodeItem : public QGraphicsEllipseItem {
public:
SkeletonGraphicsNodeItem(SkeletonProfile profile=SkeletonProfile::Unknown) :
m_profile(profile),
m_hovered(false),
m_checked(false),
m_markColor(Qt::transparent),
m_deactivated(false),
m_rotated(false)
SkeletonGraphicsNodeItem(SkeletonProfile profile = SkeletonProfile::Unknown)
: m_profile(profile)
, m_hovered(false)
, m_checked(false)
, m_markColor(Qt::transparent)
, m_deactivated(false)
, m_rotated(false)
{
setData(0, "node");
setRadius(32);
@ -147,8 +144,7 @@ public:
QColor color = Qt::gray;
if (!m_deactivated) {
switch (m_profile)
{
switch (m_profile) {
case SkeletonProfile::Unknown:
break;
case SkeletonProfile::Main:
@ -253,6 +249,7 @@ public:
{
return m_hovered;
}
private:
dust3d::Uuid m_uuid;
SkeletonProfile m_profile;
@ -263,17 +260,16 @@ private:
bool m_rotated;
};
class SkeletonGraphicsEdgeItem : public QGraphicsPolygonItem
{
class SkeletonGraphicsEdgeItem : public QGraphicsPolygonItem {
public:
SkeletonGraphicsEdgeItem() :
m_firstItem(nullptr),
m_secondItem(nullptr),
m_hovered(false),
m_checked(false),
m_profile(SkeletonProfile::Unknown),
m_deactivated(false),
m_rotated(false)
SkeletonGraphicsEdgeItem()
: m_firstItem(nullptr)
, m_secondItem(nullptr)
, m_hovered(false)
, m_checked(false)
, m_profile(SkeletonProfile::Unknown)
, m_deactivated(false)
, m_rotated(false)
{
setData(0, "edge");
}
@ -317,8 +313,7 @@ public:
QColor color = Qt::gray;
if (!m_deactivated) {
switch (m_firstItem->profile())
{
switch (m_firstItem->profile()) {
case SkeletonProfile::Unknown:
break;
case SkeletonProfile::Main:
@ -380,6 +375,7 @@ public:
{
return m_hovered;
}
private:
dust3d::Uuid m_uuid;
SkeletonGraphicsNodeItem* m_firstItem;
@ -392,8 +388,7 @@ private:
bool m_rotated;
};
class SkeletonGraphicsWidget : public QGraphicsView
{
class SkeletonGraphicsWidget : public QGraphicsView {
Q_OBJECT
public:
~SkeletonGraphicsWidget();
@ -445,6 +440,7 @@ signals:
void shortcutToggleFlatShading();
void shortcutToggleRotation();
void loadedTurnaroundImageChanged();
public:
SkeletonGraphicsWidget(const SkeletonDocument* document);
std::map<dust3d::Uuid, std::pair<SkeletonGraphicsNodeItem*, SkeletonGraphicsNodeItem*>> nodeItemMap;
@ -474,6 +470,7 @@ public:
bool inputWheelEventFromOtherWidget(QWheelEvent* event);
bool rotated();
const QImage* loadedTurnaroundImage() const;
protected:
void mouseMoveEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
@ -577,6 +574,7 @@ public slots:
void shortcutEscape();
private slots:
void turnaroundImageReady();
private:
QPointF mouseEventScenePos(QMouseEvent* event);
QPointF scenePosToUnified(QPointF pos);
@ -600,6 +598,7 @@ private:
void rotateItems(const std::set<SkeletonGraphicsNodeItem*>& nodeItems, int degree, QVector2D center);
void rotateAllSideProfile(int degree);
bool isFloatEqual(float a, float b);
private:
const SkeletonDocument* m_document = nullptr;
QGraphicsPixmapItem* m_backgroundItem = nullptr;
@ -645,14 +644,14 @@ private:
std::set<dust3d::Uuid> m_deferredRemoveEdgeIds;
};
class SkeletonGraphicsContainerWidget : public QWidget
{
class SkeletonGraphicsContainerWidget : public QWidget {
Q_OBJECT
signals:
void containerSizeChanged(QSize size);
public:
SkeletonGraphicsContainerWidget() :
m_graphicsWidget(nullptr)
SkeletonGraphicsContainerWidget()
: m_graphicsWidget(nullptr)
{
}
void resizeEvent(QResizeEvent* event) override
@ -664,6 +663,7 @@ public:
{
m_graphicsWidget = graphicsWidget;
}
private:
SkeletonGraphicsWidget* m_graphicsWidget;
};

View File

@ -1,6 +1,6 @@
#include <QGuiApplication>
#include "skeleton_ik_mover.h"
#include "ccd_ik_resolver.h"
#include <QGuiApplication>
SkeletonIkMover::SkeletonIkMover()
{

View File

@ -2,19 +2,17 @@
#define DUST3D_APPLICATION_SKELETON_IK_MOVER_H_
#include <QObject>
#include <vector>
#include <QVector3D>
#include <dust3d/base/uuid.h>
#include <vector>
struct SkeletonIkNode
{
struct SkeletonIkNode {
dust3d::Uuid id;
QVector3D position;
QVector3D newPosition;
};
class SkeletonIkMover : public QObject
{
class SkeletonIkMover : public QObject {
Q_OBJECT
public:
SkeletonIkMover();
@ -28,8 +26,10 @@ signals:
void finished();
public slots:
void process();
private:
void resolve();
private:
unsigned long long m_updateVersion = 0;
std::vector<SkeletonIkNode> m_ikNodes;

View File

@ -1,8 +1,8 @@
#include "spinnable_toolbar_icon.h"
#include "theme.h"
SpinnableToolbarIcon::SpinnableToolbarIcon(QWidget *parent) :
QWidget(parent)
SpinnableToolbarIcon::SpinnableToolbarIcon(QWidget* parent)
: QWidget(parent)
{
setFixedSize(Theme::toolIconSize, Theme::toolIconSize);

View File

@ -1,16 +1,16 @@
#ifndef DUST3D_APPLICATION_SPINNABLE_TOOLBAR_ICON_H_
#define DUST3D_APPLICATION_SPINNABLE_TOOLBAR_ICON_H_
#include <QWidget>
#include "waitingspinnerwidget.h"
#include "toolbar_button.h"
#include "waitingspinnerwidget.h"
#include <QWidget>
class SpinnableToolbarIcon : public QWidget
{
class SpinnableToolbarIcon : public QWidget {
public:
SpinnableToolbarIcon(QWidget* parent = nullptr);
void showSpinner(bool showSpinner = true);
bool isSpinning();
private:
WaitingSpinnerWidget* m_spinner = nullptr;
};

View File

@ -1,19 +1,19 @@
#include <QPainter>
#include <QGuiApplication>
#include <QRegion>
#include <QPolygon>
#include <QElapsedTimer>
#include <QRadialGradient>
#include <dust3d/base/texture_type.h>
#include "texture_generator.h"
#include "theme.h"
#include "material.h"
#include "debug.h"
#include "material.h"
#include "theme.h"
#include <QElapsedTimer>
#include <QGuiApplication>
#include <QPainter>
#include <QPolygon>
#include <QRadialGradient>
#include <QRegion>
#include <dust3d/base/texture_type.h>
QColor TextureGenerator::m_defaultTextureColor = Qt::transparent;
TextureGenerator::TextureGenerator(const dust3d::Object &object, dust3d::Snapshot *snapshot) :
m_snapshot(snapshot)
TextureGenerator::TextureGenerator(const dust3d::Object& object, dust3d::Snapshot* snapshot)
: m_snapshot(snapshot)
{
m_object = new dust3d::Object();
*m_object = object;
@ -426,8 +426,7 @@ void TextureGenerator::generate()
if (findNeighborColor == partColorMap.end())
return;
for (const auto& it : allRects->second) {
if (it.contains(firstPoint.x(), firstPoint.y()) ||
it.contains(secondPoint.x(), secondPoint.y())) {
if (it.contains(firstPoint.x(), firstPoint.y()) || it.contains(secondPoint.x(), secondPoint.y())) {
float finalRadius = (it.width() + it.height()) * 0.5 * findNeighborColorSolubility->second;
if (finalRadius < edgeLength)
finalRadius = edgeLength;
@ -552,9 +551,7 @@ void TextureGenerator::generate()
const std::vector<dust3d::Vector2>& uv = triangleVertexUvs[triangleIndex];
dust3d::Vector2 middlePoint = (uv[0] + uv[1] + uv[2]) / 3.0;
float finalRadius = ((uv[0] - uv[1]).length() +
(uv[1] - uv[2]).length() +
(uv[2] - uv[0]).length()) / 3.0;
float finalRadius = ((uv[0] - uv[1]).length() + (uv[1] - uv[2]).length() + (uv[2] - uv[0]).length()) / 3.0;
QRadialGradient gradient(QPointF(middlePoint.x() * TextureGenerator::m_textureSize,
middlePoint.y() * TextureGenerator::m_textureSize),
finalRadius * TextureGenerator::m_textureSize);
@ -669,9 +666,7 @@ QImage *TextureGenerator::combineMetalnessRoughnessAmbientOcclusionImages(QImage
QImage* ambientOcclusionImage)
{
QImage* textureMetalnessRoughnessAmbientOcclusionImage = nullptr;
if (nullptr != metalnessImage ||
nullptr != roughnessImage ||
nullptr != ambientOcclusionImage) {
if (nullptr != metalnessImage || nullptr != roughnessImage || nullptr != ambientOcclusionImage) {
int textureSize = 0;
if (nullptr != metalnessImage)
textureSize = metalnessImage->height();

View File

@ -1,17 +1,16 @@
#ifndef DUST3D_APPLICATION_TEXTURE_GENERATOR_H_
#define DUST3D_APPLICATION_TEXTURE_GENERATOR_H_
#include <QObject>
#include <vector>
#include <QImage>
#include "model_mesh.h"
#include <QColor>
#include <QImage>
#include <QObject>
#include <QPixmap>
#include <dust3d/base/object.h>
#include <dust3d/base/snapshot.h>
#include "model_mesh.h"
#include <vector>
class TextureGenerator : public QObject
{
class TextureGenerator : public QObject {
Q_OBJECT
public:
TextureGenerator(const dust3d::Object& object, dust3d::Snapshot* snapshot = nullptr);
@ -37,10 +36,13 @@ signals:
void finished();
public slots:
void process();
public:
static QColor m_defaultTextureColor;
private:
void prepare();
private:
dust3d::Object* m_object = nullptr;
QImage* m_resultTextureColorImage = nullptr;

View File

@ -1,9 +1,9 @@
#include "theme.h"
#include <QApplication>
#include <QStyleFactory>
#include <QPalette>
#include <QFont>
#include <QFontMetrics>
#include "theme.h"
#include <QPalette>
#include <QStyleFactory>
QColor Theme::white = QColor(0xf7, 0xd9, 0xc8);
QColor Theme::red = QColor(0xfc, 0x66, 0x21);

View File

@ -1,15 +1,14 @@
#ifndef DUST3D_APPLICATION_THEME_H_
#define DUST3D_APPLICATION_THEME_H_
#include <QColor>
#include <QChar>
#include <QPushButton>
#include <QLabel>
#include <QCheckBox>
#include "QtAwesome.h"
#include <QChar>
#include <QCheckBox>
#include <QColor>
#include <QLabel>
#include <QPushButton>
class Theme
{
class Theme {
public:
static QColor white;
static QColor red;

View File

@ -1,10 +1,10 @@
#include <QSvgWidget>
#include <QGridLayout>
#include "toolbar_button.h"
#include "theme.h"
#include <QGridLayout>
#include <QSvgWidget>
ToolbarButton::ToolbarButton(const QString &filename, QWidget *parent) :
QPushButton(parent)
ToolbarButton::ToolbarButton(const QString& filename, QWidget* parent)
: QPushButton(parent)
{
auto margin = Theme::toolIconSize / 5;

View File

@ -6,12 +6,12 @@
class QSvgWidget;
class ToolbarButton : public QPushButton
{
class ToolbarButton : public QPushButton {
Q_OBJECT
public:
ToolbarButton(const QString& filename = QString(), QWidget* parent = nullptr);
void setIcon(const QString& filename);
private:
QSvgWidget* m_iconWidget = nullptr;
};

View File

@ -1,5 +1,5 @@
#include <QGuiApplication>
#include "turnaround_loader.h"
#include <QGuiApplication>
TurnaroundLoader::TurnaroundLoader(const QString& filename, QSize viewSize)
{

View File

@ -1,13 +1,12 @@
#ifndef DUST3D_APPLICATION_TURNAROUND_LOADER_H_
#define DUST3D_APPLICATION_TURNAROUND_LOADER_H_
#include <QObject>
#include <QString>
#include <QSize>
#include <QImage>
#include <QObject>
#include <QSize>
#include <QString>
class TurnaroundLoader : public QObject
{
class TurnaroundLoader : public QObject {
Q_OBJECT
public:
TurnaroundLoader(const QString& filename, QSize viewSize);
@ -18,6 +17,7 @@ signals:
void finished();
public slots:
void process();
private:
QImage* m_resultImage = nullptr;
QImage m_inputImage;

Some files were not shown because too many files have changed in this diff Show More