[OpendTect_Developers] How to couple 2D Viewer's Visual Objects with tree item

Umesh Sinha umesh.sinha at dgbes.com
Tue Jun 14 06:36:35 CEST 2011


Dear All,

This is second post in series of how to work with our recently launched 
2D viewer.

In my earlier post I talked about how to add your own element in 2D 
Viewer's tree. For those who missed that post, can access at 
http://lists.opendtect.org/pipermail/developers/2011-February/000229.html

Today I'm going to discuss how to couple each leaf of 2D Viewer's tree 
item with corresponding 2D Viewer's Visual Object. Assuming, everyone 
will be familiar with what is mean by 'leaf' in tree data structure. Do 
let me know if anyone is not familiar with this notation, I can explain 
it in a bit detail.

First of all, lets get ourselves introduced to 'Vw2DDataObject'. This is 
the base class for visualization on 2D Viewer. Apart from other routine 
things, this class has two important members,

1) id_
2) name_

and one important method
1) triggerDeSel()

*id_* and *name_* is responsible for keeping unique id and unique name 
in 'local 2D Viewer system'. The moment one creates 'Vw2DDataObject' 
type of object, corresponding 'id_' automatically get generated and one 
can access this 'id_' via 'id()' method. *triggerDeSel()* is a virtual 
method where one puts his own custom deSelection and clean up/washing 
hand off mechanism. For a better understanding have a look at 
'/od/include(src)/uiViewer2D/visvw2ddata.h(cc)'.

For a direct coupling between leaf of tree item of 2D Viewer's tree item 
and corresponding 'Vw2DDataObject', make sure 'Vw2DDataObject' is having 
*has-a relationship* with 'leaf of 2D Viewer's tree item'.

Then comes 'Vw2DDataManager'. This class more or less works as a 
container as well as controller class for all the 'Vw2DDataObject' type 
of objects for local 2D Viewer system.

If 'local 2D Viewer' sounds confusing then, in OpendTect one can have 
more than one 2D Viewer at a time and each '2D Viewer' works as a 
independent system in itself. While coding one doesn't have to bother 
about whether (s)he is in local 2D Viewer system or not. The moment one 
ask corresponding tree item for 'viewer2D()', it straightforward gives 
'local 2D Viewer'.

Knowing what's there in 'Vw2DDataManager' is not important, but knowing 
how it handles 'Vw2DDataObject' type of objects is backbone of entire 2D 
viewer system.

In each 'local 2D Viewer system' one can access above mentioned manager 
by calling 'viewer2D()->dataMgr()'. There are three important function 
which are primarily responsible for containing and controlling 
'Vw2DDataObject' type of objects. These are

1)addObject(Vw2DDataObject*) :Whenever we make new 'Vw2DDataObject' type 
of object in leaf tree item, we should call this function.

2)removeObject(Vw2DDataObject*) : Functions just opposite of above 
mentioned function 'addObject'.

3)setSelected(Vw2DDataObject*) : This function is called when we need to 
pass selection action to corresponding 'Vw2DDataObject' type of object 
via tree item's *select()* method call. This particular function is most 
important one, by calling this we jump inside the corresponding 
'Vw2DDataObject' type of object where we can do painting and editing on 
2D Viewer's displayed image.

Hope this post will help in getting familiar with 2D Viewer system. How 
to do above mentioned 'painting and editing', I'll explain in  my next 
post. Till then happy coding.

With Regards,
Umesh

-- 
Umesh Sinha
Geoscientific Software Engineer
dGB Earth Science
304, Gateway Plaza, Hiranandani Garden, Powai, Mumbai 400076, India
Phone: +91 22 25704984 , Fax: +91 22 25704977, Mobile: +91 9930126183
umesh.sinha at dgbes.com, http://www.dgbes.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendtect.org/pipermail/developers/attachments/20110614/2ca46c49/attachment.html>


More information about the Developers mailing list