NRI : First integration.

This commit is contained in:
nri 2003-05-19 14:07:00 +00:00
parent 26dabc480d
commit 3973ceea25
104 changed files with 33826 additions and 0 deletions

View File

@ -0,0 +1,13 @@
using namespace std;
#include "Document_Reader.h"
#include "utilities.h"
void Document_Reader::SetFile(string aFile) {
myFile = aFile;
}
void Document_Reader::SetDocument(Handle(SMESHDS_Document)& aDoc) {
myDocument = aDoc;
}

View File

@ -0,0 +1,18 @@
#ifndef _INCLUDE_DOCUMENT_READER
#define _INCLUDE_DOCUMENT_READER
#include "SMESHDS_Document.hxx"
#include <string>
class Document_Reader {
public :
virtual void Read() =0;
void SetFile(string);
void SetDocument(Handle(SMESHDS_Document)&);
protected :
Handle_SMESHDS_Document myDocument;
string myFile;
};
#endif

View File

@ -0,0 +1,11 @@
using namespace std;
#include "Document_Writer.h"
void Document_Writer::SetFile(string aFile) {
myFile = aFile;
}
void Document_Writer::SetDocument(Handle(SMESHDS_Document)& aDoc) {
myDocument = aDoc;
}

View File

@ -0,0 +1,19 @@
#ifndef _INCLUDE_DOCUMENT_WRITER
#define _INCLUDE_DOCUMENT_WRITER
#include "SMESHDS_Document.hxx"
#include <string>
class Document_Writer {
public :
virtual void Write() =0;
void SetFile(string);
void SetDocument(Handle(SMESHDS_Document)&);
protected :
Handle_SMESHDS_Document myDocument;
string myFile;
};
#endif

183
src/Driver/Driver_dl.cxx Normal file
View File

@ -0,0 +1,183 @@
using namespace std;
#include "Driver.h"
#include <dlfcn.h>
#include <stdio.h>
#include <utilities.h>
#include "DriverDAT_R_SMESHDS_Document.h"
#include "Test.h"
/*! extern "C"
{
void test() {
void *handle;
double (*cosine)(double);
char *error;
handle = dlopen ("/usr/lib/libm.so", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
cosine = dlsym(handle, "cos");
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
printf ("%f\n", (*cosine)(2.0));
dlclose(handle);
char* error;
string Extension=string("DAT");
string Class=string("SMESHDS_Document");
string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so");
SCRUTE(myLibrary);
//Document_Reader* myDriver;//a caster ???
DriverDAT_R_SMESHDS_Document* myDriver;
string myClass = string("Driver")+Extension+string("_R_")+Class;
SCRUTE(myClass);
void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
MESSAGE("Open ok");
//int* res = (int*)dlsym(handle, "getOne");
//SCRUTE(res);
SCRUTE(dlsym(handle, "getOne"));
//int res2= (*res)();
myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str());
MESSAGE("Reading 1");
SCRUTE(myDriver);
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
MESSAGE("Reading 2");
dlclose(handle);
MESSAGE("after close");
}
}*/
Document_Reader* Driver::GetDocumentReader(string Extension, string Class) {
test();
//p-e extern C ?
/*!
char* error;
string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so");
SCRUTE(myLibrary);
//Document_Reader* myDriver;//a caster ???
DriverDAT_R_SMESHDS_Document* myDriver;
string myClass = string("Driver")+Extension+string("_R_")+Class;
SCRUTE(myClass);
void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
MESSAGE("Open ok");
//myDriver = (Document_Reader*) dlsym(handle, myClass.c_str());
int* res = (int*) dlsym(handle, "getOne");
SCRUTE(res);
myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str());
MESSAGE("Reading 1");
SCRUTE(myDriver);
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
MESSAGE("Reading 2");
dlclose(handle);
MESSAGE("after close");
return (myDriver);
*/
}
Document_Writer* Driver::GetDocumentWriter(string Extension, string Class) {
char* error;
string myLibrary = string("libMeshDriver")+Extension+string(".so");
Document_Writer* myDriver;//a caster ???
string myClass = string("Driver")+Extension+string("_W_")+Class;
void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
myDriver = (Document_Writer*) dlsym(handle, myClass.c_str());
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
dlclose(handle);
return (myDriver);
}
Mesh_Reader* Driver::GetMeshReader(string Extension, string Class) {
char* error;
string myLibrary = string("libMeshDriver")+Extension+string(".so");
Mesh_Reader* myDriver;//a caster ???
string myClass = string("Driver")+Extension+string("_R_")+Class;
void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
myDriver = (Mesh_Reader*) dlsym(handle, myClass.c_str());
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
dlclose(handle);
return (myDriver);
}
Mesh_Writer* Driver::GetMeshWriter(string Extension, string Class) {
char* error;
string myLibrary = string("libMeshDriver")+Extension+string(".so");
Mesh_Writer* myDriver;//a caster ???
string myClass = string("Driver")+Extension+string("_W_")+Class;
void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}
myDriver = (Mesh_Writer*) dlsym(handle, myClass.c_str());
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s\n", error);
exit(1);
}
dlclose(handle);
return (myDriver);
}

39
src/Driver/Makefile.in Normal file
View File

@ -0,0 +1,39 @@
# -* Makefile *-
#
# Author : Marc Tajchman (CEA)
# Date : 5/07/2001
# $Header$
#
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@
@COMMENCE@
# header files
EXPORT_HEADERS= Document_Reader.h Document_Writer.h Mesh_Reader.h Mesh_Writer.h
# Libraries targets
LIB = libMeshDriver.la
LIB_SRC = Document_Reader.cxx Document_Writer.cxx Mesh_Reader.cxx Mesh_Writer.cxx
LIB_CLIENT_IDL =
LIB_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -rdynamic -ldl -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) -lSMESHDS -lSMDS
%_moc.cxx: %.h
$(MOC) $< -o $@
@CONCLUDE@

View File

@ -0,0 +1,3 @@
using namespace std;
#include "Mesh_Reader.h"

17
src/Driver/Mesh_Reader.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _INCLUDE_MESH_READER
#define _INCLUDE_MESH_READER
#include <string>
#include "Handle_SMDS_Mesh.hxx"
class Mesh_Reader {
public :
virtual void Add() =0;
virtual void Read() =0;
virtual void SetMesh(Handle(SMDS_Mesh)&) =0;
virtual void SetMeshId(int) =0;
virtual void SetFile(string) =0;
};
#endif

View File

@ -0,0 +1,2 @@
using namespace std;
#include "Mesh_Writer.h"

17
src/Driver/Mesh_Writer.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _INCLUDE_MESH_WRITER
#define _INCLUDE_MESH_WRITER
#include <string>
#include "Handle_SMDS_Mesh.hxx"
class Mesh_Writer {
public :
virtual void Add() =0;
virtual void Write() =0;
virtual void SetMesh(Handle(SMDS_Mesh)&) =0;
virtual void SetFile(string) =0;
virtual void SetMeshId(int) =0;
};
#endif

113
src/Driver/SMESHDriver.cxx Normal file
View File

@ -0,0 +1,113 @@
using namespace std;
#include "SMESHDriver.h"
#include <dlfcn.h>
#include <utilities.h>
//A enlever
#include "DriverMED_R_SMESHDS_Document.h"
#include "DriverMED_R_SMESHDS_Mesh.h"
#include "DriverMED_R_SMDS_Mesh.h"
#include "DriverMED_W_SMESHDS_Document.h"
#include "DriverMED_W_SMESHDS_Mesh.h"
#include "DriverMED_W_SMDS_Mesh.h"
#include "DriverDAT_R_SMESHDS_Document.h"
#include "DriverDAT_R_SMESHDS_Mesh.h"
#include "DriverDAT_R_SMDS_Mesh.h"
#include "DriverDAT_W_SMESHDS_Document.h"
#include "DriverDAT_W_SMESHDS_Mesh.h"
#include "DriverDAT_W_SMDS_Mesh.h"
//
Document_Reader* SMESHDriver::GetDocumentReader(string Extension, string Class) {
if (Extension==string("MED")) {
DriverMED_R_SMESHDS_Document* myDriver = new DriverMED_R_SMESHDS_Document();
return (myDriver);
}
else if (Extension==string("DAT")) {
DriverDAT_R_SMESHDS_Document* myDriver = new DriverDAT_R_SMESHDS_Document();
return (myDriver);
}
else {
MESSAGE("No driver known for this extension");
return (Document_Reader*)NULL;
}
}
Document_Writer* SMESHDriver::GetDocumentWriter(string Extension, string Class) {
if (Extension==string("MED")) {
DriverMED_W_SMESHDS_Document* myDriver = new DriverMED_W_SMESHDS_Document();
return (myDriver);
}
else if (Extension==string("DAT")) {
DriverDAT_W_SMESHDS_Document* myDriver = new DriverDAT_W_SMESHDS_Document();
return (myDriver);
}
else {
MESSAGE("No driver known for this extension");
return (Document_Writer*)NULL;
}
}
Mesh_Reader* SMESHDriver::GetMeshReader(string Extension, string Class) {
if (Extension==string("MED")) {
if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
DriverMED_R_SMESHDS_Mesh* myDriver = new DriverMED_R_SMESHDS_Mesh();
return (myDriver);
}
else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
DriverMED_R_SMDS_Mesh* myDriver = new DriverMED_R_SMDS_Mesh();
return (myDriver);
}
}
else if (Extension==string("DAT")) {
if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
DriverDAT_R_SMESHDS_Mesh* myDriver = new DriverDAT_R_SMESHDS_Mesh();
return (myDriver);
}
else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
DriverDAT_R_SMDS_Mesh* myDriver = new DriverDAT_R_SMDS_Mesh();
return (myDriver);
}
}
}
Mesh_Writer* SMESHDriver::GetMeshWriter(string Extension, string Class) {
if (Extension==string("MED")) {
if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
DriverMED_W_SMESHDS_Mesh* myDriver = new DriverMED_W_SMESHDS_Mesh();
return (myDriver);
}
else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
DriverMED_W_SMDS_Mesh* myDriver = new DriverMED_W_SMDS_Mesh();
return (myDriver);
}
}
else if (Extension==string("DAT")) {
if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) {
DriverDAT_W_SMESHDS_Mesh* myDriver = new DriverDAT_W_SMESHDS_Mesh();
return (myDriver);
}
else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) {
DriverDAT_W_SMDS_Mesh* myDriver = new DriverDAT_W_SMDS_Mesh();
return (myDriver);
}
}
}

19
src/Driver/SMESHDriver.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef _INCLUDE_SMESHDRIVER
#define _INCLUDE_SMESHDRIVER
#include "Document_Reader.h"
#include "Document_Writer.h"
#include "Mesh_Reader.h"
#include "Mesh_Writer.h"
class SMESHDriver {
public :
static Document_Reader* GetDocumentReader(string Extension, string Class);
static Document_Writer* GetDocumentWriter(string Extension, string Class);
static Mesh_Reader* GetMeshReader(string Extension, string Class);
static Mesh_Writer* GetMeshWriter(string Extension, string Class);
};
#endif

36
src/MEFISTO2/Makefile.in Normal file
View File

@ -0,0 +1,36 @@
# -* Makefile *-
#
# Author :
# Date : 29/01/2001
#
#
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@
@COMMENCE@
# header files
EXPORT_HEADERS = aptrte.h Rn.h
# Libraries targets
LIB = libMEFISTO2D.la
LIB_SRC = aptrte.cxx trte.f
# areteideale.f
LIB_CLIENT_IDL =
LIB_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += $(OCC_LIBS) -lg2c
@CONCLUDE@

204
src/MEFISTO2/Rn.h Executable file
View File

@ -0,0 +1,204 @@
#ifndef Rn__h
#define Rn__h
#include <gp_Pnt.hxx> //Dans OpenCascade
#include <gp_Vec.hxx> //Dans OpenCascade
#include <gp_Dir.hxx> //Dans OpenCascade
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// BUT: Definir les espaces affines R R2 R3 R4 soit Rn pour n=1,2,3,4
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// AUTEUR : Frederic HECHT ANALYSE NUMERIQUE UPMC PARIS OCTOBRE 2000
// MODIFS : Alain PERRONNET ANALYSE NUMERIQUE UPMC PARIS NOVEMBRE 2000
//...............................................................................
#include <iostream>
#include <cmath>
using namespace std;
template<class T> inline T Abs (const T &a){return a <0 ? -a : a;}
template<class T> inline void Echange (T& a,T& b) {T c=a;a=b;b=c;}
template<class T> inline T Min (const T &a,const T &b) {return a < b ? a : b;}
template<class T> inline T Max (const T &a,const T & b) {return a > b ? a : b;}
template<class T> inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);}
template<class T> inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);}
template<class T> inline T Max (const T &a,const T & b,const T & c,const T & d)
{return Max(Max(a,b),Max(c,d));}
template<class T> inline T Min (const T &a,const T & b,const T & c,const T & d)
{return Min(Min(a,b),Min(c,d));}
//le type Nom des entites geometriques P L S V O
//===========
typedef char Nom[1+24];
//le type N des nombres entiers positifs
//=========
typedef unsigned long int N;
//le type Z des nombres entiers relatifs
//=========
typedef long int Z;
//le type R des nombres "reels"
//=========
typedef double R;
//le type XPoint des coordonnees d'un pixel dans une fenetre
//==============
//typedef struct { short int x,y } XPoint; //en fait ce type est defini dans X11-Window
// #include <X11/Xlib.h>
//la classe R2
//============
class R2
{
friend ostream& operator << (ostream& f, const R2 & P)
{ f << P.x << ' ' << P.y ; return f; }
friend istream& operator >> (istream& f, R2 & P)
{ f >> P.x >> P.y ; return f; }
friend ostream& operator << (ostream& f, const R2 * P)
{ f << P->x << ' ' << P->y ; return f; }
friend istream& operator >> (istream& f, R2 * P)
{ f >> P->x >> P->y ; return f; }
public:
R x,y; //les donnees
R2 () :x(0),y(0) {} //les constructeurs
R2 (R a,R b) :x(a),y(b) {}
R2 (R2 A,R2 B) :x(B.x-A.x),y(B.y-A.y) {} //vecteur defini par 2 points
R2 operator+(R2 P) const {return R2(x+P.x,y+P.y);} // Q+P possible
R2 operator+=(R2 P) {x += P.x;y += P.y; return *this;}// Q+=P;
R2 operator-(R2 P) const {return R2(x-P.x,y-P.y);} // Q-P
R2 operator-=(R2 P) {x -= P.x;y -= P.y; return *this;} // Q-=P;
R2 operator-()const {return R2(-x,-y);} // -Q
R2 operator+()const {return *this;} // +Q
R operator,(R2 P)const {return x*P.x+y*P.y;} // produit scalaire (Q,P)
R operator^(R2 P)const {return x*P.y-y*P.x;} // produit vectoriel Q^P
R2 operator*(R c)const {return R2(x*c,y*c);} // produit a droite P*c
R2 operator*=(R c) {x *= c; y *= c; return *this;}
R2 operator/(R c)const {return R2(x/c,y/c);} // division par un reel
R2 operator/=(R c) {x /= c; y /= c; return *this;}
R & operator[](int i) {return (&x)[i];} // la coordonnee i
R2 orthogonal() {return R2(-y,x);} //le vecteur orthogonal dans R2
friend R2 operator*(R c,R2 P) {return P*c;} // produit a gauche c*P
};
//la classe R3
//============
class R3
{
friend ostream& operator << (ostream& f, const R3 & P)
{ f << P.x << ' ' << P.y << ' ' << P.z ; return f; }
friend istream& operator >> (istream& f, R3 & P)
{ f >> P.x >> P.y >> P.z ; return f; }
friend ostream& operator << (ostream& f, const R3 * P)
{ f << P->x << ' ' << P->y << ' ' << P->z ; return f; }
friend istream& operator >> (istream& f, R3 * P)
{ f >> P->x >> P->y >> P->z ; return f; }
public:
R x,y,z; //les 3 coordonnees
R3 () :x(0),y(0),z(0) {} //les constructeurs
R3 (R a,R b,R c):x(a),y(b),z(c) {} //Point ou Vecteur (a,b,c)
R3 (R3 A,R3 B):x(B.x-A.x),y(B.y-A.y),z(B.z-A.z) {} //Vecteur AB
R3 (gp_Pnt P) : x(P.X()), y(P.Y()), z(P.Z()) {} //Point d'OpenCascade
R3 (gp_Vec V) : x(V.X()), y(V.Y()), z(V.Z()) {} //Vecteur d'OpenCascade
R3 (gp_Dir P) : x(P.X()), y(P.Y()), z(P.Z()) {} //Direction d'OpenCascade
R3 operator+(R3 P)const {return R3(x+P.x,y+P.y,z+P.z);}
R3 operator+=(R3 P) {x += P.x; y += P.y; z += P.z; return *this;}
R3 operator-(R3 P)const {return R3(x-P.x,y-P.y,z-P.z);}
R3 operator-=(R3 P) {x -= P.x; y -= P.y; z -= P.z; return *this;}
R3 operator-()const {return R3(-x,-y,-z);}
R3 operator+()const {return *this;}
R operator,(R3 P)const {return x*P.x+y*P.y+z*P.z;} // produit scalaire
R3 operator^(R3 P)const {return R3(y*P.z-z*P.y ,P.x*z-x*P.z, x*P.y-y*P.x);} // produit vectoriel
R3 operator*(R c)const {return R3(x*c,y*c,z*c);}
R3 operator*=(R c) {x *= c; y *= c; z *= c; return *this;}
R3 operator/(R c)const {return R3(x/c,y/c,z/c);}
R3 operator/=(R c) {x /= c; y /= c; z /= c; return *this;}
R & operator[](int i) {return (&x)[i];}
friend R3 operator*(R c,R3 P) {return P*c;}
R3 operator=(gp_Pnt P) {return R3(P.X(),P.Y(),P.Z());}
R3 operator=(gp_Dir P) {return R3(P.X(),P.Y(),P.Z());}
friend gp_Pnt gp_pnt(R3 xyz) { return gp_Pnt(xyz.x,xyz.y,xyz.z); }
//friend gp_Pnt operator=() { return gp_Pnt(x,y,z); }
friend gp_Dir gp_dir(R3 xyz) { return gp_Dir(xyz.x,xyz.y,xyz.z); }
bool DansPave( R3 & xyzMin, R3 & xyzMax )
{ return xyzMin.x<=x && x<=xyzMax.x &&
xyzMin.y<=y && y<=xyzMax.y &&
xyzMin.z<=z && z<=xyzMax.z; }
};
//la classe R4
//============
class R4: public R3
{
friend ostream& operator <<(ostream& f, const R4 & P )
{ f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; }
friend istream& operator >>(istream& f, R4 & P)
{ f >> P.x >> P.y >> P.z >> P.omega ; return f; }
friend ostream& operator <<(ostream& f, const R4 * P )
{ f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; }
friend istream& operator >>(istream& f, R4 * P)
{ f >> P->x >> P->y >> P->z >> P->omega ; return f; }
public:
R omega; //la donnee du poids supplementaire
R4 () :omega(1.0) {} //les constructeurs
R4 (R a,R b,R c,R d):R3(a,b,c),omega(d) {}
R4 (R4 A,R4 B) :R3(B.x-A.x,B.y-A.y,B.z-A.z),omega(B.omega-A.omega) {}
R4 operator+(R4 P)const {return R4(x+P.x,y+P.y,z+P.z,omega+P.omega);}
R4 operator+=(R4 P) {x += P.x;y += P.y;z += P.z;omega += P.omega;return *this;}
R4 operator-(R4 P)const {return R4(x-P.x,y-P.y,z-P.z,omega-P.omega);}
R4 operator-=(R4 P) {x -= P.x;y -= P.y;z -= P.z;omega -= P.omega;return *this;}
R4 operator-()const {return R4(-x,-y,-z,-omega);}
R4 operator+()const {return *this;}
R operator,(R4 P)const {return x*P.x+y*P.y+z*P.z+omega*P.omega;} // produit scalaire
R4 operator*(R c)const {return R4(x*c,y*c,z*c,omega*c);}
R4 operator*=(R c) {x *= c; y *= c; z *= c; omega *= c; return *this;}
R4 operator/(R c)const {return R4(x/c,y/c,z/c,omega/c);}
R4 operator/=(R c) {x /= c; y /= c; z /= c; omega /= c; return *this;}
R & operator[](int i) {return (&x)[i];}
friend R4 operator*(R c,R4 P) {return P*c;}
};
//quelques fonctions supplementaires sur ces classes
//==================================================
inline R Aire2d(const R2 A,const R2 B,const R2 C){return (B-A)^(C-A);}
inline R Angle2d(R2 P){ return atan2(P.y,P.x);}
inline R Norme2_2(const R2 & A){ return (A,A);}
inline R Norme2(const R2 & A){ return sqrt((A,A));}
inline R NormeInfinie(const R2 & A){return Max(Abs(A.x),Abs(A.y));}
inline R Norme2_2(const R3 & A){ return (A,A);}
inline R Norme2(const R3 & A){ return sqrt((A,A));}
inline R NormeInfinie(const R3 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z));}
inline R Norme2_2(const R4 & A){ return (A,A);}
inline R Norme2(const R4 & A){ return sqrt((A,A));}
inline R NormeInfinie(const R4 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z),Abs(A.omega));}
inline R2 XY(R3 P) {return R2(P.x, P.y);} //restriction a R2 d'un R3 par perte de z
inline R3 Min(R3 P, R3 Q)
{return R3(P.x<Q.x ? P.x : Q.x, P.y<Q.y ? P.y : Q.y, P.z<Q.z ? P.z : Q.z);} //Pt de xyz Min
inline R3 Max(R3 P, R3 Q)
{return R3(P.x>Q.x ? P.x : Q.x, P.y>Q.y ? P.y : Q.y, P.z>Q.z ? P.z : Q.z);} //Pt de xyz Max
#endif

760
src/MEFISTO2/aptrte.cxx Executable file
View File

@ -0,0 +1,760 @@
using namespace std;
#include "Rn.h"
#include "aptrte.h"
#include "utilities.h"
extern "C"
{
R aretemaxface_;
R areteideale_( R3 xyz, R3 direction )
{
return aretemaxface_;
}
}
//calcul de la longueur ideale de l'arete au sommet xyz (z ici inactif)
//dans la direction donnee
//a ajuster pour chaque surface plane et selon l'entier notysu (voir plus bas)
static double cpunew, cpuold=0;
void tempscpu_( double & tempsec )
//Retourne le temps CPU utilise en secondes
{
tempsec = ( (double) clock() ) / CLOCKS_PER_SEC;
//MESSAGE( "temps cpu=" << tempsec );
}
void deltacpu_( R & dtcpu )
//Retourne le temps CPU utilise en secondes depuis le precedent appel
{
tempscpu_( cpunew );
dtcpu = R( cpunew - cpuold );
cpuold = cpunew;
//MESSAGE( "delta temps cpu=" << dtcpu );
return;
}
void aptrte( Z nutysu, R aretmx,
Z nblf, Z * nudslf, R2 * uvslf,
Z nbpti, R2 *uvpti,
Z & nbst, R2 * & uvst, Z & nbt, Z * & nust,
Z & ierr )
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// but : appel de la triangulation par un arbre-4 recouvrant
// ----- de triangles equilateraux
// le contour du domaine plan est defini par des lignes fermees
// la premiere ligne etant l'enveloppe de toutes les autres
// la fonction areteideale(s,d) donne la taille d'arete
// au point s dans la direction (actuellement inactive) d
// des lors toute arete issue d'un sommet s devrait avoir une longueur
// comprise entre 0.65 areteideale_(s,d) et 1.3 areteideale_(s,d)
//
//Attention:
// Les tableaux uvslf et uvpti sont supposes ne pas avoir de sommets identiques!
// De meme, un sommet d'une ligne fermee ne peut appartenir a une autre ligne fermee
//
// entrees:
// --------
// nutysu : numero de traitement de areteideale_(s,d) selon le type de surface
// 0 pas d'emploi de la fonction areteideale_() et aretmx est active
// 1 il existe une fonction areteideale_(s,d)
// dont seules les 2 premieres composantes de uv sont actives
// ... autres options a definir ...
// aretmx : longueur maximale des aretes de la future triangulation
// nblf : nombre de lignes fermees de la surface
// nudslf : numero du dernier sommet de chacune des nblf lignes fermees
// nudslf(0)=0 pour permettre la difference sans test
// Attention le dernier sommet de chaque ligne est raccorde au premier
// tous les sommets et les points internes ont des coordonnees
// UV differentes <=> Pas de point double!
// uvslf : uv des nudslf(nblf) sommets des lignes fermees
// nbpti : nombre de points internes futurs sommets de la triangulation
// uvpti : uv des points internes futurs sommets de la triangulation
//
// sorties:
// --------
// nbst : nombre de sommets de la triangulation finale
// uvst : coordonnees uv des nbst sommets de la triangulation
// nbt : nombre de triangles de la triangulation finale
// nust : 4 numeros dans uvst des sommets des nbt triangles
// s1, s2, s3, 0: no dans uvst des 3 sommets et 0 car quadrangle!
// ierr : 0 si pas d'erreur
// > 0 sinon
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// auteur : Alain Perronnet Analyse Numerique Paris UPMC decembre 2001
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
R d, tcpu=0;
R3 direction=R3(0,0,0); //direction pour areteideale() inactive ici!
Z nbarfr=nudslf[nblf]; //nombre total d'aretes des lignes fermees
Z mxtrou = Max( 1024, nblf ); //nombre maximal de trous dans la surface
R3 *mnpxyd=NULL;
Z *mnsoar=NULL, mosoar=7, mxsoar, n1soar; //le hachage des aretes
Z *mnartr=NULL, moartr=3, mxartr, n1artr; //le no des 3 aretes des triangles
Z *mntree=NULL, motree=9, mxtree; //L'arbre 4 de TE et nombre d'entiers par TE
Z *mnqueu=NULL, mxqueu;
Z *mn1arcf=NULL;
Z *mnarcf=NULL, mxarcf;
Z *mnarcf1=NULL;
Z *mnarcf2=NULL;
Z *mnarcf3=NULL;
Z *mntrsu=NULL;
Z *mndalf=NULL;
Z *mnslig=NULL;
Z *mnarst=NULL;
Z *mnlftr=NULL;
R3 comxmi[2]; //coordonnees UV Min et Maximales
R aremin, aremax; //longueur minimale et maximale des aretes
R quamoy, quamin;
Z noar0, noar, na;
Z i, l, n, ns, ns0, ns1, ns2, nosotr[3], nt;
Z mxsomm, nbsomm, nbarpi, nbarli, ndtri0, mn;
Z moins1=-1;
aretemaxface_ = aretmx;
// initialisation du temps cpu
deltacpu_( d );
ierr = 0;
// quelques reservations de tableaux pour faire les calculs
// ========================================================
// le tableau pointeur sur la premiere arete de chaque ligne fermee
if( mndalf!=NULL ) delete [] mndalf;
mndalf = new Z[1+nblf];
if( mndalf==NULL ) goto ERREUR;
mndalf[0]=0;
// declaration du tableau des coordonnees des sommets de la frontiere
// puis des sommets internes ajoutes
// majoration empirique du nombre de sommets de la triangulation
i = 4*nbarfr/10;
mxsomm = Max( 20000, 64*nbpti+i*i );
MESSAGE( "APTRTE: Depart de la triangulation avec " );
MESSAGE( "nutysu=" << nutysu << " aretmx=" << aretmx << " mxsomm=" << mxsomm );
NEWDEPART:
//mnpxyd( 3, mxsomm ) les coordonnees UV des sommets et la taille d'arete aux sommets
if( mnpxyd!=NULL ) delete [] mnpxyd;
mnpxyd = new R3[mxsomm];
if( mnpxyd==NULL ) goto ERREUR;
// le tableau mnsoar des aretes des triangles
// 1: sommet 1 dans pxyd,
// 2: sommet 2 dans pxyd,
// 3: numero de 1 a nblf de la ligne qui supporte l'arete
// 4: numero dans mnartr du triangle 1 partageant cette arete,
// 5: numero dans mnartr du triangle 2 partageant cette arete,
// 6: chainage des aretes frontalieres ou internes ou
// des aretes simples des etoiles de triangles,
// 7: chainage du hachage des aretes
// nombre d'aretes = 3 ( nombre de sommets - 1 + nombre de trous )
// pour le hachage des aretes mxsoar doit etre > 3*mxsomm!
// h(ns1,ns2) = min( ns1, ns2 )
if( mnsoar!=NULL ) delete [] mnsoar;
mxsoar = 3 * ( mxsomm + mxtrou );
mnsoar = new Z[mosoar*mxsoar];
if( mnsoar==NULL ) goto ERREUR;
//initialiser le tableau mnsoar pour le hachage des aretes
insoar_( mxsomm, mosoar, mxsoar, n1soar, mnsoar );
// mnarst( mxsomm ) numero mnsoar d'une arete pour chacun des sommets
if( mnarst!=NULL ) delete [] mnarst;
mnarst = new Z[1+mxsomm];
if( mnarst==NULL ) goto ERREUR;
n = 1+mxsomm;
azeroi_( n, mnarst );
// mnslig( mxsomm ) no de sommet dans sa ligne pour chaque sommet frontalier
// ou no du point si interne forc'e par l'utilisateur
// ou 0 si interne cree par le module
if( mnslig!=NULL ) delete [] mnslig;
mnslig = new Z[mxsomm];
if( mnslig==NULL ) goto ERREUR;
azeroi_( mxsomm, mnslig );
// initialisation des aretes frontalieres de la triangulation future
// renumerotation des sommets des aretes des lignes pour la triangulation
// mise a l'echelle des coordonnees des sommets pour obtenir une
// meilleure precision lors des calculs + quelques verifications
// boucle sur les lignes fermees qui forment la frontiere
// ======================================================================
noar = 0;
aremin = 1e100;
aremax = 0;
for (n=1; n<=nblf; n++)
{
//l'initialisation de la premiere arete de la ligne n dans la triangulation
//-------------------------------------------------------------------------
//le sommet ns0 est le numero de l'origine de la ligne
ns0 = nudslf[n-1];
mnpxyd[ns0].x = uvslf[ns0].x;
mnpxyd[ns0].y = uvslf[ns0].y;
mnpxyd[ns0].z = areteideale_( mnpxyd[ns0], direction );
// cout << "Sommet " << ns0 << ": " << mnpxyd[ns0].x
// << " " << mnpxyd[ns0].y << " longueur arete=" << mnpxyd[ns0].z << endl;
//carre de la longueur de l'arete 1 de la ligne fermee n
d = pow( uvslf[ns0+1].x - uvslf[ns0].x, 2 )
+ pow( uvslf[ns0+1].y - uvslf[ns0].y, 2 ) ;
aremin = Min( aremin, d );
aremax = Max( aremax, d );
//le numero des 2 sommets (ns1,ns2) de la premiere arete de la ligne
//initialisation de la 1-ere arete ns1-ns1+1 de cette ligne fermee n
//le numero des 2 sommets ns1 ns2 de la 1-ere arete
//Attention: les numeros ns debutent a 1 (ils ont >0)
// les tableaux c++ demarrent a zero!
// les tableaux fortran demarrent ou l'on veut!
ns0++;
ns1 = ns0;
ns2 = ns1+1;
//le numero n de la ligne du sommet et son numero ns1 dans la ligne
mnslig[ns0-1] = 1000000 * n + ns1-nudslf[n-1];
fasoar_( ns1, ns2, moins1, moins1, n,
mosoar, mxsoar, n1soar, mnsoar, mnarst,
noar0, ierr );
//pas de test sur ierr car pas de saturation possible a ce niveau
//le pointeur dans le hachage sur la premiere arete de la ligne fermee n
mndalf[n] = noar0;
//la nouvelle arete est la suivante de l'arete definie juste avant
if( noar > 0 )
mnsoar[mosoar * noar - mosoar + 5] = noar0;
//l'initialisation des aretes suivantes de la ligne dans la triangulation
//-----------------------------------------------------------------------
nbarli = nudslf[n] - nudslf[n-1]; //nombre d'aretes=sommets de la ligne n
for (i=2; i<=nbarli; i++)
{
ns1 = ns2; //le numero de l'arete et le numero du premier sommet de l'arete
if( i < nbarli )
//nbs+1 est le 2-eme sommet de l'arete i de la ligne fermee n
ns2 = ns1+1;
else
//le 2-eme sommet de la derniere arete est le premier sommet de la ligne
ns2 = ns0;
//l'arete precedente est dotee de sa suivante:celle cree ensuite
//les 2 coordonnees du sommet ns2 de la ligne
ns = ns1 - 1;
mnpxyd[ns].x = uvslf[ns].x;
mnpxyd[ns].y = uvslf[ns].y;
mnpxyd[ns].z = areteideale_( mnpxyd[ns], direction );
// cout << "Sommet " << ns << ": " << mnpxyd[ns].x
// << " " << mnpxyd[ns].y << " longueur arete=" << mnpxyd[ns].z << endl;
//carre de la longueur de l'arete
d = pow( uvslf[ns2-1].x - uvslf[ns1-1].x, 2)
+ pow( uvslf[ns2-1].y - uvslf[ns1-1].y, 2);
aremin = Min( aremin, d );
aremax = Max( aremax, d );
//le numero n de la ligne du sommet et son numero ns1 dans la ligne
mnslig[ns] = 1000000 * n + ns1-nudslf[n-1];
//ajout de l'arete dans la liste
fasoar_( ns1, ns2, moins1, moins1, n,
mosoar, mxsoar, n1soar, mnsoar,
mnarst, noar, ierr );
//pas de test sur ierr car pas de saturation possible a ce niveau
//chainage des aretes frontalieres en position 6 du tableau mnsoar
//la nouvelle arete est la suivante de l'arete definie juste avant
mnsoar[ mosoar * noar0 - mosoar + 5 ] = noar;
noar0 = noar;
}
//attention: la derniere arete de la ligne fermee enveloppe
// devient en fait la premiere arete de cette ligne
// dans le chainage des aretes de la frontiere!
}
if( ierr != 0 ) goto ERREUR;
aremin = sqrt( aremin ); //longueur minimale d'une arete des lignes fermees
aremax = sqrt( aremax ); //longueur maximale d'une arete
aretmx = Min( aretmx, aremax ); //pour homogeneiser
cout << "nutysu=" << nutysu << " aretmx=" << aretmx
<< " arete min=" << aremin << " arete max=" << aremax << endl;
//chainage des aretes frontalieres : la derniere arete frontaliere
mnsoar[ mosoar * noar - mosoar + 5 ] = 0;
//tous les sommets et aretes frontaliers sont numerotes de 1 a nbarfr
//reservation du tableau des numeros des 3 aretes de chaque triangle
//mnartr( moartr, mxartr )
//En nombre: Triangles = Aretes Internes + Aretes Frontalieres - Sommets + 1-Trous
// 3Triangles = 2 Aretes internes + Aretes frontalieres
// d'ou 3T/2 < AI + AF => T < 3T/2 - Sommets + 1-Trous
//nombre de triangles < 2 ( nombre de sommets - 1 + nombre de trous )
if( mnartr!=NULL ) delete [] mnartr;
mxartr = 2 * ( mxsomm + mxtrou );
mnartr = new Z[moartr*mxartr];
if( mnartr==NULL ) goto ERREUR;
//Ajout des points internes
ns1 = nudslf[ nblf ];
for (i=0; i<nbpti; i++)
{
//les 2 coordonnees du point i de sommet nbs
mnpxyd[ns1].x = uvpti[i].x;
mnpxyd[ns1].y = uvpti[i].y;
mnpxyd[ns1].z = areteideale_( mnpxyd[ns1], direction );
//le numero i du point interne
mnslig[ns1] = i+1;
ns1++;
}
//nombre de sommets de la frontiere et internes
nbarpi = ns1;
// creation de l'arbre-4 des te (tableau letree)
// ajout dans les te des sommets des lignes et des points internes imposes
// =======================================================================
// premiere estimation de mxtree
mxtree = 2 * mxsomm;
NEWTREE: //en cas de saturation de l'un des tableaux, on boucle
MESSAGE( "Debut triangulation avec mxsomm=" << mxsomm );
if( mntree != NULL ) delete [] mntree;
nbsomm = nbarpi;
mntree = new Z[motree*(1+mxtree)];
if( mntree==NULL ) goto ERREUR;
//initialisation du tableau letree et ajout dans letree des sommets 1 a nbsomm
teajte_( mxsomm, nbsomm, mnpxyd, comxmi, aretmx, mxtree, mntree, ierr );
comxmi[0].z=0;
comxmi[1].z=0;
if( ierr == 51 )
{
//saturation de letree => sa taille est augmentee et relance
mxtree = mxtree * 2;
ierr = 0;
MESSAGE( "Nouvelle valeur de mxtree=" << mxtree );
goto NEWTREE;
}
deltacpu_( d );
tcpu += d;
MESSAGE( "Temps de l'ajout arbre-4 des Triangles Equilateraux=" << d << " secondes" );
if( ierr != 0 ) goto ERREUR;
//ici le tableau mnpxyd contient les sommets des te et les points frontaliers et internes
// homogeneisation de l'arbre des te a un saut de taille au plus
// prise en compte des tailles d'aretes souhaitees autour des sommets initiaux
// ===========================================================================
// reservation de la queue pour parcourir les te de l'arbre
if( mnqueu != NULL ) delete [] mnqueu;
mxqueu = mxtree;
mnqueu = new Z[mxqueu];
if( mnqueu==NULL) goto ERREUR;
tehote_( nutysu, nbarpi, mxsomm, nbsomm, mnpxyd,
comxmi, aretmx,
mntree, mxqueu, mnqueu,
ierr );
deltacpu_( d );
tcpu += d;
cout << "Temps de l'adaptation et l'homogeneisation de l'arbre-4 des TE="
<< d << " secondes" << endl;
if( ierr != 0 )
{
//destruction du tableau auxiliaire et de l'arbre
if( ierr == 51 )
{
//letree sature
mxtree = mxtree * 2;
MESSAGE( "Redemarrage avec la valeur de mxtree=" << mxtree );
ierr = 0;
goto NEWTREE;
}
else
goto ERREUR;
}
// trianguler les triangles equilateraux feuilles a partir de leurs 3 sommets
// et des points de la frontiere, des points internes imposes interieurs
// ==========================================================================
tetrte_( comxmi, aretmx, nbarpi, mxsomm, mnpxyd,
mxqueu, mnqueu, mntree, mosoar, mxsoar, n1soar, mnsoar,
moartr, mxartr, n1artr, mnartr, mnarst,
ierr );
// destruction de la queue et de l'arbre devenus inutiles
delete [] mnqueu; mnqueu=NULL;
delete [] mntree; mntree=NULL;
//Temps calcul
deltacpu_( d );
tcpu += d;
MESSAGE( "Temps de la triangulation des TE=" << d << " secondes" );
// ierr =0 si pas d'erreur
// =1 si le tableau mnsoar est sature
// =2 si le tableau mnartr est sature
// =3 si aucun des triangles ne contient l'un des points internes
// =5 si saturation de la queue de parcours de l'arbre des te
if( ierr != 0 ) goto ERREUR;
//qualites de la triangulation actuelle
qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr,
nbt, quamoy, quamin );
// boucle sur les aretes internes (non sur une ligne de la frontiere)
// avec echange des 2 diagonales afin de rendre la triangulation delaunay
// ======================================================================
// formation du chainage 6 des aretes internes a echanger eventuellement
aisoar_( mosoar, mxsoar, mnsoar, na );
tedela_( mnpxyd, mnarst,
mosoar, mxsoar, n1soar, mnsoar, na,
moartr, mxartr, n1artr, mnartr, n );
MESSAGE( "Nombre d'echanges des diagonales de 2 triangles=" << n );
deltacpu_( d );
tcpu += d;
cout << "Temps de la triangulation Delaunay par echange des diagonales="
<< d << " secondes" << endl;
//qualites de la triangulation actuelle
qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr,
nbt, quamoy, quamin );
// detection des aretes frontalieres initiales perdues
// triangulation frontale pour les restaurer
// ===================================================
mxarcf = mxsomm/5;
if( mn1arcf != NULL ) delete [] mn1arcf;
if( mnarcf != NULL ) delete [] mnarcf;
if( mnarcf1 != NULL ) delete [] mnarcf1;
if( mnarcf2 != NULL ) delete [] mnarcf2;
mn1arcf = new Z[1+mxarcf];
if( mn1arcf == NULL ) goto ERREUR;
mnarcf = new Z[3*mxarcf];
if( mnarcf == NULL ) goto ERREUR;
mnarcf1 = new Z[mxarcf];
if( mnarcf1 == NULL ) goto ERREUR;
mnarcf2 = new Z[mxarcf];
if( mnarcf2 == NULL ) goto ERREUR;
terefr_( nbarpi, mnpxyd,
mosoar, mxsoar, n1soar, mnsoar,
moartr, n1artr, mnartr, mnarst,
mxarcf, mn1arcf, mnarcf, mnarcf1, mnarcf2,
n, ierr );
MESSAGE( "Restauration de " << n << " aretes perdues de la frontiere" );
deltacpu_( d );
tcpu += d;
cout << "Temps de la recuperation des aretes perdues de la frontiere="
<< d << " secondes" << endl;
if( ierr != 0 ) goto ERREUR;
//qualites de la triangulation actuelle
qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr,
nbt, quamoy, quamin );
// fin de la triangulation avec respect des aretes initiales frontalieres
// suppression des triangles externes a la surface
// ===============================================
// recherche du dernier triangle utilise
mn = mxartr * moartr;
for ( ndtri0=mxartr; ndtri0<=1; ndtri0-- )
{
mn -= moartr;
if( mnartr[mn] != 0 ) break;
}
if( mntrsu != NULL ) delete [] mntrsu;
mntrsu = new Z[ndtri0];
if( mntrsu == NULL ) goto ERREUR;
if( mnlftr != NULL ) delete [] mnlftr;
mnlftr = new Z[nblf];
if( mnlftr == NULL ) goto ERREUR;
for (n=0; n<nblf; n++) //numero de la ligne fermee de 1 a nblf
mnlftr[n] = n+1;
tesuex_( nblf, mnlftr,
ndtri0, nbsomm, mnpxyd, mnslig,
mosoar, mxsoar, mnsoar,
moartr, mxartr, n1artr, mnartr, mnarst,
nbt, mntrsu, ierr );
delete [] mnlftr; mnlftr=NULL;
delete [] mntrsu; mntrsu=NULL;
deltacpu_( d );
tcpu += d;
MESSAGE( "Temps de la suppression des triangles externes=" << d );
if( ierr != 0 ) goto ERREUR;
//qualites de la triangulation actuelle
qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr,
nbt, quamoy, quamin );
// amelioration de la qualite de la triangulation par
// barycentrage des sommets internes a la triangulation
// suppression des aretes trop longues ou trop courtes
// modification de la topologie des groupes de triangles
// mise en delaunay de la triangulation
// =====================================================
mnarcf3 = new Z[mxarcf];
if( mnarcf3 == NULL ) goto ERREUR;
teamqt_( nutysu,
mnarst, mosoar, mxsoar, n1soar, mnsoar,
moartr, mxartr, n1artr, mnartr,
mxarcf, mnarcf2, mnarcf3,
mn1arcf, mnarcf, mnarcf1,
comxmi, nbarpi, nbsomm, mxsomm, mnpxyd, mnslig,
ierr );
if( mn1arcf != NULL ) {delete [] mn1arcf; mn1arcf=NULL;}
if( mnarcf != NULL ) {delete [] mnarcf; mnarcf =NULL;}
if( mnarcf1 != NULL ) {delete [] mnarcf1; mnarcf1=NULL;}
if( mnarcf2 != NULL ) {delete [] mnarcf2; mnarcf2=NULL;}
if( mnarcf3 != NULL ) {delete [] mnarcf3; mnarcf3=NULL;}
deltacpu_( d );
tcpu += d;
MESSAGE( "Temps de l'amelioration de la qualite de la triangulation=" << d );
if( ierr != 0 ) goto ERREUR;
//qualites de la triangulation finale
qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr,
nbt, quamoy, quamin );
// renumerotation des sommets internes: mnarst(i)=numero final du sommet
// ===================================
for (i=0; i<=nbsomm; i++)
mnarst[i] = 0;
for (nt=1; nt<=mxartr; nt++)
{
if( mnartr[nt*moartr-moartr] != 0 )
{
//le numero des 3 sommets du triangle nt
nusotr_( nt, mosoar, mnsoar, moartr, mnartr, nosotr );
//les 3 sommets du triangle sont actifs
mnarst[ nosotr[0] ] = 1;
mnarst[ nosotr[1] ] = 1;
mnarst[ nosotr[2] ] = 1;
}
}
nbst = 0;
for (i=1; i<=nbsomm; i++)
{
if( mnarst[i] >0 )
mnarst[i] = ++nbst;
}
// generation du tableau uvst de la surface triangulee
// ---------------------------------------------------
if( uvst != NULL ) delete [] uvst;
uvst = new R2[nbst];
if( uvst == NULL ) goto ERREUR;
nbst=-1;
for (i=0; i<nbsomm; i++ )
{
if( mnarst[i+1]>0 )
{
nbst++;
uvst[nbst].x = mnpxyd[i].x;
uvst[nbst].y = mnpxyd[i].y;
//si le sommet est un point ou appartient a une ligne
//ses coordonnees initiales sont restaurees
n = mnslig[i];
if( n > 0 )
{
if( n >= 1000000 )
{
//sommet d'une ligne
//retour aux coordonnees initiales dans uvslf
l = n / 1000000;
n = n - 1000000 * l + nudslf[l-1] - 1;
uvst[nbst].x = uvslf[n].x;
uvst[nbst].y = uvslf[n].y;
}
else
{
//point utilisateur n interne impose
//retour aux coordonnees initiales dans uvpti
uvst[nbst].x = uvpti[n-1].x;
uvst[nbst].y = uvpti[n-1].y;
}
}
}
}
nbst++;
// generation du tableau 'nsef' de la surface triangulee
// -----------------------------------------------------
// boucle sur les triangles occupes (internes et externes)
if( nust != NULL ) delete [] nust;
nust = new Z[4*nbt];
if( nust == NULL ) goto ERREUR;
nbt = 0;
for (i=1; i<=mxartr; i++)
{
//le triangle i de mnartr
if( mnartr[i*moartr-moartr] != 0 )
{
//le triangle i est interne => nosotr numero de ses 3 sommets
nusotr_( i, mosoar, mnsoar, moartr, mnartr, nosotr );
nust[nbt++] = mnarst[ nosotr[0] ];
nust[nbt++] = mnarst[ nosotr[1] ];
nust[nbt++] = mnarst[ nosotr[2] ];
nust[nbt++] = 0;
}
}
nbt /= 4; //le nombre final de triangles de la surface
cout << "Nombre de sommets=" << nbst
<< " Nombre de triangles=" << nbt << endl;
deltacpu_( d );
tcpu += d;
MESSAGE( "Temps total de la triangulation=" << tcpu << " secondes" );
// destruction des tableaux auxiliaires
// ------------------------------------
NETTOYAGE:
if( mnarst != NULL ) delete [] mnarst;
if( mnartr != NULL ) delete [] mnartr;
if( mnslig != NULL ) delete [] mnslig;
if( mnsoar != NULL ) delete [] mnsoar;
if( mnpxyd != NULL ) delete [] mnpxyd;
if( mndalf != NULL ) delete [] mndalf;
if( mntree != NULL ) delete [] mntree;
if( mnqueu != NULL ) delete [] mnqueu;
if( mntrsu != NULL ) delete [] mntrsu;
if( mnlftr != NULL ) delete [] mnlftr;
if( mn1arcf != NULL ) delete [] mn1arcf;
if( mnarcf != NULL ) delete [] mnarcf;
if( mnarcf1 != NULL ) delete [] mnarcf1;
if( mnarcf2 != NULL ) delete [] mnarcf2;
if( mnarcf3 != NULL ) delete [] mnarcf3;
return;
ERREUR:
if( ierr == 51 || ierr == 52 )
{
//saturation des sommets => redepart avec 2 fois plus de sommets
mxsomm = 2 * mxsomm;
ierr = 0;
goto NEWDEPART;
}
else
{
MESSAGE( "Triangulation non realisee " << ierr );
if( ierr == 0 ) ierr=1;
goto NETTOYAGE;
}
}
void qualitetrte( R3 *mnpxyd,
Z & mosoar, Z & mxsoar, Z *mnsoar,
Z & moartr, Z & mxartr, Z *mnartr,
Z & nbtria, R & quamoy, R & quamin )
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// but : calculer la qualite moyenne et minimale de la triangulation
// ----- actuelle definie par les tableaux mnsoar et mnartr
// entrees:
// --------
// mnpxyd : tableau des coordonnees 2d des points
// par point : x y distance_souhaitee
// mosoar : nombre maximal d'entiers par arete et
// indice dans mnsoar de l'arete suivante dans le hachage
// mxsoar : nombre maximal d'aretes stockables dans le tableau mnsoar
// attention: mxsoar>3*mxsomm obligatoire!
// mnsoar : numero des 2 sommets , no ligne, 2 triangles de l'arete,
// chainage des aretes frontalieres, chainage du hachage des aretes
// hachage des aretes = mnsoar(1)+mnsoar(2)*2
// avec mxsoar>=3*mxsomm
// une arete i de mnsoar est vide <=> mnsoar(1,i)=0 et
// mnsoar(2,arete vide)=l'arete vide qui precede
// mnsoar(3,arete vide)=l'arete vide qui suit
// moartr : nombre maximal d'entiers par arete du tableau mnartr
// mxartr : nombre maximal de triangles declarables
// mnartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3
// arete1 = 0 si triangle vide => arete2 = triangle vide suivant
// sorties:
// --------
// nbtria : nombre de triangles internes au domaine
// quamoy : qualite moyenne des triangles actuels
// quamin : qualite minimale des triangles actuels
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
R d, aire, qualite;
Z nosotr[3], mn, nbtrianeg, nt;
aire = 0;
quamoy = 0;
quamin = 2.0;
nbtria = 0;
nbtrianeg = 0;
mn = -moartr;
for ( nt=1; nt<=mxartr; nt++ )
{
mn += moartr;
if( mnartr[mn]!=0 )
{
//un triangle occupe de plus
nbtria++;
//le numero des 3 sommets du triangle nt
nusotr_( nt, mosoar, mnsoar, moartr, mnartr, nosotr );
//la qualite du triangle ns1 ns2 ns3
qutr2d_( mnpxyd[nosotr[0]-1], mnpxyd[nosotr[1]-1], mnpxyd[nosotr[2]-1],
qualite );
//la qualite moyenne
quamoy += qualite;
//la qualite minimale
quamin = Min( quamin, qualite );
//aire signee du triangle nt
d = surtd2_( mnpxyd[nosotr[0]-1], mnpxyd[nosotr[1]-1], mnpxyd[nosotr[2]-1] );
if( d<0 )
{
//un triangle d'aire negative de plus
nbtrianeg++;
cout << "ATTENTION: le triangle " << nt << " de sommets:"
<< nosotr[0] << " " << nosotr[1] << " " << nosotr[2]
<< " a une aire " << d <<"<=0" << endl;
}
//aire des triangles actuels
aire += Abs(d);
}
}
//les affichages
quamoy /= nbtria;
cout << "Qualite moyenne=" << quamoy
<< " Qualite minimale=" << quamin
<< " des " << nbtria << " triangles de surface totale="
<< aire << endl;
if( nbtrianeg>0 )
MESSAGE( "ATTENTION: nombre de triangles d'aire negative=" << nbtrianeg );
return;
}

229
src/MEFISTO2/aptrte.h Executable file
View File

@ -0,0 +1,229 @@
#ifndef aptrte__h
#define aptrte__h
#include <limits.h> // limites min max int long real ...
#include <unistd.h> // gethostname, ...
#include <stdio.h>
#include <iostream.h> // pour cout cin ...
#include <iomanip.h> // pour le format des io setw, stx, setfill, ...
#include <string.h> // pour les fonctions sur les chaines de caracteres
#include <ctype.h>
#include <stdlib.h>
#include <math.h> // pour les fonctions mathematiques
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
void qualitetrte( R3 *mnpxyd,
Z & mosoar, Z & mxsoar, Z *mnsoar,
Z & moartr, Z & mxartr, Z *mnartr,
Z & nbtria, R & quamoy, R & quamin );
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// but : calculer la qualite moyenne et minimale de la triangulation
// ----- actuelle definie par les tableaux nosoar et noartr
// entrees:
// --------
// mnpxyd : tableau des coordonnees 2d des points
// par point : x y distance_souhaitee
// mosoar : nombre maximal d'entiers par arete et
// indice dans nosoar de l'arete suivante dans le hachage
// mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar
// attention: mxsoar>3*mxsomm obligatoire!
// nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete,
// chainage des aretes frontalieres, chainage du hachage des aretes
// hachage des aretes = nosoar(1)+nosoar(2)*2
// avec mxsoar>=3*mxsomm
// une arete i de nosoar est vide <=> nosoar(1,i)=0 et
// nosoar(2,arete vide)=l'arete vide qui precede
// nosoar(3,arete vide)=l'arete vide qui suit
// moartr : nombre maximal d'entiers par arete du tableau noartr
// mxartr : nombre maximal de triangles declarables
// noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3
// arete1 = 0 si triangle vide => arete2 = triangle vide suivant
// sorties:
// --------
// nbtria : nombre de triangles internes au domaine
// quamoy : qualite moyenne des triangles actuels
// quamin : qualite minimale des triangles actuels
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void aptrte( Z nutysu, R aretmx,
Z nblf, Z *nudslf, R2 *uvslf,
Z nbpti, R2 *uvpti,
Z & nbst, R2 * & uvst, Z & nbt, Z * & nust,
Z & ierr );
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// but : appel de la triangulation par un arbre-4 recouvrant
// ----- de triangles equilateraux
// le contour du domaine plan est defini par des lignes fermees
// la premiere ligne etant l'enveloppe de toutes les autres
// la fonction areteideale_(s,d) donne la taille d'arete
// au point s dans la direction d (direction inactive pour l'instant)
// des lors toute arete issue d'un sommet s devrait avoir une longueur
// comprise entre 0.65 areteideale_(s,d) et 1.3 areteideale_(s,d)
//
//Attention:
// Les tableaux uvslf et uvpti sont supposes ne pas avoir de sommets identiques!
// De meme, un sommet d'une ligne fermee ne peut appartenir a une autre ligne fermee
//
// entrees:
// --------
// nutysu : numero de traitement de areteideale_() selon le type de surface
// 0 pas d'emploi de la fonction areteideale_() et aretmx est active
// 1 il existe une fonction areteideale_(s,d)
// dont seules les 2 premieres composantes de uv sont actives
// ... autres options a definir ...
// aretmx : longueur maximale des aretes de la future triangulation
// nblf : nombre de lignes fermees de la surface
// nudslf : numero du dernier sommet de chacune des nblf lignes fermees
// nudslf(0)=0 pour permettre la difference sans test
// Attention le dernier sommet de chaque ligne est raccorde au premier
// tous les sommets et les points internes ont des coordonnees
// UV differentes <=> Pas de point double!
// uvslf : uv des nudslf(nblf) sommets des lignes fermees
// nbpti : nombre de points internes futurs sommets de la triangulation
// uvpti : uv des points internes futurs sommets de la triangulation
//
// sorties:
// --------
// nbst : nombre de sommets de la triangulation finale
// uvst : coordonnees uv des nbst sommets de la triangulation
// nbt : nombre de triangles de la triangulation finale
// nust : 3 numeros dans uvst des sommets des nbt triangles
// ierr : 0 si pas d'erreur
// > 0 sinon
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// auteur : Alain Perronnet Analyse Numerique Paris UPMC decembre 2001
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
extern "C" { void tempscpu_( double & tempsec ); }
//Retourne le temps CPU utilise en secondes
extern "C" { void deltacpu_( R & dtcpu ); }
//Retourne le temps CPU utilise en secondes depuis le precedent appel
//initialiser le tableau mnsoar pour le hachage des aretes
extern "C" {void insoar_( Z & mxsomm, Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar );}
//mettre a zero les nb entiers de tab
extern "C" {void azeroi_( Z & nb, Z * tab );}
extern "C" {void fasoar_( Z & ns1, Z & ns2, Z & nt1, Z & nt2, Z & nolign,
Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, Z * mnarst,
Z & noar, Z & ierr );}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// but : former l'arete de sommet ns1-ns2 dans le hachage du tableau
// ----- nosoar des aretes de la triangulation
// entrees:
// --------
// ns1 ns2: numero pxyd des 2 sommets de l'arete
// nt1 : numero du triangle auquel appartient l'arete
// nt1=-1 si numero inconnu
// nt2 : numero de l'eventuel second triangle de l'arete si connu
// nt2=-1 si numero inconnu
// nolign : numero de la ligne fermee de l'arete
// =0 si l'arete n'est une arete de ligne
// ce numero est ajoute seulement si l'arete est creee
// mosoar : nombre maximal d'entiers par arete du tableau nosoar
// mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar
// modifies:
// ---------
// n1soar : numero de la premiere arete vide dans le tableau nosoar
// une arete i de nosoar est vide <=> nosoar(1,i)=0
// chainage des aretes vides amont et aval
// l'arete vide qui precede=nosoar(4,i)
// l'arete vide qui suit =nosoar(5,i)
// nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete,
// chainage momentan'e d'aretes, chainage du hachage des aretes
// hachage des aretes = min( nosoar(1), nosoar(2) )
// noarst : noarst(np) numero d'une arete du sommet np
// ierr : si < 0 en entree pas d'affichage en cas d'erreur du type
// "arete appartenant a plus de 2 triangles et a creer!"
// si >=0 en entree affichage de ce type d'erreur
// sorties:
// --------
// noar : >0 numero de l'arete retrouvee ou ajoutee
// ierr : =0 si pas d'erreur
// =1 si le tableau nosoar est sature
// =2 si arete a creer et appartenant a 2 triangles distincts
// des triangles nt1 et nt2
// =3 si arete appartenant a 2 triangles distincts
// differents des triangles nt1 et nt2
// =4 si arete appartenant a 2 triangles distincts
// dont le second n'est pas le triangle nt2
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//initialisation du tableau letree et ajout dans letree des sommets 1 a nbsomm
extern "C" {void teajte_( Z & mxsomm, Z & nbsomm, R3 * mnpxyd, R3 * comxmi,
R & aretmx, Z & mxtree, Z * letree,
Z & ierr );}
extern "C" {void tehote_( Z & nutysu, Z & nbarpi, Z & mxsomm, Z & nbsomm, R3 * mnpxyd,
R3 * comxmi, R & aretmx,
Z * letree, Z & mxqueu, Z * mnqueu,
Z & ierr );}
// homogeneisation de l'arbre des te a un saut de taille au plus
// prise en compte des tailles d'aretes souhaitees autour des sommets initiaux
extern "C" {void tetrte_( R3 * comxmi, R & aretmx, Z & nbarpi, Z & mxsomm, R3 * mnpxyd,
Z & mxqueu, Z * mnqueu, Z * mntree,
Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar,
Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z * mnarst,
Z & ierr );}
// trianguler les triangles equilateraux feuilles a partir de leurs 3 sommets
// et des points de la frontiere, des points internes imposes interieurs
extern "C" {void aisoar_( Z & mosoar, Z & mxsoar, Z * mnsoar, Z & na );}
// formation du chainage 6 des aretes internes a echanger eventuellement
extern "C" {void tedela_( R3 * mnpxyd, Z * mnarst,
Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, Z & na,
Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z & n );}
// boucle sur les aretes internes (non sur une ligne de la frontiere)
// avec echange des 2 diagonales afin de rendre la triangulation delaunay
extern "C" {void terefr_( Z & nbarpi, R3 * mnpxyd,
Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar,
Z & moartr, Z & n1artr, Z * mnartr, Z * mnarst,
Z & mxarcf, Z * mnarc1, Z * mnarc2,
Z * mnarc3, Z * mnarc4,
Z & n, Z & ierr );}
// detection des aretes frontalieres initiales perdues
// triangulation frontale pour les restaurer
extern "C" {void tesuex_( Z & nblf, Z * nulftr,
Z & ndtri0, Z & nbsomm, R3 * mnpxyd, Z * mnslig,
Z & mosoar, Z & mxsoar, Z * mnsoar,
Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z * mnarst,
Z & nbtria, Z * mntrsu, Z & ierr );}
// suppression des triangles externes a la surface
extern "C" {void teamqt_( Z & nutysu,
Z * mnarst, Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar,
Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr,
Z & mxarcf, Z * mntrcf, Z * mnstbo,
Z * n1arcf, Z * mnarcf, Z * mnarc1,
R3 * comxmi, Z & nbarpi, Z & nbsomm, Z & mxsomm,
R3 * mnpxyd, Z * mnslig,
Z & ierr );}
// amelioration de la qualite de la triangulation par
// barycentrage des sommets internes a la triangulation
// suppression des aretes trop longues ou trop courtes
// modification de la topologie des groupes de triangles
// mise en delaunay de la triangulation
extern "C" {void nusotr_( Z & nt, Z & mosoar, Z * mnsoar, Z & moartr, Z * mnartr,
Z * nosotr );}
//retrouver les numero des 3 sommets du triangle nt
extern "C" {void qutr2d_( R3 & p1, R3 & p2, R3 & p3, R & qualite );}
//calculer la qualite d'un triangle de R2 de sommets p1, p2, p3
extern "C" { R surtd2_( R3 & p1, R3 & p2, R3 & p3 ); }
//calcul de la surface d'un triangle defini par 3 points de r**2
#endif

5
src/MEFISTO2/areteideale.f Executable file
View File

@ -0,0 +1,5 @@
double precision function areteideale( xyz, direction )
double precision xyz(3), direction(3)
areteideale = 10
return
end

8319
src/MEFISTO2/trte.f Executable file

File diff suppressed because it is too large Load Diff

22
src/Makefile.in Normal file
View File

@ -0,0 +1,22 @@
#==============================================================================
# File : Makefile.in
# Created : ven déc 7 13:32:20 CET 2001
# Author : Paul RASCLE, EDF
# Project : SALOME
# Copyright : EDF 2001
# $Header$
#==============================================================================
# source path
top_srcdir=@top_srcdir@
top_builddir=..
srcdir=@srcdir@
VPATH=.:@srcdir@
@COMMENCE@
SUBDIRS = OBJECT SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV MEFISTO2 \
SMESH SMESH_I SMESHFiltersSelection SMESHGUI \
SMESH_SWIG
@MODULE@

33
src/OBJECT/Makefile.in Normal file
View File

@ -0,0 +1,33 @@
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
@COMMENCE@
EXPORT_HEADERS = SMESH_Actor.h \
SMESH_Grid.h
# Libraries targets
LIB = libSMESHObject.la
LIB_SRC = SMESH_Actor.cxx \
SMESH_Grid.cxx
LIB_CLIENT_IDL =
# Executables targets
BIN =
BIN_SRC =
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome
%_moc.cxx: %.h
$(MOC) $< -o $@
@CONCLUDE@

598
src/OBJECT/SMESH_Actor.cxx Normal file
View File

@ -0,0 +1,598 @@
using namespace std;
// File : SMESH_Actor.cxx
// Created : Mon May 13 22:31:18 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
/*!
\class SMESH_Actor SMESH_Actor.h
\brief ...
*/
#include "SMESH_Actor.h"
#include "SMESH_Grid.h"
#include "utilities.h"
// VTK Includes
#include <vtkObjectFactory.h>
#include <vtkMergePoints.h>
#include <vtkDataSetMapper.h>
#include <vtkFeatureEdges.h>
#include <vtkGeometryFilter.h>
//-------------------------------------------------------------
// Main methods
//-------------------------------------------------------------
SMESH_Actor* SMESH_Actor::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Actor");
if(ret)
{
return (SMESH_Actor*)ret;
}
// If the factory was unable to create the object, then create it here.
return new SMESH_Actor;
}
SMESH_Actor::SMESH_Actor()
{
this->Device = vtkActor::New();
this->EdgeDevice = vtkActor::New();
EdgeDevice->VisibilityOff();
EdgeDevice->PickableOff();
this->EdgeShrinkDevice = vtkActor::New();
EdgeShrinkDevice->VisibilityOff();
EdgeShrinkDevice->PickableOff();
myIO = NULL;
myName = "";
myDisplayMode = 0;
ishighlighted = false;
ispreselected = false;
edgeColor.r = 0.;
edgeColor.g = 0.;
edgeColor.b = 0.;
edgeHighlightColor.r = 1.;
edgeHighlightColor.g = 1.;
edgeHighlightColor.b = 1.;
edgePreselectedColor.r = 0.;
edgePreselectedColor.g = 1.;
edgePreselectedColor.b = 1.;
actorColor.r = 1.;
actorColor.g = 1.;
actorColor.b = 0.;
actorHighlightColor.r = 1.;
actorHighlightColor.g = 1.;
actorHighlightColor.b = 1.;
actorPreselectedColor.r = 0.;
actorPreselectedColor.g = 1.;
actorPreselectedColor.b = 1.;
actorNodeColor.r = 1.;
actorNodeColor.g = 1.;
actorNodeColor.b = 0.;
actorNodeSize = 2 ;
}
SMESH_Actor::~SMESH_Actor()
{
this->EdgeDevice->Delete();
this->EdgeShrinkDevice->Delete();
}
void SMESH_Actor::setReader(vtkUnstructuredGridReader* r) {
myReader=r;
}
vtkUnstructuredGridReader* SMESH_Actor::getReader() {
return (myReader);
}
vtkMapper* SMESH_Actor::getMapper() {
return (this->Mapper);
}
void SMESH_Actor::ShallowCopy(vtkProp *prop)
{
SMESH_Actor *f = SMESH_Actor::SafeDownCast(prop);
if ( f != NULL )
{
this->setName( f->getName() );
if ( f->hasIO() )
this->setIO( f->getIO() );
this->setDisplayMode( f->getDisplayMode() );
// Copy devices
vtkActor* tempDev = vtkActor::New();
tempDev->ShallowCopy(f->Device);
vtkProperty* prp = vtkProperty::New();
prp->DeepCopy(f->Device->GetProperty());
tempDev->SetProperty(prp);
prp = vtkProperty::New();
prp->DeepCopy(f->Device->GetBackfaceProperty());
tempDev->SetBackfaceProperty(prp);
this->Device = tempDev;
tempDev = vtkActor::New();
tempDev->ShallowCopy(f->EdgeDevice);
prp = vtkProperty::New();
prp->DeepCopy(f->EdgeDevice->GetProperty());
tempDev->SetProperty(prp);
prp = vtkProperty::New();
prp->DeepCopy(f->EdgeDevice->GetBackfaceProperty());
tempDev->SetBackfaceProperty(prp);
this->EdgeDevice = tempDev;
tempDev = vtkActor::New();
tempDev->ShallowCopy(f->EdgeShrinkDevice);
prp = vtkProperty::New();
prp->DeepCopy(f->EdgeShrinkDevice->GetProperty());
tempDev->SetProperty(prp);
prp = vtkProperty::New();
prp->DeepCopy(f->EdgeShrinkDevice->GetBackfaceProperty());
tempDev->SetBackfaceProperty(prp);
this->EdgeShrinkDevice = tempDev;
// Copy data source
this->DataSource = f->DataSource;
this->myReader = f->myReader;
}
// Now do superclass
this->SALOME_Actor::ShallowCopy(prop);
// Here we need to modify default ShallowCopy() results
// Create copies of properties
if ( f != NULL ) {
vtkProperty* prp = vtkProperty::New();
prp->DeepCopy(f->GetProperty());
this->SetProperty(prp);
prp = vtkProperty::New();
prp->DeepCopy(f->GetBackfaceProperty());
this->SetBackfaceProperty(prp);
// Copy the mapper
vtkDataSetMapper* mpr = vtkDataSetMapper::New();
mpr->ShallowCopy(f->GetMapper());
mpr->SetInput(f->DataSource);
this->SetMapper(mpr);
}
}
void SMESH_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper )
{
if (this->Mapper == NULL) {
MESSAGE ("No mapper for actor.")
return;
}
if ( myDisplayMode == 1 ) {
EdgeDevice->VisibilityOn();
EdgeShrinkDevice->VisibilityOff();
} else if ( myDisplayMode == 2 ) {
EdgeShrinkDevice->VisibilityOn();
EdgeDevice->VisibilityOff();
} else {
EdgeShrinkDevice->VisibilityOff();
EdgeDevice->VisibilityOff();
}
vtkMapper *bestMapper;
bestMapper = this->Mapper;
/* render the property */
if (!this->Property) {
// force creation of a property
this->GetProperty();
}
if ( ishighlighted ) {
if ( myDisplayMode == 1 ) {
EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
} else if ( myDisplayMode == 2 ) {
EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
} else {
this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b);
}
} else if (! ispreselected ) {
if ( myDisplayMode == 1 ) {
EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
}
else if ( myDisplayMode == 2 )
EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
else
this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
}
else {
if ( myDisplayMode == 1 )
EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
else if ( myDisplayMode == 2 )
EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
else
this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b);
}
this->Property->Render(this, ren);
if (this->BackfaceProperty) {
this->BackfaceProperty->BackfaceRender(this, ren);
this->Device->SetBackfaceProperty(this->BackfaceProperty);
}
this->Device->SetProperty(this->Property);
/* render the texture */
if (this->Texture) {
this->Texture->Render(ren);
}
// Store information on time it takes to render.
// We might want to estimate time from the number of polygons in mapper.
this->Device->Render(ren,bestMapper);
this->EstimatedRenderTime = bestMapper->GetTimeToDraw();
}
int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp)
{
int renderedSomething = 0;
vtkRenderer *ren = (vtkRenderer *)vp;
if ( ! this->Mapper ) {
return 0;
}
// make sure we have a property
if (!this->Property) {
// force creation of a property
this->GetProperty();
}
if ( ishighlighted ) {
if ( myDisplayMode == 1 ) {
EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
} else if ( myDisplayMode == 2 ) {
EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b);
} else {
this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b);
}
} else if (! ispreselected ) {
if ( myDisplayMode == 1 )
EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
else if ( myDisplayMode == 2 )
EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b);
else
this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b);
}
else {
if ( myDisplayMode == 1 )
EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
else if ( myDisplayMode == 2 )
EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b);
else
this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b);
}
// is this actor opaque ?
if (this->GetIsOpaque()) {
this->Property->Render(this, ren);
// render the backface property
if (this->BackfaceProperty) {
this->BackfaceProperty->BackfaceRender(this, ren);
}
// render the texture
if (this->Texture) {
this->Texture->Render(ren);
}
this->Render(ren,this->Mapper);
renderedSomething = 1;
}
return renderedSomething;
}
void SMESH_Actor::SetColor(float r,float g,float b)
{
actorColor.r = r;
actorColor.g = g;
actorColor.b = b;
}
void SMESH_Actor::GetColor(float& r,float& g,float& b)
{
r = actorColor.r;
g = actorColor.g;
b = actorColor.b;
}
void SMESH_Actor::SetPreselectedColor(float r,float g,float b)
{
actorPreselectedColor.r = r;
actorPreselectedColor.g = g;
actorPreselectedColor.b = b;
}
void SMESH_Actor::GetPreselectedColor(float& r,float& g,float& b)
{
r = actorPreselectedColor.r;
g = actorPreselectedColor.g;
b = actorPreselectedColor.b;
}
void SMESH_Actor::SetHighlightColor(float r,float g,float b)
{
actorHighlightColor.r = r;
actorHighlightColor.g = g;
actorHighlightColor.b = b;
}
void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b)
{
r = actorHighlightColor.r;
g = actorHighlightColor.g;
b = actorHighlightColor.b;
}
void SMESH_Actor::SetEdgeColor(float r,float g,float b)
{
edgeColor.r = r;
edgeColor.g = g;
edgeColor.b = b;
}
void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b)
{
r = edgeColor.r;
g = edgeColor.g;
b = edgeColor.b;
}
void SMESH_Actor::SetEdgeHighlightColor(float r,float g,float b)
{
edgeHighlightColor.r = r;
edgeHighlightColor.g = g;
edgeHighlightColor.b = b;
}
void SMESH_Actor::GetEdgeHighlightColor(float& r,float& g,float& b)
{
r = edgeHighlightColor.r;
g = edgeHighlightColor.g;
b = edgeHighlightColor.b;
}
void SMESH_Actor::SetEdgePreselectedColor(float r,float g,float b)
{
edgePreselectedColor.r = r;
edgePreselectedColor.g = g;
edgePreselectedColor.b = b;
}
void SMESH_Actor::GetEdgePreselectedColor(float& r,float& g,float& b)
{
r = edgePreselectedColor.r;
g = edgePreselectedColor.g;
b = edgePreselectedColor.b;
}
void SMESH_Actor::SetNodeColor(float r,float g,float b)
{
actorNodeColor.r = r ;
actorNodeColor.g = g ;
actorNodeColor.b = b ;
}
void SMESH_Actor::GetNodeColor(float& r,float& g,float& b)
{
r = actorNodeColor.r ;
g = actorNodeColor.g ;
b = actorNodeColor.b ;
}
void SMESH_Actor::SetNodeSize(int size)
{
actorNodeSize = size ;
}
int SMESH_Actor::GetNodeSize()
{
return actorNodeSize ;
}
void SMESH_Actor::AddNode(int idSMESHDSnode,int idVTKnode)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->AddNode(idSMESHDSnode, idVTKnode);
} else
MESSAGE("AddNode() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::AddElement(int idSMESHDSelement, int idVTKelement)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->AddElement(idSMESHDSelement, idVTKelement);
} else
MESSAGE("AddElement() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->SetIdsVTKNode(mapVTK);
} else
MESSAGE("SetIdsVTKNode() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->SetIdsSMESHDSNode(mapSMESHDS);
} else
MESSAGE("SetIdsSMESHDSNode() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->SetIdsVTKElement(mapVTK);
} else
MESSAGE("SetIdsVTKElement() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->SetIdsSMESHDSElement(mapSMESHDS);
} else
MESSAGE("SetIdsSMESHDSElement() method has been moved to SMESH_Grid class");
}
int SMESH_Actor::GetIdVTKNode(int idSMESHDSnode)
{
if (DataSource->IsA("SMESH_Grid")) {
return ((SMESH_Grid*)DataSource)->GetIdVTKNode(idSMESHDSnode);
} else {
MESSAGE("GetIdVTKNode() method has been moved to SMESH_Grid class");
return -1;
}
}
int SMESH_Actor::GetIdVTKElement(int idSMESHDSelement)
{
if (DataSource->IsA("SMESH_Grid")) {
return ((SMESH_Grid*)DataSource)->GetIdVTKElement(idSMESHDSelement);
} else {
MESSAGE("GetIdVTKElement() method has been moved to SMESH_Grid class");
return -1;
}
}
int SMESH_Actor::GetIdSMESHDSNode(int idVTKnode)
{
if (DataSource->IsA("SMESH_Grid")) {
return ((SMESH_Grid*)DataSource)->GetIdSMESHDSNode(idVTKnode);
} else {
MESSAGE("GetIdSMESHDSNode() method has been moved to SMESH_Grid class");
return -1;
}
}
int SMESH_Actor::GetIdSMESHDSElement(int idVTKelement)
{
if (DataSource->IsA("SMESH_Grid")) {
return ((SMESH_Grid*)DataSource)->GetIdSMESHDSElement(idVTKelement);
} else {
MESSAGE("AddNode() method has been moved to SMESH_Grid class");
return -1;
}
}
void SMESH_Actor::ClearNode()
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->ClearNode();
} else
MESSAGE("ClearNode() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::ClearElement()
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->ClearElement();
} else
MESSAGE("ClearElement() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::RemoveNode(int id)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->RemoveNode(id);
} else
MESSAGE("RemoveNode() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::RemoveElement(int id)
{
if (DataSource->IsA("SMESH_Grid")) {
((SMESH_Grid*)DataSource)->RemoveElement(id);
} else
MESSAGE("RemoveElement() method has been moved to SMESH_Grid class");
}
void SMESH_Actor::setDisplayMode(int thenewmode) {
myDisplayMode = thenewmode;
if ( myDisplayMode == 1 ) {
EdgeDevice->VisibilityOn();
EdgeShrinkDevice->VisibilityOff();
} else if ( myDisplayMode == 2 ) {
EdgeDevice->VisibilityOff();
EdgeShrinkDevice->VisibilityOn();
} else {
EdgeDevice->VisibilityOff();
EdgeShrinkDevice->VisibilityOff();
}
}
float SMESH_Actor::GetShrinkFactor()
{
return myShrinkFactor;
}
void SMESH_Actor::SetShrinkFactor(float value )
{
if ( value <= 0.1 )
value = 0.8;
myShrinkFactor = value;
}
void SMESH_Actor::GetChildActors(vtkActorCollection* actors)
{
actors->AddItem(EdgeDevice);
actors->AddItem(EdgeShrinkDevice);
}
void SMESH_Actor::SetVisibility(bool visibility)
{
if ( visibility ) {
this->VisibilityOn();
if ( myDisplayMode == 1 ) {
EdgeDevice->VisibilityOn();
EdgeShrinkDevice->VisibilityOff();
} else if ( myDisplayMode == 2 ) {
EdgeDevice->VisibilityOff();
EdgeShrinkDevice->VisibilityOn();
} else {
EdgeDevice->VisibilityOff();
EdgeShrinkDevice->VisibilityOff();
}
} else {
this->VisibilityOff();
EdgeDevice->VisibilityOff();
EdgeShrinkDevice->VisibilityOff();
}
}

137
src/OBJECT/SMESH_Actor.h Normal file
View File

@ -0,0 +1,137 @@
// File : SMESH_Actor.h
// Created : Mon May 13 22:30:51 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESH_ACTOR_H
#define SMESH_ACTOR_H
#include "SALOME_Actor.h"
// VTK Includes
#include <vtkActor.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGridReader.h>
// Open CASCADE Includes
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx>
typedef struct rgbStruct
{
float r;
float g;
float b;
} RGBStruct;
class SMESH_Actor : public SALOME_Actor {
public:
vtkTypeMacro(SMESH_Actor,SALOME_Actor);
static SMESH_Actor* New();
// Description:
// This causes the actor to be rendered. It, in turn, will render the actor`s
// property and then mapper.
virtual void Render(vtkRenderer *, vtkMapper *);
// Description:
// This method is used internally by the rendering process.
// We overide the superclass method to properly set the estimated render time.
int RenderOpaqueGeometry(vtkViewport *viewport);
void ShallowCopy(vtkProp *prop);
void setReader(vtkUnstructuredGridReader* r) ;
vtkUnstructuredGridReader* getReader();
// Highlight
virtual bool hasHighlight() { return true; }
vtkMapper* getMapper();
void setDisplayMode(int);
void SetColor(float r,float g,float b);
void GetColor(float& r,float& g,float& b);
void SetHighlightColor(float r,float g,float b);
void GetHighlightColor(float& r,float& g,float& b);
void SetPreselectedColor(float r,float g,float b);
void GetPreselectedColor(float& r,float& g,float& b);
void SetEdgeColor(float r,float g,float b);
void GetEdgeColor(float& r,float& g,float& b);
void SetEdgeHighlightColor(float r,float g,float b);
void GetEdgeHighlightColor(float& r,float& g,float& b);
void SetEdgePreselectedColor(float r,float g,float b);
void GetEdgePreselectedColor(float& r,float& g,float& b);
void SetNodeColor(float r,float g,float b);
void GetNodeColor(float& r,float& g,float& b);
void SetNodeSize(int size) ;
int GetNodeSize() ;
void ClearNode();
void ClearElement();
void RemoveNode(int idSMESHDSnode);
void RemoveElement(int idSMESHDSelement);
void AddNode(int idSMESHDSnode, int idVTKnode);
void AddElement(int idSMESHDSelement, int idVTKelement);
int GetIdVTKNode(int idSMESHDSnode);
int GetIdVTKElement(int idSMESHDSelement);
int GetIdSMESHDSNode(int idVTKnode);
int GetIdSMESHDSElement(int idVTKelement);
void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK);
void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK);
void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
vtkDataSet* DataSource;
vtkActor* EdgeDevice;
vtkActor* EdgeShrinkDevice;
float GetShrinkFactor();
void SetShrinkFactor(float value );
void GetChildActors(vtkActorCollection*);
void SetVisibility(bool visibility);
protected:
SMESH_Actor();
~SMESH_Actor();
SMESH_Actor(const SMESH_Actor&) {};
void operator=(const SMESH_Actor&) {};
vtkUnstructuredGridReader* myReader;
float myShrinkFactor;
RGBStruct edgeColor;
RGBStruct edgeHighlightColor;
RGBStruct edgePreselectedColor;
RGBStruct actorColor;
RGBStruct actorHighlightColor;
RGBStruct actorPreselectedColor;
RGBStruct actorNodeColor; // LPN
int actorNodeSize; // LPN
};
#endif //SMESH_ACTOR_H

141
src/OBJECT/SMESH_Grid.cxx Normal file
View File

@ -0,0 +1,141 @@
using namespace std;
// File: SMESH_Grid.cxx
// Created: Fri Sep 27 15:47:42 2002
// Author: Nicolas REJNERI
#include "SMESH_Grid.h"
#include "utilities.h"
// VTK Includes
#include <vtkObjectFactory.h>
SMESH_Grid* SMESH_Grid::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Grid");
if(ret)
{
return (SMESH_Grid*)ret;
}
// If the factory was unable to create the object, then create it here.
return new SMESH_Grid;
}
void SMESH_Grid::AddNode(int idSMESHDSnode,int idVTKnode)
{
myMapNodeSMDStoVTK.Bind(idSMESHDSnode, idVTKnode);
myMapNodeVTKtoSMDS.Bind(idVTKnode, idSMESHDSnode);
}
void SMESH_Grid::AddElement(int idSMESHDSelement, int idVTKelement)
{
myMapElementSMDStoVTK.Bind(idSMESHDSelement, idVTKelement);
myMapElementVTKtoSMDS.Bind(idVTKelement, idSMESHDSelement);
}
void SMESH_Grid::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK)
{
myMapNodeVTKtoSMDS = mapVTK;
}
void SMESH_Grid::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
{
myMapNodeSMDStoVTK = mapSMESHDS;
}
void SMESH_Grid::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK)
{
myMapElementVTKtoSMDS = mapVTK;
}
void SMESH_Grid::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
{
myMapElementSMDStoVTK = mapSMESHDS;
}
int SMESH_Grid::GetIdVTKNode(int idSMESHDSnode)
{
if ( myMapNodeSMDStoVTK.IsBound( idSMESHDSnode ) )
return myMapNodeSMDStoVTK.Find(idSMESHDSnode);
else {
MESSAGE("GetIdVTKNode(): SMDS node not found: " << idSMESHDSnode);
return -1;
}
}
int SMESH_Grid::GetIdVTKElement(int idSMESHDSelement)
{
if ( myMapElementSMDStoVTK.IsBound( idSMESHDSelement ) )
return myMapElementSMDStoVTK.Find(idSMESHDSelement);
else {
MESSAGE("GetIdVTKElement(): SMDS element not found: " << idSMESHDSelement);
return -1;
}
}
int SMESH_Grid::GetIdSMESHDSNode(int idVTKnode)
{
if ( myMapNodeVTKtoSMDS.IsBound( idVTKnode ) )
return myMapNodeVTKtoSMDS.Find(idVTKnode);
else {
MESSAGE("GetIdSMESHDSNode(): VTK node not found: " << idVTKnode);
return -1;
}
}
int SMESH_Grid::GetIdSMESHDSElement(int idVTKelement)
{
if ( myMapElementVTKtoSMDS.IsBound( idVTKelement ) )
return myMapElementVTKtoSMDS.Find(idVTKelement);
else {
MESSAGE("GetIdSMESHDSElement(): VTK element not found: " << idVTKelement);
return -1;
}
}
void SMESH_Grid::ClearNode()
{
myMapNodeVTKtoSMDS.Clear();
myMapNodeSMDStoVTK.Clear();
}
void SMESH_Grid::ClearElement()
{
myMapElementVTKtoSMDS.Clear();
myMapElementSMDStoVTK.Clear();
}
void SMESH_Grid::RemoveNode(int id)
{
if ( myMapNodeSMDStoVTK.IsBound( id ) ) {
int idVTK = myMapNodeSMDStoVTK.Find(id);
myMapNodeSMDStoVTK.UnBind(id);
if ( myMapNodeVTKtoSMDS.IsBound( idVTK ) ) {
myMapNodeVTKtoSMDS.UnBind(idVTK);
}
}
}
void SMESH_Grid::RemoveElement(int id)
{
if ( myMapElementSMDStoVTK.IsBound( id ) ) {
int idVTK = myMapElementSMDStoVTK.Find(id);
myMapElementSMDStoVTK.UnBind(id);
if ( myMapElementVTKtoSMDS.IsBound( idVTK ) ) {
myMapElementVTKtoSMDS.UnBind(idVTK);
}
}
}
void SMESH_Grid::DeepCopy(vtkDataObject *src)
{
SMESH_Grid* srcGrid = SMESH_Grid::SafeDownCast(src);
if (srcGrid != NULL) {
CopyMaps(srcGrid);
}
vtkUnstructuredGrid::DeepCopy(src);
}
void SMESH_Grid::CopyMaps(SMESH_Grid *srcGrid)
{
this->myMapNodeVTKtoSMDS = srcGrid->myMapNodeVTKtoSMDS;
this->myMapNodeSMDStoVTK = srcGrid->myMapNodeSMDStoVTK;
this->myMapElementVTKtoSMDS = srcGrid->myMapElementVTKtoSMDS;
this->myMapElementSMDStoVTK = srcGrid->myMapElementSMDStoVTK;
}

61
src/OBJECT/SMESH_Grid.h Normal file
View File

@ -0,0 +1,61 @@
// File : SMESH_Grid.h
// Created : Fri Sep 27 15:30:51 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESH_GRID_H
#define SMESH_GRID_H
// VTK Includes
#include <vtkUnstructuredGrid.h>
// Open CASCADE Includes
#include <TColStd_DataMapOfIntegerInteger.hxx>
class SMESH_Grid : public vtkUnstructuredGrid {
public:
vtkTypeMacro(SMESH_Grid, vtkUnstructuredGrid);
static SMESH_Grid* New();
void ClearNode();
void ClearElement();
void RemoveNode(int idSMESHDSnode);
void RemoveElement(int idSMESHDSelement);
void AddNode(int idSMESHDSnode, int idVTKnode);
void AddElement(int idSMESHDSelement, int idVTKelement);
int GetIdVTKNode(int idSMESHDSnode);
int GetIdVTKElement(int idSMESHDSelement);
int GetIdSMESHDSNode(int idVTKnode);
int GetIdSMESHDSElement(int idVTKelement);
void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK);
void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK);
void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
virtual void DeepCopy (vtkDataObject *src);
void CopyMaps(SMESH_Grid *src);
protected:
SMESH_Grid() : vtkUnstructuredGrid() {};
TColStd_DataMapOfIntegerInteger myMapNodeVTKtoSMDS;
TColStd_DataMapOfIntegerInteger myMapNodeSMDStoVTK;
TColStd_DataMapOfIntegerInteger myMapElementVTKtoSMDS;
TColStd_DataMapOfIntegerInteger myMapElementSMDStoVTK;
};
#endif

View File

@ -0,0 +1,89 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
#ifndef _Handle_SMESH_TypeFilter_HeaderFile
#define _Handle_SMESH_TypeFilter_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_SALOME_Filter_HeaderFile
#include "Handle_SALOME_Filter.hxx"
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(SALOME_Filter);
class SMESH_TypeFilter;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SMESH_TypeFilter);
class Handle(SMESH_TypeFilter) : public Handle(SALOME_Filter) {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
Handle(SMESH_TypeFilter)():Handle(SALOME_Filter)() {}
Handle(SMESH_TypeFilter)(const Handle(SMESH_TypeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle)
{
}
Handle(SMESH_TypeFilter)(const SMESH_TypeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem)
{
}
Handle(SMESH_TypeFilter)& operator=(const Handle(SMESH_TypeFilter)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(SMESH_TypeFilter)& operator=(const SMESH_TypeFilter* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
SMESH_TypeFilter* operator->()
{
return (SMESH_TypeFilter *)ControlAccess();
}
SMESH_TypeFilter* operator->() const
{
return (SMESH_TypeFilter *)ControlAccess();
}
Standard_EXPORT ~Handle(SMESH_TypeFilter)();
Standard_EXPORT static const Handle(SMESH_TypeFilter) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -0,0 +1,40 @@
# -* Makefile *-
#
# Author : Patrick GOLDBRONN (CEA)
# Date : 29/06/2001
# $Header$
#
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libSMESHFiltersSelection.la
LIB_SRC = SMESH_TypeFilter.cxx
LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl
# header files
EXPORT_HEADERS= SMESH_Type.h \
SMESH_TypeFilter.hxx \
Handle_SMESH_TypeFilter.hxx
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
# additional file to be cleaned
MOSTLYCLEAN =
CLEAN =
DISTCLEAN =
@CONCLUDE@

View File

@ -0,0 +1,21 @@
// File : SMESH_Type.h
// Created : Mon Jun 03 15:14:15 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
enum MeshObjectType {
HYPOTHESIS,
ALGORITHM,
MESH,
SUBMESH,
MESHorSUBMESH,
SUBMESH_VERTEX,
SUBMESH_EDGE,
SUBMESH_FACE,
SUBMESH_SOLID,
SUBMESH_COMPOUND
};

View File

@ -0,0 +1,139 @@
using namespace std;
// File : SMESH_TypeFilter.cxx
// Created : Fri Dec 07 09:57:24 2001
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE
// $Header$
#include "SMESH_TypeFilter.ixx"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_TypeFilter.hxx"
#include "utilities.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType)
{
myKind = aType;
}
Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const
{
Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "MESH" );
if ( !meshFilter->IsOk(anObj) )
return false;
if ( anObj->hasEntry() ) {
QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() );
bool Ok = false;
switch ( myKind )
{
case HYPOTHESIS:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
Ok = true;
break;
}
case ALGORITHM:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
Ok = true;
break;
}
case MESH:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
Ok = true;
break;
}
case SUBMESH:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
Ok = true;
break;
}
case MESHorSUBMESH:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) )
Ok = true;
if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) )
Ok = true;
break;
}
case SUBMESH_VERTEX:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
Ok = true;
break;
}
case SUBMESH_EDGE:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
Ok = true;
break;
}
case SUBMESH_FACE:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
Ok = true;
break;
}
case SUBMESH_SOLID:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
Ok = true;
break;
}
case SUBMESH_COMPOUND:
{
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 ))
Ok = true;
break;
}
}
if ( Ok )
return true;
}
return false;
}

View File

@ -0,0 +1,95 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#ifndef _SMESH_TypeFilter_HeaderFile
#define _SMESH_TypeFilter_HeaderFile
#ifndef _Handle_SMESH_TypeFilter_HeaderFile
#include "Handle_SMESH_TypeFilter.hxx"
#endif
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Filter.hxx"
#include "SMESH_Type.h"
// Open CASCADE Includes
#include <Standard.hxx>
class SMESH_TypeFilter : public SALOME_Filter {
public:
inline void* operator new(size_t,void* anAddress)
{
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
// Methods PUBLIC
//
Standard_EXPORT SMESH_TypeFilter(MeshObjectType aType);
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const;
Standard_EXPORT ~SMESH_TypeFilter();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& SMESH_TypeFilter_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
MeshObjectType myKind;
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,71 @@
// File generated by CPPExt (Transient)
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#include "SMESH_TypeFilter.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
SMESH_TypeFilter::~SMESH_TypeFilter() {}
Standard_EXPORT Handle_Standard_Type& SMESH_TypeFilter_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter);
static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
static Handle_Standard_Type _aType = new Standard_Type("SMESH_TypeFilter",
sizeof(SMESH_TypeFilter),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(SMESH_TypeFilter) Handle(SMESH_TypeFilter)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(SMESH_TypeFilter) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(SMESH_TypeFilter))) {
_anOtherObject = Handle(SMESH_TypeFilter)((Handle(SMESH_TypeFilter)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& SMESH_TypeFilter::DynamicType() const
{
return STANDARD_TYPE(SMESH_TypeFilter) ;
}
Standard_Boolean SMESH_TypeFilter::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(SMESH_TypeFilter) == AType || SALOME_Filter::IsKind(AType));
}
Handle_SMESH_TypeFilter::~Handle_SMESH_TypeFilter() {}

View File

@ -0,0 +1,3 @@
#ifndef _SMESH_TypeFilter_HeaderFile
#include "SMESH_TypeFilter.hxx"
#endif

111
src/SMESHGUI/Makefile.in Normal file
View File

@ -0,0 +1,111 @@
# -* Makefile *-
#
# Author : Nicolas REJNERI
# Date : Sun May 05 11:45:40 2002
# $Header$
#
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome
@COMMENCE@
# header files
EXPORT_HEADERS= SMESHGUI_Swig.hxx \
SMESHGUI_Swig.i
# .po files to transform in .qm
PO_FILES = \
SMESH_icons.po \
SMESH_msg_en.po
# Libraries targets
LIB = libSMESHGUI.la
LIB_SRC = SMESHGUI.cxx \
SMESHGUI_StudyAPI.cxx \
SMESHGUI_SpinBox.cxx \
SMESHGUI_NodesDlg.cxx \
SMESHGUI_AddHypothesisDlg.cxx \
SMESHGUI_AddAlgorithmDlg.cxx \
SMESHGUI_InitMeshDlg.cxx \
SMESHGUI_AddSubMeshDlg.cxx \
SMESHGUI_LocalLengthDlg.cxx \
SMESHGUI_NbSegmentsDlg.cxx \
SMESHGUI_TransparencyDlg.cxx \
SMESHGUI_RemoveNodesDlg.cxx \
SMESHGUI_RemoveElementsDlg.cxx \
SMESHGUI_MeshInfosDlg.cxx \
SMESHGUI_Preferences_ColorDlg.cxx \
SMESHGUI_MaxElementAreaDlg.cxx \
SMESHGUI_Preferences_ScalarBarDlg.cxx \
SMESHGUI_EditScalarBarDlg.cxx \
SMESHGUI_aParameterDlg.cxx \
SMESHGUI_MaxElementVolumeDlg.cxx \
SMESHGUI_Swig.cxx \
SMESHGUI_ComputeScalarValue.cxx \
SMESHGUI_MoveNodesDlg.cxx \
SMESHGUI_OrientationElementsDlg.cxx \
SMESHGUI_DiagonalInversionDlg.cxx \
SMESHGUI_EdgesConnectivityDlg.cxx \
SMESHGUI_AddFaceDlg.cxx \
SMESHGUI_AddVolumeDlg.cxx \
SMESHGUI_AddEdgeDlg.cxx \
SMESHGUI_EditHypothesesDlg.cxx
LIB_MOC = \
SMESHGUI.h \
SMESHGUI_NodesDlg.h \
SMESHGUI_SpinBox.h \
SMESHGUI_AddHypothesisDlg.h \
SMESHGUI_AddAlgorithmDlg.h \
SMESHGUI_InitMeshDlg.h \
SMESHGUI_AddSubMeshDlg.h \
SMESHGUI_LocalLengthDlg.h \
SMESHGUI_NbSegmentsDlg.h \
SMESHGUI_TransparencyDlg.h \
SMESHGUI_RemoveNodesDlg.h \
SMESHGUI_RemoveElementsDlg.h \
SMESHGUI_MeshInfosDlg.h \
SMESHGUI_Preferences_ColorDlg.h \
SMESHGUI_MaxElementAreaDlg.h \
SMESHGUI_Preferences_ScalarBarDlg.h \
SMESHGUI_EditScalarBarDlg.h \
SMESHGUI_aParameterDlg.h \
SMESHGUI_MaxElementVolumeDlg.h \
SMESHGUI_MoveNodesDlg.h \
SMESHGUI_OrientationElementsDlg.h \
SMESHGUI_DiagonalInversionDlg.h \
SMESHGUI_EdgesConnectivityDlg.h \
SMESHGUI_AddEdgeDlg.h \
SMESHGUI_AddVolumeDlg.h \
SMESHGUI_AddFaceDlg.h \
SMESHGUI_EditHypothesesDlg.h
LIB_CLIENT_IDL = SALOME_Exception.idl \
GEOM_Gen.idl \
GEOM_Shape.idl \
SMESH_Gen.idl \
SMESH_Mesh.idl \
SMESH_Hypothesis.idl \
SMESH_BasicHypothesis.idl \
SALOMEDS.idl \
SALOMEDS_Attributes.idl \
SALOME_ModuleCatalog.idl \
SALOME_Component.idl \
MED.idl
LIB_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
#$(OCC_CXXFLAGS)
LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lSMESHObject -lSMDS -lSMESHDS -lSMESHFiltersSelection -lGeometryClient -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV $(OCC_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@

6013
src/SMESHGUI/SMESHGUI.cxx Normal file

File diff suppressed because it is too large Load Diff

297
src/SMESHGUI/SMESHGUI.h Normal file
View File

@ -0,0 +1,297 @@
// File : SMESHGUI.h
// Created : Sun May 05 11:45:40 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_HeaderFile
#define SMESHGUI_HeaderFile
#include "TColStd_MapOfInteger.hxx"
#include "SMESHDS_Document.hxx"
// SALOME Includes
#include "QAD_Desktop.h"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "SMESH_Actor.h"
#include "SMESHGUI_StudyAPI.h"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// QT Includes
#include <qstringlist.h>
// VTK Inlcudes
#include <vtkScalarBarActor.h>
//=================================================================================
// class : SMESHGUI
// purpose :
//=================================================================================
class SMESHGUI : public QObject
{
Q_OBJECT
private :
QAD_Desktop* myDesktop;
QAD_Study* myActiveStudy;
SMESH::SMESH_Gen_var myComponentMesh;
GEOM::GEOM_Gen_var myComponentGeom;
QDialog* myActiveDialogBox;
int myNbMesh ;
int myState ;
vtkActorCollection* mySimulationActors;
vtkActor2DCollection* mySimulationActors2D;
SMESH_Actor* myCurrentMesh;
SALOMEDS::Study_var myStudy;
int myStudyId;
SMESHGUI_StudyAPI myStudyAPI;
// vtkScalarBarActor* myScalarBar;
Handle_SMESHDS_Document myDocument;//NBU
bool myAutomaticUpdate;
public :
SMESHGUI();
~SMESHGUI();
static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
static SMESHGUI* GetSMESHGUI() ;
QAD_Study* GetActiveStudy() ;
QAD_Desktop* GetDesktop() ;
SALOMEDS::Study_ptr GetStudy();
SMESHGUI_StudyAPI GetStudyAPI();
vtkScalarBarActor* GetScalarBar();
QDialog* GetActiveDialogBox() ;
void SetActiveDialogBox(QDialog* aDlg) ;
void SetState(int aState) ;
void ResetState() ;
bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
/* Managed by IAPP */
Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ;
Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent,
QAD_StudyFrame* studyFrame );
Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent,
QAD_StudyFrame* studyFrame );
Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent,
QAD_StudyFrame* studyFrame );
Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent );
Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent );
Standard_EXPORT static void DefinePopup( QString & theContext,
QString & theParent,
QString & theObject );
Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent,
QPopupMenu* popup,
const QString& theContext,
const QString& theParent,
const QString& theObject );
Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&);
void OnEditDelete();
/* Mesh Management */
SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
/* Hypothesis Management */
SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis );
void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ;
void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ;
void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ;
void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length );
void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, double nbSegments );
void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea );
void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume );
/* Algorithms Management */
void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp );
void CreateAlgorithm( QString TypeAlgo, QString NameAlgo );
/* NODES */
void ViewNodes();
vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ;
void AddNodes( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
void RemoveNode(SMESH_Actor*, int idnode) ;
void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
void RemoveNodes(SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
/* EDGES */
void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ;
void AddEdges( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
/* TRIANGLES */
void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ;
void AddTriangles( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
/* QUADRANGLES */
void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2,
int idnode3, int idnode4) ;
void AddQuadrangles( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
/* VOLUMES */
void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2,
int idnode3, int idnode4) ;
void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2,
int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ;
void AddTetras( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void AddHexaedres( SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
/* ELEMENTS */
void RemoveElement(SMESH_Actor*, int idnode);
void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
void RemoveElements(SMESH_Actor* Mactor, int number,
const SMESH::double_array& coords, const SMESH::long_array& indexes);
void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
/* Simulation management */
void EraseSimulationActors() ;
/* Non modal dialog boxes magement */
void EmitSignalDeactivateDialog() ;
void EmitSignalCloseAllDialogs() ;
/* Selection management */
int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
Standard_Boolean& testResult ) ;
SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
/* Geometry Client */
GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
Standard_Boolean& testResult ) ;
/* Popup management */
QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
QString CheckHomogeneousSelection();
/* Scripts management */
SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
/* Actors management */
void Dump(SMESH_Actor* Mactor);
void SetViewMode(int commandId);
void ChangeRepresentation( SMESH_Actor* ac, int type );
SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh,
Standard_Boolean& testResult,
bool onlyInActiveView);
SMESH_Actor* FindActorByEntry(QString entry,
Standard_Boolean& testResult,
bool onlyInActiveView);
void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
void DisplayActor(SMESH_Actor* ac, bool visibility = true);
void EraseActor(SMESH_Actor* ac);
bool AddActorInSelection(SMESH_Actor* ac);
void UpdateView();
void Update();
void Update(const Handle(SALOME_InteractiveObject)& IO);
void ScalarVisibilityOff();
/* Settings management */
void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
QString Bold, QString Italic, QString Shadow, QString Font,
QString Orientation, float Width, float Height,
int NbColors, int NbLabels);
void DisplayScalarBar(bool visibility);
void UpdateScalarBar(float MinRange, float MaxRange);
void SetDisplaySettings();
SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
/* Control management */
void Control(int theCommandID);
/* Parameter functions */
double Parameter( Standard_Boolean& res, const double aValue,
const char* aLabel, const char* aTitle,
const double bottom, const double top, const int decimals ) ;
int Parameter( Standard_Boolean& res, const int aValue,
const char* aLabel, const char* aTitle,
const int bottom, const int top ) ;
static void setOrb();
/* Import/Export */ //NBU
static void Import_Document(QAD_Desktop* parent, int theCommandID);
static void Export_Document(QAD_Desktop* parent, int theCommandID);
static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
signals:
void SignalDeactivateActiveDialog() ;
void SignalCloseAllDialogs() ;
};
#endif

View File

@ -0,0 +1,448 @@
using namespace std;
// File : SMESHGUI_AddAlgorithmDlg.cxx
// Created : Wed May 22 19:05:31 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESHGUI
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddAlgorithmDlg.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qevent.h>
//=================================================================================
// class : SMESHGUI_AddAlgorithmDlg()
// purpose : Constructs a SMESHGUI_AddAlgorithmDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_AddAlgorithmDlg::SMESHGUI_AddAlgorithmDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_ALGORITHM")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddAlgorithmDlg" );
resize( 322, 220 );
setCaption( tr( "SMESH_ADD_ALGORITHM_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddAlgorithmDlgLayout = new QGridLayout( this );
SMESHGUI_AddAlgorithmDlgLayout->setSpacing( 6 );
SMESHGUI_AddAlgorithmDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_ADD_ALGORITHM" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupConstructor1->setColumnLayout(0, Qt::Vertical );
GroupConstructor1->layout()->setSpacing( 0 );
GroupConstructor1->layout()->setMargin( 0 );
GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() );
GroupConstructor1Layout->setAlignment( Qt::AlignTop );
GroupConstructor1Layout->setSpacing( 6 );
GroupConstructor1Layout->setMargin( 11 );
LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" );
LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 );
LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" );
LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 );
SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" );
SelectButtonC1A1Hyp->setText( tr( "" ) );
SelectButtonC1A1Hyp->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 );
SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" );
SelectButtonC1A2Mesh->setText( tr( "" ) );
SelectButtonC1A2Mesh->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 );
TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" );
TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) );
TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 );
TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" );
TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_ALGORITHM" ) );
TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 );
SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructor1, 1, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_1, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~SMESHGUI_AddAlgorithmDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddAlgorithmDlg::~SMESHGUI_AddAlgorithmDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myConstructorId = 0 ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Hyp ;
Constructor1->setChecked( TRUE );
myOkMesh = myOkSubMesh = myOkAlgorithm = false ;
myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::ConstructorsClicked(int constructorId)
{
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Hyp ;
LineEditC1A2Mesh->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkMesh = myOkSubMesh = myOkAlgorithm = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkMesh && myOkAlgorithm ) {
SALOME_ListIteratorOfListIO It( AlgoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ;
}
} else if ( myOkSubMesh && myOkAlgorithm ) {
SALOME_ListIteratorOfListIO It( AlgoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ;
}
}
break ;
}
}
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( myEditCurrentArgument == LineEditC1A2Mesh ) {
if ( nbSel == 1 ) {
Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
QString aName = IObject->getName();
Standard_Boolean testResult;
myOkMesh = true ;
myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ;
if( !testResult ) {
myOkMesh = false;
myOkSubMesh = true;
mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ;
if( !testResult ) {
myOkSubMesh = false;
return ;
}
}
LineEditC1A2Mesh->setText(aString) ;
}
else {
myOkMesh = myOkSubMesh = false ;
return ;
}
}
else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
if ( nbSel >= 1 ) {
AlgoList.Clear(); // = mySelection->StoredIObjects() ;
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
AlgoList.Append(Itinit.Value());
}
myOkAlgorithm = true ;
if (nbSel > 1)
aString = tr("%1 Algorithms").arg(nbSel) ;
LineEditC1A1Hyp->setText(aString) ;
}
else {
myOkAlgorithm = false ;
return ;
}
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Hyp ) {
LineEditC1A1Hyp->setFocus() ;
myEditCurrentArgument = LineEditC1A1Hyp ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myAlgorithmFilter) ;
}
else if(send == SelectButtonC1A2Mesh) {
LineEditC1A2Mesh->setFocus() ;
myEditCurrentArgument = LineEditC1A2Mesh;
mySelection->ClearFilters() ;
mySelection->AddFilter(myMeshOrSubMeshFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::LineEditReturnPressed()
{
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddAlgorithmDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}

View File

@ -0,0 +1,112 @@
// File : SMESHGUI_AddAlgorithmDlg.h
// Created : Wed May 22 19:05:13 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESHGUI
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_ALGORITHM_H
#define DIALOGBOX_ADD_ALGORITHM_H
#include "SALOME_Selection.h"
#include "SMESH_TypeFilter.hxx"
#include "SALOME_ListIO.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_AddAlgorithmDlg
// purpose :
//=================================================================================
class SMESHGUI_AddAlgorithmDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddAlgorithmDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddAlgorithmDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESH::SMESH_Gen_var myCompMesh ;
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh;
SMESH::SMESH_Hypothesis_var myAlgorithm;
Handle(SMESH_TypeFilter) myAlgorithmFilter;
Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter;
bool myOkMesh ;
bool myOkSubMesh ;
bool myOkAlgorithm;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SALOME_ListIO AlgoList;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Hyp;
QLineEdit* LineEditC1A2Mesh;
QPushButton* SelectButtonC1A1Hyp;
QPushButton* SelectButtonC1A2Mesh;
QLabel* TextLabelC1A2Mesh;
QLabel* TextLabelC1A1Hyp;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_AddAlgorithmDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_ADD_ALGORITHM_H

View File

@ -0,0 +1,370 @@
using namespace std;
// File : SMESHGUI_AddEdgeDlg.cxx
// Created : Wed Jun 26 21:00:14 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddEdgeDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qcheckbox.h>
//=================================================================================
// class : SMESHGUI_AddEdgeDlg()
// purpose :
//=================================================================================
SMESHGUI_AddEdgeDlg::SMESHGUI_AddEdgeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
myNodes = 2;
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_LINE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddEdgeDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_ADD_EDGE_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddEdgeDlgLayout = new QGridLayout( this );
SMESHGUI_AddEdgeDlgLayout->setSpacing( 6 );
SMESHGUI_AddEdgeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_EDGE" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_AddEdgeDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddEdgeDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ADD_EDGE" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_AddEdgeDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_AddEdgeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddEdgeDlg::~SMESHGUI_AddEdgeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkNodes = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddEdgeDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkNodes) {
mySMESHGUI->EraseSimulationActors();
mySMESHGUI->AddEdge( myMesh, myMapIndex ) ;
mySMESHGUI->ViewNodes();
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_AddEdgeDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkNodes = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes < 1)
return ;
if ( mySelection->SelectionMode() != 1 ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
if ( myNodes == 2 && nbNodes == 2 ) {
mySMESHGUI->DisplaySimulationEdge(myMesh, myMapIndex);
myOkNodes = true ;
} else {
// mySMESHGUI->EraseSimulationActors();
myOkNodes = false ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddEdgeDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,97 @@
// File : SMESHGUI_AddEdgeDlg.h
// Created : Wed Jun 26 21:00:41 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_EDGE_H
#define DIALOGBOX_ADD_EDGE_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_AddEdgeDlg
// purpose :
//=================================================================================
class SMESHGUI_AddEdgeDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddEdgeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddEdgeDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */
int myNodes ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_AddEdgeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ADD_EDGE_H

View File

@ -0,0 +1,414 @@
using namespace std;
// File : SMESHGUI_AddFaceDlg.cxx
// Created : Wed Jun 26 21:00:14 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddFaceDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qcheckbox.h>
//=================================================================================
// class : SMESHGUI_AddFaceDlg()
// purpose :
//=================================================================================
SMESHGUI_AddFaceDlg::SMESHGUI_AddFaceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
int nbNodes, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
myNodes = nbNodes;
QPixmap image0;
if ( myNodes == 3 )
image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_TRIANGLE")));
else if ( myNodes == 4 )
image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_QUADRANGLE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddFaceDlg" );
resize( 303, 185 );
if ( myNodes == 3 )
setCaption( tr( "SMESH_ADD_TRIANGLE_TITLE" ) );
else if ( myNodes == 4 )
setCaption( tr( "SMESH_ADD_QUADRANGLE_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddFaceDlgLayout = new QGridLayout( this );
SMESHGUI_AddFaceDlgLayout->setSpacing( 6 );
SMESHGUI_AddFaceDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
if ( myNodes == 3 )
GroupConstructors->setTitle( tr( "SMESH_TRIANGLE" ) );
else if ( myNodes == 4 )
GroupConstructors->setTitle( tr( "SMESH_QUADRANGLE" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_AddFaceDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddFaceDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
if ( myNodes == 3 )
GroupC1->setTitle( tr( "SMESH_ADD_TRIANGLE" ) );
else if ( myNodes == 4 )
GroupC1->setTitle( tr( "SMESH_ADD_QUADRANGLE" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
Reverse = new QCheckBox( GroupC1, "Reverse" );
Reverse->setText( tr( "SMESH_REVERSE" ) );
GroupC1Layout->addWidget( Reverse, 1, 0 );
SMESHGUI_AddFaceDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_AddFaceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddFaceDlg::~SMESHGUI_AddFaceDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkNodes = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
reverse = false;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddFaceDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkNodes) {
mySMESHGUI->EraseSimulationActors();
mySMESHGUI->AddFace( myMesh, myMapIndex, reverse ) ;
mySMESHGUI->ViewNodes();
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_AddFaceDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkNodes = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes < 1)
return ;
if ( mySelection->SelectionMode() != 1 ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex );
if ( myNodes == 3 && nbNodes == 3 ) {
mySMESHGUI->DisplaySimulationTriangle(myMesh, myMapIndex, reverse);
myOkNodes = true ;
} else if ( myNodes == 4 && nbNodes == 4 ) {
mySMESHGUI->DisplaySimulationQuadrangle(myMesh, myMapIndex, reverse);
myOkNodes = true ;
} else {
// mySMESHGUI->EraseSimulationActors();
myOkNodes = false ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddFaceDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
void SMESHGUI_AddFaceDlg::CheckBox( int state )
{
if( Reverse->isOn() ) reverse = true;
else reverse = false;
if ( myOkNodes == false )
return;
if ( state >= 0 ) {
mySMESHGUI->EraseSimulationActors();
if ( myNodes == 3 )
mySMESHGUI->DisplaySimulationTriangle( myMesh, myMapIndex, reverse);
else if ( myNodes == 4 ) {
mySMESHGUI->DisplaySimulationQuadrangle( myMesh, myMapIndex, reverse);
}
}
}

View File

@ -0,0 +1,102 @@
// File : SMESHGUI_AddFaceDlg.h
// Created : Wed Jun 26 21:00:41 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_FACE_H
#define DIALOGBOX_ADD_FACE_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_AddFaceDlg
// purpose :
//=================================================================================
class SMESHGUI_AddFaceDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddFaceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0,
int nbNode = 3, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddFaceDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */
int myNodes ;
bool reverse ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QCheckBox* Reverse;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void CheckBox( int );
protected:
QGridLayout* SMESHGUI_AddFaceDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ADD_FACE_H

View File

@ -0,0 +1,449 @@
using namespace std;
// File : SMESHGUI_AddHypothesisDlg.cxx
// Created : Wed May 22 19:05:31 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESHGUI
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddHypothesisDlg.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qevent.h>
//=================================================================================
// class : SMESHGUI_AddHypothesisDlg()
// purpose : Constructs a SMESHGUI_AddHypothesisDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_AddHypothesisDlg::SMESHGUI_AddHypothesisDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_HYPOTHESIS")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddHypothesisDlg" );
resize( 322, 220 );
setCaption( tr( "SMESH_ADD_HYPOTHESIS_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddHypothesisDlgLayout = new QGridLayout( this );
SMESHGUI_AddHypothesisDlgLayout->setSpacing( 6 );
SMESHGUI_AddHypothesisDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_ADD_HYPOTHESIS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupConstructor1->setColumnLayout(0, Qt::Vertical );
GroupConstructor1->layout()->setSpacing( 0 );
GroupConstructor1->layout()->setMargin( 0 );
GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() );
GroupConstructor1Layout->setAlignment( Qt::AlignTop );
GroupConstructor1Layout->setSpacing( 6 );
GroupConstructor1Layout->setMargin( 11 );
LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" );
LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 );
LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" );
LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 );
SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" );
SelectButtonC1A1Hyp->setText( tr( "" ) );
SelectButtonC1A1Hyp->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 );
SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" );
SelectButtonC1A2Mesh->setText( tr( "" ) );
SelectButtonC1A2Mesh->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 );
TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" );
TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) );
TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 );
TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" );
TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) );
TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 );
SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructor1, 1, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_1, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~SMESHGUI_AddHypothesisDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddHypothesisDlg::~SMESHGUI_AddHypothesisDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myConstructorId = 0 ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Hyp ;
Constructor1->setChecked( TRUE );
myOkMesh = myOkSubMesh = myOkHypothesis = false ;
myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddHypothesisDlg::ConstructorsClicked(int constructorId)
{
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Hyp ;
LineEditC1A2Mesh->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkMesh = myOkSubMesh = myOkHypothesis = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkMesh && myOkHypothesis ) {
SALOME_ListIteratorOfListIO It( HypoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ;
}
} else if( myOkSubMesh && myOkHypothesis ) {
SALOME_ListIteratorOfListIO It( HypoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ;
}
}
break ;
}
}
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void SMESHGUI_AddHypothesisDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( myEditCurrentArgument == LineEditC1A2Mesh ) {
if ( nbSel == 1 ) {
Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
QString aName = IObject->getName();
Standard_Boolean testResult;
myOkMesh = true ;
myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ;
if( !testResult ) {
myOkMesh = false;
myOkSubMesh = true;
mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ;
if( !testResult ) {
myOkSubMesh = false;
return ;
}
}
LineEditC1A2Mesh->setText(aString) ;
}
else {
myOkMesh = myOkSubMesh = false ;
return ;
}
}
else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
if ( nbSel >= 1 ) {
HypoList.Clear(); // = mySelection->StoredIObjects() ;
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
HypoList.Append(Itinit.Value());
}
myOkHypothesis = true ;
if (nbSel > 1)
aString = tr("%1 Hypothesis").arg(nbSel) ;
LineEditC1A1Hyp->setText(aString) ;
}
else {
myOkHypothesis = false ;
return ;
}
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Hyp ) {
myEditCurrentArgument = LineEditC1A1Hyp ;
LineEditC1A1Hyp->setFocus() ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myHypothesisFilter) ;
}
else if(send == SelectButtonC1A2Mesh) {
myEditCurrentArgument = LineEditC1A2Mesh;
LineEditC1A2Mesh->setFocus() ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myMeshOrSubMeshFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::LineEditReturnPressed()
{
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void SMESHGUI_AddHypothesisDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddHypothesisDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}

View File

@ -0,0 +1,114 @@
// File : SMESHGUI_AddHypothesisDlg.h
// Created : Wed May 22 19:05:13 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESHGUI
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_HYPOTHESIS_H
#define DIALOGBOX_ADD_HYPOTHESIS_H
#include "SALOME_Selection.h"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_TypeFilter.hxx"
#include "SALOME_ListIO.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_AddHypothesisDlg
// purpose :
//=================================================================================
class SMESHGUI_AddHypothesisDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddHypothesisDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddHypothesisDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESH::SMESH_Gen_var myCompMesh ;
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh;
SMESH::SMESH_Hypothesis_var myHypothesis;
Handle(SMESH_TypeFilter) myHypothesisFilter;
Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter;
bool myOkMesh ;
bool myOkSubMesh ;
bool myOkHypothesis;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SALOME_ListIO HypoList;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Hyp;
QLineEdit* LineEditC1A2Mesh;
QPushButton* SelectButtonC1A1Hyp;
QPushButton* SelectButtonC1A2Mesh;
QLabel* TextLabelC1A2Mesh;
QLabel* TextLabelC1A1Hyp;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_AddHypothesisDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_ADD_HYPOTHESIS_H

View File

@ -0,0 +1,516 @@
using namespace std;
// File : SMESHGUI_AddSubMeshDlg.cxx
// Created : Mon May 27 10:20:11 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddSubMeshDlg.h"
#include "SMESHGUI.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_AddSubMeshDlg()
// purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_SUBMESH")));
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddSubMeshDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_ADD_SUBMESH" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this );
SMESHGUI_AddSubMeshDlgLayout->setSpacing( 6 );
SMESHGUI_AddSubMeshDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_SUBMESH" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image1 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESH" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image0 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image0 );
SelectButtonC1A2->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" );
TextLabel_NameMesh->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameMesh, 2, 0 );
LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
GroupC1Layout->addWidget( LineEdit_NameMesh, 2, 2 );
TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" );
TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) );
TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1Hyp, 3, 0 );
SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
SelectButtonC1A1Hyp->setText( tr( "" ) );
SelectButtonC1A1Hyp->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 );
LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 );
TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" );
TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) );
TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Algo->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1Algo, 4, 0 );
SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
SelectButtonC1A1Algo->setText( tr( "" ) );
SelectButtonC1A1Algo->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 );
LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 );
SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ;
}
//=================================================================================
// function : ~SMESHGUI_AddSubMeshDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
myGeomFilter = new SALOME_TypeFilter( "GEOM" );
myMeshFilter = new SMESH_TypeFilter( MESH );
myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
myNameSubMesh = "SubMesh";
myGeomShape = GEOM::GEOM_Shape::_nil();
myMesh = SMESH::SMESH_Mesh::_nil();
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddSubMeshDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if ( !myNameSubMesh.isEmpty() && !myNameSubMesh.isNull() &&
!myGeomShape->_is_nil() && !myMesh->_is_nil()) {
mySubMesh = mySMESHGUI->AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ;
}
if( myOkHypothesis && !mySubMesh->_is_nil() ) {
SALOME_ListIteratorOfListIO It( HypoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ;
}
}
if( myOkAlgorithm && !mySubMesh->_is_nil() ) {
SALOME_ListIteratorOfListIO It( AlgoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ;
}
}
break ;
}
}
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySelection->ClearFilters() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1 ) {
if ( nbSel != 1 ) {
myOkHypothesis = false;
myOkAlgorithm = false;
return ;
} else {
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
if( !testResult ) {
myMesh = SMESH::SMESH_Mesh::_nil();
return ;
}
}
} else if ( myEditCurrentArgument == LineEditC1A2 ) {
if ( nbSel != 1 ) {
myOkHypothesis = false;
myOkAlgorithm = false;
return ;
} else {
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult ) {
myGeomShape = GEOM::GEOM_Shape::_nil();
return ;
}
}
} else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
if ( nbSel >= 1 ) {
HypoList.Clear();
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
HypoList.Append(Itinit.Value());
}
myOkHypothesis = true ;
if (nbSel > 1)
aString = tr("%1 Hypothesis").arg(nbSel) ;
LineEditC1A1Hyp->setText(aString) ;
}
else {
myOkHypothesis = false ;
return ;
}
} else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
if ( nbSel >= 1 ) {
AlgoList.Clear();
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
AlgoList.Append(Itinit.Value());
}
myOkAlgorithm = true ;
if (nbSel > 1)
aString = tr("%1 Algorithms").arg(nbSel) ;
LineEditC1A1Algo->setText(aString) ;
}
else {
myOkAlgorithm = false ;
return ;
}
}
break;
}
}
myEditCurrentArgument->setText(aString) ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ;
mySelection->AddFilter(myMeshFilter) ;
} else if (send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
mySelection->ClearFilters() ;
mySelection->AddFilter(myGeomFilter) ;
} else if( send == SelectButtonC1A1Hyp ) {
LineEditC1A1Hyp->setFocus() ;
myEditCurrentArgument = LineEditC1A1Hyp ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myHypothesisFilter) ;
} else if( send == SelectButtonC1A1Algo ) {
LineEditC1A1Algo->setFocus() ;
myEditCurrentArgument = LineEditC1A1Algo ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myAlgorithmFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_AddSubMeshDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameMesh) {
myNameSubMesh = newText;
}
return ;
}

View File

@ -0,0 +1,126 @@
// File : SMESHGUI_AddSubMeshDlg.h
// Created : Mon May 27 10:23:17 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_SUBMESH_H
#define DIALOGBOX_ADD_SUBMESH_H
#include "SALOME_Selection.h"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_TypeFilter.hxx"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_AddSubMeshDlg
// purpose :
//=================================================================================
class SMESHGUI_AddSubMeshDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddSubMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddSubMeshDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
GEOM::GEOM_Shape_var myGeomShape ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh;
QString myNameSubMesh ;
Handle(SALOME_TypeFilter) myGeomFilter;
Handle(SMESH_TypeFilter) myMeshFilter;
Handle(SMESH_TypeFilter) myHypothesisFilter;
Handle(SMESH_TypeFilter) myAlgorithmFilter;
SALOME_ListIO HypoList;
SALOME_ListIO AlgoList;
bool myOkHypothesis;
bool myOkAlgorithm;
SMESH::SMESH_Hypothesis_var myHypothesis;
SMESH::SMESH_Hypothesis_var myAlgorithm;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabel_NameMesh ;
QLineEdit* LineEdit_NameMesh ;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A2;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A2;
QLabel* TextLabelC1A1Hyp;
QPushButton* SelectButtonC1A1Hyp;
QLineEdit* LineEditC1A1Hyp;
QLabel* TextLabelC1A1Algo;
QPushButton* SelectButtonC1A1Algo;
QLineEdit* LineEditC1A1Algo;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
protected:
QGridLayout* SMESHGUI_AddSubMeshDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ADD_SUBMESH_H

View File

@ -0,0 +1,388 @@
using namespace std;
// File : SMESHGUI_AddVolumeDlg.cxx
// Created : Wed Jun 26 21:00:14 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_AddVolumeDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qcheckbox.h>
//=================================================================================
// class : SMESHGUI_AddVolumeDlg()
// purpose :
//=================================================================================
SMESHGUI_AddVolumeDlg::SMESHGUI_AddVolumeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
int nbNodes, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
myNodes = nbNodes;
QPixmap image0;
if ( myNodes == 4 )
image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_TETRAS")));
else if ( myNodes == 8 )
image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_HEXAS")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_AddVolumeDlg" );
resize( 303, 185 );
if ( myNodes == 4 )
setCaption( tr( "SMESH_ADD_TETRAS_TITLE" ) );
else if ( myNodes == 8 )
setCaption( tr( "SMESH_ADD_HEXAS_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_AddVolumeDlgLayout = new QGridLayout( this );
SMESHGUI_AddVolumeDlgLayout->setSpacing( 6 );
SMESHGUI_AddVolumeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
if ( myNodes == 4 )
GroupConstructors->setTitle( tr( "SMESH_TETRAS" ) );
else if ( myNodes == 8 )
GroupConstructors->setTitle( tr( "SMESH_HEXAS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_AddVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_AddVolumeDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
if ( myNodes == 4 )
GroupC1->setTitle( tr( "SMESH_ADD_TETRAS" ) );
else if ( myNodes == 8 )
GroupC1->setTitle( tr( "SMESH_ADD_HEXAS" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_AddVolumeDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_AddVolumeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_AddVolumeDlg::~SMESHGUI_AddVolumeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkNodes = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_AddVolumeDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkNodes) {
mySMESHGUI->EraseSimulationActors();
mySMESHGUI->AddVolume( myMesh, myMapIndex ) ;
mySMESHGUI->ViewNodes();
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_AddVolumeDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkNodes = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes < 1)
return ;
if ( mySelection->SelectionMode() != 1 ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
if ( myNodes == 4 && nbNodes == 4 ) {
mySMESHGUI->DisplaySimulationTetra(myMesh, myMapIndex);
myOkNodes = true ;
} else if ( myNodes == 8 && nbNodes == 8 ) {
mySMESHGUI->DisplaySimulationHexa(myMesh, myMapIndex);
myOkNodes = true ;
} else {
// mySMESHGUI->EraseSimulationActors();
myOkNodes = false ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_AddVolumeDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,98 @@
// File : SMESHGUI_AddVolumeDlg.h
// Created : Wed Jun 26 21:00:41 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ADD_VOLUME_H
#define DIALOGBOX_ADD_VOLUME_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_AddVolumeDlg
// purpose :
//=================================================================================
class SMESHGUI_AddVolumeDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_AddVolumeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0,
int nbNode = 4, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddVolumeDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */
int myNodes ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_AddVolumeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ADD_VOLUME_H

View File

@ -0,0 +1,409 @@
using namespace std;
// File : SMESHGUI_ComputeScalarValue.cxx
// Created : Mon Jun 24 14:06:00 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_ComputeScalarValue.h"
#include "utilities.h"
#include <math.h>
//=============================================================================
/*!
*
*/
//=============================================================================
static double ComputeLength(float* p1, float* p2) {
float a1,a2,a3,b1,b2,b3;
a1 = p1[0];
a2 = p1[1];
a3 = p1[2];
b1 = p2[0];
b2 = p2[1];
b3 = p2[2];
// MESSAGE( a1 << " "<< a2 << " "<< a3 << " " << b1 << " "<< b2 << " "<< b3 );
float X1,Y1,Z1,X2,Z2,Y2;
X1 = b1 - a1;
Y1 = b2 - a2;
Z1 = b3 - a3;
// MESSAGE( X1 << " "<< Y1 << " "<< Z1 );
float e1;
e1 = sqrt( X1*X1 + Y1*Y1 + Z1*Z1 ) ;
// MESSAGE( "Length = " << e1 );
return e1;
}
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::LengthEdges(vtkCell* theCell) {
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points != 2 ) return 0;
float* pnt1 = points->GetPoint(0);
float* pnt2 = points->GetPoint(1);
return ComputeLength(pnt1,pnt2);
};
//=============================================================================
/*!
*
*/
//=============================================================================
static double ComputeAreaOfTriangle(float* p1, float* p2, float* p3) {
double a1,a2,a3,b1,b2,b3,c1,c2,c3;
a1 = p1[0];
a2 = p1[1];
a3 = p1[2];
b1 = p2[0];
b2 = p2[1];
b3 = p2[2];
c1 = p3[0];
c2 = p3[1];
c3 = p3[2];
float e1, e2, e3;
e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ;
e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ;
e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ;
// MESSAGE( "e = " << e1 << " " << e2 <<" " << e3 );
float s = (e1+e2+e3)/2;
double area = sqrt(s*(s-e1)*(s-e2)*(s-e3));
// MESSAGE( "area = " << area );
return area;
}
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::AreaElements(vtkCell* theCell){
// MESSAGE ( " SMESHGUI_ComputeScalarValue::AreaElements " )
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
// MESSAGE( "num_points = "<< num_points );
for (int j = 0; j < theCell->GetNumberOfPoints (); j++) {
float* pnt = points->GetPoint(j);
// MESSAGE( pnt[0] << " " << pnt[1] << " " << pnt[2] );
}
if (num_points < 3 ) return 0;
if (num_points == 3) {
float* p1 = points->GetPoint(0);
float* p2 = points->GetPoint(1);
float* p3 = points->GetPoint(2);
double area = ComputeAreaOfTriangle(p1,p2,p3);
return area;
} else if (num_points == 4) {
float* p1 = points->GetPoint(0);
float* p2 = points->GetPoint(1);
float* p3 = points->GetPoint(2);
float* p4 = points->GetPoint(3);
double area1 = ComputeAreaOfTriangle(p1,p2,p3);
double area2 = ComputeAreaOfTriangle(p3,p4,p1);
return area1+area2;
}
};
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::Taper(vtkCell* theCell){
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points != 4 ) return 0;
float* p1 = points->GetPoint(0);
float* p2 = points->GetPoint(1);
float* p3 = points->GetPoint(2);
float* p4 = points->GetPoint(3);
double A1 = ComputeAreaOfTriangle(p4,p1,p2);
double A2 = ComputeAreaOfTriangle(p3,p1,p2);
double A3 = ComputeAreaOfTriangle(p2,p3,p4);
double A4 = ComputeAreaOfTriangle(p3,p4,p1);
double JA = 0.25 * (A1 + A2 + A3 + A4);
double taper = fabs(A1/(JA-1));
if (fabs(A2/(JA-1)) > taper) taper = fabs(A2/(JA-1));
if (fabs(A3/(JA-1)) > taper) taper = fabs(A3/(JA-1));
if (fabs(A4/(JA-1)) > taper) taper = fabs(A4/(JA-1));
// MESSAGE( "Taper = " << taper);
return taper;
};
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::AspectRatio(vtkCell* theCell) {
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points < 3 ) return 0;
if (num_points == 3) {
float a1,a2,a3,b1,b2,b3,c1,c2,c3;
float* pnt = points->GetPoint(0);
a1 = pnt[0];
a2 = pnt[1];
a3 = pnt[2];
pnt = points->GetPoint(1);
b1 = pnt[0];
b2 = pnt[1];
b3 = pnt[2];
pnt = points->GetPoint(2);
c1 = pnt[0];
c2 = pnt[1];
c3 = pnt[2];
float e1, e2, e3;
e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ;
e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ;
e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ;
float amax,p,s;
amax=e1;
if (e2>amax) amax=e2;
if (e3>amax) amax=e3;
p=(e1+e2+e3)/2;
s=AreaElements(theCell);
double aspectRatio=amax*p*sqrt(double(3))/(s*6);
// MESSAGE( "aspectRatio = " << aspectRatio );
return(aspectRatio);
}
else if (num_points == 4) {
float a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3;
float* pnt = points->GetPoint(0);
a1 = pnt[0];
a2 = pnt[1];
a3 = pnt[2];
pnt = points->GetPoint(1);
b1 = pnt[0];
b2 = pnt[1];
b3 = pnt[2];
pnt = points->GetPoint(2);
c1 = pnt[0];
c2 = pnt[1];
c3 = pnt[2];
pnt = points->GetPoint(3);
d1 = pnt[0];
d2 = pnt[1];
d3 = pnt[2];
float e1, e2, e3, e4;
float len_min, len_max;
e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ;
e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ;
e3 = sqrt( (c1-d1)*(c1-d1) + (c2-d2)*(c2-d2) + (c3-d3)*(c3-d3) ) ;
e4 = sqrt( (d1-a1)*(d1-a1) + (d2-a2)*(d2-a2) + (d3-a3)*(d3-a3) ) ;
len_min = e1; len_max = e1;
if (e2 >len_max ) len_max = e2;
if (e3 >len_max ) len_max = e3;
if (e4 >len_max ) len_max = e4;
if (e2 <len_min ) len_min = e2;
if (e3 <len_min ) len_min = e3;
if (e4 <len_min ) len_min = e4;
return (len_max/len_min);
}
};
//=============================================================================
/*!
*
*/
//=============================================================================
static double ComputeAngle(float* p1, float* p2, float* p3) {
const double pi=4*atan(double(1));
float a1,a2,a3,b1,b2,b3,c1,c2,c3;
a1 = p1[0];
a2 = p1[1];
a3 = p1[2];
b1 = p2[0];
b2 = p2[1];
b3 = p2[2];
c1 = p3[0];
c2 = p3[1];
c3 = p3[2];
float X1,Y1,Z1,X2,Z2,Y2;
X1 = b1 - a1;
X2 = c1 - b1;
Y1 = b2 - a2;
Y2 = c2 - b2;
Z1 = b3 - a3;
Z2 = c3 - b3;
float e1, e2, e3;
e1 = sqrt( X1*X1 + Y1*Y1 + Z1*Z1 ) ;
e2 = sqrt( X2*X2 + Y2*Y2 + Z2*Z2 ) ;
double dot=(X1*(X2)+Y1*(Y2)+Z1*(Z2));
// MESSAGE( pi );
// MESSAGE( dot/(e1*e2) );
double cosinus = dot/(e1*e2);
cosinus = fabs(cosinus);
return 180*acos (cosinus)/pi;
}
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::MinimumAngle(vtkCell* theCell) {
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points < 3 ) return 0;
float* pnt1 = points->GetPoint(0);
float* pnt2 = points->GetPoint(1);
float* pnt3 = points->GetPoint(2);
if (num_points == 3) {
double a1,a2,a3,amin;
a1=fabs(ComputeAngle(pnt1,pnt2,pnt3));
amin=a1;
a2=fabs(ComputeAngle(pnt2,pnt3,pnt1));
if (a2<amin) amin=a2;
a3=fabs(ComputeAngle(pnt3,pnt1,pnt2));
if (a3<amin) amin=a3;
// MESSAGE( "Minimal angle " << amin );
return amin;
}
else if (num_points == 4) {
float* pnt4 = points->GetPoint(3);
double a1,a2,a3,a4,amin;
a1=fabs(ComputeAngle(pnt1,pnt2,pnt3));
amin=a1;
a2=fabs(ComputeAngle(pnt2,pnt3,pnt4));
if (a2<amin) amin=a2;
a3=fabs(ComputeAngle(pnt3,pnt4,pnt1));
if (a3<amin) amin=a3;
a4=fabs(ComputeAngle(pnt4,pnt1,pnt2));
if (a4<amin) amin=a4;
// MESSAGE( "Minimal angle " << amin );
return amin;
}
};
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::Skew(vtkCell* theCell) {
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points < 3 ) return 0;
//triangle case
if (num_points == 3) {
float* pnt1 = points->GetPoint(0);
float* pnt2 = points->GetPoint(1);
float* pnt3 = points->GetPoint(2);
double a1,a2,a3,amax;
a1=fabs(60 - fabs(ComputeAngle(pnt1,pnt2,pnt3)));
amax=a1;
a2=fabs(60 - fabs(ComputeAngle(pnt2,pnt3,pnt1)));
if (a2>amax) amax=a2;
a3=fabs(60 - fabs(ComputeAngle(pnt3,pnt1,pnt2)));
if (a3>amax) amax=a3;
// MESSAGE( "Skew = " << amax );
return amax;
}
//quadrangle case
else if (num_points == 4) {
float* pnt1 = points->GetPoint(0);
float* pnt2 = points->GetPoint(1);
float* pnt3 = points->GetPoint(2);
float* pnt4 = points->GetPoint(3);
double a1,a2,a3,a4,amax;
a1=fabs(90 - fabs(ComputeAngle(pnt1,pnt2,pnt3)));
amax=a1;
a2=fabs(90 - fabs(ComputeAngle(pnt2,pnt3,pnt4)));
if (a2>amax) amax=a2;
a3=fabs(90 - fabs(ComputeAngle(pnt3,pnt4,pnt1)));
if (a3>amax) amax=a3;
a4=fabs(90 - fabs(ComputeAngle(pnt4,pnt1,pnt2)));
if (a4>amax) amax=a4;
// MESSAGE( "Skew = " << amax );
return amax;
}
};
//=============================================================================
/*!
*
*/
//=============================================================================
static double ComputeA(float* p1, float* p2, float* p3, float* G) {
double e1 = sqrt(pow(p2[0]-p1[0], 2)+pow(p2[1]-p1[1], 2)+pow(p2[2]-p1[2], 2));
double e2 = sqrt(pow(p3[0]-p2[0], 2)+pow(p3[1]-p2[1], 2)+pow(p3[2]-p2[2], 2));
double l;
if (e1 < e2) l = 0.5*e1;
else l = 0.5*e2;
float GI[3], GJ[3], N[3];;
GI[0] = (p2[0]-p1[0])/2-G[0];
GI[1] = (p2[1]-p1[1])/2-G[1];
GI[2] = (p2[2]-p1[2])/2-G[2];
GJ[0] = (p3[0]-p2[0])/2-G[0];
GJ[1] = (p3[1]-p2[1])/2-G[1];
GJ[2] = (p3[2]-p2[2])/2-G[2];
N[0] = GI[1]*GJ[2] - GI[2]*GJ[1];
N[1] = GI[2]*GJ[0] - GI[0]*GJ[2];
N[2] = GI[0]*GJ[1] - GI[1]*GJ[0];
double H;
float T[3];
T[0] = (p1[0]-G[0])*N[0];
T[1] = (p1[1]-G[1])*N[1];
T[2] = (p1[2]-G[2])*N[2];
H = sqrt(pow(T[0],2)+pow(T[1],2)+pow(T[2],2))/sqrt(pow(N[0],2)+pow(N[1],2)+pow(N[2],2));
double A = H/l;
return A;
}
//=============================================================================
/*!
*
*/
//=============================================================================
double SMESHGUI_ComputeScalarValue::Warp(vtkCell* theCell) {
int num_points = theCell->GetNumberOfPoints ();
vtkPoints* points = theCell->GetPoints();
if (num_points != 4 ) return 0;
float* p1 = points->GetPoint(0);
float* p2 = points->GetPoint(1);
float* p3 = points->GetPoint(2);
float* p4 = points->GetPoint(3);
double G1, G2, G3;
float G[3];
G[0] = (p1[0]+p2[0]+p3[0]+p4[0])/4;
G[1] = (p1[1]+p2[1]+p3[1]+p4[1])/4;
G[2] = (p1[2]+p2[2]+p3[2]+p4[2])/4;
double amax = ComputeA(p1, p2, p3, G);
double nextA = ComputeA(p2, p3, p4, G);
if (nextA > amax) amax = nextA;
nextA = ComputeA(p3, p4, p1, G);
if (nextA > amax) amax = nextA;
nextA = ComputeA(p4, p1, p2, G);
if (nextA > amax) amax = nextA;
// MESSAGE( "Warp = " << amax );
return amax;
}

View File

@ -0,0 +1,26 @@
// File : SMESHGUI_ComputeScalarValue.h
// Created : Mon Jun 24 14:06:00 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_CONTROLALGORITHMS_H
#define SMESHGUI_CONTROLALGORITHMS_H
#include <vtkCell.h>
class SMESHGUI_ComputeScalarValue {
public:
static double LengthEdges(vtkCell* theCell);
static double AreaElements(vtkCell* theCell);
static double Taper(vtkCell* theCell);
static double AspectRatio(vtkCell* theCell);
static double MinimumAngle(vtkCell* theCell);
static double Skew(vtkCell* theCell);
static double Warp(vtkCell* theCell);
};
#endif

View File

@ -0,0 +1,351 @@
using namespace std;
// File : SMESHGUI_DiagonalInversionDlg.cxx
// Created :
// Author : Damien COQUERET
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_DiagonalInversionDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_DiagonalInversionDlg()
// purpose :
//=================================================================================
SMESHGUI_DiagonalInversionDlg::SMESHGUI_DiagonalInversionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MESH_DIAGONAL")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_DiagonalInversionDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_DIAGONAL_INVERSION_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_DiagonalInversionDlgLayout = new QGridLayout( this );
SMESHGUI_DiagonalInversionDlgLayout->setSpacing( 6 );
SMESHGUI_DiagonalInversionDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_DIAGONAL" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_DIAGONAL" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_DIAGONAL" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_DiagonalInversionDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_DiagonalInversionDlg::~SMESHGUI_DiagonalInversionDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkElements = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkElements) {
mySMESHGUI->DiagonalInversion( myMesh, myMapIndex ) ;
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkElements = false;
QString aString = "";
if ( mySelection->SelectionMode() != 2 ) {
return;
}
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbElements = mySMESHGUI->GetNameOfSelectedEdges(mySelection, aString) ;
if(nbElements < 1)
return ;
MESSAGE( "DCQ : nb. elements = " << nbElements )
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
myOkElements = true ;
myEditCurrentArgument->setText(aString) ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_DiagonalInversionDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,94 @@
// File : SMESHGUI_DiagonalInversionDlg.h
// Created :
// Author : Damien COQUERET
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_DIAGONAL_INVERSION_H
#define DIALOGBOX_DIAGONAL_INVERSION_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_DiagonalInversionDlg
// purpose :
//=================================================================================
class SMESHGUI_DiagonalInversionDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_DiagonalInversionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_DiagonalInversionDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkElements ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_DiagonalInversionDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_DIAGONAL_INVERSION_H

View File

@ -0,0 +1,429 @@
using namespace std;
// File : SMESHGUI_EdgesConnectivityDlg.cxx
// Created : Tue Jun 25 21:22:12 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_EdgesConnectivityDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qcheckbox.h>
// VTK Include
#include <vtkFeatureEdges.h>
//=================================================================================
// class : SMESHGUI_EdgesConnectivityDlg()
// purpose :
//=================================================================================
SMESHGUI_EdgesConnectivityDlg::SMESHGUI_EdgesConnectivityDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_CONNECTIVITY")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_EdgesConnectivityDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_EDGES_CONNECTIVITY_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_EdgesConnectivityDlgLayout = new QGridLayout( this );
SMESHGUI_EdgesConnectivityDlgLayout->setSpacing( 6 );
SMESHGUI_EdgesConnectivityDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_EDGES_CONNECTIVITY" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
//buttonOk = new QPushButton( GroupButtons, "buttonOk" );
//buttonOk->setText( tr( "SMESH_BUT_OK" ) );
//buttonOk->setAutoDefault( TRUE );
//buttonOk->setDefault( TRUE );
//GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_EDGES_CONNECTIVITY" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_MESH" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
BoundaryEdges = new QCheckBox( GroupC1, "BoundaryEdges" );
BoundaryEdges->setText( tr( "SMESH_BOUNDARYEDGES" ) );
GroupC1Layout->addWidget( BoundaryEdges, 1, 0 );
ManifoldEdges = new QCheckBox( GroupC1, "ManifoldEdges" );
ManifoldEdges->setText( tr( "SMESH_MANIFOLDEDGES" ) );
GroupC1Layout->addWidget( ManifoldEdges, 2, 0 );
NonManifoldEdges = new QCheckBox( GroupC1, "NonManifoldEdges" );
NonManifoldEdges->setText( tr( "SMESH_NONMANIFOLDEDGES" ) );
GroupC1Layout->addWidget( NonManifoldEdges, 1, 2 );
FeatureEdges = new QCheckBox( GroupC1, "FeatureEdges" );
FeatureEdges->setText( tr( "SMESH_FEATUREEDGES" ) );
GroupC1Layout->addWidget( FeatureEdges, 2, 2 );
FeatureAngle= new QLabel( GroupC1, "FeatureAngle" );
FeatureAngle->setText( tr( "SMESH_FEATUREANGLE" ) );
FeatureAngle->setMinimumSize( QSize( 50, 0 ) );
FeatureAngle->setFrameShape( QLabel::NoFrame );
FeatureAngle->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( FeatureAngle, 3, 0 );
SpinBox_FeatureAngle = new SMESHGUI_SpinBox( GroupC1, "SpinBox_FeatureAngle" ) ;
GroupC1Layout->addWidget( SpinBox_FeatureAngle , 3, 2 );
SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_EdgesConnectivityDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_EdgesConnectivityDlg::~SMESHGUI_EdgesConnectivityDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkActor = false ;
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 5.0 ;
/* min, max, step and decimals for spin boxes */
SpinBox_FeatureAngle->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_FeatureAngle->SetValue( 30.0 ) ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
//connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( BoundaryEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
connect( ManifoldEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
connect( NonManifoldEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
connect( FeatureEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkActor) {
Standard_Boolean res;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
if ( !IO->hasEntry() )
break;
SMESH_Actor* ac = mySMESHGUI->FindActorByEntry( IO->getEntry(), res, true );
if ( !res )
break;
mySMESHGUI->ChangeRepresentation( ac, 0 );
vtkGeometryFilter *gf = vtkGeometryFilter::New();
gf->SetInput(ac->DataSource);
vtkFeatureEdges *edges = vtkFeatureEdges::New();
edges->SetInput( gf->GetOutput() );
edges->ColoringOn();
if ( BoundaryEdges->isOn() ) edges->BoundaryEdgesOn();
else edges->BoundaryEdgesOff();
if ( ManifoldEdges->isOn() ) edges->ManifoldEdgesOn();
else edges->ManifoldEdgesOff();
if ( NonManifoldEdges->isOn() ) edges->NonManifoldEdgesOn();
else edges->NonManifoldEdgesOff();
if ( FeatureEdges->isOn() ) edges->FeatureEdgesOn();
else edges->FeatureEdgesOff();
double angle = SpinBox_FeatureAngle->GetValue() ;
edges->SetFeatureAngle( angle );
vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New();
EdgeMapper->SetInput( edges->GetOutput() );
EdgeMapper->SetScalarModeToUseCellData();
ac->SetMapper(EdgeMapper);
mySMESHGUI->DisplayEdgesConnectivityLegendBox(ac);
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::ClickOnCancel()
{
mySMESHGUI->ScalarVisibilityOff();
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
mySMESHGUI->ScalarVisibilityOff();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkActor = false;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if(nbSel != 1) {
mySMESHGUI->ScalarVisibilityOff();
return;
}
myEditCurrentArgument->setText(aString) ;
myOkActor = true ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_EdgesConnectivityDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
void SMESHGUI_EdgesConnectivityDlg::CheckBox( int state )
{
QCheckBox* send = (QCheckBox*)sender();
if( send == BoundaryEdges ) {
} else if( send == ManifoldEdges ) {
} else if( send == NonManifoldEdges ) {
} else {
}
}

View File

@ -0,0 +1,104 @@
// File : SMESHGUI_EdgesConnectivityDlg.h
// Created : Tue Jun 25 21:22:54 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_EDGES_CONNECTIVITY_H
#define DIALOGBOX_EDGES_CONNECTIVITY_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox;
class SMESHGUI;
class SMESHGUI_SpinBox;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_EdgesConnectivityDlg
// purpose :
//=================================================================================
class SMESHGUI_EdgesConnectivityDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_EdgesConnectivityDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_EdgesConnectivityDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
bool myOkActor ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QCheckBox* BoundaryEdges;
QCheckBox* ManifoldEdges;
QCheckBox* NonManifoldEdges;
QCheckBox* FeatureEdges;
QLabel* FeatureAngle;
SMESHGUI_SpinBox* SpinBox_FeatureAngle ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void CheckBox( int );
protected:
QGridLayout* SMESHGUI_EdgesConnectivityDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
QHBoxLayout* hbox_2;
QVBoxLayout* vbox;
QVBoxLayout* vbox_2;
};
#endif // DIALOGBOX_EDGES_CONNECTIVITY_H

View File

@ -0,0 +1,824 @@
using namespace std;
// File : SMESHGUI_EditHypothesesDlg.cxx
// Created : Fri Aug 02 09:14:56 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_EditHypothesesDlg.h"
#include "SMESHGUI.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//VRV: porting on Qt 3.0.5
#if QT_VERSION >= 0x030005
#include <qlistbox.h>
#endif
//VRV: porting on Qt 3.0.5
//=================================================================================
// class : SMESHGUI_EditHypothesesDlg()
// purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_EDIT_MESH")));
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_EditHypothesesDlg" );
resize( 417, 573 );
setCaption( tr( "SMESH_EDIT_HYPOTHESES" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this );
SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 );
SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_HYPOTHESES" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image1 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 96 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
buttonCancel->setDefault( TRUE );
buttonCancel->setEnabled( TRUE ) ;
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
buttonApply->setDefault( FALSE );
buttonApply->setEnabled( FALSE ) ;
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( FALSE );
buttonOk->setEnabled( FALSE ) ;
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 5, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image0 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image0 );
SelectButtonC1A2->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
GroupHypotheses = new QGroupBox( this, "GroupHypotheses" );
GroupHypotheses->setTitle( tr( "SMESH_HYPOTHESES" ) );
GroupHypotheses->setColumnLayout(0, Qt::Vertical );
GroupHypotheses->layout()->setSpacing( 0 );
GroupHypotheses->layout()->setMargin( 0 );
grid_3 = new QGridLayout( GroupHypotheses->layout() );
grid_3->setGeometry( QRect( 12, 18, 139, 110 ) );
grid_3->setAlignment( Qt::AlignTop );
grid_3->setSpacing( 6 );
grid_3->setMargin( 11 );
hbox_2 = new QHBoxLayout;
hbox_2->setSpacing( 6 );
hbox_2->setMargin( 0 );
vbox = new QVBoxLayout;
vbox->setSpacing( 6 );
vbox->setMargin( 0 );
TextHypDefinition = new QLabel( GroupHypotheses, "TextHypDefinition" );
TextHypDefinition->setText( tr( "SMESH_AVAILABLE" ) );
vbox->addWidget( TextHypDefinition );
ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" );
ListHypDefinition->setMinimumSize( 100, 50);
// ListHypDefinition->setRowMode(4);
// ListHypDefinition->setRowMode( QListBox::FixedNumber );
// ListHypDefinition->setLineWidth( 4 );
// ListHypDefinition->setColumnMode( QListBox::Variable );
// ListHypDefinition->setVariableHeight( FALSE );
// ListHypDefinition->insertItem( tr( "New Item" ) );
vbox->addWidget( ListHypDefinition );
hbox_2->addLayout( vbox );
vbox_2 = new QVBoxLayout;
vbox_2->setSpacing( 6 );
vbox_2->setMargin( 0 );
TextHypAssignation = new QLabel( GroupHypotheses, "TextHypAssignation" );
TextHypAssignation->setText( tr( "SMESH_EDIT_USED" ) );
vbox_2->addWidget( TextHypAssignation );
ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" );
ListHypAssignation->setMinimumSize( 100, 50);
// ListHypAssignation->setRowMode(4);
// ListHypAssignation->setRowMode( QListBox::FixedNumber );
// ListHypAssignation->setLineWidth( 4 );
// ListHypAssignation->setColumnMode( QListBox::Variable );
// ListHypAssignation->setVariableHeight( FALSE );
// ListHypAssignation->insertItem( tr( "New Item" ) );
vbox_2->addWidget( ListHypAssignation );
hbox_2->addLayout( vbox_2 );
grid_3->addLayout( hbox_2, 0, 0 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 2, 0 );
GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" );
GroupAlgorithms->setTitle( tr( "SMESH_ADD_ALGORITHM" ) );
GroupAlgorithms->setColumnLayout(0, Qt::Vertical );
GroupAlgorithms->layout()->setSpacing( 0 );
GroupAlgorithms->layout()->setMargin( 0 );
grid_4 = new QGridLayout( GroupAlgorithms->layout() );
grid_4->setGeometry( QRect( 12, 18, 139, 110 ) );
grid_4->setAlignment( Qt::AlignTop );
grid_4->setSpacing( 6 );
grid_4->setMargin( 11 );
hbox_3 = new QHBoxLayout;
hbox_3->setSpacing( 6 );
hbox_3->setMargin( 0 );
vbox_3 = new QVBoxLayout;
vbox_3->setSpacing( 6 );
vbox_3->setMargin( 0 );
TextAlgoDefinition = new QLabel( GroupAlgorithms, "TextAlgoDefinition" );
TextAlgoDefinition->setText( tr( "SMESH_AVAILABLE" ) );
vbox_3->addWidget( TextAlgoDefinition );
ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" );
ListAlgoDefinition->setMinimumSize( 100, 50);
// ListAlgoDefinition->setRowMode(4);
// ListAlgoDefinition->setRowMode( QListBox::FixedNumber );
// ListAlgoDefinition->setLineWidth( 4 );
// ListAlgoDefinition->setColumnMode( QListBox::Variable );
// ListAlgoDefinition->setVariableHeight( FALSE );
// ListAlgoDefinition->insertItem( tr( "New Item" ) );
vbox_3->addWidget( ListAlgoDefinition );
hbox_3->addLayout( vbox_3 );
vbox_4 = new QVBoxLayout;
vbox_4->setSpacing( 6 );
vbox_4->setMargin( 0 );
TextAlgoAssignation = new QLabel( GroupAlgorithms, "TextAlgoAssignation" );
TextAlgoAssignation->setText( tr( "SMESH_EDIT_USED" ) );
vbox_4->addWidget( TextAlgoAssignation );
ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" );
ListAlgoAssignation ->setMinimumSize( 100, 50);
// ListAlgoAssignation->setRowMode(4);
// ListAlgoAssignation->setRowMode( QListBox::FixedNumber );
// ListAlgoAssignation->setLineWidth( 4 );
// ListAlgoAssignation->setColumnMode( QListBox::Variable );
// ListAlgoAssignation->setVariableHeight( FALSE );
// ListAlgoAssignation->insertItem( tr( "New Item" ) );
vbox_4->addWidget( ListAlgoAssignation );
hbox_3->addLayout( vbox_4 );
grid_4->addLayout( hbox_3, 0, 0 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 3, 0 );
SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ;
}
//=================================================================================
// function : ~SMESHGUI_EditHypothesesDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
InitHypDefinition();
InitAlgoDefinition();
InitHypAssignation();
InitAlgoAssignation();
myGeomFilter = new SALOME_TypeFilter( "GEOM" );
myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
myGeomShape = GEOM::GEOM_Shape::_nil();
myMesh = SMESH::SMESH_Mesh::_nil();
mySubMesh = SMESH::SMESH_subMesh::_nil();
/* signals and slots connections */
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect( ListHypAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
connect( ListAlgoAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) );
connect( ListHypDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
connect( ListAlgoDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) );
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_EditHypothesesDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySelection->ClearFilters() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1 ) {
if ( nbSel != 1 ) {
myOkHypothesis = false;
myOkAlgorithm = false;
myMesh = SMESH::SMESH_Mesh::_nil();
mySubMesh = SMESH::SMESH_subMesh::_nil();
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
return ;
} else {
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ;
if( !testResult ) {
myMesh = SMESH::SMESH_Mesh::_nil();
mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ;
if( !testResult ) {
mySubMesh = SMESH::SMESH_subMesh::_nil();
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
return ;
}
}
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
}
} else if ( myEditCurrentArgument == LineEditC1A2 ) {
if ( nbSel != 1 ) {
myOkHypothesis = false;
myOkAlgorithm = false;
myGeomShape = GEOM::GEOM_Shape::_nil();
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
return ;
} else {
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult ) {
myGeomShape = GEOM::GEOM_Shape::_nil();
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
return ;
}
InitHypAssignation();
InitAlgoAssignation();
InitGeom();
}
}
break;
}
}
myEditCurrentArgument->setText(aString) ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ;
mySelection->AddFilter(myMeshOrSubMeshFilter) ;
} else if (send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
mySelection->ClearFilters() ;
mySelection->AddFilter(myGeomFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
return ;
}
void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i)
{
if (!i) return;
SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
int index = ListHypAssignation->index( i );
if ( index != -1 ) {
if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
SMESH::SMESH_Hypothesis_var Hyp =
SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR( mapNameIOR[ string(i->text()) ].c_str() ) );
if ( !myMesh->_is_nil() ) {
SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
// mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
mySMESHGUI->GetActiveStudy()->updateObjBrowser();
}
if ( !mySubMesh->_is_nil() ) {
SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
// mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
mySMESHGUI->GetActiveStudy()->updateObjBrowser();
}
ListHypAssignation->removeItem( index );
}
return;
}
index = ListAlgoAssignation->index( i );
if ( index != -1 ) {
if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
SMESH::SMESH_Hypothesis_var Hyp =
SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
if ( !myMesh->_is_nil() ) {
SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh);
mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp);
// mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false );
mySMESHGUI->GetActiveStudy()->updateObjBrowser();
}
if ( !mySubMesh->_is_nil() ) {
SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh);
mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp);
// mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false );
mySMESHGUI->GetActiveStudy()->updateObjBrowser();
}
ListAlgoAssignation->removeItem( index );
}
}
}
//=================================================================================
// function : addItem()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i)
{
if (!i) return;
SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
if ( ListHypDefinition->findItem( i->text() ) ) {
if ( !ListHypAssignation->findItem( i->text() ) ) {
ListHypAssignation->insertItem( i->text() );
if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
SMESH::SMESH_Hypothesis_var Hyp =
SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
if ( !myMesh->_is_nil() )
mySMESHGUI->AddHypothesisOnMesh(myMesh, Hyp);
if ( !mySubMesh->_is_nil() )
mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, Hyp);
}
}
return;
}
if ( ListAlgoDefinition->findItem( i->text() ) ) {
if ( !ListAlgoAssignation->findItem( i->text() ) ) {
ListAlgoAssignation->insertItem( i->text() );
if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) {
SMESH::SMESH_Hypothesis_var Hyp =
SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) );
if ( !myMesh->_is_nil() )
mySMESHGUI->AddAlgorithmOnMesh(myMesh, Hyp);
if ( !mySubMesh->_is_nil() )
mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, Hyp);
}
}
}
mySMESHGUI->GetActiveStudy()->updateObjBrowser();
}
//=================================================================================
// function : InitHypDefinition()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
{
SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
SALOMEDS::SObject_var HypothesisRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
int Tag_HypothesisRoot = 1;
if (father->FindSubObject (1, HypothesisRoot)) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListHypDefinition->insertItem(aName->Value());
if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
mapNameIOR[ aName->Value() ] = anIOR->Value();
}
}
}
}
}
//=================================================================================
// function : InitHypAssignation()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
{
MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
ListHypAssignation->clear();
SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
int Tag_RefOnAppliedHypothesis = 2;
SALOMEDS::SObject_var AHR, aRef;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !myMesh->_is_nil() ) {
SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
if ( aMesh->FindSubObject (2, AHR)) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
if (aRef->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListHypAssignation->insertItem(aName->Value());
}
}
}
}
}
if ( !mySubMesh->_is_nil() ) {
SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
if ( aSubMesh->FindSubObject (2, AHR)) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
if (aRef->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListHypAssignation->insertItem(aName->Value());
}
}
}
}
}
}
//=================================================================================
// function : InitAlgoDefinition()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition()
{
SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH");
SALOMEDS::SObject_var AlgorithmsRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
int Tag_AlgorithmsRoot = 2;
if (father->FindSubObject (2, AlgorithmsRoot)) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListAlgoDefinition->insertItem(aName->Value());
if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
mapNameIOR[ aName->Value() ] = anIOR->Value();
}
}
}
}
}
//=================================================================================
// function : InitAlgoAssignation()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation()
{
MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() )
MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() )
ListAlgoAssignation->clear();
SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
int Tag_RefOnAppliedAlgorithms = 3;
SALOMEDS::SObject_var AHR, aRef;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !myMesh->_is_nil() ) {
SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
if ( aMesh->FindSubObject (3, AHR) ) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
if (aRef->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListAlgoAssignation->insertItem(aName->Value());
}
}
}
}
}
if ( !mySubMesh->_is_nil() ) {
SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
if ( aSubMesh->FindSubObject (3, AHR) ) {
SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( Obj->ReferencedObject(aRef) ) {
if (aRef->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
ListAlgoAssignation->insertItem(aName->Value());
}
}
}
}
}
}
//=================================================================================
// function : InitGeom()
// purpose :
//=================================================================================
void SMESHGUI_EditHypothesesDlg::InitGeom()
{
LineEditC1A2->setText("") ;
SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI();
if ( !myMesh->_is_nil() ) {
SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh );
if ( !aMesh->_is_nil() )
myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh);
}
if ( !mySubMesh->_is_nil() ) {
SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh );
if ( !aSubMesh->_is_nil() )
myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh);
}
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) {
SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() );
if ( !aSO->_is_nil() ) {
if (aSO->FindAttribute(anAttr, "AttributeName") ) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
LineEditC1A2->setText( QString(aName->Value()) ) ;
}
}
}
}

View File

@ -0,0 +1,158 @@
// File : SMESHGUI_EditHypothesesDlg.h
// Created : Fri Aug 02 09:15:40 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SALOMEDS
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_EDIT_HYPOTHESES_H
#define DIALOGBOX_EDIT_HYPOTHESES_H
#include "SALOME_Selection.h"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_TypeFilter.hxx"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <map>
#include <string>
using namespace std;
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QListBox;
class QListBoxItem;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_EditHypothesesDlg
// purpose :
//=================================================================================
class SMESHGUI_EditHypothesesDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_EditHypothesesDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
void InitHypDefinition();
void InitAlgoDefinition();
void InitHypAssignation();
void InitAlgoAssignation();
void InitGeom();
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
GEOM::GEOM_Shape_var myGeomShape ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh;
Handle(SALOME_TypeFilter) myGeomFilter;
Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter;
map<string,string> mapNameIOR;
SALOME_ListIO HypoList;
SALOME_ListIO AlgoList;
bool myOkHypothesis;
bool myOkAlgorithm;
SMESH::SMESH_Hypothesis_var myHypothesis;
SMESH::SMESH_Hypothesis_var myAlgorithm;
SMESH::ListOfHypothesis_var myLHypothesis;
SMESH::ListOfHypothesis_var myLAlgorithm;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A2;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A2;
QGroupBox* GroupHypotheses;
QLabel* TextHypDefinition;
QListBox* ListHypDefinition;
QLabel* TextHypAssignation;
QListBox* ListHypAssignation;
QGroupBox* GroupAlgorithms;
QLabel* TextAlgoDefinition;
QListBox* ListAlgoDefinition;
QLabel* TextAlgoAssignation;
QListBox* ListAlgoAssignation;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnCancel();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
void removeItem(QListBoxItem*);
void addItem(QListBoxItem*);
protected:
QGridLayout* SMESHGUI_EditHypothesesDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* grid_3;
QGridLayout* grid_4;
QHBoxLayout* hbox_2;
QHBoxLayout* hbox_3;
QVBoxLayout* vbox;
QVBoxLayout* vbox_2;
QVBoxLayout* vbox_3;
QVBoxLayout* vbox_4;
};
#endif // DIALOGBOX_EDIT_HYPOTHESES_H

View File

@ -0,0 +1,127 @@
using namespace std;
// File : SMESHGUI_EditScalarBarDlg.cxx
// Created : Wed Jun 12 12:01:26 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_EditScalarBarDlg.h"
#include "SMESHGUI.h"
// QT Includes
#include <qframe.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a SMESHGUI_EditScalarBarDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
SMESHGUI_EditScalarBarDlg::SMESHGUI_EditScalarBarDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name )
setName( "SMESHGUI_EditScalarBarDlg" );
resize( 124, 122 );
setCaption( tr( "SMESH_SCALARBAR" ) );
setSizeGripEnabled( TRUE );
grid = new QGridLayout( this );
grid->setSpacing( 6 );
grid->setMargin( 11 );
grid_2 = new QGridLayout;
grid_2->setSpacing( 6 );
grid_2->setMargin( 0 );
PushButtonUpdateView = new QPushButton( this, "PushButtonUpdateView" );
PushButtonUpdateView->setText( tr( "SMESH_UPDATEVIEW" ) );
grid_2->addWidget( PushButtonUpdateView, 1, 0 );
grid_3 = new QGridLayout;
grid_3->setSpacing( 6 );
grid_3->setMargin( 0 );
grid_4 = new QGridLayout;
grid_4->setSpacing( 6 );
grid_4->setMargin( 0 );
grid_5 = new QGridLayout;
grid_5->setSpacing( 6 );
grid_5->setMargin( 0 );
LineEditMax = new QLineEdit( this, "LineEditMax" );
grid_5->addWidget( LineEditMax, 0, 0 );
LineEditMin = new QLineEdit( this, "LineEditMin" );
grid_5->addWidget( LineEditMin, 1, 0 );
grid_4->addLayout( grid_5, 0, 1 );
grid_6 = new QGridLayout;
grid_6->setSpacing( 6 );
grid_6->setMargin( 0 );
TextLabelMax = new QLabel( this, "TextLabelMax" );
TextLabelMax->setText( tr( "SMESH_MAX" ) );
grid_6->addWidget( TextLabelMax, 0, 0 );
TextLabelMin = new QLabel( this, "TextLabelMin" );
TextLabelMin->setText( tr( "SMESH_MIN" ) );
grid_6->addWidget( TextLabelMin, 1, 0 );
grid_4->addLayout( grid_6, 0, 0 );
grid_3->addLayout( grid_4, 0, 0 );
Line1 = new QFrame( this, "Line1" );
Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
grid_3->addWidget( Line1, 1, 0 );
grid_2->addLayout( grid_3, 0, 0 );
grid->addLayout( grid_2, 0, 0 );
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
if ( mySMESHGUI && mySMESHGUI->GetScalarBar() && mySMESHGUI->GetScalarBar()->GetLookupTable() ) {
float *range = mySMESHGUI->GetScalarBar()->GetLookupTable()->GetRange();
LineEditMin->setText( QString("%1").arg(range[0]) );
LineEditMax->setText( QString("%1").arg(range[1]) );
}
// signals and slots connections
connect( PushButtonUpdateView, SIGNAL( clicked() ), this, SLOT( updateView() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ;
}
/*
* Destroys the object and frees any allocated resources
*/
SMESHGUI_EditScalarBarDlg::~SMESHGUI_EditScalarBarDlg()
{
// no need to delete child widgets, Qt does it all for us
}
void SMESHGUI_EditScalarBarDlg::updateView()
{
float MinRange = LineEditMin->text().toFloat();
float MaxRange = LineEditMax->text().toFloat();
mySMESHGUI->UpdateScalarBar(MinRange,MaxRange);
}

View File

@ -0,0 +1,54 @@
// File : SMESHGUI_EditScalarBarDlg.h
// Created : Wed Jun 12 12:01:39 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_EDITSCALARBARDLG_H
#define SMESHGUI_EDITSCALARBARDLG_H
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QLineEdit;
class QPushButton;
class SMESHGUI;
class SMESHGUI_EditScalarBarDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_EditScalarBarDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_EditScalarBarDlg();
QPushButton* PushButtonUpdateView;
QLineEdit* LineEditMax;
QLineEdit* LineEditMin;
QLabel* TextLabelMax;
QLabel* TextLabelMin;
QFrame* Line1;
SMESHGUI *mySMESHGUI;
public slots:
void updateView();
protected:
QGridLayout* grid;
QGridLayout* grid_2;
QGridLayout* grid_3;
QGridLayout* grid_4;
QGridLayout* grid_5;
QGridLayout* grid_6;
};
#endif // SMESHGUI_EDITSCALARBARDLG_H

View File

@ -0,0 +1,473 @@
using namespace std;
// File : SMESHGUI_InitMeshDlg.cxx
// Created : Mon May 27 10:20:11 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_InitMeshDlg.h"
#include "SMESHGUI.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_InitMeshDlg()
// purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_INIT_MESH")));
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_InitMeshDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_INIT_MESH" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_InitMeshDlgLayout = new QGridLayout( this );
SMESHGUI_InitMeshDlgLayout->setSpacing( 6 );
SMESHGUI_InitMeshDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_INIT" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image1 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_InitMeshDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_OBJECT_GEOM" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image0 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" );
TextLabel_NameMesh->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameMesh, 1, 0 );
LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
GroupC1Layout->addWidget( LineEdit_NameMesh, 1, 2 );
TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" );
TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) );
TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1Hyp, 2, 0 );
SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
SelectButtonC1A1Hyp->setText( tr( "" ) );
SelectButtonC1A1Hyp->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 );
LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 );
TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" );
TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) );
TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Algo->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1Algo, 3, 0 );
SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
SelectButtonC1A1Algo->setText( tr( "" ) );
SelectButtonC1A1Algo->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 );
LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 );
SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ;
}
//=================================================================================
// function : ~SMESHGUI_InitMeshDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
myGeomFilter = new SALOME_TypeFilter( "GEOM" );
myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM );
myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS );
myNameMesh = "Mesh";
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_InitMeshDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
MESSAGE ( " myNameMesh " << myNameMesh.isEmpty() )
MESSAGE ( " myGeomShape " << myGeomShape->_is_nil() )
if ( !myNameMesh.isEmpty() && !myNameMesh.isNull() && !myGeomShape->_is_nil() )
myMesh = mySMESHGUI->InitMesh( myGeomShape, myNameMesh ) ;
MESSAGE ( " myMesh " << myMesh->_is_nil() )
MESSAGE ( " myOkHypothesis " )
MESSAGE ( " myOkAlgorithm " )
if( myOkHypothesis && !myMesh->_is_nil() ) {
SALOME_ListIteratorOfListIO It( HypoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ;
}
}
if( myOkAlgorithm && !myMesh->_is_nil() ) {
SALOME_ListIteratorOfListIO It( AlgoList );
for(;It.More();It.Next()) {
Handle(SALOME_InteractiveObject) IObject = It.Value();
Standard_Boolean testResult;
myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ;
if( testResult )
mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ;
}
}
break ;
}
}
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_InitMeshDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( myEditCurrentArgument == LineEditC1A1 ) {
if ( nbSel != 1 ) {
myOkHypothesis = false;
myOkAlgorithm = false;
myGeomShape = GEOM::GEOM_Shape::_nil();
return ;
} else {
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult ) {
myOkHypothesis = false;
myOkAlgorithm = false;
return ;
}
}
}
else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
if ( nbSel >= 1 ) {
HypoList.Clear();
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
HypoList.Append(Itinit.Value());
}
myOkHypothesis = true ;
if (nbSel > 1)
aString = tr("%1 Hypothesis").arg(nbSel) ;
LineEditC1A1Hyp->setText(aString) ;
}
else {
myOkHypothesis = false ;
return ;
}
} else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
if ( nbSel >= 1 ) {
AlgoList.Clear();
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() );
for (; Itinit.More(); Itinit.Next()) {
AlgoList.Append(Itinit.Value());
}
myOkAlgorithm = true ;
if (nbSel > 1)
aString = tr("%1 Algorithms").arg(nbSel) ;
LineEditC1A1Algo->setText(aString) ;
}
else {
myOkAlgorithm = false ;
return ;
}
}
myEditCurrentArgument->setText(aString) ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ;
mySelection->AddFilter(myGeomFilter) ;
} else if( send == SelectButtonC1A1Hyp ) {
LineEditC1A1Hyp->setFocus() ;
myEditCurrentArgument = LineEditC1A1Hyp ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myHypothesisFilter) ;
} else if( send == SelectButtonC1A1Algo ) {
LineEditC1A1Algo->setFocus() ;
myEditCurrentArgument = LineEditC1A1Algo ;
mySelection->ClearFilters() ;
mySelection->AddFilter(myAlgorithmFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_InitMeshDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameMesh) {
myNameMesh = newText;
}
return ;
}

View File

@ -0,0 +1,121 @@
// File : SMESHGUI_InitMeshDlg.h
// Created : Mon May 27 10:23:17 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_INIT_MESH_H
#define DIALOGBOX_INIT_MESH_H
#include "SALOME_Selection.h"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_TypeFilter.hxx"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SMESH_Gen)
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_InitMeshDlg
// purpose :
//=================================================================================
class SMESHGUI_InitMeshDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_InitMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_InitMeshDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
SALOME_Selection* mySelection ;
GEOM::GEOM_Shape_var myGeomShape ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QString myNameMesh ;
Handle(SALOME_TypeFilter) myGeomFilter;
Handle(SMESH_TypeFilter) myHypothesisFilter;
Handle(SMESH_TypeFilter) myAlgorithmFilter;
SALOME_ListIO HypoList;
SALOME_ListIO AlgoList;
bool myOkHypothesis;
bool myOkAlgorithm;
SMESH::SMESH_Hypothesis_var myHypothesis;
SMESH::SMESH_Hypothesis_var myAlgorithm;
SMESH::SMESH_Mesh_var myMesh;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabel_NameMesh ;
QLineEdit* LineEdit_NameMesh ;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A1Hyp;
QPushButton* SelectButtonC1A1Hyp;
QLineEdit* LineEditC1A1Hyp;
QLabel* TextLabelC1A1Algo;
QPushButton* SelectButtonC1A1Algo;
QLineEdit* LineEditC1A1Algo;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
protected:
QGridLayout* SMESHGUI_InitMeshDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_INIT_MESH_H

View File

@ -0,0 +1,315 @@
using namespace std;
// File : SMESHGUI_LocalLengthDlg.cxx
// Created : Mon May 27 11:38:27 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_LocalLengthDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_LocalLengthDlg()
// purpose : Constructs a SMESHGUI_LocalLengthDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_LocalLengthDlg::SMESHGUI_LocalLengthDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_LOCAL_LENGTH")));
if ( !name )
setName( "SMESHGUI_LocalLengthDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_LOCAL_LENGTH_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_LocalLengthDlgLayout = new QGridLayout( this );
SMESHGUI_LocalLengthDlgLayout->setSpacing( 6 );
SMESHGUI_LocalLengthDlgLayout->setMargin( 11 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_LocalLengthDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
SMESHGUI_LocalLengthDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_Length = new QLabel(GroupC1 , "TextLabel_Length" );
TextLabel_Length->setText( tr( "SMESH_LENGTH" ) );
GroupC1Layout->addWidget( TextLabel_Length, 1, 0 );
TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
SpinBox_Length = new SMESHGUI_SpinBox( GroupC1, "SpinBox_Length" ) ;
GroupC1Layout->addWidget( SpinBox_Length, 1, 1 );
LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC1Layout->addItem( spacer1, 1, 3 );
SMESHGUI_LocalLengthDlgLayout->addWidget(GroupC1 , 1, 0 );
/***************************************************************/
Init() ;
}
//=================================================================================
// function : ~SMESHGUI_LocalLengthDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_LocalLengthDlg::~SMESHGUI_LocalLengthDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::Init()
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEdit_NameHypothesis ;
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 1.0 ;
/* min, max, step and decimals for spin boxes */
SpinBox_Length->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_Length->SetValue( 1.0 ) ; /* is myLength */
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
LineEdit_NameHypothesis->setText("") ;
myLength = 1.0 ;
myNameHypothesis = "" ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_LocalLengthDlg::ConstructorsClicked(int constructorId)
{
return;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
myLength = SpinBox_Length->GetValue() ;
mySMESHGUI->CreateLocalLength( "LocalLength", myNameHypothesis, myLength );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::ClickOnCancel()
{
mySMESHGUI->ResetState() ;
reject() ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameHypothesis) {
myNameHypothesis = newText ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_LocalLengthDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,89 @@
// File : SMESHGUI_LocalLengthDlg.h
// Created : Mon May 27 11:38:37 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_LOCAL_LENGTH_H
#define DIALOGBOX_LOCAL_LENGTH_H
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
class SMESHGUI_SpinBox;
//=================================================================================
// class : SMESHGUI_LocalLengthDlg
// purpose :
//=================================================================================
class SMESHGUI_LocalLengthDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_LocalLengthDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_LocalLengthDlg();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
QString myNameHypothesis ;
double myLength ;
bool myOkNameHypothesis ;
bool myOkLength ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabel_NameHypothesis ;
QLabel* TextLabel_Length ;
QLineEdit* LineEdit_NameHypothesis ;
SMESHGUI_SpinBox* SpinBox_Length ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
protected:
QGridLayout* SMESHGUI_LocalLengthDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_LOCAL_LENGTH_H

View File

@ -0,0 +1,315 @@
using namespace std;
// File : SMESHGUI_MaxElementAreaDlg.cxx
// Created : Mon May 27 11:38:27 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_MaxElementAreaDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_MaxElementAreaDlg()
// purpose : Constructs a SMESHGUI_MaxElementAreaDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_MaxElementAreaDlg::SMESHGUI_MaxElementAreaDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MAX_ELEMENT_AREA")));
if ( !name )
setName( "SMESHGUI_MaxElementAreaDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_MAX_ELEMENT_AREA_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_MaxElementAreaDlgLayout = new QGridLayout( this );
SMESHGUI_MaxElementAreaDlgLayout->setSpacing( 6 );
SMESHGUI_MaxElementAreaDlgLayout->setMargin( 11 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_MaxElementAreaDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
SMESHGUI_MaxElementAreaDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_MaxElementArea = new QLabel(GroupC1 , "TextLabel_MaxElementArea" );
TextLabel_MaxElementArea->setText( tr( "SMESH_MAX_ELEMENT_AREA" ) );
GroupC1Layout->addWidget( TextLabel_MaxElementArea, 1, 0 );
TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
SpinBox_MaxElementArea = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementArea" ) ;
GroupC1Layout->addWidget( SpinBox_MaxElementArea, 1, 1 );
LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC1Layout->addItem( spacer1, 1, 3 );
SMESHGUI_MaxElementAreaDlgLayout->addWidget(GroupC1 , 1, 0 );
/***************************************************************/
Init() ;
}
//=================================================================================
// function : ~SMESHGUI_MaxElementAreaDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_MaxElementAreaDlg::~SMESHGUI_MaxElementAreaDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::Init()
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEdit_NameHypothesis ;
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 1.0 ;
/* min, max, step and decimals for spin boxes */
SpinBox_MaxElementArea->setPrecision( 10 );
SpinBox_MaxElementArea->RangeStepAndValidator( 0.001, 999999.999, step, 3 ) ;
SpinBox_MaxElementArea->SetValue( 1.0 ) ; /* is myMaxElementArea */
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
LineEdit_NameHypothesis->setText("") ;
myNameHypothesis = "" ;
myMaxElementArea = 1.0 ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::ConstructorsClicked(int constructorId)
{
return;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
myMaxElementArea = SpinBox_MaxElementArea->GetValue() ;
mySMESHGUI->CreateMaxElementArea( "MaxElementArea", myNameHypothesis, myMaxElementArea );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::ClickOnCancel()
{
mySMESHGUI->ResetState() ;
reject() ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameHypothesis) {
myNameHypothesis = newText ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementAreaDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,89 @@
// File : SMESHGUI_MaxElementAreaDlg.h
// Created : Mon May 27 11:38:37 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_MAX_ELEMENT_AREA_H
#define DIALOGBOX_MAX_ELEMENT_AREA_H
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
class SMESHGUI_SpinBox;
//=================================================================================
// class : SMESHGUI_MaxElementAreaDlg
// purpose :
//=================================================================================
class SMESHGUI_MaxElementAreaDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_MaxElementAreaDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_MaxElementAreaDlg();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
QString myNameHypothesis ;
double myMaxElementArea ;
bool myOkNameHypothesis ;
bool myOkMaxElementArea ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabel_NameHypothesis ;
QLabel* TextLabel_MaxElementArea ;
QLineEdit* LineEdit_NameHypothesis ;
SMESHGUI_SpinBox* SpinBox_MaxElementArea ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
protected:
QGridLayout* SMESHGUI_MaxElementAreaDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_MAX_ELEMENT_AREA_H

View File

@ -0,0 +1,319 @@
using namespace std;
// File : SMESHGUI_MaxElementVolumeDlg.cxx
// Created : Wed Jun 12 21:17:51 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_MaxElementVolumeDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_MaxElementVolumeDlg()
// purpose : Constructs a SMESHGUI_MaxElementVolumeDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_MaxElementVolumeDlg::SMESHGUI_MaxElementVolumeDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MAX_ELEMENT_VOLUME")));
if ( !name )
setName( "SMESHGUI_MaxElementVolumeDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_MAX_ELEMENT_VOLUME_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_MaxElementVolumeDlgLayout = new QGridLayout( this );
SMESHGUI_MaxElementVolumeDlgLayout->setSpacing( 6 );
SMESHGUI_MaxElementVolumeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_MaxElementVolumeDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
SMESHGUI_MaxElementVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_MaxElementVolume = new QLabel(GroupC1 , "TextLabel_MaxElementVolume" );
TextLabel_MaxElementVolume->setText( tr( "SMESH_MAX_ELEMENT_VOLUME" ) );
GroupC1Layout->addWidget( TextLabel_MaxElementVolume, 1, 0 );
TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
// LineEdit_MaxElementVolume = new QLineEdit(GroupC1 , "LineEdit_MaxElementVolume" );
// GroupC1Layout->addWidget( LineEdit_MaxElementVolume, 1, 1 );
SpinBox_MaxElementVolume = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementVolume" ) ;
GroupC1Layout->addWidget( SpinBox_MaxElementVolume, 1, 1 );
LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC1Layout->addItem( spacer1, 1, 3 );
SMESHGUI_MaxElementVolumeDlgLayout->addWidget(GroupC1 , 1, 0 );
/***************************************************************/
Init() ;
}
//=================================================================================
// function : ~SMESHGUI_MaxElementVolumeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_MaxElementVolumeDlg::~SMESHGUI_MaxElementVolumeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::Init()
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEdit_NameHypothesis ;
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 1.0 ;
/* min, max, step and decimals for spin boxes */
SpinBox_MaxElementVolume->setPrecision( 10 );
SpinBox_MaxElementVolume->RangeStepAndValidator( 0.001, 999999.999, step, 3 ) ;
SpinBox_MaxElementVolume->SetValue( 1.0 ) ; /* is myMaxElementVolume */
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
LineEdit_NameHypothesis->setText("") ;
myNameHypothesis = "" ;
myMaxElementVolume = 1.0 ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::ConstructorsClicked(int constructorId)
{
return;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
myMaxElementVolume = SpinBox_MaxElementVolume->GetValue() ;
mySMESHGUI->CreateMaxElementVolume( "MaxElementVolume", myNameHypothesis, myMaxElementVolume );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::ClickOnCancel()
{
mySMESHGUI->ResetState() ;
reject() ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameHypothesis) {
myNameHypothesis = newText ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_MaxElementVolumeDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,89 @@
// File : SMESHGUI_MaxElementVolumeDlg.h
// Created : Wed Jun 12 21:18:15 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_MAX_ELEMENT_VOLUME_H
#define DIALOGBOX_MAX_ELEMENT_VOLUME_H
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
class SMESHGUI_SpinBox;
//=================================================================================
// class : SMESHGUI_MaxElementVolumeDlg
// purpose :
//=================================================================================
class SMESHGUI_MaxElementVolumeDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_MaxElementVolumeDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_MaxElementVolumeDlg();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
QString myNameHypothesis ;
double myMaxElementVolume ;
bool myOkNameHypothesis ;
bool myOkMaxElementVolume ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabel_NameHypothesis ;
QLabel* TextLabel_MaxElementVolume ;
QLineEdit* LineEdit_NameHypothesis ;
SMESHGUI_SpinBox* SpinBox_MaxElementVolume ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
protected:
QGridLayout* SMESHGUI_MaxElementVolumeDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_MAX_ELEMENT_VOLUME_H

View File

@ -0,0 +1,428 @@
using namespace std;
// File : SMESHGUI_MeshInfosDlg.cxx
// Created : Sat Jun 08 15:31:16 2002
// Author : Nicolas BARBEROU
// Project : SALOME
// Module : SMESH
// Copyright : EADS CCR 2002
// $Header$
#include "SMESHGUI_MeshInfosDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qmap.h>
/*
* Constructs a SMESHGUI_MeshInfosDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name )
setName( "SMESHGUI_MeshInfosDlg" );
setCaption( tr( "SMESH_MESHINFO_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_MeshInfosDlgLayout = new QVBoxLayout( this );
SMESHGUI_MeshInfosDlgLayout->setSpacing( 6 );
SMESHGUI_MeshInfosDlgLayout->setMargin( 11 );
/****************************************************************/
GroupBox1 = new QGroupBox( this, "GroupBox1" );
GroupBox1->setTitle( tr( "SMESH_MESHINFO_NB1D" ) );
GroupBox1->setColumnLayout(0, Qt::Vertical );
GroupBox1->layout()->setSpacing( 0 );
GroupBox1->layout()->setMargin( 0 );
QGridLayout* GroupBox1Layout = new QGridLayout( GroupBox1->layout() );
GroupBox1Layout->setAlignment( Qt::AlignTop );
GroupBox1Layout->setSpacing( 6 );
GroupBox1Layout->setMargin( 11 );
TextLabel11 = new QLabel( GroupBox1, "TextLabel11" );
TextLabel11->setMinimumWidth( 100 );
TextLabel11->setText( tr( "SMESH_MESHINFO_NODES" ) );
GroupBox1Layout->addWidget( TextLabel11, 0, 0 );
TextLabel12 = new QLabel( GroupBox1, "TextLabel12" );
TextLabel12->setMinimumWidth( 100 );
TextLabel12->setText( tr( "SMESH_MESHINFO_EDGES" ) );
GroupBox1Layout->addWidget( TextLabel12, 1, 0 );
TextLabel13 = new QLabel( GroupBox1, "TextLabel13" );
TextLabel13->setMinimumWidth( 100 );
GroupBox1Layout->addWidget( TextLabel13, 0, 1 );
TextLabel14 = new QLabel( GroupBox1, "TextLabel14" );
TextLabel14->setMinimumWidth( 100 );
GroupBox1Layout->addWidget( TextLabel14, 1, 1 );
SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox1 );
/****************************************************************/
GroupBox2 = new QGroupBox( this, "GroupBox2" );
GroupBox2->setTitle( tr( "SMESH_MESHINFO_NB2D" ) );
GroupBox2->setColumnLayout(0, Qt::Vertical );
GroupBox2->layout()->setSpacing( 0 );
GroupBox2->layout()->setMargin( 0 );
QGridLayout* GroupBox2Layout = new QGridLayout( GroupBox2->layout() );
GroupBox2Layout->setAlignment( Qt::AlignTop );
GroupBox2Layout->setSpacing( 6 );
GroupBox2Layout->setMargin( 11 );
TextLabel21 = new QLabel( GroupBox2, "TextLabel21" );
TextLabel21->setMinimumWidth( 100 );
TextLabel21->setText( tr( "SMESH_MESHINFO_TRIANGLES" ) );
GroupBox2Layout->addWidget( TextLabel21, 0, 0 );
TextLabel22 = new QLabel( GroupBox2, "TextLabel22" );
TextLabel22->setMinimumWidth( 100 );
TextLabel22->setText( tr( "SMESH_MESHINFO_QUADRANGLES" ) );
GroupBox2Layout->addWidget( TextLabel22, 1, 0 );
TextLabel23 = new QLabel( GroupBox2, "TextLabel23" );
TextLabel23->setMinimumWidth( 100 );
GroupBox2Layout->addWidget( TextLabel23, 0, 1 );
TextLabel24 = new QLabel( GroupBox2, "TextLabel24" );
TextLabel24->setMinimumWidth( 100 );
GroupBox2Layout->addWidget( TextLabel24, 1, 1 );
SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox2 );
/****************************************************************/
GroupBox3 = new QGroupBox( this, "GroupBox3" );
GroupBox3->setTitle( tr( "SMESH_MESHINFO_NB3D" ) );
GroupBox3->setColumnLayout(0, Qt::Vertical );
GroupBox3->layout()->setSpacing( 0 );
GroupBox3->layout()->setMargin( 0 );
QGridLayout* GroupBox3Layout = new QGridLayout( GroupBox3->layout() );
GroupBox3Layout->setAlignment( Qt::AlignTop );
GroupBox3Layout->setSpacing( 6 );
GroupBox3Layout->setMargin( 11 );
TextLabel31 = new QLabel( GroupBox3, "TextLabel31" );
TextLabel31->setMinimumWidth( 100 );
TextLabel31->setText( tr( "SMESH_MESHINFO_TETRAS" ) );
GroupBox3Layout->addWidget( TextLabel31, 0, 0 );
TextLabel32 = new QLabel( GroupBox3, "TextLabel32" );
TextLabel32->setMinimumWidth( 100 );
TextLabel32->setText( tr( "SMESH_MESHINFO_HEXAS" ) );
GroupBox3Layout->addWidget( TextLabel32, 1, 0 );
TextLabel33 = new QLabel( GroupBox3, "TextLabel33" );
TextLabel33->setMinimumWidth( 100 );
GroupBox3Layout->addWidget( TextLabel33, 0, 1 );
TextLabel34 = new QLabel( GroupBox3, "TextLabel34" );
TextLabel34->setMinimumWidth( 100 );
GroupBox3Layout->addWidget( TextLabel34, 1, 1 );
SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox3 );
/****************************************************************/
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
SMESHGUI_MeshInfosDlgLayout->addWidget( GroupButtons );
/****************************************************************/
Init( Sel ) ;
}
/*
* Destroys the object and frees any allocated resources
*/
SMESHGUI_MeshInfosDlg::~SMESHGUI_MeshInfosDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
myStudy = mySMESHGUI->GetActiveStudy()->getStudyDocument();
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH");
myCompMesh = SMESH::SMESH_Gen::_narrow(comp);
int nbSel = mySelection->IObjectCount();
TextLabel13->setText( "0" );
TextLabel14->setText( "0" );
TextLabel23->setText( "0" );
TextLabel24->setText( "0" );
TextLabel33->setText( "0" );
TextLabel34->setText( "0" );
//gets the selected mesh
if ( nbSel == 1 ) {
Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res );
if ( res )
DumpMeshInfos();
}
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : genEdgeKey
// purpose : edge counting helper;
// packs two long integers into one 8-byte value (treated as double by the caller);
// the order of arguments is insignificant
//=================================================================================
void genEdgeKey(long a, long b, void* key)
{
long* lKey = (long*)key;
*lKey = (a < b) ? a : b;
*(++lKey) = (a < b) ? b : a;
}
//=================================================================================
// function : DumpMeshInfos()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::DumpMeshInfos()
{
int nbOfNodes = myMesh->NbNodes();
int nbOfEdges = myMesh->NbEdges();
int nbOfTriangles = myMesh->NbTriangles();
int nbOfQuadrangles = myMesh->NbQuadrangles();
int nbOfTetras = myMesh->NbTetras();
int nbOfHexas = myMesh->NbHexas();
/*
int nbOfNodes = 0 ;
int nbOfEdges = 0 ;
int nbOfTriangles = 0 ;
int nbOfQuadrangles = 0 ;
int nbOfTetras = 0 ;
int nbOfHexas = 0 ;
int nbCells = 0 ;
int CellType = 0 ;
QMap<double, char> aMapOfEdges;
Standard_Boolean result;
SMESH_Actor* MeshActor = mySMESHGUI->FindActor(myMesh, result, true);
if ( result ) {
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( MeshActor->DataSource );
vtkPoints *Pts = ugrid->GetPoints();
nbOfNodes = Pts->GetNumberOfPoints();
int nbCells = ugrid->GetNumberOfCells();
for ( int i = 0; i < nbCells; i++ ) {
vtkCell* cellPtr = ugrid->GetCell(i);
CellType = cellPtr->GetCellType();
switch (CellType)
{
case 3: //Edges
{
nbOfEdges++;
break;
}
case 5: //Triangles
{
nbOfTriangles++;
for (int edgeNum = 0; edgeNum < 3; edgeNum++) {
vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
double anEdgeKey;
genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
if (!aMapOfEdges.contains(anEdgeKey)) {
nbOfEdges++;
aMapOfEdges.insert(anEdgeKey, 0);
}
}
break;
}
case 9: //Quadrangles
{
nbOfQuadrangles++;
for (int edgeNum = 0; edgeNum < 4; edgeNum++) {
vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
double anEdgeKey;
genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
if (!aMapOfEdges.contains(anEdgeKey)) {
nbOfEdges++;
aMapOfEdges.insert(anEdgeKey, 0);
}
}
break;
}
case 10: //Tetraedras
{
nbOfTetras++;
for (int edgeNum = 0; edgeNum < 6; edgeNum++) {
vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
double anEdgeKey;
genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
if (!aMapOfEdges.contains(anEdgeKey)) {
nbOfEdges++;
aMapOfEdges.insert(anEdgeKey, 0);
}
}
break;
}
case 12: //Hexahedras
{
nbOfHexas++;
for (int edgeNum = 0; edgeNum < 12; edgeNum++) {
vtkCell* edgePtr = cellPtr->GetEdge(edgeNum);
double anEdgeKey;
genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey);
if (!aMapOfEdges.contains(anEdgeKey)) {
nbOfEdges++;
aMapOfEdges.insert(anEdgeKey, 0);
}
}
break;
}
}
}
}
*/
TextLabel13->setText( tr( "%1" ).arg(nbOfNodes) );
TextLabel14->setText( tr( "%1" ).arg(nbOfEdges) );
TextLabel23->setText( tr( "%1" ).arg(nbOfTriangles) );
TextLabel24->setText( tr( "%1" ).arg(nbOfQuadrangles) );
TextLabel33->setText( tr( "%1" ).arg(nbOfTetras) );
TextLabel34->setText( tr( "%1" ).arg(nbOfHexas) );
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::ClickOnOk()
{
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void SMESHGUI_MeshInfosDlg::SelectionIntoArgument()
{
TextLabel13->setText( "0" );
TextLabel14->setText( "0" );
TextLabel23->setText( "0" );
TextLabel24->setText( "0" );
TextLabel33->setText( "0" );
TextLabel34->setText( "0" );
int nbSel = mySelection->IObjectCount();
if ( nbSel == 1 ) {
Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject();
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res );
if ( res )
DumpMeshInfos();
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::closeEvent( QCloseEvent* e )
{
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void SMESHGUI_MeshInfosDlg::enterEvent( QEvent * )
{
ActivateThisDialog() ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog()
{
disconnect( mySelection, 0, this, 0 );
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_MeshInfosDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
return ;
}

View File

@ -0,0 +1,83 @@
// File : SMESHGUI_MeshInfosDlg.h
// Created : Sat Jun 08 15:31:16 2002
// Author : Nicolas BARBEROU
// Project : SALOME
// Module : SMESH
// Copyright : EADS CCR 2002 2002
// $Header$
#ifndef SMESHGUI_MESHINFOSDLG_H
#define SMESHGUI_MESHINFOSDLG_H
#include "SALOME_Selection.h"
#include "QAD_Study.h"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QGroupBox;
class QLabel;
class QPushButton;
class SMESHGUI;
class SMESHGUI_MeshInfosDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_MeshInfosDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_MeshInfosDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void DumpMeshInfos();
SMESH::SMESH_Gen_var myCompMesh ;
SMESHGUI* mySMESHGUI ;
SMESH::SMESH_Mesh_var myMesh ;
SALOME_Selection* mySelection ;
SALOMEDS::Study_var myStudy;
QGroupBox* GroupBox1;
QLabel* TextLabel12;
QLabel* TextLabel11;
QLabel* TextLabel13;
QLabel* TextLabel14;
QGroupBox* GroupBox2;
QLabel* TextLabel21;
QLabel* TextLabel22;
QLabel* TextLabel23;
QLabel* TextLabel24;
QGroupBox* GroupBox3;
QLabel* TextLabel31;
QLabel* TextLabel32;
QLabel* TextLabel33;
QLabel* TextLabel34;
QPushButton* buttonOk;
private slots:
void ClickOnOk();
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QVBoxLayout* SMESHGUI_MeshInfosDlgLayout;
QHBoxLayout* Layout1;
};
#endif // SMESHGUI_MESHINFOSDLG_H

View File

@ -0,0 +1,467 @@
using namespace std;
// File : SMESHGUI_MoveNodesDlg.cxx
// Created : Thu Jun 20 22:30:09 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_MoveNodesDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
// Open CASCADE Include
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
// VTK Include
#include <vtkActor.h>
//=================================================================================
// class : SMESHGUI_MoveNodesDlg()
// purpose :
//=================================================================================
SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MOVE_NODE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_MoveNodesDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_MOVE_NODES_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_MoveNodesDlgLayout = new QGridLayout( this );
SMESHGUI_MoveNodesDlgLayout->setSpacing( 6 );
SMESHGUI_MoveNodesDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_NODES" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_MoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_MoveNodesDlgLayout->addWidget( GroupButtons, 3, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_MOVE" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_MoveNodesDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) );
GroupCoordinates->setColumnLayout(0, Qt::Vertical );
GroupCoordinates->layout()->setSpacing( 0 );
GroupCoordinates->layout()->setMargin( 0 );
GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
GroupCoordinatesLayout->setSpacing( 6 );
GroupCoordinatesLayout->setMargin( 11 );
TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
TextLabel_X->setText( tr( "SMESH_X" ) );
GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
TextLabel_Y->setText( tr( "SMESH_Y" ) );
GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
TextLabel_Z->setText( tr( "SMESH_Z" ) );
GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
SMESHGUI_MoveNodesDlgLayout->addWidget( GroupCoordinates, 2, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_MoveNodesDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* Sel )
{
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 25.0 ;
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkNodes = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* min, max, step and decimals for spin boxes */
SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_X->SetValue( 0.0 ) ;
SpinBox_Y->SetValue( 0.0 ) ;
SpinBox_Z->SetValue( 0.0 ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_MoveNodesDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkNodes) {
mySMESHGUI->EraseSimulationActors();
// mySMESHGUI->MoveNode( myMesh, myIdnode, LineEdit_X->text().toFloat(), LineEdit_Y->text().toFloat(), LineEdit_Z->text().toFloat() ) ;
// mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_MoveNodesDlg::SelectionIntoArgument()
{
disconnect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
disconnect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
disconnect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
mySMESHGUI->EraseSimulationActors();
myEditCurrentArgument->setText("") ;
myOkNodes = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return ;
int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes != 1) {
SpinBox_X->SetValue(0.0) ;
SpinBox_Y->SetValue(0.0) ;
SpinBox_Z->SetValue(0.0) ;
return ;
}
if ( mySelection->SelectionMode() != 1 ){
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
SMESH_Actor* ac = mySMESHGUI->FindActorByEntry( mySelection->firstIObject()->getEntry(), res, false );
if ( !res )
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
TColStd_MapIteratorOfMapOfInteger ite( myMapIndex );
if ( ite.More() ) {
myIdnode = ite.Key();
mySimulationActor = mySMESHGUI->SimulationMoveNode( ac, myIdnode );
} else
return ;
MESSAGE ( " myIdnode " << myIdnode );
float *pt = ac->GetMapper()->GetInput()->GetPoint(myIdnode);
MESSAGE ( " pt " << pt[0] << ";" << pt[1] << ";" << pt[2] )
SpinBox_X->SetValue( (double)pt[0] ) ;
SpinBox_Y->SetValue( (double)pt[1] ) ;
SpinBox_Z->SetValue( (double)pt[2] ) ;
connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
myOkNodes = true ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void SMESHGUI_MoveNodesDlg::ValueChangedInSpinBox( double newValue )
{
double vx = SpinBox_X->GetValue() ;
double vy = SpinBox_Y->GetValue() ;
double vz = SpinBox_Z->GetValue() ;
mySMESHGUI->DisplaySimulationMoveNode( mySimulationActor, myIdnode, vx, vy , vz );
}

View File

@ -0,0 +1,111 @@
// File : SMESHGUI_MoveNodesDlg.h
// Created : Thu Jun 20 22:30:22 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_MOVE_NODES_H
#define DIALOGBOX_MOVE_NODES_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
class SMESHGUI_SpinBox;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
// VTK Include
#include <vtkActor.h>
//=================================================================================
// class : SMESHGUI_MoveNodesDlg
// purpose :
//=================================================================================
class SMESHGUI_MoveNodesDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_MoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_MoveNodesDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
int myIdnode;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
vtkActor *mySimulationActor;
QGroupBox* GroupCoordinates;
QLabel* TextLabel_X;
QLabel* TextLabel_Y;
QLabel* TextLabel_Z;
SMESHGUI_SpinBox* SpinBox_X;
SMESHGUI_SpinBox* SpinBox_Y;
SMESHGUI_SpinBox* SpinBox_Z;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* SMESHGUI_MoveNodesDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupCoordinatesLayout;
};
#endif // DIALOGBOX_MOVE_NODES_H

View File

@ -0,0 +1,310 @@
using namespace std;
// File : SMESHGUI_NbSegmentsDlg.cxx
// Created : Mon May 27 11:38:27 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_NbSegmentsDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qspinbox.h>
//=================================================================================
// class : SMESHGUI_NbSegmentsDlg()
// purpose : Constructs a SMESHGUI_NbSegmentsDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
SMESHGUI_NbSegmentsDlg::SMESHGUI_NbSegmentsDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_NB_SEGMENTS")));
if ( !name )
setName( "SMESHGUI_NbSegmentsDlg" );
resize( 303, 175 );
setCaption( tr( "SMESH_NB_SEGMENTS_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_NbSegmentsDlgLayout = new QGridLayout( this );
SMESHGUI_NbSegmentsDlgLayout->setSpacing( 6 );
SMESHGUI_NbSegmentsDlgLayout->setMargin( 11 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_NbSegmentsDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_NB_SEGMENTS_HYPOTHESIS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
SMESHGUI_NbSegmentsDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_NbSeg = new QLabel(GroupC1 , "TextLabel_NbSeg" );
TextLabel_NbSeg->setText( tr( "SMESH_SEGMENTS" ) );
GroupC1Layout->addWidget( TextLabel_NbSeg, 1, 0 );
TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" );
TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) );
GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 );
SpinBox_NbSeg = new QSpinBox( GroupC1, "SpinBox_NbSeg" );
GroupC1Layout->addWidget( SpinBox_NbSeg, 1, 1 );
LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" );
GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 );
QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC1Layout->addItem( spacer1, 1, 3 );
SMESHGUI_NbSegmentsDlgLayout->addWidget(GroupC1 , 1, 0 );
/***************************************************************/
Init() ;
}
//=================================================================================
// function : ~SMESHGUI_NbSegmentsDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_NbSegmentsDlg::~SMESHGUI_NbSegmentsDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::Init()
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEdit_NameHypothesis ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
LineEdit_NameHypothesis->setText("") ;
SpinBox_NbSeg->setMinValue( 1 );
SpinBox_NbSeg->setMaxValue( 9999 );
SpinBox_NbSeg->setValue(3) ; /* myNbSeg */
myNbSeg = 3.0 ;
myNameHypothesis = "" ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_NbSegmentsDlg::ConstructorsClicked(int constructorId)
{
return;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
myNbSeg = SpinBox_NbSeg->value() ;
mySMESHGUI->CreateNbSegments( "NumberOfSegments", myNameHypothesis, myNbSeg );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::ClickOnCancel()
{
mySMESHGUI->ResetState() ;
reject() ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
if (send == LineEdit_NameHypothesis) {
myNameHypothesis = newText ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::ActivateThisDialog()
{
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_NbSegmentsDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,89 @@
// File : SMESHGUI_NbSegmentsDlg.h
// Created : Mon May 27 11:38:37 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_NB_SEGMENTS_H
#define DIALOGBOX_NB_SEGMENTS_H
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QSpinBox;
class QPushButton;
class QRadioButton;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_NbSegmentsDlg
// purpose :
//=================================================================================
class SMESHGUI_NbSegmentsDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_NbSegmentsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_NbSegmentsDlg();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ;
SMESHGUI* mySMESHGUI ;
QString myNameHypothesis ;
double myNbSeg ;
bool myOkNameHypothesis ;
QDoubleValidator *myVa ;
int myConstructorId ;
QLineEdit* myEditCurrentArgument;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabel_NameHypothesis ;
QLabel* TextLabel_NbSeg ;
QLineEdit* LineEdit_NameHypothesis ;
QSpinBox* SpinBox_NbSeg ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void DeactivateActiveDialog() ;
void TextChangedInLineEdit(const QString& newText) ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_NbSegmentsDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_NB_SEGMENTS_H

View File

@ -0,0 +1,397 @@
using namespace std;
// File : SMESHGUI_NodesDlg.cxx
// Created : Tue May 14 21:35:46 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#include "QAD_MessageBox.h"
#include "SMESH_Actor.h"
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
// VTK Includes
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkDataSetMapper.h>
#include <vtkIdList.h>
#include <vtkVertex.h>
// QT Includes
#include <qbuttongroup.h>
#include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qvalidator.h>
#include <qevent.h>
//=================================================================================
// class : SMESHGUI_NodesDlg()
// purpose :
//=================================================================================
SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( QWidget* parent,
const char* name,
SALOME_Selection* Sel,
bool modal,
WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_NODE")));
if ( !name )
setName( "SMESHGUI_NodesDlg" );
resize( 303, 185 );
setCaption( tr( "MESH_NODE_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_NodesDlgLayout = new QGridLayout( this );
SMESHGUI_NodesDlgLayout->setSpacing( 6 );
SMESHGUI_NodesDlgLayout->setMargin( 11 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_NodesDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "MESH_NODE" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) );
GroupCoordinates->setColumnLayout(0, Qt::Vertical );
GroupCoordinates->layout()->setSpacing( 0 );
GroupCoordinates->layout()->setMargin( 0 );
GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
GroupCoordinatesLayout->setSpacing( 6 );
GroupCoordinatesLayout->setMargin( 11 );
TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
TextLabel_X->setText( tr( "SMESH_X" ) );
GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
TextLabel_Y->setText( tr( "SMESH_Y" ) );
GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
TextLabel_Z->setText( tr( "SMESH_Z" ) );
GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ;
GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates, 1, 0 );
/* Initialisation and display */
Init(Sel) ;
}
//=======================================================================
// function : ~SMESHGUI_NodesDlg()
// purpose : Destructor
//=======================================================================
SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg()
{}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel)
{
/* Get setting of step value from file configuration */
double step ;
// QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO
// step = St.toDouble() ; TODO
step = 25.0 ;
/* min, max, step and decimals for spin boxes */
SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ;
SpinBox_X->SetValue( 0.0 ) ;
SpinBox_Y->SetValue( 0.0 ) ;
SpinBox_Z->SetValue( 0.0 ) ;
mySelection = Sel ;
myMeshGUI = SMESHGUI::GetSMESHGUI() ;
myMeshGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myMeshGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myMeshGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myMeshGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
SelectionIntoArgument();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue )
{
double vx = SpinBox_X->GetValue() ;
double vy = SpinBox_Y->GetValue() ;
double vz = SpinBox_Z->GetValue() ;
myMeshGUI->DisplaySimulationNode( myMesh, vx, vy, vz );
//myMeshGUI->ViewNodes();
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_NodesDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=======================================================================
// function : ClickOnApply()
// purpose :
//=======================================================================
void SMESHGUI_NodesDlg::ClickOnApply()
{
if ( myMeshGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) {
return;
}
if ( Constructor1->isChecked() ) {
/* Recup args and call method */
double x = SpinBox_X->GetValue() ;
double y = SpinBox_Y->GetValue() ;
double z = SpinBox_Z->GetValue() ;
myMeshGUI->EraseSimulationActors() ;
myMeshGUI->AddNode( myMesh, x, y, z ) ;
myMeshGUI->ViewNodes();
mySelection->ClearIObjects();
}
}
//=======================================================================
// function : ClickOnCancel()
// purpose :
//=======================================================================
void SMESHGUI_NodesDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
myMeshGUI->ResetState() ;
myMeshGUI->EraseSimulationActors() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_NodesDlg::SelectionIntoArgument()
{
int nbSel = mySelection->IObjectCount();
if(nbSel != 1) {
SpinBox_X->SetValue(0.0) ;
SpinBox_Y->SetValue(0.0) ;
SpinBox_Z->SetValue(0.0) ;
return;
}
Standard_Boolean res;
myMesh = myMeshGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res) {
SpinBox_X->SetValue(0.0) ;
SpinBox_Y->SetValue(0.0) ;
SpinBox_Z->SetValue(0.0) ;
return ;
}
if ( mySelection->SelectionMode() != 1 ) {
SpinBox_X->SetValue(0.0) ;
SpinBox_Y->SetValue(0.0) ;
SpinBox_Z->SetValue(0.0) ;
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
QString aString = "";
int nbNodes = myMeshGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes != 1) {
SpinBox_X->SetValue(0.0) ;
SpinBox_Y->SetValue(0.0) ;
SpinBox_Z->SetValue(0.0) ;
return ;
}
if ( nbNodes == 1 ) {
TColStd_MapOfInteger myMapIndex;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
TColStd_MapIteratorOfMapOfInteger ite( myMapIndex );
int idNodes[1];
for ( ; ite.More(); ite.Next() ) {
idNodes[0] = ite.Key();
}
Standard_Boolean result;
SMESH_Actor* ac = myMeshGUI->FindActor( myMesh, result, true );
vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource );
float *p0 = ugrid->GetPoint(idNodes[0]);
SpinBox_X->SetValue( p0[0] ) ;
SpinBox_Y->SetValue( p0[1] ) ;
SpinBox_Z->SetValue( p0[2] ) ;
myMeshGUI->DisplaySimulationNode( myMesh, p0[0], p0[1], p0[2] );
// myMeshGUI->ViewNodes();
}
return ;
}
//=======================================================================
// function : closeEvent()
// purpose :
//=======================================================================
void SMESHGUI_NodesDlg::closeEvent(QCloseEvent* e)
{
this->ClickOnCancel() ; /* same than click on cancel button */
return ;
}
//=================================================================================
// function : enterEvent()
// purpose : to reactivate this dialog box when mouse enter onto the window
//=================================================================================
void SMESHGUI_NodesDlg::enterEvent( QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void SMESHGUI_NodesDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupCoordinates->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
myMeshGUI->EraseSimulationActors() ;
myMeshGUI->ResetState() ;
myMeshGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_NodesDlg::ActivateThisDialog( )
{
myMeshGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupCoordinates->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}

View File

@ -0,0 +1,96 @@
// File : SMESHGUI_NodesDlg.h
// Created : Tue May 14 21:36:44 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_NODES_H
#define DIALOGBOX_NODES_H
#include "SALOME_Selection.h"
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
class SMESHGUI_SpinBox;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_NodesDlg
// purpose :
//=================================================================================
class SMESHGUI_NodesDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_NodesDlg( QWidget* parent = 0, const char* name = 0,
SALOME_Selection* Sel = 0,
bool modal = FALSE,
WFlags fl = 0 );
~SMESHGUI_NodesDlg();
private :
SALOME_Selection* mySelection ;
SMESHGUI* myMeshGUI ;
SMESH::SMESH_Mesh_var myMesh;
void Init(SALOME_Selection* Sel) ;
void enterEvent(QEvent* e);
void closeEvent(QCloseEvent* e) ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupCoordinates;
SMESHGUI_SpinBox* SpinBox_X;
SMESHGUI_SpinBox* SpinBox_Y;
SMESHGUI_SpinBox* SpinBox_Z;
QLabel* TextLabel_X;
QLabel* TextLabel_Y;
QLabel* TextLabel_Z;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void SelectionIntoArgument() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* SMESHGUI_NodesDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupCoordinatesLayout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_NODES_H

View File

@ -0,0 +1,354 @@
using namespace std;
// File : SMESHGUI_OrientationElementsDlg.cxx
// Created : Tue Jun 25 14:28:17 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_OrientationElementsDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_OrientationElementsDlg()
// purpose :
//=================================================================================
SMESHGUI_OrientationElementsDlg::SMESHGUI_OrientationElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MESH_ORIENTATION")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_OrientationElementsDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_ORIENTATION_ELEMENTS_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_OrientationElementsDlgLayout = new QGridLayout( this );
SMESHGUI_OrientationElementsDlgLayout->setSpacing( 6 );
SMESHGUI_OrientationElementsDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_ORIENTATION" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_OrientationElementsDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_OrientationElementsDlg::~SMESHGUI_OrientationElementsDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkElements = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_OrientationElementsDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkElements) {
mySMESHGUI->OrientationElements( myMesh, myMapIndex ) ;
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_OrientationElementsDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkElements = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ;
if(nbElements < 1)
return ;
if ( mySelection->SelectionMode() != 3 ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
myOkElements = true ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_OrientationElementsDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,94 @@
// File : SMESHGUI_OrientationElementsDlg.h
// Created : Tue Jun 25 14:30:34 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_ORIENTATION_ELEMENTS_H
#define DIALOGBOX_ORIENTATION_ELEMENTS_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_OrientationElementsDlg
// purpose :
//=================================================================================
class SMESHGUI_OrientationElementsDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_OrientationElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_OrientationElementsDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkElements ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_OrientationElementsDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ORIENTATION_ELEMENTS_H

View File

@ -0,0 +1,375 @@
using namespace std;
// File : SMESHGUI_Preferences_ColorDlg.cxx
// Created : Mon Jun 17 19:11:27 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_Preferences_ColorDlg.h"
#include "SMESHGUI.h"
#include "utilities.h"
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qframe.h>
#include <qlabel.h>
#include <qpixmap.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qcolordialog.h>
#include <qspinbox.h>
#include <qcolor.h>
/*
* Constructs a SMESHGUI_Preferences_ColorDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( QWidget* parent, const char* name )
: QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name )
setName( "SMESHGUI_Preferences_ColorDlg" );
setCaption( tr( "Preferences - Set Color" ) );
setSizeGripEnabled( TRUE );
QGridLayout* SMESHGUI_Preferences_ColorDlgLayout = new QGridLayout( this );
SMESHGUI_Preferences_ColorDlgLayout->setSpacing( 6 );
SMESHGUI_Preferences_ColorDlgLayout->setMargin( 11 );
ButtonGroup1 = new QButtonGroup( tr( "Elements" ), this, "ButtonGroup1" );
ButtonGroup1->setColumnLayout(0, Qt::Vertical );
ButtonGroup1->layout()->setSpacing( 0 );
ButtonGroup1->layout()->setMargin( 0 );
QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() );
ButtonGroup1Layout->setAlignment( Qt::AlignTop );
ButtonGroup1Layout->setSpacing( 6 );
ButtonGroup1Layout->setMargin( 11 );
TextLabel_Fill = new QLabel( tr( "Fill" ), ButtonGroup1, "TextLabel_2D_Fill" );
ButtonGroup1Layout->addWidget( TextLabel_Fill, 0, 0 );
btnFillColor = new QPushButton( ButtonGroup1, "btnFillColor" );
btnFillColor->setFixedSize( QSize( 25, 25 ) );
ButtonGroup1Layout->addWidget( btnFillColor, 0, 1 );
TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1, "TextLabel_2D_Outine" );
ButtonGroup1Layout->addWidget( TextLabel_Outine, 0, 2 );
btnOutlineColor = new QPushButton( ButtonGroup1, "btnOutlineColor" );
btnOutlineColor->setFixedSize( QSize( 25, 25 ) );
ButtonGroup1Layout->addWidget( btnOutlineColor, 0, 3 );
TextLabel_Width = new QLabel( tr( "Width" ), ButtonGroup1, "TextLabel_2D_Width" );
ButtonGroup1Layout->addWidget( TextLabel_Width, 0, 4 );
SpinBox_Width = new QSpinBox( 0, 5, 1, ButtonGroup1, "SpinBox_Width" );
SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
SpinBox_Width->setWrapping( FALSE );
SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus );
ButtonGroup1Layout->addWidget( SpinBox_Width, 0, 5 );
TextLabel_BackFace = new QLabel( tr( "Back Face" ), ButtonGroup1, "TextLabel_BackFace" );
ButtonGroup1Layout->addWidget( TextLabel_BackFace, 1, 0 );
btnBackFaceColor = new QPushButton( ButtonGroup1, "btnBackFaceColor" );
btnBackFaceColor->setFixedSize( QSize( 25, 25 ) );
ButtonGroup1Layout->addWidget( btnBackFaceColor, 1, 1 );
TextLabel_ShrinkCoeff = new QLabel( tr( "Shrink coef." ), ButtonGroup1, "TextLabel_ShrinkCoeff" );
ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, 2, 0 );
SpinBox_Shrink = new QSpinBox( 20, 100, 1, ButtonGroup1, "SpinBox_Shrink" );
SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus );
ButtonGroup1Layout->addMultiCellWidget( SpinBox_Shrink, 2, 2, 1, 5);
SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup1, 0, 0 );
ButtonGroup2 = new QButtonGroup( tr( "Nodes" ), this, "ButtonGroup2" );
ButtonGroup2->setColumnLayout(0, Qt::Vertical );
ButtonGroup2->layout()->setSpacing( 0 );
ButtonGroup2->layout()->setMargin( 0 );
QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2->layout() );
ButtonGroup2Layout->setAlignment( Qt::AlignTop );
ButtonGroup2Layout->setSpacing( 6 );
ButtonGroup2Layout->setMargin( 11 );
TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2, "TextLabel_Nodes_Color" );
ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 );
btnNodeColor = new QPushButton( ButtonGroup2, "btnNodeColor" );
btnNodeColor->setFixedSize( QSize( 25, 25 ) );
ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 );
TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2, "TextLabel_Nodes_Size" );
ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size, 0, 2 );
SpinBox_Nodes_Size = new QSpinBox( 0, 5, 1, ButtonGroup2, "SpinBox_Nodes_Size" );
SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
SpinBox_Nodes_Size->setWrapping( FALSE );
SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus );
ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size, 0, 3 );
SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup2, 1, 0 );
GroupButtons = new QButtonGroup( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
SMESHGUI_Preferences_ColorDlgLayout->addWidget( GroupButtons, 2, 0 );
Init();
}
/*
* Destroys the object and frees any allocated resources
*/
SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::Init()
{
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( btnFillColor, SIGNAL( clicked() ), this, SLOT( SelectFillColor() ) ) ;
connect( btnOutlineColor, SIGNAL( clicked() ), this, SLOT( SelectOutlineColor() ) ) ;
connect( btnNodeColor, SIGNAL( clicked() ), this, SLOT( SelectNodeColor() ) ) ;
connect( btnBackFaceColor, SIGNAL( clicked() ), this, SLOT( SelectBackFaceColor() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
}
//=================================================================================
// function : SelectFillColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SelectFillColor()
{
QColor color = btnFillColor->palette().active().button();
color = QColorDialog::getColor( color );
if ( color.isValid() ) {
QPalette pal = btnFillColor->palette();
pal.setColor(QColorGroup::Button, color);
btnFillColor->setPalette(pal);
}
}
//=================================================================================
// function : SelectBackFaceColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SelectBackFaceColor()
{
QColor color = btnBackFaceColor->palette().active().button();
color = QColorDialog::getColor( color );
if ( color.isValid() ) {
QPalette pal = btnBackFaceColor->palette();
pal.setColor(QColorGroup::Button, color);
btnBackFaceColor->setPalette(pal);
}
}
//=================================================================================
// function : SelectOutlineColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SelectOutlineColor()
{
QColor color = btnOutlineColor->palette().active().button();
color = QColorDialog::getColor( color );
if ( color.isValid() ) {
QPalette pal = btnOutlineColor->palette();
pal.setColor(QColorGroup::Button, color);
btnOutlineColor->setPalette(pal);
}
}
//=================================================================================
// function : SelectNodeColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SelectNodeColor()
{
QColor color = btnNodeColor->palette().active().button();
color = QColorDialog::getColor( color );
if ( color.isValid() ) {
QPalette pal = btnNodeColor->palette();
pal.setColor(QColorGroup::Button, color);
btnNodeColor->setPalette(pal);
}
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::ClickOnOk()
{
mySMESHGUI->ResetState();
accept();
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::ClickOnCancel()
{
mySMESHGUI->ResetState();
reject() ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog()
{
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
return ;
}
//=================================================================================
// function : SetColor()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SetColor(int type, QColor color)
{
switch (type) {
case 1 : // fill
{
QPalette pal = btnFillColor->palette();
pal.setColor(QColorGroup::Button, color);
btnFillColor->setPalette(pal);
break;
}
case 2 : // outline
{
QPalette pal = btnOutlineColor->palette();
pal.setColor(QColorGroup::Button, color);
btnOutlineColor->setPalette(pal);
break;
}
case 3 : // node
{
QPalette pal = btnNodeColor->palette();
pal.setColor(QColorGroup::Button, color);
btnNodeColor->setPalette(pal);
break;
}
case 4 : // back face
{
QPalette pal = btnBackFaceColor->palette();
pal.setColor(QColorGroup::Button, color);
btnBackFaceColor->setPalette(pal);
break;
}
}
}
//=================================================================================
// function : GetColor()
// purpose :
//=================================================================================
QColor SMESHGUI_Preferences_ColorDlg::GetColor(int type)
{
QColor color;
switch (type) {
case 1 : color = btnFillColor->palette().active().button(); break; // fill
case 2 : color = btnOutlineColor->palette().active().button(); break; // outline
case 3 : color = btnNodeColor->palette().active().button(); break; // node
case 4 : color = btnBackFaceColor->palette().active().button(); break; // back face
}
return color;
}
//=================================================================================
// function : SetIntValue()
// purpose :
//=================================================================================
void SMESHGUI_Preferences_ColorDlg::SetIntValue(int type, int value)
{
switch (type) {
case 1 : SpinBox_Width->setValue(value); break; // width
case 2 : SpinBox_Nodes_Size->setValue(value); break; // nodes size = value; break;
case 3 : SpinBox_Shrink->setValue(value); break; // shrink coeff
}
}
//=================================================================================
// function : GetIntValue()
// purpose :
//=================================================================================
int SMESHGUI_Preferences_ColorDlg::GetIntValue(int type)
{
int res = 0;
switch (type) {
case 1 : res = SpinBox_Width->value(); break; // width
case 2 : res = SpinBox_Nodes_Size->value(); break; // nodes size
case 3 : res = SpinBox_Shrink->value(); break; // shrink coeff
}
return res;
}

View File

@ -0,0 +1,86 @@
// File : SMESHGUI_Preferences_ColorDlg.h
// Created : Mon Jun 17 19:11:46 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_PREFERENCES_COLORDLG_H
#define SMESHGUI_PREFERENCES_COLORDLG_H
// SALOME Includes
#include "QAD_Config.h"
#include "QAD_Settings.h"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
// QT Includes
#include <qdialog.h>
class QButtonGroup;
class QFrame;
class QLabel;
class QPushButton;
class QSpinBox;
class QColor;
class SMESHGUI;
class SMESHGUI_Preferences_ColorDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_Preferences_ColorDlg( QWidget* parent = 0, const char* name = 0 );
~SMESHGUI_Preferences_ColorDlg();
void SetColor(int type, QColor color);
QColor GetColor(int type);
void SetIntValue(int type, int value);
int GetIntValue(int type);
private:
void closeEvent( QCloseEvent* e ) ;
void Init();
private slots:
// void RadioButtonClicked(int radioButtonId);
void ClickOnOk();
void ClickOnCancel();
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void SelectFillColor();
void SelectBackFaceColor();
void SelectOutlineColor();
void SelectNodeColor();
private:
SMESH::SMESH_Gen_var myCompMesh ;
SMESHGUI* mySMESHGUI ;
QButtonGroup* ButtonGroup1;
QLabel* TextLabel_Fill;
QPushButton* btnFillColor;
QLabel* TextLabel_Outine;
QPushButton* btnOutlineColor;
QLabel* TextLabel_Width;
QSpinBox* SpinBox_Width;
QLabel* TextLabel_BackFace;
QPushButton* btnBackFaceColor;
QLabel* TextLabel_ShrinkCoeff;
QSpinBox* SpinBox_Shrink;
QButtonGroup* ButtonGroup2;
QLabel* TextLabel_Nodes_Color;
QPushButton* btnNodeColor;
QLabel* TextLabel_Nodes_Size;
QSpinBox* SpinBox_Nodes_Size;
QButtonGroup* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
};
#endif // SMESHGUI_PREFERENCES_COLORDLG_H

View File

@ -0,0 +1,187 @@
using namespace std;
// File : SMESHGUI_Preferences_ScalarBarDlg.cxx
// Created : Tue Jun 11 17:23:32 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
/*
* Constructs a SMESHGUI_Preferences_ScalarBarDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name )
setName( "SMESHGUI_Preferences_ScalarBarDlg" );
setCaption( tr( "SMESH_PREFERENCES_SCALARBAR" ) );
setSizeGripEnabled( TRUE );
grid = new QGridLayout( this );
grid->setSpacing( 6 );
grid->setMargin( 11 );
/******************************************************************************/
Properties = new QGroupBox( this, "Properties" );
Properties->setTitle( tr( "SMESH_PROPERTIES" ) );
Properties->setColumnLayout(0, Qt::Vertical );
Properties->layout()->setSpacing( 0 );
Properties->layout()->setMargin( 0 );
grid_4 = new QGridLayout( Properties->layout() );
grid_4->setAlignment( Qt::AlignTop );
grid_4->setSpacing( 6 );
grid_4->setMargin( 11 );
/* Font */
grid_5 = new QGridLayout;
grid_5->setSpacing( 6 );
grid_5->setMargin( 0 );
TextLabel2 = new QLabel( Properties, "TextLabel2" );
TextLabel2->setText( tr( "SMESH_FONT" ) );
grid_5->addWidget( TextLabel2, 0, 0 );
ComboBox1 = new QComboBox( FALSE, Properties, "ComboBox1" );
ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
ComboBox1->insertItem( tr( "SMESH_FONT_ARIAL" ) );
ComboBox1->insertItem( tr( "SMESH_FONT_COURIER" ) );
ComboBox1->insertItem( tr( "SMESH_FONT_TIMES" ) );
grid_5->addWidget( ComboBox1, 0, 1 );
grid_4->addLayout( grid_5, 0, 0 );
/* Font attributes */
grid_6 = new QGridLayout;
grid_6->setSpacing( 6 );
grid_6->setMargin( 0 );
Bold = new QCheckBox( Properties, "Bold" );
Bold->setText( tr( "SMESH_FONT_BOLD" ) );
grid_6->addWidget( Bold, 0, 0 );
Italic = new QCheckBox( Properties, "Italic" );
Italic->setText( tr( "SMESH_FONT_ITALIC" ) );
grid_6->addWidget( Italic, 0, 1 );
Shadow = new QCheckBox( Properties, "Shadow" );
Shadow->setText( tr( "SMESH_FONT_SHADOW" ) );
grid_6->addWidget( Shadow, 0, 2 );
grid_4->addLayout( grid_6, 1, 0 );
grid_7 = new QGridLayout;
grid_7->setSpacing( 6 );
grid_7->setMargin( 0 );
NumberColors = new QLabel( Properties, "NumberColors" );
NumberColors->setText( tr( "SMESH_NUMBEROFCOLORS" ) );
grid_7->addWidget( NumberColors, 0, 0 );
SpinBoxColors = new QSpinBox( Properties, "SpinBoxColors" );
SpinBoxColors->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
SpinBoxColors->setMinValue( 1 );
grid_7->addWidget( SpinBoxColors, 0, 1 );
NumberLabels = new QLabel( Properties, "NumberLabels" );
NumberLabels->setText( tr( "SMESH_NUMBEROFLABELS" ) );
grid_7->addWidget( NumberLabels, 1, 0 );
SpinBoxLabels = new QSpinBox( Properties, "SpinBoxLabels" );
SpinBoxLabels->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
SpinBoxLabels->setMinValue( 1 );
grid_7->addWidget( SpinBoxLabels, 1, 1 );
grid_4->addLayout( grid_7, 2, 0 );
grid->addWidget( Properties, 0, 0 );
/******************************************************************************/
ButtonGroup_Orientation = new QButtonGroup( this, "ButtonGroup_Orientation" );
ButtonGroup_Orientation->setTitle( tr( "SMESH_ORIENTATION" ) );
ButtonGroup_Orientation->setColumnLayout(0, Qt::Vertical );
ButtonGroup_Orientation->layout()->setSpacing( 0 );
ButtonGroup_Orientation->layout()->setMargin( 0 );
grid_2 = new QGridLayout( ButtonGroup_Orientation->layout() );
grid_2->setAlignment( Qt::AlignTop );
grid_2->setSpacing( 6 );
grid_2->setMargin( 11 );
RadioVert = new QRadioButton( ButtonGroup_Orientation, "RadioVert" );
RadioVert->setText( tr( "SMESH_VERTICAL" ) );
RadioHoriz = new QRadioButton( ButtonGroup_Orientation, "RadioHoriz" );
RadioHoriz->setText( tr( "SMESH_HORIZONTAL" ) );
grid_2->addWidget( RadioVert, 0, 0 );
grid_2->addWidget( RadioHoriz, 0, 1 );
grid->addWidget( ButtonGroup_Orientation, 1, 0 );
/******************************************************************************/
GroupBox5 = new QGroupBox( this, "GroupBox5" );
GroupBox5->setTitle( tr( "SMESH_DIMENSIONS" ) );
GroupBox5->setColumnLayout(0, Qt::Vertical );
GroupBox5->layout()->setSpacing( 0 );
GroupBox5->layout()->setMargin( 0 );
grid_11 = new QGridLayout( GroupBox5->layout() );
grid_11->setAlignment( Qt::AlignTop );
grid_11->setSpacing( 6 );
grid_11->setMargin( 11 );
LineEditWidth = new QLineEdit( GroupBox5, "LineEditWidth" );
grid_11->addWidget( LineEditWidth, 0, 0 );
Width = new QLabel( GroupBox5, "Width" );
Width->setText( tr( "SMESH_WIDTH" ) );
grid_11->addWidget( Width, 0, 1 );
LineEditHeight = new QLineEdit( GroupBox5, "LineEditHeight" );
grid_11->addWidget( LineEditHeight, 1, 0 );
Height = new QLabel( GroupBox5, "Height" );
Height->setText( tr( "SMESH_HEIGHT" ) );
grid_11->addWidget( Height, 1, 1 );
grid->addWidget( GroupBox5, 2, 0 );
/***************************************************************/
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
grid_15 = new QGridLayout( GroupButtons->layout() );
grid_15->setAlignment( Qt::AlignTop );
grid_15->setSpacing( 6 );
grid_15->setMargin( 11 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
grid_15->addWidget( buttonOk, 0, 0 );
grid_15->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CANCEL" ) );
buttonCancel->setAutoDefault( TRUE );
grid_15->addWidget( buttonCancel, 0, 2 );
grid->addWidget( GroupButtons, 3, 0 );
// signals and slots connections
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg()
{
// no need to delete child widgets, Qt does it all for us
}

View File

@ -0,0 +1,75 @@
// File : SMESHGUI_Preferences_ScalarBarDlg.h
// Created : Tue Jun 11 17:23:15 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_PREFERENCES_SCALARBARDLG_H
#define SMESHGUI_PREFERENCES_SCALARBARDLG_H
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QSpinBox;
class SMESHGUI_Preferences_ScalarBarDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_Preferences_ScalarBarDlg();
QButtonGroup* ButtonGroup_Orientation;
QRadioButton* RadioHoriz;
QRadioButton* RadioVert;
QGroupBox* Properties;
QLabel* NumberLabels;
QLabel* NumberColors;
QSpinBox* SpinBoxLabels;
QSpinBox* SpinBoxColors;
QLabel* TextLabel2;
QComboBox* ComboBox1;
QCheckBox* Shadow;
QCheckBox* Italic;
QCheckBox* Bold;
QGroupBox* GroupBox5;
QLineEdit* LineEditWidth;
QLineEdit* LineEditHeight;
QLabel* Height;
QLabel* Width;
QPushButton* buttonCancel;
QPushButton* buttonOk;
protected:
QGridLayout* grid;
QGridLayout* grid_2;
QGridLayout* grid_3;
QGridLayout* grid_4;
QGridLayout* grid_5;
QGridLayout* grid_6;
QGridLayout* grid_7;
QGridLayout* grid_8;
QGridLayout* grid_9;
QGridLayout* grid_10;
QGridLayout* grid_11;
QGridLayout* grid_12;
QGridLayout* grid_13;
QGridLayout* grid_14;
QGridLayout* grid_15;
};
#endif // SMESHGUI_PREFERENCES_SCALARBARDLG_H

View File

@ -0,0 +1,351 @@
using namespace std;
// File : SMESHGUI_RemoveElementsDlg.cxx
// Created : Fri Jun 07 11:18:31 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_RemoveElementsDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_RemoveElementsDlg()
// purpose :
//=================================================================================
SMESHGUI_RemoveElementsDlg::SMESHGUI_RemoveElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_REM_ELEMENT")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_RemoveElementsDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_REMOVE_ELEMENTS_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_RemoveElementsDlgLayout = new QGridLayout( this );
SMESHGUI_RemoveElementsDlgLayout->setSpacing( 6 );
SMESHGUI_RemoveElementsDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_REMOVE" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_RemoveElementsDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_RemoveElementsDlg::~SMESHGUI_RemoveElementsDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkElements = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkElements) {
mySMESHGUI->RemoveElements( myMesh, myMapIndex ) ;
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkElements = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return;
int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ;
if(nbElements < 1)
return ;
if ( mySelection->SelectionMode() != 3 ) {
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
myOkElements = true ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_RemoveElementsDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,93 @@
// File : SMESHGUI_RemoveElementsDlg.h
// Created : Fri Jun 07 11:18:42 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_REMOVE_ELEMENTS_H
#define DIALOGBOX_REMOVE_ELEMENTS_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_RemoveElementsDlg
// purpose :
//=================================================================================
class SMESHGUI_RemoveElementsDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_RemoveElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_RemoveElementsDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkElements ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_RemoveElementsDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_REMOVE_ELEMENTS_H

View File

@ -0,0 +1,362 @@
using namespace std;
// File : SMESHGUI_RemoveNodesDlg.cxx
// Created : Fri Jun 07 11:18:31 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "utilities.h"
// QT Includes
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : SMESHGUI_RemoveNodesDlg()
// purpose :
//=================================================================================
SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel,
bool modal, WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_REM_NODE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_RemoveNodesDlg" );
resize( 303, 185 );
setCaption( tr( "SMESH_REMOVE_NODES_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_RemoveNodesDlgLayout = new QGridLayout( this );
SMESHGUI_RemoveNodesDlgLayout->setSpacing( 6 );
SMESHGUI_RemoveNodesDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "SMESH_NODES" ) );
GroupConstructors->setExclusive( TRUE );
GroupConstructors->setColumnLayout(0, Qt::Vertical );
GroupConstructors->layout()->setSpacing( 0 );
GroupConstructors->layout()->setMargin( 0 );
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
GroupConstructorsLayout->setAlignment( Qt::AlignTop );
GroupConstructorsLayout->setSpacing( 6 );
GroupConstructorsLayout->setMargin( 11 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "SMESH_REMOVE" ) );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupC1, 1, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~SMESHGUI_RemoveNodesDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkNodes = false ;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
SelectionIntoArgument();
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkNodes) {
mySMESHGUI->EraseSimulationActors();
mySMESHGUI->RemoveNodes( myMesh, myMapIndex ) ;
mySMESHGUI->ViewNodes();
mySelection->ClearIObjects();
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ClickOnCancel()
{
QAD_Application::getDesktop()->SetSelectionMode( 4 );
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState() ;
mySMESHGUI->EraseSimulationActors();
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myOkNodes = false;
QString aString = "";
int nbSel = mySelection->IObjectCount();
if(nbSel != 1)
return ;
int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ;
if(nbNodes < 1)
return ;
if ( mySelection->SelectionMode() != 1 ){
QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"),
tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") );
return;
}
myEditCurrentArgument->setText(aString) ;
Standard_Boolean res;
myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res );
if (!res)
return ;
mySelection->GetIndex( mySelection->firstIObject(), myMapIndex);
myOkNodes = true ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
mySMESHGUI->EraseSimulationActors() ;
mySMESHGUI->ResetState() ;
mySMESHGUI->SetActiveDialogBox(0) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
mySMESHGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_RemoveNodesDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,93 @@
// File : SMESHGUI_RemoveNodesDlg.h
// Created : Fri Jun 07 11:18:42 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_REMOVE_NODES_H
#define DIALOGBOX_REMOVE_NODES_H
#include "SALOME_Selection.h"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
// Open CASCADE Includes
#include <TColStd_MapOfInteger.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class SMESHGUI;
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_RemoveNodesDlg
// purpose :
//=================================================================================
class SMESHGUI_RemoveNodesDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_RemoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_RemoveNodesDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
SMESH::SMESH_Mesh_var myMesh;
TColStd_MapOfInteger myMapIndex;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* SMESHGUI_RemoveNodesDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_REMOVE_NODES_H

View File

@ -0,0 +1,77 @@
using namespace std;
// File : SMESHGUI_SpinBox.cxx
// Created : 14 august 2002
// Author : Lucien PIGNOLONI
// Project : SALOME
// Module : SMESHGUI
// Copyright : OPEN CASCADE
// $Header$
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI.h"
#include <qvalidator.h>
//=================================================================================
// class : SMESHGUI_SpinBox()
// purpose : constructor of specific widget accepting floats in double precision.
//=================================================================================
SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent, const char* name )
: QAD_SpinBoxDbl( parent, name)
{
}
//=================================================================================
// function : SetStep() [SLOT]
// purpose :
//=================================================================================
void SMESHGUI_SpinBox::SetStep( double newStep )
{
setLineStep( newStep );
}
//=================================================================================
// function : ~SMESHGUI_SpinBox()
// purpose : destructor
//=================================================================================
SMESHGUI_SpinBox::~SMESHGUI_SpinBox()
{
}
//=================================================================================
// function : SetValue()
// purpose :
//=================================================================================
void SMESHGUI_SpinBox::SetValue( double v )
{
setValue( v );
}
//=================================================================================
// function : GetValue()
// purpose : returns a double
//=================================================================================
double SMESHGUI_SpinBox::GetValue( )
{
return value();
}
//=================================================================================
// function : GetString()
// purpose : returns a QString
//=================================================================================
QString SMESHGUI_SpinBox::GetString( )
{
return cleanText();
}
//=================================================================================
// function : RangeStepAndValidator()
// purpose :
//=================================================================================
void SMESHGUI_SpinBox::RangeStepAndValidator( double min, double max, double step, unsigned short decimals )
{
setRange( min, max );
setLineStep( step );
( ( QDoubleValidator* )validator() )->setRange( min, max, decimals ) ;
}

View File

@ -0,0 +1,39 @@
// File : SMESHGUI_SpinBox.h
// Created : 14 august 2002
// Author : Lucien PIGNOLONI
// Project : SALOME
// Module : SMESHGUI
// Copyright : OPEN CASCADE
// $Header$
#ifndef SMESHSPINBOX_H
#define SMESHSPINBOX_H
#include "QAD_SpinBoxDbl.h"
//=================================================================================
// class : SMESHGUI_SpinBox
// purpose : Derivated from QAD_SpinBoxDbl class
//=================================================================================
class SMESHGUI_SpinBox : public QAD_SpinBoxDbl
{
Q_OBJECT
public :
SMESHGUI_SpinBox( QWidget* parent, const char* name = 0 ) ;
~SMESHGUI_SpinBox() ;
void RangeStepAndValidator( double min = -1000000.0,
double max = +1000000.0,
double step = 100.0,
unsigned short decimals = 3 ) ;
void SetValue( double v ) ;
double GetValue() ;
QString GetString() ;
public slots:
void SetStep( double newStep );
};
#endif // SMESHSPINBOX_H

View File

@ -0,0 +1,691 @@
using namespace std;
// File : SMESHGUI_StudyAPI.cxx
// Created : Fri May 17 15:23:35 CEST 2002
// Author : Yves FRICAUD
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE
// $Header:
#include "SMESHGUI_StudyAPI.h"
#include "utilities.h"
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "QAD_MessageBox.h"
#include "QAD_Application.h"
// QT Includes
#include <qobject.h>
// Open CASCADE Includes
#include "Standard_CString.hxx"
static CORBA::ORB_var _orb;
// Tags definition
long Tag_HypothesisRoot = 1;
long Tag_AlgorithmsRoot = 2;
long Tag_RefOnShape = 1;
long Tag_RefOnAppliedHypothesis = 2;
long Tag_RefOnAppliedAlgorithms = 3;
long Tag_SubMeshOnVertex = 4;
long Tag_SubMeshOnEdge = 5;
long Tag_SubMeshOnFace = 6;
long Tag_SubMeshOnSolid = 7;
long Tag_SubMeshOnCompound = 8;
static char* IORToString (CORBA::Object_ptr obj)
{
// MESSAGE ( " IORToString " << _orb->object_to_string(obj) )
return _orb->object_to_string(obj);
}
CORBA::Object_ptr SMESHGUI_StudyAPI::StringToIOR (const char* IOR)
{
// MESSAGE ( " StringToIOR " << _orb->string_to_object(IOR) )
return _orb->string_to_object(IOR);
}
//=======================================================================
// function :
// purpose : Constructor
//=======================================================================
SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ()
{
}
SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy,
SMESH::SMESH_Gen_ptr CompMesh)
{
myStudy = aStudy;
myStudyBuilder = aStudy->NewBuilder();
setOrb();
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
QObject::tr("WARNING"),
QObject::tr("WRN_STUDY_LOCKED"),
QObject::tr("BUT_OK") );
return;
}
// NRI
SALOMEDS::SComponent_var father = aStudy->FindComponent("MESH");
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributePixMap_var aPixmap;
if (father->_is_nil()) {
father = myStudyBuilder->NewComponent("MESH");
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
//NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT"));
aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) );
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
}
myStudyBuilder->DefineComponentInstance(father, CompMesh );
mySComponentMesh = SALOMEDS::SComponent::_narrow( father );
}
//=======================================================================
// function :
// purpose : Destructor
//=======================================================================
SMESHGUI_StudyAPI::~SMESHGUI_StudyAPI ()
{
}
//=======================================================================
// function :
// purpose : Update
//=======================================================================
void SMESHGUI_StudyAPI::Update(SMESH::SMESH_Gen_ptr CompMesh)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH");
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributePixMap_var aPixmap;
if (father->_is_nil()) {
father = myStudyBuilder->NewComponent("MESH");
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
//NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT"));
aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) );
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
}
myStudyBuilder->DefineComponentInstance(father, CompMesh );
mySComponentMesh = SALOMEDS::SComponent::_narrow( father );
}
//=======================================================================
// function : AddNewMesh
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewMesh (SMESH::SMESH_Mesh_ptr M)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
//Find or Create Hypothesis root
SALOMEDS::SObject_var HypothesisRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
SALOMEDS::SObject_var AlgorithmsRoot;
if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
// Add New Mesh
SALOMEDS::SObject_var newMesh = myStudyBuilder->NewObject(mySComponentMesh);
anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IORToString(M));
return SALOMEDS::SObject::_narrow( newMesh );
}
//=======================================================================
// function : SetShape
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::SetShape (SALOMEDS::SObject_ptr SO_MorSM,
SALOMEDS::SObject_ptr SO_GeomShape )
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
SALOMEDS::SObject_var SO = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnShape);
myStudyBuilder->Addreference (SO,SO_GeomShape);
}
//=======================================================================
// function : GetShapeOnMeshOrSubMesh
// purpose :
//=======================================================================
GEOM::GEOM_Shape_ptr SMESHGUI_StudyAPI::GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return GEOM::GEOM_Shape::_nil();
}
// NRI
GEOM::GEOM_Shape_var Shape;
SALOMEDS::SObject_var aSO, aGeom;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( SO_Mesh_Or_SubMesh->FindSubObject( Tag_RefOnShape, aSO ) ) {
if ( aSO->ReferencedObject(aGeom) ) {
if (aGeom->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
return GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) );
}
}
}
return GEOM::GEOM_Shape::_nil();
}
//=======================================================================
// function : AddNewHypothesis
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewHypothesis (SMESH::SMESH_Hypothesis_ptr H)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
//Find or Create Hypothesis root
SALOMEDS::SObject_var HypothesisRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
}
// Add New Hypothesis
SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
QString aType = H->GetName();
MESSAGE ( " aType " << aType )
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_" + aType );
// if ( aType.compare("LocalLength") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_LENGTH" );
// else if ( aType.compare("NumberOfSegments") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_SEGMENT" );
// else if ( aType.compare("MaxElementArea") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_AREA" );
// else if ( aType.compare("MaxElementVolume") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_VOLUME" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IORToString(H));
return SALOMEDS::SObject::_narrow(newHypo);
}
//=======================================================================
// function : AddNewAlgorithms
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewAlgorithms (SMESH::SMESH_Hypothesis_ptr H)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
//Find or Create Algorithms root
SALOMEDS::SObject_var AlgorithmsRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
}
// Add New Algorithms
SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
QString aType = H->GetName();
// if ( aType.compare("Regular_1D") == 0 )
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_" + aType );
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_REGULAR" );
// else if ( aType.compare("MEFISTO_2D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_MEFISTO" );
// else if ( aType.compare("Quadrangle_2D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_QUAD" );
// else if ( aType.compare("Hexa_3D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_HEXA" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IORToString(H));
return SALOMEDS::SObject::_narrow(newHypo);
}
//=======================================================================
// function : AddSubMeshOnShape
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh,
SMESH::SMESH_subMesh_ptr SM,
GEOM::shape_type ST)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
long Tag_Shape ;
Standard_CString Name;
if (ST == GEOM::SOLID) {Tag_Shape = Tag_SubMeshOnSolid; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnSolid"));}
else if (ST == GEOM::FACE) {Tag_Shape = Tag_SubMeshOnFace; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnFace"));}
else if (ST == GEOM::EDGE) {Tag_Shape = Tag_SubMeshOnEdge; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnEdge"));}
else if (ST == GEOM::VERTEX){Tag_Shape = Tag_SubMeshOnVertex; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnVertex"));}
else {
Tag_Shape = Tag_SubMeshOnCompound; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnCompound"));
}
SALOMEDS::SObject_var SubmeshesRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
if (!SO_Mesh->FindSubObject (Tag_Shape,SubmeshesRoot )) {
SubmeshesRoot = myStudyBuilder->NewObjectToTag (SO_Mesh, Tag_Shape);
anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(Name);
anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IORToString(SM));
return SALOMEDS::SObject::_narrow( SO );
}
//=======================================================================
// function : AddSubMeshOnShape
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh,
SALOMEDS::SObject_ptr SO_GeomShape,
SMESH::SMESH_subMesh_ptr SM,
GEOM::shape_type ST)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
SALOMEDS::SObject_var SO_SM = AddSubMeshOnShape (SO_Mesh,SM,ST);
SetShape (SO_SM,SO_GeomShape);
// SetShapeOnSubMesh (SO_SM,SO_GeomShape);
return SALOMEDS::SObject::_narrow( SO_SM );
}
//=======================================================================
// function : SetHypothesis
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::SetHypothesis (SALOMEDS::SObject_ptr SO_MorSM,
SALOMEDS::SObject_ptr SO_Hypothesis)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
//Find or Create Applied Hypothesis root
SALOMEDS::SObject_var AHR;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedHypothesis, AHR)) {
AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR);
myStudyBuilder->Addreference (SO,SO_Hypothesis);
}
//=======================================================================
// function : SetAlgorithms
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::SetAlgorithms (SALOMEDS::SObject_ptr SO_MorSM,
SALOMEDS::SObject_ptr SO_Algorithms)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
//Find or Create Applied Algorithms root
SALOMEDS::SObject_var AHR;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedAlgorithms, AHR)) {
AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR);
myStudyBuilder->Addreference (SO,SO_Algorithms);
}
//=======================================================================
// function :
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindMesh (SMESH::SMESH_Mesh_ptr M)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(M)) );
}
//=======================================================================
// function :
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(H)) );
}
//=======================================================================
// function :
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindSubMesh (SMESH::SMESH_subMesh_ptr SM)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(SM)) );
}
void SMESHGUI_StudyAPI::setOrb()
{
try {
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
_orb = init( 0 , 0 );
} catch (...) {
INFOS("internal error : orb not found");
_orb = 0;
}
ASSERT(! CORBA::is_nil(_orb));
}
//=======================================================================
// function :
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::SetTagHypothesisRoot()
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(mySComponentMesh);
int i = 0;
for (; it->More();it->Next()) {
i++;
}
Tag_HypothesisRoot = i++;
}
//=======================================================================
// function :
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::SetName( SALOMEDS::SObject_ptr SO, const char* Name )
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(Name);
}
//=======================================================================
// function :
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
myStudyBuilder->RemoveObject(SO_Applied_Hypothesis);
}
//=======================================================================
// function :
// purpose :
//=======================================================================
void SMESHGUI_StudyAPI::UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return;
}
// NRI
myStudyBuilder->RemoveObject(SO_Applied_Algorithm);
}
//=======================================================================
// function :
// purpose :
//=======================================================================
SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return SALOMEDS::SObject::_nil();
}
// NRI
SALOMEDS::SObject_var MorSM,SB;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
if (SO->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Shape_var Shape = GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) );
if (!Shape->_is_nil()) {
//It s a shape
MorSM = SO->GetFather();
// MESSAGE ( " MorSM shape " << MorSM->GetID() )
return SALOMEDS::SObject::_narrow( MorSM);
}
}
if (SO->ReferencedObject(SB)) {
//It's Reference on Hypothesis or Algorithm
MorSM = SO->GetFather()->GetFather();
// MESSAGE ( " MorSM reference " << MorSM->GetID() )
return SALOMEDS::SObject::_narrow( MorSM);
}
// It's SMESH_MEN_APPLIED_HYPOTHESIS or SMESH_MEN_APPLIED_ALGORITHMS or SubMeshesOnFace etc...
MorSM = SO->GetFather();
// MESSAGE ( " MorSM banniere " << MorSM->GetID() )
return SALOMEDS::SObject::_narrow( MorSM);
}
void SMESHGUI_StudyAPI::ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right)
{
// NRI : Temporary added
if ( myStudy->GetProperties()->IsLocked() ) {
return ;
}
// NRI
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributePixMap_var aPixmap;
anAttr = myStudyBuilder->FindOrCreateAttribute(MorSM, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
if (right) {
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
} else {
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" );
}
int i = 1;
SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(MorSM);
for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value();
if ( i >= 4 ) {
int j = 1;
SALOMEDS::ChildIterator_var it1 = myStudy->NewChildIterator(Obj);
for (; it1->More();it1->Next()) {
SALOMEDS::SObject_var Obj1 = it1->Value();
anAttr = myStudyBuilder->FindOrCreateAttribute(Obj1, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
if (right) {
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
} else {
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" );
}
}
}
i++;
}
}

View File

@ -0,0 +1,86 @@
// File : SMESHGUI_StudyAPI.h
// Created : Fri May 17 15:23:35 CEST 2002
// Author : Yves FRICAUD
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE
// $Header:
#ifndef _INCLUDE_SMESHGUI_StudyAPI_
#define _INCLUDE_SMESHGUI_StudyAPI_
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
class SMESH_subMesh_ptr;
class SMESHGUI_StudyAPI {
public:
SMESHGUI_StudyAPI ();
SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy, SMESH::SMESH_Gen_ptr Gen);
~SMESHGUI_StudyAPI ();
// Adding in Study
CORBA::Object_ptr StringToIOR(const char* IOR);
SALOMEDS::SObject_ptr AddNewMesh (SMESH::SMESH_Mesh_ptr M);
SALOMEDS::SObject_ptr AddNewHypothesis (SMESH::SMESH_Hypothesis_ptr H);
SALOMEDS::SObject_ptr AddNewAlgorithms (SMESH::SMESH_Hypothesis_ptr H);
SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST);
SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SALOMEDS::SObject_ptr SO_GeomShape, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST);
void Update(SMESH::SMESH_Gen_ptr Gen);
void ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right);
void SetShape (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_GeomShape);
GEOM::GEOM_Shape_ptr GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh);
void SetHypothesis (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Hypothesis);
void SetAlgorithms (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Algorithms);
void UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis);
void UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm);
void SetTagHypothesisRoot();
void SetName( SALOMEDS::SObject_ptr SO, const char* Name ) ;
//Exploration
SALOMEDS::SObject_ptr GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO);
SALOMEDS::SObject_ptr FindMesh (SMESH::SMESH_Mesh_ptr M);
SALOMEDS::SObject_ptr FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H);
SALOMEDS::SObject_ptr FindSubMesh (SMESH::SMESH_subMesh_ptr SM);
//SALOMEDS::ListOfSObject_ptr FindMesh (SALOMEDS_SObject_ptr SO_GeomShape);
//SALOMEDS_SObject_ptr FindSubMesh (SALOMEDS_SObject_ptr SO_Mesh, SALOMEDS_SObject_ptr SO_GeomShape);
static void setOrb();
private:
//fields
SALOMEDS::Study_var myStudy;
SALOMEDS::StudyBuilder_var myStudyBuilder;
SALOMEDS::SComponent_var mySComponentMesh;
};
#endif

View File

@ -0,0 +1,405 @@
using namespace std;
// File : SMESH_Swig.cxx
// Created : Mon Jun 17 13:41:43 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_Swig.hxx"
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
// SALOME Includes
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_ResourceMgr.h"
#include "utilities.h"
// Open CASCADE Includes
#include <TopoDS.hxx>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
#include CORBA_SERVER_HEADER(GEOM_Shape)
static CORBA::ORB_var _orb;
static char* ObjectToString (CORBA::Object_ptr obj)
{
return _orb->object_to_string(obj);
}
static CORBA::Object_ptr StringToObject (const char* ior)
{
return _orb->string_to_object(ior);
}
SMESH_Swig::SMESH_Swig()
{
MESSAGE("Constructeur");
setOrb();
}
void SMESH_Swig::Init(int studyID)
{
MESSAGE("Init");
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH");
SMESH::SMESH_Gen_var CompMesh = SMESH::SMESH_Gen::_narrow(comp);
QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager();
if ( resMgr ) {
QString msg;
if (!resMgr->loadResources( "SMESH", msg ))
MESSAGE ( msg )
}
CORBA::Object_var obj = QAD_Application::getDesktop()->getNameService()->Resolve("/myStudyManager");
SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj);
myStudy = myStudyMgr->GetStudyByID(studyID);
myStudyBuilder = myStudy->NewBuilder();
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributePixMap_var aPixmap;
SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH");
if (father->_is_nil()) {
father = myStudyBuilder->NewComponent("MESH");
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
//NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT"));
aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) );
anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" );
}
myStudyBuilder->DefineComponentInstance(father, CompMesh );
mySComponentMesh = SALOMEDS::SComponent::_narrow( father );
// Tags definition
Tag_HypothesisRoot = 1;
Tag_AlgorithmsRoot = 2;
Tag_RefOnShape = 1;
Tag_RefOnAppliedHypothesis = 2;
Tag_RefOnAppliedAlgorithms = 3;
Tag_SubMeshOnVertex = 4;
Tag_SubMeshOnEdge = 5;
Tag_SubMeshOnFace = 6;
Tag_SubMeshOnSolid = 7;
Tag_SubMeshOnCompound = 8;
}
SMESH_Swig::~SMESH_Swig()
{
MESSAGE("Destructeur");
}
const char* SMESH_Swig::AddNewMesh(const char* IOR)
{
MESSAGE("AddNewMesh");
//Find or Create Hypothesis root
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
SALOMEDS::SObject_var HypothesisRoot;
if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
SALOMEDS::SObject_var AlgorithmsRoot;
if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
// Add New Mesh
SALOMEDS::SObject_var newMesh = myStudyBuilder->NewObject(mySComponentMesh);
anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IOR);
return SALOMEDS::SObject::_narrow( newMesh )->GetID();
}
const char* SMESH_Swig::AddNewHypothesis(const char* IOR)
{
MESSAGE("AddNewHypothesis");
//Find or Create Hypothesis root
SALOMEDS::SObject_var HypothesisRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) {
HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
}
// Add New Hypothesis
SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(HypothesisRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
SMESH::SMESH_Hypothesis_var H = SMESH::SMESH_Hypothesis::_narrow( StringToObject(IOR) );
QString aType = H->GetName();
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_" + aType );
// if ( aType.compare("LocalLength") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_LENGTH" );
// else if ( aType.compare("NumberOfSegments") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_SEGMENT" );
// else if ( aType.compare("MaxElementArea") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_AREA" );
// else if ( aType.compare("MaxElementVolume") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_VOLUME" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IOR);
return SALOMEDS::SObject::_narrow(newHypo)->GetID();
}
const char* SMESH_Swig::AddNewAlgorithms(const char* IOR)
{
MESSAGE("AddNewAlgorithms");
//Find or Create Algorithms root
SALOMEDS::SObject_var AlgorithmsRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) {
AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
}
// Add New Algorithms
SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(AlgorithmsRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
SMESH::SMESH_Hypothesis_var H = SMESH::SMESH_Hypothesis::_narrow( StringToObject(IOR) );
QString aType = H->GetName();
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_" + aType );
// if ( aType.compare("Regular_1D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_REGULAR" );
// else if ( aType.compare("MEFISTO_2D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_MEFISTO" );
// else if ( aType.compare("Quadrangle_2D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_QUAD" );
// else if ( aType.compare("Hexa_3D") == 0 )
// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_HEXA" );
anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(IOR);
return SALOMEDS::SObject::_narrow(newHypo)->GetID();
}
void SMESH_Swig::SetShape(const char* ShapeEntry, const char* MeshEntry)
{
SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( MeshEntry );
SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectID( ShapeEntry );
if ( !SO_MorSM->_is_nil() && !SO_GeomShape->_is_nil() ) {
SALOMEDS::SObject_var SO = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnShape);
myStudyBuilder->Addreference (SO,SO_GeomShape);
}
}
void SMESH_Swig::SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry)
{
SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( Mesh_Or_SubMesh_Entry );
SALOMEDS::SObject_var SO_Hypothesis = myStudy->FindObjectID( Hypothesis_Entry );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if ( !SO_MorSM->_is_nil() && !SO_Hypothesis->_is_nil() ) {
//Find or Create Applied Hypothesis root
SALOMEDS::SObject_var AHR;
if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedHypothesis, AHR)) {
AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" );
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR);
myStudyBuilder->Addreference (SO,SO_Hypothesis);
}
}
void SMESH_Swig::SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry)
{
SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( Mesh_Or_SubMesh_Entry );
SALOMEDS::SObject_var SO_Algorithms = myStudy->FindObjectID( Algorithms_Entry );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeSelectable_var aSelAttr;
SALOMEDS::AttributePixMap_var aPixmap;
if ( !SO_MorSM->_is_nil() && !SO_Algorithms->_is_nil() ) {
//Find or Create Applied Algorithms root
SALOMEDS::SObject_var AHR;
if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedAlgorithms, AHR)) {
AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS"));
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" );
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR);
myStudyBuilder->Addreference (SO,SO_Algorithms);
}
}
void SMESH_Swig::UnSetHypothesis(const char* Applied_Hypothesis_Entry )
{
SALOMEDS::SObject_var SO_Applied_Hypothesis = myStudy->FindObjectID( Applied_Hypothesis_Entry );
if ( !SO_Applied_Hypothesis->_is_nil() )
myStudyBuilder->RemoveObject(SO_Applied_Hypothesis);
}
const char* SMESH_Swig::AddSubMesh(const char* SO_Mesh_Entry, const char* SM_IOR, int ST)
{
SALOMEDS::SObject_var SO_Mesh = myStudy->FindObjectID( SO_Mesh_Entry );
if ( !SO_Mesh->_is_nil() ) {
long Tag_Shape ;
Standard_CString Name;
if (ST == TopAbs_SOLID) {Tag_Shape = Tag_SubMeshOnSolid; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnSolid"));}
else if (ST == TopAbs_FACE) {Tag_Shape = Tag_SubMeshOnFace; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnFace"));}
else if (ST == TopAbs_EDGE) {Tag_Shape = Tag_SubMeshOnEdge; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnEdge"));}
else if (ST == TopAbs_VERTEX){Tag_Shape = Tag_SubMeshOnVertex; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnVertex"));}
else {
Tag_Shape = Tag_SubMeshOnCompound; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnCompound"));
}
SALOMEDS::SObject_var SubmeshesRoot;
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
SALOMEDS::AttributeIOR_var anIOR;
SALOMEDS::AttributeSelectable_var aSelAttr;
if (!SO_Mesh->FindSubObject (Tag_Shape,SubmeshesRoot )) {
SubmeshesRoot = myStudyBuilder->NewObjectToTag (SO_Mesh, Tag_Shape);
anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(Name);
anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable");
aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
aSelAttr->SetSelectable(false);
}
SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot);
anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR");
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIOR->SetValue(SM_IOR);
return SALOMEDS::SObject::_narrow( SO )->GetID();
}
return "";
}
const char* SMESH_Swig::AddSubMeshOnShape(const char* Mesh_Entry, const char* GeomShape_Entry,
const char* SM_IOR, int ST)
{
SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectID( GeomShape_Entry );
if ( !SO_GeomShape->_is_nil() ) {
const char * SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST);
SALOMEDS::SObject_var SO_SM = myStudy->FindObjectID( SM_Entry );
if ( !SO_SM->_is_nil() ) {
SetShape (GeomShape_Entry, SM_Entry);
return SALOMEDS::SObject::_narrow( SO_SM )->GetID();
}
}
return "";
}
void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry )
{
// SMESH_Actor* Mesh = smeshGUI->ReadScript(aM);
}
void SMESH_Swig::SetName(const char* Entry, const char* Name)
{
SALOMEDS::SObject_var SO = myStudy->FindObjectID( Entry );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var aName;
if ( !SO->_is_nil() ) {
anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(Name);
}
}
void SMESH_Swig::setOrb()
{
try {
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
_orb = init( 0 , 0 );
} catch (...) {
INFOS("internal error : orb not found");
_orb = 0;
}
ASSERT(! CORBA::is_nil(_orb));
}

View File

@ -0,0 +1,69 @@
// File : SMESHGUI_Swig.hxx
// Created : Mon Jun 17 13:41:12 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef _SMESHGUI_SWIG_HXX_
#define _SMESHGUI_SWIG_HXX_
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
class SMESH_Swig
{
public:
SMESH_Swig();
~SMESH_Swig();
static void setOrb();
void Init(int studyID);
const char* AddNewMesh(const char* IOR);
const char* AddNewHypothesis(const char* IOR);
const char* AddNewAlgorithms(const char* IOR);
void SetShape(const char* ShapeEntry, const char* MeshEntry);
void SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry);
void SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry);
void UnSetHypothesis(const char* Applied_Hypothesis_Entry );
const char* AddSubMesh (const char* Mesh_Entry, const char* SM_IOR, int ST);
const char* AddSubMeshOnShape (const char* Mesh_Entry, const char* GeomShape_Entry, const char* SM_IOR, int ST);
void CreateAndDisplayActor( const char* Mesh_Entry );
void SetName(const char* Entry, const char* Name);
private:
SALOMEDS::Study_var myStudy;
SALOMEDS::StudyBuilder_var myStudyBuilder;
SALOMEDS::SComponent_var mySComponentMesh;
// Tags definition
long Tag_HypothesisRoot;
long Tag_AlgorithmsRoot;
long Tag_RefOnShape;
long Tag_RefOnAppliedHypothesis;
long Tag_RefOnAppliedAlgorithms;
long Tag_SubMeshOnVertex;
long Tag_SubMeshOnEdge;
long Tag_SubMeshOnFace;
long Tag_SubMeshOnSolid;
long Tag_SubMeshOnCompound;
};
#endif

View File

@ -0,0 +1,40 @@
// File : SMESHGUI_Swig.i
// Created : Mon Jun 17 13:40:36 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
%{
#include "SMESHGUI_Swig.hxx"
%}
%include "typemaps.i"
class SMESH_Swig
{
public:
SMESH_Swig();
~SMESH_Swig();
void Init(int studyID);
const char* AddNewMesh(const char* IOR);
const char* AddNewHypothesis(const char* IOR);
const char* AddNewAlgorithms(const char* IOR);
void SetShape(const char* ShapeEntry, const char* MeshEntry);
void SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry);
void SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry);
void UnSetHypothesis(const char* Applied_Hypothesis_Entry );
const char* AddSubMesh (const char* Mesh_Entry, const char* SM_IOR, int ST);
const char* AddSubMeshOnShape (const char* Mesh_Entry, const char* GeomShape_Entry, const char* SM_IOR, int ST);
void SetName(const char* Entry, const char* Name);
};

View File

@ -0,0 +1,191 @@
using namespace std;
// File : SMESHGUI_TransparencyDlg.cxx
// Created : Thu Jun 06 16:41:42 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI.h"
#include "VTKViewer_ViewFrame.h"
#include "VTKViewer_RenderWindowInteractor.h"
#include "QAD_RightFrame.h"
#include "SALOME_ListIteratorOfListIO.hxx"
// QT Includes
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qapplication.h>
#include <qgroupbox.h>
//=================================================================================
// class : SMESHGUI_TransparencyDlg()
// purpose :
//
//=================================================================================
SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( QWidget* parent,
const char* name,
SALOME_Selection* Sel,
bool modal,
WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
if ( !name )
setName( "SMESHGUI_TransparencyDlg" );
resize( 152, 107 );
setCaption( tr( "SMESH_TRANSPARENCY_TITLE" ) );
setSizeGripEnabled( TRUE );
SMESHGUI_TransparencyDlgLayout = new QGridLayout( this );
SMESHGUI_TransparencyDlgLayout->setSpacing( 6 );
SMESHGUI_TransparencyDlgLayout->setMargin( 11 );
/*************************************************************************/
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
/*************************************************************************/
QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
TextLabelOpaque->setText( tr( "SMESH_TRANSPARENCY_OPAQUE" ) );
TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) );
GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" );
TextLabelTransparent->setText( tr( "SMESH_TRANSPARENCY_TRANSPARENT" ) );
TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) );
GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" );
Slider1->setMinimumSize( 300, 0 );
Slider1->setTickmarks( QSlider::Left );
GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 );
SMESHGUI_TransparencyDlgLayout->addWidget( GroupC1, 0, 0 );
SMESHGUI_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 );
/* Initialisations */
this->mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
this->mySel = Sel ;
/* First call valueChanged() method for initialisation */
/* The default value of transparency will change with the selection */
this->myFirstInit = true ;
// Slider1->setMaxValue( 10 );
// Slider1->setValue( 5 ) ;
this->ValueHasChanged( Slider1->value() ) ;
// signals and slots connections : after ValueHasChanged()
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( Slider1, SIGNAL( valueChanged(int) ), this, SLOT( ValueHasChanged(int) ) );
/* Move widget on the botton right corner of main widget */
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays this Dialog */
}
//=================================================================================
// function : ~SMESHGUI_TransparencyDlg()
// purpose :
//=================================================================================
SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=======================================================================
// function : ClickOnOk()
// purpose :
//=======================================================================
void SMESHGUI_TransparencyDlg::ClickOnOk()
{
accept() ;
return ;
}
//=======================================================================
// function : ClickOnClose()
// purpose :
//=======================================================================
void SMESHGUI_TransparencyDlg::ClickOnClose()
{
accept() ;
return ;
}
//=================================================================================
// function : ValueHasChanged()
// purpose : Called when value of slider change
// : or the first time as initilisation
//=================================================================================
void SMESHGUI_TransparencyDlg::ValueHasChanged( int newValue )
{
if ( mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() );
Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject();
if( !FirstIOS.IsNull() ) {
/* The first time as initialisation */
if( this->myFirstInit ) {
this->myFirstInit = false ;
float transp = ( myRenderInter->GetTransparency(FirstIOS))*10.0 ;
this->Slider1->setValue( int(transp) ) ;
return;
}
}
QApplication::setOverrideCursor( Qt::waitCursor );
for( ;It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) IOS = It.Value();
myRenderInter->SetTransparency( IOS, newValue/10.0 );
}
QApplication::restoreOverrideCursor();
}
QApplication::restoreOverrideCursor();
return ;
}

View File

@ -0,0 +1,71 @@
// File : SMESHGUI_TransparencyDlg.h
// Created : Thu Jun 06 16:41:57 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef DIALOGBOX_TRANSPARENCYDLG_H
#define DIALOGBOX_TRANSPARENCYDLG_H
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
// QT Includes
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QPushButton;
class QSlider;
class SMESHGUI;
//=================================================================================
// class : SMESHGUI_TransparencyDlg
// purpose :
//=================================================================================
class SMESHGUI_TransparencyDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_TransparencyDlg( QWidget* parent = 0,
const char* name = 0,
SALOME_Selection* Sel = 0,
bool modal = TRUE,
WFlags fl = 0 );
~SMESHGUI_TransparencyDlg();
private :
SMESHGUI* mySMESHGUI ; /* Current GeomGUI object */
bool myFirstInit ; /* Inform for the first init */
SALOME_Selection* mySel; /* User selection */
QPushButton* buttonOk;
QLabel* TextLabelOpaque;
QLabel* TextLabelTransparent;
QSlider* Slider1;
public slots:
void ClickOnOk();
void ClickOnClose();
void ValueHasChanged( int newValue ) ;
protected:
QGridLayout* SMESHGUI_TransparencyDlgLayout;
QHBoxLayout* Layout1;
QHBoxLayout* Layout2;
};
#endif // DIALOGBOX_TRANSPARENCYDLG_H

View File

@ -0,0 +1,234 @@
using namespace std;
// File : SMESHGUI_aParameterDlg.cxx
// Created : Wed Jun 12 21:06:21 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#include "SMESHGUI_aParameterDlg.h"
#include "SMESHGUI.h"
#include "QAD_SpinBoxDbl.h"
#include "QAD_Tools.h"
// QT Includes
#include <qgroupbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qspinbox.h>
#include <qvalidator.h>
//======================================================================================
// function : SMESHGUI_aParameterDlg()
// purpose : Constructs a SMESHGUI_aParametertDlg for double values
//
// parent : parent widget
// title : is the title for the user in dialog box
// label : text label for the value
//
// bottom : the minimal value to be entered
// top : the maximum value to be entered
// decimals : number of decimals to be entered
//
// The dialog will by default be modal, unless you set 'modal' to
// false when constructing dialog
//
//======================================================================================
SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
QString title,
QString label,
const double bottom,
const double top,
const int decimals,
bool modal )
: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
myIntSpin( 0 ), myDblSpin( 0 )
{
/* creating widgets */
init( true );
/* title */
setCaption( title );
/* caption */
myTextLabel->setText( label );
/* range */
myDblSpin->setRange( bottom, top );
((QDoubleValidator*)(myDblSpin->validator()))->setRange( bottom, top, decimals );
/* Move widget on the botton right corner of main widget */
QAD_Tools::centerWidget( this, parent );
}
//======================================================================================
// function : SMESHGUI_aParameterDlg()
// purpose : Constructs a SMESHGUI_aParametertDlg for int values
//
// parent : parent widget
// title : is the title for the user in dialog box
// label : text label for the value
//
// bottom : the minimal value to be entered
// top : the maximum value to be entered
//
// The dialog will by default be modal, unless you set 'modal' to
// false when constructing dialog
//
//======================================================================================
SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
QString title,
QString label,
const int bottom,
const int top,
bool modal )
: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
myIntSpin( 0 ), myDblSpin( 0 )
{
/* creating widgets */
init( false );
/* title */
setCaption( title );
/* caption */
myTextLabel->setText( label );
/* range */
myIntSpin->setRange( bottom, top );
((QIntValidator*)(myIntSpin->validator()))->setRange( bottom, top );
/* Move widget on the botton right corner of main widget */
QAD_Tools::centerWidget( this, parent );
}
//======================================================================================
// function : SMESHGUI_aParameterDlg::init()
// purpose : creates dialog's layout
//======================================================================================
void SMESHGUI_aParameterDlg::init( bool isDouble )
{
setSizeGripEnabled( TRUE );
QGridLayout* topLayout = new QGridLayout( this );
topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
/***************************************************************/
QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
/* Label */
/* aTitle1 : text prompt on left of edit line */
myTextLabel = new QLabel( GroupC1, "TextLabel" );
GroupC1Layout->addWidget( myTextLabel, 0, 0 );
/* Spin box */
if ( isDouble ) {
myIntSpin = 0;
myDblSpin = new QAD_SpinBoxDbl( GroupC1 );
myDblSpin->setPrecision( 12 );
myDblSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
myDblSpin->setMinimumSize( 150, 0 );
GroupC1Layout->addWidget( myDblSpin, 0, 1 );
}
else {
myDblSpin = 0;
myIntSpin = new QSpinBox( GroupC1 );
myIntSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
myIntSpin->setMinimumSize( 150, 0 );
GroupC1Layout->addWidget( myIntSpin, 0, 1 );
}
/***************************************************************/
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
/* Ok button */
myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
myButtonOk->setText( tr("SMESH_BUT_OK") );
myButtonOk->setAutoDefault( TRUE );
myButtonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( myButtonOk, 0, 0 );
/* add spacer between buttons */
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
/* Cancel button */
myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
myButtonCancel->setText( tr("SMESH_BUT_CANCEL") );
myButtonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( myButtonCancel, 0, 2 );
/***************************************************************/
topLayout->addWidget( GroupC1, 0, 0);
topLayout->addWidget( GroupButtons, 1, 0);
/* signals and slots connections */
connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
/* Retrieve SMESHGUI */
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
}
//======================================================================================
// function : ~SMESHGUI_aParameterDlg()
// purpose : Destructor
//======================================================================================
SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg()
{
}
//======================================================================================
// function : SMESHGUI_aParameterDlg::setValue
// purpose : sets double value
//======================================================================================
void SMESHGUI_aParameterDlg::setValue( const double val )
{
if ( myDblSpin )
myDblSpin->setValue( val );
}
//======================================================================================
// function : SMESHGUI_aParameterDlg::setValue
// purpose : sets int value
//======================================================================================
void SMESHGUI_aParameterDlg::setValue( const int val )
{
if ( myIntSpin )
myIntSpin->setValue( val );
}
//======================================================================================
// function : SMESHGUI_aParameterDlg::getDblValue
// purpose : returns double value entered by user
//======================================================================================
double SMESHGUI_aParameterDlg::getDblValue()
{
if ( myDblSpin )
return myDblSpin->value();
return 0.0;
}
//======================================================================================
// function : SMESHGUI_aParameterDlg::getIntValu
// purpose : returns int value entered by user
//======================================================================================
int SMESHGUI_aParameterDlg::getIntValue()
{
if ( myIntSpin )
return myIntSpin->value();
return 0;
}

View File

@ -0,0 +1,65 @@
// File : SMESHGUI_aParameterDlg.h
// Created : Wed Jun 12 21:04:41 2002
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE 2002
// $Header$
#ifndef SMESHGUI_aParameterDlg_H
#define SMESHGUI_aParameterDlg_H
// QT Includes
#include <qdialog.h>
class QLabel;
class QPushButton;
class QSpinBox;
class SMESHGUI;
class QAD_SpinBoxDbl;
//=================================================================================
// class : SMESHGUI_aParameterDlg
// purpose :
//=================================================================================
class SMESHGUI_aParameterDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_aParameterDlg( QWidget* parent = 0,
QString title = QString::null,
QString label = QString::null,
const double bottom = -1E6,
const double top = +1E6,
const int decimals = 3,
bool modal = TRUE );
SMESHGUI_aParameterDlg( QWidget* parent = 0,
QString title = QString::null,
QString label = QString::null,
const int bottom = 0,
const int top = 1000,
bool modal = TRUE );
~SMESHGUI_aParameterDlg();
void setValue( const double val );
void setValue( const int val );
double getDblValue();
int getIntValue();
protected:
void init( bool isDouble );
private:
SMESHGUI* mySMESHGUI ;
QPushButton* myButtonOk;
QPushButton* myButtonCancel;
QLabel* myTextLabel;
QSpinBox* myIntSpin;
QAD_SpinBoxDbl* myDblSpin;
};
#endif // SMESHGUI_aParameterDlg.h

170
src/SMESHGUI/SMESH_icons.po Normal file
View File

@ -0,0 +1,170 @@
# This is a Qt message file in .po format. Each msgid starts with
# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
# would be translated to "Pub", not "Foo::Pub".
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
"PO-Revision-Date: YYYY-MM-DD\n"
"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
#-----------------------------------------------------------
# Divers Mesh
#-----------------------------------------------------------
#ObjectBrowser Icon
msgid "ICON_OBJBROWSER_SMESH"
msgstr "mesh.png"
#Select Icon
msgid "ICON_SELECT"
msgstr "select1.png"
#Mesh Init
msgid "ICON_DLG_INIT_MESH"
msgstr "mesh_init.png"
#
msgid "ICON_DLG_ADD_SUBMESH"
msgstr "mesh_add_sub.png"
#Move Node
msgid "ICON_DLG_MOVE_NODE"
msgstr "mesh_move_node.png"
#Remove Node
msgid "ICON_DLG_REM_NODE"
msgstr "mesh_rem_node.png"
#Remove Element
msgid "ICON_DLG_REM_ELEMENT"
msgstr "mesh_rem_element.png"
#Orientation
msgid "ICON_DLG_MESH_ORIENTATION"
msgstr "mesh_orientation.png"
#
msgid "ICON_DLG_MESH_DIAGONAL"
msgstr "mesh_diagonal.png"
#Connectivity
msgid "ICON_DLG_CONNECTIVITY"
msgstr "mesh_connectivity.png"
#-----------------------------------------------------------
# Hypothesis
#-----------------------------------------------------------
#Hypo Local Length
msgid "ICON_DLG_LOCAL_LENGTH"
msgstr "mesh_hypo_length.png"
#Hypo Nb Segments
msgid "ICON_DLG_NB_SEGMENTS"
msgstr "mesh_hypo_segment.png"
#Hypo Max Area
msgid "ICON_DLG_MAX_ELEMENT_AREA"
msgstr "mesh_hypo_area.png"
#Hypo Max Volume
msgid "ICON_DLG_MAX_ELEMENT_VOLUME"
msgstr "mesh_hypo_volume.png"
#Set Algo
msgid "ICON_DLG_ADD_ALGORITHM"
msgstr "mesh_set_algo.png"
#Set Hypo
msgid "ICON_DLG_ADD_HYPOTHESIS"
msgstr "mesh_set_hypo.png"
#Edit Hypo.
msgid "ICON_DLG_EDIT_MESH"
msgstr "mesh_edit.png"
#-----------------------------------------------------------
# Elements
#-----------------------------------------------------------
#Vertex
msgid "ICON_DLG_NODE"
msgstr "mesh_vertex.png"
#Line
msgid "ICON_DLG_LINE"
msgstr "mesh_line.png"
#triangle
msgid "ICON_DLG_TRIANGLE"
msgstr "mesh_triangle.png"
#Quadrangle
msgid "ICON_DLG_QUADRANGLE"
msgstr "mesh_quad.png"
#triangle
msgid "ICON_DLG_TETRAS"
msgstr "mesh_tetra.png"
#Quadrangle
msgid "ICON_DLG_HEXAS"
msgstr "mesh_hexa.png"
#-----------------------------------------------------------
# ObjectBrother
#-----------------------------------------------------------
#mesh_tree_mesh
msgid "ICON_SMESH_TREE_MESH"
msgstr "mesh_tree_mesh.png"
#mesh_tree_algo
msgid "ICON_SMESH_TREE_ALGO"
msgstr "mesh_tree_algo.png"
#mesh_tree_algo_regular
msgid "ICON_SMESH_TREE_ALGO_Regular_1D"
msgstr "mesh_tree_algo_regular.png"
#mesh_tree_algo_hexa
msgid "ICON_SMESH_TREE_ALGO_Hexa_3D"
msgstr "mesh_tree_algo_hexa.png"
#mesh_tree_algo_mefisto
msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D"
msgstr "mesh_tree_algo_mefisto.png"
#mesh_tree_algo_quad
msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D"
msgstr "mesh_tree_algo_quad.png"
#mesh_tree_hypo
msgid "ICON_SMESH_TREE_HYPO"
msgstr "mesh_tree_hypo.png"
#mesh_tree_hypo_area
msgid "ICON_SMESH_TREE_HYPO_MaxElementArea"
msgstr "mesh_tree_hypo_area.png"
#mesh_tree_hypo_length
msgid "ICON_SMESH_TREE_HYPO_LocalLength"
msgstr "mesh_tree_hypo_length.png"
#mesh_tree_hypo_segment
msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments"
msgstr "mesh_tree_hypo_segment.png"
#mesh_tree_hypo_volume
msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume"
msgstr "mesh_tree_hypo_volume.png"
#mesh_tree_mesh_warn
msgid "ICON_SMESH_TREE_MESH_WARN"
msgstr "mesh_tree_mesh_warn.png"

View File

@ -0,0 +1,638 @@
# This is a Qt message file in .po format. Each msgid starts with
# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
# would be translated to "Pub", not "Foo::Pub".
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n"
"PO-Revision-Date: YYYY-MM-DD\n"
"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
#-------------------------------------------------------------------------
# BUTTON
#-------------------------------------------------------------------------
#Apply
msgid "SMESH_BUT_APPLY"
msgstr "&Apply"
#Close
msgid "SMESH_BUT_CLOSE"
msgstr "&Close"
#Ok
msgid "SMESH_BUT_OK"
msgstr "&Ok"
#Yes
msgid "SMESH_BUT_YES"
msgstr "&Yes"
#No
msgid "SMESH_BUT_NO"
msgstr "&No"
#Cancel
msgid "SMESH_BUT_CANCEL"
msgstr "&Cancel"
#-------------------------------------------------------------------------
# WARNING
#-------------------------------------------------------------------------
#Warning
msgid "SMESH_WRN_WARNING"
msgstr "Warning"
#: SMESHGUI.cxx:465
msgid "SMESH_REALLY_DELETE"
msgstr "Do you really want to delete object(s) ?"
#Hypothesis or Algorithm not exists
msgid "SMESH_WRN_HYPOTHESIS_NOTEXIST"
msgstr "Hypothesis or Algorithm not exists"
#Hypothesis already exists
msgid "SMESH_WRN_HYPOTHESIS_ALREADYEXIST"
msgstr "Hypothesis already exists"
#Algorithm already exists
msgid "SMESH_WRN_ALGORITHM_ALREADYEXIST"
msgstr "Algorithm already exists"
#Missing parameters
msgid "SMESH_WRN_MISSING_PARAMETERS"
msgstr "Missing parameters"
#Study frame with VTK Viewer must be activated
msgid "SMESH_WRN_VIEWER_VTK"
msgstr "Study frame with VTK Viewer must be activated"
#Activate Elements Selection Mode
msgid "SMESH_WRN_SELECTIONMODE_ELEMENTS"
msgstr "Activate Elements Selection Mode"
#Activate Nodes Selection Mode
msgid "SMESH_WRN_SELECTIONMODE_NODES"
msgstr "Activate Nodes Selection Mode"
#Activate Link Selection Mode
msgid "SMESH_WRN_SELECTIONMODE_DIAGONAL"
msgstr "Activate Link Selection Mode"
#-------------------------------------------------------------------------
# MEN
#-------------------------------------------------------------------------
#SMESH
msgid "SMESH_MEN_COMPONENT"
msgstr "SMESH"
#SubMeshes On Vertex
msgid "SMESH_MEN_SubMeshesOnVertex"
msgstr "SubMeshes On Vertex"
#SubMeshes On Edge
msgid "SMESH_MEN_SubMeshesOnEdge"
msgstr "SubMeshes On Edge"
#SubMeshes On Face
msgid "SMESH_MEN_SubMeshesOnFace"
msgstr "SubMeshes On Face"
#SubMeshes On Solid
msgid "SMESH_MEN_SubMeshesOnSolid"
msgstr "SubMeshes On Solid"
#SubMeshes On Compound
msgid "SMESH_MEN_SubMeshesOnCompound"
msgstr "SubMeshes On Compound"
#Applied Algorithm
msgid "SMESH_MEN_APPLIED_ALGORIHTMS"
msgstr "Applied Algorithm"
#Applied Hypothesis
msgid "SMESH_MEN_APPLIED_HYPOTHESIS"
msgstr "Applied Hypothesis"
#Hypothesis Definition
msgid "SMESH_MEN_HYPOTHESIS"
msgstr "Hypothesis Definition"
#Algorithms Definition
msgid "SMESH_MEN_ALGORITHMS"
msgstr "Algorithms Definition"
#-------------------------------------------------------------------------
# DIVERS
#-------------------------------------------------------------------------
#Arguments
msgid "SMESH_ARGUMENTS"
msgstr "Arguments"
#Value
msgid "SMESH_VALUE"
msgstr "Value"
#%1_objects
msgid "SMESH_OBJECTS_SELECTED"
msgstr "%1_objects"
#Name
msgid "SMESH_NAME"
msgstr "Name"
#Geometrical Object
msgid "SMESH_OBJECT_GEOM"
msgstr "Geometrical Object"
#Length
msgid "SMESH_LENGTH"
msgstr "Length"
#Coordinates
msgid "SMESH_COORDINATES"
msgstr "Coordinates"
#X
msgid "SMESH_X"
msgstr "X"
#Y
msgid "SMESH_Y"
msgstr "Y"
#Z
msgid "SMESH_Z"
msgstr "Z"
#-------------------------------------------------------------------------
# DLG
#-------------------------------------------------------------------------
# -------------- Init --------------
#Mesh
msgid "SMESH_INIT"
msgstr "Mesh"
#Mesh or SubMesh
msgid "SMESH_OBJECT_MESHorSUBMESH"
msgstr "Mesh or SubMesh"
#Mesh Construction
msgid "SMESH_INIT_MESH"
msgstr "Mesh Construction"
#SubMesh Construction
msgid "SMESH_ADD_SUBMESH"
msgstr "SubMesh Construction"
#Mesh
msgid "SMESH_OBJECT_MESH"
msgstr "Mesh"
#SubMesh
msgid "SMESH_SUBMESH"
msgstr "SubMesh"
# -------------- Hypothesis / Algorithm --------------
#Hypothesis
msgid "SMESH_ADD_HYPOTHESIS"
msgstr "Hypothesis"
#Hypothesis Construction
msgid "SMESH_ADD_HYPOTHESIS_TITLE"
msgstr "Hypothesis Assignation"
#Hypothesis
msgid "SMESH_OBJECT_HYPOTHESIS"
msgstr "Hypothesis"
#Local Length
msgid "SMESH_LOCAL_LENGTH_HYPOTHESIS"
msgstr "Local Length"
#Hypothesis Construction
msgid "SMESH_LOCAL_LENGTH_TITLE"
msgstr "Hypothesis Construction"
#Algorithms
msgid "SMESH_ADD_ALGORITHM"
msgstr "Algorithms"
#Algorithms Construction
msgid "SMESH_ADD_ALGORITHM_TITLE"
msgstr "Algorithms Assignation"
#Algorithm
msgid "SMESH_OBJECT_ALGORITHM"
msgstr "Algorithm"
#Number of Segments
msgid "SMESH_NB_SEGMENTS_HYPOTHESIS"
msgstr "Number of Segments"
#Hypothesis Construction
msgid "SMESH_NB_SEGMENTS_TITLE"
msgstr "Hypothesis Construction"
#Max. Area
msgid "SMESH_MAX_ELEMENT_AREA"
msgstr "Max. Area"
#Max. Element Area
msgid "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"
msgstr "Max. Element Area"
#Hypothesis Construction
msgid "SMESH_MAX_ELEMENT_AREA_TITLE"
msgstr "Hypothesis Construction"
#Max. Volume
msgid "SMESH_MAX_ELEMENT_VOLUME"
msgstr "Max. Volume"
#Max. Element Volume
msgid "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"
msgstr "Max. Element Volume"
#Hypothesis Construction
msgid "SMESH_MAX_ELEMENT_VOLUME_TITLE"
msgstr "Hypothesis Construction"
# -------------- Nodes / Segments / Elements --------------
#Node
msgid "MESH_NODE"
msgstr "Node"
#Node Construction
msgid "MESH_NODE_TITLE"
msgstr "Node Construction"
#Segments
msgid "SMESH_SEGMENTS"
msgstr "Segments"
#Elements
msgid "SMESH_ELEMENTS"
msgstr "Elements"
#Id Elements
msgid "SMESH_ID_ELEMENTS"
msgstr "Id Elements"
#Remove
msgid "SMESH_REMOVE"
msgstr "Remove"
#Remove Elements
msgid "SMESH_REMOVE_ELEMENTS_TITLE"
msgstr "Remove Elements"
#Id Nodes
msgid "SMESH_ID_NODES"
msgstr "Id Nodes"
#Nodes
msgid "SMESH_NODES"
msgstr "Nodes"
#Remove Nodes
msgid "SMESH_REMOVE_NODES_TITLE"
msgstr "Remove Nodes"
#Move
msgid "SMESH_MOVE"
msgstr "Move"
#Move Node
msgid "SMESH_MOVE_NODES_TITLE"
msgstr "Move Node"
#Add Triangle
msgid "SMESH_ADD_TRIANGLE_TITLE"
msgstr "Add Triangle"
#Add Quadrangle
msgid "SMESH_ADD_QUADRANGLE_TITLE"
msgstr "Add Quadrangle"
#Add Edge
msgid "SMESH_ADD_EDGE_TITLE"
msgstr "Add Edge"
#Add Tetrahedron
msgid "SMESH_ADD_TETRAS_TITLE"
msgstr "Add Tetrahedron"
#Add Hexahedron
msgid "SMESH_ADD_HEXAS_TITLE"
msgstr "Add Hexahedron"
#Reverse
msgid "SMESH_REVERSE"
msgstr "Reverse"
#Triangle
msgid "SMESH_TRIANGLE"
msgstr "Triangle"
#Quadrangle
msgid "SMESH_QUADRANGLE"
msgstr "Quadrangle"
#Edge
msgid "SMESH_EDGE"
msgstr "Edge"
#Tetrahedron
msgid "SMESH_TETRAS"
msgstr "Tetrahedron"
#Hexahedron
msgid "SMESH_HEXAS"
msgstr "Hexahedron"
#Add Triangle
msgid "SMESH_ADD_TRIANGLE"
msgstr "Add Triangle"
#Add Quadrangle
msgid "SMESH_ADD_QUADRANGLE"
msgstr "Add Quadrangle"
#Add Edge
msgid "SMESH_ADD_EDGE"
msgstr "Add Edge"
#Add Tetrahedron
msgid "SMESH_ADD_TETRAS"
msgstr "Add Tetrahedron"
#Add Hexahedron
msgid "SMESH_ADD_HEXAS"
msgstr "Add Hexahedron"
# -------------- Transparency --------------
#Opacity
msgid "SMESH_TRANSPARENCY_OPAQUE"
msgstr "Opacity"
#Transparency
msgid "SMESH_TRANSPARENCY_TITLE"
msgstr "Transparency"
#Fully Transparency
msgid "SMESH_TRANSPARENCY_TRANSPARENT"
msgstr "Fully Transparency"
# -------------- Preferences -----------
#Arial
msgid "SMESH_FONT_ARIAL"
msgstr "Arial"
#Bold
msgid "SMESH_FONT_BOLD"
msgstr "Bold"
#Courier
msgid "SMESH_FONT_COURIER"
msgstr "Courier"
#Dimensions
msgid "SMESH_DIMENSIONS"
msgstr "Dimensions"
#Font
msgid "SMESH_FONT"
msgstr "Font"
#Height
msgid "SMESH_HEIGHT"
msgstr "Height"
#Horizontal
msgid "SMESH_HORIZONTAL"
msgstr "Horizontal"
#Italic
msgid "SMESH_FONT_ITALIC"
msgstr "Italic"
#Scalar Bar Preferences
msgid "SMESH_PREFERENCES_SCALARBAR"
msgstr "Scalar Bar Preferences"
#Number Of Colors
msgid "SMESH_NUMBEROFCOLORS"
msgstr "Number Of Colors"
#Number Of Labels
msgid "SMESH_NUMBEROFLABELS"
msgstr "Number Of Labels"
#Orientation
msgid "SMESH_ORIENTATION"
msgstr "Orientation"
#Properties
msgid "SMESH_PROPERTIES"
msgstr "Properties"
#Shadow
msgid "SMESH_FONT_SHADOW"
msgstr "Shadow"
#Times
msgid "SMESH_FONT_TIMES"
msgstr "Times"
#Vertical
msgid "SMESH_VERTICAL"
msgstr "Vertical"
#Width
msgid "SMESH_WIDTH"
msgstr "Width"
# -------------- ScalarBar --------------
#Max
msgid "SMESH_MAX"
msgstr "Max"
#Min
msgid "SMESH_MIN"
msgstr "Min"
#ScalarBar
msgid "SMESH_SCALARBAR"
msgstr "ScalarBar"
#Update View
msgid "SMESH_UPDATEVIEW"
msgstr "Update View"
# -------------- Connectivity --------------
#Boundary Edges
msgid "SMESH_BOUNDARYEDGES"
msgstr "Boundary Edges"
#Feature Edges
msgid "SMESH_FEATUREEDGES"
msgstr "Feature Edges"
#Manifold Edges
msgid "SMESH_MANIFOLDEDGES"
msgstr "Manifold Edges"
#Non Manifold Edges
msgid "SMESH_NONMANIFOLDEDGES"
msgstr "Non Manifold Edges"
#Edges Connectivity
msgid "SMESH_EDGES_CONNECTIVITY"
msgstr "Edges Connectivity"
#Edges Connectivity
msgid "SMESH_EDGES_CONNECTIVITY_TITLE"
msgstr "Edges Connectivity"
#Mesh
msgid "SMESH_MESH"
msgstr "Mesh"
#Feature Angle
msgid "SMESH_FEATUREANGLE"
msgstr "Feature Angle"
# -------------- Operations --------------
#Change Orientation
msgid "SMESH_ORIENTATION_ELEMENTS_TITLE"
msgstr "Change Orientation"
#Id Diagonal
msgid "SMESH_ID_DIAGONAL"
msgstr "Id Edges"
#Diagonal Inversion
msgid "SMESH_DIAGONAL"
msgstr "Diagonal Inversion"
#Diagonal Inversion
msgid "SMESH_DIAGONAL_INVERSION_TITLE"
msgstr "Diagonal Inversion"
# -------------- Mesh Infos --------------
#Mesh Infos
msgid "SMESH_MESHINFO_TITLE"
msgstr "Mesh Infos"
#Number Of 1D Elements
msgid "SMESH_MESHINFO_NB1D"
msgstr "Number Of 1D Elements"
#Number Of 2D Elements
msgid "SMESH_MESHINFO_NB2D"
msgstr "Number Of 2D Elements"
#Number Of 3D Elements
msgid "SMESH_MESHINFO_NB3D"
msgstr "Number Of 3D Elements"
#Edges :
msgid "SMESH_MESHINFO_EDGES"
msgstr "Edges :"
#Nodes :
msgid "SMESH_MESHINFO_NODES"
msgstr "Nodes :"
#Triangles :
msgid "SMESH_MESHINFO_TRIANGLES"
msgstr "Triangles :"
#Quadrangles :
msgid "SMESH_MESHINFO_QUADRANGLES"
msgstr "Quadrangles :"
#Tetrahedrons :
msgid "SMESH_MESHINFO_TETRAS"
msgstr "Tetrahedrons :"
#Hexahedrons :
msgid "SMESH_MESHINFO_HEXAS"
msgstr "Hexahedrons :"
# -------------- Controls --------------
#Length
msgid "SMESH_CONTROL_LENGTH_EDGES"
msgstr "Length"
#Area
msgid "SMESH_CONTROL_AREA_ELEMENTS"
msgstr "Area"
#Taper
msgid "SMESH_CONTROL_TAPER_ELEMENTS"
msgstr "Taper"
#Aspect Ratio
msgid "SMESH_CONTROL_ASPECTRATIO_ELEMENTS"
msgstr "Aspect Ratio"
#Minimum Angle
msgid "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS"
msgstr "Minimum Angle"
#Warp
msgid "SMESH_CONTROL_WARP_ELEMENTS"
msgstr "Warp"
#Skew
msgid "SMESH_CONTROL_SKEW_ELEMENTS"
msgstr "Skew"
# -------------- Edit --------------
#Hypotheses Assignation
msgid "SMESH_EDIT_HYPOTHESES"
msgstr "Hypotheses Assignation"
#Hypotheses
msgid "SMESH_HYPOTHESES"
msgstr "Hypotheses"
#Available
msgid "SMESH_AVAILABLE"
msgstr "Available"
#Used
msgid "SMESH_EDIT_USED"
msgstr "Used"

View File

@ -0,0 +1,43 @@
# File : Makefile.in
# Created : Tue Mar 26 15:04:48 2002
# Author : Nicolas REJNERI, Paul RASCLE
# Project : SALOME
# Module : GEOM
# Copyright : Open CASCADE, EDF 2002
# $Header$
# source path
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libSMESH_Swigcmodule.la
LIB_SRC =
SWIG_DEF = libSMESH_Swig.i
EXPORT_PYSCRIPTS = libSMESH_Swig.py \
SMESH_test0.py SMESH_test1.py SMESH_test2.py SMESH_test3.py SMESH_mechanic.py SMESH_fixation.py batchmode_smesh.py
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_Exception.idl \
GEOM_Gen.idl \
GEOM_Shape.idl \
SMESH_Gen.idl \
SMESH_Mesh.idl \
SMESH_Hypothesis.idl \
SMESH_BasicHypothesis.idl \
SALOME_ModuleCatalog.idl \
SALOME_Component.idl \
MED.idl
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H
LIBS+= $(PYTHON_LIBS)
LDFLAGS+= -lSMESHGUI
@CONCLUDE@

View File

@ -0,0 +1,464 @@
#==============================================================================
# File : SMESH_fix_volute.py
# Created : mer sep 4 09:58:49 CEST 2002
# Author : Paul RASCLE, EDF
# Project : SALOME
# Copyright : EDF 2002
# $Header$
#==============================================================================
#
# les numeros d'edge dans les explode sont parfois decales de 1 entre
# le script et le gui
# piece1 --> piece : memes numeros
# ellipse : il faut decrementer de 1 dans le script
#
import salome
from salome import sg
import geompy
##import SMESH
##import smeshpy
##import SMESH_BasicHypothesis_idl
import math
# -----------------------------------------------------------------------------
def MakeFace(lstEdges) :
"""
Creates a face from 4 edges
"""
lstWire = []
for edge in lstEdges :
lstWire.append(edge._get_Name())
wire = geompy.MakeWire(lstWire)
face = geompy.MakeFace(wire, 1)
return face
def MakeShell(lstFaces) :
"""
Creates a shell from 6 faces
"""
lstShell = []
for face in lstFaces :
lstShell.append(face._get_Name())
shell = geompy.MakeSewing(lstShell, 0.00001)
return shell
def MakeCompound(lstShells) :
"""
Creates a compound from several shells
"""
lstCompound = []
for shell in lstShells :
lstCompound.append(shell._get_Name())
compound = geompy.MakeCompound(lstCompound)
return compound
# -----------------------------------------------------------------------------
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
myBuilder = salome.myStudy.NewBuilder()
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
# ---- dimensions
##longueurPlq = 0.686
##largeurPlq = 0.573
##epaisseurPlq = 0.150
##hauteurFlanc = 0.380
##epaisseurFlanc = 0.112
##rayonConge = 0.150 - epaisseurFlanc
##epaisseurFond = 0.162
##rayonTrou = 0.075
##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou)
##marge = 0.01
##tol3d = 1.e-5
longueurPlq = 686
largeurPlq = 573
epaisseurPlq = 150
hauteurFlanc = 380
epaisseurFlanc = 112
rayonConge = 150 - epaisseurFlanc
epaisseurFond = 162
rayonTrou = 75
posAxeTrou = hauteurFlanc -(180 + rayonTrou)
marge = 10
tol3d = 1.e-3
# ---- points, directions de base
p0 = geom.MakePointStruct(0., 0., 0.)
px = geom.MakePointStruct(100., 0., 0.)
vx = geom.MakeDirection(px)
py = geom.MakePointStruct(0., 100., 0.)
vy = geom.MakeDirection(py)
pz = geom.MakePointStruct(0., 0., 100.)
vz = geom.MakeDirection(pz)
# ---- volumes de controle
volglob = geom.MakeBox( 0., 0., 0.,
longueurPlq,
largeurPlq,
hauteurFlanc + epaisseurPlq +marge)
idvolglob = geompy.addToStudy(volglob, "volglob")
volhaut = geom.MakeBox(-marge,
0.5*(largeurPlq - epaisseurFond),
hauteurFlanc + epaisseurPlq,
longueurPlq+marge,
largeurPlq+marge,
hauteurFlanc + epaisseurPlq +2*marge)
idvolhaut = geompy.addToStudy(volhaut, "volhaut")
# ---- base
#plaque = geom.MakeBox( 0., 0., 0., longueurPlq, largeurPlq, epaisseurPlq )
plaque = geom.MakeBox( -marge, -marge/2, 0.,
longueurPlq +2*marge, largeurPlq, epaisseurPlq )
# ---- fond
fond = geom.MakeBox( rayonConge,
largeurPlq - epaisseurFond,
epaisseurPlq,
longueurPlq - rayonConge,
largeurPlq,
epaisseurPlq + hauteurFlanc +marge/2)
# ---- trou du fond
pAxe1 = geom.MakePointStruct( 0.5*longueurPlq,
0.,
epaisseurPlq + posAxeTrou)
cylFond = geom.MakeCylinder(pAxe1, vy, rayonTrou, 1.1*largeurPlq)
fondTroue = geom.MakeBoolean(fond, cylFond, 2)
piece = geom.MakeBoolean(plaque, fondTroue, 3)
idPiece = geompy.addToStudy(piece, "piece")
# ---- cotes
cote1 = geom.MakeBox(rayonConge,
-marge/2,
epaisseurPlq,
epaisseurFlanc + rayonConge,
largeurPlq - epaisseurFond,
hauteurFlanc + epaisseurPlq +marge/2)
piece = geom.MakeBoolean(piece, cote1, 3)
cote2 = geom.MakeBox(longueurPlq -epaisseurFlanc -rayonConge,
-marge/2,
epaisseurPlq,
longueurPlq -rayonConge,
largeurPlq - epaisseurFond,
hauteurFlanc + epaisseurPlq +marge/2)
piece = geom.MakeBoolean(piece, cote2, 3)
idPiece = geompy.addToStudy(piece, "piece1")
# ---- ellipse du flanc
he = hauteurFlanc -2*rayonConge
re = 0.5*(largeurPlq - epaisseurFond) - rayonConge
sine = re/he
cose = math.sqrt(1.-sine*sine)
pe = geom.MakePointStruct(sine, 0., cose)
ve = geom.MakeDirection(pe)
cyl0 = geom.MakeCylinder(p0, ve, re, 2*he)
axecy = geom.MakeAxisStruct(0., 0., 0.,sine, 0., cose)
cyl1 = geom.MakeRotation(cyl0, axecy, 0.5)
cyle = geom.MakeTranslation(cyl1,
-marge*sine, 0., -marge*cose)
boxe = geom.MakeBox(0., 0., 0., 3*he, -2*re, 3*he)
#idcyle = geompy.addToStudy(cyle, "cyle")
#idboxe = geompy.addToStudy(boxe, "boxe")
cylcoup = geom.MakeBoolean(cyle, boxe, 2)
idcylcoup = geompy.addToStudy(cylcoup, "cylcoup")
aretes = []
aretes = geompy.SubShapeAll(cylcoup, ShapeTypeEdge)
# OCC3.1 : aretes[3], OCC4.0 aretes[5]
shape = geom.MakeCopy(aretes[5])
aShape = geom.MakeTranslation(shape,
0., rayonConge +re, epaisseurPlq +2*rayonConge)
# ---- segments face objet decoupe des flancs
pf1 = geom.MakePointStruct(0.,
-marge,
hauteurFlanc + epaisseurPlq +marge)
pf2 = geom.MakePointStruct(0.,
0.5*(largeurPlq - epaisseurFond),
hauteurFlanc + epaisseurPlq +marge)
pf3 = geom.MakePointStruct(0.,
0.5*(largeurPlq - epaisseurFond),
hauteurFlanc + epaisseurPlq)
pf4 = geom.MakePointStruct(0.,
rayonConge,
epaisseurPlq +2*rayonConge)
pf5 = geom.MakePointStruct(0.,
rayonConge,
epaisseurPlq)
pf6 = geom.MakePointStruct(0.,
-marge,
epaisseurPlq)
vf1 = geom.MakeEdge(pf1,pf2)
vf2 = geom.MakeEdge(pf2,pf3)
vf4 = geom.MakeEdge(pf4,pf5)
vf5 = geom.MakeEdge(pf5,pf6)
vf6 = geom.MakeEdge(pf6,pf1)
id1 = geompy.addToStudy(vf1,"vf1")
id2 = geompy.addToStudy(vf2,"vf2")
ids = geompy.addToStudy(aShape,"aShape")
id4 = geompy.addToStudy(vf4,"vf4")
id5 = geompy.addToStudy(vf5,"vf5")
id6 = geompy.addToStudy(vf6,"vf6")
faceDec = MakeFace([vf1,vf2,aShape,vf4,vf5,vf6])
idf = geompy.addToStudy(faceDec,"faceDec")
# forme de decoupe par extrusion
pfe = geom.MakePointStruct(longueurPlq+4*marge, 0., 0.)
decoupe = geom.MakePrism(faceDec, p0, pfe)
decoupe = geom.MakeTranslation(decoupe, -2*marge, 0., 0.)
idec = geompy.addToStudy(decoupe, "decoupe")
# decoupe piece1 par decoupe
piece2 = geom.MakeBoolean(piece, decoupe, 2)
idpiece = geompy.addToStudy(piece2, "piece2")
# conges
conges = []
conges = geompy.SubShapeAllSorted(piece2, ShapeTypeEdge)
# boucle pour trouver les bons indices
#ind = 0
#for ff in conges:
# print ind, ff._get_Index()
# name = "edge%d"%(ind)
# geompy.addToStudy(ff, name)
# ind = ind + 1
index1 = conges[7]._get_Index()
index2 = conges[11]._get_Index()
index3 = conges[36]._get_Index()
index4 = conges[43]._get_Index()
#piece3 = geompy.MakeFillet (piece2, rayonConge, ShapeTypeEdge, [3,4,8,9])
piece3 = geompy.MakeFillet (piece2, rayonConge, ShapeTypeEdge, [index1[0],index2[0],index3[0],index4[0]])
idPiece = geompy.addToStudy(piece3, "piece3")
# partie incluse dans le volume de controle (devient non valide)
piece4 = geom.MakeBoolean(piece3, volglob, 1)
idPiece = geompy.addToStudy(piece4, "piece4")
# enlever volume haut
piece = geom.MakeBoolean(piece4, volhaut, 2)
idpiece = geompy.addToStudy(piece, "piece")
# -----------------------------------------------------------------------------
# ---- decoupage de la piece en volumes a 6 faces de 4 cotes
# -----------------------------------------------------------------------------
# ---- cotes x
x0 = 0.
x0h = rayonConge
x1 = rayonConge + epaisseurFlanc
xc = longueurPlq/2
x2 = longueurPlq - rayonConge - epaisseurFlanc
x3h = longueurPlq - rayonConge
x3 = longueurPlq
# ---- cotes y
y0 = 0.
y0h = rayonConge
y1 = largeurPlq - epaisseurFond
y1m = y1 -marge
y2 = largeurPlq
y2p = largeurPlq + marge
# ---- cotes z
z0 = 0.
z1m = epaisseurPlq -marge
z1 = epaisseurPlq
z2 = epaisseurPlq + rayonConge
z3 = epaisseurPlq + 2*rayonConge
z4 = epaisseurPlq + hauteurFlanc
z4p = epaisseurPlq + hauteurFlanc + marge
zc = epaisseurPlq + posAxeTrou
zc2 = epaisseurPlq + (posAxeTrou -rayonTrou)/3
zc3 = epaisseurPlq + 2*(posAxeTrou -rayonTrou)/3
# ---- decoupe du fond
p11 = geom.MakePointStruct(x1, y1m, z1)
p12 = geom.MakePointStruct(x1, y1m, z2)
p13 = geom.MakePointStruct(x1, y1m, z3)
p14 = geom.MakePointStruct(x1, y1m, z4)
pc1 = geom.MakePointStruct(xc, y1m, z1)
pc2 = geom.MakePointStruct(xc, y1m, zc2)
pc3 = geom.MakePointStruct(xc, y1m, zc3)
pcc = geom.MakePointStruct(xc, y1m, zc)
pc4 = geom.MakePointStruct(xc, y1m, z4)
p21 = geom.MakePointStruct(x2, y1m, z1)
p22 = geom.MakePointStruct(x2, y1m, z2)
p23 = geom.MakePointStruct(x2, y1m, z3)
p24 = geom.MakePointStruct(x2, y1m, z4)
pcf = geom.MakePointStruct(xc, y2p, zc)
arc2 = geom.MakeArc(p12,pc2,p22)
arc3 = geom.MakeArc(p13,pc3,p23)
segz1 = geom.MakeVector(p11,p21)
#segz4 = geom.MakeVector(p14,p24)
segz41 = geom.MakeVector(p14,pc4)
segz42 = geom.MakeVector(pc4,p24)
segx11 = geom.MakeVector(p11,p12)
segx12 = geom.MakeVector(p12,p13)
segx13 = geom.MakeVector(p13,p14)
segxc2 = geom.MakeVector(pc1,pc2)
segxc3 = geom.MakeVector(pc2,pc3)
segxc4 = geom.MakeVector(pcc,pc4)
segx21 = geom.MakeVector(p21,p22)
segx22 = geom.MakeVector(p22,p23)
segx23 = geom.MakeVector(p23,p24)
segx1c1 = geom.MakeVector(p13,pcc)
segx1c2 = geom.MakeVector(p14,pcc)
segx2c1 = geom.MakeVector(p23,pcc)
segx2c2 = geom.MakeVector(p24,pcc)
facef = []
facef.append(MakeFace([segx13,segx1c2,segx1c1]))
facef.append(MakeFace([segx23,segx2c2,segx2c1]))
facef.append(MakeFace([segx2c2,segxc4,segz42]))
facef.append(MakeFace([segx1c2,segz41,segxc4]))
facef.append(MakeFace([segx1c1,arc3,segx2c1]))
facef.append(MakeFace([segx12,arc2,segx22,arc3]))
facef.append(MakeFace([segx11,segz1,segx21,arc2]))
decf =[]
for face in facef:
decf.append(geom.MakePrism(face,pcc,pcf))
axeCyl = geom.MakeAxisStruct( 0.5*longueurPlq,
0.,
epaisseurPlq + posAxeTrou,
0.,
largeurPlq,
0.)
cylFond2 = geom.MakeRotation(geom.MakeCopy(cylFond),axeCyl,math.pi)
idcylfond2 = geompy.addToStudy(cylFond2,"cylFond2")
fondec =[]
for id in (0,1,2,3):
fondec.append(geom.MakeBoolean(decf[id],cylFond2,2))
fondec.append(geom.MakeBoolean(decf[4],cylFond,2))
for id in (5,6):
fondec.append(decf[id])
iff=0
for ff in fondec:
idfo = geompy.addToStudy(ff, "ff%d"%(iff))
iff = iff +1
# ----- autres blocs de decoupe
bcong1=geom.MakeBox(x0,y0,z1, x1,y1,z2)
bcong2=geom.MakeBox(x0,y1,z1, x1,y2,z2)
bcong3=geom.MakeBox(x2,y0,z1, x3,y1,z2)
bcong4=geom.MakeBox(x2,y1,z1, x3,y2,z2)
pcylx0 = geom.MakePointStruct(0., -marge, z2)
cylcongx0 = geom.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq +2*marge)
idcylcongx0 = geompy.addToStudy(cylcongx0,"cylcongx0")
pcylx3 = geom.MakePointStruct(longueurPlq, -marge, z2)
cylcongx3 = geom.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq +2*marge)
idcylcongx3 = geompy.addToStudy(cylcongx3,"cylcongx3")
pcyly0 = geom.MakePointStruct(-marge, 0., z2)
cylcongy0 = geom.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq +2*marge)
idcylcongy0 = geompy.addToStudy(cylcongy0,"cylcongy0")
bcong1=geom.MakeBoolean(bcong1,cylcongx0,2)
bcong2=geom.MakeBoolean(bcong2,cylcongx0,2)
bcong1=geom.MakeBoolean(bcong1,cylcongy0,2)
bcong3=geom.MakeBoolean(bcong3,cylcongx3,2)
bcong4=geom.MakeBoolean(bcong4,cylcongx3,2)
bcong3=geom.MakeBoolean(bcong3,cylcongy0,2)
pf1 = geom.MakePointStruct(0., y0h, z3)
pf2 = geom.MakePointStruct(0., y1, z3)
pf3 = geom.MakePointStruct(0., y1, z4)
pf4 = geom.MakePointStruct(0.,0.5*(largeurPlq - epaisseurFond) , z4)
vf1 = geom.MakeEdge(pf1,pf2)
vf2 = geom.MakeEdge(pf2,pf3)
vf3 = geom.MakeEdge(pf3,pf4)
faceFlanc = MakeFace([vf1,vf2,vf3,aShape])
idfaceFlanc = geompy.addToStudy(faceFlanc,"faceFlanc")
pfe = geom.MakePointStruct(epaisseurFlanc, 0., 0.)
flanc1 = geom.MakePrism(faceFlanc, p0, pfe)
flanc2 = geom.MakeCopy(flanc1)
flanc1 = geom.MakeTranslation(flanc1,
rayonConge,0.,0.)
flanc2 = geom.MakeTranslation(flanc2,
longueurPlq-rayonConge-epaisseurFlanc,0.,0.)
# ---- constitution et decoupe des blocs
boxfond2 = geom.MakeBox(x0, y1, z0, x3, y2, z4p)
idboxfond2 = geompy.addToStudy(boxfond2,"boxfond2")
blocs = []
for dec in fondec:
blocs.append(geom.MakeBoolean(boxfond2, dec, 1))
blocs.append(geom.MakeBox(x0,y1,z0, x1,y2,z1))
blocs.append(geom.MakeBox(x1,y1,z0, x2,y2,z1))
blocs.append(geom.MakeBox(x2,y1,z0, x3,y2,z1))
blocs.append(geom.MakeBox(x0,y0,z0, x1,y1,z1))
blocs.append(geom.MakeBox(x1,y0,z0, x2,y1,z1))
blocs.append(geom.MakeBox(x2,y0,z0, x3,y1,z1))
blocs.append(bcong2)
blocs.append(bcong4)
blocs.append(bcong1)
blocs.append(bcong3)
blocs.append(geom.MakeBox(x0h,y1, z2, x1, y2, z3))
blocs.append(geom.MakeBox(x2, y1, z2, x3h,y2, z3))
blocs.append(geom.MakeBox(x0h,y0h,z2, x1, y1, z3))
blocs.append(geom.MakeBox(x2, y0h,z2, x3h,y1, z3))
blocs.append(geom.MakeBox(x0h,y1, z3, x1, y2, z4))
blocs.append(geom.MakeBox(x2, y1, z3, x3h,y2, z4))
blocs.append(flanc1)
blocs.append(flanc2)
compbloc = MakeCompound(blocs)
idcomp = geompy.addToStudy(compbloc,"compbloc")
# ---- eliminer les faces en double, solid-->shell
compshell = geom.MakeGlueFaces(compbloc,tol3d)
idcomp = geompy.addToStudy(compshell,"compshell")

View File

@ -0,0 +1,308 @@
#==============================================================================
# File : SMESH_withHole.py
# Created : 26 august 2002
# Author : Lucien PIGNOLONI
# Project : SALOME
# Copyright : Open CASCADE, 2002
# $Header$
#==============================================================================
import SMESH
import smeshpy
import salome
from salome import sg
import math
#import SMESH_BasicHypothesis_idl
import geompy
# ---------------------------- GEOM --------------------------------------
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
myBuilder = salome.myStudy.NewBuilder()
#from geompy import gg
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId);
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
# ---- define contigous arcs and segment to define a closed wire
p1 = geom.MakePointStruct( 100.0, 0.0, 0.0 )
p2 = geom.MakePointStruct( 50.0, 50.0, 0.0 )
p3 = geom.MakePointStruct( 100.0, 100.0, 0.0 )
arc1 = geom.MakeArc( p1, p2, p3 )
p4 = geom.MakePointStruct( 170.0, 100.0, 0.0 )
seg1 = geom.MakeVector( p3, p4 )
p5 = geom.MakePointStruct( 200.0, 70.0, 0.0 )
p6 = geom.MakePointStruct( 170.0, 40.0, 0.0 )
arc2 = geom.MakeArc( p4, p5, p6 )
p7 = geom.MakePointStruct( 120.0, 30.0, 0.0 )
arc3 = geom.MakeArc( p6, p7, p1 )
# ---- define a closed wire with arcs and segment
List1 = []
List1.append( arc1 )
List1.append( seg1 )
List1.append( arc2 )
List1.append( arc3 )
ListIOR1 = []
for S in List1 :
ListIOR1.append( S._get_Name() )
wire1 = geom.MakeWire( ListIOR1 )
Id_wire1 = geompy.addToStudy( wire1, "wire1")
# ---- define a planar face with wire
WantPlanarFace = 1 #True
face1 = geom.MakeFace( wire1, WantPlanarFace )
Id_face1 = geompy.addToStudy( face1, "face1")
# ---- create a shape by extrusion
pO = geom.MakePointStruct( 0.0, 0.0, 0.0 )
pz = geom.MakePointStruct( 0.0, 0.0, 100.0 )
prism1 = geom.MakePrism( face1, pO, pz )
Id_prism1 = geompy.addToStudy( prism1, "prism1")
# ---- create two cylinders
pc1 = geom.MakePointStruct( 90.0, 50.0, -40.0 )
pc2 = geom.MakePointStruct( 170.0, 70.0, -40.0 )
vz = geom.MakeDirection( pz )
radius = 20.0
height = 180.0
cyl1 = geom.MakeCylinder( pc1, vz, radius, height )
cyl2 = geom.MakeCylinder( pc2, vz, radius, height )
Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" )
Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" )
# ---- cut with cyl1
shape = geom.MakeBoolean( prism1, cyl1, 2 )
# ---- fuse with cyl2
shape1 = geom.MakeBoolean( shape, cyl2, 3 )
Id_shape1 = geompy.addToStudy( shape1, "shape1")
# ---- add a face sub shape in study to be meshed different
IdSubFaceList = []
IdSubFaceList.append(10)
sub_face = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceList )
name = geompy.SubShapeName( sub_face._get_Name(), shape1._get_Name() )
Id_SubFace = geompy.addToStudyInFather( shape1, sub_face, name )
# ---- add a face sub shape in study to be meshed different
IdSubFaceL = []
IdSubFaceL.append(7)
sub_face2 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL )
name = geompy.SubShapeName( sub_face2._get_Name(), shape1._get_Name() )
Id_SubFace2 = geompy.addToStudyInFather( shape1, sub_face2, name )
# ---------------------------- SMESH --------------------------------------
# ---- launch SMESH, init a Mesh with shape 'shape1'
gen = smeshpy.smeshpy()
mesh = gen.Init( Id_shape1 )
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
smeshgui.SetName( idmesh, "Mesh_meca" );
smeshgui.SetShape( Id_shape1, idmesh );
# ------------------------------ Length Hypothesis
print "-------------------------- create Hypothesis"
print "-------------------------- LocalLength"
hyp1 = gen.CreateHypothesis( "LocalLength" )
hypLen1 = hyp1._narrow( SMESH.SMESH_LocalLength )
hypLen1.SetLength( 100.0 )
print hypLen1.GetName()
print hypLen1.GetId()
print hypLen1.GetLength()
idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) );
smeshgui.SetName(idlength, "Local_Length_100");
print "-------------------------- NumberOfSegments"
hyp2 = gen.CreateHypothesis( "NumberOfSegments" )
hypNbSeg1 = hyp2._narrow( SMESH.SMESH_NumberOfSegments )
hypNbSeg1.SetNumberOfSegments( 10 )
print hypNbSeg1.GetName()
print hypNbSeg1.GetId()
print hypNbSeg1.GetNumberOfSegments()
idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) );
smeshgui.SetName(idseg, "NumberOfSegments_12");
print "-------------------------- MaxElementArea"
hyp3 = gen.CreateHypothesis( "MaxElementArea" )
hypArea1 = hyp3._narrow( SMESH.SMESH_MaxElementArea )
hypArea1.SetMaxElementArea( 25 )
print hypArea1.GetName()
print hypArea1.GetId()
print hypArea1.GetMaxElementArea()
idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) );
smeshgui.SetName(idarea1, "MaxElementArea_20");
print "-------------------------- MaxElementArea"
hyp4 = gen.CreateHypothesis( "MaxElementArea" )
hypArea2 = hyp4._narrow( SMESH.SMESH_MaxElementArea )
hypArea2.SetMaxElementArea( 35 )
print hypArea2. GetName()
print hypArea2.GetId()
print hypArea2.GetMaxElementArea()
idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) );
smeshgui.SetName(idarea2, "MaxElementArea_30");
print "-------------------------- Regular_1D"
alg1 = gen.CreateHypothesis( "Regular_1D" )
algo1 = alg1._narrow( SMESH.SMESH_Algo )
listHyp =algo1.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
algoReg1d = alg1._narrow( SMESH.SMESH_Regular_1D )
print algoReg1d.GetName()
print algoReg1d.GetId()
idreg1d = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg1d) );
smeshgui.SetName( idreg1d, "Regular_1D" );
print "-------------------------- MEFISTO_2D"
alg2 = gen.CreateHypothesis( "MEFISTO_2D" )
algo2 = alg2._narrow( SMESH.SMESH_Algo )
listHyp = algo2.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
algoMef = alg2._narrow( SMESH.SMESH_MEFISTO_2D )
print algoMef.GetName()
print algoMef.GetId()
idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) );
smeshgui.SetName( idmef, "MEFISTO_2D" );
print "-------------------------- SMESH_Quadrangle_2D"
alg3 = gen.CreateHypothesis( "Quadrangle_2D" )
algo3 = alg3._narrow( SMESH.SMESH_2D_Algo )
listHyp = algo3.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
algoQad2 = alg3._narrow( SMESH.SMESH_Quadrangle_2D )
print algoQad2.GetName()
print algoQad2.GetId()
idqad2 = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoQad2) );
smeshgui.SetName( idqad2, "SMESH_Quadrangle_2D" );
print "-------------------------- add hypothesis to main shape1"
shape_mesh = salome.IDToObject( Id_shape1 )
submesh = mesh.GetElementsOnShape( shape_mesh )
ret = mesh.AddHypothesis( shape_mesh, algoReg1d ) # Regular 1D/wire discretisation
print ret
ret = mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D
print ret
ret = mesh.AddHypothesis( shape_mesh, hypNbSeg1 ) # nb segments
print ret
ret = mesh.AddHypothesis( shape_mesh, hypArea1 ) # max area
print ret
smeshgui.SetAlgorithms( idmesh, idreg1d ); # Regular 1D/wire discretisation
smeshgui.SetAlgorithms( idmesh, idmef ); # MEFISTO 2D
smeshgui.SetHypothesis( idmesh, idseg ); # nb segments
smeshgui.SetHypothesis( idmesh, idarea1 ); # max area
print "-------------------------- add hypothesis and algorith to sub face"
sub_face = salome.IDToObject( Id_SubFace )
submesh = mesh.GetElementsOnShape( sub_face )
ret = mesh.AddHypothesis( sub_face, algoQad2 ) # Quadrangle 2D
print ret
ret = mesh.AddHypothesis( sub_face, hypArea2 ) # max area
print ret
idsm2 = smeshgui.AddSubMeshOnShape( idmesh,
Id_SubFace,
salome.orb.object_to_string(submesh),
ShapeTypeFace )
smeshgui.SetName(idsm2, "SubMeshFace")
smeshgui.SetAlgorithms( idsm2, idqad2 ); # Quadrangle 2D
smeshgui.SetHypothesis( idsm2, idarea2 ); # max area
print "-------------------------- add hypothesis and algorith to sub face"
sub_face2 = salome.IDToObject( Id_SubFace2 )
submesh = mesh.GetElementsOnShape( sub_face2 )
ret = mesh.AddHypothesis( sub_face2, algoQad2 ) # Quadrangle 2D
print ret
ret = mesh.AddHypothesis( sub_face2, hypArea2 ) # max area
print ret
idsm3 = smeshgui.AddSubMeshOnShape( idmesh,
Id_SubFace2,
salome.orb.object_to_string(submesh),
ShapeTypeFace )
smeshgui.SetName(idsm3, "SubMeshFace2")
smeshgui.SetAlgorithms( idsm3, idqad2 ); # Quadrangle 2D
smeshgui.SetHypothesis( idsm3, idarea2 ); # max area
sg.updateObjBrowser(1);

View File

@ -0,0 +1,54 @@
import SMESH
import smeshpy
import salome
from salome import sg
import math
#import SMESH_BasicHypothesis_idl
import geompy
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
myBuilder = salome.myStudy.NewBuilder()
from geompy import gg
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId);
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
# ---- define a box
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geompy.addToStudy(box,"box")
# ---- add first face of box in study
subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
face=subShapeList[0]
name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
print name
idface=geompy.addToStudyInFather(box,face,name)
# ---- add shell from box in study
subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
shell = subShellList[0]
name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
print name
idshell=geompy.addToStudyInFather(box,shell,name)
# ---- add first edge of face in study
edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
edge=edgeList[0];
name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
print name
idedge=geompy.addToStudyInFather(face,edge,name)
sg.updateObjBrowser(1);

View File

@ -0,0 +1,185 @@
import SMESH
import smeshpy
import salome
from salome import sg
import math
#import SMESH_BasicHypothesis_idl
import geompy
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
myBuilder = salome.myStudy.NewBuilder()
from geompy import gg
smeshgui = salome.ImportComponentGUI("SMESH")
smeshgui.Init(salome.myStudyId);
ShapeTypeCompSolid = 1
ShapeTypeSolid = 2
ShapeTypeShell = 3
ShapeTypeFace = 4
ShapeTypeWire = 5
ShapeTypeEdge = 6
ShapeTypeVertex = 7
# ---- define a box
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
idbox = geompy.addToStudy(box,"box")
# ---- add first face of box in study
subShapeList=geompy.SubShapeAll(box,ShapeTypeFace)
face=subShapeList[0]
name = geompy.SubShapeName( face._get_Name(), box._get_Name() )
print name
idface=geompy.addToStudyInFather(box,face,name)
# ---- add shell from box in study
subShellList=geompy.SubShapeAll(box,ShapeTypeShell)
shell = subShellList[0]
name = geompy.SubShapeName( shell._get_Name(), box._get_Name() )
print name
idshell=geompy.addToStudyInFather(box,shell,name)
# ---- add first edge of face in study
edgeList = geompy.SubShapeAll(face,ShapeTypeEdge)
edge=edgeList[0];
name = geompy.SubShapeName( edge._get_Name(), face._get_Name() )
print name
idedge=geompy.addToStudyInFather(face,edge,name)
# ---- launch SMESH, init a Mesh with the box
gen=smeshpy.smeshpy()
mesh=gen.Init(idbox)
idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) )
smeshgui.SetName(idmesh, "Meshbox");
smeshgui.SetShape(idbox, idmesh);
# ---- create Hypothesis
print "-------------------------- create Hypothesis"
print "-------------------------- LocalLength"
hyp1=gen.CreateHypothesis("LocalLength")
hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength)
hypLen1.SetLength(100)
print hypLen1.GetName()
print hypLen1.GetId()
print hypLen1.GetLength()
idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) );
smeshgui.SetName(idlength, "Local_Length_100");
print "-------------------------- NumberOfSegments"
hyp2=gen.CreateHypothesis("NumberOfSegments")
hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments)
hypNbSeg1.SetNumberOfSegments(7)
print hypNbSeg1.GetName()
print hypNbSeg1.GetId()
print hypNbSeg1.GetNumberOfSegments()
idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) );
smeshgui.SetName(idseg, "NumberOfSegments_7");
print "-------------------------- MaxElementArea"
hyp3=gen.CreateHypothesis("MaxElementArea")
hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea)
hypArea1.SetMaxElementArea(2500)
print hypArea1.GetName()
print hypArea1.GetId()
print hypArea1.GetMaxElementArea()
idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) );
smeshgui.SetName(idarea1, "MaxElementArea_2500");
print "-------------------------- MaxElementArea"
hyp3=gen.CreateHypothesis("MaxElementArea")
hypArea2=hyp3._narrow(SMESH.SMESH_MaxElementArea)
hypArea2.SetMaxElementArea(500)
print hypArea2.GetName()
print hypArea2.GetId()
print hypArea2.GetMaxElementArea()
idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) );
smeshgui.SetName(idarea2, "MaxElementArea_500");
print "-------------------------- Regular_1D"
alg1=gen.CreateHypothesis("Regular_1D")
algo1=alg1._narrow(SMESH.SMESH_Algo)
listHyp=algo1.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
algoReg=alg1._narrow(SMESH.SMESH_Regular_1D)
print algoReg.GetName()
print algoReg.GetId()
idreg = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg) );
smeshgui.SetName(idreg, "Regular_1D");
print "-------------------------- MEFISTO_2D"
alg2=gen.CreateHypothesis("MEFISTO_2D")
algo2=alg2._narrow(SMESH.SMESH_Algo)
listHyp=algo2.GetCompatibleHypothesis()
for hyp in listHyp:
print hyp
algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
print algoMef.GetName()
print algoMef.GetId()
idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) );
smeshgui.SetName(idmef, "MEFISTO_2D");
# ---- add hypothesis to edge
print "-------------------------- add hypothesis to edge"
edge=salome.IDToObject(idedge)
submesh=mesh.GetElementsOnShape(edge)
ret=mesh.AddHypothesis(edge,algoReg)
print ret
ret=mesh.AddHypothesis(edge,hypLen1)
print ret
idsm1 = smeshgui.AddSubMeshOnShape( idmesh,
idedge,
salome.orb.object_to_string(submesh),
ShapeTypeEdge )
smeshgui.SetName(idsm1, "SubMeshEdge")
smeshgui.SetAlgorithms( idsm1, idreg );
smeshgui.SetHypothesis( idsm1, idlength );
print "-------------------------- add hypothesis to face"
face=salome.IDToObject(idface)
submesh=mesh.GetElementsOnShape(face)
ret=mesh.AddHypothesis(face,hypArea2)
print ret
idsm2 = smeshgui.AddSubMeshOnShape( idmesh,
idface,
salome.orb.object_to_string(submesh),
ShapeTypeFace )
smeshgui.SetName(idsm2, "SubMeshFace")
smeshgui.SetHypothesis( idsm2, idarea2 );
# ---- add hypothesis to box
print "-------------------------- add hypothesis to box"
box=salome.IDToObject(idbox)
submesh=mesh.GetElementsOnShape(box)
ret=mesh.AddHypothesis(box,algoReg)
print ret
ret=mesh.AddHypothesis(box,hypNbSeg1)
print ret
ret=mesh.AddHypothesis(box,algoMef)
print ret
ret=mesh.AddHypothesis(box,hypArea1)
print ret
smeshgui.SetAlgorithms( idmesh, idreg );
smeshgui.SetHypothesis( idmesh, idseg );
smeshgui.SetAlgorithms( idmesh, idmef );
smeshgui.SetHypothesis( idmesh, idarea1 );
sg.updateObjBrowser(1);

Some files were not shown because too many files have changed in this diff Show More