Commit 46c2af29 authored by Nickolas Davis's avatar Nickolas Davis 🥑 Committed by Kitware Robot
Browse files

Merge topic 'remove-render-annotations'

a683a880

 add support for removing annotations and remove from regression tests
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Matt Larsen's avatarMatt Larsen <larsen30@llnl.gov>
Merge-request: !2433
parents 2fd7c928 a683a880
data/baseline/filter/contour-tangle.png

130 Bytes | W: | H:

data/baseline/filter/contour-tangle.png

129 Bytes | W: | H:

data/baseline/filter/contour-tangle.png
data/baseline/filter/contour-tangle.png
data/baseline/filter/contour-tangle.png
data/baseline/filter/contour-tangle.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/contour-uniform.png

129 Bytes | W: | H:

data/baseline/filter/contour-uniform.png

129 Bytes | W: | H:

data/baseline/filter/contour-uniform.png
data/baseline/filter/contour-uniform.png
data/baseline/filter/contour-uniform.png
data/baseline/filter/contour-uniform.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/contour-wedge.png

130 Bytes | W: | H:

data/baseline/filter/contour-wedge.png

129 Bytes | W: | H:

data/baseline/filter/contour-wedge.png
data/baseline/filter/contour-wedge.png
data/baseline/filter/contour-wedge.png
data/baseline/filter/contour-wedge.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/point-transform.png

130 Bytes | W: | H:

data/baseline/filter/point-transform.png

130 Bytes | W: | H:

data/baseline/filter/point-transform.png
data/baseline/filter/point-transform.png
data/baseline/filter/point-transform.png
data/baseline/filter/point-transform.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/split-sharp-edges.png

130 Bytes | W: | H:

data/baseline/filter/split-sharp-edges.png

130 Bytes | W: | H:

data/baseline/filter/split-sharp-edges.png
data/baseline/filter/split-sharp-edges.png
data/baseline/filter/split-sharp-edges.png
data/baseline/filter/split-sharp-edges.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/streamline.png

130 Bytes | W: | H:

data/baseline/filter/streamline.png

130 Bytes | W: | H:

data/baseline/filter/streamline.png
data/baseline/filter/streamline.png
data/baseline/filter/streamline.png
data/baseline/filter/streamline.png
  • 2-up
  • Swipe
  • Onion skin
data/baseline/filter/surface-normals.png

130 Bytes | W: | H:

data/baseline/filter/surface-normals.png

130 Bytes | W: | H:

