[vtkusers] vtkChartLegend SetOpacity not working

Joseph Melnyk JMelnyk at pile.com
Thu Jul 7 13:01:27 EDT 2011


For what it's worth, this solution worked wonderfully.  One only needs to do chart->GetLegend()->GetBrush()->SetOpactiy([0-255]) to set the opacity.

Thanks again!





> -----Original Message-----
> From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
> Behalf Of Joseph Melnyk
> Sent: Wednesday, July 06, 2011 3:27 PM
> To: Eric E. Monson
> Cc: vtkusers at vtk.org
> Subject: Re: [vtkusers] vtkChartLegend SetOpacity not working
> 
> vtkChartLegend::SetBrush must be pretty new, as it's not in my nightly build
> from January.  I'll build that and give it a go.  Thanks for the suggestion
> though; I've done similar things with GetPen() before so it should work out.
> 
> Regards
> Joseph Melnyk
> 
> 
> 
> > -----Original Message-----
> > From: Eric E. Monson [mailto:emonson at cs.duke.edu]
> > Sent: Wednesday, July 06, 2011 3:01 PM
> > To: Joseph Melnyk
> > Cc: vtkusers at vtk.org
> > Subject: Re: [vtkusers] vtkChartLegend SetOpacity not working
> >
> > Hey Joseph,
> >
> > It looks like SetOpacity is inherited by vtkChartLegend from
> > vtkContextItem, but not really used.
> >
> > It happens that you can change the background of the legend through
> > GetBrush(), then set a color with a lower alpha, and change the
> > outline through the GetPen() method, then change the opacity to a non-
> unity value.
> >
> > Hopefully this accomplishes what you want, -Eric
> >
> > P.S. I don't know if it makes any difference, but just so you know,
> > you can also turn on the legend using chart->SetShowLegend(true);
> >
> > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> > Eric E Monson Duke Visualization Technology Group
> >
> >
> > On Jul 6, 2011, at 2:29 PM, Joseph Melnyk wrote:
> >
> > > I'm attempting to use vtkChartLegend's SetOpacity function and it
> > > doesn't
> > appear to be working, neither in my code nor if I modify the test examples.
> > For example, modifying the code at
> > http://www.vtk.org/Wiki/VTK/Examples/Cxx/Plotting/LinePlot to include
> > the following lines has no effect:
> > >
> > >  chart->GetLegend()->SetVisible(true);
> > >  chart->GetLegend()->SetOpacity(.5);
> > >
> > > Am I missing something or is this broken?  I'm using a 5.6.1 version
> > > of VTK
> > from the nightly (built in late January).
> > >
> > > Thanks!
> > >
> > > __Scanned by MessageLabs
> > > _______________________________________________
> > > Powered by www.kitware.com
> > >
> > > Visit other Kitware open-source projects at
> > > http://www.kitware.com/opensource/opensource.html
> > >
> > > Please keep messages on-topic and check the VTK FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ
> > >
> > > Follow this link to subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
> > _Scanned by MessageLabs
> 
> __Scanned by MessageLabs
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> _Scanned by MessageLabs

__Scanned by MessageLabs



More information about the vtkusers mailing list