1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : YACSGui_Selection.cxx
22 // Author : Alexander BORODIN
26 #include <YACSGui_Selection.h>
27 #include <YACSGui_Module.h>
28 #include <YACSGui_DataModel.h>
30 #include <LightApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
32 #include <SalomeApp_Study.h>
33 #include <SALOME_ListIO.hxx>
36 #include "YacsTrace.hxx"
42 YACSGui_Selection::YACSGui_Selection ()
50 YACSGui_Selection::~YACSGui_Selection ()
54 //!redefined method param
57 QtxValue YACSGui_Selection::param( const int k, const QString& name) const
59 DEBTRACE("YACSGui_Selection::param name = " << name.latin1());
62 if ( name == "ObjectType" )
64 DEBTRACE("ObjectType= " << myCurrentObjectType.latin1());
65 v = myCurrentObjectType;
69 return LightApp_Selection::param( k, name );
72 //!detection of type of current selected object
75 void YACSGui_Selection::init( const QString& client, LightApp_SelectionMgr* mgr)
77 LightApp_Selection::init(client, mgr);
79 myCurrentObjectType = "";
81 YACSGui_Module* module = dynamic_cast<YACSGui_Module*>( mgr->application()->activeModule() );
82 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
83 if ( study && module )
85 _PTR(Study) studyDS = study->studyDS();
88 SALOME_ListIO selObjects;
89 mgr->selectedObjects( selObjects, false );
91 //consider only single selection
92 if ( selObjects.Extent() == 1 )
94 Handle(SALOME_InteractiveObject) io = selObjects.First();
95 YACSGui_DataModel::ObjectType type = ((YACSGui_DataModel*)module->dataModel())->objectType( io->getEntry() );
96 myCurrentObjectType = YACSGui_DataModel::Type2Str( type );