2016-02-09 13:59:26 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-02-09 13:59:26 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
2016-06-02 21:43:30 +00:00
|
|
|
#ifndef vtk_m_rendering_View_h
|
|
|
|
#define vtk_m_rendering_View_h
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2016-09-01 18:33:28 +00:00
|
|
|
#include <vtkm/rendering/vtkm_rendering_export.h>
|
|
|
|
|
2016-06-02 19:04:01 +00:00
|
|
|
#include <vtkm/rendering/Camera.h>
|
2016-09-01 18:33:28 +00:00
|
|
|
#include <vtkm/rendering/Canvas.h>
|
2016-05-24 20:34:47 +00:00
|
|
|
#include <vtkm/rendering/Color.h>
|
2016-09-01 18:33:28 +00:00
|
|
|
#include <vtkm/rendering/Mapper.h>
|
2016-05-24 20:34:47 +00:00
|
|
|
#include <vtkm/rendering/Scene.h>
|
2017-07-28 17:31:19 +00:00
|
|
|
#include <vtkm/rendering/TextAnnotation.h>
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2022-02-14 16:15:00 +00:00
|
|
|
#include <functional>
|
2016-09-12 17:08:06 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace rendering
|
|
|
|
{
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief The abstract class representing the view of a rendering scene.
|
2016-10-19 18:09:15 +00:00
|
|
|
class VTKM_RENDERING_EXPORT View
|
2016-04-18 20:42:59 +00:00
|
|
|
{
|
2019-02-11 15:20:37 +00:00
|
|
|
struct InternalData;
|
|
|
|
|
2016-04-18 20:42:59 +00:00
|
|
|
public:
|
2017-05-26 17:53:28 +00:00
|
|
|
View(const vtkm::rendering::Scene& scene,
|
|
|
|
const vtkm::rendering::Mapper& mapper,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Canvas& canvas,
|
2017-12-05 04:46:38 +00:00
|
|
|
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
|
|
|
|
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
View(const vtkm::rendering::Scene& scene,
|
|
|
|
const vtkm::rendering::Mapper& mapper,
|
|
|
|
const vtkm::rendering::Canvas& canvas,
|
|
|
|
const vtkm::rendering::Camera& camera,
|
2017-12-05 04:46:38 +00:00
|
|
|
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
|
|
|
|
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
|
2016-06-08 20:53:32 +00:00
|
|
|
|
2016-09-01 18:33:28 +00:00
|
|
|
virtual ~View();
|
2016-06-08 20:53:32 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Specify the scene object holding the objects to render.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::Scene& GetScene() const;
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetScene
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
vtkm::rendering::Scene& GetScene();
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetScene
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
void SetScene(const vtkm::rendering::Scene& scene);
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Specify the mapper object determining how objects are rendered.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::Mapper& GetMapper() const;
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetMapper
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
vtkm::rendering::Mapper& GetMapper();
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Specify the canvas object that holds the buffer to render into.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::Canvas& GetCanvas() const;
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetCanvas
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
vtkm::rendering::Canvas& GetCanvas();
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::WorldAnnotator& GetWorldAnnotator() const;
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Specify the perspective from which to render a scene.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::Camera& GetCamera() const;
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetCamera
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
vtkm::rendering::Camera& GetCamera();
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetCamera
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
void SetCamera(const vtkm::rendering::Camera& camera);
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Specify the color used where nothing is rendered.
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
const vtkm::rendering::Color& GetBackgroundColor() const;
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc GetBackgroundColor
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
void SetBackgroundColor(const vtkm::rendering::Color& color);
|
2016-05-24 20:34:47 +00:00
|
|
|
|
2024-02-08 13:38:40 +00:00
|
|
|
/// @brief Specify the color of foreground elements.
|
2023-07-27 20:07:19 +00:00
|
|
|
///
|
|
|
|
/// The foreground is typically used for annotation elements.
|
|
|
|
/// The foreground should contrast well with the background.
|
2017-12-05 04:46:38 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
void SetForegroundColor(const vtkm::rendering::Color& color);
|
2017-12-05 04:46:38 +00:00
|
|
|
|
2020-07-09 18:38:39 +00:00
|
|
|
VTKM_CONT
|
|
|
|
bool GetWorldAnnotationsEnabled() const { return this->WorldAnnotationsEnabled; }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void SetWorldAnnotationsEnabled(bool val) { this->WorldAnnotationsEnabled = val; }
|
|
|
|
|
2021-03-03 18:52:15 +00:00
|
|
|
VTKM_CONT void SetRenderAnnotationsEnabled(bool val) { this->RenderAnnotationsEnabled = val; }
|
2023-05-30 16:02:33 +00:00
|
|
|
VTKM_CONT bool GetRenderAnnotationsEnabled() const { return this->RenderAnnotationsEnabled; }
|
2021-03-03 18:52:15 +00:00
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @brief Render a scene and store the result in the canvas' buffers.
|
2016-05-24 20:34:47 +00:00
|
|
|
virtual void Paint() = 0;
|
2016-09-01 18:33:28 +00:00
|
|
|
virtual void RenderScreenAnnotations() = 0;
|
|
|
|
virtual void RenderWorldAnnotations() = 0;
|
2016-05-24 20:34:47 +00:00
|
|
|
|
2021-10-02 21:08:03 +00:00
|
|
|
void RenderAnnotations();
|
|
|
|
|
2023-07-27 20:07:19 +00:00
|
|
|
/// @copydoc vtkm::rendering::Canvas::SaveAs
|
2017-05-18 14:29:41 +00:00
|
|
|
void SaveAs(const std::string& fileName) const;
|
2016-04-18 20:42:59 +00:00
|
|
|
|
2017-07-28 17:31:19 +00:00
|
|
|
VTKM_CONT
|
2019-02-11 15:20:37 +00:00
|
|
|
void SetAxisColor(vtkm::rendering::Color c);
|
2017-07-28 17:31:19 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2021-03-03 18:52:15 +00:00
|
|
|
void ClearTextAnnotations();
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void ClearAdditionalAnnotations();
|
2017-08-02 16:32:19 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2021-03-03 18:52:15 +00:00
|
|
|
void AddAdditionalAnnotation(std::function<void(void)> ann);
|
2017-07-28 17:31:19 +00:00
|
|
|
|
2016-05-19 14:13:04 +00:00
|
|
|
protected:
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetupForWorldSpace(bool viewportClip = true);
|
2016-05-24 20:34:47 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetupForScreenSpace(bool viewportClip = false);
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2017-07-28 17:31:19 +00:00
|
|
|
|
2017-08-02 16:32:19 +00:00
|
|
|
vtkm::rendering::Color AxisColor = vtkm::rendering::Color::white;
|
2020-07-09 18:38:39 +00:00
|
|
|
bool WorldAnnotationsEnabled = true;
|
2021-03-03 18:52:15 +00:00
|
|
|
bool RenderAnnotationsEnabled = true;
|
2017-08-02 16:32:19 +00:00
|
|
|
|
2016-06-06 14:29:17 +00:00
|
|
|
private:
|
2023-05-30 16:02:33 +00:00
|
|
|
std::unique_ptr<InternalData> Internal;
|
2016-04-18 20:42:59 +00:00
|
|
|
};
|
2021-03-03 18:52:15 +00:00
|
|
|
|
|
|
|
} // namespace vtkm::rendering
|
|
|
|
} // namespace vtkm
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2016-06-02 21:43:30 +00:00
|
|
|
#endif //vtk_m_rendering_View_h
|