OsgView.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_OSGVIEW_H
#define SURGSIM_GRAPHICS_OSGVIEW_H
#include <osgViewer/Viewer>
#include "SurgSim/Graphics/View.h"
namespace osgViewer
{
class StatsHandler;
class DisplaySettings;
}
namespace SurgSim
{
namespace Input
{
class CommonDevice;
}
namespace Devices
{
class KeyboardDevice;
class MouseDevice;
}
namespace Graphics
{
class OsgCamera;
class OsgTrackballZoomManipulator;
SURGSIM_STATIC_REGISTRATION(OsgView);
class OsgView : public View
{
public:
explicit OsgView(const std::string& name);
~OsgView();
SURGSIM_CLASSNAME(SurgSim::Graphics::OsgView);
void setPosition(const std::array<int, 2>& position) override;
std::array<int, 2> getPosition() const override;
void setDimensions(const std::array<int, 2>& dimensions) override;
std::array<int, 2> getDimensions() const override;
void setDimensionsDouble(const std::array<double, 2>& dimensions) override;
std::array<double, 2> getDimensionsDouble() const override;
void setWindowBorderEnabled(bool enabled) override;
bool isWindowBorderEnabled() const override;
void setCamera(std::shared_ptr<SurgSim::Framework::Component> camera) override;
void enableManipulator(bool val);
bool isManipulatorEnabled();
void setManipulatorParameters(const SurgSim::Math::Vector3d& position, const SurgSim::Math::Vector3d& lookat);
void setManipulatorPosition(const SurgSim::Math::Vector3d& position);
SurgSim::Math::Vector3d getManipulatorPosition();
void setManipulatorLookAt(const SurgSim::Math::Vector3d& lookAt);
SurgSim::Math::Vector3d getManipulatorLookAt();
void setOsgMapsUniforms(bool val);
bool getOsgMapsUniforms();
std::shared_ptr<SurgSim::Input::CommonDevice> getKeyboardDevice();
void enableKeyboardDevice(bool val);
bool isKeyboardDeviceEnabled();
std::shared_ptr<SurgSim::Input::CommonDevice> getMouseDevice();
void enableMouseDevice(bool val);
bool isMouseDeviceEnabled();
void update(double dt) override;
osg::ref_ptr<osgViewer::View> getOsgView() const;
protected:
bool doInitialize() override;
bool doWakeUp() override;
int doSetTargetScreen(int val) override;
virtual osg::ref_ptr<osg::DisplaySettings> createDisplaySettings() const;
private:
void fixupStatsHandler(osgViewer::StatsHandler* statsHandler);
std::array<int, 2> m_position;
std::array<int, 2> m_dimensions;
std::array<int, 2> m_screenDimensions;
bool m_isWindowBorderEnabled;
bool m_isFirstUpdate;
bool m_areWindowSettingsDirty;
osg::ref_ptr<osgViewer::View> m_view;
bool m_osgMapUniforms;
osg::ref_ptr<OsgTrackballZoomManipulator> m_manipulator;
SurgSim::Math::Vector3d m_manipulatorPosition;
SurgSim::Math::Vector3d m_manipulatorLookat;
bool m_keyboardEnabled;
std::shared_ptr<SurgSim::Devices::KeyboardDevice> m_keyboardDevice;
bool m_mouseEnabled;
std::shared_ptr<SurgSim::Devices::MouseDevice> m_mouseDevice;
};
}; // namespace Graphics
}; // namespace SurgSim
#endif // SURGSIM_GRAPHICS_OSGVIEW_H
SurgSim::Graphics::View
Base graphics view class, which defines the basic interface for all graphics views.
Definition: View.h:39
SurgSim::Graphics::OsgView::m_manipulator
osg::ref_ptr< OsgTrackballZoomManipulator > m_manipulator
Definition: OsgView.h:197
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::OsgView::m_osgMapUniforms
bool m_osgMapUniforms
Wether to enable osg uniform mapping.
Definition: OsgView.h:195
SurgSim::Graphics::OsgView::m_view
osg::ref_ptr< osgViewer::View > m_view
OSG view which performs the actual work involved in setting up and rendering to a window...
Definition: OsgView.h:192
SurgSim::Graphics::OsgView::m_manipulatorPosition
SurgSim::Math::Vector3d m_manipulatorPosition
Definition: OsgView.h:198
osgViewer
Definition: OsgView.h:23
SurgSim::Graphics::OsgView::m_mouseEnabled
bool m_mouseEnabled
Indicate if a mouse device is enabled.
Definition: OsgView.h:206
SurgSim::Graphics::OsgView::m_isWindowBorderEnabled
bool m_isWindowBorderEnabled
Whether the view window has a border.
Definition: OsgView.h:183
SurgSim::Graphics::OsgView::m_mouseDevice
std::shared_ptr< SurgSim::Devices::MouseDevice > m_mouseDevice
Definition: OsgView.h:207
SurgSim::Graphics::OsgView::m_position
std::array< int, 2 > m_position
Position of the view on the screen (in pixels)
Definition: OsgView.h:178
SurgSim::Graphics::OsgView::m_screenDimensions
std::array< int, 2 > m_screenDimensions
Definition: OsgView.h:181
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
View.h
SurgSim::Graphics::OsgView::m_dimensions
std::array< int, 2 > m_dimensions
Dimensions of the view on the screen (in pixels)
Definition: OsgView.h:180
SurgSim::Graphics::OsgView::m_keyboardDevice
std::shared_ptr< SurgSim::Devices::KeyboardDevice > m_keyboardDevice
Definition: OsgView.h:203
SurgSim::Graphics::OsgView::m_manipulatorLookat
SurgSim::Math::Vector3d m_manipulatorLookat
Definition: OsgView.h:199
SurgSim::Graphics::OsgView::m_isFirstUpdate
bool m_isFirstUpdate
Whether the next update will be the first time the view has been updated On the first update...
Definition: OsgView.h:187
SurgSim::Graphics::OsgView::m_areWindowSettingsDirty
bool m_areWindowSettingsDirty
Whether the settings have been changed and the window needs to be updated.
Definition: OsgView.h:189
SurgSim::Graphics::OsgView::m_keyboardEnabled
bool m_keyboardEnabled
Indicate if a keyboard device is enabled.
Definition: OsgView.h:202
SurgSim::Math::Vector3d
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
SurgSim::Graphics::OsgView
OSG-based implementation of graphics view class.
Definition: OsgView.h:56