Salome HOME
Update copyright information
[modules/visu.git] / src / VISU_I / VISU_OptionalDeformation_i.cc
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  File   : VISU_OptionalDeformation_i.cc
21 //  Author : 
22 //  Module : VISU
23 //
24 #include "VISU_OptionalDeformation_i.hh"
25 #include "VISU_Result_i.hh"
26 #include "VISU_Prs3dUtils.hh"
27 #include "VISUConfig.hh"
28
29 #include "VISU_OptionalDeformationPL.hxx"
30
31
32 #ifdef _DEBUG_
33 static int MYDEBUG = 0;
34 #else
35 static int MYDEBUG = 0;
36 #endif
37
38 //---------------------------------------------------------------
39 VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::ColoredPrs3d_i *theColoredPrs3d):
40   Deformation_i(theColoredPrs3d)
41 {
42   if(MYDEBUG) MESSAGE("OptionalDeformation_i::OptionalDeformation_i()");
43 }
44
45 //---------------------------------------------------------------
46 VISU::OptionalDeformation_i::~OptionalDeformation_i()
47 {
48   if(MYDEBUG) MESSAGE("OptionalDeformation_i::~OptionalDeformation_i()");
49 }
50
51 //---------------------------------------------------------------
52 void VISU::OptionalDeformation_i::UseDeformation(CORBA::Boolean theFlag){
53   if(MYDEBUG) MESSAGE("OptionalDeformation_i::UseDeformation()");
54
55   VISU::TSetModified aModified(GetColoredPrs3d());
56
57   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_OptionalDeformationPL, bool>
58                    (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag));
59 }
60
61 //---------------------------------------------------------------
62 CORBA::Boolean VISU::OptionalDeformation_i::IsDeformed(){
63
64   if(MYDEBUG) MESSAGE("OptionalDeformation_i::IsDeformed()");
65   return GetSpecificDeformedPL()->IsDeformed();
66 }
67
68
69 void VISU::OptionalDeformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
70
71   if(MYDEBUG) MESSAGE("OptionalDeformation_i::InitDeformedPipeLine()");
72   myOptionalDeformationPL = dynamic_cast<VISU_OptionalDeformationPL*>(theDeformedPipeLine);
73
74   TSuperClass::InitDeformedPipeLine(myOptionalDeformationPL);
75 }
76
77 //---------------------------------------------------------------
78 void VISU::OptionalDeformation_i::
79 DeformationToStream(std::ostringstream& theStr)
80 {
81   Storable::DataToStream(theStr,"IsDeformed", IsDeformed());
82   if(IsDeformed())
83     TSuperClass::DeformationToStream(theStr);
84 }
85
86 //---------------------------------------------------------------
87 void
88 VISU::OptionalDeformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
89                                                 const Storable::TRestoringMap& theMap)
90 {
91   UseDeformation(Storable::FindValue(theMap,"IsDeformed").toInt());
92   if(IsDeformed())
93     TSuperClass::RestoreDeformation(theSObject,theMap);
94 }
95
96
97
98 void 
99 VISU::OptionalDeformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
100
101   if(const OptionalDeformation_i* aPrs3d = dynamic_cast<const OptionalDeformation_i*>(aDeformedPrs)){
102     OptionalDeformation_i* anOrigin = const_cast<OptionalDeformation_i*>(aPrs3d);
103     UseDeformation(anOrigin->IsDeformed());
104     
105     if(anOrigin->IsDeformed()){
106       TSuperClass::SameAsDeformation(aDeformedPrs);
107     }
108   }
109 }