[OpendTect_Developers] How to save oneself from 2D Viewer Annotation repainting overhead
Umesh Sinha
umesh.sinha at dgbes.com
Mon Oct 31 06:05:32 CET 2011
Dear Fellow Developer,
Good to see that popularity of 2D Viewer is growing day by day. Hard
work at our end is certainly paying dividend.
Today I'm going to let you know how to save yourself from repainting all
annotation overhead in 2D Viewer.
First of all let us see how we do 'Annotation Painting' with help of our
AuxData.
Let us say, we have a bunch of 2D points and we know where they should
go in 2D Viewer layout, then first thing we do is initialize an AuxData
as given below,
FlatView::Annotation::AuxData* myauxdata = new
FlatView::Annotation::AuxData( "name" );
then we initialize display property of our choice for AuxData as
described below,
myauxdata->markerstyles_ += your_marker_style;
myauxdata->linestyle_ = your_linestyle;
myauxdata->linestyle_.color_ = your_color
and so on...
and then convert all 2D points to FlatView::Point and add then to
myauxdata->poly_. For example, if one of the points is having coordinate
x and y, then following code will add your data to AuxData points
myauxdata->poly_ = FlatView::Point( x, y );
then we make sure AuxData is enabled and add it to 2D Viewer system, as
shown below
myauxdata->enabled_ = true;
viewer_.appearance().annot_.auxdata_ += auxdata;
here 'viewer_' represents '2D Viewer' and I'm assuming we all know how
to get correct '2D Viewer' instance.
Finally we ask '2D Viewer' system to handle the change with respect to
Annotation as shown below.
viewer_.handleChange( FlatView::Viewer::Annot );
So far as good, but problem with 'viewer_.handleChange(Annot)' approach
is if we have already so many things painted on 2D Viewer and ask 2D
Viewer system to handle change with respect to Annotation then it
repaints the entire AuxData again, which is a bit of overhead.
I have added some functionalities in Viewer which can help you in
dealing with your individual AuxData only, those are
void showAuxDataObjects(Annotation::AuxData&,bool);
void updateProperties(const Annotation::AuxData&);
void reGenerate(Annotation::AuxData&) ;
void remove(const Annotation::AuxData&);
Hoping these are self explanatory, do let me know if you have any
questions or confusion.
Happy coding with less overhead :-)
With Regards,
Umesh
--
- Umesh Sinha
- Geoscientific Software Developer
-
- dGB Earth Sciences
- 304, Gateway Plaza, Hiranandani Gardens,
- Powai, Mumbai 400 076, India
- Phone: +91 22 25704984 , Fax: +91 22 25704977
- Mobile: +91 9930126183
- mailto:umesh.sinha at dgbes.com, http://www.dgbes.com
More information about the Developers
mailing list