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 : PV_Tools.cxx
24 // Author : Alexey PETROV
28 #include "PARAVIS_Gen_i.hh"
30 #include <omnithread.h>
31 #include CORBA_SERVER_HEADER(SALOME_Session)
32 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
34 #include <SALOME_NamingService.hxx>
40 //----------------------------------------------------------------------------
41 SALOMEDS::ListOfFileNames* GetListOfFileNames(const QStringList& theFileNames)
43 SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
44 if(!theFileNames.isEmpty()){
45 aListOfFileNames->length(theFileNames.size());
47 foreach (QString aName, theFileNames) {
48 aListOfFileNames[i] = qPrintable(aName);
52 return aListOfFileNames._retn();
55 //----------------------------------------------------------------------------
56 SALOMEDS::SComponent_var FindOrCreateParaVisComponent(SALOMEDS::Study_ptr theStudyDocument)
58 SALOMEDS::SComponent_var aSComponent = theStudyDocument->FindComponent("PARAVIS");
59 if (aSComponent->_is_nil()) {
60 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
61 aStudyBuilder->NewCommand();
62 int aLocked = theStudyDocument->GetProperties()->IsLocked();
63 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
64 aSComponent = aStudyBuilder->NewComponent("PARAVIS");
65 SALOMEDS::GenericAttribute_var anAttr =
66 aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
67 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
69 CORBA::ORB_var anORB = PARAVIS_Gen_i::GetORB();
70 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
71 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
72 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
73 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
74 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "PARAVIS" );
75 if ( !CORBA::is_nil(Comp) ) {
76 aName->SetValue( Comp->componentusername() );
79 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
80 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
81 aPixmap->SetPixMap( "pqAppIcon16.png" );
83 PARAVIS_Gen_var aParaVisGen = PARAVIS_Gen_i::GetParavisGenImpl()->_this();
84 aStudyBuilder->DefineComponentInstance(aSComponent, aParaVisGen);
86 theStudyDocument->GetProperties()->SetLocked(true);
87 aStudyBuilder->CommitCommand();
92 PARAVIS_Base_i* GET_SERVANT(CORBA::Object_ptr aObj) {
93 //dynamic_cast<PARAVIS_Base_i*>(PARAVIS_Gen_i::GetPOA()->reference_to_servant(OBJ).in())
94 if (CORBA::is_nil(aObj))
97 PortableServer::POA_ptr aPOA = PARAVIS_Gen_i::GetPOA();
98 PortableServer::ServantBase_var aServant = aPOA->reference_to_servant(aObj);
99 return dynamic_cast<PARAVIS_Base_i*>(aServant.in());
101 MESSAGE("GET_SERVANT: Unknown exception!!!");