Hi Sascha,

I want to achieve that the GetCurrentSelection() function returns the node
that I want to select. If the selection event is fired and the
OnSelectionChanged function of the view is invoked automatically, that is a
plus, but I can invoke it myself.

I tried this now, but did not help:

  berry::ISelectionProvider::Pointer selectionProvider =
GetSite()->GetSelectionProvider();
  berry::SingleNodeSelection* singleSelection = new
berry::SingleNodeSelection();
  singleSelection->SetNode(d->surfaceNode);
  berry::ISelection::Pointer selection;
  selection = singleSelection;
  selectionProvider->SetSelection(selection);

Is this how it should work?

The GetCurrentSelection still returns an empty list.

Thanks,
Miklos

On Mon, Jun 18, 2012 at 2:39 PM, Sascha Zelzer
<s.zel...@dkfz-heidelberg.de>wrote:

>  Hi Miklos,
>
> I guess what you want is to change the selection state of some widget in
> your application (for example the selection in the datamanager).
>
> You can either use the Qt API of the widget directly (if you have access
> to it) or you could work with the selection provider of a particular view
> to change that views selection state. Have a look at
> IWorkbenchPartSite::GetSelectionProvider() and the "SetSelection()" method
> of the returned ISelectionProvider instance.
>
> - Sascha
>
>
> On 06/18/2012 01:29 PM, Miklos Espak wrote:
>
> Hi Andreas,
>
> now I tried, but did not help.
>
>   d->referenceNode->SetSelected(false);
>   d->surfaceNode->SetSelected(true);
>   FireNodeSelected(d->surfaceNode);
>   QList < itk::SmartPointer<mitk::DataNode> > currentSelection =
> this->GetCurrentSelection();
>   MITK_INFO << "SurfaceExtractorView::createSurfaceNode() selected node
> number: " << currentSelection.size();
>
>
> The code prints zero.
>
> Regards,
> Miklos
>
>  On Mon, Jun 18, 2012 at 12:19 PM, Fetzer, Andreas <
> a.fet...@dkfz-heidelberg.de> wrote:
>
>> Hi Miklos,
>>
>> you have to call FireNodeSelected(DataNode*). SetSelected just changes
>> the property value.
>>
>> Regards
>> Andreas
>>
>> On 18.06.2012, at 12:10, Miklos Espak wrote:
>>
>> Hi,
>>
>>
>> is there a way to select a node programmatically?
>>
>> I tried a code snippet that I found in the MITK code base, but it does
>> not work.
>>
>>
>> ------------------------------------------------
>>  d->referenceNode->SetSelected(false);
>>  d->surfaceNode->SetSelected(true);
>>
>>  // EMULATE INITIAL SELECTION EVENTS
>>  // send the current selection
>>  berry::IWorkbenchPart::Pointer activePart =
>> this->GetSite()->GetPage()->GetActivePart();
>>  if (activePart.IsNotNull())
>>  {
>>   QList < itk::SmartPointer<mitk::DataNode> > currentSelection =
>> this->GetCurrentSelection();
>>   this->OnSelectionChanged(activePart, currentSelection);
>>  }
>> ------------------------------------------------
>>
>> d->referenceNode and d->surfaceNode are added to the data storage. The
>> problem is that even I change their "selected" property, the
>> currentSelection is empty.
>>
>> Any idea?
>>
>> Thank you,
>> Miklos
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats.
>> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________
>> mitk-users<http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/_______________________________________________%0Amitk-users>mailing
>>  list
>> mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/mitk-users
>>
>>
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to