]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_Prs3d_i.cc
Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / VISU_I / VISU_Prs3d_i.cc
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //  File   : VISU_Prs3d_i.cc
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_PipeLine.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_Prs3d_i.hh"
30 #include "VISU_Actor.h"
31 using namespace VISU;
32 using namespace std;
33
34 #ifdef _DEBUG_
35 static int MYDEBUG = 1;
36 static int MYDEBUGWITHFILES = 0;
37 #else
38 static int MYDEBUG = 0;
39 static int MYDEBUGWITHFILES = 0;
40 #endif
41
42 VISU::Prs3d_i::Prs3d_i(Result_i* theResult) : 
43        PrsObject_i(theResult->GetStudyDocument()), 
44        myResult(theResult) 
45 {
46   myAddToStudy = true;
47   myPipeLine = NULL;
48 }
49
50 void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin)
51 {
52   Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin);
53   myPipeLine->ShallowCopy(aOrigin->GetPL());
54 }
55
56 VISU::Prs3d_i::~Prs3d_i() {
57   if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i()");
58   myPipeLine->Delete();
59 }
60
61 void VISU::Prs3d_i::Destroy() {
62   CORBA::Object_var anObj = _this();
63   PortableServer::POA_ptr aPOA = Base_i::GetPOA();
64   PortableServer::ObjectId_var anId = aPOA->reference_to_id(anObj);
65   aPOA->deactivate_object(anId.in());
66   this->_remove_ref();
67 }
68
69
70 void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
71   throw (std::runtime_error&)
72 {
73   try{
74     Update();
75     if(myAddToStudy){
76       Handle(SALOME_InteractiveObject) anIO = theIO;
77       if (anIO.IsNull())
78         anIO = new SALOME_InteractiveObject(strdup(GetEntry()),"VISU",strdup(GetName()));
79       theActor->setIO(anIO); 
80     }
81     theActor->SetPipeLine(GetPipeLine());
82     theActor->SetPrs3d(this);
83   }catch(std::runtime_error& ex){
84     throw ex;
85   }catch(...){
86     throw std::runtime_error("Prs3d_i::CreateActor >> unexpected exception was caught!!!");
87   }
88 }
89
90 void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor){
91   theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
92   theActor->Modified();
93 }
94
95 VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap)
96      throw(std::logic_error&)
97 {
98   myName = VISU::Storable::FindValue(theMap,"myName").latin1();
99   return this;
100 }
101
102 void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){
103   Storable::DataToStream( theStr, "myName",   myName.c_str() );
104 }
105
106 void VISU::Prs3d_i::Update(){
107   myPipeLine->Update();
108 }
109
110 VISU_PipeLine* VISU::Prs3d_i::GetPipeLine(){
111   return GetPL();
112 }
113
114 VISU_PipeLine* VISU::Prs3d_i::GetPL(){
115   return myPipeLine;
116 }
117
118 VISU::Result_i* VISU::Prs3d_i::GetResult(SALOMEDS::SObject_ptr theSObject){
119   VISU::Result_var aResult = FindResult(theSObject);
120   if(!aResult->_is_nil())
121     return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()));
122   return NULL;
123 }