Personal tools
You are here: Home Forum How to use Salome? Failed to get Selected Item from LightApp_SelectionMgr

Failed to get Selected Item from LightApp_SelectionMgr

Up to How to use Salome?

Failed to get Selected Item from LightApp_SelectionMgr

Posted by Yuefeng Qiu at February 07. 2013

Hello!

I am learning to integrate module into SALOME. My test code create some regular meshes and organizes these meshes in mesh groups. 

My problem is: after creating a Mesh Group, I try to select this group and obtain its Group ID by LightApp_SelectionMgr, but there is nothing in the selected list. I need the Group ID for appending new meshes.

I attach my code for debugging. The problem occurs in XYZMESHGUI_CreateMeshOp.cxx:67. 

Thanks !

BTW, is it a good choice to use LightApp_Operation and LightApp_Dialog? I found them laborious and unclear for usage. 

Attachments

Re: Failed to get Selected Item from LightApp_SelectionMgr

Posted by Yuefeng Qiu at February 08. 2013

I think I found the reason by myself. The selected items are removed each time the UpdateBrowser() is called. One bug in my code cause calling of this method before obtaining the select list. that is why I get nothing.

Re: Failed to get Selected Item from LightApp_SelectionMgr

Posted by Vadim SANDLER at February 08. 2013

Hello Yuefeng,

Actually selection manager seems to work OK. When I select created group in the Object browser, invoke "GenerateMesh" operation from menu and press OK button, I can see in debugger that QString aEntry is "XYZMESHGUI_1" (line 74 of XYZMESHGUI_CreateMeshOp.cxx file) - exactly as shown in the "Entry" column of the Object browser. Moreover, after next code line aGroupId is 1 (ok).

However, then the application crashes. I did not analyze the reason, it seems to be a problem with the data model.

Regarding LightApp_Operation and LightApp_Dialog classes - indeed, you are not obliged to use these helper classes in your module, you can use any alternative approach to implement GUI actions.

Regards,
Vadim.

Re: Failed to get Selected Item from LightApp_SelectionMgr

Posted by Yuefeng Qiu at February 08. 2013

Thanks, Vadim!

I have a bug in the  XYZMESHGUI_CreateMeshOp::OnApply(), which invokes the abort() method. the object browser is updated therefore all selected item is deselected. 

I think LightApp_Operation and LightApp_Dialog classes offer useful methods for controlling the GUI interaction. Unfortunately there is no very detail documents and tutorials and therefore hard for me to know its mechanism. A good helper class is wasted. 


Re: Failed to get Selected Item from LightApp_SelectionMgr

Posted by Timo Siltala at March 14. 2017

Hi Vadim,

I have a problem with selection: execution never gets into MYMODULE::selected function (checked it several times with debugger). I have DataModel and DataObject, object manager beautifully represents my items tree. However yet no operations written for them. Is this the reason for my problem? If not, how does the entry to ::selection happen (who calls it) or where could the problem hide? Compilation goes OK.

Regards,

Timo

Re: Failed to get Selected Item from LightApp_SelectionMgr

Posted by Vadim SANDLER at March 14. 2017

Hello Timo,

You have to connect a signal from selection manager to the dedicated slot. Most appropriate place to do this is activateModule() method of your module class. See how this is done in Geometry module:

bool GeometryGUI::activateModule( SUIT_Study* study )
{
   ...
   connect( sm, SIGNAL( currentSelectionChanged() ), this, SLOT( updateCreationInfo() ));
   ...
}

Here, updateCreationInfo() is the method which can be invoked when selection is changed. It should be declared in a class as a slot, e.g.:

class GeometryGUI : public SalomeApp_Module
{
   ...
   private slots:
      void  updateCreationInfo();
   ...
}

And don't forget to disconnect the slot in the deactivateModule() method if you don't want your module to react on selection change event when the module is not active!

Regards,
Vadim.

Powered by Ploneboard
Document Actions