[OpendTect_Developers] How to create QC panels for your attribute

Helene Huck helene.huck at dgbes.com
Wed Nov 3 17:01:12 CET 2010


Hi all,

While developing attributes I noticed that there is an increasing demand
from the users for QC tools and help facilities while choosing
parameters. A simple 2D panel can indeed sometimes be of great help to
calibrate the attributes settings, and thus be a real 'plus' to
integrate in your attribute user interface.
You can find examples of such panels in OpendTect in the GapDecon free
plugin or more recently in the Spectral Decomposition attribute user
interfaces.
To make the programming of those panels easier, a specific class is now
available since development version 4.1.1: the uiAttribPanel
(uiAttributes/uiattribpanel) which is designed to help attribute preview
in a 2D viewer. This new class is basically taking over all the
management of tasks that are not specific to your attribute, like
passing your data to the attribute engine or the creation of the 2D
viewer, which makes it a lot easier to have a nice panel with a very
reasonable amount of work.

So, how can you quickly program such a panel for your attribute?
Let's have a look at some code abstract from the Spectral Decomposition
user interface code (uiAttributes/uispecdecompattrib) :

>  void uiSpecDecompAttrib::panelTFPush( CallBacker* cb )
> {
>     if ( inpfld_->attribID() == DescID::undef() )
>     {
>         uiMSG().error( "Please, first, fill in the Input Data field" );
>         return;
>     }
>
>     MultiID mid;
>     getInputMID( mid );
>     CubeSampling cs;
>     inpfld_->getRanges( cs );
>     if ( positiondlg_ ) delete positiondlg_;
>     positiondlg_ = new uiTrcPositionDlg( this, cs, ads_->is2D(), mid );
>     if ( !positiondlg_->go() ) return;
>
>     DescSet* dset = new DescSet( *ads_ );
>     DescID inpid = inpfld_->attribID();
>     DescID specdecompid = createSpecDecompDesc( dset );
>
>     LineKey lk;
>     cs = positiondlg_->getCubeSampling();
>     if ( dset->is2D() )
>         lk = LineKey( positiondlg_->getLineKey() );
>     panelview_->compAndDispAttrib( dset, specdecompid, cs, lk );
> } 

This is the function which is called when the user clicks on the
"Display Panel" button; you can see here 4 different paragraphs, I will
go throught them one by one:

The first one is a check to ensure the data field has been filled in,
nothing strange.
The second one aims to pop up a small dialog (the new uiTrcPositionDlg
class can be seen at uiSeis/uitrcpositiondlg) to let the user choose the
position of the trace(s) which will be used for the QC or attribute preview.

The third paragraph is there to do the only thing that is really
specific to your attribute: build the attribute description
(Attrib::Desc), ie select its parameters, inputs and outputs; you can
use attribute parameters selected by the user in the interface (QC,
attribute preview) or any other combination (self computed attributes as
input, default parameters...). Coding the creation of the Attrib::Desc
is of course more or less complicated depending on the complexity of
your attribute: the more parameters and inputs, the more lines of code
to set them all, but all in all this is more fastidious than difficult.
I invite you to use the uispecdecompattrib.cc file as an example
(functions createSpecDecompDesc and fillInSDDescParams), here is an
abstract where you can see how to set 3 parameters in the description
for instance:

> #define mSetParam( type, nm, str, fn )\                               
>                                                        //a macro to be
> quicker...
> {\
>     mDynamicCastGet(type##Param*, nm, newdesc->getValParam(str))\
>     nm->setValue( fn );\
> }
>
>
> void uiSpecDecompAttrib::fillInSDDescParams( Desc* newdesc ) const
> {
>     mSetParam(Enum,type,SpecDecomp::transformTypeStr(),
> typefld_->getBoolValue() ? 0 : 2)        //set the transform type
> parameter
>    
> mSetParam(Enum,cwt,SpecDecomp::cwtwaveletStr(),waveletfld_->getIntValue())   
>                     //set the wavelet type
>     mSetParam(ZGate,gate,SpecDecomp::gateStr(),
> gatefld_->getFInterval())                                   //set the
> z gate

And, at last, the fourth paragraph is asking the panel view to do all
the rest: compute the attribute and display it in the 2D viewer,
provided the description of the attribute and the CubeSampling of the
position(s) we want to compute it.

And this is it, with that little bit of work you get a nice QC panel
coupled with your attribute user interface!
You can of course always use the defaults of the uiAttribPanel or
customize your panel by creating a subclass of it and change colors,
labels... the choice is all yours, but at least you do not have to
bother with the hard work anymore!

Best regards,
Helene

-- 
--
-- Helene Huck
-- Geophysical software engineer
-- dGB Earth Sciences B.V.
-- Nijverheidstraat 11-2, 7511 JM Enschede, The Netherlands
-- mailto: helene.huck at dgbes.com, http://www.dgbes.com
-- Tel: +31 53 4315155 , Fax: +31 53 4315104

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


More information about the Developers mailing list