data/baseline/filter/surface-normals.png
data/baseline/filter/surface-normals.png
data/baseline/filter/surface-normals.png
data/baseline/filter/surface-normals.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -55,6 +55,7 @@ void TestContourFilterWedge()
"gyroid",
colorTable,
"filter/contour-wedge.png",
false,
static_cast<vtkm::FloatDefault>(0.08));
}
......@@ -85,7 +86,7 @@ void TestContourFilterUniform()
//Y axis Flying Edge algorithm has subtle differences at a couple of boundaries
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "pointvar", colorTable, "filter/contour-uniform.png");
result, "pointvar", colorTable, "filter/contour-uniform.png", false);
}
void TestContourFilterTangle()
......@@ -113,7 +114,7 @@ void TestContourFilterTangle()
//Y axis Flying Edge algorithm has subtle differences at a couple of boundaries
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "nodevar", colorTable, "filter/contour-tangle.png");
result, "nodevar", colorTable, "filter/contour-tangle.png", false);
}
void TestContourFilter()
......
......@@ -53,7 +53,7 @@ void TestPointTransform()
result.PrintSummary(std::cout);
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "pointvar", colorTable, "filter/point-transform.png");
result, "pointvar", colorTable, "filter/point-transform.png", false);
}
} // namespace
......
......@@ -46,7 +46,7 @@ void TestSplitSharpEdges()
result.PrintSummary(std::cout);
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "pointvar", colorTable, "filter/split-sharp-edges.png");
result, "pointvar", colorTable, "filter/split-sharp-edges.png", false);
}
} // namespace
......
......@@ -69,7 +69,7 @@ void TestStreamline()
result.PrintSummary(std::cout);
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "pointvar", colorTable, "filter/streamline.png");
result, "pointvar", colorTable, "filter/streamline.png", false);
}
} // namespace
......
......@@ -48,7 +48,7 @@ void TestSurfaceNormals()
result.PrintSummary(std::cout);
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
result, "pointvar", colorTable, "filter/surface-normals.png");
result, "pointvar", colorTable, "filter/surface-normals.png", false);
}
} // namespace
......
......@@ -27,7 +27,8 @@ struct View::InternalData
vtkm::rendering::Mapper* MapperPointer{ nullptr };
vtkm::rendering::Canvas* CanvasPointer{ nullptr };
vtkm::rendering::WorldAnnotator* WorldAnnotatorPointer{ nullptr };
std::vector<std::unique_ptr<vtkm::rendering::TextAnnotation>> Annotations;
std::vector<std::unique_ptr<vtkm::rendering::TextAnnotation>> TextAnnotations;
std::vector<std::function<void(void)>> AdditionalAnnotations;
vtkm::rendering::Camera Camera;
};
......@@ -148,10 +149,7 @@ void View::SetForegroundColor(const vtkm::rendering::Color& color)
this->Internal->CanvasPointer->SetForegroundColor(color);
}
void View::Initialize()
{
// does nothing
}
void View::Initialize() {}
void View::SaveAs(const std::string& fileName) const
{
......@@ -165,31 +163,66 @@ void View::SetAxisColor(vtkm::rendering::Color c)
void View::ClearAnnotations()
{
this->Internal->Annotations.clear();
this->Internal->TextAnnotations.clear();
}
void View::AddAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann)
{
this->Internal->Annotations.push_back(std::move(ann));
this->Internal->TextAnnotations.push_back(std::move(ann));
}
void View::ClearTextAnnotations()
{
this->Internal->TextAnnotations.clear();
}
void View::AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann)
{
this->Internal->TextAnnotations.push_back(std::move(ann));
}
void View::ClearAdditionalAnnotations()
{
this->Internal->AdditionalAnnotations.clear();
}
void View::AddAdditionalAnnotation(std::function<void(void)> ann)
{
this->Internal->AdditionalAnnotations.emplace_back(ann);
}
void View::RenderAnnotations()
{
for (unsigned int i = 0; i < this->Internal->Annotations.size(); ++i)
this->Internal->Annotations[i]->Render(
this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
if (this->RenderAnnotationsEnabled)
{
this->SetupForScreenSpace();
this->RenderScreenAnnotations();
for (auto& textAnnotation : this->Internal->TextAnnotations)
{
textAnnotation->Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
}
for (auto& additionalAnnotation : this->Internal->AdditionalAnnotations)
{
additionalAnnotation();
}
this->SetupForWorldSpace();
if (this->WorldAnnotationsEnabled)
{
this->RenderWorldAnnotations();
}
}
}
void View::SetupForWorldSpace(bool viewportClip)
{
//this->Camera.SetupMatrices();
this->GetCanvas().SetViewToWorldSpace(this->Internal->Camera, viewportClip);
}
void View::SetupForScreenSpace(bool viewportClip)
{
//this->Camera.SetupMatrices();
this->GetCanvas().SetViewToScreenSpace(this->Internal->Camera, viewportClip);
}
}
} // namespace vtkm::rendering
} // namespace vtkm
......@@ -89,6 +89,9 @@ public:
VTKM_CONT
void SetWorldAnnotationsEnabled(bool val) { this->WorldAnnotationsEnabled = val; }
VTKM_CONT void SetRenderAnnotationsEnabled(bool val) { this->RenderAnnotationsEnabled = val; }
VTKM_CONT bool GetRenderAnnotationsEnabled() { return this->RenderAnnotationsEnabled; }
VTKM_DEPRECATED(1.6, "Initialize() does nothing.")
virtual void Initialize();
......@@ -98,14 +101,25 @@ public:
void SaveAs(const std::string& fileName) const;
VTKM_CONT VTKM_DEPRECATED(1.6, "Use ClearTextAnnotations Instead") void ClearAnnotations();
VTKM_CONT VTKM_DEPRECATED(1.6, "Use AddTextAnnotation Instead") void AddAnnotation(
std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
VTKM_CONT
void SetAxisColor(vtkm::rendering::Color c);
VTKM_CONT
void ClearAnnotations();
void ClearTextAnnotations();
VTKM_CONT
void AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
VTKM_CONT
void ClearAdditionalAnnotations();
VTKM_CONT
void AddAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
void AddAdditionalAnnotation(std::function<void(void)> ann);
protected:
void SetupForWorldSpace(bool viewportClip = true);
......@@ -116,11 +130,13 @@ protected:
vtkm::rendering::Color AxisColor = vtkm::rendering::Color::white;
bool WorldAnnotationsEnabled = true;
bool RenderAnnotationsEnabled = true;
private:
std::shared_ptr<InternalData> Internal;
};
}
} //namespace vtkm::rendering
} // namespace vtkm::rendering
} // namespace vtkm
#endif //vtk_m_rendering_View_h
......@@ -42,13 +42,9 @@ void View1D::Paint()
{
this->GetCanvas().Clear();
this->UpdateCameraProperties();
this->SetupForWorldSpace();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
this->RenderWorldAnnotations();
this->SetupForScreenSpace();
this->RenderScreenAnnotations();
this->RenderColorLegendAnnotations();
this->AddAdditionalAnnotation([&]() { this->RenderColorLegendAnnotations(); });
this->RenderAnnotations();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
}
void View1D::RenderScreenAnnotations()
......
......@@ -40,13 +40,8 @@ void View2D::Paint()
{
this->GetCanvas().Clear();
this->UpdateCameraProperties();
this->SetupForWorldSpace();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
if (this->WorldAnnotationsEnabled)
this->RenderWorldAnnotations();
this->SetupForScreenSpace();
this->RenderScreenAnnotations();
this->RenderAnnotations();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
}
void View2D::RenderScreenAnnotations()
......
......@@ -39,15 +39,8 @@ View3D::~View3D() {}
void View3D::Paint()
{
this->GetCanvas().Clear();
this->SetupForWorldSpace();
if (this->WorldAnnotationsEnabled)
this->RenderWorldAnnotations();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
this->SetupForScreenSpace();
this->RenderAnnotations();
this->RenderScreenAnnotations();
this->GetScene().Render(this->GetMapper(), this->GetCanvas(), this->GetCamera());
}
void View3D::RenderScreenAnnotations()
......
......@@ -115,7 +115,7 @@ std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
new vtkm::rendering::TextAnnotationScreen(
"Test Plot", vtkm::rendering::Color(1, 1, 1, 1), .075f, vtkm::Vec2f_32(-.11f, .92f), 0.f));
view->AddAnnotation(std::move(titleAnnotation));
view->AddTextAnnotation(std::move(titleAnnotation));
return view;
}
......@@ -140,6 +140,7 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
const std::string& fieldNm,
const vtkm::cont::ColorTable& colorTable,
const std::string& outputFile,
const bool& enableAnnotations = true,
const vtkm::Float64& dataViewPadding = 0)
{
MapperType mapper;
......@@ -148,6 +149,7 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
ds, fieldNm, canvas, mapper, scene, colorTable, dataViewPadding);
view->SetRenderAnnotationsEnabled(enableAnnotations);
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
}
// --------------------------------------------------------------
......@@ -181,7 +183,7 @@ std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
new vtkm::rendering::TextAnnotationScreen(
"Test Plot", vtkm::rendering::Color(1, 1, 1, 1), .075f, vtkm::Vec2f_32(-.11f, .92f), 0.f));
view->AddAnnotation(std::move(titleAnnotation));
view->AddTextAnnotation(std::move(titleAnnotation));
return view;
}
......@@ -207,6 +209,7 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
const std::vector<std::string>& fields,
const std::vector<vtkm::rendering::Color>& colors,
const std::string& outputFile,
const bool& enableAnnotations = true,
const vtkm::Float64& dataViewPadding = 0)
{
MapperType mapper;
......@@ -216,6 +219,7 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
ds, fields, colors, canvas, mapper, scene, dataViewPadding);
view->SetRenderAnnotationsEnabled(enableAnnotations);
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
}
// --------------------------------------------------------------
......@@ -247,7 +251,7 @@ std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
new vtkm::rendering::TextAnnotationScreen(
"1D Test Plot", foreground, .1f, vtkm::Vec2f_32(-.27f, .87f), 0.f));
view->AddAnnotation(std::move(titleAnnotation));
view->AddTextAnnotation(std::move(titleAnnotation));
view->SetLogY(logY);
return view;
}
......@@ -275,6 +279,7 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
const vtkm::rendering::Color& color,
const std::string& outputFile,
const bool logY = false,
const bool& enableAnnotations = true,
const vtkm::Float64& dataViewPadding = 0)
{
MapperType mapper;
......@@ -283,11 +288,11 @@ void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
ds, fieldNm, canvas, mapper, scene, color, logY, dataViewPadding);
view->SetRenderAnnotationsEnabled(enableAnnotations);
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
}
// --------------------------------------------------------------
// A render test that allows for testing different mapper params
template <typename MapperType, typename CanvasType, typename ViewType>
void Render(MapperType& mapper,
......@@ -305,8 +310,6 @@ void Render(MapperType& mapper,
Render<MapperType, CanvasType, ViewType>(*view, outputFile);
}
template <typename MapperType1, typename MapperType2, typename CanvasType, typename ViewType>
void MultiMapperRender(const vtkm::cont::DataSet& ds1,
const vtkm::cont::DataSet& ds2,
......@@ -351,8 +354,9 @@ void MultiMapperRender(const vtkm::cont::DataSet& ds1,
canvas.SaveAs(outputFile);
}
}
}
} // namespace vtkm::rendering::testing
} // namespace vtkm::rendering
} // namespace vtkm
#endif //vtk_m_rendering_testing_RenderTest_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment