]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_Tools.cxx
Salome HOME
SMH: 3.0.0 preparation - merged and adopted version (POLYWORK+HEAD)
[modules/visu.git] / src / VISUGUI / VisuGUI_Tools.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2005  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : VisuGUI_Tools.cxx
25 //  Author : Sergey Anikin
26 //  Module : VISU
27
28
29 #include "VisuGUI_Tools.h"
30
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Result_i.hh"
34 #include "VISU_Table_i.hh"
35 #include "VISU_ViewManager_i.hh"
36 #include "VISU_Actor.h"
37
38 #include "SalomeApp_Module.h"
39 #include "SalomeApp_Study.h"
40 #include "SalomeApp_Application.h"
41 #include "SalomeApp_SelectionMgr.h"
42
43 #include "SALOME_ListIO.hxx"
44 #include "SALOME_ListIteratorOfListIO.hxx"
45
46 #include "SVTK_ViewWindow.h"
47 #include "SVTK_ViewModel.h"
48 #include "SVTK_Functor.h"
49
50 #include "VTKViewer_Algorithm.h"
51
52 #include "SPlot2d_ViewModel.h"
53 #include "Plot2d_ViewFrame.h"
54
55 #include "SUIT_Session.h"
56 #include "SUIT_MessageBox.h"
57
58 #include <vtkRenderer.h>
59 #include <vtkActorCollection.h>
60
61
62 //=============================================================================
63 namespace VISU
64 {
65   SUIT_Desktop*
66   GetDesktop(const CAM_Module* theModule)
67   {
68     return theModule->application()->desktop();
69   }
70
71   SalomeApp_SelectionMgr*
72   GetSelectionMgr(const SalomeApp_Module* theModule)
73   {
74     return theModule->getApp()->selectionMgr();
75   }
76
77   SalomeApp_Study*
78   GetAppStudy(const CAM_Module* theModule)
79   {
80     return
81       dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
82   }
83
84   _PTR(Study)
85   GetCStudy(const SalomeApp_Study* theStudy)
86   {
87     return theStudy->studyDS();
88   }
89
90   SALOMEDS::StudyManager_var
91   GetStudyManager()
92   {
93     static SALOMEDS::StudyManager_var aStudyManager;
94     if(CORBA::is_nil(aStudyManager)){
95       SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
96       CORBA::Object_var anObject = aNamingService->Resolve("/myStudyManager");
97       aStudyManager = SALOMEDS::StudyManager::_narrow(anObject);
98     }
99     return aStudyManager;
100   }
101
102   bool
103   IsStudyLocked(const SALOMEDS::Study_var& theStudy)
104   {
105     if(!CORBA::is_nil(theStudy))
106       return theStudy->GetProperties()->IsLocked();
107     return true;
108   }
109
110   bool
111   CheckLock(const SALOMEDS::Study_var& theStudy,
112             const CAM_Module* theModule)
113   {
114     if(IsStudyLocked(theStudy))
115       throw std::runtime_error(QObject::tr("WRN_STUDY_LOCKED").latin1());
116     return false;
117   }
118
119   VISU_Gen_i*
120   GetVisuGen(const CAM_Module* theModule)
121   {
122     static VISU_Gen_i* aGen = NULL;
123     if(!aGen){
124       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
125       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
126       VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
127       if(!CORBA::is_nil(aVISU)){
128         aGen = VISU_Gen_i::GetVisuGenImpl();
129         aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
130       }
131     }
132     if(!aGen)
133       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").latin1());
134     return aGen;
135   }
136
137   SALOME_MED::MED_Gen_var
138   GetMEDEngine()
139   {
140     static SALOME_MED::MED_Gen_var aGen;
141     if(CORBA::is_nil(aGen)){
142       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
143       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
144       aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
145     }
146     if(CORBA::is_nil(aGen))
147       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").latin1());
148     return aGen;
149   }
150
151   CORBA::Object_var
152   GetSelectedObj(const SalomeApp_Study* theStudy,
153                  const QString& theEntry,
154                  VISU::Storable::TRestoringMap* theMap)
155   {
156     if ( !theStudy || theEntry.isEmpty() )
157       return CORBA::Object::_nil();
158
159     SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy( theStudy ));
160     SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( theEntry.latin1() );
161     if(!aSObject->_is_nil()){
162       SALOMEDS::GenericAttribute_var anAttr;
163       if(theMap && aSObject->FindAttribute(anAttr,"AttributeComment")){
164         SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
165         std::string aValue = aComment->Value();
166         QString aString(aValue.c_str());
167         VISU::Storable::StrToMap(aString,*theMap);
168       }
169       return VISU::SObjectToObject(aSObject);
170     }
171     return CORBA::Object::_nil();
172   }
173
174   CORBA::Object_var
175   GetSelectedObj(const SalomeApp_Module* theModule,
176                  Handle(SALOME_InteractiveObject)* theIO,
177                  VISU::Storable::TRestoringMap* theMap)
178   {
179     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
180     SALOME_ListIO aListIO;
181     aSelectionMgr->selectedObjects(aListIO);
182     SALOME_ListIteratorOfListIO anIter(aListIO);
183     if(anIter.More()){
184       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
185       if(theIO)
186         *theIO = anIO;
187       if(anIO->hasEntry())
188         return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
189     }
190     return CORBA::Object::_nil();
191   }
192
193   VISU::Storable::TRestoringMap
194   getMapOfValue(SALOMEDS::SObject_var theSObject)
195   {
196     VISU::Storable::TRestoringMap aMap;
197     if(!theSObject->_is_nil()){
198       SALOMEDS::GenericAttribute_var anAttr;
199       if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
200         SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
201         CORBA::String_var aValue = aComment->Value();
202         QString aString(aValue.in());
203         VISU::Storable::StrToMap(aString,aMap);
204       }
205     }
206     return aMap;
207   }
208
209   QString
210   getValue(SALOMEDS::SObject_var theSObject,
211            QString theKey)
212   {
213     QString aStr("");
214     VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
215     if(!aMap.empty())
216       aStr = VISU::Storable::FindValue(aMap,theKey.latin1());
217     return aStr;
218   }
219
220   VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject)
221   {
222     VISU::Storable::TRestoringMap aMap;
223     if (theSObject) {
224       _PTR(GenericAttribute) anAttr;
225       if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
226         _PTR(AttributeComment) aComment (anAttr);
227         std::string aValue = aComment->Value();
228         QString aString (aValue.c_str());
229         VISU::Storable::StrToMap(aString, aMap);
230       }
231     }
232     return aMap;
233   }
234
235   QString getValue (_PTR(SObject) theSObject, QString theKey)
236   {
237     QString aStr("");
238     VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
239     if (!aMap.empty())
240       aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
241     return aStr;
242   }
243
244
245   bool
246   CheckTimeStamp(const SalomeApp_Module* theModule,
247                  SALOMEDS::SObject_var& theSObject,
248                  Handle(SALOME_InteractiveObject)* theIO)
249   {
250     Handle(SALOME_InteractiveObject) anIO;
251     CORBA::Object_var anObject = GetSelectedObj(theModule,&anIO);
252     if(theIO)
253       *theIO = anIO;
254     if(!anIO.IsNull() && anIO->hasEntry()){
255       SALOMEDS::Study_var aStudy = GetDSStudy(GetCStudy(GetAppStudy(theModule)));
256       theSObject = aStudy->FindObjectID(anIO->getEntry());
257       QString aValue = getValue(theSObject,"myType");
258       if(aValue.toInt() == int(VISU::TTIMESTAMP))
259         return true;
260     }
261     SUIT_MessageBox::warn1(GetDesktop(theModule),
262                            QObject::tr("VISU_WARNING"),
263                            QObject::tr("WRN_NO_AVAILABLE_DATA"),
264                            QObject::tr("VISU_BUT_OK") );
265     return false;
266   }
267
268
269   VISU::Result_i*
270   CheckResult(const SalomeApp_Module* theModule,
271               SALOMEDS::SObject_var theSource,
272               VISU::Result_var& theResult)
273   {
274     SALOMEDS::SObject_var aSObj;
275
276     aSObj = theSource->GetFather();
277     if (CORBA::is_nil(aSObj))
278       return NULL;
279
280     aSObj = aSObj->GetFather();
281     if (CORBA::is_nil(aSObj))
282       return NULL;
283
284     aSObj = aSObj->GetFather();
285     if (CORBA::is_nil(aSObj))
286       return NULL;
287
288     CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
289     if (CORBA::is_nil(anObject)) {
290       aSObj = aSObj->GetFather();
291       if (CORBA::is_nil(aSObj))
292         return NULL;
293       anObject = VISU::SObjectToObject(aSObj);
294     }
295
296     if (CORBA::is_nil(anObject))
297       return NULL;
298
299     theResult = VISU::Result::_narrow(anObject);
300     VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
301     if(pResult == NULL)
302       SUIT_MessageBox::warn1(GetDesktop(theModule),
303                              QObject::tr("VISU_WARNING"),
304                              QObject::tr("WRN_NO_AVAILABLE_DATA"),
305                              QObject::tr("VISU_BUT_OK"));
306     return pResult;
307   }
308
309   SVTK_ViewWindow*
310   GetViewWindow(const SalomeApp_Module* theModule)
311   {
312     if(SalomeApp_Application* anApp = theModule->getApp()){
313       if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), true )){
314         if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
315           return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
316         }
317       }
318     }
319     return NULL;
320   }
321
322   SVTK_ViewWindow*
323   GetViewWindow()
324   {
325     SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
326       (SUIT_Session::session()->activeApplication());
327     if (anApp) {
328       if (SUIT_ViewManager* aViewManager = anApp->activeViewManager()) {
329         if (aViewManager->getType() == SVTK_Viewer::Type()) {
330           if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
331             return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
332           }
333         }
334       }
335     }
336     return NULL;
337   }
338
339   TViewWindows
340   GetViews(const SalomeApp_Module* theModule)
341   {
342     TViewWindows aViewWindows;
343     if(SalomeApp_Application* anApp = theModule->getApp()){
344       ViewManagerList aViewManagerList;
345       anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
346       QPtrListIterator<SUIT_ViewManager> anIter(aViewManagerList);
347       while(SUIT_ViewManager* aViewManager = anIter.current()){
348         QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
349         for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
350           if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
351             if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
352               aViewWindows.push_back(aView);
353         }
354         ++anIter;
355       }
356     }
357     return aViewWindows;
358   }
359
360   VISU_Actor* 
361   PublishInView(const SalomeApp_Module* theModule,
362                 VISU::Prs3d_i* thePrs)
363   {
364     VISU_Actor* aActor = NULL;
365     if(!thePrs)
366       return aActor;
367     if(SVTK_ViewWindow* aView = GetViewWindow(theModule)){
368       QApplication::setOverrideCursor( Qt::waitCursor );
369       if(aActor = thePrs->CreateActor()){
370         aView->AddActor(aActor);
371       }
372       QApplication::restoreOverrideCursor();
373     }
374     return aActor;
375   }
376
377   VISU_Actor* 
378   UpdateViewer(const SalomeApp_Module* theModule,
379                VISU::Prs3d_i* thePrs, 
380                bool theDispOnly)
381   {
382     SVTK_ViewWindow* vw = GetViewWindow( theModule );
383     if (!vw) return NULL;
384
385     vtkRenderer *aRen = vw->getRenderer();
386     vtkActorCollection *anActColl = aRen->GetActors();
387
388     vtkActor *anActor;
389     VISU_Actor* anVISUActor = NULL;
390     VISU_Actor* aResActor = NULL;
391     for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
392       if(!SALOME_Actor::SafeDownCast(anActor))
393         continue;
394       if(anActor->IsA("VISU_Actor")){ 
395         anVISUActor = VISU_Actor::SafeDownCast(anActor);
396         VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();      
397         if(aPrs == NULL) continue;
398         if (thePrs == aPrs) {
399           aResActor = anVISUActor->GetParent();
400           thePrs->UpdateActor(aResActor);
401           aResActor->VisibilityOn();
402           
403         } else if (theDispOnly) {
404           anVISUActor->GetParent()->VisibilityOff();
405         } else {
406         }
407       } else if (theDispOnly && anActor->GetVisibility()) {
408         anActor->VisibilityOff();
409       } else {
410       } 
411     }
412     if (aResActor) 
413       return aResActor;
414
415     anVISUActor = PublishInView( theModule, thePrs );
416     return anVISUActor;
417   }
418
419   VISU_Actor*
420   FindActor(SVTK_ViewWindow* theViewWindow,
421             const char* theEntry)
422   {
423     using namespace VTK;
424     if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
425       if(vtkActorCollection* aCollection = aRenderer->GetActors()){
426         if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
427           return anActor->GetParent();
428         }
429       }
430     }
431     return NULL;
432   }
433
434   VISU_Actor*
435   FindActor(SVTK_ViewWindow* theViewWindow,
436             VISU::Prs3d_i* thePrs)
437   {
438     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
439     CORBA::String_var anEntry = aSObject->GetID();
440     return FindActor(theViewWindow,anEntry.in());
441   }
442
443   void
444   Add(SalomeApp_SelectionMgr* theSelectionMgr,
445       const Handle(SALOME_InteractiveObject)& theIO)
446   {
447     SALOME_ListIO aListIO;
448     theSelectionMgr->selectedObjects(aListIO);
449     aListIO.Append(theIO);
450     theSelectionMgr->setSelectedObjects(aListIO);
451   }
452
453   void
454   Remove(SalomeApp_SelectionMgr* theSelectionMgr,
455          const Handle(SALOME_InteractiveObject)& theIO)
456   {
457     SALOME_ListIO aListIO;
458     theSelectionMgr->selectedObjects(aListIO);
459     SALOME_ListIteratorOfListIO anIter(aListIO);
460     while(anIter.More()){
461       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
462       if(anIO->isSame(theIO)){
463         aListIO.Remove(anIter);
464       }
465       anIter.Next();
466     }
467     theSelectionMgr->setSelectedObjects(aListIO);
468   }
469
470   void
471   DeletePrs3d(SalomeApp_Module* theModule,
472               VISU::Prs3d_i* thePrs,
473               const Handle(SALOME_InteractiveObject)& theIO)
474   {
475     if(!thePrs)
476       return;
477     if(CheckLock(GetDSStudy(GetCStudy(GetAppStudy(theModule))),theModule))
478       return;
479     SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
480     CORBA::String_var anEntry = aSObject->GetID();
481     SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
482     Remove(aSelectionMgr,theIO);
483     TViewWindows aViewWindows = GetViews(theModule);
484     for(int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++){
485       SVTK_ViewWindow* aView = aViewWindows[i];
486       if(VISU_Actor* anActor = FindActor(aView,anEntry.in())){
487         aView->RemoveActor(anActor);
488         anActor->Delete();
489       }
490     }
491     thePrs->RemoveFromStudy();
492     theModule->updateObjBrowser(); //update Object browser
493   }
494
495   void
496   ErasePrs3d(SalomeApp_Module* theModule,
497              VISU::Prs3d_i* thePrs)
498   {
499     if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
500       VISU_Actor* anVISUActor = FindActor( vw, thePrs );
501       if (anVISUActor) {
502         anVISUActor->VisibilityOff();
503       }
504     }
505   }
506
507   SPlot2d_Viewer*
508   GetPlot2dViewer(const SalomeApp_Module* theModule)
509   {
510     if(SalomeApp_Application* anApp = theModule->getApp()){
511       if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), true )){
512         return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
513       }
514     }
515     return NULL;
516   }
517
518   // Internal function used by several public functions below
519   void
520   UpdateCurve(VISU::Curve_i* theCurve,
521               Plot2d_ViewFrame* aPlot,
522               SPlot2d_Curve* plotCurve,
523               int theDisplaying)
524   {
525     if ( theDisplaying == VISU::eErase ) {
526       if ( plotCurve )
527         aPlot->eraseCurve( plotCurve, false );
528     }
529     else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
530       if ( plotCurve ) {
531         plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
532         //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
533         plotCurve->setVerTitle( theCurve->GetName() );
534         plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
535         plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
536         double* xList = 0;
537         double* yList = 0;
538         int     nbPoints = theCurve->GetData( xList, yList );
539         if ( nbPoints > 0 && xList && yList ) {
540           plotCurve->setData( xList, yList, nbPoints );
541         }
542         if ( !theCurve->IsAuto() ) {
543           plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
544           plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); 
545           SALOMEDS::Color color = theCurve->GetColor();
546           plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
547         }
548         plotCurve->setAutoAssign( theCurve->IsAuto() );
549         aPlot->displayCurve( plotCurve, false );
550       }
551       else {
552         Plot2d_Curve* crv = theCurve->CreatePresentation();
553         if ( crv ) {
554           aPlot->displayCurve( crv, false );
555           theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
556           theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
557           SALOMEDS::Color newColor;
558           newColor.R = crv->getColor().red()/255.;
559           newColor.G = crv->getColor().green()/255.;
560           newColor.B = crv->getColor().blue()/255.;
561           theCurve->SetColor( newColor );
562           crv->setAutoAssign( theCurve->IsAuto() );
563         }
564       }
565     }
566   }
567
568   void                                 
569   PlotTable(const SalomeApp_Module* theModule, 
570             VISU::Table_i* table, 
571             int theDisplaying)
572   {
573     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule );
574     if ( !aView )
575       return;
576     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
577
578     if ( theDisplaying == VISU::eDisplayOnly ) 
579       aPlot->EraseAll();
580     QList<Plot2d_Curve> clist;
581     aPlot->getCurves( clist );
582     _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
583     _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
584     if ( TableSO ) {
585       _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
586       for ( ; Iter->More(); Iter->Next() ) {
587         CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
588         if( !CORBA::is_nil( childObject ) ) {
589           CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
590           if( !CORBA::is_nil( aCurve ) ) {
591             VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
592             SPlot2d_Curve* plotCurve = 0;
593             SPlot2d_Curve* tmpCurve;
594             for ( int i = 0; i < clist.count(); i++ ) {
595               tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
596               if ( tmpCurve && tmpCurve->hasIO() && !strcmp( tmpCurve->getIO()->getEntry(), theCurve->GetEntry() ) ) {
597                 plotCurve = tmpCurve;
598                 break;
599               }
600             }
601
602             UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
603
604             if ( theDisplaying == VISU::eErase && plotCurve ) {
605               clist.remove( plotCurve );
606             }
607           }
608         }
609       }
610       aPlot->Repaint();
611     }
612   }
613
614   void
615   PlotCurve(const SalomeApp_Module* theModule, 
616             VISU::Curve_i* theCurve, 
617             int theDisplaying)
618   {
619     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule );
620     if ( !aView )
621       return;
622     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
623 //  if ( theDisplaying == VISU::eDisplayOnly ) 
624 //    aPlot->EraseAll();
625     QList<Plot2d_Curve> clist;
626     aPlot->getCurves( clist );
627     SPlot2d_Curve* plotCurve = 0;
628     SPlot2d_Curve* tmpCurve;
629     for ( int i = 0; i < clist.count(); i++ ) {
630       tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
631       if ( tmpCurve && tmpCurve->hasIO() && !strcmp( tmpCurve->getIO()->getEntry(), theCurve->GetEntry() ) ) {
632         plotCurve = tmpCurve;
633       }
634       else if ( theDisplaying == VISU::eDisplayOnly ) {
635         aPlot->eraseCurve( clist.at( i ) );
636       }
637     }
638
639     UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
640
641     aPlot->Repaint();
642   }
643
644   void
645   PlotContainer(const SalomeApp_Module* theModule, 
646                 VISU::Container_i* container, 
647                 int theDisplaying)
648   {
649     SPlot2d_Viewer* aView = GetPlot2dViewer( theModule );
650     if ( !aView )
651       return;
652     Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
653     if ( theDisplaying == VISU::eDisplayOnly ) 
654       aPlot->EraseAll();
655     QList<Plot2d_Curve> clist;
656     aPlot->getCurves( clist );
657     if ( container->GetNbCurves() > 0 ) {
658       int nbCurves = container->GetNbCurves();
659       for ( int k = 1; k <= nbCurves; k++ ) {
660         VISU::Curve_i* theCurve = container->GetCurve( k );
661         if ( theCurve && theCurve->IsValid() ) {
662           SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>( aView->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) ) );
663           
664           UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
665
666           if ( plotCurve && theDisplaying == VISU::eErase ) {
667             clist.remove( plotCurve );
668           }
669         }
670       }
671     }
672     aPlot->Repaint();
673   }
674 }