[OpendTect_Developers] tips and tricks for plugin makers

Helene Huck helene.huck at dgbes.com
Wed Mar 16 11:02:41 CET 2011


Hi all,

Looking at support emails is always very handy to get an insight into
the problems you, as plugin makers, might be confronted to. There are of
course often questions which are very project-dependent but some others
can, I guess, be of interest for everyone.
I would like to share here a few tips and tricks which you could use
while building your plugins, around 2 subjects:
1) how to allow computation on z-slices, picksets and horizons even when
your attribute requires the entire trace as input ?
2) How can you make sure that your plugin icons and menus are always
added to the desired menus and toolbars? and why do you need it?

Let's just start with the first issue; some attributes sometimes require
the entire trace to be present to get a meaningful output (recursive
attributes for instance, full trace transformation...). To safely allow
computation on z-slices, picksets and horizons, which only consist of 1
single Z position, there is just a little extra thing to define: a
desired sample gate big enough to cover the entire trace.
Here is an example of what you should have :
in your include file:

/protected:
const Interval<int>*        desZSampMargin(int input,int output) const;
Interval<int>                    deszsamplemargin_;/

and in the .cc file:
/deszsamplemargin_ = Interval<int>( -10000, 10000 );/   [whatever, just
make it big] in the constructor

and
/const Interval<int>* MyAttrib::desZSampMargin(int input, int output) const
{
    return &deszsamplemargin_;
}/

And this is it, in the end very simple and easy.

Let's now talk about putting plugin related stuff into OpendTect menus
and toolbars.
At survey change the menus are always rebuilt to accomodate changes in
survey settings which would make some menus/buttons useless or even
irrelevant (2D and 3D specific menus for instance). You will thus need a
callback at survey change to be able to insert your plugins in the menus.

Here is a example of what you should have in your uimypluginpi.cc file:

-- class declaration --

/class uiMyPluginPIMgr : public CallBacker
{
public:

                        uiMyPluginPIMgr(uiODMain*);
void                 updateDTectProcMnu(CallBacker*);
void                 insertMyMenu();

uiODMain*       appl;
} /

-- the constructor of the plugin info manager --

/uiMyPluginPIMgr::uiMyPluginPIMgr( uiODMain* a )
    : appl(a)
{
    appl->menuMgr().dTectMnuChanged.notify(
                        mCB(this,uiMyPluginPIMgr, updateDTectProcMnu) );
    insertMyMenu();
} /

-- implementation --
/void uiMyPluginPIMgr::updateDTectProcMnu( CallBacker* )
{
    insertMyMenu();
} /

-- example of simple insertion of a single menu item in the "Processing"
menu of OpendTect--
/void uiMyPluginPIMgr::insertMyMenu()
{
    uiPopupMenu* procmnu = appl->menuMgr().procMnu();
    procmnu->insertSeparator();
    uiPopupMenu* mymnu = new uiPopupMenu( appl, "&New plugin" );
    procmnu->insertItem( mymnu );
} /

-- and the InituiMyPluginPlugin --

/mExternC const char* InituiDipSteerPlugin( int, char** )
{
    static uiMyPluginPIMgr* pimgr = 0; if ( pimgr ) return 0;
    pimgr = new uiMyPluginPIMgr( ODMainWin() );
} /

You can find a real example in our uiHorizonAttrib plugin, in
/uihorattribpi.cc/ .


Best regards and happy coding!
Helene HUCK

-- 
--
-- 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/20110316/2102a4f2/attachment.html>


More information about the Developers mailing list