51 IsVisualizeMaskEnum<T>::value &&
52 std::is_same_v<std::underlying_type_t<T>,
int> &&
53 std::is_same_v<T, std::remove_cvref_t<T>>;
68 std::type_index type_;
72 template <AnyVisualizeMaskEnumType T>
75 template <AnyVisualizeMaskEnumType T>
76 [[nodiscard]] std::optional<T>
tryGet()
const
78 if ( type_ ==
typeid(T) )
118 operator uint32_t&() {
return f; }
119 operator uint32_t()
const {
return f; }
126 Dirty& operator =( uint32_t b ) noexcept {
f = b;
return *
this; }
139 constexpr static const char*
TypeName() noexcept {
return "VisualObject"; }
140 virtual const char*
typeName()
const override {
return TypeName(); }
143 virtual std::string
getClassName()
const override {
return "Visual Object"; }
163 std::size_t counter = 0;
164 setAllVisualizeProperties_( properties, counter );
168 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
169 void showLabels(
bool on ) {
return setVisualizeProperty( on, VisualizeMaskType::Labels, ViewportMask::all() ); }
170 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
171 bool showLabels()
const {
return getVisualizeProperty( VisualizeMaskType::Labels, ViewportMask::any() ); }
174 void showName(
bool on ) {
return setVisualizeProperty( on, VisualizeMaskType::Name, ViewportMask::all() ); }
176 bool showName()
const {
return getVisualizeProperty( VisualizeMaskType::Name, ViewportMask::any() ); }
208 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
210 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
213 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
216 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
236 return Object::getRedrawFlag( viewportMask ) ||
237 ( isVisible( viewportMask ) &&
265 virtual void setShininess(
float shininess ) { shininess_ = shininess; needRedraw_ =
true; }
270 virtual void setSpecularStrength(
float specularStrength ) { specularStrength_ = specularStrength; needRedraw_ =
true; }
275 virtual void setAmbientStrength(
float ambientStrength ) { ambientStrength_ = ambientStrength; needRedraw_ =
true; }
277 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
278 const std::vector<PositionedText>&
getLabels()
const {
return labels_; }
279 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
280 virtual void setLabels( std::vector<PositionedText> labels ) { labels_ = std::move( labels ); needRedraw_ =
true; }
311 { useDefaultScenePropertiesOnDeserialization_ = useDefaultScenePropertiesOnDeserialization; }
339 float shininess_{35.0f};
340 float specularStrength_{ 0.5f };
341 float ambientStrength_{ 0.1f };
353 bool useDefaultScenePropertiesOnDeserialization_{
false };
369 template <AnyVisualizeMaskEnumType T>
372 for (
int i = 0; i < int( T::_count ); i++ )
373 setVisualizePropertyMask( T( i ), properties[pos++] );
376 template <AnyVisualizeMaskEnumType T>
379 properties.reserve( properties.size() + std::size_t( T::_count ) );
380 for (
int i = 0; i < int( ( T::_count ) ); i++ )
381 properties.push_back( getVisualizePropertyMask( T( i ) ) );
385 mutable Box3f boundingBoxCache_;
388 void setDefaultColors_();
391 void setDefaultSceneProperties_();
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
InvertedNormals
Definition MRVisualObject.h:34
Visibility
Definition MRVisualObject.h:33
ClippedByPlane
Definition MRVisualObject.h:38
CropLabelsByViewportRect
Definition MRVisualObject.h:37
Labels
Definition MRVisualObject.h:36
Name
Definition MRVisualObject.h:35
DepthTest
Definition MRVisualObject.h:39
Definition MRVisualObject.h:67
AnyVisualizeMaskEnum(T value)
Definition MRVisualObject.h:73
std::optional< T > tryGet() const
Definition MRVisualObject.h:76
named object in the data model
Definition MRObject.h:60
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Definition MRViewportProperty.h:17
Visual Object.
Definition MRVisualObject.h:131
MRMESH_API bool useDefaultScenePropertiesOnDeserialization() const
Definition MRVisualObject.h:307
virtual MRMESH_API const ViewportProperty< Color > & getFrontColorsForAllViewports(bool selected=true) const
returns color of object when it is selected/not-selected (depending on argument) in all viewports
virtual bool getRedrawFlag(ViewportMask viewportMask) const override
returns true if the object must be redrawn (due to dirty flags) in one of specified viewports
Definition MRVisualObject.h:234
virtual MRMESH_API void setFrontColor(const Color &color, bool selected, ViewportId viewportId={})
sets color of object when it is selected/not-selected (depending on argument) in given viewport
MRMESH_API ViewportMask & getVisualizePropertyMask_(AnyVisualizeMaskEnum type)
ViewportMask showLabels_
Definition MRVisualObject.h:330
MRMESH_API void setUseDefaultScenePropertiesOnDeserialization(bool useDefaultScenePropertiesOnDeserialization)
Definition MRVisualObject.h:310
VisualObject(ProtectedStruct, const VisualObject &obj)
this ctor is public only for std::make_shared used inside clone()
Definition MRVisualObject.h:298
virtual MRMESH_API bool supportsVisualizeProperty(AnyVisualizeMaskEnum type) const
Returns true if this class supports the property type. Otherwise passing it to the functions below is...
virtual MRMESH_API void renderForPicker(const ModelBaseRenderParams &, unsigned) const
draws this object for picking
float getShininess() const
returns the current shininess visual value
Definition MRVisualObject.h:263
virtual MRMESH_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
MRMESH_API VisualObject()
virtual MRMESH_API std::shared_ptr< Object > clone() const override
MRMESH_API void setVisualizeProperty(bool value, AnyVisualizeMaskEnum type, ViewportMask viewportMask)
set visual property in all viewports specified by the mask
MRMESH_API const ViewportProperty< Color > & getLabelsColorsForAllViewports() const
MRMESH_API void resetDirty() const
resets all dirty flags (except for cache flags that will be reset automatically on cache update)
virtual MRMESH_API Box3f getWorldBox(ViewportId={}) const override
virtual ~VisualObject()=default
MRMESH_API bool getVisualizeProperty(AnyVisualizeMaskEnum type, ViewportMask viewportMask) const
returns true if the property is set at least in one viewport specified by the mask
virtual MRMESH_API void setDirtyFlags(uint32_t mask, bool invalidateCaches=true)
virtual MRMESH_API const ViewportProperty< uint8_t > & getGlobalAlphaForAllViewports() const
returns global transparency alpha of object in all viewports
MRMESH_API const Color & getLabelsColor(ViewportId viewportId={}) const
void getAllVisualizePropertiesForEnum(AllVisualizeProperties &properties) const
Definition MRVisualObject.h:377
virtual void setSpecularStrength(float specularStrength)
sets intensity of reflections
Definition MRVisualObject.h:270
virtual MRMESH_API void setBackColor(const Color &color, ViewportId viewportId={})
sets backward color of object in given viewport
static constexpr const char * TypeName() noexcept
Definition MRVisualObject.h:139
virtual void updateVertsColorMap(VertColors &vertsColorMap)
swaps per-vertex colors of the object with given argument
Definition MRVisualObject.h:251
virtual Box3f computeBoundingBox_() const
Definition MRVisualObject.h:361
virtual MRMESH_API bool render(const ModelRenderParams &) const
bool showLabels() const
Definition MRVisualObject.h:171
ViewportProperty< Color > unselectedColor_
Definition MRVisualObject.h:347
virtual MRMESH_API void setLabelsColorsForAllViewports(ViewportProperty< Color > val)
virtual MRMESH_API void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos)
ViewportMask showName_
Definition MRVisualObject.h:331
MRMESH_API uint32_t getDirtyFlags() const
returns current dirty flags for the object
Definition MRVisualObject.h:224
MRMESH_API void deserializeFields_(const Json::Value &root) override
virtual MRMESH_API void setBackColorsForAllViewports(ViewportProperty< Color > val)
sets backward color of object in all viewports
virtual MRMESH_API void setLabelsColor(const Color &color, ViewportId viewportId={})
virtual const char * typeName() const override
Definition MRVisualObject.h:140
bool showName() const
returns whether object name is shown in any viewport
Definition MRVisualObject.h:176
MRMESH_API const Color & getFrontColor(bool selected=true, ViewportId viewportId={}) const
returns color of object when it is selected/not-selected (depending on argument) in given viewport
virtual MRMESH_API const ViewportProperty< Color > & getBackColorsForAllViewports() const
returns backward color of object in all viewports
float getSpecularStrength() const
returns intensity of reflections
Definition MRVisualObject.h:268
virtual MRMESH_API std::vector< std::string > getInfoLines() const override
return several info lines that can better describe the object in the UI
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
VertColors vertsColorMap_
Definition MRVisualObject.h:345
virtual MRMESH_API void renderUi(const UiRenderParams ¶ms) const
draws this object for 2d UI
VisualObject(const VisualObject &obj)=default
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRVisualObject.h:143
Dirty dirty_
Definition MRVisualObject.h:324
virtual MRMESH_API void setGlobalAlphaForAllViewports(ViewportProperty< uint8_t > val)
sets global transparency alpha of object in all viewports
void showLabels(bool on)
shows/hides labels
Definition MRVisualObject.h:169
virtual void setupRenderObject_() const
Definition MRVisualObject.h:321
virtual MRMESH_API void setColoringType(ColoringType coloringType)
sets coloring mode of the object with given argument
MRMESH_API Box3f getBoundingBox() const
returns cached bounding box of this object in local coordinates
virtual void setAmbientStrength(float ambientStrength)
sets intensity of non-directional light
Definition MRVisualObject.h:275
bool isPickable(ViewportMask viewportMask=ViewportMask::any()) const
whether the object can be picked (by mouse) in any of given viewports
Definition MRVisualObject.h:242
virtual MRMESH_API const ViewportMask & getVisualizePropertyMask(AnyVisualizeMaskEnum type) const
returns mask of viewports where given property is set
VisualObject(VisualObject &&)=default
virtual MRMESH_API void copyColors(const VisualObject &src, const VertMap &thisToSrc, const FaceMap &thisToSrcFaces={})
copies point colors from given source object
virtual MRMESH_API void setGlobalAlpha(uint8_t alpha, ViewportId viewportId={})
sets global transparency alpha of object in given viewport
void setAllVisualizeProperties(const AllVisualizeProperties &properties)
set all visualize properties masks
Definition MRVisualObject.h:161
void showName(bool on)
shows/hides object name in all viewports
Definition MRVisualObject.h:174
void setAllVisualizePropertiesForEnum(const AllVisualizeProperties &properties, std::size_t &pos)
Definition MRVisualObject.h:370
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
std::vector< PositionedText > labels_
Definition MRVisualObject.h:351
UniquePtr< IRenderObject > renderObj_
Definition MRVisualObject.h:323
virtual MRMESH_API AllVisualizeProperties getAllVisualizeProperties() const
get all visualize properties masks
ViewportMask clipByPlane_
Definition MRVisualObject.h:329
virtual void setLabels(std::vector< PositionedText > labels)
Definition MRVisualObject.h:280
ViewportProperty< Color > selectedColor_
Definition MRVisualObject.h:346
virtual MRMESH_API void setFrontColorsForAllViewports(ViewportProperty< Color > val, bool selected=true)
sets color of object when it is selected/not-selected (depending on argument) in all viewports
virtual MRMESH_API void setVisualizePropertyMask(AnyVisualizeMaskEnum type, ViewportMask viewportMask)
set visual property mask
ColoringType getColoringType() const
returns the current coloring mode of the object
Definition MRVisualObject.h:254
virtual void setVertsColorMap(VertColors vertsColorMap)
sets per-vertex colors of the object
Definition MRVisualObject.h:249
const VertColors & getVertsColorMap() const
returns per-vertex colors of the object
Definition MRVisualObject.h:247
virtual MRMESH_API void setPickable(bool on, ViewportMask viewportMask=ViewportMask::all())
sets the object as can/cannot be picked (by mouse) in all of given viewports
virtual void setShininess(float shininess)
sets shininess visual value of the object with given argument
Definition MRVisualObject.h:265
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
ViewportProperty< Color > backFacesColor_
Definition MRVisualObject.h:348
const std::vector< PositionedText > & getLabels() const
Definition MRVisualObject.h:278
MRMESH_API const Color & getBackColor(ViewportId viewportId={}) const
returns backward color of object in given viewport
MRMESH_API void toggleVisualizeProperty(AnyVisualizeMaskEnum type, ViewportMask viewportMask)
toggle visual property in all viewports specified by the mask
ViewportMask invertNormals_
invert mesh normals
Definition MRVisualObject.h:334
MRMESH_API void boundingBoxToInfoLines_(std::vector< std::string > &res) const
adds information about bounding box in res
float getAmbientStrength() const
returns intensity of non-directional light
Definition MRVisualObject.h:273
MRMESH_API const uint8_t & getGlobalAlpha(ViewportId viewportId={}) const
returns global transparency alpha of object in given viewport
Definition MRVisualObject.h:50
DirtyFlags
Definition MRVisualObject.h:88
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:85
ColoringType
Definition MRVisualObject.h:21
@ DIRTY_PRIMITIVE_COLORMAP
Definition MRVisualObject.h:101
@ DIRTY_POSITION
Definition MRVisualObject.h:90
@ DIRTY_TEXTURE
Definition MRVisualObject.h:97
@ DIRTY_NONE
Definition MRVisualObject.h:89
@ DIRTY_SELECTION
Definition MRVisualObject.h:96
@ DIRTY_FACES_RENDER_NORMAL
gl normals
Definition MRVisualObject.h:93
@ DIRTY_MESH
Definition MRVisualObject.h:104
@ DIRTY_FACES_COLORMAP
Definition MRVisualObject.h:102
@ DIRTY_TEXTURE_PER_FACE
Definition MRVisualObject.h:103
@ DIRTY_FACE
Definition MRVisualObject.h:99
@ DIRTY_EDGES_SELECTION
Definition MRVisualObject.h:107
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:100
@ DIRTY_RENDER_NORMALS
Definition MRVisualObject.h:95
@ DIRTY_BORDER_LINES
Definition MRVisualObject.h:106
@ DIRTY_ALL
Definition MRVisualObject.h:109
@ DIRTY_VERTS_RENDER_NORMAL
Definition MRVisualObject.h:92
@ DIRTY_CACHES
Definition MRVisualObject.h:108
@ DIRTY_UV
Definition MRVisualObject.h:91
@ DIRTY_PRIMITIVES
Definition MRVisualObject.h:98
@ DIRTY_BOUNDING_BOX
Definition MRVisualObject.h:105
@ DIRTY_CORNERS_RENDER_NORMAL
gl normals
Definition MRVisualObject.h:94
@ LinesColorMap
Use different color (taken from faces colormap) for each line (primitive for object lines)
@ VertsColorMap
Use different color (taken from verts colormap) for each vert.
@ SolidColor
Use simple color for whole mesh.
@ FacesColorMap
Use different color (taken from faces colormap) for each face (primitive for object mesh)
@ PrimitivesColorMap
Use different color (taken from faces colormap) for each ptimitive.
Definition MRCameraOrientationPlugin.h:8
Definition MRVisualObject.h:116
uint32_t f
Definition MRVisualObject.h:117
Dirty & operator=(const Dirty &) noexcept
Definition MRVisualObject.h:124
Dirty(Dirty &&) noexcept=default
Definition MRVisualObject.h:45
Definition MRIRenderObject.h:43
Mesh rendering parameters for primary rendering (as opposed to the picker).
Definition MRIRenderObject.h:51
Definition MRObject.h:246
Definition MRIRenderObject.h:107
Definition MRUniquePtr.h:12