Skip to content
Snippets Groups Projects
Commit 8830837c authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

ENH: Clean light class

1. Enforces const correctness
2. Adds move constructors
3. Adds comments
parent a641946c
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@
namespace imstk
{
LightType
Light::getType()
Light::getType() const
{
return m_type;
}
......@@ -82,19 +82,19 @@ Light::setFocalPoint(const double& x,
}
bool
Light::isOn()
Light::isOn() const
{
return m_vtkLight->GetSwitch() != 0;
}
void
Light::switchOn()
Light::switchOn() const
{
m_vtkLight->SwitchOn();
}
bool
Light::isOff()
Light::isOff() const
{
return !this->isOn();
}
......@@ -156,8 +156,14 @@ Light::getName() const
}
void
Light::setName(std::string name)
Light::setName(const std::string& name)
{
m_name = name;
}
void
Light::setName(const std::string&& name)
{
m_name = std::move(name);
}
} // imstk
......@@ -47,18 +47,18 @@ enum class LightType
///
/// \class Light
///
/// \brief Abstract class for lights
/// \brief Abstract base class for lights
///
class Light
{
public:
///
/// \brief
/// \brief Returns the type of light (see imstk::LightType)
///
LightType getType();
LightType getType() const;
///
/// \brief
/// \brief Set the type of the light
///
void setType(const LightType& type);
......@@ -76,22 +76,22 @@ public:
const double& z);
///
/// \brief
/// \brief Get the status (On/off) of the light
///
bool isOn();
bool isOn() const;
///
/// \brief
/// \brief Switch the light On
///
void switchOn();
void switchOn() const;
///
/// \brief
/// \brief Get the status (On/off) of the light
///
bool isOff();
bool isOff() const;
///
/// \brief
/// \brief Switch the light Off
///
void switchOff();
......@@ -128,13 +128,12 @@ public:
///
/// \brief Set the light name
///
void setName(std::string name);
void setName(const std::string& name);
void setName(const std::string&& name);
protected:
Light(std::string name)
{
m_name = name;
};
Light(const std::string& name) : m_name(name){};
Light(std::string&& name) : m_name(std::move(name)){};
vtkSmartPointer<vtkLight> m_vtkLight = vtkSmartPointer<vtkLight>::New();
std::string m_name;
......@@ -152,7 +151,15 @@ protected:
class DirectionalLight : public Light
{
public:
DirectionalLight(std::string name) : Light(name)
///
/// \brief Constructor
///
DirectionalLight(const std::string& name) : Light(name)
{
m_type = LightType::DIRECTIONAL_LIGHT;
m_vtkLight->SetPositional(false);
};
DirectionalLight(std::string&& name) : Light(std::move(name))
{
m_type = LightType::DIRECTIONAL_LIGHT;
m_vtkLight->SetPositional(false);
......@@ -170,7 +177,16 @@ public:
class PointLight : public Light
{
public:
PointLight(std::string name) : Light(name)
///
/// \brief Constructors
///
PointLight(const std::string& name) : Light(name)
{
m_type = LightType::POINT_LIGHT;
m_vtkLight->SetPositional(true);
m_vtkLight->SetConeAngle(179.0);
};
PointLight(std::string&& name) : Light(std::move(name))
{
m_type = LightType::POINT_LIGHT;
m_vtkLight->SetPositional(true);
......@@ -199,7 +215,15 @@ public:
class SpotLight : public PointLight
{
public:
SpotLight(std::string name) : PointLight(name)
///
/// \brief Constructors
///
SpotLight(const std::string& name) : PointLight(name)
{
m_type = LightType::SPOT_LIGHT;
m_vtkLight->SetConeAngle(45);
};
SpotLight(std::string&& name) : PointLight(std::move(name))
{
m_type = LightType::SPOT_LIGHT;
m_vtkLight->SetConeAngle(45);
......
......@@ -98,8 +98,8 @@ SimulationManager::createNewScene(std::string&& newSceneName)
if (this->isSceneRegistered(newSceneName))
{
LOG(WARNING) << "Can not create new scene: '" << newSceneName
<< "' is already registered in this simulation\n"
<< "You can create a new scene using an unique name";
<< "' is already registered in this simulation\n"
<< "You can create a new scene using an unique name";
return nullptr;
}
......
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