2021-11-18 14:58:01 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
|
|
|
|
#define DUST3D_APPLICATION_MATERIAL_EDIT_WIDGET_H_
|
|
|
|
|
|
|
|
#include "float_number_widget.h"
|
2022-10-18 09:35:04 +00:00
|
|
|
#include "image_preview_widget.h"
|
2021-11-18 14:58:01 +00:00
|
|
|
#include "material_layer.h"
|
2022-10-18 09:35:04 +00:00
|
|
|
#include "material_previews_generator.h"
|
|
|
|
#include "model_widget.h"
|
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <map>
|
2020-12-19 02:29:24 +00:00
|
|
|
|
|
|
|
class Document;
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
enum class PopupWidgetType {
|
2018-10-09 02:19:12 +00:00
|
|
|
PitchYawRoll,
|
|
|
|
Intersection
|
|
|
|
};
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
class MaterialEditWidget : public QDialog {
|
2018-10-09 02:19:12 +00:00
|
|
|
Q_OBJECT
|
|
|
|
signals:
|
2021-11-18 14:58:01 +00:00
|
|
|
void addMaterial(dust3d::Uuid materialId, QString name, std::vector<MaterialLayer> layers);
|
|
|
|
void removeMaterial(dust3d::Uuid materialId);
|
|
|
|
void setMaterialLayers(dust3d::Uuid materialId, std::vector<MaterialLayer> layers);
|
|
|
|
void renameMaterial(dust3d::Uuid materialId, QString name);
|
2018-10-09 02:19:12 +00:00
|
|
|
void layersAdjusted();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
public:
|
2022-10-18 09:35:04 +00:00
|
|
|
MaterialEditWidget(const Document* document, QWidget* parent = nullptr);
|
2018-10-09 02:19:12 +00:00
|
|
|
~MaterialEditWidget();
|
|
|
|
public slots:
|
|
|
|
void updatePreview();
|
2021-11-18 14:58:01 +00:00
|
|
|
void setEditMaterialId(dust3d::Uuid materialId);
|
2018-10-09 02:19:12 +00:00
|
|
|
void setEditMaterialName(QString name);
|
2018-10-25 00:19:38 +00:00
|
|
|
void setEditMaterialLayers(std::vector<MaterialLayer> layers);
|
2018-10-09 02:19:12 +00:00
|
|
|
void updateTitle();
|
|
|
|
void save();
|
|
|
|
void clearUnsaveState();
|
|
|
|
void previewReady();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
protected:
|
|
|
|
QSize sizeHint() const override;
|
2022-10-18 09:35:04 +00:00
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2018-10-09 02:19:12 +00:00
|
|
|
void reject() override;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
private:
|
2022-10-18 09:35:04 +00:00
|
|
|
void updateMapButtonBackground(ImagePreviewWidget* button, const QImage* image);
|
|
|
|
ImagePreviewWidget* createMapButton();
|
|
|
|
QImage* pickImage();
|
|
|
|
const Document* m_document = nullptr;
|
|
|
|
MaterialPreviewsGenerator* m_materialPreviewsGenerator = nullptr;
|
|
|
|
ModelWidget* m_previewWidget = nullptr;
|
|
|
|
FloatNumberWidget* m_tileScaleSlider = nullptr;
|
2018-10-09 02:19:12 +00:00
|
|
|
bool m_isPreviewDirty = false;
|
|
|
|
bool m_closed = false;
|
2021-11-18 14:58:01 +00:00
|
|
|
dust3d::Uuid m_materialId;
|
2018-10-09 02:19:12 +00:00
|
|
|
bool m_unsaved = false;
|
2022-10-18 09:35:04 +00:00
|
|
|
QLineEdit* m_nameEdit = nullptr;
|
2018-10-25 00:19:38 +00:00
|
|
|
std::vector<MaterialLayer> m_layers;
|
2022-10-18 09:35:04 +00:00
|
|
|
ImagePreviewWidget* m_textureMapButtons[(int)dust3d::TextureType::Count - 1] = { nullptr };
|
2018-10-09 02:19:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|