2017-07-19 23:20:32 +02:00
|
|
|
#pragma once
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2015-12-22 23:44:46 +01:00
|
|
|
#include "lc_array.h"
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
struct lcPartProperties;
|
|
|
|
class lcQPropertiesTreeDelegate;
|
|
|
|
|
2015-12-22 23:44:46 +01:00
|
|
|
enum lcPropertyWidgetMode
|
|
|
|
{
|
|
|
|
LC_PROPERTY_WIDGET_EMPTY,
|
|
|
|
LC_PROPERTY_WIDGET_PIECE,
|
|
|
|
LC_PROPERTY_WIDGET_CAMERA,
|
|
|
|
LC_PROPERTY_WIDGET_LIGHT,
|
|
|
|
LC_PROPERTY_WIDGET_MULTIPLE
|
|
|
|
};
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
class lcQPropertiesTree : public QTreeWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
lcQPropertiesTree(QWidget *parent = 0);
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
QSize sizeHint() const override;
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
QTreeWidgetItem *indexToItem(const QModelIndex &index) const
|
|
|
|
{
|
|
|
|
return itemFromIndex(index);
|
|
|
|
}
|
|
|
|
|
2015-12-22 23:44:46 +01:00
|
|
|
void Update(const lcArray<lcObject*>& Selection, lcObject* Focus);
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
QWidget *createEditor(QWidget *parent, QTreeWidgetItem *item) const;
|
|
|
|
bool lastColumn(int column) const;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PropertyTypeRole = Qt::UserRole,
|
|
|
|
PropertyValueRole
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PropertyType
|
|
|
|
{
|
|
|
|
PropertyGroup,
|
2014-05-03 03:22:24 +02:00
|
|
|
PropertyBool,
|
2013-08-09 06:57:18 +02:00
|
|
|
PropertyFloat,
|
2023-08-04 22:26:29 +02:00
|
|
|
PropertyFloatReadOnly,
|
|
|
|
PropertyFloatLightSpotSize,
|
2023-08-07 13:08:13 +02:00
|
|
|
PropertyFloatLightSpotFalloff,
|
2020-01-26 03:07:33 +01:00
|
|
|
PropertyStep,
|
2013-08-09 06:57:18 +02:00
|
|
|
PropertyString,
|
2023-09-02 05:46:29 +02:00
|
|
|
PropertyStringList,
|
2023-08-07 13:08:13 +02:00
|
|
|
PropertyLightFormat,
|
2023-08-04 22:26:29 +02:00
|
|
|
PropertyLightShape,
|
2013-08-09 06:57:18 +02:00
|
|
|
PropertyColor,
|
2023-09-02 19:21:25 +02:00
|
|
|
PropertyPieceColor,
|
2013-08-09 06:57:18 +02:00
|
|
|
PropertyPart
|
|
|
|
};
|
|
|
|
|
|
|
|
protected slots:
|
2014-05-03 03:22:24 +02:00
|
|
|
void slotToggled(bool value);
|
2013-08-09 06:57:18 +02:00
|
|
|
void slotReturnPressed();
|
|
|
|
void slotSetValue(int value);
|
|
|
|
void slotColorButtonClicked();
|
2023-08-27 20:17:07 +02:00
|
|
|
void LightColorButtonClicked();
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
protected:
|
2020-03-22 23:44:41 +01:00
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
2013-08-09 06:57:18 +02:00
|
|
|
void updateColorEditor(QPushButton *editor, int value) const;
|
2023-08-27 20:17:07 +02:00
|
|
|
void UpdateLightColorEditor(QPushButton* Editor, QColor Color) const;
|
2013-08-09 06:57:18 +02:00
|
|
|
|
|
|
|
QTreeWidgetItem *addProperty(QTreeWidgetItem *parent, const QString& label, PropertyType propertyType);
|
|
|
|
|
2015-12-22 23:44:46 +01:00
|
|
|
void SetEmpty();
|
2016-02-09 20:40:59 +01:00
|
|
|
void SetPiece(const lcArray<lcObject*>& Selection, lcObject* Focus);
|
2015-12-22 23:44:46 +01:00
|
|
|
void SetCamera(lcObject* Focus);
|
|
|
|
void SetLight(lcObject* Focus);
|
|
|
|
void SetMultiple();
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2023-08-13 15:15:52 +02:00
|
|
|
lcLightType mLightType;
|
2023-08-04 22:26:29 +02:00
|
|
|
int mLightShape;
|
2023-08-07 13:08:13 +02:00
|
|
|
bool mPOVRayLight;
|
2023-08-04 22:26:29 +02:00
|
|
|
|
2015-12-22 23:44:46 +01:00
|
|
|
lcPropertyWidgetMode mWidgetMode;
|
|
|
|
lcObject* mFocus;
|
2013-08-09 06:57:18 +02:00
|
|
|
|
2023-08-27 20:17:07 +02:00
|
|
|
lcQPropertiesTreeDelegate* mDelegate;
|
2013-08-09 06:57:18 +02:00
|
|
|
QIcon m_expandIcon;
|
|
|
|
QIcon m_checkedIcon;
|
|
|
|
QIcon m_uncheckedIcon;
|
|
|
|
|
2023-09-02 19:21:25 +02:00
|
|
|
QTreeWidgetItem* mPieceAttributesItem;
|
|
|
|
QTreeWidgetItem* partPosition;
|
|
|
|
QTreeWidgetItem* partPositionX;
|
|
|
|
QTreeWidgetItem* partPositionY;
|
|
|
|
QTreeWidgetItem* partPositionZ;
|
|
|
|
QTreeWidgetItem* partRotation;
|
|
|
|
QTreeWidgetItem* partRotationX;
|
|
|
|
QTreeWidgetItem* partRotationY;
|
|
|
|
QTreeWidgetItem* partRotationZ;
|
|
|
|
QTreeWidgetItem* partVisibility;
|
|
|
|
QTreeWidgetItem* partShow;
|
|
|
|
QTreeWidgetItem* partHide;
|
|
|
|
QTreeWidgetItem* partAppearance;
|
|
|
|
QTreeWidgetItem* mPieceColorItem;
|
|
|
|
QTreeWidgetItem* mPieceIdItem;
|
|
|
|
|
|
|
|
QTreeWidgetItem* cameraPosition;
|
|
|
|
QTreeWidgetItem* cameraPositionX;
|
|
|
|
QTreeWidgetItem* cameraPositionY;
|
|
|
|
QTreeWidgetItem* cameraPositionZ;
|
|
|
|
QTreeWidgetItem* cameraTarget;
|
|
|
|
QTreeWidgetItem* cameraTargetX;
|
|
|
|
QTreeWidgetItem* cameraTargetY;
|
|
|
|
QTreeWidgetItem* cameraTargetZ;
|
|
|
|
QTreeWidgetItem* cameraUp;
|
|
|
|
QTreeWidgetItem* cameraUpX;
|
|
|
|
QTreeWidgetItem* cameraUpY;
|
|
|
|
QTreeWidgetItem* cameraUpZ;
|
|
|
|
QTreeWidgetItem* mCameraAttributesItem;
|
|
|
|
QTreeWidgetItem* mCameraProjectionItem;
|
|
|
|
QTreeWidgetItem* cameraFOV;
|
|
|
|
QTreeWidgetItem* cameraNear;
|
|
|
|
QTreeWidgetItem* cameraFar;
|
|
|
|
QTreeWidgetItem* mCameraNameItem;
|
|
|
|
|
|
|
|
QTreeWidgetItem* lightConfiguration;
|
|
|
|
QTreeWidgetItem* lightPosition;
|
|
|
|
QTreeWidgetItem* lightPositionX;
|
|
|
|
QTreeWidgetItem* lightPositionY;
|
|
|
|
QTreeWidgetItem* lightPositionZ;
|
|
|
|
QTreeWidgetItem* lightTarget;
|
|
|
|
QTreeWidgetItem* lightTargetX;
|
|
|
|
QTreeWidgetItem* lightTargetY;
|
|
|
|
QTreeWidgetItem* lightTargetZ;
|
|
|
|
QTreeWidgetItem* mLightColorItem;
|
|
|
|
QTreeWidgetItem* mLightAttributesItem;
|
|
|
|
QTreeWidgetItem* lightDiffuse;
|
|
|
|
QTreeWidgetItem* lightSpecular;
|
|
|
|
QTreeWidgetItem* lightCutoff;
|
|
|
|
QTreeWidgetItem* lightEnableCutoff;
|
|
|
|
QTreeWidgetItem* lightExponent;
|
|
|
|
QTreeWidgetItem* mLightTypeItem;
|
|
|
|
QTreeWidgetItem* lightSpotSize;
|
|
|
|
QTreeWidgetItem* lightShape;
|
|
|
|
QTreeWidgetItem* lightFactorA;
|
|
|
|
QTreeWidgetItem* lightFactorB;
|
|
|
|
QTreeWidgetItem* mLightNameItem;
|
|
|
|
QTreeWidgetItem* lightFormat;
|
2023-09-02 19:40:52 +02:00
|
|
|
QTreeWidgetItem* mLightCastShadowItem;
|
2023-09-02 19:21:25 +02:00
|
|
|
QTreeWidgetItem* lightAreaGridRows;
|
|
|
|
QTreeWidgetItem* lightAreaGridColumns;
|
|
|
|
QTreeWidgetItem* lightSpotFalloff;
|
|
|
|
QTreeWidgetItem* lightSpotTightness;
|
2013-08-09 06:57:18 +02:00
|
|
|
};
|
|
|
|
|
2016-05-08 04:16:52 +02:00
|
|
|
class lcQPropertiesTreeDelegate : public QItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
lcQPropertiesTreeDelegate(QObject *parent = 0)
|
|
|
|
: QItemDelegate(parent), m_treeWidget(0), m_editedItem(0), m_editedWidget(0), m_disablePainting(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void setTreeWidget(lcQPropertiesTree *treeWidget)
|
|
|
|
{
|
|
|
|
m_treeWidget = treeWidget;
|
|
|
|
}
|
|
|
|
|
2020-03-22 23:44:41 +01:00
|
|
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
|
|
|
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const override {}
|
|
|
|
void setEditorData(QWidget *, const QModelIndex &) const override {}
|
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
2016-05-08 04:16:52 +02:00
|
|
|
|
|
|
|
QTreeWidgetItem *editedItem() const
|
|
|
|
{
|
|
|
|
return m_editedItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *editor() const
|
|
|
|
{
|
|
|
|
return m_editedWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-03-22 23:44:41 +01:00
|
|
|
void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QPixmap &pixmap) const override;
|
|
|
|
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override;
|
2016-05-08 04:16:52 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotEditorDestroyed(QObject *object);
|
|
|
|
|
|
|
|
private:
|
|
|
|
int indentation(const QModelIndex &index) const;
|
|
|
|
|
|
|
|
lcQPropertiesTree *m_treeWidget;
|
|
|
|
mutable QTreeWidgetItem *m_editedItem;
|
|
|
|
mutable QWidget *m_editedWidget;
|
|
|
|
mutable bool m_disablePainting;
|
|
|
|
};
|