Salome HOME
eaf609af5894fe874e3904b1dec143193d03c66c
[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   DEBTRACE("Erase " << theObjs.Length() << " " << theViewerId);
157   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
158   if( !aViewer )
159     return;
160
161   for ( int i = 1, n = theObjs.Length(); i <= n; i++ )
162   {
163     Handle(HYDROData_Entity) anObj = theObjs.Value( i );
164     if( anObj.IsNull() )
165       continue;
166     DEBTRACE("Erasing objects...");
167     module()->removeObjectShape( (size_t)aViewer, anObj );
168   }
169   aViewer->update();
170   if ( !module()->isLandCoversScalarMapModeOn( (size_t)aViewer ) ) {
171     UpdateColorScale( aViewer );
172   }
173 }
174
175 HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const size_t                          theViewerId,
176                                                     const Handle(AIS_InteractiveContext)& theContext,
177                                                     const Handle(HYDROData_Entity)&       theObject )
178 {
179   DEBTRACE("createShape " << theViewerId);
180   HYDROGUI_Shape* aResShape = NULL;
181   if ( theContext.IsNull() || theObject.IsNull() )
182     return aResShape;
183
184   if ( !HYDROGUI_Tool::IsObjectHasPresentation( theObject, OCCViewer_Viewer::Type() ) )
185     return aResShape;
186
187   if( theObject->IsKind( STANDARD_TYPE( HYDROData_Image ) ) )
188     aResShape = new HYDROGUI_ShapeImage( theContext, Handle(HYDROData_Image)::DownCast( theObject ) );
189   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_Bathymetry ) ) )
190     aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle(HYDROData_Bathymetry)::DownCast( theObject ) );
191   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCoverMap ) ) ) {
192     bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId );
193     aResShape = new HYDROGUI_ShapeLandCoverMap( this, theContext, Handle(HYDROData_LandCoverMap)::DownCast( theObject ), -1, isScalarMode );
194   }
195   else
196     aResShape = new HYDROGUI_Shape( theContext, theObject );
197
198   module()->setObjectShape( theViewerId, theObject, aResShape );
199
200   return aResShape;
201 }
202
203 void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs,
204                                      const size_t                       theViewerId,
205                                      const bool                         theIsForced,
206                                      const bool theDoFitAll )
207 {
208   // Get OCC viewer by id
209   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
210   if( !aViewer )
211     return;
212
213   // Get interactive context
214   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
215   if( aCtx.IsNull() )
216     return;
217
218   // Get the document
219   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
220   if ( !aDoc )
221     return;
222   
223   // Assign Z layer indexes to the objects
224   aDoc->Show( theObjs );
225
226   // Sort objects by display order ( needed for Z layers assignment only )
227   HYDROData_SequenceOfObjects anUnorderedToDisplay = theObjs;
228   HYDROData_SequenceOfObjects anOrderedToDisplay;
229   HYDROData_SequenceOfObjects anAllOrderedObjects = aDoc->GetObjectsLayerOrder();
230
231   HYDROData_SequenceOfObjects::Iterator anAllOrderedIter( anAllOrderedObjects );
232   for ( ; anAllOrderedIter.More(); anAllOrderedIter.Next() ) {
233     QString anOrderedEntry = 
234       HYDROGUI_DataObject::dataObjectEntry( anAllOrderedIter.Value() );
235     
236     HYDROData_SequenceOfObjects::Iterator aToDisplayIter( anUnorderedToDisplay );
237     for ( ; aToDisplayIter.More(); aToDisplayIter.Next() ) {
238       Handle(HYDROData_Entity) anObjToDisplay = aToDisplayIter.Value();
239       QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObjToDisplay );
240       if ( anEntry == anOrderedEntry ) {
241         anOrderedToDisplay.Prepend( anObjToDisplay );
242         anUnorderedToDisplay.Remove( aToDisplayIter );
243         break;
244       }
245     }
246   }
247   
248   // Get 3d viewer
249   Handle(V3d_Viewer) aViewer3d = aViewer->getViewer3d();
250
251   // Display objects:
252   HYDROGUI_ZLayersIterator aZLayersIt( aViewer->getViewer3d() );
253   if ( !aZLayersIt.More() ) {
254     aZLayersIt.Next();
255   }
256
257   // 1. Display the ordered objects:
258   HYDROData_SequenceOfObjects::Iterator anOrderedIter( anOrderedToDisplay );
259   for ( ; anOrderedIter.More(); anOrderedIter.Next() ) {
260     Handle(HYDROData_Entity) anObj = anOrderedIter.Value();
261     if ( Display( anObj, aViewer, theIsForced ) ) {
262       // set Z layer ( one Z layer for each ordered object )
263       int aZLayerId = aZLayersIt.LayerId();
264       SetZLayer( aViewer, anObj, aZLayerId );
265       SetZLayerSettings( aViewer3d, aZLayerId, true );
266       aZLayersIt.Next();
267     }
268   }
269
270   // 2. Display the unordered objects:
271   bool isDisplayed = false;
272   int anUnorderedZLayerId = aZLayersIt.LayerId();
273   HYDROData_SequenceOfObjects::Iterator anUnorderedIter( anUnorderedToDisplay );
274   for ( ; anUnorderedIter.More(); anUnorderedIter.Next() ) {
275     Handle(HYDROData_Entity) anObj = anUnorderedIter.Value();
276     if ( Display( anObj, aViewer, theIsForced) ) {
277       // set Z layer ( one Z layer for all unordered objects )
278       SetZLayer( aViewer, anObj, anUnorderedZLayerId );
279       if ( !isDisplayed ) {
280         SetZLayerSettings( aViewer3d, anUnorderedZLayerId, false );
281       }
282       isDisplayed = true;
283     }
284   }
285   
286   // 3. Update the top Z layer index
287   if ( isDisplayed ) {
288     aZLayersIt.Next();
289   }
290
291   // Update Z layer of the active operation
292   int aPreviewZLayerId = aZLayersIt.LayerId();
293
294   HYDROGUI_Module* aModule = module();
295   SUIT_Operation* anOp = aModule->activeOperation();
296   HYDROGUI_Operation* aHOp = anOp ? dynamic_cast<HYDROGUI_Operation*>( anOp ) : 0;
297   if ( aHOp && aHOp->getPreviewZLayer() >= 0 ) {
298     aHOp->updatePreviewZLayer( aPreviewZLayerId );
299     aZLayersIt.Next();
300   }
301
302   // Update Z layer of hilight presentations
303   int aHilightLayer = aZLayersIt.TopLayer();
304   UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, aHilightLayer );
305
306   // Fit all / update selection
307   if ( theDoFitAll ) {
308     OCCViewer_ViewManager* aViewManager
309       = ::qobject_cast<OCCViewer_ViewManager*>( aViewer->getViewManager() );
310     if ( aViewManager ) {
311       OCCViewer_ViewWindow* aViewWindow = 
312         ::qobject_cast<OCCViewer_ViewWindow*>( aViewManager->getActiveView() );
313       if ( aViewWindow ) {
314         aViewWindow->onFitAll();
315       }
316     }
317   } 
318   else if ( !aCtx.IsNull() ) { // TODO: determine if this code is necessary (added as a fix for issue# 359)
319     aCtx->UpdateSelected(true);
320   }
321
322   UpdateColorScale( aViewer );
323 }
324
325 void HYDROGUI_OCCDisplayer::purgeObjects( const size_t theViewerId )
326 {
327   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
328   if( !aViewer )
329     return;
330
331   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
332   if( aCtx.IsNull() )
333     return;
334
335   AIS_ListOfInteractive aDisplayedObjects;
336   aCtx->DisplayedObjects( aDisplayedObjects );
337
338   AIS_ListIteratorOfListOfInteractive aListIter( aDisplayedObjects );
339   for ( ; aListIter.More(); aListIter.Next() )
340   {
341     Handle(AIS_InteractiveObject) aPrsObj = aListIter.Value();
342     if ( aPrsObj.IsNull() )
343       continue;
344
345     Handle(HYDROData_Entity) anOwnerObj = 
346       Handle(HYDROData_Entity)::DownCast( aPrsObj->GetOwner() );
347     if ( !anOwnerObj.IsNull() && anOwnerObj->IsRemoved() )
348       module()->removeObjectShape( (size_t)aViewer, anOwnerObj );
349   }
350   UpdateColorScale( aViewer );
351 }
352
353 QString HYDROGUI_OCCDisplayer::GetType() const
354 {
355   return OCCViewer_Viewer::Type();
356 }
357
358 bool HYDROGUI_OCCDisplayer::Display( const Handle(HYDROData_Entity)& theObject,
359                                      const OCCViewer_Viewer* theViewer,
360                                      const bool theIsForced )
361 {
362   DEBTRACE("Display");
363   bool aRes = false;
364
365   if ( theObject.IsNull() || theObject->IsRemoved() || !theViewer ) {
366     return aRes;
367   }
368
369   // Get interactive context
370   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
371   if( aCtx.IsNull() ) {
372     return aRes;
373   }
374
375   // Viewer id
376   size_t aViewerId = (size_t)theViewer;
377
378   // Object shape 
379   HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
380   // create if needed
381   if ( !anObjShape ) {
382     anObjShape = createShape( aViewerId, aCtx, theObject );
383     if ( anObjShape ) {
384       anObjShape->setIsToUpdate( true );
385     }
386   }
387   
388   // Process the shape
389   if ( anObjShape ) {
390     // update if needed
391     if ( anObjShape->getIsToUpdate() || theIsForced ) {
392       anObjShape->update( false, false );
393     }
394
395     // Set visibility
396     bool anIsVisible = module()->isObjectVisible( aViewerId, theObject );
397     anObjShape->setVisible( anIsVisible, false );
398
399     aRes = true;
400   }
401
402   return aRes;
403 }
404
405 void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer,
406                                        const Handle(HYDROData_Entity)& theObject, 
407                                        const int theZLayerId )
408 {
409   if ( !theViewer /*|| ( theZLayerId < 0 )*/ ) {
410     return;
411   }
412   
413   // Get interactive context
414   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
415   if( aCtx.IsNull() ) {
416     return;
417   }
418
419   // Get viewer id
420   size_t aViewerId = (size_t)theViewer;
421
422   // Get object shape 
423   HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
424
425   // Set Z layer
426   if ( anObjShape )
427   {
428     QList<Handle(AIS_InteractiveObject)> shapes = anObjShape->getAISObjects();
429     foreach( Handle(AIS_InteractiveObject) shape, shapes )
430       aCtx->SetZLayer( shape, theZLayerId );
431   }
432 }
433
434 void HYDROGUI_OCCDisplayer::SetToUpdateColorScale()
435 {
436   myToUpdateColorScale = true;
437 }
438
439 void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer )
440 {
441   if( !myToUpdateColorScale || !theViewer )
442     return;
443   
444   OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
445   Handle(V3d_View) aView = aWnd->getViewPort()->getView();
446       
447
448   HYDROGUI_Module* aModule = module();
449   size_t aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
450   bool isLandCoverColoringOn = aModule->isLandCoversScalarMapModeOn( aViewerId );
451     
452   QList<HYDROGUI_Shape*> aLandCoverMapShapes = aModule->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP );
453   QList<HYDROGUI_Shape*> aBathShapes = aModule->getObjectShapes( aViewerId, KIND_BATHYMETRY );
454
455   bool isDisplayColorScale = false;
456   foreach (HYDROGUI_Shape* shape, aLandCoverMapShapes)
457   {
458     if (aModule->isObjectVisible(aViewerId, shape->getObject()))
459     {
460       isDisplayColorScale = true;
461       break;
462     }
463   }
464   if (!isDisplayColorScale)
465     foreach (HYDROGUI_Shape* shape, aBathShapes)
466     {
467       if (aModule->isObjectVisible(aViewerId, shape->getObject()))
468       {
469         isDisplayColorScale = true;
470         break;
471       }
472     }
473   
474   Standard_Real aColorScaleMin = 0, aColorScaleMax = 1;
475
476   // Get range
477   Handle(HYDROData_StricklerTable) aTable;
478   QStringList aTableTypes;
479   if ( isLandCoverColoringOn ) {
480     aTable = module()->getLandCoverColoringTable( aViewerId );
481     if ( !aTable.IsNull() ) {
482       // TODO: non-empty title leads to buggy behaviour
483       // aColorScaleTitle = TCollection_ExtendedString( aTable->GetName().toLatin1().constData() );
484       aTable->GetCoefficientRange( aColorScaleMin, aColorScaleMax );
485       aTableTypes = aTable->GetTypes();
486     }
487   } else {
488     Standard_Real aMin, aMax;
489     bool isFirst = true;
490     foreach( HYDROGUI_Shape* aShape, aBathShapes )
491     {
492       HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
493       if( !aBathShape || !aBathShape->isVisible() )
494         continue;
495
496       aBathShape->GetRange( aMin, aMax );
497
498       if( isFirst || aMin < aColorScaleMin )
499         aColorScaleMin = aMin;
500       if( isFirst || aMax > aColorScaleMax )
501         aColorScaleMax = aMax;
502
503       isFirst = false;
504     }
505   }
506
507   Handle(AIS_ColorScale) aColorScale = GetColorScale( aViewerId );
508   Handle(AIS_InteractiveContext) aCtx = theViewer->getAISContext();
509   if( isDisplayColorScale )
510   {
511     if( !aColorScale.IsNull() )
512     {
513       // Set color scale title
514       TCollection_ExtendedString aColorScaleTitle = ""; //TODO
515       aColorScale->SetTitle( aColorScaleTitle );
516       
517       // Set color scale range
518       aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
519       
520       aColorScale->SetToUpdate();
521
522       if ( !isLandCoverColoringOn ) {
523         foreach( HYDROGUI_Shape* aShape, aBathShapes ) {
524           HYDROGUI_ShapeBathymetry* aBathShape = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aShape );
525           if( !aBathShape || !aBathShape->isVisible() )
526             continue;
527
528           aBathShape->UpdateWithColorScale( aColorScale );
529         }
530       }
531       
532       if ( !aCtx.IsNull()/* && !aCtx->IsDisplayed( aColorScale ) */) {
533         if ( !aCtx->IsDisplayed( aColorScale ) ) {
534           aCtx->Display( aColorScale, Standard_False );
535         }
536
537         aCtx->Update( aColorScale, true );
538       }
539     }
540   }
541   else
542   {
543     if ( !aCtx.IsNull() && aCtx->IsDisplayed( aColorScale ) ) {
544       aCtx->Erase( aColorScale, true );
545     }
546   }
547
548   foreach( HYDROGUI_Shape* aShape, aLandCoverMapShapes ) {
549     HYDROGUI_ShapeLandCoverMap* aLandCoverMapShape = 
550       dynamic_cast<HYDROGUI_ShapeLandCoverMap*>( aShape );
551
552     if ( !aLandCoverMapShape || !aLandCoverMapShape->isVisible() ) {
553       continue;
554     }
555     
556     Handle(HYDROData_LandCoverMap) aLandCoverMap = 
557       Handle(HYDROData_LandCoverMap)::DownCast( aLandCoverMapShape->getObject() );
558
559     if ( aLandCoverMap.IsNull() ) {
560       continue;
561     }
562     
563     bool isScalarMode = aLandCoverMapShape->isScalarMapModeEnabled();
564     if( isScalarMode != isLandCoverColoringOn )
565     {
566       aLandCoverMapShape->setScalarMapModeEnabled( isLandCoverColoringOn );
567       theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObjects()[0], Standard_False );
568     }
569   }
570   
571   myToUpdateColorScale = false;
572 }
573
574 Handle(AIS_ColorScale) HYDROGUI_OCCDisplayer::GetColorScale( const size_t theViewerId )
575 {
576   Handle(AIS_ColorScale) aColorScale;
577
578   aColorScale = myColorScales.value( theViewerId, aColorScale );
579   if ( aColorScale.IsNull() ) {
580     // Create color scale
581     aColorScale = new AIS_ColorScale();
582
583     // Set properties
584     Standard_Integer anXPos = 50; //TODO
585     Standard_Integer anYPos = 100; //TODO
586     Standard_Integer aWidth = 100; //TODO
587     Standard_Integer aHeight = 350; //TODO
588     
589     Standard_Integer aTextHeight = 14; //TODO
590     Standard_Integer aNbIntervals = 20; //TODO
591
592     aColorScale->SetTransformPersistence( Graphic3d_TMF_2d, gp_Pnt( -1, -1, 0 ) );
593     
594     aColorScale->SetXPosition( anXPos );
595     aColorScale->SetYPosition( anYPos );
596     aColorScale->SetSize( aWidth, aHeight );
597
598     aColorScale->SetTextHeight( aTextHeight );
599     aColorScale->SetNumberOfIntervals( aNbIntervals );
600
601     // Put into the map
602     myColorScales.insert( theViewerId, aColorScale );
603   }
604
605   return aColorScale;
606 }
607
608 void HYDROGUI_OCCDisplayer::UpdatePolylines( size_t theViewerId, int theType, int theSize )
609 {
610   OCCViewer_Viewer* aViewer = module()->getOCCViewer( theViewerId );
611   if( !aViewer )
612     return;
613
614   // Get interactive context
615   Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
616   if( aCtx.IsNull() )
617     return;
618
619   AIS_ListOfInteractive objs;
620   aCtx->DisplayedObjects( objs );
621   AIS_ListOfInteractive::const_iterator it = objs.begin(), last = objs.end();
622   for( ; it!=last; it++ )
623   {
624     Handle(HYDROGUI_Arrow) arr = Handle(HYDROGUI_Arrow)::DownCast( *it );
625     if( !arr.IsNull() )
626     {
627       if( theType>=0 )
628         arr->SetType( (HYDROGUI_Arrow::Type)theType );
629       if( theSize>=0 )
630         arr->SetSize( theSize );
631       aCtx->Redisplay( arr, Standard_False );
632     }
633   }
634   aCtx->UpdateCurrentViewer();
635 }