Commit 104b152a authored by Sreekanth Arikatla's avatar Sreekanth Arikatla

ENH: Adds background color option to VTKViewer class

Adds background color option to VTKViewer class which
internally calls vtkRenderer
parent 03307cf2
......@@ -100,7 +100,7 @@ VTKRenderer::VTKRenderer(std::shared_ptr<Scene> scene)
///TODO : based on scene properties
// Customize background colors
m_vtkRenderer->SetBackground(0.66,0.66,0.66);
m_vtkRenderer->SetBackground2(157.0/255.0*0.66, 186/255.0*0.66, 192.0/255.0*0.66);
m_vtkRenderer->SetBackground2(0.406, 0.481, 0.497);
m_vtkRenderer->GradientBackgroundOn();
///TODO : only on deformable objects with UseBounds (need vtk update)
......@@ -221,7 +221,7 @@ VTKRenderer::addActors(const std::vector<vtkSmartPointer<vtkProp>>& actorList)
}
void
VTKRenderer::updateBackground(Vec3d backgroundOne, Vec3d backgroundTwo /*= Vec3d::Zero()*/, bool gradientBackground /*= false*/)
VTKRenderer::updateBackground(const Vec3d backgroundOne, const Vec3d backgroundTwo /*= Vec3d::Zero()*/, const bool gradientBackground /*= false*/)
{
m_vtkRenderer->SetBackground(backgroundOne.x(), backgroundOne.y(), backgroundOne.z());
if (gradientBackground)
......
......@@ -92,8 +92,9 @@ public:
vtkSmartPointer<vtkRenderer> getVtkRenderer() const;
///
/// \brief
void updateBackground(Vec3d color1, Vec3d color2 = Vec3d::Zero(), bool gradientBackground = false);
/// \brief Update background colors
///
void updateBackground(const Vec3d color1, const Vec3d color2 = Vec3d::Zero(), const bool gradientBackground = false);
protected:
///
......
......@@ -253,4 +253,10 @@ VTKViewer::getScreenCaptureUtility() const
{
return m_screenCapturer;
}
void
VTKViewer::setBackgroundColors(const Vec3d color1, const Vec3d color2 /*= Vec3d::Zero()*/, const bool gradientBackground /*= false*/)
{
this->getCurrentRenderer()->updateBackground(color1, color2, gradientBackground);
}
} // imstk
......@@ -135,15 +135,24 @@ public:
void setOnRightButtonUpFunction(VTKEventHandlerFunction func);
void setOnMouseWheelForwardFunction(VTKEventHandlerFunction func);
void setOnMouseWheelBackwardFunction(VTKEventHandlerFunction func);
// Set custom behaviour to be run on every frame.
// The return of the function will not have any effect.
///
/// \brief Set custom behavior to be run on every frame.
/// The return of the function will not have any effect.
///
void setOnTimerFunction(VTKEventHandlerFunction func);
///
/// \brief access screen shot utility
/// \brief Access screen shot utility
///
std::shared_ptr<VTKScreenCaptureUtility> getScreenCaptureUtility() const;
///
/// \brief Set the coloring of the screen background
/// If 'gradientBackground' is false or not supplied color1 will fill the entire background
///
void setBackgroundColors(const Vec3d color1, const Vec3d color2 = Vec3d::Zero(), const bool gradientBackground = false);
protected:
vtkSmartPointer<vtkRenderWindow> m_vtkRenderWindow = vtkSmartPointer<vtkRenderWindow>::New();
......
......@@ -1386,6 +1386,7 @@ void testPbdVolume()
scene->addLight(light);
sdk->setCurrentScene(scene);
sdk->getViewer()->setBackgroundColors(Vec3d(0.3285, 0.3285, 0.6525), Vec3d(0.13836, 0.13836, 0.2748), true);
sdk->startSimulation(true);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment