1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, 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.
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
22 #include "SUPERVGUI_Selection.h"
23 #include "SUPERVGUI.h"
25 #include <LightApp_DataOwner.h>
26 #include <SalomeApp_Study.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ViewWindow.h>
30 #include <SUIT_ViewManager.h>
31 #include <SUIT_ViewModel.h>
33 #include <SALOMEDSClient_SObject.hxx>
34 #include <SALOMEDSClient_Study.hxx>
35 #include <SALOMEDS_SObject.hxx>
36 #include <SALOME_Prs.h>
37 #include <SALOME_InteractiveObject.hxx>
41 #include <OCCViewer_ViewModel.h>
43 SUPERVGUI_Selection::SUPERVGUI_Selection()
47 SUPERVGUI_Selection::~SUPERVGUI_Selection()
51 QtxValue SUPERVGUI_Selection::param( const int ind, const QString& p ) const
53 QtxValue val( LightApp_Selection::param( ind, p ) );
54 if ( !val.isValid() ) {
55 if ( p == "type" ) val = QtxValue( typeName( ind ) );
58 //printf( "--> param() : [%s] = %s\n", p.latin1(), val.toString ().latin1() );
63 QString SUPERVGUI_Selection::typeName( const int index ) const
65 if ( isComponent( index ) )
68 _PTR(SObject) anIObj = getObject( index );
70 bool aIsOwner, aIsDataflow;
71 SUPERVGUI::Supervision()->whatIsSelected(anIObj, aIsOwner, aIsDataflow);
72 if ( aIsDataflow ) //selected dataflow object
74 if ( aIsOwner ) //selected object belongs to Supervisor
75 return "SupervisorObject";
80 bool SUPERVGUI_Selection::isComponent( const int index ) const
82 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
83 (SUIT_Session::session()->activeApplication()->activeStudy());
85 if ( appStudy && index >= 0 && index < count() ) {
86 _PTR(Study) study = appStudy->studyDS();
87 QString anEntry = entry( index );
89 if ( study && !anEntry.isNull() ) {
90 _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );
91 if ( aSO && aSO->GetFatherComponent() )
92 return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
98 _PTR(SObject) SUPERVGUI_Selection::getObject( const int index ) const
100 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
101 (SUIT_Session::session()->activeApplication()->activeStudy());
103 if ( appStudy && index >= 0 && index < count() ) {
104 _PTR(Study) study = appStudy->studyDS();
105 QString anEntry = entry( index );
107 if ( study && !anEntry.isNull() ) {
108 _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );