Salome HOME
Still an error on ZLayers related to edit CalculationCase The call to createViewManag...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_OCCDisplayer.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_OCCDisplayer.h"
20
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_Module.h"
23 #include "HYDROGUI_Tool2.h"
24 #include <HYDROGUI_ShapeImage.h>
25 #include <HYDROGUI_ShapeBathymetry.h>
26 #include <HYDROGUI_ShapeLandCoverMap.h>
27 #include "HYDROGUI_Operation.h"
28 #include "HYDROGUI_DataObject.h"
29 #include "HYDROGUI_ZLayers.h"
30 #include "HYDROGUI_Polyline.h"
31
32 #include <HYDROData_Bathymetry.h>
33 #include <HYDROData_Image.h>
34 #include <HYDROData_LandCoverMap.h>
35 #include <HYDROData_StricklerTable.h>
36
37 #include <AIS_InteractiveContext.hxx>
38 #include <AIS_ListIteratorOfListOfInteractive.hxx>
39 #include <AIS_ListOfInteractive.hxx>
40 #include <AIS_ColorScale.hxx>
41
42 #include <TColStd_SequenceOfInteger.hxx>
43
44 #include <LightApp_Application.h>
45 #include <SUIT_Study.h>
46
47 #include <OCCViewer_ViewManager.h>
48 #include <OCCViewer_ViewModel.h>
49 #include <OCCViewer_ViewWindow.h>
50 #include <OCCViewer_ViewPort3d.h>
51
52 //#define _DEVDEBUG_
53 #include "HYDRO_trace.hxx"
54
55 HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
56 : HYDROGUI_AbstractDisplayer( theModule )
57 {
58   DEBTRACE("HYDROGUI_OCCDisplayer");
59   myToUpdateColorScale = false;
60 }
61
62 HYDROGUI_OCCDisplayer::~HYDROGUI_OCCDisplayer()
63 {
64 }
65
66 void HYDROGUI_OCCDisplayer::SetToUpdate( const HYDROData_SequenceOfObjects& theObjs,
67                                          const size_t                       theViewerId )
68 {
69   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
70   if( !aViewer )
71     return;
72
73   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
74   {
75     Handle(HYDROData_Entity) anObj = theObjs.Value( i );
76     if( anObj.IsNull() )
77       continue;
78
79     HYDROGUI_Shape* anObjShape = module()->getObjectShape( (size_t)aViewer, anObj );
80     if ( !anObjShape )
81       continue;
82     
83     anObjShape->setIsToUpdate( true );
84   }
85 }
86
87 int HYDROGUI_OCCDisplayer::AddPreviewZLayer( OCCViewer_ViewManager* theMgr )
88 {
89   DEBTRACE("AddPreviewZLayer");
90   int aLayer = -1;
91   OCCViewer_Viewer* aViewer = theMgr->getOCCViewer();
92   if ( !aViewer )
93     return aLayer;
94
95   aLayer = CreateTopZLayer( aViewer->getViewer3d() );
96   
97   // Hilight presentation should be on top
98   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
99   if( !aCtx.IsNull() ) {
100     int aTopLayer = CreateTopZLayer( aViewer->getViewer3d() );
101     if ( aTopLayer > 0 ) {
102       UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, aTopLayer );
103     }
104   }
105
106   return aLayer;
107 }
108
109 void HYDROGUI_OCCDisplayer::RemoveZLayer( OCCViewer_ViewManager* theMgr,
110                                           const int theLayer,
111                                           bool isClearAll)
112 {
113   DEBTRACE("RemoveZLayer " << theLayer << " " << isClearAll);
114   if ( theLayer < 0 )
115     return;
116
117   if ( !theMgr )
118     return;
119
120   OCCViewer_Viewer* aViewer = theMgr->getOCCViewer();
121   if ( !aViewer )
122     return;
123
124   // Get existing Z layers
125   TColStd_SequenceOfInteger anExistingZLayers;
126   aViewer->getViewer3d()->GetAllZLayers( anExistingZLayers );
127   int aNbLayers = anExistingZLayers.Length();
128   
129   if (isClearAll)
130     {
131       for ( int i = 1; i <= aNbLayers; i++ )
132         {
133           int val = anExistingZLayers.Value( i );
134           if (val > 0)
135             aViewer->getViewer3d()->RemoveZLayer( val, true );
136         }
137     }
138   else
139     if ( theLayer < aNbLayers )
140       aViewer->getViewer3d()->RemoveZLayer( theLayer );
141 }
142
143 void HYDROGUI_OCCDisplayer::EraseAll( const size_t theViewerId )
144 {
145   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
146   if( !aViewer )
147     return;
148
149   module()->removeViewShapes( (size_t)aViewer );
150   UpdateColorScale( aViewer );
151 }
152
153 void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
154                                    const size_t                       theViewerId )
155 {
156   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
157   if( !aViewer )
158     return;
159
160   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
161   {
162     Handle(HYDROData_Entity) anObj = theObjs.Value( i );
163     if( anObj.IsNull() )
164       continue;
165
166     module()->removeObjectShape( (size_t)aViewer, anObj );
167   }
168   aViewer->update();
169   if ( !module()->isLandCoversScalarMapModeOn( (size_t)aViewer ) ) {
170     UpdateColorScale( aViewer );
171   }
172 }
173
174 HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const size_t                          theViewerId,
175                                                     const Handle(AIS_InteractiveContext)& theContext,
176                                                     const Handle(HYDROData_Entity)&       theObject )
177 {
178   DEBTRACE("createShape " << theViewerId);
179   HYDROGUI_Shape* aResShape = NULL;
180   if ( theContext.IsNull() || theObject.IsNull() )
181     return aResShape;
182
183   if ( !HYDROGUI_Tool::IsObjectHasPresentation( theObject, OCCViewer_Viewer::Type() ) )
184     return aResShape;
185
186   if( theObject->IsKind( STANDARD_TYPE( HYDROData_Image ) ) )
187     aResShape = new HYDROGUI_ShapeImage( theContext, Handle(HYDROData_Image)::DownCast( theObject ) );
188   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) )
189     aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle(HYDROData_Bathymetry)::DownCast( theObject ) );
190   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCoverMap ) ) ) {
191     bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId );
192     aResShape = new HYDROGUI_ShapeLandCoverMap( this, theContext, Handle(HYDROData_LandCoverMap)::DownCast( theObject ), -1, isScalarMode );
193   }
194   else
195     aResShape = new HYDROGUI_Shape( theContext, theObject );
196
197   module()->setObjectShape( theViewerId, theObject, aResShape );
198
199   return aResShape;
200 }
201
202 void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
203                                      const size_t                       theViewerId,
204                                      const bool                         theIsForced,
205                                      const bool theDoFitAll )
206 {
207   // Get OCC viewer by id
208   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
209   if( !aViewer )
210     return;
211
212   // Get interactive context
213   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
214   if( aCtx.IsNull() )
215     return;
216
217   // Get the document
218   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
219   if ( !aDoc )
220     return;
221   
222   // Assign Z layer indexes to the objects
223   aDoc->Show( theObjs );
224
225   // Sort objects by display order ( needed for Z layers assignment only )
226   HYDROData_SequenceOfObjects anUnorderedToDisplay = theObjs;
227   HYDROData_SequenceOfObjects anOrderedToDisplay;
228   HYDROData_SequenceOfObjects anAllOrderedObjects = aDoc->GetObjectsLayerOrder();
229
230   HYDROData_SequenceOfObjects::Iterator anAllOrderedIter( anAllOrderedObjects );
231   for ( ; anAllOrderedIter.More(); anAllOrderedIter.Next() ) {
232     QString anOrderedEntry = 
233       HYDROGUI_DataObject::dataObjectEntry( anAllOrderedIter.Value() );
234     
235     HYDROData_SequenceOfObjects::Iterator aToDisplayIter( anUnorderedToDisplay );
236     for ( ; aToDisplayIter.More(); aToDisplayIter.Next() ) {
237       Handle(HYDROData_Entity) anObjToDisplay = aToDisplayIter.Value();
238       QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObjToDisplay );
239       if ( anEntry == anOrderedEntry ) {
240         anOrderedToDisplay.Prepend( anObjToDisplay );
241         anUnorderedToDisplay.Remove( aToDisplayIter );
242         break;
243       }
244     }
245   }
246   
247   // Get 3d viewer
248   Handle(V3d_Viewer) aViewer3d = aViewer->getViewer3d();
249
250   // Display objects:
251   HYDROGUI_ZLayersIterator aZLayersIt( aViewer->getViewer3d() );
252   if ( !aZLayersIt.More() ) {
253     aZLayersIt.Next();
254   }
255
256   // 1. Display the ordered objects:
257   HYDROData_SequenceOfObjects::Iterator anOrderedIter( anOrderedToDisplay );
258   for ( ; anOrderedIter.More(); anOrderedIter.Next() ) {
259     Handle(HYDROData_Entity) anObj = anOrderedIter.Value();
260     if ( Display( anObj, aViewer, theIsForced ) ) {
261       // set Z layer ( one Z layer for each ordered object )
262       int aZLayerId = aZLayersIt.LayerId();
263       SetZLayer( aViewer, anObj, aZLayerId );
264       SetZLayerSettings( aViewer3d, aZLayerId, true );
265       aZLayersIt.Next();
266     }
267   }
268
269   // 2. Display the unordered objects:
270   bool isDisplayed = false;
271   int anUnorderedZLayerId = aZLayersIt.LayerId();
272   HYDROData_SequenceOfObjects::Iterator anUnorderedIter( anUnorderedToDisplay );
273   for ( ; anUnorderedIter.More(); anUnorderedIter.Next() ) {
274     Handle(HYDROData_Entity) anObj = anUnorderedIter.Value();
275     if ( Display( anObj, aViewer, theIsForced) ) {
276       // set Z layer ( one Z layer for all unordered objects )
277       SetZLayer( aViewer, anObj, anUnorderedZLayerId );
278       if ( !isDisplayed ) {
279         SetZLayerSettings( aViewer3d, anUnorderedZLayerId, false );
280       }
281       isDisplayed = true;
282     }
283   }
284   
285   // 3. Update the top Z layer index
286   if ( isDisplayed ) {
287     aZLayersIt.Next();
288   }
289
290   // Update Z layer of the active operation
291   int aPreviewZLayerId = aZLayersIt.LayerId();
292
293   HYDROGUI_Module* aModule = module();
294   SUIT_Operation* anOp = aModule->activeOperation();
295   HYDROGUI_Operation* aHOp = anOp ? dynamic_cast<HYDROGUI_Operation*>( anOp ) : 0;
296   if ( aHOp && aHOp->getPreviewZLayer() >= 0 ) {
297     aHOp->updatePreviewZLayer( aPreviewZLayerId );
298     aZLayersIt.Next();
299   }
300
301   // Update Z layer of hilight presentations
302   int aHilightLayer = aZLayersIt.TopLayer();
303   UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, aHilightLayer );
304
305   // Fit all / update selection
306   if ( theDoFitAll ) {
307     OCCViewer_ViewManager* aViewManager
308       = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
309     if ( aViewManager ) {
310       OCCViewer_ViewWindow* aViewWindow = 
311         ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
312       if ( aViewWindow ) {
313         aViewWindow->onFitAll();
314       }
315     }
316   } 
317   else if ( !aCtx.IsNull() ) { // TODO: determine if this code is necessary (added as a fix for issue# 359)
318     aCtx->UpdateSelected(true);
319   }
320
321   UpdateColorScale( aViewer );
322 }
323
324 void HYDROGUI_OCCDisplayer::purgeObjects( const size_t theViewerId )
325 {
326   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
327   if( !aViewer )
328     return;
329
330   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
331   if( aCtx.IsNull() )
332     return;
333
334   AIS_ListOfInteractive aDisplayedObjects;
335   aCtx->DisplayedObjects( aDisplayedObjects );
336
337   AIS_ListIteratorOfListOfInteractive aListIter( aDisplayedObjects );
338   for ( ; aListIter.More(); aListIter.Next() )
339   {
340     Handle(AIS_InteractiveObject) aPrsObj = aListIter.Value();
341     if ( aPrsObj.IsNull() )
342       continue;
343
344     Handle(HYDROData_Entity) anOwnerObj = 
345       Handle(HYDROData_Entity)::DownCast( aPrsObj->GetOwner() );
346     if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
347       module()->removeObjectShape( (size_t)aViewer, anOwnerObj );
348   }
349   UpdateColorScale( aViewer );
350 }
351
352 QString HYDROGUI_OCCDisplayer::GetType() const
353 {
354   return OCCViewer_Viewer::Type();
355 }
356
357 bool HYDROGUI_OCCDisplayer::Display( const Handle(HYDROData_Entity)& theObject,
358                                      const OCCViewer_Viewer* theViewer,
359                                      const bool theIsForced )
360 {
361   DEBTRACE("Display");
362   bool aRes = false;
363
364   if ( theObject.IsNull() || theObject->IsRemoved() || !theViewer ) {
365     return aRes;
366   }
367
368   // Get interactive context
369   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
370   if( aCtx.IsNull() ) {
371     return aRes;
372   }
373
374   // Viewer id
375   size_t aViewerId = (size_t)theViewer;
376
377   // Object shape 
378   HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
379   // create if needed
380   if ( !anObjShape ) {
381     anObjShape = createShape( aViewerId, aCtx, theObject );
382     if ( anObjShape ) {
383       anObjShape->setIsToUpdate( true );
384     }
385   }
386   
387   // Process the shape
388   if ( anObjShape ) {
389     // update if needed
390     if ( anObjShape->getIsToUpdate() || theIsForced ) {
391       anObjShape->update( false, false );
392     }
393
394     // Set visibility
395     bool anIsVisible = module()->isObjectVisible( aViewerId, theObject );
396     anObjShape->setVisible( anIsVisible, false );
397
398     aRes = true;
399   }
400
401   return aRes;
402 }
403
404 void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer,
405                                        const Handle(HYDROData_Entity)& theObject, 
406                                        const int theZLayerId )
407 {
408   if ( !theViewer /*|| ( theZLayerId < 0 )*/ ) {
409     return;
410   }
411   
412   // Get interactive context
413   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
414   if( aCtx.IsNull() ) {
415     return;
416   }
417
418   // Get viewer id
419   size_t aViewerId = (size_t)theViewer;
420
421   // Get object shape 
422   HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
423
424   // Set Z layer
425   if ( anObjShape )
426   {
427     QList<Handle(AIS_InteractiveObject)> shapes = anObjShape->getAISObjects();
428     foreach( Handle(AIS_InteractiveObject) shape, shapes )
429       aCtx->SetZLayer( shape, theZLayerId );
430   }
431 }
432
433 void HYDROGUI_OCCDisplayer::SetToUpdateColorScale()
434 {
435   myToUpdateColorScale = true;
436 }
437
438 void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer )
439 {
440   if( !myToUpdateColorScale || !theViewer )
441     return;
442   
443   OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
444   Handle(V3d_View) aView = aWnd->getViewPort()->getView();
445       
446
447   HYDROGUI_Module* aModule = module();
448   size_t aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
449   bool isLandCoverColoringOn = aModule->isLandCoversScalarMapModeOn( aViewerId );
450     
451   QList<HYDROGUI_Shape*> aLandCoverMapShapes = aModule->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP );
452   QList<HYDROGUI_Shape*> aBathShapes = aModule->getObjectShapes( aViewerId, KIND_BATHYMETRY );
453
454   bool isDisplayColorScale = false;
455   foreach (HYDROGUI_Shape* shape, aLandCoverMapShapes)
456   {
457     if (aModule->isObjectVisible(aViewerId, shape->getObject()))
458     {
459       isDisplayColorScale = true;
460       break;
461     }
462   }
463   if (!isDisplayColorScale)
464     foreach (HYDROGUI_Shape* shape, aBathShapes)
465     {
466       if (aModule->isObjectVisible(aViewerId, shape->getObject()))
467       {
468         isDisplayColorScale = true;
469         break;
470       }
471     }
472   
473   Standard_Real aColorScaleMin = 0, aColorScaleMax = 1;
474
475   // Get range
476   Handle(HYDROData_StricklerTable) aTable;
477   QStringList aTableTypes;
478   if ( isLandCoverColoringOn ) {
479     aTable = module()->getLandCoverColoringTable( aViewerId );
480     if ( !aTable.IsNull() ) {
481       // TODO: non-empty title leads to buggy behaviour
482       // aColorScaleTitle = TCollection_ExtendedString( aTable->GetName().toLatin1().constData() );
483       aTable->GetCoefficientRange( aColorScaleMin, aColorScaleMax );
484       aTableTypes = aTable->GetTypes();
485     }
486   } else {
487     Standard_Real aMin, aMax;
488     bool isFirst = true;
489     foreach( HYDROGUI_Shape* aShape, aBathShapes )
490     {
491       HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
492       if( !aBathShape || !aBathShape->isVisible() )
493         continue;
494
495       aBathShape->GetRange( aMin, aMax );
496
497       if( isFirst || aMin < aColorScaleMin )
498         aColorScaleMin = aMin;
499       if( isFirst || aMax > aColorScaleMax )
500         aColorScaleMax = aMax;
501
502       isFirst = false;
503     }
504   }
505
506   Handle(AIS_ColorScale) aColorScale = GetColorScale( aViewerId );
507   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
508   if( isDisplayColorScale )
509   {
510     if( !aColorScale.IsNull() )
511     {
512       // Set color scale title
513       TCollection_ExtendedString aColorScaleTitle = ""; //TODO
514       aColorScale->SetTitle( aColorScaleTitle );
515       
516       // Set color scale range
517       aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
518       
519       aColorScale->SetToUpdate();
520
521       if ( !isLandCoverColoringOn ) {
522         foreach( HYDROGUI_Shape* aShape, aBathShapes ) {
523           HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
524           if( !aBathShape || !aBathShape->isVisible() )
525             continue;
526
527           aBathShape->UpdateWithColorScale( aColorScale );
528         }
529       }
530       
531       if ( !aCtx.IsNull()/* && !aCtx->IsDisplayed( aColorScale ) */) {
532         if ( !aCtx->IsDisplayed( aColorScale ) ) {
533           aCtx->Display( aColorScale, Standard_False );
534         }
535
536         aCtx->Update( aColorScale, true );
537       }
538     }
539   }
540   else
541   {
542     if ( !aCtx.IsNull() && aCtx->IsDisplayed( aColorScale ) ) {
543       aCtx->Erase( aColorScale, true );
544     }
545   }
546
547   foreach( HYDROGUI_Shape* aShape, aLandCoverMapShapes ) {
548     HYDROGUI_ShapeLandCoverMap* aLandCoverMapShape = 
549       dynamic_cast<HYDROGUI_ShapeLandCoverMap*>( aShape );
550
551     if ( !aLandCoverMapShape || !aLandCoverMapShape->isVisible() ) {
552       continue;
553     }
554     
555     Handle(HYDROData_LandCoverMap) aLandCoverMap = 
556       Handle(HYDROData_LandCoverMap)::DownCast( aLandCoverMapShape->getObject() );
557
558     if ( aLandCoverMap.IsNull() ) {
559       continue;
560     }
561     
562     bool isScalarMode = aLandCoverMapShape->isScalarMapModeEnabled();
563     if( isScalarMode != isLandCoverColoringOn )
564     {
565       aLandCoverMapShape->setScalarMapModeEnabled( isLandCoverColoringOn );
566       theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObjects()[0], Standard_False );
567     }
568   }
569   
570   myToUpdateColorScale = false;
571 }
572
573 Handle(AIS_ColorScale) HYDROGUI_OCCDisplayer::GetColorScale( const size_t theViewerId )
574 {
575   Handle(AIS_ColorScale) aColorScale;
576
577   aColorScale = myColorScales.value( theViewerId, aColorScale );
578   if ( aColorScale.IsNull() ) {
579     // Create color scale
580     aColorScale = new AIS_ColorScale();
581
582     // Set properties
583     Standard_Integer anXPos = 50; //TODO
584     Standard_Integer anYPos = 100; //TODO
585     Standard_Integer aWidth = 100; //TODO
586     Standard_Integer aHeight = 350; //TODO
587     
588     Standard_Integer aTextHeight = 14; //TODO
589     Standard_Integer aNbIntervals = 20; //TODO
590
591     aColorScale->SetTransformPersistence( Graphic3d_TMF_2d, gp_Pnt( -1, -1, 0 ) );
592     
593     aColorScale->SetXPosition( anXPos );
594     aColorScale->SetYPosition( anYPos );
595     aColorScale->SetSize( aWidth, aHeight );
596
597     aColorScale->SetTextHeight( aTextHeight );
598     aColorScale->SetNumberOfIntervals( aNbIntervals );
599
600     // Put into the map
601     myColorScales.insert( theViewerId, aColorScale );
602   }
603
604   return aColorScale;
605 }
606
607 void HYDROGUI_OCCDisplayer::UpdatePolylines( size_t theViewerId, int theType, int theSize )
608 {
609   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
610   if( !aViewer )
611     return;
612
613   // Get interactive context
614   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
615   if( aCtx.IsNull() )
616     return;
617
618   AIS_ListOfInteractive objs;
619   aCtx->DisplayedObjects( objs );
620   AIS_ListOfInteractive::const_iterator it = objs.begin(), last = objs.end();
621   for( ; it!=last; it++ )
622   {
623     Handle(HYDROGUI_Arrow) arr = Handle(HYDROGUI_Arrow)::DownCast( *it );
624     if( !arr.IsNull() )
625     {
626       if( theType>=0 )
627         arr->SetType( (HYDROGUI_Arrow::Type)theType );
628       if( theSize>=0 )
629         arr->SetSize( theSize );
630       aCtx->Redisplay( arr, Standard_False );
631     }
632   }
633   aCtx->UpdateCurrentViewer();
634 }