1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_MonoColorPrs_i.cxx
24 // Author : Vitaly Smetannikov
27 #include "VISU_MonoColorPrs_i.hh"
28 #include "VISU_Prs3dUtils.hh"
29 #include "VISU_PipeLineUtils.hxx"
30 #include "VISU_ScalarMapAct.h"
32 #include "VISU_PipeLine.hxx"
34 #include <vtkDataSetMapper.h>
35 #include <vtkProperty.h>
38 static int MYDEBUG = 0;
40 static int MYDEBUG = 0;
43 //---------------------------------------------------------------
45 ::MonoColorPrs_i(EPublishInStudyMode thePublishInStudyMode):
46 ColoredPrs3d_i(thePublishInStudyMode),
47 ScalarMap_i(thePublishInStudyMode)
49 if(MYDEBUG) MESSAGE("MonoColorPrs_i::MonoColorPrs_i");
52 //---------------------------------------------------------------
55 ::SameAs(const Prs3d_i* theOrigin)
57 TSuperClass::SameAs(theOrigin);
59 if(const MonoColorPrs_i* aPrs3d = dynamic_cast<const MonoColorPrs_i*>(theOrigin)){
60 MonoColorPrs_i* anOrigin = const_cast<MonoColorPrs_i*>(aPrs3d);
61 SetColor(anOrigin->GetColor());
62 ShowColored(anOrigin->IsColored());
67 //---------------------------------------------------------------
70 ::Create(const std::string& theMeshName,
71 VISU::Entity theEntity,
72 const std::string& theFieldName,
73 CORBA::Long theTimeStampNumber)
76 myColor.R = myColor.G = myColor.B = 0.5;
77 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
80 //---------------------------------------------------------------
83 ::Restore(SALOMEDS::SObject_ptr theSObject,
84 const Storable::TRestoringMap& theMap)
86 if(!TSuperClass::Restore(theSObject, theMap))
89 myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
90 myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
91 myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble();
92 myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble();
97 //---------------------------------------------------------------
100 ::ToStream(std::ostringstream& theStr)
102 TSuperClass::ToStream(theStr);
104 Storable::DataToStream( theStr, "myIsColored", myIsColored );
105 Storable::DataToStream( theStr, "myColor.R", myColor.R );
106 Storable::DataToStream( theStr, "myColor.G", myColor.G );
107 Storable::DataToStream( theStr, "myColor.B", myColor.B );
111 //---------------------------------------------------------------
112 VISU::MonoColorPrs_i::~MonoColorPrs_i()
114 if(MYDEBUG) MESSAGE("MonoColorPrs_i::~MonoColorPrs_i()");
117 //---------------------------------------------------------------
118 CORBA::Boolean VISU::MonoColorPrs_i::IsColored()
125 //---------------------------------------------------------------
127 VISU::MonoColorPrs_i::ShowColored(CORBA::Boolean theColored)
129 if(myIsColored == theColored)
131 myIsColored = theColored;
132 myParamsTime.Modified();
135 //---------------------------------------------------------------
136 SALOMEDS::Color VISU::MonoColorPrs_i::GetColor()
141 //---------------------------------------------------------------
142 void VISU::MonoColorPrs_i::SetColor(const SALOMEDS::Color& theColor)
144 bool anIsSameValue = VISU::CheckIsSameValue(myColor.R, theColor.R);
145 anIsSameValue &= VISU::CheckIsSameValue(myColor.G, theColor.G);
146 anIsSameValue &= VISU::CheckIsSameValue(myColor.B, theColor.B);
150 VISU::TSetModified aModified(this);
153 myParamsTime.Modified();
156 //---------------------------------------------------------------
157 VISU_Actor* VISU::MonoColorPrs_i::CreateActor(bool toSupressShrinking)
159 VISU_Actor* anActor = TSuperClass::CreateActor(toSupressShrinking);
160 anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
164 //---------------------------------------------------------------
165 VISU_Actor* VISU::MonoColorPrs_i::CreateActor()
167 return CreateActor(false);
170 //---------------------------------------------------------------
171 void VISU::MonoColorPrs_i::UpdateActor(VISU_ActorBase* theActor)
173 if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
175 anActor->SetBarVisibility(true);
176 GetPipeLine()->GetMapper()->SetScalarVisibility(1);
178 anActor->SetBarVisibility(false);
179 GetPipeLine()->GetMapper()->SetScalarVisibility(0);
180 anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
182 TSuperClass::UpdateActor(theActor);