geom/src/GEOM_I/GEOM_Gen_i.hh

402 lines
17 KiB
C++
Raw Normal View History

2019-02-14 15:09:13 +05:00
// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
2005-12-05 21:23:52 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2005-12-05 21:23:52 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2014-02-18 12:44:41 +06:00
//
2012-08-09 13:58:02 +06:00
2004-12-01 15:39:14 +05:00
#ifndef __GEOM_GEN_I_H__
#define __GEOM_GEN_I_H__
#include "GEOM_GEOM_I.hxx"
2004-12-01 15:39:14 +05:00
#include "GEOMImpl_Gen.hxx"
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_CLIENT_HEADER(SALOMEDS)
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
2004-12-01 15:39:14 +05:00
#include "SALOME_Component_i.hxx"
2004-12-01 15:39:14 +05:00
#include "SALOME_NamingService.hxx"
#include "GEOM_IBasicOperations_i.hh"
#include "GEOM_ITransformOperations_i.hh"
#include "GEOM_I3DPrimOperations_i.hh"
#include "GEOM_IShapesOperations_i.hh"
#include "GEOM_IBlocksOperations_i.hh"
#include "GEOM_IBooleanOperations_i.hh"
#include "GEOM_ICurvesOperations_i.hh"
#include "GEOM_ILocalOperations_i.hh"
#include "GEOM_IHealingOperations_i.hh"
#include "GEOM_IInsertOperations_i.hh"
#include "GEOM_IMeasureOperations_i.hh"
#include "GEOM_IGroupOperations_i.hh"
#include "GEOM_IFieldOperations_i.hh"
#include "GEOMUtils.hxx"
2012-08-09 13:58:02 +06:00
#include <TopTools_IndexedMapOfShape.hxx>
2016-02-24 18:45:13 +05:00
#include <TopTools_SequenceOfShape.hxx>
2012-08-09 13:58:02 +06:00
#include <map>
2012-08-09 13:58:02 +06:00
#include <set>
#include <list>
2012-08-09 13:58:02 +06:00
#include <string>
2004-12-01 15:39:14 +05:00
//#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=====================================================================
// Generic operations creator (for plugins mechanism)
//=====================================================================
class GEOM_I_EXPORT GEOM_GenericOperationsCreator
{
public:
// Create operations
virtual GEOM_IOperations_i* Create (PortableServer::POA_ptr thePOA,
GEOM::GEOM_Gen_ptr theEngine,
::GEOMImpl_Gen* theGenImpl) = 0;
// return the name of IDL module
//virtual std::string GetModuleName() = 0;
virtual ~GEOM_GenericOperationsCreator() {}
};
2004-12-01 15:39:14 +05:00
//=====================================================================
// GEOM_Gen_i : class definition
//=====================================================================
class GEOM_I_EXPORT GEOM_Gen_i: virtual public POA_GEOM::GEOM_Gen, virtual public Engines_Component_i
2004-12-01 15:39:14 +05:00
{
public:
//-----------------------------------------------------------------------//
// Constructor / Destructor //
//-----------------------------------------------------------------------//
// constructor to be called for servant creation.
2004-12-01 15:39:14 +05:00
GEOM_Gen_i();
GEOM_Gen_i(CORBA::ORB_ptr orb,
2012-08-09 13:58:02 +06:00
PortableServer::POA_ptr poa,
PortableServer::ObjectId * contId,
const char *instanceName,
const char *interfaceName);
2004-12-01 15:39:14 +05:00
// destructor, doing nothing (for now)
virtual ~GEOM_Gen_i();
// generic method to be put in a super class
void register_name(char * name);
2013-02-28 20:00:05 +06:00
// Get ORB object
CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
// Get Naming Service object
SALOME_NamingService* GetNS() { return name_service; }
2004-12-01 15:39:14 +05:00
2017-06-13 14:57:14 +05:00
// Get Study
SALOMEDS::Study_var getStudyServant();
2004-12-01 15:39:14 +05:00
//-----------------------------------------------------------------------//
// Inherited methods from SALOMEDS::Driver //
//-----------------------------------------------------------------------//
2004-12-01 15:39:14 +05:00
SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
2012-08-09 13:58:02 +06:00
const char* theURL,
bool isMultiFile);
2004-12-01 15:39:14 +05:00
SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
2012-08-09 13:58:02 +06:00
const char* theURL,
bool isMultiFile);
2004-12-01 15:39:14 +05:00
CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
2012-08-09 13:58:02 +06:00
const SALOMEDS::TMPFile& theStream,
const char* theURL,
bool isMultiFile);
2004-12-01 15:39:14 +05:00
CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
2012-08-09 13:58:02 +06:00
const SALOMEDS::TMPFile& theStream,
const char* theURL,
bool isMultiFile);
2004-12-01 15:39:14 +05:00
void Close(SALOMEDS::SComponent_ptr theComponent);
char* ComponentDataType();
char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
2012-08-09 13:58:02 +06:00
const char* IORString,
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII);
2004-12-01 15:39:14 +05:00
char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
2012-08-09 13:58:02 +06:00
const char* aLocalPersistentID,
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII);
2004-12-01 15:39:14 +05:00
bool CanPublishInStudy(CORBA::Object_ptr theIOR);
2017-06-13 14:57:14 +05:00
SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::SObject_ptr theSObject,
2012-08-09 13:58:02 +06:00
CORBA::Object_ptr theObject,
const char* theName) throw (SALOME::SALOME_Exception) ;
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* PublishNamedShapesInStudy(CORBA::Object_ptr theObject);
2004-12-01 15:39:14 +05:00
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
2012-08-09 13:58:02 +06:00
CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject);
2004-12-01 15:39:14 +05:00
/*! \brief Adds theObject in the study with a name = theName, if
* theFather is not null the object is placed under theFather
*/
2017-06-13 14:57:14 +05:00
SALOMEDS::SObject_ptr AddInStudy (GEOM::GEOM_BaseObject_ptr theObject,
const char* theName,
GEOM::GEOM_BaseObject_ptr theFather);
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
/*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
* To be used from python scripts out of geompy.addToStudy (non-default usage)
*/
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreSubShapesO (GEOM::GEOM_Object_ptr theObject,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix);
/*! \brief Publish sub-shapes, standing for given in \a theArgs arguments and sub-shapes.
* To be used from python scripts, generated by Dump Python.
*/
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreGivenSubShapesO (GEOM::GEOM_Object_ptr theObject,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix);
2009-02-13 17:16:39 +05:00
/*! \brief Publish sub-shapes, standing for arguments and sub-shapes of arguments.
* To be used from GUI and from geompy.addToStudy
*/
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreSubShapesSO (SALOMEDS::SObject_ptr theSObject,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix);
2009-02-13 17:16:39 +05:00
//Collects dependencies of the given objects from other ones
2017-06-13 14:57:14 +05:00
SALOMEDS::TMPFile* GetDependencyTree(const GEOM::string_array& theObjectEntries);
2014-05-16 18:49:16 +06:00
2004-12-01 15:39:14 +05:00
//-----------------------------------------------------------------------//
// Transaction methods //
//-----------------------------------------------------------------------//
2017-06-13 14:57:14 +05:00
//Undos one transaction in the document
virtual void Undo();
2004-12-01 15:39:14 +05:00
2017-06-13 14:57:14 +05:00
//Redos one transaction in the document
virtual void Redo();
2004-12-01 15:39:14 +05:00
//-----------------------------------------------------------------------//
// Operations methods //
//-----------------------------------------------------------------------//
2004-12-01 15:39:14 +05:00
//Returns a pointer to BasicOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IBasicOperations_ptr GetIBasicOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
2004-12-01 15:39:14 +05:00
//Returns a pointer to TransformOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_ITransformOperations_ptr GetITransformOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to 3DPrimOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_I3DPrimOperations_ptr GetI3DPrimOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to ShapesOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IShapesOperations_ptr GetIShapesOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to BlocksOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IBlocksOperations_ptr GetIBlocksOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to BooleanOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IBooleanOperations_ptr GetIBooleanOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to CurvesOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_ICurvesOperations_ptr GetICurvesOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to LocalOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_ILocalOperations_ptr GetILocalOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to HealingOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IHealingOperations_ptr GetIHealingOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to InsertOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IInsertOperations_ptr GetIInsertOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to MeasureOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IMeasureOperations_ptr GetIMeasureOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to GroupOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IGroupOperations_ptr GetIGroupOperations()
2004-12-01 15:39:14 +05:00
throw (SALOME::SALOME_Exception);
//Returns a pointer to FiedlOperations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IFieldOperations_ptr GetIFieldOperations()
throw (SALOME::SALOME_Exception);
//Returns a pointer to corresponding plugin operations interface
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (const char* theLibName)
2012-08-09 13:58:02 +06:00
throw (SALOME::SALOME_Exception);
//Adds a new sub-shape
virtual GEOM::GEOM_Object_ptr AddSubShape (GEOM::GEOM_Object_ptr theMainShape,
2012-08-09 13:58:02 +06:00
const GEOM::ListOfLong& theIndices);
2004-12-01 15:39:14 +05:00
virtual void RemoveObject(GEOM::GEOM_BaseObject_ptr theObject);
2004-12-01 15:39:14 +05:00
virtual char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject);
virtual GEOM::GEOM_Object_ptr GetIORFromString(const char* stringIOR);
2017-06-13 14:57:14 +05:00
virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
2012-08-09 13:58:02 +06:00
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
char* GetDumpName (const char* theStudyEntry);
GEOM::string_array* GetAllDumpNames();
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// Object information
virtual bool hasObjectInfo();
2017-06-13 14:57:14 +05:00
virtual char* getObjectInfo(const char* entry);
2012-08-09 13:58:02 +06:00
2012-12-13 14:40:36 +06:00
// Version information
virtual char* getVersion();
// Create a new folder object
2015-07-28 19:40:24 +05:00
SALOMEDS::SObject_ptr CreateFolder(const char* theName,
SALOMEDS::SObject_ptr theFather);
// Move GEOM object to the specified folder
2015-07-28 19:40:24 +05:00
void MoveToFolder(GEOM::GEOM_Object_ptr theObject,
SALOMEDS::SObject_ptr theFolder);
// Move list of GEOM objects to the specified folder
2015-07-28 19:40:24 +05:00
void MoveListToFolder (const GEOM::ListOfGO& theListOfGO,
SALOMEDS::SObject_ptr theFolder);
// Move objects to the specified position
void Move( const GEOM::object_list& what,
2015-07-28 19:40:24 +05:00
SALOMEDS::SObject_ptr where,
CORBA::Long row );
2013-10-11 18:50:25 +06:00
/*! \brief Fills 3 lists that is used to clean study of redundant objects.
* To be used from GUI.
*/
2017-06-13 14:57:14 +05:00
void GetEntriesToReduceStudy(GEOM::string_array& theSelectedEntries,
2015-07-28 19:40:24 +05:00
GEOM::string_array& theParentEntries,
GEOM::string_array& theSubEntries,
GEOM::string_array& theOtherEntries);
//-----------------------------------------------------------------------//
// Internal methods //
//-----------------------------------------------------------------------//
2017-06-13 14:57:14 +05:00
virtual GEOM::GEOM_BaseObject_ptr GetObject(const char* theEntry);
2004-12-01 15:39:14 +05:00
2009-02-13 17:16:39 +05:00
private:
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreSubShapes (GEOM::GEOM_Object_ptr theObject,
2012-08-09 13:58:02 +06:00
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix);
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreSubShapesOneLevel (SALOMEDS::SObject_ptr theOldSO,
2012-08-09 13:58:02 +06:00
SALOMEDS::SObject_ptr theNewSO,
GEOM::GEOM_Object_ptr theNewO,
GEOM::ListOfGO& theOutArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theAddPrefix);
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreGivenSubShapes (GEOM::GEOM_Object_ptr theObject,
2012-08-09 13:58:02 +06:00
SALOMEDS::SObject_ptr theSObject,
const GEOM::ListOfGO& theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theInheritFirstArg,
CORBA::Boolean theAddPrefix);
2017-06-13 14:57:14 +05:00
GEOM::ListOfGO* RestoreGivenSubShapesOneLevel (SALOMEDS::SObject_ptr theOldSO,
2012-08-09 13:58:02 +06:00
SALOMEDS::SObject_ptr theNewSO,
GEOM::GEOM_Object_ptr theNewO,
std::set<std::string> theArgs,
GEOM::find_shape_method theFindMethod,
CORBA::Boolean theAddPrefix);
// auxilary for PublishNamedShapesInStudy
2017-06-13 14:57:14 +05:00
void CreateAndPublishGroup(GEOM::GEOM_Object_var theMainShape,
2012-08-09 13:58:02 +06:00
const TopTools_IndexedMapOfShape& anIndices,
const TopTools_SequenceOfShape& SeqS,
const TColStd_SequenceOfAsciiString& SeqN,
const Standard_CString& GrName,
GEOM::ListOfGO_var aResList);
2009-02-13 17:16:39 +05:00
2015-07-28 19:40:24 +05:00
void getUpwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &upLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level = 0 );
2015-07-28 19:40:24 +05:00
void getDownwardDependency( GEOM::GEOM_BaseObject_ptr gbo,
GEOMUtils::LevelsList &downLevelList,
std::map< std::string, std::set<std::string> > &passedEntries,
int level = 0 );
void includeParentDependencies(GEOM::GEOM_BaseObject_ptr gbo,
2015-07-28 19:40:24 +05:00
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
2017-06-13 14:57:14 +05:00
void includeSubObjects(const std::string& aSelectedEntry,
2015-07-28 19:40:24 +05:00
std::set<std::string>& aSelected,
std::set<std::string>& aParents,
std::set<std::string>& aChildren,
std::set<std::string>& anOthers);
void LoadPlugin(const std::string& theLibName);
2019-12-23 16:55:03 +05:00
virtual void BreakLink(const char*) {}
2004-12-01 15:39:14 +05:00
private:
2004-12-01 15:39:14 +05:00
::GEOMImpl_Gen* _impl;
SALOME_NamingService * name_service;
char * _name;
// plugin operations managing
std::map<std::string, GEOM_GenericOperationsCreator*> myOpCreatorMap;
2004-12-01 15:39:14 +05:00
};
#endif