16 #ifndef SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H 17 #define SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H 19 #include "SurgSim/Graphics/Camera.h" 20 #include "SurgSim/Graphics/Group.h" 21 #include "SurgSim/Graphics/Manager.h" 22 #include "SurgSim/Graphics/Material.h" 23 #include "SurgSim/Graphics/Program.h" 24 #include "SurgSim/Graphics/RenderTarget.h" 25 #include "SurgSim/Graphics/Representation.h" 26 #include "SurgSim/Graphics/Texture.h" 27 #include "SurgSim/Graphics/UniformBase.h" 28 #include "SurgSim/Graphics/View.h" 29 #include "SurgSim/Graphics/ViewElement.h" 47 m_isVisible = visible;
95 return SurgSim::Framework::MANAGER_TYPE_NONE;
98 virtual std::shared_ptr<SurgSim::Graphics::Group>
getOrCreateGroup(
const std::string& name)
100 if (getGroups().find(name) == std::end(getGroups()))
102 addGroup(std::make_shared<MockGroup>(name));
104 return getGroups().at(name);
113 if (Manager::doUpdate(dt))
143 m_isInitialized(false),
145 m_drawAsWireFrame(false)
147 m_transform.setIdentity();
176 return m_isInitialized;
187 virtual bool setMaterial(std::shared_ptr<SurgSim::Framework::Component> material)
194 virtual std::shared_ptr<SurgSim::Graphics::Material>
getMaterial()
const 206 m_drawAsWireFrame = val;
211 return m_drawAsWireFrame;
225 void addUniform(
const std::string& type,
const std::string& name,
const boost::any& value)
227 throw std::logic_error(
"The method or operation is not implemented.");
230 void addUniform(std::shared_ptr<SurgSim::Graphics::UniformBase> uniform)
232 throw std::logic_error(
"The method or operation is not implemented.");
235 void setUniforms(
const std::vector<std::shared_ptr<SurgSim::Graphics::UniformBase>>& uniforms)
237 throw std::logic_error(
"The method or operation is not implemented.");
240 std::vector<std::shared_ptr<SurgSim::Graphics::UniformBase>>
getUniforms()
const 242 throw std::logic_error(
"The method or operation is not implemented.");
250 virtual bool doInitialize()
252 m_isInitialized =
true;
257 virtual bool doWakeUp()
270 bool m_isInitialized;
275 bool m_drawAsWireFrame;
291 SurgSim::Graphics::Representation(name),
292 SurgSim::Graphics::Camera(name),
296 m_pose.setIdentity();
297 m_viewMatrix.setIdentity();
298 m_projectionMatrix.setIdentity();
330 m_viewMatrix = matrix;
344 m_projectionMatrix = matrix;
351 return m_projectionMatrix;
356 return m_projectionMatrix.inverse();
371 virtual bool setMaterial(std::shared_ptr<SurgSim::Framework::Component> material)
378 virtual std::shared_ptr<SurgSim::Graphics::Material>
getMaterial()
const 397 virtual bool setColorRenderTexture(std::shared_ptr<SurgSim::Graphics::Texture> texture)
402 virtual std::shared_ptr<SurgSim::Graphics::Texture> getColorRenderTexture()
const 407 virtual bool setRenderTarget(std::shared_ptr<SurgSim::Graphics::RenderTarget> renderTarget)
432 throw std::logic_error(
"The method or operation is not implemented.");
437 throw std::logic_error(
"The method or operation is not implemented.");
442 throw std::logic_error(
"The method or operation is not implemented.");
447 throw std::logic_error(
"The method or operation is not implemented.");
452 throw std::logic_error(
"The method or operation is not implemented.");
457 throw std::logic_error(
"The method or operation is not implemented.");
462 throw std::logic_error(
"The method or operation is not implemented.");
467 throw std::logic_error(
"The method or operation is not implemented.");
470 std::array<int, 4> getViewport()
const 472 throw std::logic_error(
"The method or operation is not implemented.");
477 throw std::logic_error(
"The method or operation is not implemented.");
482 throw std::logic_error(
"The method or operation is not implemented.");
487 throw std::logic_error(
"The method or operation is not implemented.");
490 void addUniform(
const std::string& type,
const std::string& name,
const boost::any& value)
492 throw std::logic_error(
"The method or operation is not implemented.");
495 void addUniform(std::shared_ptr<SurgSim::Graphics::UniformBase> uniform)
497 throw std::logic_error(
"The method or operation is not implemented.");
500 void setUniforms(
const std::vector<std::shared_ptr<SurgSim::Graphics::UniformBase>>& uniforms)
502 throw std::logic_error(
"The method or operation is not implemented.");
505 std::vector<std::shared_ptr<SurgSim::Graphics::UniformBase>>
getUniforms()
const 507 throw std::logic_error(
"The method or operation is not implemented.");
544 m_isWindowBorderEnabled(true),
547 m_isInitialized(false),
564 std::array<int, 2> result = {m_x, m_y};
572 m_width = dimensions[0];
573 m_height = dimensions[1];
580 std::array<int, 2> result = {m_width, m_height};
586 m_width =
static_cast<int>(dimensions[0]);
587 m_height =
static_cast<int>(dimensions[1]);
592 std::array<double, 2> result = {
static_cast<double>(m_width), static_cast<double>(m_height)};
593 return std::move(result);
600 m_isWindowBorderEnabled = enabled;
606 return m_isWindowBorderEnabled;
632 return m_isInitialized;
643 virtual bool doInitialize()
645 m_isInitialized =
true;
650 virtual bool doWakeUp()
656 int doSetTargetScreen(
int val)
664 int m_width, m_height;
666 bool m_isWindowBorderEnabled;
674 bool m_isInitialized;
691 #endif // SURGSIM_GRAPHICS_UNITTESTS_MOCKOBJECTS_H void setRenderOrder(RenderOrder bin, int value) override
Determine when this camera will render.
Definition: MockObjects.h:417
Base graphics view class, which defines the basic interface for all graphics views.
Definition: View.h:39
virtual void clearMaterial()
Removes the material from the representation.
Definition: MockObjects.h:200
MockManager()
Constructor.
Definition: MockObjects.h:71
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual void update(double dt)
Updates the camera.
Definition: MockObjects.h:362
int getNumUpdates() const
Returns the number of times the manager has been updated.
Definition: MockObjects.h:78
virtual std::shared_ptr< SurgSim::Graphics::Material > getMaterial() const
Gets the material that defines the visual appearance of the representation.
Definition: MockObjects.h:194
Representation class for testing.
Definition: MockObjects.h:286
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
double getSumDt() const
Returns the sum of the dt that the manager has been updated with.
Definition: MockObjects.h:83
virtual std::shared_ptr< SurgSim::Graphics::Material > getMaterial() const
Gets the material that defines the visual appearance of the representation.
Definition: MockObjects.h:378
MockGroup(const std::string &name)
Constructor.
Definition: MockObjects.h:39
virtual void update(double dt)
Updates the representation.
Definition: MockObjects.h:164
double getSumDt() const
Returns the sum of the dt that the representation has been updated with.
Definition: MockObjects.h:156
bool isMainCamera() override
Definition: MockObjects.h:425
void setPerspectiveProjection(double fovy, double aspect, double near, double far)
Set the projection matrix with the appropriate perspective projection parameters. ...
Definition: MockObjects.h:455
Definition: ManagerTests.cpp:36
std::array< double, 2 > getDimensionsDouble() const
Get the dimensions of this view in doubles.
Definition: MockObjects.h:590
virtual std::shared_ptr< SurgSim::Graphics::Group > getOrCreateGroup(const std::string &name)
Fetch a group with a given name, if the group does not exist, create it.
Definition: MockObjects.h:98
std::array< int, 2 > getPosition() const override
Get the position of this view.
Definition: MockObjects.h:562
virtual SurgSim::Math::Matrix44d getInverseProjectionMatrix() const
Gets the inverse projection matrix of the camera.
Definition: MockObjects.h:354
NonGraphicsRepresentation(const std::string &name)
Constructor.
Definition: MockObjects.h:686
virtual std::shared_ptr< SurgSim::Graphics::RenderTarget > getRenderTarget() const
Gets RenderTarget that is currently being used by the camera.
Definition: MockObjects.h:412
void addUniform(const std::string &type, const std::string &name, const boost::any &value)
Adds and a uniform to this representation and set its value.
Definition: MockObjects.h:225
void setViewportSize(std::array< double, 2 > dimensions)
Sets the width and height of the viewport.
Definition: MockObjects.h:480
Eigen::Matrix< double, 4, 4, Eigen::RowMajor > Matrix44d
A 4x4 matrix of doubles.
Definition: Matrix.h:55
void getViewport(int *x, int *y, int *width, int *height) const
collect the viewport values
Definition: MockObjects.h:475
void addUniform(std::shared_ptr< SurgSim::Graphics::UniformBase > uniform)
Adds a uniform to this representation.
Definition: MockObjects.h:230
virtual bool getDrawAsWireFrame() const
Return if the representation is rendered as a wire frame.
Definition: MockObjects.h:392
virtual SurgSim::Math::RigidTransform3d getPose() const
Gets the pose of the camera.
Definition: MockObjects.h:321
Camera class for testing.
Definition: MockObjects.h:282
Definition: MockObjects.h:34
Manager class for testing.
Definition: MockObjects.h:196
MockCamera(const std::string &name)
Constructor.
Definition: MockObjects.h:290
void setViewport(int x, int y, int width, int height)
Sets the viewport size for this camera.
Definition: MockObjects.h:465
Base graphics camera class, which defines the basic interface for all graphics cameras.
Definition: Camera.h:51
std::vector< std::shared_ptr< SurgSim::Graphics::UniformBase > > getUniforms() const
Definition: MockObjects.h:505
virtual bool getDrawAsWireFrame() const
Return if the representation is rendered as a wire frame.
Definition: MockObjects.h:209
virtual void setDrawAsWireFrame(bool val)
Sets the representation to render as a wire frame.
Definition: MockObjects.h:388
virtual bool setRenderTarget(std::shared_ptr< SurgSim::Graphics::RenderTarget > renderTarget)
Sets RenderTarget for the current camera, enables the camera to render to off-screen textures...
Definition: MockObjects.h:407
bool isInitialized() const
Gets whether the representation has been initialized.
Definition: MockObjects.h:174
void dumpDebugInfo() const
Generic unspecified debug handle, there are no requirements on this interface the manager implementat...
Definition: MockObjects.h:88
int getNumUpdates() const
Returns the number of times the representation has been updated.
Definition: MockObjects.h:302
virtual void setPose(const SurgSim::Math::RigidTransform3d &transform)
Sets the current pose of the camera.
Definition: MockObjects.h:314
void setAmbientColor(const SurgSim::Math::Vector4d &color)
Sets a value for the ambient lighting term, this can add light to the scene when there is no lighting...
Definition: MockObjects.h:435
void setGenerateTangents(bool value)
Enable or disable the generation of tangents.
Definition: MockObjects.h:445
Representation that does not subclass any graphics components.
Definition: MockObjects.h:681
void setUniforms(const std::vector< std::shared_ptr< SurgSim::Graphics::UniformBase >> &uniforms)
Sets a set of uniforms for this representation.
Definition: MockObjects.h:235
void setGenerateTangents(bool value)
Enable or disable the generation of tangents.
Definition: MockObjects.h:215
void setDimensions(const std::array< int, 2 > &dimensions) override
Set the dimensions of this view.
Definition: MockObjects.h:570
virtual bool setMaterial(std::shared_ptr< SurgSim::Framework::Component > material)
Sets the material that defines the visual appearance of the representation.
Definition: MockObjects.h:371
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:40
virtual void clearMaterial()
Removes the material from the representation.
Definition: MockObjects.h:384
std::array< double, 2 > getViewportSize() const
Gets the dimensions of the viewport.
Definition: MockObjects.h:485
virtual void update(double dt)
Updates the view.
Definition: MockObjects.h:623
std::shared_ptr< PhysicsManagerState > doUpdate(const double &dt, const std::shared_ptr< PhysicsManagerState > &state) override
Override this function to implement the computations specific behavior.
Definition: ComputationGroup.cpp:36
bool isInitialized() const
Gets whether the view has been initialized.
Definition: MockObjects.h:630
std::vector< std::shared_ptr< SurgSim::Graphics::UniformBase > > getUniforms() const
Definition: MockObjects.h:240
Base graphics group class, which defines the interface that all graphics groups must implement...
Definition: Group.h:36
int getNumUpdates() const
Returns the number of times the representation has been updated.
Definition: MockObjects.h:151
void setMainCamera(bool val) override
Marks the camera as a main view camera, this means that view dependent passes should follow this came...
Definition: MockObjects.h:421
bool isWindowBorderEnabled() const override
Returns whether the view window has a border.
Definition: MockObjects.h:604
Definitions of small fixed-size vector types.
Basic graphics manager class which manages graphics components to provide a visualization of the scen...
Definition: Manager.h:37
void setPosition(const std::array< int, 2 > &position) override
Set the position of this view.
Definition: MockObjects.h:554
virtual SurgSim::Math::Matrix44d getViewMatrix() const
Gets the view matrix of the camera.
Definition: MockObjects.h:335
double getSumDt() const
Returns the sum of the dt that the representation has been updated with.
Definition: MockObjects.h:307
bool isAwoken() const
Gets whether the view has been awoken.
Definition: MockObjects.h:635
bool isGeneratingTangents() const
Definition: MockObjects.h:220
void setUniforms(const std::vector< std::shared_ptr< SurgSim::Graphics::UniformBase >> &uniforms)
Sets a set of uniforms for this representation.
Definition: MockObjects.h:500
Representations are manifestations of a SceneElement.
Definition: Representation.h:33
View class for testing.
Definition: MockObjects.h:529
void addUniform(std::shared_ptr< SurgSim::Graphics::UniformBase > uniform)
Adds a uniform to this representation.
Definition: MockObjects.h:495
void addUniform(const std::string &type, const std::string &name, const boost::any &value)
Adds and a uniform to this representation and set its value.
Definition: MockObjects.h:490
virtual bool isVisible() const
Gets whether the group is currently visible.
Definition: MockObjects.h:52
virtual void setProjectionMatrix(const SurgSim::Math::Matrix44d &matrix)
Sets the projection matrix of the camera.
Definition: MockObjects.h:342
virtual SurgSim::Math::Matrix44d getInverseViewMatrix() const
Gets the inverse view matrix of the camera.
Definition: MockObjects.h:430
virtual void setViewMatrix(const SurgSim::Math::Matrix44d &matrix)
Sets the view matrix of the camera.
Definition: MockObjects.h:328
void setOrthogonalProjection(double left, double right, double bottom, double top, double near, double far)
Set the projection matrix with the appropriate orthogonal projection parameters.
Definition: MockObjects.h:460
bool isAwoken() const
Gets whether the representation has been awoken.
Definition: MockObjects.h:179
std::array< int, 2 > getDimensions() const override
Set the dimensions of this view.
Definition: MockObjects.h:578
void setDimensionsDouble(const std::array< double, 2 > &dimensions)
Set the dimensions of this view in doubles.
Definition: MockObjects.h:584
MockView(const std::string &name)
Constructor.
Definition: MockObjects.h:539
virtual void setVisible(bool visible)
Sets whether the group is currently visible.
Definition: MockObjects.h:45
int getType() const override
Returns the type of Manager.
Definition: MockObjects.h:93
Group(const std::string &name)
Constructor.
Definition: Group.cpp:25
void setWindowBorderEnabled(bool enabled) override
Sets whether the view window has a border.
Definition: MockObjects.h:598
bool isGeneratingTangents() const
Definition: MockObjects.h:450
MockRepresentation(const std::string &name)
Constructor.
Definition: MockObjects.h:140
double getSumDt() const
Returns the sum of the dt that the view has been updated with.
Definition: MockObjects.h:615
int getNumUpdates() const
Returns the number of times the view has been updated.
Definition: MockObjects.h:610
virtual bool setMaterial(std::shared_ptr< SurgSim::Framework::Component > material)
Sets the material that defines the visual appearance of the representation.
Definition: MockObjects.h:187
virtual const SurgSim::Math::Matrix44d & getProjectionMatrix() const
Gets the projection matrix of the camera.
Definition: MockObjects.h:349
virtual void setDrawAsWireFrame(bool val)
Sets the representation to render as a wire frame.
Definition: MockObjects.h:204
SurgSim::Math::Vector4d getAmbientColor()
Definition: MockObjects.h:440