Forum Replies Created
-
AuthorPosts
-
4 May 2016 at 11:17 in reply to: [SOLVED] [Suggestion] Handling of container of complex class inside GUI of SOFA #6672Olivier CARREBlocked
Hi Fabien,
In fact the Data class already has a widget customisation method called “setWidget” so you should not have to specialise it.Right after the data initialisation you can call this method and give it the name of the widget you want it to use in the GUI.
The name of the widget used in the function parameter has to be the same than the one used when registering the widget designed to view / edit the corresponding data in the Sofa factory.For instance, in the “image” plugin we have a component named ImageViewer (take a look at ImageViewer.h) owning a data named “histo” of a new type “HistogramType”. To be able to view / edit this new type with the proper GUI we call
histo.setWidget("imagehistogram")
in the constructor of the ImageViewer class and in another file (HistogramWidget.h/cpp) we define and register its corresponding widget (inheriting QWidget since we use Qt4) in the sofa factory like this :
helper::Creator<DataWidgetFactory, HistogramDataWidget< Histogram<unsigned char> > > DWClass_histoUC("imagehistogram",true);
Here HistogramDataWidget is a widget designed to handle Histograms correctly.
In this example, the widget inheritance hierarchy is not really straight forward regarding QWidget because we have to handle template parameters to be able to deal with all kind of histogram according to pixel depth (unsigned char, float, etc.).Take a look at this example and do not hesitate to ask if you have any questions about it.
-
AuthorPosts