2016-02-09 13:59:26 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Copyright 2015 Sandia Corporation.
|
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
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
|
|
|
|
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
|
|
|
|
2016-10-19 18:09:15 +00:00
|
|
|
class VTKM_RENDERING_EXPORT View
|
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,
|
|
|
|
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
|
|
|
|
|
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-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 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
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Scene& GetScene() const { return this->Scene; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::rendering::Scene& GetScene() { return this->Scene; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetScene(const vtkm::rendering::Scene& scene) { this->Scene = scene; }
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Mapper& GetMapper() const { return *this->MapperPointer; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::rendering::Mapper& GetMapper() { return *this->MapperPointer; }
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Canvas& GetCanvas() const { return *this->CanvasPointer; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::rendering::Canvas& GetCanvas() { return *this->CanvasPointer; }
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::WorldAnnotator& GetWorldAnnotator() const
|
2016-06-06 14:29:17 +00:00
|
|
|
{
|
|
|
|
return *this->WorldAnnotatorPointer;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Camera& GetCamera() const { return this->Camera; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::rendering::Camera& GetCamera() { return this->Camera; }
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetCamera(const vtkm::rendering::Camera& camera) { this->Camera = camera; }
|
2016-06-06 14:29:17 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Color& GetBackgroundColor() const
|
2016-06-06 14:29:17 +00:00
|
|
|
{
|
2016-06-11 18:09:51 +00:00
|
|
|
return this->CanvasPointer->GetBackgroundColor();
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetBackgroundColor(const vtkm::rendering::Color& color)
|
2016-06-11 18:09:51 +00:00
|
|
|
{
|
|
|
|
this->CanvasPointer->SetBackgroundColor(color);
|
2016-05-24 20:34:47 +00:00
|
|
|
}
|
|
|
|
|
2016-09-01 18:33:28 +00:00
|
|
|
virtual void Initialize();
|
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
|
|
|
|
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
|
2017-08-02 16:32:19 +00:00
|
|
|
void SetAxisColor(vtkm::rendering::Color c) { this->AxisColor = c; }
|
2017-07-28 17:31:19 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2017-08-02 16:32:19 +00:00
|
|
|
void ClearAnnotations() { Annotations.clear(); }
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
void AddAnnotation(vtkm::rendering::TextAnnotation* ann) { Annotations.push_back(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
|
|
|
void RenderAnnotations();
|
|
|
|
|
2017-08-02 16:32:19 +00:00
|
|
|
vtkm::rendering::Color AxisColor = vtkm::rendering::Color::white;
|
|
|
|
|
2016-06-06 14:29:17 +00:00
|
|
|
private:
|
|
|
|
vtkm::rendering::Scene Scene;
|
2016-09-12 17:08:06 +00:00
|
|
|
std::shared_ptr<vtkm::rendering::Mapper> MapperPointer;
|
|
|
|
std::shared_ptr<vtkm::rendering::Canvas> CanvasPointer;
|
|
|
|
std::shared_ptr<vtkm::rendering::WorldAnnotator> WorldAnnotatorPointer;
|
2017-08-02 16:32:19 +00:00
|
|
|
std::vector<vtkm::rendering::TextAnnotation*> Annotations;
|
2016-06-06 14:29:17 +00:00
|
|
|
vtkm::rendering::Camera Camera;
|
2016-04-18 20:42:59 +00:00
|
|
|
};
|
2016-09-01 18:33:28 +00:00
|
|
|
}
|
|
|
|
} //namespace vtkm::rendering
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2016-06-02 21:43:30 +00:00
|
|
|
#endif //vtk_m_rendering_View_h
|