1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2005 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_PopupTools.cxx
25 // Author : Sergey Anikin
28 #include "VisuGUI_PopupTools.h"
29 #include "VisuGUI_Tools.h"
30 #include "SalomeApp_Study.h"
31 #include "LightApp_Study.h"
33 #include "VISU_Actor.h"
34 #include "VISU_ScalarMapAct.h"
38 //////////////////////////////////////////////////
39 // Class: VisuGUI_Selection
40 //////////////////////////////////////////////////
42 QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const
44 QtxValue val( LightApp_Selection::param( ind, p ) );
45 if ( !val.isValid() ) {
46 if ( p == "type" ) val = QtxValue( type( ind ) );
47 else if ( p == "nbComponents" ) val = QtxValue( nbComponents( ind ) );
48 else if ( p == "representation" ) val = QtxValue( representation( ind ) );
49 else if ( p == "nbTimeStamps" ) val = QtxValue( nbTimeStamps( ind ) );
50 else if ( p == "nbChildren" ) val = QtxValue( nbChildren( ind ) );
51 else if ( p == "nbNamedChildren") val = QtxValue( nbNamedChildren( ind ) );
52 else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) );
53 else if ( p == "isShrunk" ) val = QtxValue( isShrunk( ind ) );
54 else if ( p == "hasActor" ) val = QtxValue( hasActor( ind ) );
55 else if ( p == "isShading" ) val = QtxValue( isShading( ind ) );
56 else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) );
62 // Macro for converting VISU enumeration items into corresponding strings
63 #define ENUM2STRING( x, y ) \
68 QString VisuGUI_Selection::type( const int ind ) const
71 VISU::Storable::TRestoringMap aMap;
72 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( ( LightApp_Study* )study() );
75 CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap );
77 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
78 if ( !CORBA::is_nil( aVisuObj ) ){
79 VISU::VISUType aType = aVisuObj->GetType();
81 ENUM2STRING( aResStr, VISU::TVISUGEN );
82 ENUM2STRING( aResStr, VISU::TRESULT );
83 ENUM2STRING( aResStr, VISU::TTABLE );
84 ENUM2STRING( aResStr, VISU::TCURVE );
85 ENUM2STRING( aResStr, VISU::TCONTAINER );
86 ENUM2STRING( aResStr, VISU::TMESH );
87 ENUM2STRING( aResStr, VISU::TSCALARMAP );
88 ENUM2STRING( aResStr, VISU::TISOSURFACE );
89 ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE );
90 ENUM2STRING( aResStr, VISU::TCUTPLANES );
91 ENUM2STRING( aResStr, VISU::TCUTLINES );
92 ENUM2STRING( aResStr, VISU::TVECTORS );
93 ENUM2STRING( aResStr, VISU::TSTREAMLINES );
94 ENUM2STRING( aResStr, VISU::TPLOT3D );
95 ENUM2STRING( aResStr, VISU::TANIMATION );
101 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue( aMap, "myType", &isExist).toInt();
104 ENUM2STRING( aResStr, VISU::TENTITY );
105 ENUM2STRING( aResStr, VISU::TFAMILY );
106 ENUM2STRING( aResStr, VISU::TGROUP );
107 ENUM2STRING( aResStr, VISU::TVIEW3D );
108 ENUM2STRING( aResStr, VISU::TFIELD );
109 ENUM2STRING( aResStr, VISU::TTIMESTAMP );
114 if(aResStr.isNull()){
116 QString aVal = VISU::Storable::FindValue(aMap,"myComment",&isExist);
117 if ( isExist && aVal!="MESH" )
118 aResStr = "VISU::T" + aVal;
124 QString VisuGUI_Selection::nbComponents( const int ind ) const
127 VISU::Storable::TRestoringMap aMap;
128 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( ( LightApp_Study* )study() );
131 GetSelectedObj( aStudy, entry( ind ), &aMap );
133 const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
139 QString VisuGUI_Selection::nbTimeStamps( const int ind ) const
142 VISU::Storable::TRestoringMap aMap;
143 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( ( LightApp_Study* )study() );
146 GetSelectedObj( aStudy, entry( ind ), &aMap );
148 const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist);
154 QString VisuGUI_Selection::representation( const int ind ) const
158 if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ){
159 if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ){
160 int aRepresent = anVISUActor->GetRepresentation();
161 switch ( aRepresent ){
162 ENUM2STRING( aResStr, VISU::POINT );
163 ENUM2STRING( aResStr, VISU::WIREFRAME );
164 ENUM2STRING( aResStr, VISU::SHADED );
165 ENUM2STRING( aResStr, VISU::INSIDEFRAME );
166 ENUM2STRING( aResStr, VISU::SURFACEFRAME );
174 int VisuGUI_Selection::nbChild( const int ind, const bool named ) const
177 SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>( ( LightApp_Study* )study() );
180 _PTR(Study) aStudy = GetCStudy( aSStudy );
182 _PTR(SObject) SO = aStudy->FindObjectID( entry( ind ).latin1() );
184 for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) {
186 if ( !Iter->Value()->ReferencedObject( refSO ) && ( !named || Iter->Value()->GetName().size() ) )
194 QString VisuGUI_Selection::nbChildren( const int ind ) const
197 aResStr.setNum( nbChild( ind, false ) );
201 QString VisuGUI_Selection::nbNamedChildren( const int ind ) const
204 aResStr.setNum( nbChild( ind, true ) );
208 QString VisuGUI_Selection::isVisible( const int ind ) const
212 if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
213 if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
214 aResStr = anVISUActor->GetVisibility() ? "1" : "0";
219 QString VisuGUI_Selection::isShrunk( const int ind ) const
223 if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
224 if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
225 if ( anVISUActor->IsShrunkable() )
226 aResStr = anVISUActor->IsShrunk() ? "1" : "0";
231 QString VisuGUI_Selection::hasActor( const int ind ) const
233 return representation( ind ).isEmpty() ? "0" : "1";
236 QString VisuGUI_Selection::isShading( const int ind ) const
240 if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
241 if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
242 if ( VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor) )
243 aResStr = anActor->IsShading() ? "1" : "0";
248 QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
252 if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
253 if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
255 VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor);
256 aResStr = anActor ? "1" : "0";