[Developers] uiAttributes changes

Bert Bril Bert.Bril at opendtect.org
Fri Oct 13 13:13:31 CEST 2006


Hi all,

Due to the 2.5.1 problem the new attribute group facility has been
released early, so I'm a bit late with this e-mail.

We simply got so many attributes that it became unwieldy. In the new
situation, users can select their attribute directly as before, or
choose a group and pick one from that. Groups are not fixed: you can
specify your own group (although there are a number of 'standard' groups
defined in uiattrdesced.h). Note that the group is a UI-only thing: all
attribute names still need to be unique.

I have tried to make life even simpler than it was. You will need to
make some changes, but they will mostly be small changes and some stuff
can be removed. Here is what I did to an example, i.c. the uiCoherency
attribute (plugins/uiCoh):

---

In uicoherencyattrib.h, you have these lines spread over the class:

static void		initClass();
const char*		getAttribName() const;
static uiAttrDescEd*	createInstance(uiParent*);

.... remove them if you have one of them. To replace this, at the end of
the class def (because it's not interesting for anyone), you need to add
one line:

			mDeclReqAttribUIFns

The code then looks like:

...
    virtual void        set2D(bool);

                        mDeclReqAttribUIFns
};

---

In uicoherencyattrib.cc, I search for 'mInitUI', which leads me to:
mInitUI(uiCoherencyAttrib,"Coherency")

I change that to:
mInitAttribUI(uiCoherencyAttrib,Coherency,"Coherency",sKeyBasicGrp)

(Params are: class name, attribute name,display name,group name)

If you don't have that in your attrib source file, you need to add a
line like this. The 'standard' groups are in uiattrdesced.h, but you can
choose new group names if that suits you.

Then, search for the implementation of 'getAttribName'. If it's there,
remove it.

---

We also need to change the top-level plugin code, uicohpi.cc.
The include of uiattrfact.h needs to go - just remove the entire
#include line. Also, get rid of all lines with mDeclAttrDescEd.

Then, the line:
uiAttribFactory::add( "Coherency", "Coherency",
                      new uiCoherencyAttrDescEdCreater);
changes to:
uiCoherencyAttrib::initClass();

---


That's it. If you want to make code that goes for all versions, check
for the existence of the mInitAttribUI macro with #ifdef's, for example:

#ifndef mInitAttribUI
# include "uiattrfact.h"
#endif


/Bert

-- 
-- Bert Bril / OpendTect developer at dGB
-- Nijverheidstraat 11-2, 7511 JM Enschede, The Netherlands
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org
-- Tel: +31 534315155 , Fax: +31 534315104




More information about the Developers mailing list