Back to index

salome-gui  6.5.0
SALOME_GuiServices.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
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 
00020 // Author: Guillaume Boulant (EDF/R&D)
00021 
00022 #ifndef __GUI_SERVICES_H__
00023 #define __GUI_SERVICES_H__
00024 
00025 #include <SalomeApp_Application.h>
00026 #include <SalomeApp_Study.h>
00027 #include <LightApp_SelectionMgr.h>
00028 #include <SUIT_ResourceMgr.h>
00029 
00030 #include "SALOMEconfig.h"
00031 #include CORBA_SERVER_HEADER(SALOMEDS)
00032 #include <SALOME_InteractiveObject.hxx>
00033 #include <SALOME_KernelServices.hxx>
00034 
00035 namespace GUI {
00036 
00037   // SALOME GUI main services
00038   SalomeApp_Application * getSalomeApplication();
00039   LightApp_SelectionMgr * getSelectionManager();
00040   SUIT_ResourceMgr      * getResourcesManager();
00041 
00042   // Helper functions to deal with the study in a GUI context.
00043   //
00044   // First of all, in a GUI context, there is one of the opened
00045   // studies that is considered as active. Please note that the active
00046   // study is a GUI concept and it can be obtained only in the
00047   // SALOME_SessionServer process, i.e. the process that embeds the
00048   // SalomeApp_Application. The concept of active study doesn't make
00049   // sense outside of the GUI context.
00050   //
00051   // The active study is associated with an GUI Objects Browser that
00052   // displays a graphical representation of the study. The items that
00053   // can be selected in the Objects Browser are name Interactive
00054   // Objects (instance of class SALOME_InteractiveObject). To work
00055   // with data, we have to retrieve from this Interactive Object (IO)
00056   // the underlying Study Object (instance of class SALOMEDS::SObject)
00057   // and from this last the data object that can be anything (that
00058   // depends of the SALOME module technical choices). In general, on
00059   // of the attribute of a SObject is a CORBA servant that handles the
00060   // data to work with
00061   SALOMEDS::Study_ptr getActiveStudy();
00062   int                 getActiveStudyId();
00063 
00064   // Another way to get the active study (to be converted in
00065   // SALOMEDS::Study):
00066   SalomeApp_Study   * getSalomeAppActiveStudy();
00067 
00068   SALOMEDS::SObject_ptr IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject);
00069 
00070   template<class TInterface> typename TInterface::_var_type
00071   IObjectToInterface(const Handle(SALOME_InteractiveObject)& iobject) {
00072     SALOMEDS::SObject_ptr sobject = IObjectToSObject(iobject);
00073     return KERNEL::SObjectToInterface<TInterface>(sobject);
00074   }
00075   // _MEM_: note that template functions have to be declared AND
00076   // implemented in the header because they are not compiled in this
00077   // library but in every client library that includes this header
00078   // file. The effective compilation depends on the particular class
00079   // used for TInterface.
00080 
00081 
00082 }
00083 
00084 #endif // GUI_SERVICES