Wed, 25 May 2022 12:01:58 +0300
cleanup, gl::Compiler changed to gl::ModelShaders
#include <QBrush> #include <QFont> #include "object.h" #include "widgets/vec3editor.h" #include "modeleditor.h" static std::int32_t getIdForNewObject() { static std::int32_t id = 0; id += 1; return id; } ldraw::Object::Object() : id {getIdForNewObject()} { } ldraw::Object::~Object() { } bool ldraw::Object::hasColor() const { return false; } QVariant ldraw::Object::getProperty(Property id) const { Q_UNUSED(id); return {}; } void ldraw::Object::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) { Q_UNUSED(result) Q_UNUSED(pair) } /** * @brief public interface to setProperty */ ldraw::Object::SetPropertyResult ldraw::Object::setProperty(const PropertyKeyValue& pair) { SetPropertyResult result; this->setProperty(&result, pair); return result; } QBrush ldraw::Object::textRepresentationForeground() const { return {}; } QBrush ldraw::Object::textRepresentationBackground() const { return {}; } QFont ldraw::Object::textRepresentationFont() const { return {}; } void ldraw::Object::getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const { Q_UNUSED(polygons) Q_UNUSED(context) } const glm::vec3& ldraw::Object::getPoint(int index) const { Q_UNUSED(index); throw BadPointIndex{}; } /** * @brief Serializes the object into a stream of bytes for internal storage. * @param stream Data stream to serialize into */ QDataStream& ldraw::Object::serialize(QDataStream &stream) const { return stream << static_cast<int>(this->typeIdentifier()); } /** * @brief Deserializes the object from a stream of bytes coming from internal storage. * @param stream Data stream to serialize from. * @note @c ldraw::Object::serialize will insert a type enumerator. Before calling this function, * this enumerator is assumed to have been handled as the object class needs to be initialized based * on the value of this enumerator. */ QDataStream& ldraw::Object::deserialize(QDataStream &stream) { return stream; } QString ldraw::Object::iconName() const { return ""; } ldraw::ColoredObject::ColoredObject(const Color color_index) : colorIndex{color_index} { } bool ldraw::ColoredObject::hasColor() const { return true; } QVariant ldraw::ColoredObject::getProperty(Property id) const { switch (id) { case Property::Color: return QVariant::fromValue<Color>(colorIndex); default: return Object::getProperty(id); } } void ldraw::ColoredObject::setProperty(SetPropertyResult* result, const PropertyKeyValue& pair) { LDRAW_OBJECT_HANDLE_SET_PROPERTY(Color, {colorIndex = value;}); Object::setProperty(result, pair); } /** * @brief @overload @c ldraw::Object::serialize * @param stream * @return stream */ QDataStream& ldraw::ColoredObject::serialize(QDataStream& stream) const { return Object::serialize(stream) << this->colorIndex; } /** * @brief @overload @c ldraw::Object::deserialize * @param stream * @return stream */ QDataStream& ldraw::ColoredObject::deserialize(QDataStream& stream) { return Object::deserialize(stream) >> this->colorIndex; } QString ldraw::Empty::textRepresentation() const { return ""; } ldraw::Object::Type ldraw::Empty::typeIdentifier() const { return Type::Empty; } QString ldraw::Empty::toLDrawCode() const { return ""; } QString ldraw::Empty::typeName() const { return QObject::tr("empty"); }