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