Commit 6d616309 authored by Matt Larsen's avatar Matt Larsen
Browse files

let there be foreground color

parent 59afc5cb
......@@ -330,11 +330,21 @@ struct Canvas::CanvasInternals
: Width(width)
, Height(height)
{
BackgroundColor.Components[0] = 0.f;
BackgroundColor.Components[1] = 0.f;
BackgroundColor.Components[2] = 0.f;
BackgroundColor.Components[3] = 1.f;
ForegroundColor.Components[0] = 1.f;
ForegroundColor.Components[1] = 1.f;
ForegroundColor.Components[2] = 1.f;
ForegroundColor.Components[3] = 1.f;
}
vtkm::Id Width;
vtkm::Id Height;
vtkm::rendering::Color BackgroundColor;
vtkm::rendering::Color ForegroundColor;
ColorBufferType ColorBuffer;
DepthBufferType DepthBuffer;
vtkm::rendering::BitmapFont Font;
......@@ -400,6 +410,16 @@ void Canvas::SetBackgroundColor(const vtkm::rendering::Color& color)
Internals->BackgroundColor = color;
}
const vtkm::rendering::Color& Canvas::GetForegroundColor() const
{
return Internals->ForegroundColor;
}
void Canvas::SetForegroundColor(const vtkm::rendering::Color& color)
{
Internals->ForegroundColor = color;
}
void Canvas::Initialize()
{
}
......
......@@ -87,6 +87,12 @@ public:
VTKM_CONT
void SetBackgroundColor(const vtkm::rendering::Color& color);
VTKM_CONT
const vtkm::rendering::Color& GetForegroundColor() const;
VTKM_CONT
void SetForegroundColor(const vtkm::rendering::Color& color);
VTKM_CONT
vtkm::Id2 GetScreenPoint(vtkm::Float32 x,
vtkm::Float32 y,
......
......@@ -56,7 +56,7 @@ void ColorBarAnnotation::Render(const vtkm::rendering::Camera& camera,
canvas.AddColorBar(bounds, this->ColorTable, true);
this->Axis.SetColor(vtkm::rendering::Color(1, 1, 1));
this->Axis.SetColor(canvas.GetForegroundColor());
this->Axis.SetLineWidth(1);
this->Axis.SetScreenPosition(bounds.X.Min, bounds.Y.Min, bounds.X.Max, bounds.Y.Min);
this->Axis.SetMajorTickSize(0, .02, 1.0);
......
......@@ -189,12 +189,14 @@ struct MapperWireframer::InternalsType
: Canvas(canvas)
, ShowInternalZones(showInternalZones)
, IsOverlay(isOverlay)
, CompositeBackground(true)
{
}
vtkm::rendering::Canvas* Canvas;
bool ShowInternalZones;
bool IsOverlay;
bool CompositeBackground;
}; // struct MapperWireframer::InternalsType
MapperWireframer::MapperWireframer()
......@@ -356,6 +358,16 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
renderer.SetColorMap(this->ColorMap);
renderer.SetData(actualCoords, edgeIndices, actualField, scalarRange);
renderer.Render();
if (this->Internals->CompositeBackground)
{
this->Internals->Canvas->BlendBackground();
}
}
void MapperWireframer::SetCompositeBackground(bool on)
{
this->Internals->CompositeBackground = on;
}
vtkm::rendering::Mapper* MapperWireframer::NewCopy() const
......
......@@ -47,6 +47,7 @@ public:
bool GetShowInternalZones() const;
void SetShowInternalZones(bool showInternalZones);
void SetCompositeBackground(bool on);
bool GetIsOverlay() const;
void SetIsOverlay(bool isOverlay);
......
......@@ -28,13 +28,16 @@ namespace rendering
View::View(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: Scene(scene)
, MapperPointer(mapper.NewCopy())
, CanvasPointer(canvas.NewCopy())
, WorldAnnotatorPointer(canvas.CreateWorldAnnotator())
{
this->CanvasPointer->SetBackgroundColor(backgroundColor);
this->CanvasPointer->SetForegroundColor(foregroundColor);
this->AxisColor = foregroundColor;
vtkm::Bounds spatialBounds = this->Scene.GetSpatialBounds();
this->Camera.ResetToBounds(spatialBounds);
......@@ -52,7 +55,8 @@ View::View(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: Scene(scene)
, MapperPointer(mapper.NewCopy())
, CanvasPointer(canvas.NewCopy())
......@@ -60,6 +64,8 @@ View::View(const vtkm::rendering::Scene& scene,
, Camera(camera)
{
this->CanvasPointer->SetBackgroundColor(backgroundColor);
this->CanvasPointer->SetForegroundColor(foregroundColor);
this->AxisColor = foregroundColor;
}
View::~View()
......
......@@ -42,13 +42,15 @@ public:
View(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
View(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
virtual ~View();
......@@ -94,6 +96,12 @@ public:
this->CanvasPointer->SetBackgroundColor(color);
}
VTKM_CONT
void SetForegroundColor(const vtkm::rendering::Color& color)
{
this->CanvasPointer->SetForegroundColor(color);
}
virtual void Initialize();
virtual void Paint() = 0;
......
......@@ -30,8 +30,9 @@ namespace rendering
View1D::View1D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, backgroundColor, foregroundColor)
{
}
......@@ -39,8 +40,9 @@ View1D::View1D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, camera, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, camera, backgroundColor, foregroundColor)
{
}
......@@ -116,6 +118,7 @@ void View1D::RenderColorLegendAnnotations()
vtkm::rendering::Actor act = this->GetScene().GetActor(i);
this->Legend.AddItem(act.GetScalarField().GetName(), act.GetColorTable().MapRGB(0));
}
this->Legend.SetLabelColor(this->GetCanvas().GetForegroundColor());
this->Legend.Render(this->GetCamera(), this->GetWorldAnnotator(), this->GetCanvas());
}
}
......
......@@ -35,13 +35,15 @@ public:
View1D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
View1D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
~View1D();
......
......@@ -28,8 +28,9 @@ namespace rendering
View2D::View2D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, backgroundColor, foregroundColor)
{
}
......@@ -37,8 +38,9 @@ View2D::View2D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, camera, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, camera, backgroundColor, foregroundColor)
{
}
......
......@@ -36,13 +36,15 @@ public:
View2D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
View2D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
~View2D();
......
......@@ -28,8 +28,9 @@ namespace rendering
View3D::View3D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, backgroundColor, foregroundColor)
{
}
......@@ -37,8 +38,9 @@ View3D::View3D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor)
: View(scene, mapper, canvas, camera, backgroundColor)
const vtkm::rendering::Color& backgroundColor,
const vtkm::rendering::Color& foregroundColor)
: View(scene, mapper, canvas, camera, backgroundColor, foregroundColor)
{
}
......
......@@ -37,13 +37,15 @@ public:
View3D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
View3D(const vtkm::rendering::Scene& scene,
const vtkm::rendering::Mapper& mapper,
const vtkm::rendering::Canvas& canvas,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1));
const vtkm::rendering::Color& backgroundColor = vtkm::rendering::Color(0, 0, 0, 1),
const vtkm::rendering::Color& foregroundColor = vtkm::rendering::Color(1, 1, 1, 1));
~View3D();
......
......@@ -103,14 +103,15 @@ void Render(const vtkm::cont::DataSet& ds,
{
MapperType mapper;
CanvasType canvas(512, 512);
canvas.SetBackgroundColor(vtkm::rendering::Color::white);
vtkm::rendering::Scene scene;
scene.AddActor(vtkm::rendering::Actor(
ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fieldNm), colorTable));
vtkm::rendering::Camera camera;
SetCamera<ViewType>(camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fieldNm));
ViewType view(scene, mapper, canvas, camera, vtkm::rendering::Color(0.2f, 0.2f, 0.2f, 1.0f));
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
ViewType view(scene, mapper, canvas, camera, background, foreground);
// Print the title
vtkm::rendering::TextAnnotationScreen* titleAnnotation =
......@@ -142,7 +143,10 @@ void Render(const vtkm::cont::DataSet& ds,
}
vtkm::rendering::Camera camera;
SetCamera<ViewType>(camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fields[0]));
ViewType view(scene, mapper, canvas, camera, vtkm::rendering::Color(0.2f, 0.2f, 0.2f, 1.0f));
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
ViewType view(scene, mapper, canvas, camera, background, foreground);
// Print the title
vtkm::rendering::TextAnnotationScreen* titleAnnotation =
......@@ -164,7 +168,6 @@ void Render(const vtkm::cont::DataSet& ds,
{
MapperType mapper;
CanvasType canvas(512, 512);
canvas.SetBackgroundColor(vtkm::rendering::Color::white);
vtkm::rendering::Scene scene;
//DRP Actor? no field? no colortable (or a constant colortable) ??
......@@ -172,14 +175,15 @@ void Render(const vtkm::cont::DataSet& ds,
vtkm::rendering::Actor(ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fieldNm), color));
vtkm::rendering::Camera camera;
SetCamera<ViewType>(camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fieldNm));
ViewType view(scene, mapper, canvas, camera, vtkm::rendering::Color(0.2f, 0.2f, 0.2f, 1.0f));
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
ViewType view(scene, mapper, canvas, camera, background, foreground);
// Print the title
vtkm::rendering::TextAnnotationScreen* titleAnnotation =
new vtkm::rendering::TextAnnotationScreen("1D Test Plot",
vtkm::rendering::Color(1, 1, 1, 1),
.1f,
vtkm::Vec<vtkm::Float32, 2>(-.27f, .87f),
0.f);
new vtkm::rendering::TextAnnotationScreen(
"1D Test Plot", foreground, .1f, vtkm::Vec<vtkm::Float32, 2>(-.27f, .87f), 0.f);
view.AddAnnotation(titleAnnotation);
view.SetLogY(logY);
Render<MapperType, CanvasType, ViewType>(view, outputFile);
......
......@@ -107,14 +107,14 @@ void RenderTests()
typedef vtkm::rendering::View1D V1;
vtkm::cont::testing::MakeTestDataSet maker;
vtkm::rendering::ColorTable colorTable("thermal");
//vtkm::rendering::testing::Render<M, C, V3>(
// maker.Make3DRegularDataSet0(), "pointvar", colorTable, "reg3D.pnm");
//vtkm::rendering::testing::Render<M, C, V3>(
// maker.Make3DRectilinearDataSet0(), "pointvar", colorTable, "rect3D.pnm");
//vtkm::rendering::testing::Render<M, C, V3>(
// maker.Make3DExplicitDataSet4(), "pointvar", colorTable, "expl3D.pnm");
vtkm::rendering::ColorTable colorTable("OrRd");
vtkm::rendering::testing::Render<M, C, V3>(
maker.Make3DRegularDataSet0(), "pointvar", colorTable, "reg3D.pnm");
vtkm::rendering::testing::Render<M, C, V3>(
maker.Make3DRectilinearDataSet0(), "pointvar", colorTable, "rect3D.pnm");
vtkm::rendering::testing::Render<M, C, V3>(
maker.Make3DExplicitDataSet4(), "pointvar", colorTable, "expl3D.pnm");
vtkm::rendering::testing::Render<M, C, V3>(
Make3DUniformDataSet(), "pointvar", colorTable, "uniform3D.pnm");
vtkm::rendering::testing::Render<M, C, V2>(
......
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