]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Selection.cxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/visu.git] / src / VISUGUI / VisuGUI_Selection.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU VISUGUI : GUI of VISU component
23 //  File   : VisuGUI_Selection.cxx
24 //  Author : Sergey Anikin 
25 //  Module : VISU
26 //
27 #include "VisuGUI_Selection.h"
28
29 #include "VisuGUI_ViewTools.h"
30 #include "VisuGUI_Tools.h"
31
32 #include "VISU_Result_i.hh"
33 #include "VISU_Gen_i.hh"
34
35 #include "VISU_Actor.h"
36 #include "VISU_ScalarMapAct.h"
37
38 #include "SalomeApp_Study.h"
39 #include "LightApp_Study.h"
40 #include "LightApp_Displayer.h"
41
42 using namespace VISU;
43
44 //////////////////////////////////////////////////
45 // Class: VisuGUI_Selection
46 //////////////////////////////////////////////////
47
48
49 //---------------------------------------------------------------
50 QVariant VisuGUI_Selection::parameter( const int ind, const QString& p ) const
51 {
52   QVariant val( LightApp_Selection::parameter( ind, p ) );
53   if ( !val.isValid() ) {
54     if      ( p == "type"           ) val = QVariant( type( ind ) );
55     else if ( p == "nbComponents"   ) val = QVariant( nbComponents( ind ) );
56     else if ( p == "medEntity"   ) val = QVariant( medEntity( ind ) );
57     else if ( p == "medSource"   ) val = QVariant( medSource( ind ) );
58     else if ( p == "representation" ) val = QVariant( representation( ind ) );
59     else if ( p == "nbTimeStamps"   ) val = QVariant( nbTimeStamps( ind ) );
60     else if ( p == "nbChildren"     ) val = QVariant( nbChildren( ind ) );
61     else if ( p == "nbNamedChildren") val = QVariant( nbNamedChildren( ind ) );
62     else if ( p == "isVisible"      ) val = QVariant( isVisible( ind ) );
63     else if ( p == "isShrunk"       ) val = QVariant( isShrunk( ind ) );
64     else if ( p == "hasActor"       ) val = QVariant( hasActor( ind ) );
65     else if ( p == "isShading"      ) val = QVariant( isShading( ind ) );
66     else if ( p == "isScalarMapAct" ) val = QVariant( isScalarMapAct( ind ) );
67     else if ( p == "isVisuComponent") val = QVariant( isVisuComponent( ind ) );
68     else if ( p == "fullResolution"   ) val = QVariant( fullResolution( ind ) );
69     else if ( p == "mediumResolution"   ) val = QVariant( mediumResolution( ind ) );
70     else if ( p == "lowResolution"   ) val = QVariant( lowResolution( ind ) );
71     else if ( p == "resolutionState"   ) val = QVariant( resolutionState( ind ) );
72     else if ( p == "isThereAreVisibleCurves" ) val = QVariant( findDisplayedCurves( ind, false ) );
73     else if ( p == "isThereAreHiddenCurves" ) val = QVariant( findDisplayedCurves( ind, true ) );
74     else if ( p == "hasCurves"      ) val = QVariant( hasCurves( ind ) );
75     else if ( p == "isPlot2dViewer"      ) val = QVariant( Plot2dViewerType( ind ) );
76     else if ( p == "isValuesLabeled"  ) val = QVariant( isValuesLabeled( ind ) );
77     else if ( p == "isScalarBarVisible" ) val = QVariant( isScalarBarVisible( ind ) );
78   }
79
80   return val;
81 }
82
83
84 //---------------------------------------------------------------
85 // Macro for converting VISU enumeration items into corresponding strings
86 #define ENUM2STRING( x, y ) \
87   case y: \
88     x = QString( #y ); \
89     break
90
91 QString VisuGUI_Selection::type( const int ind ) const
92 {
93   QString aResStr;
94   SalomeApp_Study* aStudy = GetStudy();
95   if ( !aStudy )
96     return aResStr;
97
98   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1());
99   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
100
101   VISU::Base_i* aBase = anObjectInfo.myBase;
102   if(aBase){
103     VISU::VISUType aType = aBase->GetType();
104     if(aType == VISU::TCOLOREDPRS3DHOLDER){
105       CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
106       VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
107       aType = aHolder->GetPrsType();
108     }
109     switch (aType) {
110       ENUM2STRING( aResStr, VISU::TVISUGEN );
111       ENUM2STRING( aResStr, VISU::TRESULT );
112       ENUM2STRING( aResStr, VISU::TTABLE );
113       ENUM2STRING( aResStr, VISU::TCURVE );
114       ENUM2STRING( aResStr, VISU::TCONTAINER );
115       ENUM2STRING( aResStr, VISU::TMESH );
116       ENUM2STRING( aResStr, VISU::TSCALARMAP );
117       ENUM2STRING( aResStr, VISU::TISOSURFACES );
118       ENUM2STRING( aResStr, VISU::TDEFORMEDSHAPE );
119       ENUM2STRING( aResStr, VISU::TSCALARMAPONDEFORMEDSHAPE );
120       ENUM2STRING( aResStr, VISU::TCUTPLANES );
121       ENUM2STRING( aResStr, VISU::TCUTLINES );
122       ENUM2STRING( aResStr, VISU::TVECTORS );
123       ENUM2STRING( aResStr, VISU::TSTREAMLINES );
124       ENUM2STRING( aResStr, VISU::TPLOT3D );
125       ENUM2STRING( aResStr, VISU::TANIMATION );
126       ENUM2STRING( aResStr, VISU::TPOINTMAP3D );
127     }
128   }
129
130   if(aResStr.isNull()){
131     VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aMap);
132     switch (aType) {
133       ENUM2STRING( aResStr, VISU::TENTITY );
134       ENUM2STRING( aResStr, VISU::TFAMILY );
135       ENUM2STRING( aResStr, VISU::TGROUP );
136       ENUM2STRING( aResStr, VISU::TVIEW3D );
137       ENUM2STRING( aResStr, VISU::TFIELD );
138       ENUM2STRING( aResStr, VISU::TTIMESTAMP );
139     }
140   }
141
142   if(aResStr.isNull()){
143     bool anIsExist;
144     QString aVal = VISU::Storable::FindValue(aMap, "myComment", &anIsExist);
145     if ( anIsExist && aVal != "MESH" )
146       aResStr = "VISU::T" + aVal;
147   }
148
149   return aResStr;
150 }
151
152
153 //---------------------------------------------------------------
154 QString VisuGUI_Selection::nbComponents( const int ind ) const
155 {
156   QString aResStr;
157   SalomeApp_Study* aStudy = GetStudy();
158   if ( !aStudy )
159     return aResStr;
160
161   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1());
162   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
163
164   bool isExist;
165   QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
166   if ( isExist )
167     aResStr = aVal;
168   return aResStr;
169 }
170
171
172 //---------------------------------------------------------------
173 QString VisuGUI_Selection::resolutions( const int ind ) const
174 {
175   QString aResStr;
176   SalomeApp_Study* aStudy = GetStudy();
177   if ( !aStudy )
178     return aResStr;
179
180   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ).toLatin1().data());
181   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
182
183   bool isExist;
184   QString aVal = VISU::Storable::FindValue(aMap,"myResolutions",&isExist);
185   if ( isExist )
186     aResStr = aVal;
187
188   return aResStr;
189 }
190
191
192 //---------------------------------------------------------------
193 QString VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const
194 {
195   QString aResStr;
196
197   QString aResolutions = resolutions( ind );
198   if(aResolutions.isEmpty())
199     return aResStr;
200   
201   if(aResolutions.indexOf(theResoltuion) != -1)
202     aResStr = "1";
203   else
204     aResStr = "0";
205
206   return aResStr;
207 }
208
209
210 //---------------------------------------------------------------
211 QString VisuGUI_Selection::fullResolution( const int ind ) const
212 {
213   return resolution( ind, 'F');
214 }
215
216
217 //---------------------------------------------------------------
218 QString VisuGUI_Selection::mediumResolution( const int ind ) const
219 {
220   return resolution( ind, 'M');
221 }
222
223
224 //---------------------------------------------------------------
225 QString VisuGUI_Selection::lowResolution( const int ind ) const
226 {
227   return resolution( ind, 'L');
228 }
229
230
231 //---------------------------------------------------------------
232 QString VisuGUI_Selection::resolutionState( const int ind ) const
233 {
234   QString aResStr;
235   SalomeApp_Study* aStudy = GetStudy();
236   if ( !aStudy )
237     return aResStr;
238
239   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ).toLatin1().data());
240   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
241
242   bool isExist;
243   QString aVal = VISU::Storable::FindValue(aMap,"myState",&isExist);
244   if ( isExist ) {
245     if ( aVal.toInt() == VISU::Result::FULL )
246       aResStr = "F";
247     if ( aVal.toInt() == VISU::Result::MEDIUM )
248       aResStr = "M";
249     if ( aVal.toInt() == VISU::Result::LOW )
250       aResStr = "L";
251     if ( aVal.toInt() == VISU::Result::HIDDEN )
252       aResStr = "H";
253   }
254
255   return aResStr;
256 }
257
258
259 //---------------------------------------------------------------
260 QString VisuGUI_Selection::medEntity( const int ind ) const
261 {
262   SalomeApp_Study* aStudy = GetStudy();
263   if ( !aStudy )
264     return QString();
265
266   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1());
267   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
268
269   bool isExist;
270   QString aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist);
271   if ( isExist ) {
272     using namespace VISU;
273     TEntity anEntityId = TEntity(aVal.toInt());
274     switch(anEntityId){
275     case NODE_ENTITY :
276       return "NODE_ENTITY";
277     case EDGE_ENTITY :
278       return "EDGE_ENTITY";
279     case FACE_ENTITY :
280       return "FACE_ENTITY";
281     case CELL_ENTITY :
282       return "CELL_ENTITY";
283     default:
284       return QString();
285     }
286   }
287   return QString();
288 }
289
290 QString VisuGUI_Selection::medSource( const int ind ) const
291 {
292   _PTR(Study) aStudyDS = GetStudy()->studyDS();
293   if(_PTR(SObject) aSObject = aStudyDS->FindObjectID((const char*)entry(ind).toLatin1())){
294     VISU::Result_var aRes;
295     if(VISU::Result_i* aResult = CheckResult(myModule,aSObject,aRes)){
296       using namespace VISU;
297       Result_i::ECreationId aCreationId = aResult->GetCreationId();
298       switch(aCreationId){
299       case Result_i::eImportFile :
300         return "eImportFile";
301       case Result_i::eCopyAndImportFile :
302         return "eCopyAndImportFile";
303       case Result_i::eImportMed :
304         return "eImportMed";
305       case Result_i::eImportMedField :
306         return "eImportMedField";
307       default:
308         return QString();
309       }      
310     }
311   }
312   return QString();
313 }
314
315 QString VisuGUI_Selection::nbTimeStamps( const int ind ) const
316 {
317   QString aResStr;
318   SalomeApp_Study* aStudy = GetStudy();
319   if ( !aStudy )
320     return aResStr;
321
322   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, (const char*)entry( ind ).toLatin1());
323   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(anObjectInfo.mySObject);
324
325   bool isExist;
326   const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist);
327   if ( isExist )
328     aResStr = aVal;
329   return aResStr;
330 }
331
332
333 //----------------------------------------------------------------------------
334 template<class TPopupFunctor>
335 struct TPopupDispatcher
336 {
337   QString
338   operator()(const SalomeApp_Module* theModule, 
339              const QString& theEntry)
340   {
341     if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
342       QString aType = aViewManager->getType();
343       TPopupFunctor aFunctor;
344       if(aType == SVTK_Viewer::Type())
345         return aFunctor.template Get<SVTK_Viewer>(theModule, theEntry);
346       //else if(aType == VVTK_Viewer::Type())
347       //return aFunctor.template Get<VVTK_Viewer>(theModule, theEntry);
348     }
349     return QString();
350   }    
351 };
352
353
354 //----------------------------------------------------------------------------
355 template<class TViewer>
356 bool
357 GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
358                       const QString& theEntry,
359                       VISU::Prs3d_i*& thePrs3d,
360                       SVTK_ViewWindow*& theViewWindow,
361                       VISU_Actor*& thenActor)
362 {
363   VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), (const char*)theEntry.toLatin1());
364   thePrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
365   if(!thePrs3d)
366     return false;
367   
368   typedef typename TViewer::TViewWindow TViewWindow;
369   theViewWindow = GetActiveViewWindow<TViewWindow>(theModule);
370   if(!theViewWindow)
371     return false;
372   
373   thenActor = FindActor(theViewWindow, thePrs3d);
374   if(!thenActor)
375     return false;
376   
377   return true;
378 }
379
380
381 //----------------------------------------------------------------------------
382 struct TViewFunctor
383 {
384   template<class TViewer>
385   QString
386   Get(const SalomeApp_Module* theModule, 
387       const QString& theEntry)
388   {
389     VISU_Actor* anActor = NULL;
390     VISU::Prs3d_i* aPrs3d = NULL;
391     VISU_ActorBase* anActorBase = NULL;
392     VISU::PointMap3d_i* aPointMap3d = NULL;
393     SVTK_ViewWindow* aViewWindow = NULL;
394     if(GetPrs3dSelectionInfo<TViewer>(theModule, theEntry, aPrs3d, aViewWindow, anActor))
395       return get(aPrs3d, aViewWindow, anActor);
396     else {
397       aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
398       VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
399       if ( aSelectionInfo.empty() )
400         return QString();
401       VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
402       aPointMap3d = dynamic_cast<VISU::PointMap3d_i*>(aSelectionItem.myObjectInfo.myBase);
403       anActorBase = VISU::FindActorBase(aViewWindow, aPointMap3d);
404       return getPointMap(aPointMap3d, aViewWindow, anActorBase);
405     }
406   }
407   
408   QString
409   virtual
410   get(VISU::Prs3d_i* thePrs3d,
411       SVTK_ViewWindow* theViewWindow,
412       VISU_Actor* theActor)
413   {
414     return QString();
415   }
416
417   QString
418   virtual
419   getPointMap(VISU::PointMap3d_i* thePrs3d,
420               SVTK_ViewWindow* theViewWindow,
421               VISU_ActorBase* theActor)
422   {
423     return QString();
424   }
425 };
426
427
428 //----------------------------------------------------------------------------
429 struct TGetRepesentationFunctor: TViewFunctor
430 {
431   QString
432   virtual
433   get(VISU::Prs3d_i* thePrs3d,
434       SVTK_ViewWindow* theViewWindow,
435       VISU_Actor* theActor)
436   {
437     QString aResStr;
438     switch (theActor->GetRepresentation()) {
439       ENUM2STRING( aResStr, VISU::POINT );
440       ENUM2STRING( aResStr, VISU::WIREFRAME );
441       ENUM2STRING( aResStr, VISU::SHADED );
442       ENUM2STRING( aResStr, VISU::INSIDEFRAME );
443       ENUM2STRING( aResStr, VISU::SURFACEFRAME );
444       ENUM2STRING( aResStr, VISU::FEATURE_EDGES );
445     }
446     return aResStr;
447   }
448
449   QString
450   virtual
451   getPointMap(VISU::PointMap3d_i* thePrs3d,
452               SVTK_ViewWindow* theViewWindow,
453               VISU_ActorBase* theActorBase)
454   {
455     QString aResStr = "";
456     if (theActorBase) {
457       switch (theActorBase->GetRepresentation()) {
458         ENUM2STRING( aResStr, VISU::WIREFRAME ); // = 1
459         ENUM2STRING( aResStr, VISU::SHADED ); // = 2
460       }
461     }
462     return aResStr;
463   }
464 };
465
466 QString VisuGUI_Selection::representation( const int ind ) const
467 {
468   return TPopupDispatcher<TGetRepesentationFunctor>()(myModule, entry(ind));
469 }
470
471 //----------------------------------------------------------------------------
472 SalomeApp_Study* VisuGUI_Selection::GetStudy() const
473   
474 {
475   LightApp_Study* aLightStudy = const_cast<LightApp_Study*>( study() );
476   return dynamic_cast<SalomeApp_Study*>( aLightStudy );
477 }
478
479 //----------------------------------------------------------------------------
480 int VisuGUI_Selection::nbChild( const int ind, const bool named ) const
481 {
482   int cnt = 0;
483   SalomeApp_Study* aSStudy = GetStudy();
484   if ( !aSStudy )
485     return cnt;
486   _PTR(Study) aStudy =  GetCStudy( aSStudy );
487   if ( aStudy ){
488     _PTR(SObject) SO = aStudy->FindObjectID( (const char*)entry( ind ).toLatin1() );
489     if ( SO ){
490       for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) {
491         _PTR(SObject) refSO;
492         if ( !Iter->Value()->ReferencedObject( refSO ) && ( !named || Iter->Value()->GetName().size() ) )
493           cnt++;
494       }
495     }
496   }
497   return cnt;
498 }
499
500 //----------------------------------------------------------------------------
501 int VisuGUI_Selection::nbChildren( const int ind ) const
502 {
503   return nbChild( ind, false );
504 }
505
506 //----------------------------------------------------------------------------
507 int VisuGUI_Selection::nbNamedChildren( const int ind ) const
508 {
509   return nbChild( ind, true );
510 }
511
512
513 //----------------------------------------------------------------------------
514 struct TIsVisibleFunctor: TViewFunctor
515 {
516   QString
517   virtual
518   get(VISU::Prs3d_i* thePrs3d,
519       SVTK_ViewWindow* theViewWindow,
520       VISU_Actor* theActor)
521   {
522     return theActor->GetVisibility() ? "true" : "false";
523   }
524 };
525
526 QString VisuGUI_Selection::isVisible( const int ind ) const
527 {
528   return TPopupDispatcher<TIsVisibleFunctor>()(myModule, entry(ind));
529 }
530
531
532 //----------------------------------------------------------------------------
533 struct TIsShrunkFunctor: TViewFunctor
534 {
535   QString
536   virtual
537   get(VISU::Prs3d_i* thePrs3d,
538       SVTK_ViewWindow* theViewWindow,
539       VISU_Actor* theActor)
540   {
541     return theActor->IsShrunk() ? "1" : "0";
542   }
543
544   QString
545   virtual
546   getPointMap(VISU::PointMap3d_i* thePointMap,
547               SVTK_ViewWindow* theViewWindow,
548               VISU_ActorBase* theActorBase)
549   {
550     if (theActorBase)
551       return theActorBase->IsShrunk() ? "1" : "0";
552     else return "0";
553   }
554 };
555
556 QString VisuGUI_Selection::isShrunk( const int ind ) const
557 {
558   return TPopupDispatcher<TIsShrunkFunctor>()(myModule, entry(ind));
559 }
560
561
562 //----------------------------------------------------------------------------
563 bool VisuGUI_Selection::hasActor( const int ind ) const
564 {
565   return !representation( ind ).isEmpty();
566 }
567
568
569 //----------------------------------------------------------------------------
570 struct TIsShadingFunctor: TViewFunctor
571 {
572   QString
573   virtual
574   get(VISU::Prs3d_i* thePrs3d,
575       SVTK_ViewWindow* theViewWindow,
576       VISU_Actor* theActor)
577   {
578     if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor))
579       return anActor->IsShading() ? "1" : "0";
580     return QString();
581   }
582 };
583
584 QString VisuGUI_Selection::isShading( const int ind ) const
585 {
586   return TPopupDispatcher<TIsShadingFunctor>()(myModule, entry(ind));
587 }
588
589
590 //----------------------------------------------------------------------------
591 struct TIsScalarMapActFunctor: TViewFunctor
592 {
593   QString
594   virtual
595   get(VISU::Prs3d_i* thePrs3d,
596       SVTK_ViewWindow* theViewWindow,
597       VISU_Actor* theActor)
598   {
599     return dynamic_cast<VISU_ScalarMapAct*>(theActor)? "1" : "0";
600   }
601 };
602
603
604 //---------------------------------------------------------------
605 QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
606 {
607   return TPopupDispatcher<TIsScalarMapActFunctor>()(myModule, entry(ind));
608 }
609
610
611 //----------------------------------------------------------------------------
612 bool VisuGUI_Selection::isVisuComponent( const int ind ) const
613 {
614   SalomeApp_Study* study = GetStudy();
615   if ( !study )
616     return false;
617   
618   _PTR(SObject) obj = study->studyDS()->FindObjectID( (const char*)entry( ind ).toLatin1() );
619   if ( !obj )
620     return false;
621   CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj );
622   if( CORBA::is_nil( anObj ) )
623     return false;
624
625   return dynamic_cast<VISU::VISU_Gen_i*>( VISU::GetServant( anObj ).in() );
626 }
627
628 //---------------------------------------------------------------------------
629 bool VisuGUI_Selection::findDisplayedCurves( const int ind, bool findHidden ) const
630 {
631   // findHidden == false - find at least one Visible curve in the childs of ind
632   // findHidden == true - find at least one Hidden curve in the childs of ind
633   SalomeApp_Study* aSStudy = GetStudy();
634   if ( !aSStudy )
635     return false;
636
637   QString entryId;
638   _PTR(Study) aStudy = GetCStudy( aSStudy );
639   if ( aStudy ){
640     _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() );
641     if ( SO ){
642       for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) {
643         _PTR(SObject) refSO;
644         if ( Iter->Value()->ReferencedObject(refSO) )
645           entryId = refSO->GetID().c_str();
646         else
647           entryId = Iter->Value()->GetID().c_str();
648
649         LightApp_Displayer* displayer = LightApp_Displayer::FindDisplayer( myModule->moduleName(), false );
650         if ( displayer->IsDisplayed( entryId ) && findHidden == false )
651           return true;
652         else if ( !displayer->IsDisplayed( entryId ) && findHidden == true )
653           return true;
654       }
655     }
656   }
657   return false;
658 }
659
660 //---------------------------------------------------------------------------
661 bool VisuGUI_Selection::hasCurves( const int ind ) const
662 {
663   SalomeApp_Study* aSStudy = GetStudy();
664   if ( !aSStudy )
665     return false;
666
667   QString entryId;
668   _PTR(Study) aStudy = GetCStudy( aSStudy );
669   if ( aStudy ){
670     _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() );
671     if ( SO ){
672       for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) {
673         _PTR(SObject) refSO;
674         if ( Iter->Value()->ReferencedObject(refSO) ) {
675           // reference on curve
676         }
677         else
678           refSO = Iter->Value();
679
680         CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(refSO);
681         if(!CORBA::is_nil(aCORBAObject)){
682           PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
683           if(dynamic_cast<VISU::Curve_i*>(aServant.in()))
684             return true;
685         }
686       }
687     }
688   }
689   return false;
690 }
691
692 //---------------------------------------------------------------------------
693 bool VisuGUI_Selection::Plot2dViewerType( const int ind ) const
694 {
695   QString viewerType;
696   SUIT_Session* session = SUIT_Session::session();
697   if(  SUIT_Application* app = session->activeApplication() )
698     if( LightApp_Application* sApp = dynamic_cast<LightApp_Application*>( app ) )
699       if( SUIT_ViewManager* vman = sApp->activeViewManager() )
700         if( SUIT_ViewModel* vmod = vman->getViewModel() ) {
701           viewerType = vmod->getType();
702           if (viewerType ==SPlot2d_Viewer::Type())
703             return true;
704         }
705   return false;
706 }
707
708 //----------------------------------------------------------------------------
709 struct TIsValuesLabeled : TViewFunctor
710 {
711   QString
712   virtual
713   get(VISU::Prs3d_i* thePrs3d,
714       SVTK_ViewWindow* theViewWindow,
715       VISU_Actor* theActor)
716   {
717     return theActor && theActor->GetValuesLabeled() ? "true" : "false";
718   }
719 };
720
721 QString VisuGUI_Selection::isValuesLabeled( const int ind ) const
722 {
723   return TPopupDispatcher<TIsValuesLabeled>()(myModule, entry(ind));
724 }
725
726 //----------------------------------------------------------------------------
727 struct TIsScalarBarVisibleFunctor: TViewFunctor
728 {
729   QString
730   virtual
731   get(VISU::Prs3d_i* thePrs3d,
732       SVTK_ViewWindow* theViewWindow,
733       VISU_Actor* theActor)
734   {
735     if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor))
736       return anActor->GetBarVisibility() ? "true" : "false";
737     return QString();
738   }
739 };
740
741 bool VisuGUI_Selection::isScalarBarVisible( const int ind ) const
742 {
743   return TPopupDispatcher<TIsScalarBarVisibleFunctor>()(myModule, entry(ind)) == "true";
744 }