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 "GEOM_Swig_LocalSelector.h"
24 #include <SalomeApp_Study.h>
25 #include <SUIT_Desktop.h>
26 #include <SUIT_Session.h>
27 #include <GeometryGUI.h>
28 #include <SalomeApp_Application.h>
29 #include <LightApp_SelectionMgr.h>
30 #include <SALOMEDSClient_definitions.hxx>
32 #include <utilities.h>
34 GEOM_Swig_LocalSelector::GEOM_Swig_LocalSelector(QWidget* parent, SUIT_ViewWindow* wnd, const std::string& shapeEntry, int mode) :
35 GEOMBase_Helper(dynamic_cast<SUIT_Desktop*>(parent), wnd )
37 MESSAGE("GEOM_Swig_LocalSelector " << shapeEntry << " " << mode);
38 myObject = GEOM::GEOM_Object::_nil();
39 mySubShapesInd = new GEOM::short_array();
40 std::string shapeName = "aShape";
42 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(SUIT_Session::session()->activeApplication()->activeStudy());
45 _PTR(Study) studyDS = study->studyDS();
46 _PTR(SObject) obj( studyDS->FindObjectID( shapeEntry ) );
47 if ( GeometryGUI::IsInGeomComponent( obj ))
49 CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
50 if (!CORBA::is_nil(corbaObj))
52 myObject = GEOM::GEOM_Object::_narrow(corbaObj);
53 shapeName = myObject->GetName();
54 MESSAGE("shapeName: " << shapeName);
60 modes.push_back(mode);
61 localSelection(shapeEntry, shapeName, modes);
64 GEOM_Swig_LocalSelector::~GEOM_Swig_LocalSelector()
66 MESSAGE("~GEOM_Swig_LocalSelector");
69 std::vector<int> GEOM_Swig_LocalSelector::getSelection()
71 MESSAGE("getSelection");
72 SalomeApp_Application* app = (SalomeApp_Application*)SUIT_Session::session()->activeApplication();
73 LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
74 SALOME_ListIO aSelList;
75 aSelMgr->selectedObjects(aSelList);
77 TColStd_IndexedMapOfInteger aMap;
78 MESSAGE("aSelList.Extent(): " << aSelList.Extent());
79 if (aSelList.Extent() > 0)
81 Handle(SALOME_InteractiveObject) anIO = aSelList.First();
82 aSelMgr->GetIndexes(anIO, aMap);
85 const int n = aMap.Extent();
87 for (int i = 1; i <= n; i++)
88 ids.push_back(aMap(i));
89 for (int i =0; i < (int)ids.size(); i++)
91 MESSAGE("ids[" << i << "] = " << ids[i]);