Salome HOME
Rollback previous incorrect integration.
[modules/geom.git] / src / OBJECT / GEOM_Actor.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  GEOM OBJECT : interactive object for Geometry entities visualization
24 //  File   : GEOM_Actor.cxx
25 //  Author : Christophe ATTANASIO
26 //  Module : GEOM
27 //  $Header$
28 //
29 /*!
30   \class GEOM_Actor GEOM_Actor.h
31   \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer.
32 */
33 #include "GEOM_Actor.h" 
34  
35 #include "GEOM_DeviceActor.h" 
36 #include "GEOM_VertexSource.h" 
37 #include "GEOM_EdgeSource.h" 
38 #include "GEOM_WireframeFace.h" 
39 #include "GEOM_ShadingFace.h"
40 #include "SVTK_Actor.h"
41
42 #include <OCC2VTK_Tools.h>
43
44 #include <vtkObjectFactory.h> 
45 #include <vtkRenderer.h> 
46 #include <vtkProperty.h> 
47 #include <vtkPointPicker.h>
48 #include <vtkCellPicker.h>
49  
50 #include <TopAbs_ShapeEnum.hxx>
51 #include <TopExp_Explorer.hxx>
52 #include <TopoDS.hxx>
53 #include <BRep_Tool.hxx>
54 #include <TopExp.hxx>
55  
56 #include <vtkPolyDataWriter.h> 
57  
58 #include <vtkAppendPolyData.h>  
59 #include <vtkPolyDataMapper.h>  
60 #include <vtkPolyData.h>  
61 #include <vtkTransform.h>
62 #include <vtkMatrix4x4.h>
63 #include <vtkMath.h>
64 #include <vtkCamera.h>
65
66 #include "utilities.h"
67
68 #include "SALOME_InteractiveObject.hxx"
69
70 //vtkStandardNewMacro(GEOM_Actor);
71
72 #ifndef MYDEBUG
73 //#define MYDEBUG
74 #endif
75
76 GEOM_Actor::GEOM_Actor(): 
77   //  myDisplayMode(eWireframe), 
78   myIsSelected(false), 
79   myVectorMode(false),
80   myVertexActor(GEOM_DeviceActor::New(),true), 
81   myVertexSource(GEOM_VertexSource::New(),true), 
82  
83   myIsolatedEdgeActor(GEOM_DeviceActor::New(),true), 
84   myIsolatedEdgeSource(GEOM_EdgeSource::New(),true), 
85  
86   myOneFaceEdgeActor(GEOM_DeviceActor::New(),true), 
87   myOneFaceEdgeSource(GEOM_EdgeSource::New(),true), 
88  
89   mySharedEdgeActor(GEOM_DeviceActor::New(),true), 
90   mySharedEdgeSource(GEOM_EdgeSource::New(),true), 
91  
92   myWireframeFaceActor(GEOM_DeviceActor::New(),true), 
93   myWireframeFaceSource(GEOM_WireframeFace::New(),true), 
94  
95   myShadingFaceActor(GEOM_DeviceActor::New(),true), 
96   myShadingFaceSource(GEOM_ShadingFace::New(),true), 
97  
98   myHighlightActor(GEOM_DeviceActor::New(),true), 
99   myAppendFilter(vtkAppendPolyData::New(),true), 
100   myPolyDataMapper(vtkPolyDataMapper::New(),true),
101
102   myHighlightProp(vtkProperty::New()),
103   myPreHighlightProp(vtkProperty::New()),
104   myShadingFaceProp(vtkProperty::New()),
105   isOnlyVertex(false)
106
107 #ifdef MYDEBUG
108   MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
109 #endif
110
111   myPolyDataMapper->SetInput(myAppendFilter->GetOutput()); 
112   vtkProperty* aProperty; 
113
114   myHighlightProp->SetAmbient(0.5);
115   myHighlightProp->SetDiffuse(0.3);
116   myHighlightProp->SetSpecular(0.2);
117   myHighlightProp->SetRepresentationToSurface();
118   myHighlightProp->SetAmbientColor(1, 1, 1);
119   myHighlightProp->SetDiffuseColor(1, 1, 1);
120   myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5);
121   myHighlightProp->SetPointSize(SALOME_POINT_SIZE);
122   myHighlightActor->SetProperty(myHighlightProp.GetPointer());
123
124   this->myHighlightActor->SetInput(myAppendFilter->GetOutput(),false);
125
126   myPreHighlightProp->SetColor(0,1,1);
127   myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE+2);
128   myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1);
129   myPreHighlightProp->SetRepresentationToWireframe();
130
131   myAppendFilter->AddInput(myVertexSource->GetOutput()); 
132   myVertexActor->SetInput(myVertexSource->GetOutput(),false); 
133   aProperty = myVertexActor->GetProperty(); 
134   aProperty->SetRepresentation(VTK_POINTS); 
135   aProperty->SetPointSize(3); 
136   aProperty->SetColor(1, 1, 0);
137  
138   myAppendFilter->AddInput(myIsolatedEdgeSource->GetOutput()); 
139   myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutput(),false); 
140   aProperty = myIsolatedEdgeActor->GetProperty(); 
141   aProperty->SetRepresentation(VTK_WIREFRAME); 
142   aProperty->SetColor(1, 0, 0);
143  
144   myAppendFilter->AddInput(myOneFaceEdgeSource->GetOutput()); 
145   myOneFaceEdgeActor->SetInput(myOneFaceEdgeSource->GetOutput(),false); 
146   aProperty = myOneFaceEdgeActor->GetProperty(); 
147   aProperty->SetRepresentation(VTK_WIREFRAME); 
148   aProperty->SetColor(0, 1, 0);
149  
150   myAppendFilter->AddInput(mySharedEdgeSource->GetOutput()); 
151   mySharedEdgeActor->SetInput(mySharedEdgeSource->GetOutput(),false); 
152   aProperty = mySharedEdgeActor->GetProperty(); 
153   aProperty->SetRepresentation(VTK_WIREFRAME); 
154   aProperty->SetColor(1, 1, 0);
155  
156   myAppendFilter->AddInput(myWireframeFaceSource->GetOutput()); 
157   myWireframeFaceActor->SetInput(myWireframeFaceSource->GetOutput(),false); 
158   aProperty = myWireframeFaceActor->GetProperty(); 
159   aProperty->SetRepresentation(VTK_WIREFRAME); 
160   aProperty->SetColor(0.5, 0.5, 0.5);
161
162   myShadingFaceActor->SetInput(myShadingFaceSource->GetOutput(),true); 
163
164   myShadingFaceProp->SetRepresentation(VTK_SURFACE); 
165   myShadingFaceProp->SetInterpolationToGouraud(); 
166   myShadingFaceProp->SetAmbient(1.0);
167   myShadingFaceProp->SetDiffuse(1.0);
168   myShadingFaceProp->SetSpecular(0.4);
169   myShadingFaceProp->SetAmbientColor(0.329412, 0.223529, 0.027451);
170   myShadingFaceProp->SetDiffuseColor(0.780392, 0.568627, 0.113725);
171   myShadingFaceProp->SetSpecularColor(0.992157, 0.941176, 0.807843);
172
173   myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
174
175   // Toggle display mode 
176   setDisplayMode(0); // WIRE FRAME
177   SetVectorMode(0);  //
178
179
180  
181  
182 GEOM_Actor::~GEOM_Actor() 
183
184 #ifdef MYDEBUG
185   MESSAGE (this<< " ~GEOM_Actor::GEOM_Actor");
186 #endif
187   myHighlightProp->Delete();
188   myPreHighlightProp->Delete();
189   myShadingFaceProp->Delete();
190
191  
192 GEOM_Actor*  
193 GEOM_Actor:: 
194 New() 
195
196   GEOM_Actor* anObject = new GEOM_Actor(); 
197   anObject->SetMapper(anObject->myPolyDataMapper.Get()); 
198   return anObject; 
199
200  
201  
202 void Write(vtkPolyData* theDataSet, const char* theFileName){ 
203   vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); 
204   MESSAGE ("Write - "<<theFileName<<"' : "<<theDataSet->GetNumberOfPoints()<<"; "<<theDataSet->GetNumberOfCells()); 
205   aWriter->SetInput(theDataSet); 
206   aWriter->SetFileName(theFileName); 
207   //aWriter->Write(); 
208   aWriter->Delete(); 
209
210  
211 void 
212 GEOM_Actor:: 
213 SetModified() 
214
215   this->myVertexSource->Modified(); 
216   this->myIsolatedEdgeSource->Modified(); 
217   this->myOneFaceEdgeSource->Modified(); 
218   this->mySharedEdgeSource->Modified(); 
219   this->myWireframeFaceSource->Modified(); 
220   this->myShadingFaceSource->Modified(); 
221
222
223 void  
224 GEOM_Actor:: 
225 SetMapper(vtkMapper* theMapper) 
226
227   SALOME_Actor::SetMapper(theMapper); 
228
229
230 void 
231 GEOM_Actor:: 
232 AddToRender(vtkRenderer* theRenderer)
233 {
234   //SALOME_Actor::AddToRender(theRenderer);
235   
236   theRenderer->AddActor(this); 
237  
238   this->myHighlightActor->AddToRender(theRenderer); 
239   
240
241   myShadingFaceActor->AddToRender(theRenderer); 
242   myWireframeFaceActor->AddToRender(theRenderer); 
243  
244   mySharedEdgeActor->AddToRender(theRenderer); 
245   myOneFaceEdgeActor->AddToRender(theRenderer); 
246   myIsolatedEdgeActor->AddToRender(theRenderer); 
247  
248   myVertexActor->AddToRender(theRenderer); 
249 }
250  
251 void 
252 GEOM_Actor:: 
253 RemoveFromRender(vtkRenderer* theRenderer)
254 {
255   //SALOME_Actor::RemoveFromRender(theRenderer);
256
257   
258   theRenderer->RemoveActor(this);
259
260   myHighlightActor->RemoveFromRender(theRenderer); 
261   myShadingFaceActor->RemoveFromRender(theRenderer); 
262   myWireframeFaceActor->RemoveFromRender(theRenderer); 
263  
264   mySharedEdgeActor->RemoveFromRender(theRenderer); 
265   myOneFaceEdgeActor->RemoveFromRender(theRenderer); 
266   myIsolatedEdgeActor->RemoveFromRender(theRenderer); 
267  
268   myVertexActor->RemoveFromRender(theRenderer);
269
270   
271   SetSelected(false);
272   SetVisibility(false);
273 }
274
275 void  
276 GEOM_Actor:: 
277 setDisplayMode(int theMode) 
278
279 #ifdef MYDEBUG
280   MESSAGE ( "GEOM_Actor::SetDisplayMode = "<<theMode );
281 #endif
282   VTKViewer_Actor::setDisplayMode(theMode);
283   SetVisibility(GetVisibility()); 
284
285
286 void  
287 GEOM_Actor:: 
288 SetSelected(bool theIsSelected) 
289
290 #ifdef MYDEBUG
291   MESSAGE ( "GEOM_Actor::SetSelected = "<<theIsSelected  );
292 #endif
293
294   myIsSelected = theIsSelected; 
295   SetVisibility(GetVisibility()); 
296
297
298 void  
299 GEOM_Actor:: 
300 SetVisibility(int theVisibility) 
301
302 #ifdef MYDEBUG
303   MESSAGE ( "GEOM_Actor::SetVisibility = "<<theVisibility <<"  myIsSelected="<< myIsSelected
304             << " theVisibility="<<theVisibility<<" myIsPreselected="<<myIsPreselected );
305 #endif
306
307   SALOME_Actor::SetVisibility(theVisibility);
308
309   this->myHighlightActor->SetVisibility(theVisibility && (myIsSelected || myIsPreselected));
310   
311   myShadingFaceActor->SetVisibility(theVisibility && (myDisplayMode == (int)eShading) && (!myIsSelected || !myIsPreselected)); 
312   myWireframeFaceActor->SetVisibility(theVisibility && (myDisplayMode ==(int)eWireframe) && !myIsSelected);
313
314   mySharedEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
315   myOneFaceEdgeActor->SetVisibility(theVisibility && myDisplayMode == (int)eWireframe && !myIsSelected);
316   myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
317
318   myVertexActor->SetVisibility(theVisibility && !myIsSelected);// must be added new mode points 
319 }
320  
321
322 void
323 GEOM_Actor
324 ::SetNbIsos(const int theNb[2])
325 {
326   myWireframeFaceSource->SetNbIso(theNb);
327 }
328
329 void
330 GEOM_Actor
331 ::GetNbIsos(int &theNbU,int &theNbV)
332 {
333   myWireframeFaceSource->GetNbIso(theNbU, theNbV);
334 }
335
336 void
337 GEOM_Actor
338 ::SetVectorMode(bool theMode)
339 {
340   myVectorMode = theMode;
341   myIsolatedEdgeSource->SetVectorMode(theMode);
342   myOneFaceEdgeSource->SetVectorMode(theMode);
343   mySharedEdgeSource->SetVectorMode(theMode);
344   SetModified();
345 }
346
347 bool
348 GEOM_Actor
349 ::GetVectorMode()
350 {
351   return myVectorMode;
352 }
353
354 void  
355 GEOM_Actor:: 
356 SetDeflection(float theDeflection, bool theIsRelative) 
357
358   myDeflection = theDeflection; 
359   myIsRelative = theIsRelative; 
360  
361   GEOM::MeshShape2(myShape,myDeflection,myIsRelative); 
362  
363   SetModified(); 
364
365
366 void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
367                            float theDeflection,
368                            bool theIsRelative,
369                            bool theIsVector)
370 {
371   myShape = theShape;
372
373   myVertexSource->Clear();
374   myIsolatedEdgeSource->Clear();
375   myOneFaceEdgeSource->Clear();
376   mySharedEdgeSource->Clear();
377   myWireframeFaceSource->Clear();
378   myShadingFaceSource->Clear();
379
380   TopExp_Explorer aVertexExp (theShape,TopAbs_VERTEX);
381   for (; aVertexExp.More(); aVertexExp.Next())
382   {
383      const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertexExp.Current());
384      myVertexSource->AddVertex(aVertex);
385   }
386   SetDeflection(theDeflection, theIsRelative);
387
388   // look if edges are free or shared
389   TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
390   TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
391   
392   GEOM::SetShape(theShape,anEdgeMap,theIsVector,
393                  myIsolatedEdgeSource.Get(),
394                  myOneFaceEdgeSource.Get(),
395                  mySharedEdgeSource.Get(),
396                  myWireframeFaceSource.Get(),
397                  myShadingFaceSource.Get());
398   isOnlyVertex =  
399     myIsolatedEdgeSource->IsEmpty() &&
400     myOneFaceEdgeSource->IsEmpty() &&
401     mySharedEdgeSource->IsEmpty() &&
402     myWireframeFaceSource->IsEmpty() &&
403     myShadingFaceSource->IsEmpty();
404
405   
406   if((bool)myShape.Infinite() || isOnlyVertex ){
407     myVertexActor->GetDeviceActor()->SetInfinitive(true);
408     myHighlightActor->GetDeviceActor()->SetInfinitive(true);
409   }
410 }
411
412 // OLD METHODS
413 void GEOM_Actor::setDeflection(double adef) {
414 #ifdef MYDEBUG
415   MESSAGE ( "GEOM_Actor::setDeflection" );
416 #endif
417   SetDeflection((float)adef,GetIsRelative());
418 }
419
420
421 // warning! must be checked!
422 // SetHighlightProperty
423 // SetWireframeProperty
424 // SetShadingProperty
425
426 void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop)
427 {
428 #ifdef MYDEBUG
429   MESSAGE ( "GEOM_Actor::SetHighlightProperty" );
430 #endif
431   this->myHighlightActor->GetProperty()->DeepCopy(Prop);
432   
433 }
434
435 void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop)
436 {
437 #ifdef MYDEBUG
438   MESSAGE ( this << " GEOM_Actor::SetWireframeProperty" );
439 #endif
440   // must be filled
441   myWireframeFaceActor->SetProperty(Prop);
442 }
443
444 void GEOM_Actor::SetShadingProperty(vtkProperty* Prop)
445 {
446 #ifdef MYDEBUG
447   MESSAGE ( "GEOM_Actor::SetShadingProperty" );
448 #endif
449   myShadingFaceProp->DeepCopy(Prop);
450 }
451
452
453 void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
454 {
455 #ifdef MYDEBUG
456   MESSAGE ( "GEOM_Actor::Render" );
457 #endif
458
459   if(!GetVisibility())
460     return;
461
462   /* render the property */
463   if (!this->Property) {
464     // force creation of a property
465     this->GetProperty();
466     this->Property->SetInterpolation(1);
467     this->Property->SetRepresentationToSurface();
468     this->Property->SetAmbient(0.3);
469     this->Property->SetAmbientColor(0.88,0.86,0.2);
470     this->Property->SetDiffuseColor(0.99,0.7,0.21);
471     this->Property->SetSpecularColor(0.99,0.98,0.83);
472   }
473
474   switch(myDisplayMode){
475   case 0://wireframe
476     myPreHighlightProp->SetRepresentationToWireframe();
477     myHighlightProp->SetRepresentationToWireframe();
478     break;
479   case 1://shading
480     myPreHighlightProp->SetRepresentationToSurface();
481     myHighlightProp->SetRepresentationToSurface();
482     break;
483   }
484
485   if(!myIsSelected){
486     if(myIsPreselected){
487       this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer());
488       myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer());
489     } else {
490       this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer());
491       myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
492     }
493   }
494   else{
495     this->myHighlightActor->SetProperty(myHighlightProp.GetPointer());
496     myShadingFaceActor->SetProperty(myHighlightProp.GetPointer());
497   }
498
499   this->Property->Render(this, ren);
500   if (this->BackfaceProperty) {
501     this->BackfaceProperty->BackfaceRender(this, ren);
502     this->Device->SetBackfaceProperty(this->BackfaceProperty);
503   }
504   this->Device->SetProperty(this->Property);
505   /*  if(myShape.ShapeType() == TopAbs_VERTEX) {
506     if(ren){
507       //The parameter determine size of vertex actor relate to diagonal of RendererWindow
508       static vtkFloatingPointType delta = 0.01;
509       vtkFloatingPointType X1 = -1, Y1 = -1, Z1 = 0;
510       ren->ViewToWorld(X1,Y1,Z1);
511       vtkFloatingPointType X2 = +1, Y2 = +1, Z2 = 0;
512       ren->ViewToWorld(X2,Y2,Z2);
513       Z2 = sqrt((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) + (Z2-Z1)*(Z2-Z1));
514       this->SetScale(Z2*delta);
515     }
516     vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
517     this->GetMatrix(ren->GetActiveCamera(), aMatrix);
518     this->Device->SetUserMatrix(aMatrix);
519     this->Device->Render(ren,theMapper);
520     aMatrix->Delete();    
521     } else*/
522     this->Device->Render(ren, theMapper);
523 }
524
525 void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *)
526 {
527 #ifdef MYDEBUG
528   MESSAGE ( "GEOM_Actor::ReleaseGraphicsResources" );
529 #endif  
530 }
531
532
533
534 void GEOM_Actor::ShallowCopy(vtkProp *prop)
535 {
536 #ifdef MYDEBUG
537   MESSAGE ( "GEOM_Actor::ShallowCopy" );
538 #endif
539   GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
540   if ( f != NULL )
541     {
542       this->SetShape(f->getTopo(),f->GetDeflection(),f->GetIsRelative());
543     }
544
545   // Now do superclass
546   this->SALOME_Actor::ShallowCopy(prop);
547 }
548
549 const TopoDS_Shape& GEOM_Actor::getTopo() {
550 #ifdef MYDEBUG
551   MESSAGE ( "GEOM_Actor::getTopo" );
552 #endif
553   return myShape;
554 }
555
556 void GEOM_Actor::setInputShape(const TopoDS_Shape& ashape, double adef1,
557                                int imode, bool isVector)
558 {
559 #ifdef MYDEBUG
560   MESSAGE ( "GEOM_Actor::setInputShape" );
561 #endif
562 }
563
564 double GEOM_Actor::getDeflection()
565 {
566 #ifdef MYDEBUG
567   MESSAGE ( "GEOM_Actor::getDeflection" );
568 #endif
569   return (double) GetDeflection();
570 }
571
572
573 double GEOM_Actor::isVector()
574 {
575 #ifdef MYDEBUG
576   MESSAGE ( "GEOM_Actor::isVector" );
577 #endif  
578   return 0;
579 }
580
581 void GEOM_Actor::SubShapeOn()
582 {
583 #ifdef MYDEBUG
584   MESSAGE ( "GEOM_Actor::SubShapeOn" );
585 #endif  
586 }
587
588 void GEOM_Actor::SubShapeOff()
589 {
590 #ifdef MYDEBUG
591   MESSAGE ( "GEOM_Actor::SubShapeOff" );
592 #endif
593 }
594
595 void GEOM_Actor::highlight(bool highlight)
596 {
597 #ifdef MYDEBUG
598   MESSAGE ( this << " GEOM_Actor::highlight highlight="<<highlight );
599 #endif
600   SALOME_Actor::highlight(highlight);
601 }
602
603 void GEOM_Actor::SetOpacity(vtkFloatingPointType opa)
604 {
605   // enk:tested OK
606   myShadingFaceProp->SetOpacity(opa);
607   myHighlightProp->SetOpacity(opa);
608   myPreHighlightProp->SetOpacity(opa);
609   myVertexActor->GetProperty()->SetOpacity(opa);
610 }
611
612 vtkFloatingPointType GEOM_Actor::GetOpacity()
613 {
614   // enk:tested OK
615   return myShadingFaceProp->GetOpacity(); 
616 }
617
618 void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
619 {
620   // enk:tested OK
621   myShadingFaceProp->SetColor(r,g,b);                          // shading color (Shading)
622   myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b);         // standalone edge color (Wireframe)
623   myVertexActor->GetProperty()->SetColor(r,g,b);               // vertex actor (Shading/Wireframe)
624   myOneFaceEdgeActor->GetProperty()->SetColor(r,g,b);          // standalone face edge color (Wireframe)
625   mySharedEdgeActor->GetProperty()->SetColor(r,g,b);           // share edge color (Wireframe)
626 }
627
628 void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
629 {
630   // enk:tested OK
631   vtkFloatingPointType aRGB[3];
632   myShadingFaceProp->GetColor(aRGB);
633   r = aRGB[0];
634   g = aRGB[1];
635   b = aRGB[2];
636 }
637
638 bool GEOM_Actor::IsInfinitive()
639 {
640   return ((bool)myShape.Infinite() || isOnlyVertex);
641 }
642
643 /*!
644   To map current selection to VTK representation
645 */
646 void
647 GEOM_Actor
648 ::Highlight(bool theIsHighlight)
649 {
650   myIsSelected = theIsHighlight;
651 #ifdef MYDEBUG
652   MESSAGE ( this << " GEOM_Actor::Highlight myIsSelected="<<myIsSelected );
653 #endif
654   
655   SALOME_Actor::Highlight(theIsHighlight); // this method call ::highlight(theIsHighlight) in the end
656   SetVisibility(GetVisibility());
657 }
658
659 /*!
660   To process prehighlight (called from SVTK_InteractorStyle)
661 */
662 bool
663 GEOM_Actor
664 ::PreHighlight(vtkInteractorStyle *theInteractorStyle, 
665                SVTK_SelectionEvent* theSelectionEvent,
666                bool theIsHighlight)
667 {
668 #ifdef MYDEBUG
669   MESSAGE ( this<<" GEOM_Actor::PreHighlight (3) theIsHighlight="<<theIsHighlight );
670 #endif
671
672   if ( !GetPickable() )
673     return false;  
674
675   myPreHighlightActor->SetVisibility( false );
676   bool anIsPreselected = myIsPreselected;
677   
678   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
679   bool anIsChanged = (mySelectionMode != aSelectionMode);
680
681   if( !theIsHighlight ) {
682     SetPreSelected( false );
683   }else{
684     switch(aSelectionMode){
685     case ActorSelection : 
686     {
687       //      cout << "=============== " << myIO->getEntry() << endl;
688       int nbio = mySelector->IObjectCount();
689       //      cout << " nbio = " << nbio << endl;
690
691       if( !mySelector->IsSelected( myIO ) ) {
692         //      printf ("!!!!!!!!!!!!!!!!\n");
693         SetPreSelected( true );
694       }
695     }
696     default:
697       break;
698     }
699   }
700
701   mySelectionMode = aSelectionMode;
702   anIsChanged |= (anIsPreselected != myIsPreselected);
703
704   SetVisibility(GetVisibility());
705   return anIsChanged;
706 }
707
708 /*!
709   To process highlight (called from SVTK_InteractorStyle)
710 */
711 bool
712 GEOM_Actor
713 ::Highlight(vtkInteractorStyle *theInteractorStyle, 
714             SVTK_SelectionEvent* theSelectionEvent,
715             bool theIsHighlight)
716 {
717   // define the selection of object
718 #ifdef MYDEBUG
719   MESSAGE ( std::endl << this << " GEOM_Actor::Highlight (3) myIsSelected="<<myIsSelected );
720 #endif
721   bool aRet = SALOME_Actor::Highlight(theInteractorStyle,theSelectionEvent,theIsHighlight);
722   SetSelected(theIsHighlight);
723   if(theIsHighlight)
724     SetPreSelected(false);
725   
726  
727   return aRet;
728 }
729
730 // Copy the follower's composite 4x4 matrix into the matrix provided.
731 void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
732 {
733   double *pos, *vup;
734   double Rx[3], Ry[3], Rz[3], p1[3];
735   vtkMatrix4x4 *matrix = vtkMatrix4x4::New();
736   int i;
737   double distance;
738   
739   this->GetOrientation();
740   this->Transform->Push();  
741   this->Transform->PostMultiply();  
742   this->Transform->Identity();
743
744   // apply user defined matrix last if there is one 
745   if (this->UserMatrix)
746     {
747     this->Transform->Concatenate(this->UserMatrix);
748     }
749
750   this->Transform->Translate(-this->Origin[0],
751                              -this->Origin[1],
752                              -this->Origin[2]);
753   // scale
754   this->Transform->Scale(this->Scale[0],
755                          this->Scale[1],
756                          this->Scale[2]);
757   
758   // rotate
759   this->Transform->RotateY(this->Orientation[1]);
760   this->Transform->RotateX(this->Orientation[0]);
761   this->Transform->RotateZ(this->Orientation[2]);
762
763   if (theCam)
764     {
765     // do the rotation
766     // first rotate y 
767     pos = theCam->GetPosition();
768     vup = theCam->GetViewUp();
769
770     if (theCam->GetParallelProjection())
771       {
772       theCam->GetDirectionOfProjection(Rz);
773       }
774     else
775       {
776       distance = sqrt(
777         (pos[0] - this->Position[0])*(pos[0] - this->Position[0]) +
778         (pos[1] - this->Position[1])*(pos[1] - this->Position[1]) +
779         (pos[2] - this->Position[2])*(pos[2] - this->Position[2]));
780       for (i = 0; i < 3; i++)
781         {
782         Rz[i] = (pos[i] - this->Position[i])/distance;
783         }
784       }
785   
786     vtkMath::Cross(vup,Rz,Rx);
787     vtkMath::Normalize(Rx);
788     vtkMath::Cross(Rz,Rx,Ry);
789     
790     matrix->Element[0][0] = Rx[0];
791     matrix->Element[1][0] = Rx[1];
792     matrix->Element[2][0] = Rx[2];
793     matrix->Element[0][1] = Ry[0];
794     matrix->Element[1][1] = Ry[1];
795     matrix->Element[2][1] = Ry[2];
796     matrix->Element[0][2] = Rz[0];
797     matrix->Element[1][2] = Rz[1];
798     matrix->Element[2][2] = Rz[2];
799     
800     this->Transform->Concatenate(matrix);
801     }
802   
803   // translate to projection reference point PRP
804   // this is the camera's position blasted through
805   // the current matrix
806   p1[0] = this->Origin[0] + this->Position[0];
807   p1[1] = this->Origin[1] + this->Position[1];
808   p1[2] = this->Origin[2] + this->Position[2];
809
810   this->Transform->Translate(p1[0],p1[1],p1[2]);
811   this->Transform->GetMatrix(result);
812   
813   matrix->Delete();
814   this->Transform->Pop();  
815 }  
816
817