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