Overte C++ Documentation
RingGizmoPropertyGroup.h
1 //
2 // Created by Sam Gondelman on 1/22/19
3 // Copyright 2019 High Fidelity, Inc.
4 // Copyright 2023 Overte e.V.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 // SPDX-License-Identifier: Apache-2.0
9 //
10 
11 #ifndef hifi_RingGizmoPropertyGroup_h
12 #define hifi_RingGizmoPropertyGroup_h
13 
14 #include <stdint.h>
15 
16 #include "PropertyGroup.h"
17 #include "EntityItemPropertiesMacros.h"
18 #include "EntityItemPropertiesDefaults.h"
19 
21 class EncodeBitstreamParams;
22 class OctreePacketData;
23 class ReadBitstreamToTreeParams;
24 class ScriptEngine;
25 class ScriptValue;
26 
27 using u8vec3Color = glm::u8vec3;
28 
29 /*@jsdoc
30  * A {@link Entities.EntityProperties-Gizmo|ring Gizmo} entity is defined by the following properties:
31  * @typedef {object} Entities.RingGizmo
32  *
33  * @property {number} startAngle=0 - The angle at which the ring starts, in degrees.
34  * @property {number} endAngle=360 - The angle at which the ring ends, in degrees.
35  * @property {number} innerRadius=0 - The inner radius of the ring as a fraction of the total radius, range <code>0.0</code>
36  * &mdash; <code>1.0</code>.
37 
38  * @property {Color} innerStartColor=255,255,255 - The color at the inner start point of the ring.
39  * @property {Color} innerEndColor=255,255,255 - The color at the inner end point of the ring.
40  * @property {Color} outerStartColor=255,255,255 - The color at the outer start point of the ring.
41  * @property {Color} outerEndColor=255,255,255 - The color at the outer end point of the ring.
42  * @property {number} innerStartAlpha=1 - The opacity at the inner start point of the ring.
43  * @property {number} innerEndAlpha=1 - The opacity at the inner end point of the ring.
44  * @property {number} outerStartAlpha=1 - The opacity at the outer start point of the ring.
45  * @property {number} outerEndAlpha=1 - The opacity at the outer end point of the ring.
46 
47  * @property {boolean} hasTickMarks=false - <code>true</code> to render tick marks, otherwise <code>false</code>.
48  * @property {number} majorTickMarksAngle=0 - The angle between major tick marks, in degrees.
49  * @property {number} minorTickMarksAngle=0 - The angle between minor tick marks, in degrees.
50  * @property {number} majorTickMarksLength=0 - The length of the major tick marks as a fraction of the radius. A positive value
51  * draws tick marks outwards from the inner radius; a negative value draws tick marks inwards from the outer radius.
52  * @property {number} minorTickMarksLength=0 - The length of the minor tick marks, as a fraction of the radius. A positive
53  * value draws tick marks outwards from the inner radius; a negative value draws tick marks inwards from the outer radius.
54  * @property {Color} majorTickMarksColor=255,255,255 - The color of the major tick marks.
55  * @property {Color} minorTickMarksColor=255,255,255 - The color of the minor tick marks.
56  */
57 
58 class RingGizmoPropertyGroup : public PropertyGroup {
59 public:
60  // EntityItemProperty related helpers
61  virtual void copyToScriptValue(const EntityPropertyFlags& desiredProperties, ScriptValue& properties,
62  ScriptEngine* engine, bool skipDefaults,
63  EntityItemProperties& defaultEntityProperties, bool returnNothingOnEmptyPropertyFlags,
64  bool isMyOwnAvatarEntity) const override;
65  virtual void copyFromScriptValue(const ScriptValue& object, const QSet<QString> &namesSet, bool& _defaultSettings) override;
66 
67  void merge(const RingGizmoPropertyGroup& other);
68 
69  virtual void debugDump() const override;
70  virtual void listChangedProperties(QList<QString>& out) override;
71 
72  virtual bool appendToEditPacket(OctreePacketData* packetData,
73  EntityPropertyFlags& requestedProperties,
74  EntityPropertyFlags& propertyFlags,
75  EntityPropertyFlags& propertiesDidntFit,
76  int& propertyCount,
77  OctreeElement::AppendState& appendState) const override;
78 
79  virtual bool decodeFromEditPacket(EntityPropertyFlags& propertyFlags,
80  const unsigned char*& dataAt, int& processedBytes) override;
81  virtual void markAllChanged() override;
82  virtual EntityPropertyFlags getChangedProperties() const override;
83 
84  // EntityItem related helpers
85  // methods for getting/setting all properties of an entity
86  virtual void getProperties(EntityItemProperties& propertiesOut) const override;
87 
88  // returns true if something changed
89  virtual bool setProperties(const EntityItemProperties& properties) override;
90 
91  virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
92 
93  virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
94  EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
95  EntityPropertyFlags& requestedProperties,
96  EntityPropertyFlags& propertyFlags,
97  EntityPropertyFlags& propertiesDidntFit,
98  int& propertyCount,
99  OctreeElement::AppendState& appendState) const override;
100 
101  virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
102  ReadBitstreamToTreeParams& args,
103  EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
104  bool& somethingChanged) override;
105 
106  bool operator==(const RingGizmoPropertyGroup& a) const;
107  bool operator!=(const RingGizmoPropertyGroup& a) const { return !(*this == a); }
108 
109  static const float MIN_ANGLE;
110  static const float MAX_ANGLE;
111  static const float MIN_ALPHA;
112  static const float MAX_ALPHA;
113  static const float MIN_RADIUS;
114  static const float MAX_RADIUS;
115 
116  DEFINE_PROPERTY(PROP_START_ANGLE, StartAngle, startAngle, float, 0.0f);
117  DEFINE_PROPERTY(PROP_END_ANGLE, EndAngle, endAngle, float, 360.0f);
118  DEFINE_PROPERTY(PROP_INNER_RADIUS, InnerRadius, innerRadius, float, 0.0f);
119 
120  DEFINE_PROPERTY_REF(PROP_INNER_START_COLOR, InnerStartColor, innerStartColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
121  DEFINE_PROPERTY_REF(PROP_INNER_END_COLOR, InnerEndColor, innerEndColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
122  DEFINE_PROPERTY_REF(PROP_OUTER_START_COLOR, OuterStartColor, outerStartColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
123  DEFINE_PROPERTY_REF(PROP_OUTER_END_COLOR, OuterEndColor, outerEndColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
124 
125  DEFINE_PROPERTY(PROP_INNER_START_ALPHA, InnerStartAlpha, innerStartAlpha, float, ENTITY_ITEM_DEFAULT_ALPHA);
126  DEFINE_PROPERTY(PROP_INNER_END_ALPHA, InnerEndAlpha, innerEndAlpha, float, ENTITY_ITEM_DEFAULT_ALPHA);
127  DEFINE_PROPERTY(PROP_OUTER_START_ALPHA, OuterStartAlpha, outerStartAlpha, float, ENTITY_ITEM_DEFAULT_ALPHA);
128  DEFINE_PROPERTY(PROP_OUTER_END_ALPHA, OuterEndAlpha, outerEndAlpha, float, ENTITY_ITEM_DEFAULT_ALPHA);
129 
130  DEFINE_PROPERTY(PROP_HAS_TICK_MARKS, HasTickMarks, hasTickMarks, bool, false);
131  DEFINE_PROPERTY(PROP_MAJOR_TICK_MARKS_ANGLE, MajorTickMarksAngle, majorTickMarksAngle, float, 0.0f);
132  DEFINE_PROPERTY(PROP_MINOR_TICK_MARKS_ANGLE, MinorTickMarksAngle, minorTickMarksAngle, float, 0.0f);
133  DEFINE_PROPERTY(PROP_MAJOR_TICK_MARKS_LENGTH, MajorTickMarksLength, majorTickMarksLength, float, 0.0f);
134  DEFINE_PROPERTY(PROP_MINOR_TICK_MARKS_LENGTH, MinorTickMarksLength, minorTickMarksLength, float, 0.0f);
135  DEFINE_PROPERTY_REF(PROP_MAJOR_TICK_MARKS_COLOR, MajorTickMarksColor, majorTickMarksColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
136  DEFINE_PROPERTY_REF(PROP_MINOR_TICK_MARKS_COLOR, MinorTickMarksColor, minorTickMarksColor, u8vec3Color, ENTITY_ITEM_DEFAULT_COLOR);
137 };
138 
139 #endif // hifi_RingGizmoPropertyGroup_h
Definition: EntityItemProperties.h:106
Handles packing of the data portion of PacketType_OCTREE_DATA messages.
Definition: OctreePacketData.h:93
Provides an engine-independent interface for a scripting engine.
Definition: ScriptEngine.h:93
[ScriptInterface] Provides an engine-independent interface for QScriptValue
Definition: ScriptValue.h:40