Skip to content

Commit

Permalink
Merge pull request #995 from mdkus/master
Browse files Browse the repository at this point in the history
Fix: 'opacity' workaround in ImageViewer (PCLVisualizer)
  • Loading branch information
jspricke committed Nov 13, 2014
2 parents cf38df2 + eb5c347 commit f60f25f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ pcl::visualization::ImageViewer::addPlanarPolygon (
poly->setColors (static_cast<unsigned char> (r * 255.0),
static_cast<unsigned char> (g * 255.0),
static_cast<unsigned char> (b * 255.0));
poly->setOpacity (opacity);
poly->set (xy);
am_it->actor->GetScene ()->AddItem (poly);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ namespace pcl
void setColors (unsigned char rgb[3]) { memcpy (colors, rgb, 3 * sizeof (unsigned char)); }
void setOpacity (double opacity) { SetOpacity (opacity); };
unsigned char colors[3];
double opacity;
std::vector<float> params;
};

Expand Down
29 changes: 15 additions & 14 deletions visualization/src/vtk/pcl_context_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ pcl::visualization::context_items::Text::set (float x, float y, const std::strin
bool
pcl::visualization::context_items::Circle::Paint (vtkContext2D *painter)
{
painter->GetPen ()->SetColor (colors);
painter->GetBrush ()->SetColor (colors);
painter->GetBrush ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawWedge (params[0], params[1], params[2], params[3], 0.0, 360.0);
return (true);
}
Expand All @@ -148,8 +148,8 @@ pcl::visualization::context_items::Circle::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::Disk::Paint (vtkContext2D *painter)
{
painter->GetBrush ()->SetColor (colors);
painter->GetPen ()->SetColor (colors);
painter->GetBrush ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawEllipse (params[0], params[1], params[2], params[2]);
return (true);
}
Expand All @@ -158,7 +158,7 @@ pcl::visualization::context_items::Disk::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::Rectangle::Paint (vtkContext2D *painter)
{
painter->GetPen ()->SetColor (colors);
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
float p[] =
{
params[0], params[1],
Expand All @@ -176,8 +176,8 @@ pcl::visualization::context_items::Rectangle::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::FilledRectangle::Paint (vtkContext2D *painter)
{
painter->GetBrush ()->SetColor (colors);
painter->GetPen ()->SetColor (colors);
painter->GetBrush ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawRect (params[0], params[1], params[2], params[3]);
return (true);
}
Expand All @@ -186,7 +186,7 @@ pcl::visualization::context_items::FilledRectangle::Paint (vtkContext2D *painter
bool
pcl::visualization::context_items::Line::Paint (vtkContext2D *painter)
{
painter->GetPen ()->SetColor (colors);
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawLine (params[0], params[1], params[2], params[3]);
return (true);
}
Expand All @@ -195,8 +195,8 @@ pcl::visualization::context_items::Line::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::Polygon::Paint (vtkContext2D *painter)
{
painter->GetBrush ()->SetColor (colors);
painter->GetPen ()->SetColor (colors);
painter->GetBrush ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawPolygon (&params[0], static_cast<int> (params.size () / 2));
return (true);
}
Expand All @@ -205,7 +205,7 @@ pcl::visualization::context_items::Polygon::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::Point::Paint (vtkContext2D *painter)
{
painter->GetPen ()->SetColor (colors);
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawPoint (params[0], params[1]);
return (true);
}
Expand All @@ -214,7 +214,7 @@ pcl::visualization::context_items::Point::Paint (vtkContext2D *painter)
bool
pcl::visualization::context_items::Points::Paint (vtkContext2D *painter)
{
painter->GetPen ()->SetColor (colors);
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawPoints (&params[0], static_cast<int> (params.size () / 2));
return (true);
}
Expand All @@ -225,6 +225,7 @@ pcl::visualization::context_items::Text::Paint (vtkContext2D *painter)
{
vtkTextProperty *text_property = painter->GetTextProp ();
text_property->SetColor (255.0 * colors[0], 255.0 * colors[1], 255.0 * colors[2]);
text_property->SetOpacity (GetOpacity ());
text_property->SetFontFamilyToArial ();
text_property->SetFontSize (10);
text_property->SetJustificationToLeft ();
Expand Down Expand Up @@ -257,10 +258,10 @@ pcl::visualization::context_items::Markers::Paint (vtkContext2D *painter)
size = 2.3 * painter->GetPen ()->GetWidth ();

painter->GetPen ()->SetWidth (size);
painter->GetPen ()->SetColor (colors);
painter->GetPen ()->SetColor (colors[0], colors[1], colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawPointSprites (0, &params[0], nb_points);
painter->GetPen ()->SetWidth (1);
painter->GetPen ()->SetColor (point_colors);
painter->GetPen ()->SetColor (point_colors[0], point_colors[1], point_colors[2], static_cast<unsigned char> ((255.0 * GetOpacity ())));
painter->DrawPointSprites (0, &params[0], nb_points);
return (true);
}
Expand Down

0 comments on commit f60f25f

Please sign in to comment.