iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
imstkVisualModel.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkComponent.h"
10 #include "imstkEventObject.h"
11 
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 
16 namespace imstk
17 {
18 class Geometry;
19 class RenderMaterial;
20 class Renderer;
21 
27 class VisualModel : public Component, public EventObject
28 {
29 public:
30  VisualModel(const std::string& name = "VisualModel");
31  ~VisualModel() override = default;
32 
33  // *INDENT-OFF*
34  SIGNAL(VisualModel, modified);
35  // *INDENT-ON*
36 
40  std::shared_ptr<Geometry> getGeometry() const { return m_geometry; }
41  void setGeometry(std::shared_ptr<Geometry> geometry) { m_geometry = geometry; }
43 
47  const std::string& getName() const { return m_name; }
48  void setName(std::string name) { m_name = name; }
50 
55  const std::string getDelegateHint() const;
56  void setDelegateHint(const std::string& name) { m_delegateHint = name; }
58 
62  void setRenderMaterial(std::shared_ptr<RenderMaterial> renderMaterial);
63  std::shared_ptr<RenderMaterial> getRenderMaterial() const { return m_renderMaterial; }
65 
69  void show() { setIsVisible(true); }
70  void hide() { setIsVisible(false); }
71  bool isVisible() const { return m_isVisible; }
72  void setIsVisible(const bool visible);
74 
79  void setRenderDelegateCreated(Renderer* ren, bool created) { m_renderDelegateCreated[ren] = created; }
81 
82  void postModified() { this->postEvent(Event(VisualModel::modified())); }
83 
84 protected:
85  std::string m_delegateHint;
86 
87  std::shared_ptr<Geometry> m_geometry;
88  std::shared_ptr<RenderMaterial> m_renderMaterial;
89 
90  bool m_isVisible;
91  std::unordered_map<Renderer*, bool> m_renderDelegateCreated;
92 };
93 } // namespace imstk
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
const std::string getDelegateHint() const
Get/Set the delegate hint, which helps indicate how to render this VisualModel.
Compound Geometry.
Rendering window manager and contains user API to configure the rendering with various backends...
Definition: imstkRenderer.h:41
const std::string & getName() const
Get/Set name.
bool m_isVisible
true if mesh is shown, false if mesh is hidden
void setRenderMaterial(std::shared_ptr< RenderMaterial > renderMaterial)
Set/Get render material.
EventObject is the base class for all objects in iMSTK that can receive and emit events. It supports direct and queued observer functions. Direct observers receive events immediately on the same thread This can either be posted on an object or be a function pointer Queued observers receive events within their queue which they can process whenever they like. These can be connected with the connect/queuedConnect/disconnect functions Lambda recievers cannot be disconnected unless all receivers to a signal are removed.
Represents a part of an entity, involved in a system. The component system is doubly linked meaning t...
void postEvent(const T &e)
Emits the event Direct observers will be immediately called, in sync Queued observers will receive th...
bool getRenderDelegateCreated(Renderer *ren)
Get/Set whether the delegate has been created.
void show()
Visibility functions.
std::shared_ptr< Geometry > getGeometry() const
Get/Set geometry.
Contains geometric, material, and render information.