Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / SOCC / SOCC_ViewModel.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "SOCC_ViewModel.h"
20
21 #include "SOCC_Prs.h"
22 #include "SOCC_ViewWindow.h"
23
24 #include "SUIT_Session.h"
25 #include "SUIT_Application.h"
26
27 //#include "ToolsGUI.h"
28
29 // Temporarily commented to avoid awful dependecy on SALOMEDS
30 // TODO: better mechanism of storing display/erse status in a study
31 // should be provided...
32 //#include <SALOMEconfig.h>
33 //#include CORBA_CLIENT_HEADER(SALOMEDS)
34
35 #include <AIS_ListIteratorOfListOfInteractive.hxx>
36 #include <Visual3d_View.hxx>
37
38 #include <SALOME_AISShape.hxx>
39 #include <SALOME_AISObject.hxx>
40
41 // Temporarily commented to avoid awful dependecy on SALOMEDS
42 // TODO: better mechanism of storing display/erse status in a study
43 // should be provided...
44 //#include <Utils_ORB_INIT.hxx>
45 //#include <Utils_SINGLETON.hxx>
46 //#include <SALOME_ModuleCatalog_impl.hxx>
47 //#include <SALOME_NamingService.hxx>
48
49 //#include "SALOMEDSClient.hxx"
50 //#include "SALOMEDS_StudyManager.hxx"
51
52 #include <AIS_TypeOfIso.hxx>
53
54 // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
55 // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from 
56 // SALOMEDS::StudyManager - no linkage with SalomeApp. 
57
58 // Temporarily commented to avoid awful dependecy on SALOMEDS
59 // TODO: better mechanism of storing display/erse status in a study
60 // should be provided...
61 //static _PTR(Study) getStudyDS() 
62 //{
63 //  SALOMEDSClient_Study* aStudy = NULL;
64 //  _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
65
66   // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
67   //    id of its underlying SALOMEDS::Study
68 //  SUIT_Application* app = SUIT_Session::session()->activeApplication();
69 //  if ( !app )  return _PTR(Study)(aStudy);
70 //  SUIT_Study* stud = app->activeStudy();
71 //  if ( !stud ) return _PTR(Study)(aStudy);  
72 //  const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
73   // get SALOMEDS_Study with this id from StudyMgr
74 //  return aMgr->GetStudyByID( id );
75 //}
76
77 /*!
78   Constructor
79   \param DisplayTrihedron - is trihedron displayed
80 */
81 SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron )
82 : OCCViewer_Viewer( DisplayTrihedron )
83 {
84 }
85
86 /*!
87   Destructor
88 */
89 SOCC_Viewer::~SOCC_Viewer()
90 {
91 }
92
93 /*!
94   Hilights/unhilights object in viewer
95   \param obj - object to be updated
96   \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
97   \param update - update current viewer
98 */
99 bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj,
100                              bool hilight, bool upd )
101 {
102   bool isInLocal = getAISContext()->HasOpenedContext();
103   //SUIT_Study* ActiveStudy = SUIT_Application::getDesktop()->getActiveStudy();
104   //SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
105
106   AIS_ListOfInteractive List;
107   getAISContext()->DisplayedObjects(List);
108   
109   AIS_ListIteratorOfListOfInteractive ite(List);
110   for ( ; ite.More(); ite.Next() )
111   {
112     Handle(SALOME_InteractiveObject) anObj =
113       Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
114
115     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
116     {
117       if ( !isInLocal )
118           OCCViewer_Viewer::highlight( ite.Value(), hilight, false );
119       // highlight subshapes only when local selection is active
120       else
121       {
122         /*if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISShape ) ) )
123         {
124           Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast( ite.Value() );
125           TColStd_IndexedMapOfInteger MapIndex;
126           Sel->GetIndex( IObject, MapIndex );
127           aSh->highlightSubShapes( MapIndex, highlight );
128         }*/
129       }
130       break;
131     }
132   }
133     
134   if( upd )
135     update();
136     
137   return false;
138 }
139
140 /*!
141   \return true if object is in viewer or in collector
142   \param obj - object to be checked
143   \param onlyInViewer - search object only in viewer (so object must be displayed)
144 */
145 bool SOCC_Viewer::isInViewer( const Handle(SALOME_InteractiveObject)& obj,
146                               bool onlyInViewer )
147 {
148   AIS_ListOfInteractive List;
149   getAISContext()->DisplayedObjects(List);
150
151   if( !onlyInViewer ) {
152     AIS_ListOfInteractive List1;
153     getAISContext()->ObjectsInCollector(List1);
154     List.Append(List1);
155   }
156
157   AIS_ListIteratorOfListOfInteractive ite(List);
158   for ( ; ite.More(); ite.Next() )
159   {
160     Handle(SALOME_InteractiveObject) anObj =
161         Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
162
163     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
164       return true;
165   }
166   return false;
167 }
168
169 /*!
170   \return true if object is displayed in viewer
171   \param obj - object to be checked
172 */
173 bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj )
174 {
175   AIS_ListOfInteractive List;
176   getAISContext()->DisplayedObjects( List );
177
178   AIS_ListIteratorOfListOfInteractive ite( List );
179   for ( ; ite.More(); ite.Next() )
180   {
181     Handle(SALOME_InteractiveObject) anObj =
182       Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
183
184     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
185       return getAISContext()->IsDisplayed( ite.Value() );
186   }
187   
188   return false;
189 }
190
191 /*!
192   Sets color of object
193   \param obj - object to be updated
194   \param color - new color
195   \param update - update current viewer
196 */
197 void SOCC_Viewer::setColor( const Handle(SALOME_InteractiveObject)& obj,
198                             const QColor& color, bool update )
199 {
200   AIS_ListOfInteractive List;
201   getAISContext()->DisplayedObjects(List);
202   
203   AIS_ListIteratorOfListOfInteractive ite(List);
204   for ( ; ite.More(); ite.Next() )
205   {
206     Handle(SALOME_InteractiveObject) anObj =
207         Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
208
209     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
210     {
211       OCCViewer_Viewer::setColor( ite.Value(), color, update );
212       return;
213     }
214   }
215 }
216
217 /*!
218   Changes display mode of object
219   \param obj - object to be processed
220   \param mode - new display mode
221   \param update - update current viewer
222 */
223 void SOCC_Viewer::switchRepresentation( const Handle(SALOME_InteractiveObject)& obj,
224                                         int mode, bool update )
225 {
226   AIS_ListOfInteractive List;
227   getAISContext()->DisplayedObjects(List);
228   
229   AIS_ListIteratorOfListOfInteractive ite(List);
230   for ( ; ite.More(); ite.Next() )
231   {
232     Handle(SALOME_InteractiveObject) anObj =
233         Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
234
235     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
236     {
237       OCCViewer_Viewer::switchRepresentation( ite.Value(), mode, update );
238       return;
239     }
240   }
241 }
242
243 /*!
244   Changes transparency of object
245   \param obj - object to be processed
246   \param trans - new transparency
247   \param update - update current viewer
248 */
249 void SOCC_Viewer::setTransparency( const Handle(SALOME_InteractiveObject)& obj,
250                                    float trans, bool update )
251 {
252   AIS_ListOfInteractive List;
253   getAISContext()->DisplayedObjects( List );
254   
255   AIS_ListIteratorOfListOfInteractive ite( List );
256   for ( ; ite.More(); ite.Next() )
257   {
258     Handle(SALOME_InteractiveObject) anObj =
259         Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
260
261     if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
262     {
263       OCCViewer_Viewer::setTransparency( ite.Value(), trans, update );
264       return;
265     }
266   }
267 }
268
269 /*!
270   Changes name of object
271   \param obj - object to be renamed
272   \param name - new name
273 */
274 void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj,
275                           const QString& name )
276 {
277   AIS_ListOfInteractive List;
278   getAISContext()->DisplayedObjects(List);
279   
280   AIS_ListIteratorOfListOfInteractive ite(List);
281   while (ite.More())
282   {
283     if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape)))
284     {
285       Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value());
286       
287       if ( aSh->hasIO() )
288       {
289         Handle(SALOME_InteractiveObject) IO = aSh->getIO();
290         if ( IO->isSame( obj ) )
291         {
292           aSh->setName( (char*)name.latin1() );
293           break;
294         }
295       }
296     }
297     else if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) )
298     {
299       Handle(SALOME_AISObject) aSh = Handle(SALOME_AISObject)::DownCast( ite.Value() );
300
301       // Add code here, if someone create a MODULE_AISObject.
302     }
303     ite.Next();
304   }
305 }
306
307
308 /*!
309   Display presentation
310   \param prs - presentation
311 */
312 void SOCC_Viewer::Display( const SALOME_OCCPrs* prs )
313 {
314   // try do downcast object
315   const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs );
316   if ( !anOCCPrs || anOCCPrs->IsNull() )
317     return;
318
319   // get SALOMEDS Study
320   // Temporarily commented to avoid awful dependecy on SALOMEDS
321   // TODO: better mechanism of storing display/erse status in a study
322   // should be provided...
323   //  _PTR(Study) study(getStudyDS());
324
325   // get context
326   Handle (AIS_InteractiveContext) ic = getAISContext();
327
328   // get all displayed objects
329   AIS_ListOfInteractive List;
330   ic->DisplayedObjects( List );
331   // get objects in the collector
332   AIS_ListOfInteractive ListCollector;
333   ic->ObjectsInCollector( ListCollector );
334
335   // get objects to be displayed
336   AIS_ListOfInteractive anAISObjects;
337   anOCCPrs->GetObjects( anAISObjects );
338
339   AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
340   for ( ; aIter.More(); aIter.Next() )
341   {
342     Handle(AIS_InteractiveObject) anAIS = aIter.Value();
343     if ( !anAIS.IsNull() )
344     {
345       // try to find presentation in the viewer
346       bool bDisplayed = false;
347       AIS_ListIteratorOfListOfInteractive ite( List );
348       for ( ; ite.More(); ite.Next() )
349       {
350         // compare presentations by handles
351         // if the object is already displayed - nothing to do more
352         if ( ite.Value() == anAIS )
353         {
354           // Deactivate object if necessary
355           if ( !anOCCPrs->ToActivate() )
356             ic->Deactivate( anAIS );
357           bDisplayed = true;
358           break;
359         }
360       }
361
362       if ( bDisplayed )
363         continue;
364
365       // then try to find presentation in the collector
366       bDisplayed = false;
367       ite.Initialize( ListCollector );
368       for ( ; ite.More(); ite.Next() )
369       {
370         // compare presentations by handles
371         // if the object is in collector - display it
372         if ( ite.Value() == anAIS )
373         {
374           ic->DisplayFromCollector( anAIS, false );
375
376           // Deactivate object if necessary
377           if ( !anOCCPrs->ToActivate() )
378             ic->Deactivate( anAIS );
379           bDisplayed = true;
380
381           // Set visibility flag
382           // Temporarily commented to avoid awful dependecy on SALOMEDS
383           // TODO: better mechanism of storing display/erse status in a study
384           // should be provided...
385           //Handle(SALOME_InteractiveObject) anObj =
386           //  Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
387           //if ( !anObj.IsNull() && anObj->hasEntry() )
388           //{
389           //  if ( study )
390           //    ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
391           //}
392           break;
393         }
394       }
395       if ( bDisplayed )
396         continue;
397
398       // if object is not displayed and not found in the collector - display it
399       if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) )
400       {
401         Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS );
402         double aNewSize = 100, aSize = 100;
403         getTrihedronSize( aNewSize, aSize );
404         aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize );
405       }
406
407       ic->Display( anAIS, false );
408
409       // Set visibility flag
410       // Temporarily commented to avoid awful dependecy on SALOMEDS
411       // TODO: better mechanism of storing display/erse status in a study
412       // should be provided...
413       //Handle(SALOME_InteractiveObject) anObj =
414       //  Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
415       //if ( !anObj.IsNull() && anObj->hasEntry() )
416       //{
417       //  if ( study  )
418       //    ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
419       //}
420
421       // Deactivate object if necessary
422       if ( !anOCCPrs->ToActivate() )
423         ic->Deactivate( anAIS );
424     }
425   }
426 }
427
428
429 /*!
430   Erase presentation
431   \param prs - presentation
432   \param forced - removes object from context
433 */
434 void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced )
435 {
436   // try do downcast object
437   const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs );
438   if ( !anOCCPrs || anOCCPrs->IsNull() )
439     return;
440
441   // get SALOMEDS Study
442   // Temporarily commented to avoid awful dependecy on SALOMEDS
443   // TODO: better mechanism of storing display/erse status in a study
444   // should be provided...
445   //  _PTR(Study) study(getStudyDS());
446
447   // get context
448   Handle(AIS_InteractiveContext) ic = getAISContext();
449
450   // get objects to be erased
451   AIS_ListOfInteractive anAISObjects;
452   anOCCPrs->GetObjects( anAISObjects );
453
454   AIS_ListIteratorOfListOfInteractive aIter( anAISObjects );
455   for ( ; aIter.More(); aIter.Next() ) {
456     Handle(AIS_InteractiveObject) anAIS = aIter.Value();
457     if ( !anAIS.IsNull() ) {
458       // erase the object from context : move it to collector
459       ic->Erase( anAIS, false, forced ? false : true );
460
461       // Set visibility flag if necessary
462       // Temporarily commented to avoid awful dependecy on SALOMEDS
463       // TODO: better mechanism of storing display/erse status in a study
464       // should be provided...
465       //if ( !forced )
466       //{
467       //  Handle(SALOME_InteractiveObject) anObj =
468       //    Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
469       //  if ( !anObj.IsNull() && anObj->hasEntry() )
470       //  {
471       //  if ( study )
472       //    ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
473       //  }
474       //}
475     }
476   }
477 }
478
479
480 /*!
481   Erase all presentations
482   \param forced - removes all objects from context
483 */
484 void SOCC_Viewer::EraseAll( const bool forced )
485 {
486   // get SALOMEDS Study
487   // Temporarily commented to avoid awful dependecy on SALOMEDS
488   // TODO: better mechanism of storing display/erse status in a study
489   // should be provided...
490   //  _PTR(Study) study(getStudyDS());
491
492   // get context
493   Handle(AIS_InteractiveContext) ic = getAISContext();
494
495   // check if trihedron is displayed
496   Standard_Boolean isTrihedronDisplayed = ic->IsDisplayed( getTrihedron() );
497
498   // get objects to be erased (all currently displayed objects)
499   AIS_ListOfInteractive aList;
500   ic->DisplayedObjects( aList );
501   AIS_ListIteratorOfListOfInteractive anIter( aList );
502   for ( ; anIter.More(); anIter.Next() ) {
503     if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) )
504       continue;
505
506     // erase an object
507     Handle(AIS_InteractiveObject) anIO = anIter.Value();
508     ic->Erase( anIO, false, forced ? false : true );
509     
510     // Set visibility flag if necessary
511     // Temporarily commented to avoid awful dependecy on SALOMEDS
512     // TODO: better mechanism of storing display/erse status in a study
513     // should be provided...
514     //if ( !forced ) {
515     //  Handle(SALOME_InteractiveObject) anObj =
516     //  Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() );
517
518     //  if ( !anObj.IsNull() && anObj->hasEntry() ) {
519     //  if ( study )
520     //    ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
521     //  }
522     //}
523   }
524   
525   Repaint();
526 }
527
528 /*!
529   Create presentation corresponding to the entry
530   \param entry - entry
531 */
532 SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry )
533 {
534   SOCC_Prs* prs = new SOCC_Prs();
535   if ( entry )
536   {
537     // get context
538     Handle(AIS_InteractiveContext) ic = getAISContext();
539
540     // get displayed objects
541     AIS_ListOfInteractive List;
542     ic->DisplayedObjects( List );
543     // get objects in the collector
544     AIS_ListOfInteractive ListCollector;
545     ic->ObjectsInCollector( ListCollector );
546     List.Append( ListCollector );
547
548     AIS_ListIteratorOfListOfInteractive ite( List );
549     for ( ; ite.More(); ite.Next() )
550     {
551       Handle(SALOME_InteractiveObject) anObj =
552         Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
553
554       if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), entry ) == 0 )
555         prs->AddObject( ite.Value() );
556     }
557   }
558   return prs;
559 }
560
561 /*!
562   Activates selection of sub shapes
563 */
564 void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode )
565 {
566   Handle(AIS_InteractiveContext) ic = getAISContext();
567   
568   const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( thePrs );
569   if ( ic.IsNull() )
570     return;
571   
572   // Open local context if there is no one
573   bool allObjects = thePrs == 0 || thePrs->IsNull();
574   if ( !ic->HasOpenedContext() ) {
575     ic->ClearCurrents( false );
576     ic->OpenLocalContext( allObjects, true, true );
577   }
578
579   AIS_ListOfInteractive anObjs;
580   // Get objects to be activated
581   if ( allObjects ) 
582     ic->DisplayedObjects( anObjs );
583   else
584     anOCCPrs->GetObjects( anObjs );
585
586   // Activate selection of objects from prs
587   AIS_ListIteratorOfListOfInteractive aIter( anObjs );
588   for ( ; aIter.More(); aIter.Next() ) {
589     Handle(AIS_InteractiveObject) anAIS = aIter.Value();
590     if ( !anAIS.IsNull() )
591     {
592       if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
593       {
594         ic->Load( anAIS, -1, false );
595         ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) );
596       }
597       else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
598       {
599         ic->Load( anAIS, -1, false );
600         ic->Activate( anAIS, theMode );
601       }
602     }
603   }
604 }
605
606 /*!
607   Deactivates selection of sub shapes
608 */
609 void SOCC_Viewer::GlobalSelection( const bool update ) const
610 {
611   Handle(AIS_InteractiveContext) ic = getAISContext();
612   if ( !ic.IsNull() )
613   {
614     ic->CloseAllContexts( false );
615     if ( update )
616       ic->CurrentViewer()->Redraw();
617   }
618 }
619
620 /*!
621   Auxiliary method called before displaying of objects
622 */
623 void  SOCC_Viewer::BeforeDisplay( SALOME_Displayer* d )
624 {
625   d->BeforeDisplay( this, SALOME_OCCViewType() );
626 }
627
628 /*!
629   Auxiliary method called after displaying of objects
630 */
631 void SOCC_Viewer::AfterDisplay( SALOME_Displayer* d )
632 {
633   d->AfterDisplay( this, SALOME_OCCViewType() );
634 }
635
636 /*!
637   Get new and current trihedron size corresponding to the current model size
638 */
639 bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize )
640 {
641   theNewSize = 100;
642   theSize = 100;
643
644   //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
645   Handle(V3d_Viewer) viewer = getViewer3d();
646   viewer->InitActiveViews();
647   if(!viewer->MoreActiveViews()) return false;
648
649   Handle(V3d_View) view3d = viewer->ActiveView();
650   //SRN: END of fix
651
652   if ( view3d.IsNull() )
653     return false;
654
655   double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
656   double aMaxSide;
657
658   view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
659
660   if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() ||
661        Xmax == RealLast()  || Ymax == RealLast()  || Zmax == RealLast() )
662     return false;
663
664   aMaxSide = Xmax - Xmin;
665   if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
666   if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
667
668   float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("Viewer","TrihedronSize", 105.);
669
670   static float EPS = 5.0E-3;
671   theSize = getTrihedron()->Size();
672   theNewSize = aMaxSide*aSizeInPercents / 100.0;
673
674   return fabs( theNewSize - theSize ) > theSize * EPS ||
675          fabs( theNewSize - theSize) > theNewSize * EPS;
676 }
677
678
679 /*!
680   Updates current viewer
681 */
682 void SOCC_Viewer::Repaint()
683 {
684 //  onAdjustTrihedron();
685   getViewer3d()->Update();
686 }
687
688
689 /*!
690   create SOCC_ViewWindow
691 */
692 SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop )
693 {
694   SOCC_ViewWindow* view = new SOCC_ViewWindow(theDesktop, this);
695   initView( view );
696   return view;
697 }