2021-06-15 22:12:41 +03:00
|
|
|
//#
|
|
|
|
//# Copyright (C) 2021-2021 QuasarApp.
|
|
|
|
//# Distributed under the GPLv3 software license, see the accompanying
|
|
|
|
//# Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
//# of this license document, but changing it is not allowed.
|
|
|
|
//#
|
|
|
|
|
2021-05-25 17:18:56 +03:00
|
|
|
#ifndef GUIOBJECT_H
|
|
|
|
#define GUIOBJECT_H
|
|
|
|
|
|
|
|
#include "QObject"
|
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
#include <QQuaternion>
|
2021-05-25 17:18:56 +03:00
|
|
|
#include <QRectF>
|
2021-06-02 18:29:07 +03:00
|
|
|
#include <QVector3D>
|
2021-06-16 16:10:14 +03:00
|
|
|
#include "Crawl/irender.h"
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-18 22:33:00 +03:00
|
|
|
#define DEFAULT_VIEW_TEMPLATE "qrc:/CrawlModule/GraphicItem.qml"
|
|
|
|
|
2021-06-07 17:37:03 +03:00
|
|
|
/**
|
|
|
|
* @brief The GuiObject class This base model for gui objects.
|
|
|
|
*/
|
2021-06-16 18:57:50 +03:00
|
|
|
class CRAWL_EXPORT GuiObject: public QObject, public IRender {
|
2021-05-25 17:18:56 +03:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
|
|
|
|
Q_PROPERTY(int guiId READ guiId NOTIFY guiIdChanged)
|
|
|
|
Q_PROPERTY(QString viewTemplate READ viewTemplate NOTIFY viewTemplateChanged)
|
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
Q_PROPERTY(QVector3D position READ position WRITE setposition NOTIFY positionChanged)
|
|
|
|
Q_PROPERTY(QVector3D size READ size WRITE setSize NOTIFY sizeChanged)
|
|
|
|
Q_PROPERTY(QQuaternion ratation READ ratation WRITE setRatation NOTIFY ratationChanged)
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
Q_PROPERTY(QString mash READ mash WRITE setMash NOTIFY mashChanged)
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-01 18:00:17 +03:00
|
|
|
// textures
|
|
|
|
Q_PROPERTY(QString baseColorMap READ baseColorMap NOTIFY baseColorMapChanged)
|
|
|
|
Q_PROPERTY(QString roughnessMap READ roughnessMap NOTIFY roughnessMapChanged)
|
|
|
|
Q_PROPERTY(QString normalMap READ normalMap NOTIFY normalMapChanged)
|
|
|
|
Q_PROPERTY(QString emissiveMap READ emissiveMap NOTIFY emissiveMapChanged)
|
2021-05-25 17:18:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
2021-06-18 22:33:00 +03:00
|
|
|
GuiObject(const QString& name,
|
|
|
|
const QString& viewTempalte = DEFAULT_VIEW_TEMPLATE,
|
|
|
|
QObject *ptr = nullptr);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-01 18:00:17 +03:00
|
|
|
QString color() const;
|
|
|
|
void setColor(QString color);
|
|
|
|
|
|
|
|
virtual void reset();
|
|
|
|
QString viewTemplate() const;
|
|
|
|
|
2021-05-25 17:18:56 +03:00
|
|
|
int guiId() const;
|
2021-06-01 18:00:17 +03:00
|
|
|
void setGuiId(int guiId);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-01 18:00:17 +03:00
|
|
|
void setX(float newX);
|
|
|
|
void setY(float newY);
|
|
|
|
void setZ(float newZ);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-01 18:00:17 +03:00
|
|
|
void setDx(float newDx);
|
|
|
|
void setDy(float newDy);
|
|
|
|
void setDz(float newDz);
|
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
const QString &baseColorMap() const;
|
|
|
|
const QString &roughnessMap() const;
|
|
|
|
const QString &normalMap() const;
|
|
|
|
const QString &emissiveMap() const;
|
2021-06-01 18:00:17 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
/**
|
|
|
|
* @brief center This method return center of object
|
|
|
|
* @return 3d point of the object center.
|
|
|
|
* @warning This method calc center in runtime.
|
|
|
|
*/
|
|
|
|
QVector3D center() const;
|
2021-06-01 18:00:17 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
/**
|
|
|
|
* @brief intersects This method check if this object contains @a point object.
|
|
|
|
* @param point This is checked point
|
|
|
|
* @return true if the point contains in the object cube.
|
2021-06-07 17:37:03 +03:00
|
|
|
* @warning This functions check intersect approximate and only works correctly for cubic objects. if you try compare plane objects or lines you get incorrect results.
|
2021-06-02 18:29:07 +03:00
|
|
|
*/
|
|
|
|
bool intersects(const QVector3D& point) const;
|
2021-06-01 18:00:17 +03:00
|
|
|
|
2021-06-07 17:37:03 +03:00
|
|
|
/**
|
|
|
|
* @brief intersects This method check intersects betwin current object and @a object.
|
|
|
|
* @param object This is input object.
|
|
|
|
* @return true if the two objects has common points.
|
|
|
|
* @warning This functions check intersect approximate and only works correctly for cubic objects. if you try compare plane objects or lines you get incorrect results.
|
|
|
|
*/
|
|
|
|
bool intersects(const GuiObject& object) const;
|
2021-06-01 18:00:17 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
const QVector3D &position() const;
|
|
|
|
void setposition(const QVector3D &newposition);
|
2021-06-01 18:00:17 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
const QVector3D &size() const;
|
|
|
|
void setSize(const QVector3D &newSize);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
const QQuaternion &ratation() const;
|
|
|
|
void setRatation(const QQuaternion &newRatation);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
const QString &mash() const;
|
|
|
|
void setMash(const QString &newMash);
|
2021-05-25 17:18:56 +03:00
|
|
|
|
2021-06-18 22:33:00 +03:00
|
|
|
/**
|
|
|
|
* @brief className This method return class name.
|
|
|
|
* The class name using as a group of objects on thw world.
|
|
|
|
* @return class name;
|
|
|
|
* @note the class name should be sets on the consturctor of child classes of this class.
|
|
|
|
*/
|
|
|
|
const QString &className() const;
|
|
|
|
|
2021-05-25 17:18:56 +03:00
|
|
|
signals:
|
|
|
|
void guiIdChanged(int guiId);
|
|
|
|
void colorChanged(QString color);
|
2021-06-01 18:00:17 +03:00
|
|
|
void viewTemplateChanged(QString viewTemplate);
|
|
|
|
|
|
|
|
void baseColorMapChanged();
|
|
|
|
void roughnessMapChanged();
|
|
|
|
void normalMapChanged();
|
|
|
|
void emissiveMapChanged();
|
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
void positionChanged();
|
|
|
|
void sizeChanged();
|
|
|
|
void ratationChanged();
|
|
|
|
|
|
|
|
void mashChanged();
|
|
|
|
|
2021-06-01 18:00:17 +03:00
|
|
|
protected:
|
|
|
|
int _guiId = -1;
|
2021-06-16 18:57:50 +03:00
|
|
|
QString _color = "#ff1111";
|
2021-06-01 18:00:17 +03:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
void generateId();
|
|
|
|
|
|
|
|
QString _baseColorMap;
|
|
|
|
QString _roughnessMap;
|
|
|
|
QString _normalMap;
|
|
|
|
QString _emissiveMap;
|
|
|
|
QString _viewTemplate;
|
|
|
|
|
2021-06-02 18:29:07 +03:00
|
|
|
QVector3D _position;
|
|
|
|
QVector3D _size;
|
|
|
|
QQuaternion _ratation;
|
|
|
|
QString _mash;
|
2021-06-18 22:33:00 +03:00
|
|
|
QString _className;
|
2021-05-25 17:18:56 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GUIOBJECT_H
|