1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "LightApp_PV3DSelector.h"
24 #include "LightApp_DataOwner.h"
26 #include "SUIT_Desktop.h"
28 #ifndef DISABLE_PV3DVIEWER
29 #include "SPV3D_ViewModel.h"
30 #include "SPV3D_ViewManager.h"
31 #include "SPV3D_ViewWindow.h"
32 #include <vtkRenderer.h>
35 #ifndef DISABLE_SALOMEOBJECT
36 // #include "SALOME_Actor.h"
37 // #include "SALOME_ListIO.hxx"
40 #include <utilities.h>
42 #ifndef DISABLE_PV3DVIEWER
46 LightApp_PV3DSelector::LightApp_PV3DSelector( SPV3D_ViewModel* viewer, SUIT_SelectionMgr* mgr )
47 : SUIT_Selector( mgr, viewer ),
51 connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
57 SPV3D_ViewModel* LightApp_PV3DSelector::viewer() const
63 Gets type of salome PV3D viewer.
65 QString LightApp_PV3DSelector::type() const
67 return myViewer->getType();
75 void LightApp_PV3DSelector::onSelectionChanged()
80 #ifndef DISABLE_PV3DVIEWER
83 Gets list of selected data owners.(output \a aList).
85 void LightApp_PV3DSelector::getSelection( SUIT_DataOwnerPtrList& /*aList*/ ) const
90 if ( !myViewer->isSelectionEnabled() )
93 // if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){
94 // if(PV3DViewer_ViewManager* aViewMgr = dynamic_cast<PV3DViewer_ViewManager*>(aViewManager)){
95 // if(PV3DViewer_ViewWindow* aView = dynamic_cast<PV3DViewer_ViewWindow*>(aViewMgr->getActiveView())){
96 // if(SPV3D_Selector* aSelector = aView->GetSelector()){
97 // const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
98 // SALOME_ListIteratorOfListIO anIter(aListIO);
99 // for(; anIter.More(); anIter.Next()){
100 // Handle(SALOME_InteractiveObject) anIO = anIter.Value();
101 // if(anIO->hasEntry())
102 // aList.append(new LightApp_SPV3DDataOwner(anIO,aViewMgr->getDesktop()));
111 Sets selection to selector from data owner list \a theList.
113 void LightApp_PV3DSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
115 if ( myViewer && ( theList.isEmpty() || myViewer->isSelectionEnabled() )) {
116 //if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager())
118 // if(SPV3D_ViewWindow* aView = dynamic_cast<SPV3D_ViewWindow*>(aViewMgr->getActiveView()))
120 // if(PV3DViewer_Selector* aSelector = aView->GetSelector()){
121 // SALOME_ListIO anAppendList;
122 // const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
123 // SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
124 // for(; anIter != theList.end(); ++anIter) {
125 // const SUIT_DataOwner* aDataOwner = (*anIter).get();
126 // if(const LightApp_SPV3DDataOwner* anOwner = dynamic_cast<const LightApp_SPV3DDataOwner*>(aDataOwner))
128 // MESSAGE("aSelector->SetSelectionMode("<<anOwner->GetMode()<<");");
129 // aSelector->SetSelectionMode(anOwner->GetMode());
130 // Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
132 // aSelector->AddIObject(anIO);
134 // anAppendList.Append(anIO);
135 // aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
137 // else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner))
139 // Handle(SALOME_InteractiveObject) anIO =
140 // new SALOME_InteractiveObject(anOwner->entry().toUtf8(),"");
141 // aSelector->AddIObject(anIO);
142 // anAppendList.Append(anIO);
145 // // To remove IOs, which is not selected.
146 // QMap< QString, Handle( SALOME_InteractiveObject )> toRemove;
147 // SALOME_ListIteratorOfListIO anIt( aStoredList );
148 // for( ; anIt.More(); anIt.Next() )
149 // if( !anIt.Value().IsNull() )
150 // toRemove[ anIt.Value()->getEntry() ] = anIt.Value();
152 // anIt = SALOME_ListIteratorOfListIO(anAppendList);
153 // for( ; anIt.More(); anIt.Next() )
154 // toRemove.remove( anIt.Value()->getEntry() );
156 // QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
157 // REnd = toRemove.end();
158 // for( ; RIt!=REnd; RIt++ )
159 // aSelector->RemoveIObject( RIt.value() );
161 // aView->onSelectionChanged();