add support for removing annotations and remove from regression tests
This commit is contained in:
parent
6f612107d0
commit
a683a8802a
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:785051d9773c4a0ced2701de3499f9cd948da2a4c846a5187e30dfb5cb0783cb
|
||||
size 10830
|
||||
oid sha256:26b8279b8eb9ef3bb4e957628d3f314c5574843a3ceae58a9f0118bef3b3e7f2
|
||||
size 4116
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1d990b5f0e9ef27e4e5f87f4c62c4f9974992506521f32bd5901ac6670e71bfa
|
||||
size 9656
|
||||
oid sha256:dc0d600511b6cecc7b17c6ac39f108b1891b3711ac44166d87958fe361aeb625
|
||||
size 3358
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:54e09a09c97a20627e54c835d2d488bc9f692ef1315122ab60241c006ab78813
|
||||
size 19742
|
||||
oid sha256:6080d76845175339023139297f67baca21fa1c09421c566f1b51d145a65f210b
|
||||
size 4029
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e1472e6002ca4ad4012e0c9f067f8254290fabe93c82713a4994ad97a7fdbdfc
|
||||
size 31218
|
||||
oid sha256:5c6902c4b2089309101cf016312eecb033e50e5d065bcf735c472ec977d0645d
|
||||
size 12912
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5ff6d72bd325ffe0fb3b22bfdc294b6d674384afd662290424bb77634202b4ef
|
||||
size 71150
|
||||
oid sha256:7f27abf679d3f23b17fd43a490b6ae8a124881de73f64ba4b335f70d8f59779e
|
||||
size 56859
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:24c71e8846fe62e6f6eefdb72c9729639061af80bf9d3453d35c8c6838de9174
|
||||
size 37162
|
||||
oid sha256:d6ea614e63fdab4c80192084b78c1c31f6c73791509d15e3b4a71198a7fca218
|
||||
size 25127
|
||||
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b4c905ec76e72513519515ec41cf5efd34490b98255ee7465f8b6746fcff41e5
|
||||
size 51865
|
||||
oid sha256:11af170f56b1b3a8abdfa92e53d902954ce5cbf83fd18f16dbab05a0e37ee35d
|
||||
size 27534
|
||||
|
@ -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 AddAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
|
||||
void AddTextAnnotation(std::unique_ptr<vtkm::rendering::TextAnnotation> ann);
|
||||
|
||||
VTKM_CONT
|
||||
void ClearAdditionalAnnotations();
|
||||
|
||||
VTKM_CONT
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user