1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File : VISU_Vectors_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_VectorsPL.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_Vectors_i.hh"
30 #include "VISU_VectorsAct.h"
36 static int MYDEBUG = 0;
37 static int MYDEBUGWITHFILES = 0;
39 static int MYDEBUG = 0;
40 static int MYDEBUGWITHFILES = 0;
43 int VISU::Vectors_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
44 const char* theFieldName, int theIteration)
46 return DeformedShape_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
50 int VISU::Vectors_i::myNbPresent = 0;
51 QString VISU::Vectors_i::GenerateName() { return VISU::GenerateName("Vectors",myNbPresent++);}
54 const string VISU::Vectors_i::myComment = "VECTORS";
55 const char* VISU::Vectors_i::GetComment() const { return myComment.c_str();}
58 VISU::Vectors_i::Vectors_i(Result_i* theResult, bool theAddToStudy) :
59 PrsObject_i(theResult->GetStudyDocument()),
61 ScalarMap_i(theResult, theAddToStudy),
62 DeformedShape_i(theResult, theAddToStudy)
68 void VISU::Vectors_i::Destroy(){
69 DeformedShape_i::Destroy();
73 void VISU::Vectors_i::SameAs(const VISU::Vectors_i* theOrigin) {
74 Vectors_i* aVectors = const_cast<Vectors_i*>(theOrigin);
75 VISU::DeformedShape_i::SameAs(theOrigin);
77 SetLineWidth(aVectors->GetLineWidth());
78 //SetGlyphType(aVectors->GetGlyphType());
79 //SetGlyphPos(aVectors->GetGlyphPos());
83 VISU::Storable* VISU::Vectors_i::Create(const char* theMeshName, VISU::Entity theEntity,
84 const char* theFieldName, int theIteration)
87 return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration);
91 VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap)
92 throw(std::logic_error&)
94 DeformedShape_i::Restore(theMap);
96 SetGlyphType(VISU::Vectors::GlyphType(VISU::Storable::FindValue(theMap,"myTypeGlyph").toInt()));
97 SetGlyphPos(VISU::Vectors::GlyphPos(VISU::Storable::FindValue(theMap,"myPosGlyph").toInt()));
98 SetLineWidth(VISU::Storable::FindValue(theMap,"myLineWidth").toDouble());
103 void VISU::Vectors_i::ToStream(std::ostringstream& theStr){
104 DeformedShape_i::ToStream(theStr);
106 Storable::DataToStream( theStr, "myTypeGlyph", int(GetGlyphType()));
107 Storable::DataToStream( theStr, "myPosGlyph", int(GetGlyphPos()));
108 Storable::DataToStream( theStr, "myLineWidth", GetLineWidth());
111 VISU::Storable* VISU::Vectors_i::Restore(SALOMEDS::SObject_ptr theSObject,
112 const string& thePrefix, const Storable::TRestoringMap& theMap)
113 throw(std::logic_error&)
115 VISU::Result_i* pResult = GetResult(theSObject);
117 VISU::Vectors_i* pResent = new VISU::Vectors_i(pResult);
118 return pResent->Restore(theMap);
124 VISU::Vectors_i::~Vectors_i(){
125 if(MYDEBUG) MESSAGE("Vectors_i::~Vectors_i()");
129 void VISU::Vectors_i::SetLineWidth(CORBA::Double theWidth) {
130 myLineWidth = theWidth;
132 CORBA::Double VISU::Vectors_i::GetLineWidth() {
137 void VISU::Vectors_i::SetGlyphType(VISU::Vectors::GlyphType theType) {
138 myVectorsPL->SetGlyphType(VISU_VectorsPL::GlyphType(theType));
140 VISU::Vectors::GlyphType VISU::Vectors_i::GetGlyphType() {
141 return VISU::Vectors::GlyphType(myVectorsPL->GetGlyphType());
145 void VISU::Vectors_i::SetGlyphPos(VISU::Vectors::GlyphPos thePos) {
146 myVectorsPL->SetGlyphPos(VISU_VectorsPL::GlyphPos(thePos));
148 VISU::Vectors::GlyphPos VISU::Vectors_i::GetGlyphPos() {
149 return VISU::Vectors::GlyphPos(myVectorsPL->GetGlyphPos());
153 void VISU::Vectors_i::DoHook(){
154 if(!myPipeLine) myPipeLine = VISU_VectorsPL::New();
155 myVectorsPL = dynamic_cast<VISU_VectorsPL*>(myPipeLine);
157 DeformedShape_i::DoHook();
161 VISU_PipeLine* VISU::Vectors_i::GetPipeLine(){
162 VISU_PipeLine* aPipeLine = VISU_VectorsPL::New();
163 aPipeLine->ShallowCopy(myPipeLine);
169 VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
170 throw (std::runtime_error&)
172 VISU_VectorsAct* anActor = VISU_VectorsAct::New();
174 VISU::Prs3d_i::CreateActor(anActor,theIO);
175 anActor->SetBarVisibility(true);
176 anActor->myFieldName = myFieldName;
177 anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
178 anActor->GetProperty()->SetLineWidth(GetLineWidth());
179 UpdateActor(anActor);
180 }catch(std::runtime_error& exc){
188 void VISU::Vectors_i::UpdateActor(VISU_Actor* theActor){
189 if(VISU_VectorsAct* anActor = dynamic_cast<VISU_VectorsAct*>(theActor)){
190 VISU::DeformedShape_i::UpdateActor(anActor);
191 anActor->GetProperty()->SetLineWidth(GetLineWidth());
192 if(VISU_VectorsPL* aVectorsPL = dynamic_cast<VISU_VectorsPL*>(anActor->GetPipeLine())){
193 aVectorsPL->ShallowCopy(myPipeLine);
194 aVectorsPL->Update();
195 aVectorsPL->SetMapScale(myVectorsPL->GetMapScale());