Startbutton and Helpfile

41 views
Skip to first unread message

mkx...@gmail.com

unread,
Nov 24, 2017, 5:43:42 PM11/24/17
to OpendTect Developers
Hello dear OpendTect Developers!


In a former question about Inline- and Crosslinesegments (it was a Multicoreproblem, which I could finally solve) I had an additional question about a Startbutton (Icon), which should trigger editAttributeSet() with my Attribute pre-selected.


Raman was so nice to give me the following hint:

    Attrib::DescSet* ads = Attrib::eDSHolder().getDescSet(false, false);
   
Attrib::Desc* newdesc = Attrib::PF().createDescCopy("MyAttribute");
    ads
->addDesc(newdesc);
   
ODMainWin()->applMgr().editAttribSet(false);

That would have been the "perfect" solution, and it works with any other Attribute like "Convole"  etc., but throws an unhandled exception with mine.
Unhandled exception at 0x00007FFF80451B9D (AttributeEngine.dll) in od_main.exe: 0xC0000005: Access violation reading location 0x00000000000000F0.
In attribdescset.cc
Desc* DescSet::gtDesc( const DescID& id ) const
{
   
const int idx = ids_.indexOf( id ); // here!
   
if ( !descs_.validIdx(idx) )
 
      return 0;
   
return const_cast<Desc*>( descs_[idx] );
}


Later on, my colleague got an email from Arnaud with the following hint:

Here is a code snippet (in short you need to define two descs, one to provide the attribute input, and the second is your own attribute. Not sure what would happen if you skip the creation of the storeddesc)

Attrib::DescSet* ads = Attrib::eDSHolder().getDescSet(false,false);
// First attribute to define: The seismic input. Maybe you can skip it and see if ads already has such attribute to provide, as it may not be empty: ads->getStoredInput() would return non-null. 
Attrib::Desc* storeddesc = Attrib::PF().createDescCopy(Attrib::StorageProvider::attribName() )
Attrib::ValParam* keypar = storeddesc->getValParam( Attrib::StorageProvider::keyStr() );
PtrMan<IOObj> seisioobj = IOM().get( uiSeisPartServer::getDefaultDataID( bool is2d ) );
if ( seisioobj )
{
    keypar
->setValue( seisioobj->key()  );
    storeddesc
->setHidden( true );
    storeddesc
->selectOutput( 0 );
    storeddesc
->setUserRef( seisioobj->name() );
    ads
->addDesc( storeddesc );
}

// Second attribute to define: Your attribute (check if the key is appropriate) 
Attrib::Desc* newdesc = Attrib::PF().createDescCopy( "MyAttribute" );
newdesc
->setInput( 0, storeddesc );
newdesc
->setUserRef( findFreeRef().buf() );
ads
->addDesc( newdesc );

attrsetedcalled_
.trigger();


Well, I had to change Line 4 to:
PtrMan
<IOObj> seisioobj = IOM().get(ODMainWin()->applMgr().seisServer()->getDefaultDataID(false));


and with the line 
newdesc->setUserRef( findFreeRef().buf() );

I couldn't do much too, because: What findFreeRef()-Function? I simply said
newdesc->setUserRef("New Attribute");

Furthermore the last line caused headache because of the unknown member-Object, I still used:
ODMainWin()->applMgr().editAttribSet(false);

All that done, I still get the same unhandled Exception at same location and still it works with other Attributes like "Convolve", just that now they already have a predefined Attribute Name, "New Attribute" in this case.
Btw.: When I would chose a Fantasy-Attribute, like the above "MyAttribute", and not mine, than the exception is thrown at
BufferString& BufferString::assignTo( const char* s ) {...}
in bufstring.cc

I really have no clue anymore. Maybe someone could help?


Another (really shorter!) question about the helpfile.
Following the Tutorial I wrote these lines:

FilePath fp(GetDocFileDir(""));
BufferString baseurl("file:///");
baseurl
.add(fp.fullPath().add("/"));
fp
.add("MyHelp.txt");
BufferString tablefnm = fp.fullPath();
return new FracTexHelpProvider(baseurl.buf(), tablefnm.buf());

But in this case, the Help-Button just opens the Explorer and shows the doc-Folder where my Helpfile is.
Maybe, much better would be e.g. a html-file (or even a url), which is automatically opened by the Browser. I tried some options, but couldn't get it run.
B.t.w.: The doc-Folder is the correct place where (all) the Helpfiles should go, correct?

Thank you very much in advance!
Martin



mkx...@gmail.com

unread,
Dec 11, 2017, 10:26:33 AM12/11/17
to OpendTect Developers
Regarding the second question I direct the "Helpfile" to "https://dgbes.com/", which is ok currently, maybe just not very useful for the user. And its hardcoded. I'll change that later on.

Regarding my first question this is still a small "problem". After I got Package-Advices from Arnaud I had the small hope that with all alo-files and the Release dll's the plugin is treated like e.g. "Convolve". And then its just a 3-liner, like Raman mentioned some weeks before. So my technical question is: What does "Convolve" (and other Plugins) have, what I don't have? ;-)

With best wishes: Martin

mkx...@gmail.com

unread,
Feb 1, 2018, 8:01:15 PM2/1/18
to OpendTect Developers
Solved with the help of the one and only Raman!

In fact, the 4-liner

    Attrib::DescSet* ads = Attrib::eDSHolder().getDescSet(false, false);
   
Attrib::Desc* newdesc = Attrib::PF().createDescCopy("MyAttribute");
    ads
->addDesc(newdesc);
   
ODMainWin()->applMgr().editAttribSet(false);

is fine. But in my uiXxx_attrib-file I use in a function the variable ads_ (uiattrdesced.h), which is ok when I start the Plugin via "Edit Attributes" and then select it, but isn't initialized in that particular moment of the call above.
I'm so happy now! :-)
Reply all
Reply to author
Forward
0 new messages