Skip to content
Snippets Groups Projects
Commit d773531c authored by Sreekanth Arikatla's avatar Sreekanth Arikatla Committed by Ricardo Ortiz
Browse files

Disables the mouse interaction.

parent 107b65db
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,6 @@ enum VBOResult
#define SIMMEDTK_VIEWERRENDER_DISABLE (1<<11)
#define SIMMEDTK_VIEWERRENDER_DYNAMICREFLECTION (1<<12)
#define SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS (1<<13)
#define SIMMEDTK_VIEWERRENDER_FADE_BACKGROUND (1<<14)
#define SIMMEDTK_DISABLE_MOUSE_INTERACTION (1<<14)
#endif // SMCONFIGRENDERING_H
......@@ -225,3 +225,7 @@ bool RenderDetail::renderWireframe() const
{
return this->renderType & SIMMEDTK_RENDER_WIREFRAME;
}
bool RenderDetail::renderFaces() const
{
return this->renderType & SIMMEDTK_RENDER_FACES;
}
......@@ -163,6 +163,7 @@ public:
bool renderNormals() const;
bool renderWireframe() const;
bool renderFaces() const;
const float &getOpacity() const;
void setOpacity(const float &value);
......
......@@ -101,11 +101,6 @@ int main(int ac, char** av)
sdk->addSceneActor(staticDragon, staticSimulator2);
//-------------------------------------------------------
// Register both object simulators
//-------------------------------------------------------
auto sdkSimulator = sdk->getSimulator();
//-------------------------------------------------------
// Customize the viewer
//-------------------------------------------------------
......@@ -113,8 +108,9 @@ int main(int ac, char** av)
auto viewer = sdk->getViewerInstance();
viewer->setViewerRenderDetail(
SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS
//| SIMMEDTK_VIEWERRENDER_FADE_BACKGROUND
SIMMEDTK_VIEWERRENDER_GLOBALAXIS
| SIMMEDTK_VIEWERRENDER_FADEBACKGROUND
| SIMMEDTK_DISABLE_MOUSE_INTERACTION
);
// Get Scene
......@@ -148,7 +144,8 @@ int main(int ac, char** av)
camController->setScalingFactor(40.0);
viewer->init(); // viewer should be initialized to be able to retrieve the camera
camController->setCamera((std::static_pointer_cast<VTKViewer>(viewer))->getVtkCamera());
camController->setCamera(
(std::static_pointer_cast<VTKViewer>(viewer))->getVtkCamera());
sdk->registerModule(camClient);
sdk->registerModule(camController);
......
......@@ -134,6 +134,13 @@ void MeshRenderDelegate::initDraw()
{
actor->GetProperty()->SetRepresentationToWireframe();
}
if (renderDetail && renderDetail->renderFaces())
{
actor->GetProperty()->SetRepresentationToSurface();
actor->GetProperty()->SetInterpolationToPhong();
}
vtkSmartPointer<vtkTexture> texture;
if(renderDetail && renderDetail->renderTexture())
{
......
......@@ -40,6 +40,27 @@
#include <vtkLight.h>
#include <vtkAxesActor.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkObjectFactory.h>
// Remove the mouse interaction
class VTKViewer::customMouseInteractorStyle : public vtkInteractorStyleTrackballCamera
{
public:
static customMouseInteractorStyle* New();
vtkTypeMacro(customMouseInteractorStyle, vtkInteractorStyleTrackballCamera);
virtual void OnMouseMove(){}
virtual void OnLeftButtonDown(){}
virtual void OnLeftButtonUp(){}
virtual void OnMiddleButtonDown(){}
virtual void OnMiddleButtonUp(){}
virtual void OnRightButtonDown(){}
virtual void OnRightButtonUp(){}
virtual void OnMouseWheelForward(){}
virtual void OnMouseWheelBackward(){}
};
vtkStandardNewMacro(VTKViewer::customMouseInteractorStyle);
///
/// \brief Wrapper to the vtkRendering pipeline
......@@ -190,7 +211,8 @@ public:
// Set up actors
for(const auto &object : ro.scene->getSceneObject())
{
delegate = std::dynamic_pointer_cast<VTKRenderDelegate>(object->getRenderDelegate());
delegate = std::dynamic_pointer_cast<VTKRenderDelegate>(
object->getRenderDelegate());
if (delegate)
{
renderer->AddActor(delegate->getActor());
......@@ -201,7 +223,8 @@ public:
// Add actors from objects directly attached to the viewer.
for(const auto &object : this->viewer->objectList)
{
delegate = std::dynamic_pointer_cast<VTKRenderDelegate>(object->getRenderDelegate());
delegate = std::dynamic_pointer_cast<VTKRenderDelegate>(
object->getRenderDelegate());
if (delegate)
{
renderer->AddActor(delegate->getActor());
......@@ -225,17 +248,20 @@ public:
this->renderWindow->SetWindowName(this->viewer->windowTitle.data());
this->renderWindowInteractor->SetRenderWindow(this->renderWindow.GetPointer());
this->renderWindowInteractor->AddObserver(vtkCommand::TimerEvent,this);
this->renderWindowInteractor->AddObserver(vtkCommand::ExitEvent,this);
this->renderWindowInteractor->AddObserver(vtkCommand::ExitEvent, this);
if (viewer->viewerRenderDetail & SIMMEDTK_DISABLE_MOUSE_INTERACTION)
{
vtkSmartPointer<customMouseInteractorStyle> customStyle =
vtkSmartPointer<customMouseInteractorStyle>::New();
renderWindowInteractor->SetInteractorStyle(customStyle);
}
// Initialize must be called prior to creating timer events.
this->renderWindowInteractor->Initialize();
this->timerId = renderWindowInteractor->CreateRepeatingTimer(1000.0/60.0);
vtkNew<vtkInteractorStyleSwitch> style;
style->SetCurrentStyleToTrackballCamera();
renderWindowInteractor->SetInteractorStyle(style.GetPointer());
if ( viewer->viewerRenderDetail & SIMMEDTK_VIEWERRENDER_GLOBAL_AXIS)
if ( viewer->viewerRenderDetail & SIMMEDTK_VIEWERRENDER_GLOBALAXIS)
{
vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();
......@@ -254,7 +280,7 @@ public:
//}
// Set up background
if (viewer->viewerRenderDetail & SIMMEDTK_VIEWERRENDER_FADE_BACKGROUND)
if (viewer->viewerRenderDetail & SIMMEDTK_VIEWERRENDER_FADEBACKGROUND)
{
auto bgTop = this->viewer->getRenderDetail()->getBackgroundTop().getValue();
auto bgBottom = this->viewer->getRenderDetail()->getBackgroundBottom().getValue();
......
......@@ -38,6 +38,7 @@ public:
VTKViewer(const VTKViewer& other) = delete;
VTKViewer& operator=(const VTKViewer& other) = delete;
class customMouseInteractorStyle;
public:
///
/// \brief Execute when exit viewer
......
......@@ -156,10 +156,18 @@ bool LaparoscopicCameraCoupler::updateTracker()
core::Vec3d transformedUpVector = newRot._transformVector(core::Vec3d(0, 1, 0));
this->camera->SetPosition(newPos[0], newPos[1], newPos[2]);
this->camera->SetViewUp(transformedUpVector[0], transformedUpVector[1], transformedUpVector[2]);
this->camera->SetFocalPoint(transformedFocus[0], transformedFocus[1], transformedFocus[2]);
return true;
this->camera->SetViewUp(
transformedUpVector[0],
transformedUpVector[1],
transformedUpVector[2]);
this->camera->SetFocalPoint(
transformedFocus[0],
transformedFocus[1],
transformedFocus[2]);
return true;
}
void LaparoscopicCameraCoupler::setOffsetOrientation(
......@@ -181,4 +189,4 @@ const core::Quaterniond & LaparoscopicCameraCoupler::getOffsetOrientation() cons
const core::Vec3d & LaparoscopicCameraCoupler::getOffsetPosition() const
{
return this->offsetPosition;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment