1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_CutSegment_i.cc
21 // Author : Oleg UVAROV
24 #include "VISU_CutSegment_i.hh"
25 #include "VISU_Prs3dUtils.hh"
26 #include "VISU_Result_i.hh"
28 #include "VISU_Actor.h"
29 #include "VISU_CutSegmentPL.hxx"
30 #include "VISU_Convertor.hxx"
31 #include "VISU_PipeLineUtils.hxx"
33 #include "SUIT_ResourceMgr.h"
34 #include "SALOME_Event.h"
36 #include <vtkAppendPolyData.h>
39 static int MYDEBUG = 0;
41 static int MYDEBUG = 0;
46 //---------------------------------------------------------------
49 ::IsPossible(Result_i* theResult,
50 const std::string& theMeshName,
51 VISU::Entity theEntity,
52 const std::string& theFieldName,
53 CORBA::Long theTimeStampNumber,
54 bool theIsMemoryCheck)
56 return TSuperClass::IsPossible(theResult,
64 //---------------------------------------------------------------
65 int VISU::CutSegment_i::myNbPresent = 0;
67 //---------------------------------------------------------------
69 VISU::CutSegment_i::GenerateName()
71 return VISU::GenerateName("CutSegment",myNbPresent++);
74 //---------------------------------------------------------------
75 const string VISU::CutSegment_i::myComment = "CUTSEGMENT";
77 //---------------------------------------------------------------
82 return myComment.c_str();
85 //----------------------------------------------------------------------------
91 return "ICON_TREE_CUT_SEGMENT";
93 return "ICON_TREE_CUT_SEGMENT_GROUPS";
96 //---------------------------------------------------------------
98 CutSegment_i(EPublishInStudyMode thePublishInStudyMode) :
99 ColoredPrs3d_i(thePublishInStudyMode),
100 ScalarMap_i(thePublishInStudyMode),
101 CutLinesBase_i(thePublishInStudyMode),
106 //---------------------------------------------------------------
109 ::SameAs(const Prs3d_i* theOrigin)
111 TSuperClass::SameAs(theOrigin);
115 //---------------------------------------------------------------
118 ::Create(const std::string& theMeshName,
119 VISU::Entity theEntity,
120 const std::string& theFieldName,
121 CORBA::Long theTimeStampNumber)
123 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
127 //---------------------------------------------------------------
130 ::Restore(SALOMEDS::SObject_ptr theSObject,
131 const Storable::TRestoringMap& theMap)
133 if(!TSuperClass::Restore(theSObject, theMap))
136 SetPoint1(VISU::Storable::FindValue(theMap,"myPoint1[0]").toDouble(),
137 VISU::Storable::FindValue(theMap,"myPoint1[1]").toDouble(),
138 VISU::Storable::FindValue(theMap,"myPoint1[2]").toDouble());
139 SetPoint2(VISU::Storable::FindValue(theMap,"myPoint2[0]").toDouble(),
140 VISU::Storable::FindValue(theMap,"myPoint2[1]").toDouble(),
141 VISU::Storable::FindValue(theMap,"myPoint2[2]").toDouble());
147 //---------------------------------------------------------------
150 ::ToStream(std::ostringstream& theStr)
152 TSuperClass::ToStream(theStr);
155 GetPoint1( aCoord[0], aCoord[1], aCoord[2] );
156 Storable::DataToStream( theStr, "myPoint1[0]", aCoord[0] );
157 Storable::DataToStream( theStr, "myPoint1[1]", aCoord[1] );
158 Storable::DataToStream( theStr, "myPoint1[2]", aCoord[2] );
160 GetPoint2( aCoord[0], aCoord[1], aCoord[2] );
161 Storable::DataToStream( theStr, "myPoint2[0]", aCoord[0] );
162 Storable::DataToStream( theStr, "myPoint2[1]", aCoord[1] );
163 Storable::DataToStream( theStr, "myPoint2[2]", aCoord[2] );
167 //---------------------------------------------------------------
171 if(MYDEBUG) MESSAGE("CutSegment_i::~CutSegment_i()");
175 //---------------------------------------------------------------
176 struct TSetPoint1Event: public SALOME_Event
178 VISU_CutSegmentPL* myCutSegmentPL;
179 CORBA::Double myX, myY, myZ;
180 TSetPoint1Event(VISU_CutSegmentPL* theCutSegment,
184 myCutSegmentPL(theCutSegment),
194 myCutSegmentPL->SetPoint1(myX, myY, myZ);
200 ::SetPoint1(CORBA::Double theX,
204 VISU::TSetModified aModified(this);
206 ProcessVoidEvent(new TSetPoint1Event(myCutSegmentPL, theX, theY, theZ));
210 //---------------------------------------------------------------
213 ::GetPoint1(CORBA::Double& theX,
217 myCutSegmentPL->GetPoint1(theX, theY, theZ);
221 //---------------------------------------------------------------
222 struct TSetPoint2Event: public SALOME_Event
224 VISU_CutSegmentPL* myCutSegmentPL;
225 CORBA::Double myX, myY, myZ;
226 TSetPoint2Event(VISU_CutSegmentPL* theCutSegment,
230 myCutSegmentPL(theCutSegment),
240 myCutSegmentPL->SetPoint2(myX, myY, myZ);
246 ::SetPoint2(CORBA::Double theX,
250 VISU::TSetModified aModified(this);
252 ProcessVoidEvent(new TSetPoint2Event(myCutSegmentPL, theX, theY, theZ));
256 //---------------------------------------------------------------
259 ::GetPoint2(CORBA::Double& theX,
263 myCutSegmentPL->GetPoint2(theX, theY, theZ);
267 //---------------------------------------------------------------
270 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
273 myCutSegmentPL = VISU_CutSegmentPL::New();
275 myCutSegmentPL = dynamic_cast<VISU_CutSegmentPL*>(thePipeLine);
277 TSuperClass::CreatePipeLine(myCutSegmentPL);
281 //----------------------------------------------------------------------------
286 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
290 //---------------------------------------------------------------
295 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
296 anActor->SetVTKMapping(true);
297 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
298 int aDispMode = aResourceMgr->integerValue("VISU", "cut_segment_represent", 2);
299 anActor->SetRepresentation(aDispMode);