0023546: [EDF] AsterStudy: add a method to Python API to show/hide orientation vectors of faces

+ Redesign SMESH GUI Python API (libSMESH_Swig)
+ Add a lot of new methods to manage visualization attributes and properties of mesh presentations
This commit is contained in:
vsr 2018-04-17 16:50:41 +03:00
parent bcace202dd
commit 9374764094
4 changed files with 2148 additions and 1121 deletions

View File

@ -492,7 +492,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy
// Publishing a hypothesis or algorithm // Publishing a hypothesis or algorithm
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR ); SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR );
if ( aSO->_is_nil() && !aHyp->_is_nil() ) if ( aSO->_is_nil() && !aHyp->_is_nil() )
aSO = PublishHypothesis( theStudy, aHyp ); aSO = PublishHypothesis( theStudy, aHyp, theName );
// Publishing a group // Publishing a group
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR); SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR);

File diff suppressed because it is too large Load Diff

View File

@ -17,135 +17,199 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// SMESH SMESH : GUI for SMESH component
// File : libSMESH_Swig.h
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
//
#ifndef LIBSMESH_SWIG_H #ifndef LIBSMESH_SWIG_H
#define LIBSMESH_SWIG_H #define LIBSMESH_SWIG_H
#ifdef WIN32 #ifdef WIN32
#if defined SMESH_SWIG_EXPORTS || defined _libSMESH_Swig_EXPORTS #if defined SMESH_SWIG_EXPORTS || defined _libSMESH_Swig_EXPORTS
#define SMESH_SWIG_EXPORT __declspec( dllexport ) #define SMESH_SWIG_EXPORT __declspec(dllexport)
#else #else
#define SMESH_SWIG_EXPORT __declspec( dllimport ) #define SMESH_SWIG_EXPORT __declspec(dllimport)
#endif #endif
#else #else
#define SMESH_SWIG_EXPORT #define SMESH_SWIG_EXPORT
#endif #endif
// IDL includes #include <SVTK_Selection.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
//std includes
#include <vector> #include <vector>
#include <utility>
#include <SVTK_Selection.h>
#include <SVTK_Selection.h>
// See SMESH_Actor.h
typedef enum typedef enum
{ {
Undefined = -1, EntityNone = 0x00,
Node = NodeSelection, Entity0d = 0x01, // SMESH_Actor::e0DElements
Cell = CellSelection, EntityEdges = 0x02, // SMESH_Actor::eEdges
EdgeOfCell = EdgeOfCellSelection, EntityFaces = 0x04, // SMESH_Actor::eFaces
Edge = EdgeSelection, EntityVolumes = 0x08, // SMESH_Actor::eVolumes
Face = FaceSelection, EntityBalls = 0x10, // SMESH_Actor::eBallElem
Volume = VolumeSelection, EntityAll = 0xff // SMESH_Actor::eAllEntity
Actor = ActorSelection, } EntityMode;
Elem0D = Elem0DSelection,
Ball = BallSelection
} SelectionMode;
typedef struct // See SVTK_Selection.h
typedef enum
{
Undefined = -1,
Node = NodeSelection,
Cell = CellSelection,
EdgeOfCell = EdgeOfCellSelection,
Edge = EdgeSelection,
Face = FaceSelection,
Volume = VolumeSelection,
Actor = ActorSelection,
Elem0D = Elem0DSelection,
Ball = BallSelection
} SelectionMode;
// See SMESH_Actor.h
typedef enum
{
UndefinedMode = -1,
PointMode = 0, // SMESH_Actor::ePoint
EdgeMode, // SMESH_Actor::eEdge
SurfaceMode // SMESH_Actor::eSurface
} DisplayMode;
struct ColorData
{ {
double r, g, b; double r, g, b;
int delta; public:
} surfaceColorStruct; ColorData();
typedef struct
{
double r, g, b;
int delta;
} volumeColorStruct;
typedef struct
{
double r, g, b;
} edgeColorStruct;
typedef struct
{
double r, g, b;
} nodeColorStruct;
struct actorAspect
{
surfaceColorStruct surfaceColor;
volumeColorStruct volumeColor;
edgeColorStruct edgeColor;
nodeColorStruct nodeColor;
double opacity;
}; };
struct BicolorData
{
double r, g, b;
int delta;
public:
BicolorData();
};
struct Properties
{
ColorData nodeColor;
int markerType;
int markerScale;
ColorData edgeColor;
int edgeWidth;
BicolorData surfaceColor;
BicolorData volumeColor;
ColorData elem0dColor;
int elem0dSize;
ColorData ballColor;
double ballScale;
ColorData outlineColor;
int outlineWidth;
ColorData orientationColor;
double orientationScale;
bool orientation3d;
double shrinkFactor;
double opacity;
public:
Properties();
};
typedef ColorData nodeColorStruct; // deprecated
typedef ColorData edgeColorStruct; // deprecated
typedef BicolorData surfaceColorStruct; // deprecated
typedef BicolorData volumeColorStruct; // deprecated
typedef Properties actorAspect; // deprecated
class SMESH_SWIG_EXPORT SMESH_Swig class SMESH_SWIG_EXPORT SMESH_Swig
{ {
public: public:
SMESH_Swig(); SMESH_Swig();
~SMESH_Swig(); ~SMESH_Swig();
void Init( int ); // Initialization =============================================
void Init(int); // deprecated
const char* AddNewMesh( const char* ); // Publishing =================================================
const char* AddNewHypothesis( const char* ); const char* publish(const char*, const char* = 0);
const char* AddNewAlgorithms( const char* ); void rename(const char*, const char*);
void SetShape( const char*, const char* ); const char* AddNewMesh(const char*, const char* = 0); // deprecated
const char* AddNewHypothesis(const char*, const char* = 0); // deprecated
const char* AddNewAlgorithm(const char*, const char* = 0); // deprecated
const char* AddNewAlgorithms(const char*, const char* = 0); // deprecated
void SetHypothesis( const char*, const char* ); void SetShape(const char*, const char*); // deprecated
void SetAlgorithms( const char*, const char* );
void UnSetHypothesis( const char* ); void SetHypothesis(const char*, const char*); // deprecated
void SetAlgorithms(const char*, const char*); // deprecated
const char* AddSubMesh( const char*, const char*, int ); void UnSetHypothesis(const char*); // deprecated
const char* AddSubMeshOnShape( const char*, const char*, const char*, int );
void CreateAndDisplayActor( const char* ); const char* AddSubMesh(const char*, const char*, int, const char* = 0); // deprecated
const char* AddSubMeshOnShape(const char*, const char*, const char*, int, const char* = 0); // deprecated
void SetName( const char*, const char* ); void SetName(const char*, const char*); // deprecated
void EraseActor( const char*, const bool allViewers = false ); void SetMeshIcon(const char*, const bool, const bool); // deprecated
void UpdateActor( const char* Mesh_Entry ); // Visualization =============================================
/*! void display(const char*, int = 0, bool = true);
* \brief Set mesh icon according to compute status void erase(const char*, int = 0, bool = true);
* \param Mesh_Entry - entry of a mesh void update(const char*);
* \param isComputed - is mesh computed or not
*/
void SetMeshIcon( const char*, const bool, const bool );
actorAspect GetActorAspect(const char* Mesh_Entry, int viewId = 0 ); Properties properties(const char*, int = 0);
void SetActorAspect( const actorAspect& actorPres, const char* Mesh_Entry, int viewId = 0 ); void setProperties(const char*, const Properties&, int = 0);
void setSelectionMode( SelectionMode selectionMode ); bool nodesNumbering(const char*, int = 0);
std::vector<int> getSelected( const char* Mesh_Entry ); void setNodesNumbering(const char*, bool, int = 0);
std::vector<std::pair<int, int> > getSelectedEdgeOfCell( const char* Mesh_Entry ); bool elementsNumbering(const char*, int = 0);
void setElementsNumbering(const char*, bool, int = 0);
// --------------------- for the test purposes ----------------------- DisplayMode displayMode(const char*, int = 0);
SelectionMode getSelectionMode(); void setDisplayMode(const char*, DisplayMode, int = 0);
void select( const char *id, std::vector<int> ids, bool append = false );
void select( const char *id, int id1, bool append = false ); bool shrinkMode(const char*, int = 0);
void select( const char *id, std::vector<std::pair<int,int> >, bool apend = false ); void setShrinkMode(const char*, bool, int = 0);
double opacity(const char*, int = 0);
void setOpacity(const char*, double, int = 0);
bool isOrientationShown(const char*, int = 0);
void setOrientationShown(const char*, bool, int = 0);
int entitiesShown(const char*, int = 0);
void setEntitiesShown(const char*, int, int = 0);
bool isEntityShown(const char*, EntityMode, int = 0);
void setEntityShown(const char*, EntityMode, bool, int = 0);
void CreateAndDisplayActor(const char*); // deprecated
void EraseActor(const char*, const bool = false); // deprecated
void UpdateActor(const char* Mesh_Entry); // deprecated
actorAspect GetActorAspect(const char*, int = 0); // deprecated
void SetActorAspect(const actorAspect&, const char*, int = 0); // deprecated
// Selection =================================================
SelectionMode getSelectionMode(int = 0);
void setSelectionMode(SelectionMode, int = 0);
std::vector<int> getSelected(const char*);
std::vector<std::pair<int, int> > getSelectedEdgeOfCell(const char*);
void select(const char*, std::vector<int>, bool = false);
void select(const char*, int, bool = false);
void select(const char*, std::vector<std::pair<int,int> >, bool = false);
private: private:
SALOMEDS::Study_var myStudy; void init();
SALOMEDS::StudyBuilder_var myStudyBuilder;
SALOMEDS::SComponent_var mySComponentMesh; private:
int myCachedStudyId;
}; };
#endif // LIBSMESH_SWIG_H #endif // LIBSMESH_SWIG_H

