diff -r 6988973515d2 -r ca23936b455b src/linetypes/object.cpp --- a/src/linetypes/object.cpp Wed May 25 20:36:34 2022 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -#include -#include -#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& 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(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(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"); -}