mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Use scoped enums in rendering classes
We should try to favor scoped enums over unscoped enums for their enhanced type safety.
This commit is contained in:
parent
4aa81d9e1d
commit
e051565d96
@ -99,7 +99,7 @@ vtkm::Matrix<vtkm::Float32, 4, 4> Camera::Camera2DStruct::CreateProjectionMatrix
|
||||
|
||||
vtkm::Matrix<vtkm::Float32, 4, 4> Camera::CreateViewMatrix() const
|
||||
{
|
||||
if (this->Mode == Camera::MODE_3D)
|
||||
if (this->ModeType == Camera::Mode::ThreeD)
|
||||
{
|
||||
return this->Camera3D.CreateViewMatrix();
|
||||
}
|
||||
@ -112,7 +112,7 @@ vtkm::Matrix<vtkm::Float32, 4, 4> Camera::CreateViewMatrix() const
|
||||
vtkm::Matrix<vtkm::Float32, 4, 4> Camera::CreateProjectionMatrix(vtkm::Id screenWidth,
|
||||
vtkm::Id screenHeight) const
|
||||
{
|
||||
if (this->Mode == Camera::MODE_3D)
|
||||
if (this->ModeType == Camera::Mode::ThreeD)
|
||||
{
|
||||
return this->Camera3D.CreateProjectionMatrix(
|
||||
screenWidth, screenHeight, this->NearPlane, this->FarPlane);
|
||||
@ -136,7 +136,7 @@ void Camera::GetRealViewport(vtkm::Id screenWidth,
|
||||
vtkm::Float32& bottom,
|
||||
vtkm::Float32& top) const
|
||||
{
|
||||
if (this->Mode == Camera::MODE_3D)
|
||||
if (this->ModeType == Camera::Mode::ThreeD)
|
||||
{
|
||||
left = this->ViewportLeft;
|
||||
right = this->ViewportRight;
|
||||
@ -277,7 +277,7 @@ void Camera::ResetToBounds(const vtkm::Bounds& dataBounds,
|
||||
const vtkm::Float64 ZDataViewPadding)
|
||||
{
|
||||
// Save camera mode
|
||||
ModeEnum saveMode = this->GetMode();
|
||||
Mode saveMode = this->GetMode();
|
||||
|
||||
// Pad view around data extents
|
||||
vtkm::Bounds db = dataBounds;
|
||||
@ -381,7 +381,7 @@ void Camera::Dolly(vtkm::Float32 value)
|
||||
|
||||
void Camera::Print() const
|
||||
{
|
||||
if (Mode == MODE_3D)
|
||||
if (this->ModeType == Camera::Mode::ThreeD)
|
||||
{
|
||||
std::cout << "Camera: 3D" << std::endl;
|
||||
std::cout << " LookAt: " << Camera3D.LookAt << std::endl;
|
||||
@ -405,7 +405,7 @@ void Camera::Print() const
|
||||
std::cout << vm[2][0] << " " << vm[2][1] << " " << vm[2][2] << " " << vm[2][3] << std::endl;
|
||||
std::cout << vm[3][0] << " " << vm[3][1] << " " << vm[3][2] << " " << vm[3][3] << std::endl;
|
||||
}
|
||||
else if (Mode == MODE_2D)
|
||||
else if (this->ModeType == Camera::Mode::TwoD)
|
||||
{
|
||||
std::cout << "Camera: 2D" << std::endl;
|
||||
std::cout << " LRBT: " << Camera2D.Left << " " << Camera2D.Right << " " << Camera2D.Bottom
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <vtkm/rendering/vtkm_rendering_export.h>
|
||||
|
||||
#include <vtkm/Bounds.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/Matrix.h>
|
||||
#include <vtkm/Range.h>
|
||||
@ -92,14 +93,18 @@ class VTKM_RENDERING_EXPORT Camera
|
||||
};
|
||||
|
||||
public:
|
||||
enum ModeEnum
|
||||
enum struct Mode
|
||||
{
|
||||
MODE_2D,
|
||||
MODE_3D
|
||||
TwoD,
|
||||
ThreeD,
|
||||
};
|
||||
using ModeEnum VTKM_DEPRECATED(1.8, "Use Camaera::Mode") = Mode;
|
||||
VTKM_DEPRECATED(1.8, "Use Camera::Mode::TwoD.") static constexpr Mode MODE_2D = Mode::TwoD;
|
||||
VTKM_DEPRECATED(1.8, "Use Camera::Mode::ThreeD.") static constexpr Mode MODE_3D = Mode::ThreeD;
|
||||
|
||||
VTKM_CONT
|
||||
Camera(ModeEnum vtype = Camera::MODE_3D)
|
||||
: Mode(vtype)
|
||||
Camera(Mode vtype = Camera::Mode::ThreeD)
|
||||
: ModeType(vtype)
|
||||
, NearPlane(0.01f)
|
||||
, FarPlane(1000.0f)
|
||||
, ViewportLeft(-1.0f)
|
||||
@ -128,13 +133,13 @@ public:
|
||||
/// positioned anywhere and pointing at any place in 3D.
|
||||
///
|
||||
VTKM_CONT
|
||||
vtkm::rendering::Camera::ModeEnum GetMode() const { return this->Mode; }
|
||||
vtkm::rendering::Camera::Mode GetMode() const { return this->ModeType; }
|
||||
VTKM_CONT
|
||||
void SetMode(vtkm::rendering::Camera::ModeEnum mode) { this->Mode = mode; }
|
||||
void SetMode(vtkm::rendering::Camera::Mode mode) { this->ModeType = mode; }
|
||||
VTKM_CONT
|
||||
void SetModeTo3D() { this->SetMode(vtkm::rendering::Camera::MODE_3D); }
|
||||
void SetModeTo3D() { this->SetMode(vtkm::rendering::Camera::Mode::ThreeD); }
|
||||
VTKM_CONT
|
||||
void SetModeTo2D() { this->SetMode(vtkm::rendering::Camera::MODE_2D); }
|
||||
void SetModeTo2D() { this->SetMode(vtkm::rendering::Camera::Mode::TwoD); }
|
||||
|
||||
/// \brief The clipping range of the camera.
|
||||
///
|
||||
@ -541,7 +546,7 @@ public:
|
||||
void Print() const;
|
||||
|
||||
private:
|
||||
ModeEnum Mode;
|
||||
Mode ModeType;
|
||||
Camera3DStruct Camera3D;
|
||||
Camera2DStruct Camera2D;
|
||||
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
Dataset = dataSet;
|
||||
Cells = dataSet.GetCellSet();
|
||||
Coords = dataSet.GetCoordinateSystem();
|
||||
Mode = VOLUME_MODE;
|
||||
Mode = RenderMode::Volume;
|
||||
CompositeBackground = true;
|
||||
//
|
||||
// Just grab a default scalar field
|
||||
@ -63,7 +63,7 @@ public:
|
||||
|
||||
void SetSampleDistance(const vtkm::Float32& distance)
|
||||
{
|
||||
if (Mode != VOLUME_MODE)
|
||||
if (this->Mode != RenderMode::Volume)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Conn Proxy: volume mode must be set before sample distance set");
|
||||
@ -103,7 +103,7 @@ public:
|
||||
VTKM_CONT
|
||||
void SetEmissionField(const std::string& fieldName)
|
||||
{
|
||||
if (Mode != ENERGY_MODE)
|
||||
if (this->Mode != RenderMode::Energy)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Conn Proxy: energy mode must be set before setting emission field");
|
||||
@ -132,7 +132,7 @@ public:
|
||||
void Trace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& rays)
|
||||
{
|
||||
|
||||
if (Mode == VOLUME_MODE)
|
||||
if (this->Mode == RenderMode::Volume)
|
||||
{
|
||||
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
|
||||
}
|
||||
@ -151,7 +151,7 @@ public:
|
||||
VTKM_CONT
|
||||
void Trace(vtkm::rendering::raytracing::Ray<vtkm::Float32>& rays)
|
||||
{
|
||||
if (Mode == VOLUME_MODE)
|
||||
if (this->Mode == RenderMode::Volume)
|
||||
{
|
||||
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
|
||||
}
|
||||
@ -171,7 +171,7 @@ public:
|
||||
PartialVector64 PartialTrace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& rays)
|
||||
{
|
||||
|
||||
if (Mode == VOLUME_MODE)
|
||||
if (this->Mode == RenderMode::Volume)
|
||||
{
|
||||
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
|
||||
}
|
||||
@ -190,7 +190,7 @@ public:
|
||||
VTKM_CONT
|
||||
PartialVector32 PartialTrace(vtkm::rendering::raytracing::Ray<vtkm::Float32>& rays)
|
||||
{
|
||||
if (Mode == VOLUME_MODE)
|
||||
if (this->Mode == RenderMode::Volume)
|
||||
{
|
||||
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
|
||||
}
|
||||
@ -222,7 +222,7 @@ public:
|
||||
rays.Buffers.at(0).InitConst(0.f);
|
||||
raytracing::RayOperations::MapCanvasToRays(rays, camera, *canvas);
|
||||
|
||||
if (Mode == VOLUME_MODE)
|
||||
if (this->Mode == RenderMode::Volume)
|
||||
{
|
||||
Tracer.SetVolumeData(this->ScalarField, this->ScalarRange, this->Cells, this->Coords);
|
||||
}
|
||||
@ -330,7 +330,7 @@ void ConnectivityProxy::Trace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& r
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("connectivity_trace_64");
|
||||
if (Internals->GetRenderMode() == VOLUME_MODE)
|
||||
if (this->Internals->GetRenderMode() == RenderMode::Volume)
|
||||
{
|
||||
logger->AddLogData("volume_mode", "true");
|
||||
}
|
||||
@ -349,7 +349,7 @@ PartialVector32 ConnectivityProxy::PartialTrace(
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("connectivity_trace_32");
|
||||
if (Internals->GetRenderMode() == VOLUME_MODE)
|
||||
if (this->Internals->GetRenderMode() == RenderMode::Volume)
|
||||
{
|
||||
logger->AddLogData("volume_mode", "true");
|
||||
}
|
||||
@ -369,7 +369,7 @@ void ConnectivityProxy::Trace(vtkm::rendering::raytracing::Ray<vtkm::Float32>& r
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("connectivity_trace_32");
|
||||
if (Internals->GetRenderMode() == VOLUME_MODE)
|
||||
if (this->Internals->GetRenderMode() == RenderMode::Volume)
|
||||
{
|
||||
logger->AddLogData("volume_mode", "true");
|
||||
}
|
||||
@ -389,7 +389,7 @@ PartialVector64 ConnectivityProxy::PartialTrace(
|
||||
{
|
||||
raytracing::Logger* logger = raytracing::Logger::GetInstance();
|
||||
logger->OpenLogEntry("connectivity_trace_64");
|
||||
if (Internals->GetRenderMode() == VOLUME_MODE)
|
||||
if (this->Internals->GetRenderMode() == RenderMode::Volume)
|
||||
{
|
||||
logger->AddLogData("volume_mode", "true");
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#define vtk_m_rendering_ConnectivityProxy_h
|
||||
|
||||
#include <memory>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/rendering/CanvasRayTracer.h>
|
||||
#include <vtkm/rendering/Mapper.h>
|
||||
@ -37,11 +38,17 @@ public:
|
||||
// Do not allow the default constructor
|
||||
ConnectivityProxy() = delete;
|
||||
~ConnectivityProxy();
|
||||
enum RenderMode
|
||||
enum struct RenderMode
|
||||
{
|
||||
VOLUME_MODE,
|
||||
ENERGY_MODE
|
||||
Volume,
|
||||
Energy,
|
||||
VOLUME_MODE VTKM_DEPRECATED(1.8, "Use Volume.") = Volume,
|
||||
ENERGY_MODE VTKM_DEPRECATED(1.8, "Use Energy.") = Energy
|
||||
};
|
||||
VTKM_DEPRECATED(1.8, "Use ConnectivityProxy::RenderMode::Volume")
|
||||
static constexpr RenderMode VOLUME_MODE = RenderMode::Volume;
|
||||
VTKM_DEPRECATED(1.8, "Use ConnectivityProxy::RenderMode::Energy")
|
||||
static constexpr RenderMode ENERGY_MODE = RenderMode::Energy;
|
||||
|
||||
void SetRenderMode(RenderMode mode);
|
||||
void SetSampleDistance(const vtkm::Float32&);
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <vtkm/rendering/Canvas.h>
|
||||
#include <vtkm/rendering/WorldAnnotator.h>
|
||||
|
||||
#include <vtkm/Deprecated.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace rendering
|
||||
@ -24,18 +26,24 @@ namespace rendering
|
||||
class VTKM_RENDERING_EXPORT TextAnnotation
|
||||
{
|
||||
public:
|
||||
enum HorizontalAlignment
|
||||
enum struct HorizontalAlignment
|
||||
{
|
||||
Left,
|
||||
HCenter,
|
||||
Right
|
||||
};
|
||||
enum VerticalAlignment
|
||||
enum struct VerticalAlignment
|
||||
{
|
||||
Bottom,
|
||||
VCenter,
|
||||
Top
|
||||
};
|
||||
static constexpr HorizontalAlignment Left = HorizontalAlignment::Left;
|
||||
static constexpr HorizontalAlignment HCenter = HorizontalAlignment::HCenter;
|
||||
static constexpr HorizontalAlignment Right = HorizontalAlignment::Right;
|
||||
static constexpr VerticalAlignment Bottom = VerticalAlignment::Bottom;
|
||||
static constexpr VerticalAlignment VCenter = VerticalAlignment::VCenter;
|
||||
static constexpr VerticalAlignment Top = VerticalAlignment::Top;
|
||||
|
||||
protected:
|
||||
std::string Text;
|
||||
|
Loading…
Reference in New Issue
Block a user