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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_rendering_Window_h
|
|
|
|
#define vtk_m_rendering_Window_h
|
|
|
|
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
|
|
|
#include <vtkm/rendering/SceneRenderer.h>
|
|
|
|
#include <vtkm/rendering/Color.h>
|
|
|
|
#include <vtkm/rendering/View.h>
|
|
|
|
#include <vtkm/rendering/Scene.h>
|
2016-04-15 19:24:23 +00:00
|
|
|
#include <vtkm/rendering/BoundingBoxAnnotation.h>
|
2016-02-09 13:59:26 +00:00
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace rendering {
|
|
|
|
|
2016-04-19 13:16:10 +00:00
|
|
|
#if 0
|
2016-04-18 20:42:59 +00:00
|
|
|
template<typename SceneType, typename SceneRendererType, typename SurfaceType>
|
|
|
|
class Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SceneType scene;
|
|
|
|
SceneRendererType sceneRenderer;
|
|
|
|
SurfaceType surface;
|
|
|
|
vtkm::rendering::Color bgColor;
|
|
|
|
vtkm::rendering::View view;
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
Window(const SceneType &s,
|
|
|
|
const SceneRendererType &sr,
|
|
|
|
const SurfaceType &surf,
|
|
|
|
const vtkm::rendering::View &v,
|
|
|
|
const vtkm::rendering::Color &bg=vtkm::rendering::Color(0,0,0,1)) :
|
|
|
|
scene(s), sceneRenderer(sr), bgColor(bg), surface(surf), view(v)
|
|
|
|
{
|
|
|
|
sceneRenderer.SetBackgroundColor(bgColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Initialize()
|
|
|
|
{
|
|
|
|
surface.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Paint()
|
|
|
|
{
|
|
|
|
surface.Activate();
|
|
|
|
surface.Clear();
|
|
|
|
SetupForWorldSpace();
|
|
|
|
|
|
|
|
scene.Render(sceneRenderer, surface, view);
|
|
|
|
|
|
|
|
surface.Finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SaveAs(const std::string &fileName)
|
|
|
|
{
|
|
|
|
surface.SaveAs(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SetupForWorldSpace(bool viewportClip=true)
|
|
|
|
{
|
|
|
|
//view.SetupMatrices();
|
|
|
|
surface.SetViewToWorldSpace(view, viewportClip);
|
|
|
|
}
|
|
|
|
};
|
2016-04-19 13:16:10 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-09 13:59:26 +00:00
|
|
|
// Window2D Window3D
|
2016-04-15 19:24:23 +00:00
|
|
|
template<typename SceneRendererType,
|
|
|
|
typename SurfaceType,
|
|
|
|
typename WorldAnnotatorType>
|
2016-02-09 13:59:26 +00:00
|
|
|
class Window3D
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Color bgColor;
|
|
|
|
vtkm::rendering::Scene3D scene;
|
2016-04-15 19:24:23 +00:00
|
|
|
WorldAnnotatorType worldAnnotator;
|
2016-02-09 13:59:26 +00:00
|
|
|
SceneRendererType sceneRenderer;
|
|
|
|
SurfaceType surface;
|
2016-04-19 13:16:10 +00:00
|
|
|
vtkm::rendering::View view;
|
2016-04-15 19:24:23 +00:00
|
|
|
|
|
|
|
// 3D-specific annotations
|
|
|
|
BoundingBoxAnnotation bbox;
|
|
|
|
|
2016-02-09 13:59:26 +00:00
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
Window3D(const vtkm::rendering::Scene3D &s,
|
|
|
|
const SceneRendererType &sr,
|
|
|
|
const SurfaceType &surf,
|
2016-04-19 13:16:10 +00:00
|
|
|
const vtkm::rendering::View &v,
|
2016-02-09 13:59:26 +00:00
|
|
|
const vtkm::rendering::Color &bg=vtkm::rendering::Color(0,0,0,1)) :
|
2016-04-19 13:16:10 +00:00
|
|
|
scene(s), sceneRenderer(sr), bgColor(bg), surface(surf), view(v)
|
2016-02-09 13:59:26 +00:00
|
|
|
{
|
|
|
|
sceneRenderer.SetBackgroundColor(bgColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Initialize()
|
|
|
|
{
|
|
|
|
surface.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Paint()
|
|
|
|
{
|
|
|
|
surface.Activate();
|
|
|
|
surface.Clear();
|
|
|
|
SetupForWorldSpace();
|
|
|
|
|
2016-04-19 13:16:10 +00:00
|
|
|
scene.Render(sceneRenderer, surface, view);
|
2016-04-15 19:24:23 +00:00
|
|
|
RenderWorldAnnotations();
|
|
|
|
|
2016-02-09 13:59:26 +00:00
|
|
|
surface.Finish();
|
|
|
|
}
|
|
|
|
|
2016-04-15 19:24:23 +00:00
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void RenderWorldAnnotations()
|
|
|
|
{
|
|
|
|
bbox.SetColor(Color(.5,.5,.5));
|
|
|
|
bbox.SetExtents(scene.GetSpatialBounds());
|
2016-04-19 13:16:10 +00:00
|
|
|
bbox.Render(view, worldAnnotator);
|
2016-04-15 19:24:23 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 13:59:26 +00:00
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SaveAs(const std::string &fileName)
|
|
|
|
{
|
|
|
|
surface.SaveAs(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SetupForWorldSpace(bool viewportClip=true)
|
|
|
|
{
|
|
|
|
//view.SetupMatrices();
|
2016-04-18 20:42:59 +00:00
|
|
|
surface.SetViewToWorldSpace(view,viewportClip);
|
2016-02-09 13:59:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-04-19 13:16:10 +00:00
|
|
|
template<typename SceneRendererType,
|
|
|
|
typename SurfaceType>
|
2016-02-09 13:59:26 +00:00
|
|
|
class Window2D
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Color bgColor;
|
|
|
|
vtkm::rendering::Scene2D scene;
|
|
|
|
SceneRendererType sceneRenderer;
|
2016-04-19 13:16:10 +00:00
|
|
|
SurfaceType surface;
|
|
|
|
vtkm::rendering::View view;
|
2016-02-09 13:59:26 +00:00
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
Window2D(const vtkm::rendering::Scene2D &s,
|
|
|
|
const SceneRendererType &sr,
|
2016-04-19 13:16:10 +00:00
|
|
|
const SurfaceType &surf,
|
|
|
|
const vtkm::rendering::View &v,
|
2016-02-09 13:59:26 +00:00
|
|
|
const vtkm::rendering::Color &bg=vtkm::rendering::Color(0,0,0,1)) :
|
2016-04-19 13:16:10 +00:00
|
|
|
scene(s), sceneRenderer(sr), surface(surf), view(v), bgColor(bg)
|
|
|
|
{
|
|
|
|
sceneRenderer.SetBackgroundColor(bgColor);
|
|
|
|
}
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Initialize()
|
|
|
|
{
|
|
|
|
surface.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void Paint()
|
|
|
|
{
|
|
|
|
surface.Activate();
|
|
|
|
surface.Clear();
|
|
|
|
SetupForWorldSpace();
|
|
|
|
|
|
|
|
scene.Render(sceneRenderer, surface, view);
|
|
|
|
|
|
|
|
surface.Finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SaveAs(const std::string &fileName)
|
2016-02-09 13:59:26 +00:00
|
|
|
{
|
2016-04-19 13:16:10 +00:00
|
|
|
surface.SaveAs(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SetupForWorldSpace(bool viewportClip=true)
|
|
|
|
{
|
|
|
|
//view.SetupMatrices();
|
|
|
|
surface.SetViewToWorldSpace(view,viewportClip);
|
2016-02-09 13:59:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}} //namespace vtkm::rendering
|
|
|
|
|
|
|
|
#endif //vtk_m_rendering_Window_h
|