Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / OBJECT / VISU_Actor.cxx
1 using namespace std;
2 //  File      : VISU_Actor.cxx
3 //  Created   : Wed Feb 20 18:04:42 CET 2002
4 //  Author    : Laurent CORNABE with help of Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : VISU
7 //  Copyright : PRINCIPIA RD
8 //  $Header$
9
10 #include "VISU_Actor.h"
11 #include "utilities.h"
12  
13 // VTK Includes
14 #include <vtkObjectFactory.h>
15
16 VISU_Actor* VISU_Actor::New(){
17   vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_Actor");
18   if(ret) return (VISU_Actor*)ret;
19   return new VISU_Actor;
20
21 VISU_Actor::VISU_Actor(){
22   this->Device = vtkActor::New();
23
24   this->EdgeDevice = vtkActor::New();
25   EdgeDevice->VisibilityOff();
26   EdgeDevice->PickableOff();
27
28   this->DataSource = NULL;
29   myScalarBar = NULL;
30   this->myIO = NULL;
31   this->myName = "";
32   this->IsDefined = false;
33   this->IsShrunk = false;
34   this->IsShrinkable = false;
35   this->VisuActorType = 0;
36   this->Presentation = NULL;
37   myHasScalarBar = false;
38   this->HighlightProperty = NULL;
39   this->ishighlighted = false;
40   this->IsHighlighting = true;
41   this->ResultAtNode = false;
42   this->VectorComponent = -1;
43   for (int i=0; i<6; i++)
44           this->VABounds[i] = 0.;
45   strcpy(this->FieldName,"");
46 }
47
48
49 VISU_Actor::~VISU_Actor()
50 {
51   this->EdgeDevice->Delete();  
52 }
53
54
55 void VISU_Actor::setScalarBar(VISU_ScalarBarActor* theBar) {
56   if (theBar) {
57     myScalarBar = theBar;
58     myHasScalarBar = true;
59   } else {
60     myScalarBar = NULL;
61     myHasScalarBar = false;
62   }
63 }
64
65
66 void VISU_Actor::setActor(vtkActor *Actor){
67   this->Device=Actor;
68 }
69
70 void VISU_Actor::ShallowCopy(vtkProp *prop){
71   VISU_Actor *f = VISU_Actor::SafeDownCast(prop);
72   if ( f != NULL )
73     {
74       setName( f->getName() );
75       if ( f->hasIO() )
76         setIO( f->getIO() );
77     }
78   SALOME_Actor::ShallowCopy(prop);
79 }
80
81 void VISU_Actor::highlight(Standard_Boolean highlight) {
82   if (this->IsHighlighting) {
83     if(highlight && !ishighlighted) {
84       ishighlighted=true;
85       // build highlight property is necessary
86       if(HighlightProperty==NULL) {
87         HighlightProperty = vtkProperty::New();
88         HighlightProperty->SetAmbient(0.5);
89         HighlightProperty->SetDiffuse(0.3);
90         HighlightProperty->SetSpecular(0.2);
91         HighlightProperty->SetRepresentationToSurface();
92         HighlightProperty->SetAmbientColor(1, 1, 1);
93         HighlightProperty->SetDiffuseColor(1, 1, 1);
94         HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5);
95       }
96       this->Property = HighlightProperty;
97     }else if (!highlight) {
98       if(ishighlighted) {
99         ishighlighted=false;
100       }
101     }
102   }
103 }
104
105
106 void VISU_Actor::setVABounds(const float bounds[6]){
107   for (int i=0; i<6; i++)
108     VABounds[i] = bounds[i];
109 }
110
111
112 void VISU_Actor::getVABounds(float bounds[6]){
113   for (int i=0; i<6; i++)
114     bounds[i] = VABounds[i];
115 }
116