41 IsVisualizeMaskEnum<T>::value &&
42 std::is_same_v<std::underlying_type_t<T>,
int> &&
43 std::is_same_v<T, std::remove_cvref_t<T>>;
58 std::type_index type_;
62 template <AnyVisualizeMaskEnumType T>
65 template <AnyVisualizeMaskEnumType T>
66 [[nodiscard]] std::optional<T>
tryGet()
const
68 if ( type_ ==
typeid(T) )
109 operator uint32_t&() {
return f; }
110 operator uint32_t()
const {
return f; }
117 Dirty& operator =( uint32_t b ) noexcept {
f = b;
return *
this; }
130 constexpr static const char*
TypeName() noexcept {
return "VisualObject"; }
131 virtual const char*
typeName()
const override {
return TypeName(); }
154 std::size_t counter = 0;
155 setAllVisualizeProperties_( properties, counter );
159 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
161 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
165 void showName(
bool on ) {
return setVisualizeProperty( on, VisualizeMaskType::Name, ViewportMask::all() ); }
167 bool showName()
const {
return getVisualizeProperty( VisualizeMaskType::Name, ViewportMask::any() ); }
199 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
201 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
204 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
207 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
229 return Object::getRedrawFlag( viewportMask ) ||
230 ( isVisible( viewportMask ) &&
248 virtual void setShininess(
float shininess ) { shininess_ = shininess; needRedraw_ =
true; }
253 virtual void setSpecularStrength(
float specularStrength ) { specularStrength_ = specularStrength; needRedraw_ =
true; }
258 virtual void setAmbientStrength(
float ambientStrength ) { ambientStrength_ = ambientStrength; needRedraw_ =
true; }
260 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
262 [[deprecated(
"please use ObjectLabel mechanism instead" )]]
263 MR_BIND_IGNORE virtual void setLabels( std::vector<PositionedText> labels ) { labels_ = std::move( labels ); needRedraw_ =
true; }
294 { useDefaultScenePropertiesOnDeserialization_ = useDefaultScenePropertiesOnDeserialization; }
326 float shininess_{35.0f};
327 float specularStrength_{ 0.5f };
328 float ambientStrength_{ 0.1f };
339 bool useDefaultScenePropertiesOnDeserialization_{
false };
355 template <AnyVisualizeMaskEnumType T>
358 for (
int i = 0; i < int( T::_count ); i++ )
359 setVisualizePropertyMask( T( i ), properties[pos++] );
362 template <AnyVisualizeMaskEnumType T>
365 properties.reserve( properties.size() + std::size_t( T::_count ) );
366 for (
int i = 0; i < int( ( T::_count ) ); i++ )
367 properties.push_back( getVisualizePropertyMask( T( i ) ) );
371 mutable Dirty dirty_;
373 mutable Box3f boundingBoxCache_;
376 void setDefaultColors_();
379 void setDefaultSceneProperties_();
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
InvertedNormals
Definition MRVisualObject.h:24
Visibility
Definition MRVisualObject.h:23
ClippedByPlane
Definition MRVisualObject.h:28
CropLabelsByViewportRect
Definition MRVisualObject.h:27
Labels
Definition MRVisualObject.h:26
Name
Definition MRVisualObject.h:25
DepthTest
Definition MRVisualObject.h:29
Definition MRVisualObject.h:57
AnyVisualizeMaskEnum(T value)
Definition MRVisualObject.h:63
std::optional< T > tryGet() const
Definition MRVisualObject.h:66
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:42
Definition MRViewportProperty.h:17
Visual Object.
Definition MRVisualObject.h:122
MRMESH_API bool useDefaultScenePropertiesOnDeserialization() const
Definition MRVisualObject.h:290
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:227
virtual MRMESH_API void resetColors()
reset all object colors to their default values from the current theme
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
virtual MR_BIND_IGNORE void setLabels(std::vector< PositionedText > labels)
Definition MRVisualObject.h:263
MRMESH_API ViewportMask & getVisualizePropertyMask_(AnyVisualizeMaskEnum type)
ViewportMask showLabels_
Definition MRVisualObject.h:317
MRMESH_API void setUseDefaultScenePropertiesOnDeserialization(bool useDefaultScenePropertiesOnDeserialization)
Definition MRVisualObject.h:293
VisualObject(ProtectedStruct, const VisualObject &obj)
this ctor is public only for std::make_shared used inside clone()
Definition MRVisualObject.h:281
MR_BIND_IGNORE void showLabels(bool on)
shows/hides labels
Definition MRVisualObject.h:160
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...
MR_BIND_IGNORE bool showLabels() const
Definition MRVisualObject.h:162
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:246
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 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 virtual MR_BIND_IGNORE void setLabelsColorsForAllViewports(ViewportProperty< Color > val)
MRMESH_API virtual MR_BIND_IGNORE void setLabelsColor(const Color &color, ViewportId viewportId={})
void getAllVisualizePropertiesForEnum(AllVisualizeProperties &properties) const
Definition MRVisualObject.h:363
virtual void setSpecularStrength(float specularStrength)
sets intensity of reflections
Definition MRVisualObject.h:253
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:130
MRMESH_API MR_BIND_IGNORE const ViewportProperty< Color > & getLabelsColorsForAllViewports() const
virtual Box3f computeBoundingBox_() const
Definition MRVisualObject.h:347
virtual MRMESH_API bool render(const ModelRenderParams &) const
ViewportProperty< Color > unselectedColor_
Definition MRVisualObject.h:333
virtual MRMESH_API void setAllVisualizeProperties_(const AllVisualizeProperties &properties, std::size_t &pos)
ViewportMask showName_
Definition MRVisualObject.h:318
MRMESH_API uint32_t getDirtyFlags() const
returns current dirty flags for the object
Definition MRVisualObject.h:215
std::string getClassNameInPlural() const override
return human readable name of subclass in plural form
Definition MRVisualObject.h:134
MRMESH_API void deserializeFields_(const Json::Value &root) override
MR_BIND_IGNORE const std::vector< PositionedText > & getLabels() const
Definition MRVisualObject.h:261
virtual MRMESH_API void setBackColorsForAllViewports(ViewportProperty< Color > val)
sets backward color of object in all viewports
virtual const char * typeName() const override
Definition MRVisualObject.h:131
bool showName() const
returns whether object name is shown in any viewport
Definition MRVisualObject.h:167
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:251
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
virtual MRMESH_API void renderUi(const UiRenderParams ¶ms) const
draws this object for 2d UI
VisualObject(const VisualObject &obj)=default
virtual MRMESH_API void resetDirtyExceptMask(uint32_t mask) const
reset dirty flags without some specific bits (useful for lazy normals update)
virtual MRMESH_API void setGlobalAlphaForAllViewports(ViewportProperty< uint8_t > val)
sets global transparency alpha of object in all viewports
virtual void setupRenderObject_() const
Definition MRVisualObject.h:309
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:258
bool isPickable(ViewportMask viewportMask=ViewportMask::any()) const
whether the object can be picked (by mouse) in any of given viewports
Definition MRVisualObject.h:235
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 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:152
void showName(bool on)
shows/hides object name in all viewports
Definition MRVisualObject.h:165
MRMESH_API MR_BIND_IGNORE const Color & getLabelsColor(ViewportId viewportId={}) const
void setAllVisualizePropertiesForEnum(const AllVisualizeProperties &properties, std::size_t &pos)
Definition MRVisualObject.h:356
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
std::vector< PositionedText > labels_
Definition MRVisualObject.h:337
UniquePtr< IRenderObject > renderObj_
Definition MRVisualObject.h:311
virtual MRMESH_API AllVisualizeProperties getAllVisualizeProperties() const
get all visualize properties masks
ViewportMask clipByPlane_
Definition MRVisualObject.h:316
std::string getClassName() const override
return human readable name of subclass
Definition MRVisualObject.h:133
ViewportProperty< Color > selectedColor_
Definition MRVisualObject.h:332
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:240
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:248
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
ViewportProperty< Color > backFacesColor_
Definition MRVisualObject.h:334
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:321
MRMESH_API void boundingBoxToInfoLines_(std::vector< std::string > &res) const
adds information about bounding box in res
virtual MRMESH_API void resetFrontColor()
reset basic object colors to their default values from the current theme
float getAmbientStrength() const
returns intensity of non-directional light
Definition MRVisualObject.h:256
MRMESH_API const uint8_t & getGlobalAlpha(ViewportId viewportId={}) const
returns global transparency alpha of object in given viewport
Definition MRVisualObject.h:40
DirtyFlags
Definition MRVisualObject.h:78
std::vector< ViewportMask > AllVisualizeProperties
Definition MRVisualObject.h:75
@ DIRTY_PRIMITIVE_COLORMAP
Definition MRVisualObject.h:91
@ DIRTY_POSITION
Definition MRVisualObject.h:80
@ DIRTY_TEXTURE
Definition MRVisualObject.h:87
@ DIRTY_NONE
Definition MRVisualObject.h:79
@ DIRTY_SELECTION
Definition MRVisualObject.h:86
@ DIRTY_FACES_RENDER_NORMAL
gl normals
Definition MRVisualObject.h:83
@ DIRTY_MESH
Definition MRVisualObject.h:94
@ DIRTY_FACES_COLORMAP
Definition MRVisualObject.h:92
@ DIRTY_TEXTURE_PER_FACE
Definition MRVisualObject.h:93
@ DIRTY_FACE
Definition MRVisualObject.h:89
@ DIRTY_EDGES_SELECTION
Definition MRVisualObject.h:97
@ DIRTY_VERTS_COLORMAP
Definition MRVisualObject.h:90
@ DIRTY_RENDER_NORMALS
Definition MRVisualObject.h:85
@ DIRTY_BORDER_LINES
Definition MRVisualObject.h:96
@ DIRTY_ALL
Definition MRVisualObject.h:100
@ DIRTY_VOLUME
Definition MRVisualObject.h:99
@ DIRTY_VERTS_RENDER_NORMAL
Definition MRVisualObject.h:82
@ DIRTY_CACHES
Definition MRVisualObject.h:98
@ DIRTY_UV
Definition MRVisualObject.h:81
@ DIRTY_PRIMITIVES
Definition MRVisualObject.h:88
@ DIRTY_BOUNDING_BOX
Definition MRVisualObject.h:95
@ DIRTY_CORNERS_RENDER_NORMAL
gl normals
Definition MRVisualObject.h:84
Definition MRCameraOrientationPlugin.h:8
ColoringType
Definition MREnums.h:56
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
Definition MRMesh/MRColor.h:9
Definition MRVisualObject.h:107
uint32_t f
Definition MRVisualObject.h:108
Dirty & operator=(const Dirty &) noexcept
Definition MRVisualObject.h:115
Dirty(Dirty &&) noexcept=default
Definition MRVisualObject.h:35
Definition MRIRenderObject.h:43
Mesh rendering parameters for primary rendering (as opposed to the picker).
Definition MRIRenderObject.h:51
Definition MRObject.h:274
Definition MRIRenderObject.h:107
Definition MRUniquePtr.h:12