View File

@ -17,10 +17,6 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// SMESH SMESHGUI : GUI for SMESH component
// File : libSMESH_Swig.i
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
//
%module libSMESH_Swig %module libSMESH_Swig
%{ %{
@ -38,7 +34,7 @@
// Py_END_ALLOW_THREADS // Py_END_ALLOW_THREADS
~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); } ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
private: private:
PyThreadState *_save; PyThreadState* _save;
}; };
PyAllowThreadsGuard guard; PyAllowThreadsGuard guard;
@ -50,104 +46,176 @@
%include "std_vector.i" %include "std_vector.i"
%include "std_pair.i" %include "std_pair.i"
namespace std { namespace std
{
%template(VectorInt) vector<int>; %template(VectorInt) vector<int>;
%template() std::pair<int,int>; %template() std::pair<int,int>;
%template(PairVector) std::vector<std::pair<int,int> >; %template(PairVector) std::vector<std::pair<int,int> >;
}; };
// See SMESH_Actor.h
typedef enum
{
EntityNone = 0x00,
Entity0d = 0x01, // SMESH_Actor::e0DElements
EntityEdges = 0x02, // SMESH_Actor::eEdges
EntityFaces = 0x04, // SMESH_Actor::eFaces
EntityVolumes = 0x08, // SMESH_Actor::eVolumes
EntityBalls = 0x10, // SMESH_Actor::eBallElem
EntityAll = 0xff // SMESH_Actor::eAllEntity
} EntityMode;
/* Selection mode enumeration (corresponds to constants from the SALOME_Selection.h) */ // See SVTK_Selection.h
enum SelectionMode enum SelectionMode
{ {
Undefined = -1, Undefined = -1,
Node = 0, Node = 0, // NodeSelection
Cell, Cell, // CellSelection
EdgeOfCell, EdgeOfCell, // EdgeOfCellSelection
Edge, Edge, // EdgeSelection
Face, Face, // FaceSelection
Volume, Volume, // VolumeSelection
Actor, Actor, // ActorSelection
Elem0D, Elem0D, // Elem0DSelection
Ball Ball // BallSelection
}; };
typedef struct // See SMESH_Actor.h
enum DisplayMode
{
UndefinedMode = -1,
PointMode = 0, // SMESH_Actor::ePoint
EdgeMode, // SMESH_Actor::eEdge
SurfaceMode // SMESH_Actor::eSurface
};
struct ColorData
{
double r, g, b;
};
struct BicolorData
{ {
double r, g, b; double r, g, b;
int delta; int delta;
} surfaceColorStruct; };
typedef struct struct Properties
{ {
double r, g, b; ColorData nodeColor;
int delta; int markerType;
} volumeColorStruct; int markerScale;
typedef struct ColorData edgeColor;
{ int edgeWidth;
double r, g, b;
} edgeColorStruct;
typedef struct BicolorData surfaceColor;
{ BicolorData volumeColor;
double r, g, b;
} nodeColorStruct;
struct actorAspect ColorData elem0dColor;
{ int elem0dSize;
surfaceColorStruct surfaceColor;
volumeColorStruct volumeColor; ColorData ballColor;
edgeColorStruct edgeColor; double ballScale;
nodeColorStruct nodeColor;
ColorData outlineColor;
int outlineWidth;
ColorData orientationColor;
double orientationScale;
bool orientation3d;
double shrinkFactor;
double opacity; double opacity;
}; };
typedef ColorData nodeColorStruct; // deprecated
typedef ColorData edgeColorStruct; // deprecated
typedef BicolorData surfaceColorStruct; // deprecated
typedef BicolorData volumeColorStruct; // deprecated
typedef Properties actorAspect; // deprecated
class SMESH_Swig class SMESH_Swig
{ {
public: public:
SMESH_Swig(); SMESH_Swig();
~SMESH_Swig(); ~SMESH_Swig();
void Init(int studyID); // Initialization =============================================
const char* AddNewMesh(const char* IOR); void Init(int); // deprecated
const char* AddNewHypothesis(const char* IOR);
const char* AddNewAlgorithms(const char* IOR);
void SetShape(const char* ShapeEntry, const char* MeshEntry); // Publishing =================================================
const char* publish(const char*, const char* = 0);
void rename(const char*, const char*);
void SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry); const char* AddNewMesh(const char*, const char* = 0); // deprecated
void SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry); const char* AddNewHypothesis(const char*, const char* = 0); // deprecated
const char* AddNewAlgorithms(const char*, const char* = 0); // deprecated
const char* AddNewAlgorithm(const char*, const char* = 0); // deprecated
void UnSetHypothesis(const char* Applied_Hypothesis_Entry ); void SetShape(const char*, const char*); // deprecated
const char* AddSubMesh (const char* Mesh_Entry, const char* SM_IOR, int ST); void SetHypothesis(const char*, const char*); // deprecated
const char* AddSubMeshOnShape (const char* Mesh_Entry, const char* GeomShape_Entry, const char* SM_IOR, int ST); void SetAlgorithms(const char*, const char*); // deprecated
void SetName(const char* Entry, const char* Name); void UnSetHypothesis(const char*); // deprecated
void SetMeshIcon(const char* Mesh_Entry, const bool isComputed, const bool isEmpty); const char* AddSubMesh(const char*, const char*, int, const char* = 0); // deprecated
const char* AddSubMeshOnShape (const char*, const char*, const char*, int, const char* = 0); // deprecated
void CreateAndDisplayActor( const char* Mesh_Entry ); void SetName(const char*, const char*); // deprecated
void EraseActor( const char* Mesh_Entry, const bool allViewers = false );
void UpdateActor( const char* Mesh_Entry );
void setSelectionMode( SelectionMode selectionMode); void SetMeshIcon(const char*, const bool, const bool); // deprecated
std::vector<int> getSelected( const char* Mesh_Entry );
std::vector<std::pair<int,int> > getSelectedEdgeOfCell( const char* Mesh_Entry );
actorAspect GetActorAspect(const char* Mesh_Entry, int viewId = 0 ); // Visualization =============================================
void SetActorAspect( const actorAspect& actorPres, const char* Mesh_Entry, int viewId = 0 );
void setSelectionMode( SelectionMode selectionMode); void display(const char*, int = 0, bool = true);
std::vector<int> getSelected( const char* Mesh_Entry ); void erase(const char*, int = 0, bool = true);
void update(const char*);
// --------------------- for the test purposes ----------------------- Properties properties(const char*, int = 0);
SelectionMode getSelectionMode(); void setProperties(const char*, const Properties&, int = 0);
void select( const char *id, std::vector<int> ids, bool append = false );
void select( const char *id, int id1, bool append = false );
void select( const char *id, std::vector<std::pair<int,int> >, bool apend = false );
bool nodesNumbering(const char*, int = 0);
void setNodesNumbering(const char*, bool, int = 0);
bool elementsNumbering(const char*, int = 0);
void setElementsNumbering(const char*, bool, int = 0);
DisplayMode displayMode(const char*, int = 0);
void setDisplayMode(const char*, DisplayMode, int = 0);
bool shrinkMode(const char*, int = 0);
void setShrinkMode(const char*, bool, int = 0);
double opacity(const char*, int = 0);
void setOpacity(const char*, double, int = 0);
bool isOrientationShown(const char*, int = 0);
void setOrientationShown(const char*, bool, int = 0);
int entitiesShown(const char*, int = 0);
void setEntitiesShown(const char*, int, int = 0);
bool isEntityShown(const char*, EntityMode, int = 0);
void setEntityShown(const char*, EntityMode, bool, int = 0);
void CreateAndDisplayActor(const char*); // deprecated
void EraseActor(const char*, const bool = false); // deprecated
void UpdateActor(const char*); // deprecated
actorAspect GetActorAspect(const char*, int = 0); // deprecated
void SetActorAspect(const actorAspect&, const char*, int = 0); // deprecated
// Selection =================================================
SelectionMode getSelectionMode(int = 0);
void setSelectionMode(SelectionMode, int = 0);
std::vector<int> getSelected(const char*);
std::vector<std::pair<int,int> > getSelectedEdgeOfCell(const char*);
void select(const char*, std::vector<int>, bool = false);
void select(const char*, int, bool = false);
void select(const char*, std::vector<std::pair<int,int> >, bool = false);
}; };