Back to index

salome-paravis  6.5.0
PVGUI_Tools.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 //  File   : PVGUI_Tools.cxx
00020 //  Author : Vitaly Smetannikov
00021 //  Module : PARAVIS
00022 
00023 #include "PVGUI_Tools.h"
00024 #include "CAM_Module.h"
00025 #include "SALOME_LifeCycleCORBA.hxx"
00026 #include "SalomeApp_Application.h"
00027 #include "SalomeApp_Study.h"
00028 #include <stdexcept>
00029 
00030 using namespace std;
00031 
00032 //=============================================================================
00033 namespace PARAVIS
00034 {
00035   //------------------------------------------------------------
00036   PARAVIS_Gen_i* GetParavisGen(const CAM_Module* theModule)
00037   {
00038     static PARAVIS_Gen_i* aGen = NULL;
00039     if(!aGen){
00040       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
00041       Engines::EngineComponent_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","PARAVIS");
00042       PARAVIS_Gen_var aPARAVIS = PARAVIS_Gen::_narrow(aComponent);
00043       if(!CORBA::is_nil(aPARAVIS)){
00044         aGen = PARAVIS_Gen_i::GetParavisGenImpl();
00045       }
00046     }
00047     if(!aGen)
00048       throw std::runtime_error("Can not create PARAVIS_Gen");
00049     return aGen;
00050   }
00051 
00052   //------------------------------------------------------------
00053   _PTR(Study) GetCStudy(const CAM_Module* theModule)
00054   {
00055     if (theModule && theModule->application()) {
00056       SalomeApp_Study* activeStudy = 
00057        dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
00058       if (activeStudy) {
00059        return activeStudy->studyDS();
00060       }
00061     }
00062     
00063     return _PTR(Study)();
00064   }
00065 }