1 // Copyright (C) 2005 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
20 #include "SUPERVGUI_Selection.h"
21 #include "SUPERVGUI.h"
23 #include <LightApp_DataOwner.h>
24 #include <SalomeApp_Study.h>
26 #include <SUIT_Session.h>
27 #include <SUIT_ViewWindow.h>
28 #include <SUIT_ViewManager.h>
29 #include <SUIT_ViewModel.h>
31 #include <SALOMEDSClient_SObject.hxx>
32 #include <SALOMEDSClient_Study.hxx>
33 #include <SALOMEDS_SObject.hxx>
34 #include <SALOME_Prs.h>
35 #include <SALOME_InteractiveObject.hxx>
39 #include <OCCViewer_ViewModel.h>
41 SUPERVGUI_Selection::SUPERVGUI_Selection()
45 SUPERVGUI_Selection::~SUPERVGUI_Selection()
49 QtxValue SUPERVGUI_Selection::param( const int ind, const QString& p ) const
51 QtxValue val( LightApp_Selection::param( ind, p ) );
52 if ( !val.isValid() ) {
53 if ( p == "type" ) val = QtxValue( typeName( ind ) );
56 //printf( "--> param() : [%s] = %s\n", p.latin1(), val.toString ().latin1() );
61 QString SUPERVGUI_Selection::typeName( const int index ) const
63 if ( isComponent( index ) )
66 _PTR(SObject) anIObj = getObject( index );
68 bool aIsOwner, aIsDataflow;
69 SUPERVGUI::Supervision()->whatIsSelected(anIObj, aIsOwner, aIsDataflow);
70 if ( aIsDataflow ) //selected dataflow object
72 if ( aIsOwner ) //selected object belongs to Supervisor
73 return "SupervisorObject";
78 bool SUPERVGUI_Selection::isComponent( const int index ) const
80 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
81 (SUIT_Session::session()->activeApplication()->activeStudy());
83 if ( appStudy && index >= 0 && index < count() ) {
84 _PTR(Study) study = appStudy->studyDS();
85 QString anEntry = entry( index );
87 if ( study && !anEntry.isNull() ) {
88 _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );
89 if ( aSO && aSO->GetFatherComponent() )
90 return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
96 _PTR(SObject) SUPERVGUI_Selection::getObject( const int index ) const
98 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
99 (SUIT_Session::session()->activeApplication()->activeStudy());
101 if ( appStudy && index >= 0 && index < count() ) {
102 _PTR(Study) study = appStudy->studyDS();
103 QString anEntry = entry( index );
105 if ( study && !anEntry.isNull() ) {
106 _PTR(SObject) aSO( study->FindObjectID( anEntry.latin1() ) );