sources v1.2

This commit is contained in:
nri 2003-07-09 07:30:56 +00:00
parent 6cb5e9d2b4
commit 95fd864d90
237 changed files with 71704 additions and 174 deletions

View File

@ -0,0 +1,408 @@
// GEOM ARCHIMEDE : algorithm implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Archimede_VolumeSection.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "Archimede_VolumeSection.hxx"
#include "utilities.h"
#include <iostream.h>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <Poly_Triangulation.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <math_Matrix.hxx>
#include <math.h>
#include <GC_MakePlane.hxx>
#include <stdlib.h>
#include <gp_Trsf.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
//-------------------------------------------------------------------------------------------------------
//----------------------------------- Methodes publiques -------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// Maillage de la shape
VolumeSection::VolumeSection(TopoDS_Shape S , Standard_Real Precision):myShape(S),Tolerance(Precision)
{
// Maillage de la shape myShape
BRepMesh_IncrementalMesh(myShape,Tolerance);
}
TopoDS_Shape VolumeSection::GetShape()
{
return myShape;
}
void VolumeSection::SetPlane(Handle (Geom_Plane) P)
{
myPlane = P;
}
void VolumeSection::CenterOfGravity()
{
Standard_Integer i;
Standard_Integer nbNodes;
TopExp_Explorer ex;
TopLoc_Location L;
// Boucle sur les faces de la shape
Xmin = 1000000000;
Ymin = 1000000000;
Zmin = 1000000000;
Xmax = -1000000000;
Ymax = -1000000000;
Zmax = -1000000000;
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next())
{
TopoDS_Face F = TopoDS::Face(ex.Current());
Handle(Poly_Triangulation) Tr = BRep_Tool::Triangulation(F, L);
if(Tr.IsNull())
MESSAGE("Error, null layer" )
nbNodes = Tr->NbNodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
// Calcul des dimensions de la boite englobante du solide
for(i=1;i<=nbNodes;i++)
{
InitPoint = Nodes(i).Transformed(L.Transformation());
if(InitPoint.X() < Xmin)
Xmin = InitPoint.X();
if(InitPoint.X() > Xmax)
Xmax = InitPoint.X();
if(InitPoint.Y() < Ymin)
Ymin = InitPoint.Y();
if(InitPoint.Y() > Ymax)
Ymax = InitPoint.Y();
if(InitPoint.Z() < Zmin)
Zmin = InitPoint.Z();
if(InitPoint.Z() > Zmax)
Zmax = InitPoint.Z();
}
}
// Creation du point d'initialisation, c'est à dire le centre de gravité
//géométrique de la boite englobante
InitPoint.SetX(0.5 * (Xmin + Xmax));
InitPoint.SetY(0.5 * (Ymin + Ymax));
InitPoint.SetZ(0);
}
Standard_Real VolumeSection::CalculateVolume(Standard_Real Elevation)
{
Standard_Integer i,noeud[3],flag[3];
Standard_Integer nbNodes;
TopExp_Explorer ex;
TopLoc_Location L;
Standard_Real z[3];
Standard_Real Volume=0;
Standard_Real Determinant=0;
gp_Pnt P[3];
// Projection du point d'initialisation sur le plan de section
InitPoint.SetZ(Elevation);
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next())
{
TopoDS_Face F = TopoDS::Face(ex.Current());
Handle(Poly_Triangulation) Tr = BRep_Tool::Triangulation(F, L);
if(Tr.IsNull())
MESSAGE("Error, null layer" )
const Poly_Array1OfTriangle& triangles = Tr->Triangles();
Standard_Integer nbTriangles = Tr->NbTriangles();
nbNodes = Tr->NbNodes();
const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
// Calcul des volumes de chaque triangle, de chaque face
//en tenant compte des triangles coupés par le plan de section
for (i=1;i<=nbTriangles;i++)
{
Determinant=0;
//Gardons la meme orientation des noeuds
if (F.Orientation() == TopAbs_REVERSED)
triangles(i).Get(noeud[0], noeud[2], noeud[1]);
else
triangles(i).Get(noeud[0], noeud[1], noeud[2]);
P[0] = Nodes(noeud[0]).Transformed(L.Transformation());
z[0] = P[0].Z();
P[1] = Nodes(noeud[1]).Transformed(L.Transformation());
z[1] = P[1].Z();
P[2] = Nodes(noeud[2]).Transformed(L.Transformation());
z[2] = P[2].Z();
// Determination des cas aux limites pour les triangles
Standard_Integer i,compteur=0;
for (i=0;i<=2;i++)
{
flag[i]=Standard_False;
if(z[i]>=Elevation)
{
flag[i]=Standard_True;
compteur++;
}
}
switch(compteur)
{
case 0:
Determinant = ElementaryVolume(P[0],P[1],P[2]);
break;
case 1:
for (i=0;i<=2;i++)
{
if (flag[i]==Standard_True)
{
gp_Pnt Result1 = Intersection(P[i],P[(i+1)%3],Elevation);
gp_Pnt Result2 = Intersection(P[i],P[(i+2)%3],Elevation);
Determinant = ElementaryVolume(Result1,P[(i+1)%3],P[(i+2)%3])
+ ElementaryVolume(Result1,P[(i+2)%3],Result2);
}
}
break;
case 2:
for (i=0;i<=2;i++)
{
if (flag[i]==Standard_False)
{
gp_Pnt Result1 = Intersection(P[i],P[(i+1)%3],Elevation);
gp_Pnt Result2 = Intersection(P[i],P[(i+2)%3],Elevation);
Determinant = ElementaryVolume(P[i],Result1,Result2);
}
}
break;
case 3:
break;
}
Volume += Determinant;
}
}
return Volume;
}
Standard_Real VolumeSection::Archimede(Standard_Real Constante , Standard_Real Epsilon)
{
// Resolution de l equation V(h) = Constante a l aide de l algorithme de dichotomie avec ponderation type
// Lagrange
Standard_Real c,Binf,Bsup;
Standard_Real tempBsupVolume=0;
Standard_Real tempBinfVolume=0;
Standard_Real tempCVolume = 0;
Binf = Zmin;
Bsup = Zmax;
if(Binf>Bsup)
{
MESSAGE("error, Bound + < Bound - in dichotomy")
return -1;
}
tempBsupVolume = CalculateVolume(Bsup);
tempBinfVolume = CalculateVolume(Binf);
if (Constante>tempBsupVolume || Constante<tempBinfVolume)
{
MESSAGE("error, algorithm start Impossible. Wrong constant value" )
return -1;
}
c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
/((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
tempCVolume = CalculateVolume(c);
if(Abs(tempCVolume-Constante)<=Epsilon)
{
goto endMethod;
}
else
{
while((Bsup-Binf)>Epsilon)
{
if((tempBinfVolume-Constante)*(tempCVolume-Constante)>0 && Abs(tempCVolume-Constante)>Epsilon)
{
Binf = c;
tempBinfVolume=tempCVolume;
c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
/((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
tempCVolume=CalculateVolume(c);
}
else if((tempBinfVolume-Constante)*(tempCVolume-Constante)<0 && Abs(tempCVolume-Constante)>Epsilon)
{
Bsup = c;
tempBsupVolume =tempCVolume;
c = ((Binf*(tempBsupVolume-Constante))-(Bsup*(tempBinfVolume-Constante)))
/((tempBsupVolume-Constante)-(tempBinfVolume-Constante));
tempCVolume=CalculateVolume(c);
}
else
{
goto endMethod;
}
}
goto endMethod;
}
endMethod:
MESSAGE("La ligne de flottaison correspondant a la constante :"<<Constante<<" est a la cote Z = "<<c)
return c;
}
void VolumeSection::MakeRotation(gp_Dir PlaneDirection)
{
gp_Dir Zdirection(0.0,0.0,1.0);
Standard_Real VariationAngle = 0;
gp_Pnt RotationAxeLocation(0.0,0.0,0.0);
gp_Dir RotationAxeDirection(1.0,1.0,1.0);
gp_Ax1 RotationAxe(RotationAxeLocation,RotationAxeDirection);
gp_Trsf Transformation;
VariationAngle = Zdirection.Angle(PlaneDirection);
RotationAxe.SetDirection(PlaneDirection.Crossed(Zdirection));
Transformation.SetRotation(RotationAxe,VariationAngle);
TopLoc_Location L(Transformation);
myShape.Move(L);
myPlane->Transform(Transformation);
}
Handle (Geom_RectangularTrimmedSurface) VolumeSection::TrimSurf()
{
Standard_Real Umin,Umax,Vmin,Vmax;
gp_Pnt Pmin(Xmin,Ymin,Zmin);
GeomAPI_ProjectPointOnSurf Projection(Pmin,myPlane);
Projection.Parameters(1,Umin,Vmin);
gp_Pnt Pmax(Xmax,Ymax,Zmax);
GeomAPI_ProjectPointOnSurf Projection2(Pmax,myPlane);
Projection2.Parameters(1,Umax,Vmax);
Handle (Geom_RectangularTrimmedSurface) Plane = new Geom_RectangularTrimmedSurface(myPlane,Umin,Umax,Vmin,Vmax);
return Plane;
}
Handle (Geom_RectangularTrimmedSurface) VolumeSection::InvMakeRotation(gp_Dir PlaneDirection, Handle (Geom_RectangularTrimmedSurface) SurfTrim)
{
gp_Dir Zdirection(0.0,0.0,1.0);
Standard_Real VariationAngle = 0;
gp_Pnt RotationAxeLocation(0.0,0.0,0.0);
gp_Dir RotationAxeDirection(1.0,1.0,1.0);
gp_Ax1 RotationAxe(RotationAxeLocation,RotationAxeDirection);
gp_Trsf Transformation;
VariationAngle = Zdirection.Angle(PlaneDirection);
RotationAxe.SetDirection(PlaneDirection.Crossed(Zdirection));
Transformation.SetRotation(RotationAxe,-VariationAngle);
SurfTrim->Transform(Transformation);
TopLoc_Location L(Transformation);
myShape.Move(L);
return SurfTrim;
}
Handle (Geom_RectangularTrimmedSurface) VolumeSection::AjustePlan(Handle (Geom_RectangularTrimmedSurface) SurfTrim, Standard_Real Cote, gp_Pnt PosPlan)
{
gp_Trsf Transformation;
gp_Pnt PosArchi(PosPlan.X(),PosPlan.Y(),Cote);
Transformation.SetTranslation(PosPlan,PosArchi);
SurfTrim->Transform(Transformation);
return SurfTrim;
}
//-------------------------------------------------------------------------------------------------------
//----------------------------------- Methodes privees ---------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//Fonction calculant l'intersection de la droite passant par les points P1 et P2
//avec le plan horizontal Z=Hauteur
gp_Pnt VolumeSection::Intersection(gp_Pnt P1,gp_Pnt P2,Standard_Real Hauteur)
{
Standard_Real constante;
gp_Pnt Point;
constante = (Hauteur-P1.Z())/(P2.Z()-P1.Z());
Point.SetX(P1.X()*(1-constante) + constante*P2.X());
Point.SetY(P1.Y()*(1-constante) + constante*P2.Y());
Point.SetZ(Hauteur);
return Point;
}
//Fonction calculant le volume élémentaire de chaque tétraedre à partir de 3 points
Standard_Real VolumeSection::ElementaryVolume(gp_Pnt P1,gp_Pnt P2,gp_Pnt P3)
{
Standard_Real Determinant;
math_Matrix M(1,3,1,3);
M(1,1)=P1.X()-InitPoint.X();
M(1,2)=P2.X()-InitPoint.X();
M(1,3)=P3.X()-InitPoint.X();
M(2,1)=P1.Y()-InitPoint.Y();
M(2,2)=P2.Y()-InitPoint.Y();
M(2,3)=P3.Y()-InitPoint.Y();
M(3,1)=P1.Z()-InitPoint.Z();
M(3,2)=P2.Z()-InitPoint.Z();
M(3,3)=P3.Z()-InitPoint.Z();
Determinant = (1.0/6) * M.Determinant();
return Determinant;
}
void VolumeSection::getZ( double& min, double& max)
{
min = Zmin;
max = Zmax;
}

View File

@ -0,0 +1,85 @@
// GEOM ARCHIMEDE : algorithm implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Archimede_VolumeSection.hxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#ifndef ARCHIMEDE_VOLUMESECTION_HXX
#define ARCHIMEDE_VOLUMESECTION_HXX
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <TopoDS_Shape.hxx>
#include <Geom_Plane.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
class VolumeSection{
public:
// Constructeur effectuant le maillage de peau de la shape
VolumeSection(TopoDS_Shape , Standard_Real);
//Methode qui affecte à un point,les coordonnées de centre de la boite englobante de la shape
void CenterOfGravity();
// Methode qui calcule le volume sous un plan Z = h
Standard_Real CalculateVolume(Standard_Real);
// Methode qui resout l'equation V(h)=constante
Standard_Real Archimede(Standard_Real , Standard_Real);
// Methode permettant de "setter" un plan afin de l'utiliser à l'interieur de la classe
void SetPlane(Handle (Geom_Plane));
// Methode permettant de récupérer la shape modifiée à l'extérieur de la classe
TopoDS_Shape GetShape();
// Methode effectuant la rotation du plan et de la shape
void MakeRotation(gp_Dir);
// Methode effectuant la rotation inverse du plan et de la shape
Handle (Geom_RectangularTrimmedSurface) InvMakeRotation(gp_Dir,Handle(Geom_RectangularTrimmedSurface));
// Methode permettant de découper le plan selon une projection de la Shape
Handle (Geom_RectangularTrimmedSurface) TrimSurf();
// Methode permmettant de deplacer le plan jusqu'a la position donnée par Archimède
Handle (Geom_RectangularTrimmedSurface) AjustePlan(Handle(Geom_RectangularTrimmedSurface),Standard_Real,gp_Pnt);
void getZ( double& min, double& max);
private:
TopoDS_Shape myShape;
Standard_Real Tolerance;
gp_Pnt InitPoint;
Standard_Real Zmin,Zmax,Ymin,Ymax,Xmin,Xmax;
Handle(Geom_Plane) myPlane;
Standard_Real ElementaryVolume(gp_Pnt,gp_Pnt,gp_Pnt);
gp_Pnt Intersection(gp_Pnt,gp_Pnt,Standard_Real);
};
#endif

57
ARCHIMEDE/Makefile.in Normal file
View File

@ -0,0 +1,57 @@
# GEOM ARCHIMEDE : algorithm implementation
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Nicolas REJNERI
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libGeometryArchimede.la
LIB_SRC = Archimede_VolumeSection.cxx
LIB_CLIENT_IDL =
# header files
EXPORT_HEADERS = Archimede_VolumeSection.hxx
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
# additional file to be cleaned
MOSTLYCLEAN =
CLEAN =
DISTCLEAN =
@CONCLUDE@

4908
GEOM/GEOM_Gen_i.cc Normal file

File diff suppressed because it is too large Load Diff

597
GEOM/GEOM_Gen_i.hh Normal file
View File

@ -0,0 +1,597 @@
// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_GEN_i.h file
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef __GEOM_GEN_I_H__
#define __GEOM_GEN_I_H__
// standard C++ headers
#include <TDocStd_Document.hxx>
#include "GEOMDS_DataMapOfIntegerTransient.hxx"
#include "GEOMDS_Application.hxx"
#include <TopTools_MapOfShape.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
// IDL headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(SALOMEDS)
#include "SALOME_Component_i.hxx"
#include "GEOM_Shape_i.hh"
#include "SALOME_NamingService.hxx"
#include <iostream.h>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//=====================================================================
// GEOM_Gen_i : class definition
//=====================================================================
class GEOM_Gen_i: public POA_GEOM::GEOM_Gen,
public Engines_Component_i
{
private:
SALOME_NamingService * name_service;
char * _name;
Handle(GEOMDS_Application) myOCAFApp; /* geom/OCAF Application */
Handle(TDocStd_Document) myCurrentOCAFDoc; /* Current geom/OCAF Document */
GEOMDS_DataMapOfIntegerTransient myStudyIDToDoc; /* Map to bind a Study to a Document */
int myStudyID;
GEOM::GEOM_Shape_ptr CreateObject(TopoDS_Shape& tds) ;
GEOM::GEOM_Shape_ptr CreateSubObject(const TopoDS_Shape& SubShape,
const GEOM::GEOM_Shape_ptr MainShape,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID);
// Create and insert(!) SubShape of MainShape
GEOM::GEOM_Shape_ptr GEOM_Gen_i::SubShapesOne( GEOM::GEOM_Shape_ptr shape,
const TopAbs_ShapeEnum ShapeType,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
const Standard_Boolean sorted=Standard_False)
throw (SALOME::SALOME_Exception);
// return all listed subshapes as one shape
GEOM::GEOM_Gen::ListOfGeomShapes* SubShapesAll(GEOM::GEOM_Shape_ptr shape,
const TopAbs_ShapeEnum type,
const Standard_Boolean sorted=Standard_False)
throw (SALOME::SALOME_Exception);
// return all subshapes by type
TopoDS_Face FindSameFace(const TopoDS_Shape& aShape,
const TopoDS_Face& F,
double tol3d);
TopoDS_Edge FindSameEdge(const TopoDS_Face& newFace,
TopoDS_Edge& Eold,
double tol3d);
public:
//-----------------------------------------------------------------------//
// Constructor / Destructor //
//-----------------------------------------------------------------------//
// constructor to be called for servant creation.
GEOM_Gen_i();
GEOM_Gen_i(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId * contId,
const char *instanceName,
const char *interfaceName);
// destructor, doing nothing (for now)
virtual ~GEOM_Gen_i();
// generic method to be put in a super class
void register_name(char * name);
//-----------------------------------------------------------------------//
// Studies Management //
//-----------------------------------------------------------------------//
void GetCurrentStudy (CORBA::Long StudyID);
CORBA::Short NbLabels();
// inherited methods from SALOMEDS::Driver
SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
bool isMultiFile);
SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
bool isMultiFile);
CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile& theStream,
const char* theURL,
bool isMultiFile);
CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile& theStream,
const char* theURL,
bool isMultiFile);
void Close(SALOMEDS::SComponent_ptr theComponent);
char* ComponentDataType();
char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
const char* IORString,
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII);
char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
const char* aLocalPersistentID,
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII);
bool CanPublishInStudy(CORBA::Object_ptr theIOR);
SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
const char* theName) throw (SALOME::SALOME_Exception) ;
CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID);
CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID);
SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID,
SALOMEDS::SObject_ptr theObject);
//-----------------------------------------------------------------------//
// Shapes Management //
//-----------------------------------------------------------------------//
const char* InsertInLabel(TopoDS_Shape S,
const char *nameIor,
Handle(TDocStd_Document) OCAFDoc) ;
const char* InsertInLabelDependentShape(TopoDS_Shape S,
const char *nameIor,
GEOM::GEOM_Shape_ptr mainshape_ptr,
Handle(TDocStd_Document) OCAFDoc) ;
void InsertInLabelOneArgument(TopoDS_Shape main_topo,
GEOM::GEOM_Shape_ptr shape_ptr,
TopoDS_Shape result_topo,
GEOM::GEOM_Shape_ptr result,
Handle(TDocStd_Document) OCAFDoc) ;
void InsertInLabelMoreArguments(TopoDS_Shape main_topo,
GEOM::GEOM_Shape_ptr result,
const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
Handle(TDocStd_Document) OCAFDoc) ;
// Methods used by SuppressFaces
int SuppressFacesGlue( const TopoDS_Shape& S,
const TopTools_MapOfShape& mapFaces,
TopoDS_Shape& aCompoundOfShells ) throw (SALOME::SALOME_Exception) ;
// various services
int GetIndexTopology( const TopoDS_Shape& subshape,
const TopoDS_Shape& mainShape ) ;
bool GetShapeFromIndex( const TopoDS_Shape& aShape,
const TopAbs_ShapeEnum aType,
const int index,
TopoDS_Shape& tds) ;
GEOM::GEOM_Shape::ListOfSubShapeID* IndexOfFacesOfSubShell( const TopoDS_Shape& S,
const TopoDS_Shape subShell )
throw (SALOME::SALOME_Exception) ;
bool ListOfIDIntoMapOfShapes( const TopoDS_Shape& S,
const GEOM::GEOM_Shape::ListOfSubShapeID& L,
const int subShapeType,
TopTools_MapOfShape& aMap ) ;
bool ListOfIDIntoSequenceOfShapes( const TopoDS_Shape& S,
const GEOM::GEOM_Shape::ListOfSubShapeID& L,
const int subShapeType,
TopTools_SequenceOfShape& aSequenceOfShapes ) ;
// Returns a TopoDS_Shape from a GEOM::GEOM_Shape_ptr
TopoDS_Shape GetTopoShape(GEOM::GEOM_Shape_ptr shape_ptr) ;
// Define a sequence of shapes from 'listShapes' and return its length
int SequenceOfShapeFromListOfGeomShape( const GEOM::GEOM_Gen::ListOfGeomShapes& listShapes,
TopTools_SequenceOfShape& SS ) ;
// Get a string representing a shape ref IOR
const char* GetStringFromIOR(GEOM::GEOM_Shape_var shapeIOR);
// Return the shape ref represented by a string of IOR
GEOM::GEOM_Shape_ptr GetIORFromString(const char* stringIOR);
GEOM::GEOM_Gen::ListOfIOR* GetReferencedObjects(GEOM::GEOM_Shape_ptr shape);
GEOM::GEOM_Gen::ListOfIOR* GetObjects(GEOM::GEOM_Shape_ptr shape);
//-----------------------------------------------------------------------//
// Internal structure of shapes //
//-----------------------------------------------------------------------//
// Explode SubShape
GEOM::GEOM_Shape_ptr SubShape(GEOM::GEOM_Shape_ptr shape,
CORBA::Short ShapeType,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception) ;
// Explode SubShape in predictable order
GEOM::GEOM_Shape_ptr SubShapeSorted(GEOM::GEOM_Shape_ptr shape,
CORBA::Short ShapeType,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception) ;
// Explode SubShape
GEOM::GEOM_Gen::ListOfGeomShapes* SubShapeAll(GEOM::GEOM_Shape_ptr shape,
CORBA::Short ShapeType)
throw (SALOME::SALOME_Exception) ;
// Explode SubShape in predictable order for TUI or GUI
GEOM::GEOM_Gen::ListOfGeomShapes* SubShapeAllSorted(GEOM::GEOM_Shape_ptr shape,
CORBA::Short ShapeType)
throw (SALOME::SALOME_Exception) ;
// Suppress faces in a shape
GEOM::GEOM_Gen::ListOfGeomShapes* SuppressFaces( GEOM::GEOM_Shape_ptr shape,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
throw (SALOME::SALOME_Exception) ;
// Suppress one or more holes in a face or shell independant topology
GEOM::GEOM_Shape_ptr SuppressHolesInFaceOrShell( GEOM::GEOM_Shape_ptr shapeFaceShell,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires)
throw (SALOME::SALOME_Exception) ;
// Suppress a single hole in a topology (face) shell or solid with/without hole traversing
GEOM::GEOM_Shape_ptr SuppressHole( GEOM::GEOM_Shape_ptr shape,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdFace,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdWire,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdEndFace )
throw (SALOME::SALOME_Exception) ;
bool RebuildFaceRemovingHoles( const TopoDS_Face& aFace,
const TopTools_MapOfShape& mapHoles,
TopoDS_Shape& resultFace ) ;
void SuppressHoleSubRoutine( const TopoDS_Shape& mainShape,
const TopoDS_Face& aFace,
const TopTools_SequenceOfShape& SSedgesOfWire,
const TopTools_IndexedDataMapOfShapeListOfShape& aMapEdgesFaces,
const TopTools_MapOfShape& MSfaces,
TopTools_MapOfShape& MSfacesSuppress,
const Standard_Boolean withEndFace,
const TopoDS_Face& endFace,
TopTools_MapOfShape& MSwireEndEdges )
throw (SALOME::SALOME_Exception ) ;
bool BuildShapeHoleNotTraversing( const TopoDS_Shape& aShape,
const TopoDS_Face& aFace,
const TopoDS_Wire& aWire,
const TopTools_MapOfShape& MFSuppress,
TopoDS_Shape& resultTds )
throw (SALOME::SALOME_Exception) ;
bool BuildShapeHoleTraversing( const TopoDS_Shape& aShape,
const TopoDS_Face& aFace,
const TopoDS_Wire& aWire,
const TopTools_MapOfShape& MFSuppress,
const TopoDS_Face& endFace,
const TopoDS_Wire& endWire,
TopoDS_Shape& resultTds )
throw (SALOME::SALOME_Exception) ;
bool FindCompareWireHoleOnFace( const TopoDS_Face& F,
const TopTools_MapOfShape& MSwireEdges,
TopoDS_Wire& aFoundWire ) ;
bool IsShapeInSequence( const TopTools_SequenceOfShape& SS, const TopoDS_Shape& aShape ) ;
void FreeEdgesFromMapOfFace(const TopTools_MapOfShape& MSfaces, TopTools_MapOfShape& MS ) ;
void MapRemoveSequence( const TopTools_MapOfShape& MS,
const TopTools_SequenceOfShape& SSRemove,
TopTools_SequenceOfShape& ST) ;
bool BuildShellWithFaceCompound( const TopoDS_Compound Comp,
TopoDS_Shell& resultShell ) ;
//-----------------------------------------------------------------------//
// Basic structures //
//-----------------------------------------------------------------------//
GEOM::PointStruct MakePointStruct(CORBA::Double x,
CORBA::Double y,
CORBA::Double z) ;
GEOM::DirStruct MakeDirection(const GEOM::PointStruct& p) ;
GEOM::AxisStruct MakeAxisStruct(CORBA::Double x,
CORBA::Double y,
CORBA::Double z,
CORBA::Double vx,
CORBA::Double vy,
CORBA::Double vz) ;
//----------------------------------------------------------------------//
// Boolean Operations //
//----------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr MakeBoolean(GEOM::GEOM_Shape_ptr shape1,
GEOM::GEOM_Shape_ptr shape2,
CORBA::Long operation)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeFuse(GEOM::GEOM_Shape_ptr shape1,
GEOM::GEOM_Shape_ptr shape2)
throw (SALOME::SALOME_Exception) ;
//----------------------------------------------------------------------//
// Advanced Operations //
//----------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr Partition(const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
const GEOM::GEOM_Gen::ListOfIOR& ListTools,
const GEOM::GEOM_Gen::ListOfIOR& ListKeepInside,
const GEOM::GEOM_Gen::ListOfIOR& ListRemoveInside,
const CORBA::Short Limit)
throw (SALOME::SALOME_Exception) ;
// Filling a surface with section curves
GEOM::GEOM_Shape_ptr MakeFilling(GEOM::GEOM_Shape_ptr shape,
CORBA::Short mindeg,
CORBA::Short maxdeg,
CORBA::Double tol3d,
CORBA::Double tol2d,
CORBA::Short nbiter)
throw (SALOME::SALOME_Exception) ;
// Sewing of shapes
GEOM::GEOM_Shape_ptr MakeSewing(const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
CORBA::Double precision)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeSewingShape( GEOM::GEOM_Shape_ptr aShape,
CORBA::Double precision )
throw (SALOME::SALOME_Exception);
GEOM::GEOM_Shape_ptr MakeGlueFaces(GEOM::GEOM_Shape_ptr myShape,
double tol3d)
throw (SALOME::SALOME_Exception);
// Change the orientation of a (new) shape
GEOM::GEOM_Shape_ptr OrientationChange(GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakePlacedBox(CORBA::Double x1, CORBA::Double y1, CORBA::Double z1,
CORBA::Double delta1, CORBA::Double delta2, CORBA::Double delta3)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakePanel(GEOM::GEOM_Shape_ptr shape,
CORBA::Short directiontype,
CORBA::Double delta)
throw (SALOME::SALOME_Exception) ;
//---------------------------------------------------------------------//
// Transformations Operations //
//---------------------------------------------------------------------//
// Copy
GEOM::GEOM_Shape_ptr MakeCopy( GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception) ;
// Translation
GEOM::GEOM_Shape_ptr MakeTranslation( GEOM::GEOM_Shape_ptr shape,
CORBA::Double x,
CORBA::Double y,
CORBA::Double z)
throw (SALOME::SALOME_Exception) ;
// Rotation
GEOM::GEOM_Shape_ptr MakeRotation( GEOM::GEOM_Shape_ptr shape,
const GEOM::AxisStruct& axis,
CORBA::Double angle)
throw (SALOME::SALOME_Exception) ;
// Create a shape using a scale factor
GEOM::GEOM_Shape_ptr MakeScaleTransform(GEOM::GEOM_Shape_ptr shape,
const GEOM::PointStruct& theCenterOfScale,
CORBA::Double factor)
throw (SALOME::SALOME_Exception) ;
// Mirror of a shape by a plane
GEOM::GEOM_Shape_ptr MakeMirrorByPlane(GEOM::GEOM_Shape_ptr shape,
GEOM::GEOM_Shape_ptr shapePlane)
throw (SALOME::SALOME_Exception) ;
// Shape by revolution of another around an axis
GEOM::GEOM_Shape_ptr MakeRevolution(GEOM::GEOM_Shape_ptr shape,
const GEOM::AxisStruct& axis,
CORBA::Double angle)
throw (SALOME::SALOME_Exception) ;
// Create a prism with a base shape along a vector P1 to P2
GEOM::GEOM_Shape_ptr MakePrism(GEOM::GEOM_Shape_ptr baseShape,
const GEOM::PointStruct& P1,
const GEOM::PointStruct& P2)
throw (SALOME::SALOME_Exception) ;
// Create a shape by sweeping a baseShape along a pathShape
GEOM::GEOM_Shape_ptr MakePipe(GEOM::GEOM_Shape_ptr pathShape,
GEOM::GEOM_Shape_ptr baseShape)
throw (SALOME::SALOME_Exception) ;
//---------------------------------------------------------------------//
// Patterns Operations //
//---------------------------------------------------------------------//
// Multi Translation 1D
GEOM::GEOM_Shape_ptr MakeMultiTranslation1D( GEOM::GEOM_Shape_ptr shape,
const GEOM::DirStruct& dir,
CORBA::Double step,
CORBA::Short nbtimes)
throw (SALOME::SALOME_Exception) ;
// Multi Translation 2D
GEOM::GEOM_Shape_ptr MakeMultiTranslation2D( GEOM::GEOM_Shape_ptr shape,
const GEOM::DirStruct& dir1,
CORBA::Double step1,
CORBA::Short nbtimes1,
const GEOM::DirStruct& dir2,
CORBA::Double step2,
CORBA::Short nbtimes2)
throw (SALOME::SALOME_Exception) ;
// Multi Rotation 1D
GEOM::GEOM_Shape_ptr MakeMultiRotation1D( GEOM::GEOM_Shape_ptr shape,
const GEOM::DirStruct& dir,
const GEOM::PointStruct& loc,
CORBA::Short nbtimes)
throw (SALOME::SALOME_Exception) ;
// Multi Rotation 2D
GEOM::GEOM_Shape_ptr MakeMultiRotation2D( GEOM::GEOM_Shape_ptr shape,
const GEOM::DirStruct& dir,
const GEOM::PointStruct& loc,
CORBA::Double ang,
CORBA::Short nbtimes1,
CORBA::Double step,
CORBA::Short nbtimes2)
throw (SALOME::SALOME_Exception) ;
//--------------------------------------------------------------------//
// Primitives Construction //
//--------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr MakeBox(CORBA::Double x1,
CORBA::Double y1,
CORBA::Double z1,
CORBA::Double x2,
CORBA::Double y2,
CORBA::Double z2)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeSphere(CORBA::Double x1,
CORBA::Double y1,
CORBA::Double z1,
CORBA::Double radius)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeCylinder(const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruct,
CORBA::Double radius,
CORBA::Double height)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeTorus(const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruct,
CORBA::Double major_radius,
CORBA::Double minor_radius)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeCone(const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruct,
CORBA::Double radius1,
CORBA::Double radius2,
CORBA::Double height)
throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Import/Export //
//-------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr ImportIGES(const char* filename) throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr ImportBREP(const char* filename) throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr ImportSTEP(const char* filename) throw (SALOME::SALOME_Exception) ;
void ExportIGES(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ;
void ExportBREP(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ;
void ExportSTEP(const char* filename,GEOM::GEOM_Shape_ptr theShape) throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Fillet and Chamfer construction //
//-------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr MakeFillet (GEOM::GEOM_Shape_ptr shape,
CORBA::Double radius,
CORBA::Short ShapeType,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeChamfer(GEOM::GEOM_Shape_ptr shape,
CORBA::Double d1,
CORBA::Double d2,
CORBA::Short ShapeType,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Mesures Construction //
//-------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr MakeCDG(GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Check Shape //
//-------------------------------------------------------------------//
CORBA::Boolean CheckShape(GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Primitives Construction //
//-------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr MakeVertex(CORBA::Double x,
CORBA::Double y,
CORBA::Double z)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeVector(const GEOM::PointStruct& pstruct1,
const GEOM::PointStruct& pstruct2)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeLine (const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruc)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakePlane (const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruc,
CORBA::Double trimsize)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeCircle(const GEOM::PointStruct& pstruct,
const GEOM::DirStruct& dstruct,
CORBA::Double radius)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeArc (const GEOM::PointStruct& pInit,
const GEOM::PointStruct& pCircle,
const GEOM::PointStruct& pEnd)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeCompound (const GEOM::GEOM_Gen::ListOfIOR& ListShapes)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeWire (const GEOM::GEOM_Gen::ListOfIOR& ListShapes)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeEdge (const GEOM::PointStruct& pstruct1,
const GEOM::PointStruct& pstruct2)
throw (SALOME::SALOME_Exception) ;
GEOM::GEOM_Shape_ptr MakeFace (GEOM::GEOM_Shape_ptr wire, CORBA::Boolean wantplanarface)
throw (SALOME::SALOME_Exception) ;
//-------------------------------------------------------------------//
// Speciic method Archimede //
//-------------------------------------------------------------------//
GEOM::GEOM_Shape_ptr Archimede(GEOM::GEOM_Shape_ptr aShape,
CORBA::Double aWeight,
CORBA::Double aWaterDensity,
CORBA::Double aMeshingDeflection)
throw (SALOME::SALOME_Exception) ;
};
#endif

248
GEOM/GEOM_Shape_i.cc Normal file
View File

@ -0,0 +1,248 @@
// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Shape_i.cc
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include <BRepTools_ShapeSet.hxx>
#include "GEOM_Shape_i.hh"
#include "SALOME_NamingService.hxx"
#include <fstream.h>
#include <BRepTools.hxx>
//=================================================================================
// function : GEOM_Shape_i() constructor (no arguments)
// purpose : for what now ?
//=================================================================================
GEOM_Shape_i::GEOM_Shape_i() { }
//=================================================================================
// function : constructor
// purpose : constructor for servant creation
//=================================================================================
GEOM_Shape_i::GEOM_Shape_i(TopoDS_Shape geom,
CORBA::ORB_ptr orb,
GEOM::GEOM_Gen_ptr engine,
const GEOM::GEOM_Shape::ListOfSubShapeID& index,
GEOM::shape_type sht,
bool ismain) {
_geom = geom;
_orb = orb;
_engine = engine;
_shapetype = sht ;
_ismain = ismain;
_index = index ;
_shapeid = "";
_studyshapeid = "";
_name = "";
_mainname ="";
_nametype ="";
}
//=================================================================================
// function : destructor
// purpose : deleting the internal geometry structure
//=================================================================================
GEOM_Shape_i::~GEOM_Shape_i() { delete &_geom; }
//=================================================================================
// function : Name (set method)
// purpose : to set the attribute 'name' of this shape.
// : WARNING : Register to naming service actually removed !
//=================================================================================
void GEOM_Shape_i::Name(const char* name) {
_name = strdup(name);
GEOM::GEOM_Shape_ptr g = GEOM::GEOM_Shape::_narrow(_this());
// Removed declaration of shapes to naming service
//SALOME_NamingService * ns = new SALOME_NamingService(_orb);
//ns->Register(g, _name);
}
//=================================================================================
// function : Name (get method)
// purpose : to get the attribute 'name' of this shape
//=================================================================================
char* GEOM_Shape_i::Name() { return strdup(_name); }
//=================================================================================
// function : MainName (set method)
// purpose : to set the attribute 'name' of this mainshape.
//=================================================================================
void GEOM_Shape_i::MainName(const char* name) {
_mainname = strdup(name);
}
//=================================================================================
// function : MainName (get method)
// purpose : to get the attribute 'name' of this shape
//=================================================================================
char* GEOM_Shape_i::MainName() { return strdup(_mainname); }
//=================================================================================
// function : IsMainShape (get method)
// purpose : return 'true' if this is a main shape (not a sub shape)
//=================================================================================
bool GEOM_Shape_i::IsMainShape() { return _ismain ; }
//=================================================================================
// function : IsMainShape (set method)
// purpose : to set the property 'ismain' true or false of this shape
//=================================================================================
void GEOM_Shape_i::IsMainShape(const bool abool) { _ismain = abool ; }
//=================================================================================
// function : ShapeId
// purpose : to get the id of this shape from GEOM (OCAF entry)
//=================================================================================
char* GEOM_Shape_i::ShapeId() { return strdup(_shapeid) ; }
//=================================================================================
// function : ShapeId (set method)
// purpose : to set the id of this shape in GEOM/OCAF doc
//=================================================================================
void GEOM_Shape_i::ShapeId(const char * shapeid) { _shapeid = strdup(shapeid) ; }
//=================================================================================
// function : StudyShapeId (get method)
// purpose : to get the id of this shape from the study document (OCAF entry)
//=================================================================================
char* GEOM_Shape_i::StudyShapeId() { return strdup(_studyshapeid) ; }
//=================================================================================
// function : StudyShapeId (set method)
// purpose : to set the id of this shape in the Study document (OCAF entry)
//=================================================================================
void GEOM_Shape_i::StudyShapeId(const char * studyshapeid)
{ _studyshapeid = strdup(studyshapeid) ; }
//=================================================================================
// function : Index (get method)
// purpose : to get the index of this sub shape in its main shape
//=================================================================================
GEOM::GEOM_Shape::ListOfSubShapeID* GEOM_Shape_i::Index() {
unsigned int _length = _index.length();
GEOM::GEOM_Shape::ListOfSubShapeID_var _list = new GEOM::GEOM_Shape::ListOfSubShapeID;
_list->length(_length);
for (unsigned int ind = 0; ind < _length; ind++) {
_list[ind] = _index[ind];
}
return _list._retn() ;
}
//=================================================================================
// function : Index (set method)
// purpose : to set the index of this sub shape (in a main shape)
//=================================================================================
void GEOM_Shape_i::Index(const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSubShapeID)
{ _index = ListOfSubShapeID ; }
//=================================================================================
// function : ShapeType (get method)
// purpose : to get the topological type of this shape as defined in enum of IDL file
//=================================================================================
GEOM::shape_type GEOM_Shape_i::ShapeType() { return _shapetype ; }
//=================================================================================
// function : SetType (set method)
// purpose : to set the topological type of this shape (see GetType)
//=================================================================================
void GEOM_Shape_i::ShapeType(GEOM::shape_type sht) { _shapetype = sht ; }
//=================================================================================
// function : NameType (set method)
// purpose : to set the attribute 'nametype' of this shape.
//=================================================================================
void GEOM_Shape_i::NameType(const char* name) {
}
//=================================================================================
// function : NameType (get method)
// purpose : to get the attribute 'nametype' of this shape
//=================================================================================
char* GEOM_Shape_i::NameType() { return strdup(_nametype); }
//=================================================================================
// function : GetShapeStream
// Transfer resulting shape to client as sequence of bytes
//client can extract shape from stream using BrepTools::Read function
//=================================================================================
GEOM::GEOM_Shape::TMPFile* GEOM_Shape_i::GetShapeStream()
{
ostrstream streamShape;
//Write TopoDS_Shape in ASCII format to the stream
BRepTools::Write(_geom, streamShape);
//Returns the number of bytes that have been stored in the stream's buffer.
int size = streamShape.pcount();
char* buf = new char [size];
//Get pointer on internal character array in ostrstream
char* valueOfStream = streamShape.str();
//Create copy of ostrstream content
memcpy(buf, valueOfStream, size);
//Allow automatic deletion of ostrstream content
streamShape.rdbuf()->freeze(0);
CORBA::Octet* OctetBuf = (CORBA::Octet*)buf;
GEOM::GEOM_Shape::TMPFile_var SeqFile = new GEOM::GEOM_Shape::TMPFile(size,size,OctetBuf,1);
return SeqFile._retn();
}
//=======================================================================
//function : Engine
//purpose : return generator engine
//=======================================================================
GEOM::GEOM_Gen_ptr GEOM_Shape_i::Engine()
{
return _engine;
}

117
GEOM/GEOM_Shape_i.hh Normal file
View File

@ -0,0 +1,117 @@
// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Shape_i.hh
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef __GEOM_SHAPE_I_H__
#define __GEOM_SHAPE_I_H__
// SALOME config header
#include <SALOMEconfig.h>
// Standard C++ headers
#include <iostream.h>
// IDL headers
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(GEOM_Shape)
// Cascade headers
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS.hxx>
//=====================================================================
// GEOM_Shape_i : class definition
//=====================================================================
class GEOM_Shape_i: public POA_GEOM::GEOM_Shape,
public PortableServer::RefCountServantBase {
private:
TopoDS_Shape _geom;
CORBA::ORB_ptr _orb;
GEOM::GEOM_Gen_ptr _engine;
GEOM::shape_type _shapetype ; // enum defined in the IDL file (Occ topol. type of a shape)
bool _ismain;
GEOM::GEOM_Shape::ListOfSubShapeID _index;
char* _name;
char* _mainname;
char* _shapeid;
char* _studyshapeid; // exists only if added in the study document
char* _nametype;
public:
// no-arg constructor, doing nothing (for now ?)
GEOM_Shape_i();
// constructor to be called for servant creation
GEOM_Shape_i(TopoDS_Shape geom,
CORBA::ORB_ptr orb,
GEOM::GEOM_Gen_ptr engine,
const GEOM::GEOM_Shape::ListOfSubShapeID& index,
GEOM::shape_type sht = GEOM::SHAPE,
bool ismain = true);
// destructor deleting the internal geometry structure
~GEOM_Shape_i();
char* Name();
void Name(const char* name);
char* MainName();
void MainName(const char* name);
char* NameType();
void NameType(const char* name);
bool IsMainShape();
void IsMainShape(const bool abool);
char* ShapeId();
void ShapeId(const char* shapeid);
char* StudyShapeId();
void StudyShapeId(const char* studyshapeid);
GEOM::GEOM_Shape::ListOfSubShapeID* Index();
void Index(const GEOM::GEOM_Shape::ListOfSubShapeID&);
GEOM::shape_type ShapeType();
void ShapeType(GEOM::shape_type sht);
GEOM::GEOM_Shape::TMPFile* GetShapeStream();
GEOM::GEOM_Gen_ptr Engine();
};
#endif

62
GEOM/Makefile.in Normal file
View File

@ -0,0 +1,62 @@
# GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Patrick GOLDBRONN (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libGeometryEngine.la
LIB_SRC = GEOM_Shape_i.cc GEOM_Gen_i.cc
LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Gen.idl GEOM_Shape.idl
# Executables targets
BIN =
BIN_SRC =
BIN_CLIENT_IDL =
BIN_SERVER_IDL =
EXPORT_HEADERS =
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS) -lGeometryDS -lTOOLSDS -lSalomeNS -lSalomeContainer -lGeometryPartition -lGeometryArchimede
# additional file to be cleaned
MOSTLYCLEAN =
CLEAN =
DISTCLEAN =
@CONCLUDE@

82
GEOM/geom.cxx Normal file
View File

@ -0,0 +1,82 @@
// GEOM GEOM : implementaion of GEOM_Gen.idl and GEOM_Shape.idl
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : geom.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_Gen_i.hh"
#include "SALOME_NamingService.hxx"
//==================================================================================
// function : main() MAIN
// purpose :
//==================================================================================
int main(int argc, char** argv)
{
try {
// Create and initialise the ORB.
// CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4");
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3");
// Obtain a reference to the root POA.
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
// We allocate the objects on the heap. Since these are reference
// counted objects, they will be deleted by the POA when they are no
// longer needed.
GEOM_Gen_i * myGEOM_Gen_i = new GEOM_Gen_i(orb);
// Activate the objects. This tells the POA that the objects are
// ready to accept requests.
PortableServer::ObjectId_var myGEOM_Gen_iid = poa->activate_object(myGEOM_Gen_i);
myGEOM_Gen_i->register_name("/myGEOM_Gen");
// Obtain a POAManager, and tell the POA to start accepting
// requests on its objects.
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();
orb->run();
orb->destroy();
}
catch(CORBA::SystemException&) {
cerr << "Caught CORBA::SystemException." << endl;
}
catch(CORBA::Exception&) {
cerr << "Caught CORBA::Exception." << endl;
}
catch(omniORB::fatalException& fe) {
cerr << "Caught omniORB::fatalException:" << endl;
cerr << " file: " << fe.file() << endl;
cerr << " line: " << fe.line() << endl;
cerr << " msg: " << fe.errmsg() << endl;
}
catch(...) {
cerr << "Caught unknown exception." << endl;
}
return 0;
}

253
GEOMClient/GEOM_Client.cxx Normal file
View File

@ -0,0 +1,253 @@
// GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Client.cxx
// Author : Yves FRICAUD/Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_Client.hxx"
#include <SALOMEconfig.h>
#include "utilities.h"
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopExp_Explorer.hxx>
#include <TopAbs.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
//=======================================================================
// function : Load()
// purpose :
//=======================================================================
static TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape )
{
TopoDS_Shape S;
/* get sequence of bytes of resulting brep shape from GEOM server */
GEOM::GEOM_Shape::TMPFile_var SeqFile = aShape->GetShapeStream();
int sizebuf = SeqFile->length();
char* buf;
buf = (char*) &SeqFile[0];
istrstream streamBrep(buf,sizebuf);
BRep_Builder aBuilder;
BRepTools::Read(S, streamBrep, aBuilder);
return S;
}
//=======================================================================
// function : Create()
// purpose :
//=======================================================================
GEOM_Client::GEOM_Client()
{
}
//=======================================================================
// function : Find()
// purpose :
//=======================================================================
Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S )
{
for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) {
if (myIORs.Value(i).IsEqual(IOR)) {
S = myShapes.Value(i);
return i;
}
}
return 0;
}
//=======================================================================
// function : Bind()
// purpose :
//=======================================================================
void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S )
{
myIORs.Append(IOR);
myShapes.Append(S);
}
//=======================================================================
// function : RemoveShapeFromBuffer()
// purpose : Remove shape from Client Buffer
//=======================================================================
void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR )
{
if( myIORs.IsEmpty() )
return ;
TopoDS_Shape S ;
Standard_Integer anIndex = Find( shapeIOR, S ) ;
if( anIndex != 0 ) {
myIORs.Remove(anIndex) ;
myShapes.Remove(anIndex) ;
}
return ;
}
//=======================================================================
// function : ClearClientBuffer()
// purpose : purge buffer
//=======================================================================
void GEOM_Client::ClearClientBuffer()
{
if( myIORs.IsEmpty() )
return ;
myIORs.Clear() ;
myShapes.Clear() ;
return ;
}
//=======================================================================
// function : BufferLength()
// purpose :
//=======================================================================
unsigned int GEOM_Client::BufferLength()
{
return myIORs.Length() ;
}
//=======================================================================
// function : GetShape()
// purpose :
//=======================================================================
TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape )
{
TopoDS_Shape S;
TCollection_AsciiString IOR(aShape->Name());
Standard_Integer anIndex = Find(IOR, S);
BRep_Builder B;
if (anIndex !=0 ) {
return S ;
}
/******* in case of a MAIN GEOM::SHAPE ********/
if (aShape->IsMainShape()) {
S = Load(geom, aShape);
Bind(IOR,S);
return S;
}
/******* in case of SUB GEOM::SHAPE ***********/
// Load and Explore the Main Shape
TopoDS_Shape MainShape = GetShape (geom, geom->GetIORFromString(aShape->MainName()));
GEOM::GEOM_Shape::ListOfSubShapeID_var list = aShape->Index();
Standard_Integer j = 1;
TopExp_Explorer exp;
TopAbs_ShapeEnum ShapeType = TopAbs_ShapeEnum(aShape->ShapeType());
/* Case of only one subshape */
if (list->length() == 1)
{
if (ShapeType == TopAbs_COMPOUND)
{
TopoDS_Iterator it;
TopTools_ListOfShape CL;
CL.Append( MainShape );
TopTools_ListIteratorOfListOfShape itC;
for (itC.Initialize( CL ); itC.More(); itC.Next())
{
for (it.Initialize( itC.Value() ); it.More(); it.Next())
{
if ( it.Value().ShapeType() == TopAbs_COMPOUND)
{
if (j == list[0])
{
S = it.Value();
Bind(IOR, S);
return S;
}
j++;
CL.Append( it.Value() );
}
}
}
}
else
{
TopTools_MapOfShape M;
for (exp.Init(MainShape, ShapeType); exp.More(); exp.Next()) {
if ( M.Add(exp.Current()) )
{
if (j == list[0])
{
S = exp.Current();
Bind(IOR, S);
return S;
}
j++;
}
}
}
}
/* Case of a compound containing two or more sub shapes (not a main shape compound !) */
/* Warning : the compound when representing sub shapes must be explored in a sub type */
/* that is NOT ShapeType=aShape->ShapeType()= TopAbs_COMPOUND ! */
/* We have to retrieve the exact sub type of shapes contained in the compound first ! */
TopoDS_Iterator it ;
TopAbs_ShapeEnum exactSubType ;
S = Load( geom, aShape );
it.Initialize( S, true, true ) ;
it.More();
exactSubType = it.Value().ShapeType() ;
TColStd_MapOfInteger MapIndex;
Standard_Integer nbSS = list->length();
TopoDS_Compound Comp;
B.MakeCompound(Comp);
for (Standard_Integer i=1; i<=nbSS; i++)
MapIndex.Add(list[i-1]);
for (exp.Init(MainShape, exactSubType), j=1; exp.More() ; exp.Next(), j++) {
if ( MapIndex.Contains(j) ) {
B.Add( Comp, exp.Current() );
}
}
Bind(IOR, Comp);
return Comp;
}

View File

@ -0,0 +1,93 @@
// GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_Client.hxx
// Author : Yves FRICAUD
// Module : GEOM
// $Header$
#ifndef _GEOM_Client_HeaderFile
#define _GEOM_Client_HeaderFile
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(GEOM_Gen)
#
#ifndef _TColStd_SequenceOfAsciiString_HeaderFile
#include <TColStd_SequenceOfAsciiString.hxx>
#endif
#ifndef _TopTools_SequenceOfShape_HeaderFile
#include <TopTools_SequenceOfShape.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
class TCollection_AsciiString;
class TopoDS_Shape;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
//=====================================================================
// GEOM_Client : class definition
//=====================================================================
class GEOM_Client {
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);
}
// Methods PUBLIC
//
Standard_EXPORT GEOM_Client();
Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& ShapeIOR, TopoDS_Shape& S ) ;
Standard_EXPORT void Bind( const TCollection_AsciiString& ShapeIOR, const TopoDS_Shape& S ) ;
Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape );
Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) ;
Standard_EXPORT void ClearClientBuffer() ;
Standard_EXPORT unsigned int BufferLength() ;
private:
// Fields PRIVATE
//
TColStd_SequenceOfAsciiString myIORs ;
TopTools_SequenceOfShape myShapes ;
};
#endif

60
GEOMClient/Makefile.in Normal file
View File

@ -0,0 +1,60 @@
# GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Patrick GOLDBRONN (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# header files
EXPORT_HEADERS = \
GEOM_Client.hxx
# Libraries targets
LIB = libGeometryClient.la
LIB_SRC = GEOM_Client.cxx
LIB_SERVER_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
# Executables targets
BIN =
BIN_SRC =
BIN_CLIENT_IDL =
BIN_SERVER_IDL =
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
@CONCLUDE@

53
GEOMDS/GEOMDS.cdl Normal file
View File

@ -0,0 +1,53 @@
-- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : GEOMDS.cdl
-- Author : Yves FRICAUD
-- Module : GEOM
package GEOMDS
---Purpose:
uses
TDF,
TDocStd,
TDataStd,
TColStd,
TopoDS,
TCollection,
TNaming
is
class Application;
class Commands;
class Explorer;
class DataMapOfIntegerTransient instantiates DataMap from
TCollection(Integer from Standard, Transient from Standard, MapIntegerHasher
from TColStd);
end GEOMDS;

View File

@ -0,0 +1,49 @@
-- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : GEOMDS_Application.cdl
-- Author : Yves FRICAUD
-- Module : GEOM
class Application from GEOMDS inherits Application from TDocStd
---Purpose:
uses
Label from TDF,
SequenceOfExtendedString from TColStd,
CString from Standard,
Document from TDocStd
is
Create
returns mutable Application from GEOMDS;
Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd)
is redefined;
ResourcesName (me: mutable) returns CString from Standard;
end Application;

View File

@ -0,0 +1,66 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Application.cxx
// Author : Yves FRICAUD
// Module : GEOM
// $Header$
using namespace std;
#include "GEOMDS_Application.ixx"
//=======================================================================
//function : GEOMDS_Application
//purpose :
//=======================================================================
GEOMDS_Application::GEOMDS_Application()
{
}
//=======================================================================
//function : Formats
//purpose :
//=======================================================================
void GEOMDS_Application::Formats(TColStd_SequenceOfExtendedString& Formats)
{
Formats.Append(TCollection_ExtendedString ("SALOME_GEOM"));
}
//=======================================================================
//function : ResourcesName
//purpose :
//=======================================================================
Standard_CString GEOMDS_Application::ResourcesName()
{
return Standard_CString ("Resources");
}

View File

@ -0,0 +1,112 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Application.hxx
// Module : GEOM
#ifndef _GEOMDS_Application_HeaderFile
#define _GEOMDS_Application_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_GEOMDS_Application_HeaderFile
#include <Handle_GEOMDS_Application.hxx>
#endif
#ifndef _TDocStd_Application_HeaderFile
#include <TDocStd_Application.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
class TColStd_SequenceOfExtendedString;
class GEOMDS_Application : public TDocStd_Application {
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 GEOMDS_Application();
Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ;
Standard_EXPORT Standard_CString ResourcesName() ;
Standard_EXPORT ~GEOMDS_Application();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOMDS_Application_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,86 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Application.ixx
// Module : GEOM
#include "GEOMDS_Application.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOMDS_Application::~GEOMDS_Application() {}
Standard_EXPORT Handle_Standard_Type& GEOMDS_Application_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application);
static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application);
if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application);
static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application);
if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application);
static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient);
if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient);
static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL};
static Handle_Standard_Type _aType = new Standard_Type("GEOMDS_Application",
sizeof(GEOMDS_Application),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
const Handle(GEOMDS_Application) Handle(GEOMDS_Application)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMDS_Application) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_Application))) {
_anOtherObject = Handle(GEOMDS_Application)((Handle(GEOMDS_Application)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOMDS_Application::DynamicType() const
{
return STANDARD_TYPE(GEOMDS_Application) ;
}
Standard_Boolean GEOMDS_Application::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOMDS_Application) == AType || TDocStd_Application::IsKind(AType));
}
Handle_GEOMDS_Application::~Handle_GEOMDS_Application() {}

View File

@ -0,0 +1,32 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Application.jxx
// Module : GEOM
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
#include <TColStd_SequenceOfExtendedString.hxx>
#endif
#ifndef _GEOMDS_Application_HeaderFile
#include "GEOMDS_Application.hxx"
#endif

View File

@ -0,0 +1,46 @@
-- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : GEOMDS_Commands.cdl
-- Author : Yves FRICAUD
-- Module : GEOM
class Commands from GEOMDS
---Purpose:
uses
Label from TDF,
Shape from TopoDS,
ExtendedString from TCollection
is
Create ( Main : Label from TDF) returns Commands from GEOMDS;
AddShape(me : in out; S : Shape from TopoDS;
Name : ExtendedString from TCollection)
returns Label from TDF;
fields
myLab : Label from TDF;
end Commands;

302
GEOMDS/GEOMDS_Commands.cxx Normal file
View File

@ -0,0 +1,302 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeomDS_Commands.cxx
// Author : Yves FRICAUD/Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "utilities.h"
#include "GEOMDS_Commands.ixx"
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_Integer.hxx>
#include <TDF_Reference.hxx>
#include <TNaming_Tool.hxx>
#include <TDF_ChildIterator.hxx>
//=======================================================================
//function : GEOMDS_Commands
//purpose :
//=======================================================================
GEOMDS_Commands::GEOMDS_Commands(const TDF_Label& Main)
: myLab(Main)
{
}
//=======================================================================
// function : Generated()
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S,
const TCollection_ExtendedString& Name)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Generated(S);
TDataStd_Name::Set(NewLab,Name);
return NewLab;
}
//=======================================================================
// function : Generated()
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::Generated(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const TCollection_ExtendedString& Name)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Generated(S1,S2);
TDataStd_Name::Set(NewLab,Name);
return NewLab;
}
//=======================================================================
// function : AddShape()
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::AddShape(const TopoDS_Shape& S,
const TCollection_ExtendedString& Name)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Select(S,S);
TDataStd_Name::Set(NewLab,Name);
return NewLab;
}
//=======================================================================
// function : AddIndependentShape()
// purpose : SAME than AddShape() : will be renamed later
//=======================================================================
TDF_Label GEOMDS_Commands::AddIndependentShape(const TopoDS_Shape& S,
const TCollection_AsciiString& nameIOR)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Select(S,S);
TDataStd_Name::Set(NewLab, nameIOR);
return NewLab;
}
//=======================================================================
// function : AddDependentShape()
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::AddDependentShape(const TopoDS_Shape& S,
const TCollection_AsciiString& nameIOR,
const TDF_Label& mainLab)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Select(S,S);
TDataStd_Name::Set(NewLab, nameIOR);
/* NewLab has a reference attribute to mainLab (the main shape in fact) */
TDF_Reference::Set(NewLab, mainLab) ;
return NewLab;
}
//=======================================================================
// function : AddConstructiveElement()
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::AddConstructiveElement(const TopoDS_Shape& S,
const TCollection_ExtendedString& nameIOR,
const GEOMDS_ConstructiveType& aType)
{
TDF_Label NewLab = myLab.NewChild();
TNaming_Builder B(NewLab);
B.Select(S,S);
TDataStd_Name::Set(NewLab, nameIOR);
/* Add the Attribute Constructive Element coded with a TDataStd_Integer from an enum */
TDataStd_Integer::Set(NewLab, Standard_Integer(aType));
return NewLab;
}
//=======================================================================
// function : AddIORNameAttribute()
// purpose : Add attribute TDataStd_Name to a label
// : this attribute represents the name/IOR of object
// : Return false if attribute exist before
//=======================================================================
Standard_Boolean GEOMDS_Commands::AddIORNameAttribute(const TDF_Label& aLabel,
const TCollection_ExtendedString& nameIOR)
{
if( this->HasIOR(aLabel) )
return false ;
TDataStd_Name::Set(aLabel, nameIOR);
return true ;
}
//=======================================================================
// function : IsConstructiveElement() 1/2
// purpose : Return true if 'aLabel' is a constructive element
//=======================================================================
Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel)
{
Handle(TDataStd_Integer) anAttType ;
if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType ) )
return true ;
return false;
}
//=======================================================================
// function : IsConstructiveElement() 2/2
// purpose : Return true if 'aLabel' is a constructive element and return the
// : topology ' returnTopo' and type 'returnType'
//=======================================================================
Standard_Boolean GEOMDS_Commands::IsConstructiveElement(const TDF_Label& aLabel,
TopoDS_Shape& returnTopo,
GEOMDS_ConstructiveType& returnType)
{
Handle(TDataStd_Integer) anAttType ;
Handle(TNaming_NamedShape) anAttTopo ;
if( aLabel.FindAttribute(TDataStd_Integer::GetID(), anAttType) && aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) {
returnTopo = TNaming_Tool::GetShape(anAttTopo) ;
returnType = GEOMDS_ConstructiveType( anAttType->Get() ) ;
return true ;
}
return false;
}
//=======================================================================
// function : GetShape()
// purpose : return true and 'returnTopo' if a topology is found on 'aLabel'
//=======================================================================
Standard_Boolean GEOMDS_Commands::GetShape(const TDF_Label& aLabel,
TopoDS_Shape& returnTopo)
{
Handle(TNaming_NamedShape) anAttTopo ;
if( aLabel.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) {
returnTopo = TNaming_Tool::GetShape(anAttTopo) ;
return true ;
}
return false;
}
//=======================================================================
// function : IsDependentShape()
// purpose : return true if the shape in the label is dependant (a sub shape)
//=======================================================================
Standard_Boolean GEOMDS_Commands::IsDependentShape(const TDF_Label& aLabel)
{
Handle(TDF_Reference) anAttRef ;
if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef))
return true ;
return false;
}
//=======================================================================
// function : GetMainShapeLabel()
// purpose : return true if an attribute Reference is found for 'aLabel'
// : so 'returnMainLabel' is defined. 'aLabel' is supposed to be
// : a dependent object, otherwise return false.
//=======================================================================
Standard_Boolean GEOMDS_Commands::GetMainShapeLabel(const TDF_Label& aLabel,
TDF_Label& returnMainLabel)
{
Handle(TDF_Reference) anAttRef ;
if( aLabel.FindAttribute(TDF_Reference::GetID(), anAttRef)) {
returnMainLabel = anAttRef->Get() ;
return true ;
}
return false;
}
//=======================================================================
// function : ClearAllIOR()
// purpose : Clear all IOR from aLabel usually the main label.
// : Useful before reconstruction after a load of a document.
// : IOR is the attribute often called 'name' or 'nameIOR'
//=======================================================================
Standard_Boolean GEOMDS_Commands::ClearAllIOR(const TDF_Label& aLabel)
{
TDF_ChildIterator it;
Handle(TDataStd_Name) anAttName ;
bool notTested = false ;
for( it.Initialize(aLabel, Standard_False); it.More(); it.Next() ) {
TDF_Label L = it.Value() ;
if( L.FindAttribute(TDataStd_Name::GetID(), anAttName) ) {
notTested = L.ForgetAttribute(TDataStd_Name::GetID()) ;
}
if(notTested)
MESSAGE("in GEOMDS_Commands::ClearAllIOR : IOR CLEARED" )
}
return true ;
}
//=======================================================================
// function : HasIOR()
// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR)
//=======================================================================
Standard_Boolean GEOMDS_Commands::HasIOR(const TDF_Label& aLabel)
{
Handle(TDataStd_Name) anAttName ;
if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) )
return false ;
return true ;
}
//=======================================================================
// function : ReturnNameIOR()
// purpose : Return true is 'aLabel' has an attribute IOR (nameIOR)
// : and define 'returnNameIOR'
//=======================================================================
Standard_Boolean GEOMDS_Commands::ReturnNameIOR(const TDF_Label& aLabel,
TCollection_ExtendedString& returnNameIOR)
{
Handle(TDataStd_Name) anAttName ;
if( !aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName) )
return false ;
else {
returnNameIOR = anAttName->Get() ;
return true ;
}
}

150
GEOMDS/GEOMDS_Commands.hxx Normal file
View File

@ -0,0 +1,150 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeomDS_Commands.hxx
// Author : Yves FRICAUD/Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef _GEOMDS_Commands_HeaderFile
#define _GEOMDS_Commands_HeaderFile
#ifndef _TDF_Label_HeaderFile
#include <TDF_Label.hxx>
#endif
class TDF_Label;
class TopoDS_Shape;
class TCollection_ExtendedString;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
//============================================================================
// class : GEOMDS_Commands
// purpose :
//============================================================================
class GEOMDS_Commands {
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
//
// used for specific entities
enum GEOMDS_ConstructiveType { VECTOR, LINE, PLANE } ;
// Methods to add or create items in the data structure
Standard_EXPORT GEOMDS_Commands(const TDF_Label& Main);
Standard_EXPORT TDF_Label AddShape(const TopoDS_Shape& S,
const TCollection_ExtendedString& Name) ;
Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S,
const TCollection_ExtendedString& Name) ;
Standard_EXPORT TDF_Label Generated(const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
const TCollection_ExtendedString& Name) ;
/* Shapes construction */
Standard_EXPORT TDF_Label AddIndependentShape(const TopoDS_Shape& S,
const TCollection_AsciiString& nameIOR) ;
Standard_EXPORT TDF_Label AddDependentShape(const TopoDS_Shape& S,
const TCollection_AsciiString& nameIOR,
const TDF_Label& mainLab) ;
Standard_EXPORT TDF_Label AddConstructiveElement(const TopoDS_Shape& S,
const TCollection_ExtendedString& nameIOR,
const GEOMDS_ConstructiveType& aType);
Standard_EXPORT Standard_Boolean AddIORNameAttribute(const TDF_Label& aLabel,
const TCollection_ExtendedString& nameIOR) ;
/* Shapes query */
Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel) ;
Standard_EXPORT Standard_Boolean IsConstructiveElement(const TDF_Label& aLabel,
TopoDS_Shape& returnTopo,
GEOMDS_ConstructiveType& returnType) ;
Standard_EXPORT Standard_Boolean GetShape(const TDF_Label& aLabel,
TopoDS_Shape& returnTopo) ;
Standard_EXPORT Standard_Boolean IsDependentShape(const TDF_Label& aLabel) ;
Standard_EXPORT Standard_Boolean GetMainShapeLabel(const TDF_Label& aLabel,
TDF_Label& returnMainLabel) ;
Standard_EXPORT Standard_Boolean ClearAllIOR(const TDF_Label& aLabel) ;
Standard_EXPORT Standard_Boolean HasIOR(const TDF_Label& aLabel) ;
Standard_EXPORT Standard_Boolean ReturnNameIOR(const TDF_Label& aLabel,
TCollection_ExtendedString& returnNameIOR) ;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
TDF_Label myLab;
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,31 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Commands.ixx
// Module : GEOM
#include "GEOMDS_Commands.jxx"

View File

@ -0,0 +1,38 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Commands.jxx
// Module : GEOM
#ifndef _TDF_Label_HeaderFile
#include <TDF_Label.hxx>
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TCollection_ExtendedString_HeaderFile
#include <TCollection_ExtendedString.hxx>
#endif
#ifndef _GEOMDS_Commands_HeaderFile
#include "GEOMDS_Commands.hxx"
#endif

View File

@ -0,0 +1,118 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx
// Module : GEOM
#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile
#define _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile
#ifndef _TCollection_BasicMapIterator_HeaderFile
#include <TCollection_BasicMapIterator.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Handle_Standard_Transient_HeaderFile
#include <Handle_Standard_Transient.hxx>
#endif
#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#endif
class Standard_NoSuchObject;
class Standard_Transient;
class TColStd_MapIntegerHasher;
class GEOMDS_DataMapOfIntegerTransient;
class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient : public TCollection_BasicMapIterator {
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 GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient();
Standard_EXPORT GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& aMap);
Standard_EXPORT void Initialize(const GEOMDS_DataMapOfIntegerTransient& aMap) ;
Standard_EXPORT const Standard_Integer& Key() const;
Standard_EXPORT const Handle_Standard_Transient& Value() const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,62 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx
// Module : GEOM
using namespace std;
#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx"
#ifndef _Standard_NoSuchObject_HeaderFile
#include <Standard_NoSuchObject.hxx>
#endif
#ifndef _Standard_Transient_HeaderFile
#include <Standard_Transient.hxx>
#endif
#ifndef _TColStd_MapIntegerHasher_HeaderFile
#include <TColStd_MapIntegerHasher.hxx>
#endif
#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapOfIntegerTransient.hxx"
#endif
#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#endif
#define TheKey Standard_Integer
#define TheKey_hxx <Standard_Integer.hxx>
#define TheItem Handle_Standard_Transient
#define TheItem_hxx <Standard_Transient.hxx>
#define Hasher TColStd_MapIntegerHasher
#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_hxx <GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx>
#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient
#define TCollection_DataMapIterator_hxx <GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_()
#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient
#define TCollection_DataMap_hxx <GEOMDS_DataMapOfIntegerTransient.hxx>
#include <TCollection_DataMapIterator.gxx>

View File

@ -0,0 +1,152 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx
// Module : GEOM
#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#define _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Handle_Standard_Transient_HeaderFile
#include <Handle_Standard_Transient.hxx>
#endif
#ifndef _TCollection_MapNode_HeaderFile
#include <TCollection_MapNode.hxx>
#endif
#ifndef _TCollection_MapNodePtr_HeaderFile
#include <TCollection_MapNodePtr.hxx>
#endif
class Standard_Transient;
class TColStd_MapIntegerHasher;
class GEOMDS_DataMapOfIntegerTransient;
class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient;
class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient : public TCollection_MapNode {
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 inline GEOMDS_DataMapNodeOfDataMapOfIntegerTransient(const Standard_Integer& K,const Handle(Standard_Transient)& I,const TCollection_MapNodePtr& n);
Standard_EXPORT inline Standard_Integer& Key() const;
Standard_EXPORT inline Handle_Standard_Transient& Value() const;
Standard_EXPORT ~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
Standard_Integer myKey;
Handle_Standard_Transient myValue;
};
#define TheKey Standard_Integer
#define TheKey_hxx <Standard_Integer.hxx>
#define TheItem Handle_Standard_Transient
#define TheItem_hxx <Standard_Transient.hxx>
#define Hasher TColStd_MapIntegerHasher
#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_hxx <GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx>
#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient
#define TCollection_DataMapIterator_hxx <GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_()
#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient
#define TCollection_DataMap_hxx <GEOMDS_DataMapOfIntegerTransient.hxx>
#include <TCollection_DataMapNode.lxx>
#undef TheKey
#undef TheKey_hxx
#undef TheItem
#undef TheItem_hxx
#undef Hasher
#undef Hasher_hxx
#undef TCollection_DataMapNode
#undef TCollection_DataMapNode_hxx
#undef TCollection_DataMapIterator
#undef TCollection_DataMapIterator_hxx
#undef Handle_TCollection_DataMapNode
#undef TCollection_DataMapNode_Type_
#undef TCollection_DataMap
#undef TCollection_DataMap_hxx
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,111 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx
// Module : GEOM
using namespace std;
#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
#ifndef _Standard_Transient_HeaderFile
#include <Standard_Transient.hxx>
#endif
#ifndef _TColStd_MapIntegerHasher_HeaderFile
#include <TColStd_MapIntegerHasher.hxx>
#endif
#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapOfIntegerTransient.hxx"
#endif
#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx"
#endif
GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {}
Standard_EXPORT Handle_Standard_Type& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode);
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("GEOMDS_DataMapNodeOfDataMapOfIntegerTransient",
sizeof(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient))) {
_anOtherObject = Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)((Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::DynamicType() const
{
return STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) ;
}
Standard_Boolean GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) == AType || TCollection_MapNode::IsKind(AType));
}
Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient::~Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient() {}
#define TheKey Standard_Integer
#define TheKey_hxx <Standard_Integer.hxx>
#define TheItem Handle_Standard_Transient
#define TheItem_hxx <Standard_Transient.hxx>
#define Hasher TColStd_MapIntegerHasher
#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_hxx <GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx>
#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient
#define TCollection_DataMapIterator_hxx <GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_()
#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient
#define TCollection_DataMap_hxx <GEOMDS_DataMapOfIntegerTransient.hxx>
#include <TCollection_DataMapNode.gxx>

View File

@ -0,0 +1,140 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapOfIntegerTransient.hxx
// Module : GEOM
#ifndef _GEOMDS_DataMapOfIntegerTransient_HeaderFile
#define _GEOMDS_DataMapOfIntegerTransient_HeaderFile
#ifndef _TCollection_BasicMap_HeaderFile
#include <TCollection_BasicMap.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Handle_Standard_Transient_HeaderFile
#include <Handle_Standard_Transient.hxx>
#endif
#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#include "Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class Standard_DomainError;
class Standard_NoSuchObject;
class Standard_Transient;
class TColStd_MapIntegerHasher;
class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient;
class GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class GEOMDS_DataMapOfIntegerTransient : public TCollection_BasicMap {
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 GEOMDS_DataMapOfIntegerTransient(const Standard_Integer NbBuckets = 1);
Standard_EXPORT GEOMDS_DataMapOfIntegerTransient& Assign(const GEOMDS_DataMapOfIntegerTransient& Other) ;
GEOMDS_DataMapOfIntegerTransient& operator =(const GEOMDS_DataMapOfIntegerTransient& Other)
{
return Assign(Other);
}
Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ;
Standard_EXPORT void Clear() ;
~GEOMDS_DataMapOfIntegerTransient()
{
Clear();
}
Standard_EXPORT Standard_Boolean Bind(const Standard_Integer& K,const Handle(Standard_Transient)& I) ;
Standard_EXPORT Standard_Boolean IsBound(const Standard_Integer& K) const;
Standard_EXPORT Standard_Boolean UnBind(const Standard_Integer& K) ;
Standard_EXPORT const Handle_Standard_Transient& Find(const Standard_Integer& K) const;
const Handle_Standard_Transient& operator()(const Standard_Integer& K) const
{
return Find(K);
}
Standard_EXPORT Handle_Standard_Transient& ChangeFind(const Standard_Integer& K) ;
Handle_Standard_Transient& operator()(const Standard_Integer& K)
{
return ChangeFind(K);
}
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
Standard_EXPORT GEOMDS_DataMapOfIntegerTransient(const GEOMDS_DataMapOfIntegerTransient& Other);
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,65 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_DataMapOfIntegerTransient_0.cxx
// Module : GEOM
using namespace std;
#include "GEOMDS_DataMapOfIntegerTransient.hxx"
#ifndef _Standard_DomainError_HeaderFile
#include <Standard_DomainError.hxx>
#endif
#ifndef _Standard_NoSuchObject_HeaderFile
#include <Standard_NoSuchObject.hxx>
#endif
#ifndef _Standard_Transient_HeaderFile
#include <Standard_Transient.hxx>
#endif
#ifndef _TColStd_MapIntegerHasher_HeaderFile
#include <TColStd_MapIntegerHasher.hxx>
#endif
#ifndef _GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx"
#endif
#ifndef _GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_HeaderFile
#include "GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx"
#endif
#define TheKey Standard_Integer
#define TheKey_hxx <Standard_Integer.hxx>
#define TheItem Handle_Standard_Transient
#define TheItem_hxx <Standard_Transient.hxx>
#define Hasher TColStd_MapIntegerHasher
#define Hasher_hxx <TColStd_MapIntegerHasher.hxx>
#define TCollection_DataMapNode GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_hxx <GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx>
#define TCollection_DataMapIterator GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient
#define TCollection_DataMapIterator_hxx <GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient.hxx>
#define Handle_TCollection_DataMapNode Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient
#define TCollection_DataMapNode_Type_() GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_Type_()
#define TCollection_DataMap GEOMDS_DataMapOfIntegerTransient
#define TCollection_DataMap_hxx <GEOMDS_DataMapOfIntegerTransient.hxx>
#include <TCollection_DataMap.gxx>

View File

@ -0,0 +1,52 @@
-- GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
--
-- Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-- CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
--
--
--
-- File : GEOMDS_Explorer.cdl
-- Author : Yves FRICAUD
-- Module : GEOM
class Explorer from GEOMDS
---Purpose:
uses
ChildIterator from TDF,
Label from TDF,
ExtendedString from TCollection,
Shape from TopoDS
is
Create ( Main : Label from TDF) returns Explorer from GEOMDS;
More(me : in out) returns Boolean from Standard;
Next(me : in out);
Shape(me)returns Shape from TopoDS;
Name(me) returns ExtendedString from TCollection;
fields
myChildIterator : ChildIterator from TDF;
end Explorer;

126
GEOMDS/GEOMDS_Explorer.cxx Normal file
View File

@ -0,0 +1,126 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Explorer.cxx
// Author : Yves FRICAUD
// Module : GEOM
// $Header$
using namespace std;
#include "GEOMDS_Explorer.ixx"
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TDataStd_Name.hxx>
//=======================================================================
//function : GEOMDS_Explorer
//purpose :
//=======================================================================
GEOMDS_Explorer::GEOMDS_Explorer(const TDF_Label& Main) : myChildIterator(Main)
{
}
//=======================================================================
//function : const;
//purpose :
//=======================================================================
Standard_Boolean GEOMDS_Explorer::More()
{
if (!myChildIterator.More())
return 0;
Handle(TDataStd_Name) Att;
Handle(TNaming_NamedShape) NS;
TDF_Label L = myChildIterator.Value();
if (( L.FindAttribute(TDataStd_Name::GetID(),Att) ) ||
(L.FindAttribute(TNaming_NamedShape::GetID(),NS))
)
return 1;
// myChildIterator.Next();
// More();
return 0;
/*
if (!myChildIterator.More())
return 0;
TDF_Label L = myChildIterator.Value();
Handle(TNaming_NamedShape) NS;
for (TDF_ChildIterator it2(L); it2.More(); it2.Next()) {
TDF_Label L2 = it2.Value();
if (L2.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return 1;
}
myChildIterator.Next();
}
return 0;
*/
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void GEOMDS_Explorer::Next()
{
myChildIterator.Next();
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
TopoDS_Shape GEOMDS_Explorer::Shape() const
{
Handle(TNaming_NamedShape) NS;
TDF_Label L = myChildIterator.Value();
L.FindAttribute(TNaming_NamedShape::GetID(),NS);
TopoDS_Shape S = TNaming_Tool::GetShape(NS);
return S;
}
//=======================================================================
//function : Name
//purpose :
//=======================================================================
TCollection_ExtendedString GEOMDS_Explorer::Name() const
{
TDF_Label L = myChildIterator.Value();
Handle(TDataStd_Name) Att;
if ( L.FindAttribute(TDataStd_Name::GetID(),Att) )
//L.FindAttribute(TDataStd_Name::GetID(),Att);
return Att->Get();
else
return TCollection_ExtendedString();
}

101
GEOMDS/GEOMDS_Explorer.hxx Normal file
View File

@ -0,0 +1,101 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Explorer.hxx
// Module : GEOM
#ifndef _GEOMDS_Explorer_HeaderFile
#define _GEOMDS_Explorer_HeaderFile
#ifndef _TDF_ChildIterator_HeaderFile
#include <TDF_ChildIterator.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
class TDF_Label;
class TopoDS_Shape;
class TCollection_ExtendedString;
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
class GEOMDS_Explorer {
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 GEOMDS_Explorer(const TDF_Label& Main);
Standard_EXPORT Standard_Boolean More() ;
Standard_EXPORT void Next() ;
Standard_EXPORT TopoDS_Shape Shape() const;
Standard_EXPORT TCollection_ExtendedString Name() const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
TDF_ChildIterator myChildIterator;
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,31 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Explorer.ixx
// Module : GEOM
#include "GEOMDS_Explorer.jxx"

View File

@ -0,0 +1,38 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOMDS_Explorer.jxx
// Module : GEOM
#ifndef _TDF_Label_HeaderFile
#include <TDF_Label.hxx>
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TCollection_ExtendedString_HeaderFile
#include <TCollection_ExtendedString.hxx>
#endif
#ifndef _GEOMDS_Explorer_HeaderFile
#include "GEOMDS_Explorer.hxx"
#endif

View File

@ -0,0 +1,100 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOMDS_Application.hxx
// Module : GEOM
#ifndef _Handle_GEOMDS_Application_HeaderFile
#define _Handle_GEOMDS_Application_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_TDocStd_Application_HeaderFile
#include <Handle_TDocStd_Application.hxx>
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(TDocStd_Application);
class GEOMDS_Application;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SimpleOCAF_Application);
class Handle(GEOMDS_Application) : public Handle(TDocStd_Application) {
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(GEOMDS_Application)():Handle(TDocStd_Application)() {}
Handle(GEOMDS_Application)(const Handle(GEOMDS_Application)& aHandle) : Handle(TDocStd_Application)(aHandle)
{
}
Handle(GEOMDS_Application)(const GEOMDS_Application* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem)
{
}
Handle(GEOMDS_Application)& operator=(const Handle(GEOMDS_Application)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOMDS_Application)& operator=(const GEOMDS_Application* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOMDS_Application* operator->()
{
return (GEOMDS_Application *)ControlAccess();
}
GEOMDS_Application* operator->() const
{
return (GEOMDS_Application *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOMDS_Application)();
Standard_EXPORT static const Handle(GEOMDS_Application) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -0,0 +1,100 @@
// GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx
// Module : GEOM
#ifndef _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#define _Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_HeaderFile
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Handle_TCollection_MapNode_HeaderFile
#include <Handle_TCollection_MapNode.hxx>
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(TCollection_MapNode);
class GEOMDS_DataMapNodeOfDataMapOfIntegerTransient;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient);
class Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) : public Handle(TCollection_MapNode) {
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(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)():Handle(TCollection_MapNode)() {}
Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle) : Handle(TCollection_MapNode)(aHandle)
{
}
Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem)
{
}
Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)& operator=(const GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->()
{
return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess();
}
GEOMDS_DataMapNodeOfDataMapOfIntegerTransient* operator->() const
{
return (GEOMDS_DataMapNodeOfDataMapOfIntegerTransient *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient)();
Standard_EXPORT static const Handle(GEOMDS_DataMapNodeOfDataMapOfIntegerTransient) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

74
GEOMDS/Makefile.in Normal file
View File

@ -0,0 +1,74 @@
# GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Patrick GOLDBRONN (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libGeometryDS.la
LIB_SRC = GEOMDS_Application.cxx \
GEOMDS_Commands.cxx \
GEOMDS_Explorer.cxx \
GEOMDS_DataMapIteratorOfDataMapOfIntegerTransient_0.cxx \
GEOMDS_DataMapNodeOfDataMapOfIntegerTransient_0.cxx \
GEOMDS_DataMapOfIntegerTransient_0.cxx
LIB_CLIENT_IDL =
LIB_SERVER_IDL =
# Executables targets
BIN =
BIN_SRC =
BIN_CLIENT_IDL =
BIN_SERVER_IDL =
# header files
EXPORT_HEADERS= GEOMDS_Application.hxx \
GEOMDS_DataMapOfIntegerTransient.hxx \
Handle_GEOMDS_DataMapNodeOfDataMapOfIntegerTransient.hxx \
Handle_GEOMDS_Application.hxx \
GEOMDS_Commands.hxx \
GEOMDS_Explorer.hxx
# additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES)
CXXFLAGS += $(OCC_CXXFLAGS)
LDFLAGS += $(OCC_LIBS)
# additional file to be cleaned
MOSTLYCLEAN =
CLEAN =
DISTCLEAN =
@CONCLUDE@

View File

@ -0,0 +1,134 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_EdgeFilter.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_EdgeFilter.ixx"
#include "GEOM_Client.hxx"
#include "SALOME_InteractiveObject.hxx"
#include "GEOM_InteractiveObject.hxx"
#include "GEOM_ShapeTypeFilter.hxx"
#include "SALOME_TypeFilter.hxx"
#include "utilities.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
// Open CASCADE Includes
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
static GEOM_Client ShapeReader;
/*!
enumeration TypeOfEdge is AnyEdge,Line,Circle;
*/
GEOM_EdgeFilter::GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge,
GEOM::GEOM_Gen_ptr geom)
{
myKind = Edge;
myComponentGeom = GEOM::GEOM_Gen::_narrow(geom);
}
Standard_Boolean GEOM_EdgeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const
{
Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" );
if ( !GeomFilter->IsOk(anObj) )
return false;
Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myComponentGeom );
if ( !GeomShapeTypeFilter->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() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
switch (myKind) {
case StdSelect_AnyEdge:
return Standard_True;
case StdSelect_Line:
{
BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
return (curv.GetType() == GeomAbs_Line);
}
break;
case StdSelect_Circle:
BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
return (curv.GetType() == GeomAbs_Circle);
}
}
}
}
if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GObject =
Handle(GEOM_InteractiveObject)::DownCast(anObj);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
switch (myKind) {
case StdSelect_AnyEdge:
return Standard_True;
case StdSelect_Line:
{
BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
return (curv.GetType() == GeomAbs_Line);
}
break;
case StdSelect_Circle:
BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
return (curv.GetType() == GeomAbs_Circle);
}
}
return false;
}

View File

@ -0,0 +1,117 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_EdgeFilter.hxx
// Module : GEOM
#ifndef _GEOM_EdgeFilter_HeaderFile
#define _GEOM_EdgeFilter_HeaderFile
#ifndef _Handle_GEOM_EdgeFilter_HeaderFile
#include "Handle_GEOM_EdgeFilter.hxx"
#endif
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Filter.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// Open CASCADE Includes
#include <Standard.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Shape.hxx>
#include <StdSelect_TypeOfEdge.hxx>
class GEOM_EdgeFilter : 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 GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge,
GEOM::GEOM_Gen_ptr geom);
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const;
Standard_EXPORT ~GEOM_EdgeFilter();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOM_EdgeFilter_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
StdSelect_TypeOfEdge myKind;
GEOM::GEOM_Gen_var myComponentGeom;
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,83 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_EdgeFilter.ixx
// Module : GEOM
#include "GEOM_EdgeFilter.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOM_EdgeFilter::~GEOM_EdgeFilter() {}
Standard_EXPORT Handle_Standard_Type& GEOM_EdgeFilter_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("GEOM_EdgeFilter",
sizeof(GEOM_EdgeFilter),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOM_EdgeFilter) Handle(GEOM_EdgeFilter)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOM_EdgeFilter) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOM_EdgeFilter))) {
_anOtherObject = Handle(GEOM_EdgeFilter)((Handle(GEOM_EdgeFilter)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOM_EdgeFilter::DynamicType() const
{
return STANDARD_TYPE(GEOM_EdgeFilter) ;
}
Standard_Boolean GEOM_EdgeFilter::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOM_EdgeFilter) == AType || SALOME_Filter::IsKind(AType));
}
Handle_GEOM_EdgeFilter::~Handle_GEOM_EdgeFilter() {}

View File

@ -0,0 +1,29 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_EdgeFilter.jxx
// Module : GEOM
#ifndef _GEOM_EdgeFilter_HeaderFile
#include "GEOM_EdgeFilter.hxx"
#endif

View File

@ -0,0 +1,184 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_FaceFilter.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_FaceFilter.ixx"
#include "GEOM_Client.hxx"
#include "SALOME_InteractiveObject.hxx"
#include "GEOM_InteractiveObject.hxx"
#include "GEOM_ShapeTypeFilter.hxx"
#include "SALOME_TypeFilter.hxx"
#include "utilities.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
// Open CASCADE Includes
#include <BRepAdaptor_Surface.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
static GEOM_Client ShapeReader;
/*!
enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol,Cone;
*/
GEOM_FaceFilter::GEOM_FaceFilter(const StdSelect_TypeOfFace Face,
GEOM::GEOM_Gen_ptr geom)
{
myKind = Face;
myComponentGeom = GEOM::GEOM_Gen::_narrow(geom);
}
Standard_Boolean GEOM_FaceFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const
{
Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" );
if ( !GeomFilter->IsOk(anObj) )
return false;
Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_FACE, myComponentGeom );
if ( !GeomShapeTypeFilter->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() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
switch (myKind) {
case StdSelect_AnyFace:
return Standard_True;
case StdSelect_Plane:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Plane);
}
case StdSelect_Cylinder:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Cylinder);
}
case StdSelect_Sphere:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Sphere);
}
case StdSelect_Torus:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return ( surf.GetType() == GeomAbs_Torus);
}
case StdSelect_Revol:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return ( surf.GetType() == GeomAbs_Cylinder ||
surf.GetType() == GeomAbs_Cone ||
surf.GetType() == GeomAbs_Torus ||
surf.GetType() == GeomAbs_Sphere ||
surf.GetType() == GeomAbs_SurfaceOfRevolution );
}
case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Cone);
}
}
}
}
}
if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GObject =
Handle(GEOM_InteractiveObject)::DownCast(anObj);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
switch (myKind) {
case StdSelect_AnyFace:
return Standard_True;
case StdSelect_Plane:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Plane);
}
case StdSelect_Cylinder:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Cylinder);
}
case StdSelect_Sphere:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Sphere);
}
case StdSelect_Torus:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return ( surf.GetType() == GeomAbs_Torus);
}
case StdSelect_Revol:
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return ( surf.GetType() == GeomAbs_Cylinder ||
surf.GetType() == GeomAbs_Cone ||
surf.GetType() == GeomAbs_Torus ||
surf.GetType() == GeomAbs_Sphere ||
surf.GetType() == GeomAbs_SurfaceOfRevolution );
}
case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone
{
BRepAdaptor_Surface surf(TopoDS::Face(Shape));
return (surf.GetType() == GeomAbs_Cone);
}
}
}
return false;
}

View File

@ -0,0 +1,117 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_FaceFilter.hxx
// Module : GEOM
#ifndef _GEOM_FaceFilter_HeaderFile
#define _GEOM_FaceFilter_HeaderFile
#ifndef _Handle_GEOM_FaceFilter_HeaderFile
#include "Handle_GEOM_FaceFilter.hxx"
#endif
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Filter.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// Open CASCADE Includes
#include <Standard.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Shape.hxx>
#include <StdSelect_TypeOfFace.hxx>
class GEOM_FaceFilter : 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 GEOM_FaceFilter(const StdSelect_TypeOfFace Face,
GEOM::GEOM_Gen_ptr geom);
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const;
Standard_EXPORT ~GEOM_FaceFilter();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOM_FaceFilter_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
StdSelect_TypeOfFace myKind;
GEOM::GEOM_Gen_var myComponentGeom;
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,83 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_FaceFilter.ixx
// Module : GEOM
#include "GEOM_FaceFilter.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOM_FaceFilter::~GEOM_FaceFilter() {}
Standard_EXPORT Handle_Standard_Type& GEOM_FaceFilter_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("GEOM_FaceFilter",
sizeof(GEOM_FaceFilter),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOM_FaceFilter) Handle(GEOM_FaceFilter)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOM_FaceFilter) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOM_FaceFilter))) {
_anOtherObject = Handle(GEOM_FaceFilter)((Handle(GEOM_FaceFilter)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOM_FaceFilter::DynamicType() const
{
return STANDARD_TYPE(GEOM_FaceFilter) ;
}
Standard_Boolean GEOM_FaceFilter::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOM_FaceFilter) == AType || SALOME_Filter::IsKind(AType));
}
Handle_GEOM_FaceFilter::~Handle_GEOM_FaceFilter() {}

View File

@ -0,0 +1,29 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_FaceFilter.jxx
// Module : GEOM
#ifndef _GEOM_FaceFilter_HeaderFile
#include "GEOM_FaceFilter.hxx"
#endif

View File

@ -0,0 +1,109 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_ShapeTypeFilter.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GEOM_ShapeTypeFilter.ixx"
#include "GEOM_Client.hxx"
#include "SALOME_InteractiveObject.hxx"
#include "GEOM_InteractiveObject.hxx"
#include "SALOME_TypeFilter.hxx"
#include "utilities.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
static GEOM_Client ShapeReader;
GEOM_ShapeTypeFilter::GEOM_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType,
GEOM::GEOM_Gen_ptr geom)
{
myKind = ShapeType;
myComponentGeom = GEOM::GEOM_Gen::_narrow(geom);
}
Standard_Boolean GEOM_ShapeTypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const
{
Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" );
if ( !GeomFilter->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() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
MESSAGE ( " myKind = " << myKind );
MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() );
if ( myKind == TopAbs_SHAPE )
return true;
if ( Shape.ShapeType() == myKind )
return true;
else
return false;
}
}
}
if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GObject =
Handle(GEOM_InteractiveObject)::DownCast(anObj);
GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() );
if ( aShape->_is_nil() )
return false;
TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
if ( Shape.IsNull() )
return false;
MESSAGE ( " myKind = " << myKind );
MESSAGE ( " Shape.ShapeType = " << Shape.ShapeType() );
if ( myKind == TopAbs_SHAPE )
return true;
if ( Shape.ShapeType() == myKind )
return true;
else
return false;
}
return false;
}

View File

@ -0,0 +1,115 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_ShapeTypeFilter.hxx
// Module : GEOM
#ifndef _GEOM_ShapeTypeFilter_HeaderFile
#define _GEOM_ShapeTypeFilter_HeaderFile
#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile
#include "Handle_GEOM_ShapeTypeFilter.hxx"
#endif
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Filter.hxx"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Shape)
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
// Open CASCADE Includes
#include <Standard.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Shape.hxx>
class GEOM_ShapeTypeFilter : 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 GEOM_ShapeTypeFilter(TopAbs_ShapeEnum ShapeType,
GEOM::GEOM_Gen_ptr geom);
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const;
Standard_EXPORT ~GEOM_ShapeTypeFilter();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOM_ShapeTypeFilter_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
TopAbs_ShapeEnum myKind;
GEOM::GEOM_Gen_var myComponentGeom;
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
};
// other inline functions and methods (like "C++: function call" methods)
//
#endif

View File

@ -0,0 +1,83 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_ShapeTypeFilter.ixx
// Module : GEOM
#include "GEOM_ShapeTypeFilter.jxx"
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
GEOM_ShapeTypeFilter::~GEOM_ShapeTypeFilter() {}
Standard_EXPORT Handle_Standard_Type& GEOM_ShapeTypeFilter_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("GEOM_ShapeTypeFilter",
sizeof(GEOM_ShapeTypeFilter),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
// DownCast method
// allow safe downcasting
//
const Handle(GEOM_ShapeTypeFilter) Handle(GEOM_ShapeTypeFilter)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOM_ShapeTypeFilter) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOM_ShapeTypeFilter))) {
_anOtherObject = Handle(GEOM_ShapeTypeFilter)((Handle(GEOM_ShapeTypeFilter)&)AnObject);
}
}
return _anOtherObject ;
}
const Handle(Standard_Type)& GEOM_ShapeTypeFilter::DynamicType() const
{
return STANDARD_TYPE(GEOM_ShapeTypeFilter) ;
}
Standard_Boolean GEOM_ShapeTypeFilter::IsKind(const Handle(Standard_Type)& AType) const
{
return (STANDARD_TYPE(GEOM_ShapeTypeFilter) == AType || SALOME_Filter::IsKind(AType));
}
Handle_GEOM_ShapeTypeFilter::~Handle_GEOM_ShapeTypeFilter() {}

View File

@ -0,0 +1,29 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GEOM_ShapeTypeFilter.jxx
// Module : GEOM
#ifndef _GEOM_ShapeTypeFilter_HeaderFile
#include "GEOM_ShapeTypeFilter.hxx"
#endif

View File

@ -0,0 +1,100 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOM_EdgeFilter.hxx
// Module : GEOM
#ifndef _Handle_GEOM_EdgeFilter_HeaderFile
#define _Handle_GEOM_EdgeFilter_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 GEOM_EdgeFilter;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_EdgeFilter);
class Handle(GEOM_EdgeFilter) : 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(GEOM_EdgeFilter)():Handle(SALOME_Filter)() {}
Handle(GEOM_EdgeFilter)(const Handle(GEOM_EdgeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle)
{
}
Handle(GEOM_EdgeFilter)(const GEOM_EdgeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem)
{
}
Handle(GEOM_EdgeFilter)& operator=(const Handle(GEOM_EdgeFilter)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOM_EdgeFilter)& operator=(const GEOM_EdgeFilter* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOM_EdgeFilter* operator->()
{
return (GEOM_EdgeFilter *)ControlAccess();
}
GEOM_EdgeFilter* operator->() const
{
return (GEOM_EdgeFilter *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOM_EdgeFilter)();
Standard_EXPORT static const Handle(GEOM_EdgeFilter) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -0,0 +1,100 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOM_FaceFilter.hxx
// Module : GEOM
#ifndef _Handle_GEOM_FaceFilter_HeaderFile
#define _Handle_GEOM_FaceFilter_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 GEOM_FaceFilter;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_FaceFilter);
class Handle(GEOM_FaceFilter) : 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(GEOM_FaceFilter)():Handle(SALOME_Filter)() {}
Handle(GEOM_FaceFilter)(const Handle(GEOM_FaceFilter)& aHandle) : Handle(SALOME_Filter)(aHandle)
{
}
Handle(GEOM_FaceFilter)(const GEOM_FaceFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem)
{
}
Handle(GEOM_FaceFilter)& operator=(const Handle(GEOM_FaceFilter)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOM_FaceFilter)& operator=(const GEOM_FaceFilter* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOM_FaceFilter* operator->()
{
return (GEOM_FaceFilter *)ControlAccess();
}
GEOM_FaceFilter* operator->() const
{
return (GEOM_FaceFilter *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOM_FaceFilter)();
Standard_EXPORT static const Handle(GEOM_FaceFilter) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -0,0 +1,100 @@
// GEOM GEOMFiltersSelection : filter selector for the viewer
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : Handle_GEOM_ShapeTypeFilter.hxx
// Module : GEOM
#ifndef _Handle_GEOM_ShapeTypeFilter_HeaderFile
#define _Handle_GEOM_ShapeTypeFilter_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 GEOM_ShapeTypeFilter;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_ShapeTypeFilter);
class Handle(GEOM_ShapeTypeFilter) : 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(GEOM_ShapeTypeFilter)():Handle(SALOME_Filter)() {}
Handle(GEOM_ShapeTypeFilter)(const Handle(GEOM_ShapeTypeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle)
{
}
Handle(GEOM_ShapeTypeFilter)(const GEOM_ShapeTypeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem)
{
}
Handle(GEOM_ShapeTypeFilter)& operator=(const Handle(GEOM_ShapeTypeFilter)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOM_ShapeTypeFilter)& operator=(const GEOM_ShapeTypeFilter* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOM_ShapeTypeFilter* operator->()
{
return (GEOM_ShapeTypeFilter *)ControlAccess();
}
GEOM_ShapeTypeFilter* operator->() const
{
return (GEOM_ShapeTypeFilter *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOM_ShapeTypeFilter)();
Standard_EXPORT static const Handle(GEOM_ShapeTypeFilter) DownCast(const Handle(Standard_Transient)& AnObject);
};
#endif

View File

@ -0,0 +1,65 @@
# GEOM GEOMFiltersSelection : filter selector for the viewer
#
# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#
#
#
# File : Makefile.in
# Author : Patrick GOLDBRONN (CEA)
# Module : GEOM
# $Header$
top_srcdir=@top_srcdir@
top_builddir=../../..
srcdir=@srcdir@
VPATH=.:@srcdir@:@top_srcdir@/idl
@COMMENCE@
# Libraries targets
LIB = libGeometryFiltersSelection.la
LIB_SRC = GEOM_ShapeTypeFilter.cxx \
GEOM_FaceFilter.cxx \
GEOM_EdgeFilter.cxx
LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
# header files
EXPORT_HEADERS= GEOM_ShapeTypeFilter.hxx \
Handle_GEOM_ShapeTypeFilter.hxx \
GEOM_FaceFilter.hxx \
Handle_GEOM_FaceFilter.hxx \
GEOM_EdgeFilter.hxx \
Handle_GEOM_EdgeFilter.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@

7147
GEOMGUI/GeometryGUI.cxx Normal file

File diff suppressed because it is too large Load Diff

341
GEOMGUI/GeometryGUI.h Normal file
View File

@ -0,0 +1,341 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef GeometryGUI_HeaderFile
#define GeometryGUI_HeaderFile
// SALOME Includes
#include "QAD_Desktop.h"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "GEOM_InteractiveObject.hxx"
#include "GEOM_AISShape.hxx"
#include "GEOM_Actor.h"
#include "GEOM_Sketcher.h"
// Open CASCADE Includes
#include <AIS_InteractiveContext.hxx>
#include <Standard.hxx>
#include <gp_Pnt.hxx>
#include <V3d_View.hxx>
#include <Quantity_Color.hxx>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
//=================================================================================
//
//=================================================================================
enum {
POINT_METHOD,
CURRENT_SKETCH
} ;
//=================================================================================
// class : GeometryGUI
// purpose :
//=================================================================================
class GeometryGUI : public QObject
{
Q_OBJECT /* for QT compatibility */
private :
QAD_Desktop* myDesktop;
QAD_Study* myActiveStudy;
GEOM::GEOM_Gen_var myComponentGeom;
QDialog* myActiveDialogBox; /* Unique active dialog box */
Handle(AIS_Shape) mySimulationShape; /* AIS shape used only during topo/geom simulations */
vtkActorCollection* mySimulationActor; /* GEOM Actor used only during topo/geom simulations */
int myNbGeom ; /* Unique name for a geom entity */
int myState ; /* Identify a method */
Sketch mySketcher;
Quantity_Color myShadingColor;
public :
GeometryGUI();
~GeometryGUI();
static GeometryGUI* GetOrCreateGeometryGUI( QAD_Desktop* desktop );
static GeometryGUI* GetGeometryGUI() ;
QAD_Study* GetActiveStudy() ;
QAD_Desktop* GetDesktop() ;
QDialog* GetActiveDialogBox() ; /* Returns the active DialogBox */
void SetActiveDialogBox(QDialog* aDlg) ; /* Sets 'myActiveDialogBox' a pointer to the active Dialog Box */
void SetState(int aState) ;
void ResetState() ; /* Sets myState = -1 a private field to indicate wich method is active */
bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
bool SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR);
void OnEditCopy ();
void OnEditDelete ();
void OnVTKDisplayOnly ();
void OnDisplayOnly ();
void OnDisplayAll ( bool onlyPreviousDisplayedObject = false );
void SetDisplayedObjectList();
bool AddInStudy( bool selection = false, const Handle(SALOME_InteractiveObject)& anIO = 0 );
bool Display( GEOM::GEOM_Shape_ptr aShape, Standard_CString name = "");
/* Import and export topology methods */
bool Import();
bool Export();
static int GetIndex(const TopoDS_Shape& subshape, const TopoDS_Shape& shape, int ShapeType) ;
static bool VertexToPoint(const TopoDS_Shape& S, gp_Pnt& P) ;
static void GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz) ;
static bool GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString ) ;
static bool LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2) ;
static gp_Pnt ConvertClickToPoint( Standard_Real x, Standard_Real y, Handle(V3d_View) aView ) ;
/* User dialog 1 parameter returned */
static double Parameter( Standard_Boolean& res,
const char* aValue1 = 0,
const char* aTitle1 = 0,
const char* aTitle = 0,
const double bottom = -1E6,
const double top = +1E6,
const int decimals = 6 ) ;
/* 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 Archimede( const Handle(SALOME_InteractiveObject)& IO, const double aWeight,
const double aWaterDensity, const double aMeshingDeflection );
void MakePointAndDisplay( const double x, const double y, const double z ) ;
void MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 );
void MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ;
void MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
const Standard_Real dy, const Standard_Real dz, const Standard_Real TrimSize ) ;
void MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius) ;
void MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius) ;
void MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint ) ;
void MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint) ;
void MakeCylinderAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
const double Radius, const double aHeight ) ;
void MakeConeAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
const double Radius1, const double Radius2, const double aHeight ) ;
void MakeTorusAndDisplay( const gp_Pnt BasePoint, const gp_Dir aDir,
const double Radius1, const double Radius2 ) ;
void MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2,
const short operation ) ;
void MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc,
const gp_Dir dir, Standard_Real revolAngle ) ;
void MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 ) ;
void MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase ) ;
void MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape, const short mindeg, const short maxdeg,
const double tol3d, const double tol2d, const short nbiter ) ;
void MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir,
const Standard_Real angle ) ;
void MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Vec V) ;
void MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes ) ;
void MakeMultiTranslation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir1, const double Step1, const short NbTimes1,
const gp_Dir Dir2, const double Step2, const short NbTimes2 ) ;
void MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes ) ;
void MakeMultiRotation2DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const double Ang,
const short NbTimes1, const double Step, const short NbTimes2 ) ;
void MakeCDGAndDisplay( GEOM::GEOM_Shape_ptr Shape );
void MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint,
const Standard_Real factor) ;
void MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 ) ;
void MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
const Standard_Real precision ) ;
void MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
void MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 ) ;
void MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape ) ;
void MakePartitionAndDisplay (const GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
const GEOM::GEOM_Gen::ListOfIOR& listToolsIOR,
const GEOM::GEOM_Gen::ListOfIOR& listKeepInsIOR,
const GEOM::GEOM_Gen::ListOfIOR& listRemoveInsIOR,
const GEOM::shape_type limit ) ;
void MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR ) ;
void MakeWorkingPlane( const gp_Pnt P, const gp_Dir D) ;
void MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar ) ;
/* Simulation management */
bool CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone ) ;
void DisplaySimulationShape(const TopoDS_Shape& S) ;
void EraseSimulationShape() ;
/* Selection and objects management */
TopoDS_Shape GetShapeFromIOR( QString IOR );
bool GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds) ;
int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
Standard_Boolean& testResult ) ;
Handle(GEOM_AISShape) ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
Standard_Boolean& testResult,
bool onlyInActiveView = false ) ;
Handle(GEOM_AISShape) ConvertIORinGEOMAISShape( const char * IOR,
Standard_Boolean& testResult,
bool onlyInActiveView = false ) ;
GEOM_Actor* ConvertIORinGEOMActor( const char * IOR,
Standard_Boolean& testResult,
bool onlyInActiveView = false ) ;
void ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
GEOM::GEOM_Gen::ListOfIOR& listIOR ) ;
/* Method used by dialog boxes called when used has entered a name of object in a LineEdit */
bool SelectionByNameInDialogs( QWidget* aWidget, const QString& userObjectName, SALOME_Selection *Sel ) ;
/* Method opening context for any sub shape selection */
bool PrepareSubShapeSelection( const int SubShapeType,
Standard_Integer& returnLocalContextId ) ;
/* Method opening context for sub shape selection on an argument shape */
bool PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
const int SubShapeType,
Standard_Integer& returnLocalContextId ) ;
/* Define a list of indices of sub shapes selected in a local context */
bool GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
const int SubShapeType,
GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
Standard_Integer& aLocalContextId,
bool& myUseLocalContext ) ;
/* Methods for sub shapes explode */
bool OnSubShapeGetAll( const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType) ;
bool OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
const char* ShapeTopoIOR,
const int SubShapeType,
Standard_Integer& aLocalContextId,
bool& myUseLocalContext ) ;
/* Remove faces in a shape */
bool OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
const char* ShapeTopoIOR,
const Standard_Integer& aLocalContextId,
bool& myUseLocalContext ) ;
/* Remove an hole in a topology (ListOfIdEndFace may be an empty list ) */
bool OnSuppressHole( const char* ShapeTopoIOR,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace ) ;
/* Remove one or more holes in a face or a shell */
bool OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires ) ;
/* Create a face corresponding to a hole on a shape */
bool OnFillingHole( const TopoDS_Shape& MainShape,
const char* ShapeTopoIOR,
const Standard_Integer& aLocalContextId,
bool& myUseLocalContext ) ;
/* Method for Fillet */
bool OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR) ;
bool OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
const char* ShapeTopoIOR,
const double Radius,
const int SubShapeType,
Standard_Integer& aLocalContextId,
bool& myUseLocalContext );
/* Methods for Chamfer */
bool OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR) ;
bool OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
const char* ShapeTopoIOR,
const double D1, const double D2, const int SubShapeType,
Standard_Integer& aLocalContextId,
bool& myUseLocalContext ) ;
/* Non modal dialog boxes magement */
void EmitSignalDeactivateDialog() ;
void EmitSignalCloseAllDialogs() ;
/* Sketcher management */
void OnSketchSegment();
void OnSketchArc();
void OnSketchSetAngle();
void OnSketchSetx();
void OnSketchSety();
void OnSketchDelete();
void OnSketchClose();
void OnSketchEnd();
void OnSketchOptionsOnoffangledimension();
void OnSketchOptionsOnofflengthdimension();
void OnSketchOptionsOnoffradiusdimension();
void OnSketchOptionsOnoffxdimension();
void OnSketchOptionsOnoffydimension();
void OnSettingsNoconstraint();
void OnSettingsPerpendicular();
void OnSettingsTangent();
signals:
void SignalDeactivateActiveDialog() ;
void SignalCloseAllDialogs() ;
void SignalDefaultStepValueChanged( double newVal ) ;
};
#endif

View File

@ -0,0 +1,507 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ArcDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_ArcDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Tools.h"
#include "utilities.h"
#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 : GeometryGUI_ArcDlg()
// purpose : Constructs a GeometryGUI_ArcDlg 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.
//=================================================================================
GeometryGUI_ArcDlg::GeometryGUI_ArcDlg( 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( "GeometryGUI",tr("ICON_DLG_ARC")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_ArcDlg" );
resize( 303, 251 );
setCaption( tr( "GEOM_ARC_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_ArcDlgLayout = new QGridLayout( this );
GeometryGUI_ArcDlgLayout->setSpacing( 6 );
GeometryGUI_ArcDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_ARC" ) );
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 );
GeometryGUI_ArcDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_POINTS" ) );
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( "GEOM_POINT_I" ).arg( "1" ) );
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 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_POINT_I" ).arg( "2" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_POINT_I" ).arg( "3" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
SelectButtonC1A3 = new QPushButton( GroupC1, "SelectButtonC1A3" );
SelectButtonC1A3->setText( tr( "" ) );
SelectButtonC1A3->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A3, 2, 1 );
LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
GeometryGUI_ArcDlgLayout->addWidget( GroupC1, 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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_ArcDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
/* Move widget on the botton right corner of main widget */
QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
/* Display Dialog */
this->show() ;
}
//=================================================================================
// function : ~GeometryGUI_ArcDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_ArcDlg::~GeometryGUI_ArcDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myOkPoint1 = myOkPoint2 = myOkPoint3 = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
mySelection->AddFilter(myVertexFilter) ;
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_ArcDlg::ConstructorsClicked(int constructorId)
{
/* only a constructor now */
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkPoint1 && myOkPoint2 && myOkPoint3 ) {
myGeomGUI->MakeArcAndDisplay( myPoint1, myPoint2, myPoint3 ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_ArcDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QString aString = ""; /* name of future selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
myEditCurrentArgument->setText("") ;
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
myEditCurrentArgument->setText("") ;
myOkPoint2 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A3 ) {
myEditCurrentArgument->setText("") ;
myOkPoint3 = false ;
}
return ;
}
// nbSel == 1 !
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint( S, this->myPoint1 ) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint( S, this->myPoint2 ) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint2 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A3 && myGeomGUI->VertexToPoint( S, this->myPoint3 ) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint3 = true ;
}
/* Simulation */
if( myOkPoint1 && myOkPoint2 && myOkPoint3 ) {
this->MakeArcSimulationAndDisplay() ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
mySelection->AddFilter(myVertexFilter) ;
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
}
else if(send == SelectButtonC1A3) {
LineEditC1A3->setFocus() ;
myEditCurrentArgument = LineEditC1A3;
}
SelectionIntoArgument() ;
break;
}
}
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else if ( send == LineEditC1A3 )
myEditCurrentArgument = LineEditC1A3 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : MakeArcSimulationAndDisplay()
// purpose :
//=================================================================================
void GeometryGUI_ArcDlg::MakeArcSimulationAndDisplay()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
try {
if ( myPoint2.IsEqual( myPoint1, Precision::Confusion() ) ) {
myEditCurrentArgument->setText("") ;
return;
}
if ( myPoint2.IsEqual( myPoint3, Precision::Confusion() ) ) {
myEditCurrentArgument->setText("") ;
return;
}
gp_Vec v1( this->myPoint2, this->myPoint1 ) ;
gp_Vec v2( this->myPoint2, this->myPoint3 ) ;
if( v1.IsParallel(v2, Precision::Angular() ) ) {
myEditCurrentArgument->setText("") ;
return ;
}
GC_MakeArcOfCircle Arc( this->myPoint1, this->myPoint2, this->myPoint3 );
if ( Arc.IsDone() ) {
Handle(Geom_TrimmedCurve) curve = Arc.Value() ;
mySimulationTopoDs = BRepBuilderAPI_MakeEdge(curve).Shape() ;
myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
}
}
catch(Standard_Failure) {
MESSAGE( "Exception catched in MakeArcSimulationAndDisplay" ) ;
}
return ;
}

View File

@ -0,0 +1,125 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ArcDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_ARC_H
#define DIALOGBOX_ARC_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <gp_Pnt.hxx>
#include <Precision.hxx>
#include <GC_MakeArcOfCircle.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom_TrimmedCurve.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_ArcDlg
// purpose :
//=================================================================================
class GeometryGUI_ArcDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_ArcDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_ArcDlg();
private :
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
gp_Pnt myPoint1 ;
gp_Pnt myPoint2 ;
gp_Pnt myPoint3;
bool myOkPoint1 ;
bool myOkPoint2;
bool myOkPoint3;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void Init( SALOME_Selection* Sel ) ;
void MakeArcSimulationAndDisplay() ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QLineEdit* LineEditC1A1;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A1;
QLabel* TextLabelC1A2;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A2;
QLabel* TextLabelC1A3;
QPushButton* SelectButtonC1A3;
QLineEdit* LineEditC1A3;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void LineEditReturnPressed() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_ArcDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ARC_H

View File

@ -0,0 +1,470 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ArchimedeDlg.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_ArchimedeDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Tools.h"
#include "utilities.h"
#include "SALOME_InteractiveObject.hxx"
#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 <qvalidator.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : GeometryGUI_ArchimedeDlg()
// purpose : Constructs a GeometryGUI_ArchimedeDlg 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.
//=================================================================================
GeometryGUI_ArchimedeDlg::GeometryGUI_ArchimedeDlg( 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( "GeometryGUI",tr("ICON_DLG_ARCHIMEDE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_ArchimedeDlg" );
resize( 303, 219 );
setCaption( tr( "GEOM_ARCHIMEDE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_ArchimedeDlgLayout = new QGridLayout( this );
GeometryGUI_ArchimedeDlgLayout->setSpacing( 6 );
GeometryGUI_ArchimedeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_ARCHIMEDE" ) );
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)3, (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 );
GeometryGUI_ArchimedeDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_ArchimedeDlgLayout->addWidget( GroupButtons, 2, 0 );
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) );
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 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
LineEditC1A2->setMinimumSize( QSize( 40, 0 ) );
LineEditC1A2->setMaximumSize( QSize( 32767, 32767 ) );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
LineEditC1A3->setMinimumSize( QSize( 40, 0 ) );
LineEditC1A3->setMaximumSize( QSize( 32767, 32767 ) );
GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" );
LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) );
LineEditC1A4->setMinimumSize( QSize( 40, 0 ) );
LineEditC1A4->setMaximumSize( QSize( 32767, 32767 ) );
GroupC1Layout->addWidget( LineEditC1A4, 3, 2 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_WEIGHT" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_WATER_DENSITY" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A3->setFrameShape( QLabel::NoFrame );
TextLabelC1A3->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
TextLabelC1A4->setText( tr( "GEOM_MESHING_DEFLECTION" ) );
TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A4->setFrameShape( QLabel::NoFrame );
TextLabelC1A4->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
GeometryGUI_ArchimedeDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
/* Move widget on the botton right corner of main widget */
QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
/* Display Dialog */
this->show() ;
}
//=================================================================================
// function : ~GeometryGUI_ArchimedeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_ArchimedeDlg::~GeometryGUI_ArchimedeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::Init( SALOME_Selection* Sel )
{
LineEditC1A2->setMaxLength( 10 );
LineEditC1A3->setMaxLength( 10 );
LineEditC1A4->setMaxLength( 10 );
this->myVa = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A2 ) ;
this->myVb = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A3 ) ;
this->myVc = new QDoubleValidator( 0, +999999.999, 3, LineEditC1A4 ) ;
LineEditC1A2->setValidator( myVa ) ;
LineEditC1A3->setValidator( myVb ) ;
LineEditC1A4->setValidator( myVc ) ;
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myWeight = 100.0 ;
LineEditC1A2->setText("100.0") ;
this->myWaterDensity = 1.0 ;
LineEditC1A3->setText("1.0") ;
this->myMeshingDeflection = 0.01 ;
LineEditC1A4->setText("0.01") ;
myOkWeight = myOkWaterDensity = myOkMeshingDeflection = true ;
myOkIO = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( LineEditC1A2, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( LineEditC1A3, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( LineEditC1A4, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_ArchimedeDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkIO && myOkWeight && myOkWaterDensity && myOkMeshingDeflection ) {
myGeomGUI->Archimede( myIO, myWeight, myWaterDensity, myMeshingDeflection );
}
}
break ;
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::ClickOnCancel()
{
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_ArchimedeDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = "";
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
myEditCurrentArgument->setText("") ;
myOkIO = false ;
}
else {
myEditCurrentArgument->setText(aString) ;
myIO = mySelection->firstIObject();
myOkIO = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::TextChangedInLineEdit(const QString& newText)
{
QLineEdit* send = (QLineEdit*)sender();
QString newT = strdup(newText) ;
int i ;
if(send == LineEditC1A2) {
if( myVa->validate(newT, i) == myVa->Acceptable ) {
this->myWeight = newText.toFloat() ;
myOkWeight = true ;
}
else {
myOkWeight = false ;
}
}
else if(send == LineEditC1A3) {
if( myVb->validate(newT, i) == myVb->Acceptable ) {
this->myWaterDensity = newText.toFloat() ;
myOkWaterDensity = true ;
}
else {
myOkWaterDensity = false ;
}
}
else if(send == LineEditC1A4) {
if( myVc->validate(newT, i) == myVc->Acceptable ) {
this->myMeshingDeflection = newText.toFloat() ;
myOkMeshingDeflection = true ;
}
else {
myOkMeshingDeflection = false ;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_ArchimedeDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,127 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ArchimedeDlg.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_ARCHIMEDE_H
#define DIALOGBOX_ARCHIMEDE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_ArchimedeDlg
// purpose :
//=================================================================================
class GeometryGUI_ArchimedeDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_ArchimedeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_ArchimedeDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
Handle(SALOME_InteractiveObject) myIO ;
Standard_Real myWeight ;
Standard_Real myWaterDensity ;
Standard_Real myMeshingDeflection ;
bool myOkIO ;
bool myOkWeight ;
bool myOkWaterDensity ;
bool myOkMeshingDeflection ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QDoubleValidator *myVa ; /* Double validator for numeric input */
QDoubleValidator *myVb ; /* Double validator for numeric input */
QDoubleValidator *myVc ; /* Double validator for numeric input */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QGroupBox* GroupC1;
QLineEdit* LineEditC1A1;
QLineEdit* LineEditC1A2;
QLineEdit* LineEditC1A3;
QLineEdit* LineEditC1A4;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A1;
QLabel* TextLabelC1A2;
QLabel* TextLabelC1A3;
QLabel* TextLabelC1A4;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void TextChangedInLineEdit(const QString&) ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_ArchimedeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_ARCHIMEDE_H

View File

@ -0,0 +1,487 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_BndBoxDlg.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_BndBoxDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepBndLib.hxx>
#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 : GeometryGUI_BndBoxDlg()
// purpose : Constructs a GeometryGUI_BndBoxDlg 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.
//=================================================================================
GeometryGUI_BndBoxDlg::GeometryGUI_BndBoxDlg( 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( "GeometryGUI",tr("ICON_DLG_BOUNDING_BOX")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_BndBoxDlg" );
resize( 303, 275 );
setCaption( tr( "GEOM_BNDBOX_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_BndBoxDlgLayout = new QGridLayout( this );
GeometryGUI_BndBoxDlgLayout->setSpacing( 6 );
GeometryGUI_BndBoxDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_BNDBOX" ) );
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)3, (QSizePolicy::SizeType)0,
Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 60, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
GeometryGUI_BndBoxDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_BNDBOX_OBJDIM" ) );
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 );
LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
// GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 );
SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" );
SelectButtonC1A1->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
// GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
// GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 );
QHBoxLayout* bl = new QHBoxLayout;
bl->setMargin(0); bl->setSpacing(6);
bl->addWidget(TextLabelC1A1); bl->addWidget(SelectButtonC1A1); bl->addWidget(LineEditC1A1);
GroupConstructor1Layout->addMultiCellLayout(bl, 0, 0, 0, 2);
TextLabel_Min = new QLabel( GroupConstructor1, "TextLabel_Min" );
TextLabel_Min->setText( tr( "GEOM_MIN" ) );
TextLabel_Min->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Min->setFrameShape( QLabel::NoFrame );
TextLabel_Min->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Min, 1, 1 );
TextLabel_Max = new QLabel( GroupConstructor1, "TextLabel_Max" );
TextLabel_Max->setText( tr( "GEOM_MAX" ) );
TextLabel_Max->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Max->setFrameShape( QLabel::NoFrame );
TextLabel_Max->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Max, 1, 2 );
TextLabel_X = new QLabel( GroupConstructor1, "TextLabel_X" );
TextLabel_X->setText( tr( "GEOM_X" ) );
TextLabel_X->setMinimumSize( QSize( 50, 0 ) );
TextLabel_X->setFrameShape( QLabel::NoFrame );
TextLabel_X->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_X, 2, 0 );
LineEdit_MinX = new QLineEdit( GroupConstructor1, "LineEdit_MinX" );
LineEdit_MinX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinX->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinX->setEnabled( FALSE );
LineEdit_MinX->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinX, 2, 1 );
LineEdit_MaxX = new QLineEdit( GroupConstructor1, "LineEdit_MaxX" );
LineEdit_MaxX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxX->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxX->setEnabled( FALSE );
LineEdit_MaxX->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxX, 2, 2 );
TextLabel_Y = new QLabel( GroupConstructor1, "TextLabel_Y" );
TextLabel_Y->setText( tr( "GEOM_Y" ) );
TextLabel_Y->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Y->setFrameShape( QLabel::NoFrame );
TextLabel_Y->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Y, 3, 0 );
LineEdit_MinY = new QLineEdit( GroupConstructor1, "LineEdit_MinY" );
LineEdit_MinY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinY->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinY->setEnabled( FALSE );
LineEdit_MinY->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinY, 3, 1 );
LineEdit_MaxY = new QLineEdit( GroupConstructor1, "LineEdit_MaxY" );
LineEdit_MaxY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxY->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxY->setEnabled( FALSE );
LineEdit_MaxY->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxY, 3, 2 );
TextLabel_Z = new QLabel( GroupConstructor1, "TextLabel_Z" );
TextLabel_Z->setText( tr( "GEOM_Z" ) );
TextLabel_Z->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Z->setFrameShape( QLabel::NoFrame );
TextLabel_Z->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Z, 4, 0 );
LineEdit_MinZ = new QLineEdit( GroupConstructor1, "LineEdit_MinZ" );
LineEdit_MinZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinZ->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinZ->setEnabled( FALSE );
LineEdit_MinZ->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinZ, 4, 1 );
LineEdit_MaxZ = new QLineEdit( GroupConstructor1, "LineEdit_MaxZ" );
LineEdit_MaxZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxZ->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxZ->setEnabled( FALSE );
LineEdit_MaxZ->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxZ, 4, 2 );
GeometryGUI_BndBoxDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_8, 0, 0 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
GeometryGUI_BndBoxDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_BndBoxDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_BndBoxDlg::~GeometryGUI_BndBoxDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::Init( SALOME_Selection* Sel )
{
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
mySimulationTopoDs.Nullify() ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_BndBoxDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_BndBoxDlg::SelectionIntoArgument()
{
LineEdit_MinX->setText("") ;
LineEdit_MinY->setText("") ;
LineEdit_MinZ->setText("") ;
LineEdit_MaxX->setText("") ;
LineEdit_MaxY->setText("") ;
LineEdit_MaxZ->setText("") ;
myEditCurrentArgument->setText("") ;
mySimulationTopoDs.Nullify() ;
QString aString = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if( S.IsNull() ) {
myEditCurrentArgument->setText( "" );
return ;
}
LineEditC1A1->setText(aString) ;
this->CalculateAndDisplayBndBox(S) ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : CalculateAndDisplayBndBox()
// purpose :
//=================================================================================
void GeometryGUI_BndBoxDlg::CalculateAndDisplayBndBox(const TopoDS_Shape& S)
{
LineEdit_MinX->setText("") ;
LineEdit_MinY->setText("") ;
LineEdit_MinZ->setText("") ;
LineEdit_MaxX->setText("") ;
LineEdit_MaxY->setText("") ;
LineEdit_MaxZ->setText("") ;
if( S.IsNull() )
return ;
Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
Bnd_Box B;
try {
BRepBndLib::Add(S,B);
B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
LineEdit_MinX->setText( tr("%1").arg( axmin, 12, 'f', 6 ) ) ;
LineEdit_MinY->setText( tr("%1").arg( aymin, 12, 'f', 6 ) ) ;
LineEdit_MinZ->setText( tr("%1").arg( azmin, 12, 'f', 6 ) ) ;
LineEdit_MaxX->setText( tr("%1").arg( axmax, 12, 'f', 6 ) ) ;
LineEdit_MaxY->setText( tr("%1").arg( aymax, 12, 'f', 6 ) ) ;
LineEdit_MaxZ->setText( tr("%1").arg( azmax, 12, 'f', 6 ) ) ;
mySimulationTopoDs = BRepPrimAPI_MakeBox( gp_Pnt(axmin,aymin,azmin),
gp_Pnt(axmax,aymax,azmax) ).Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
catch(Standard_Failure) {
MESSAGE("Catch intercepted in CalculateAndDisplayBndBox()" << endl ) ;
}
return ;
}

View File

@ -0,0 +1,119 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_BndBoxDlg.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_BNDBOX_H
#define DIALOGBOX_BNDBOX_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#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 GeometryGUI;
//=================================================================================
// class : DialogBox_PROPERTIES
// purpose :
//=================================================================================
class GeometryGUI_BndBoxDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_BndBoxDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_BndBoxDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void CalculateAndDisplayBndBox(const TopoDS_Shape& S) ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A1;
QLabel* TextLabel_Min;
QLabel* TextLabel_Max;
QLabel* TextLabel_X;
QLabel* TextLabel_Y;
QLabel* TextLabel_Z;
QLineEdit* LineEdit_MinX;
QLineEdit* LineEdit_MinY;
QLineEdit* LineEdit_MinZ;
QLineEdit* LineEdit_MaxX;
QLineEdit* LineEdit_MaxY;
QLineEdit* LineEdit_MaxZ;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnCancel();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_BndBoxDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupConstructor1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_BNDBOX_H

View File

@ -0,0 +1,639 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_BoxDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_BoxDlg.h"
#include "GeometryGUI_SpinBox.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "utilities.h"
#include <qbuttongroup.h>
#include <qframe.h>
#include <qgroupbox.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 <qlabel.h>
#include <qvalidator.h>
#include <qevent.h>
#include <qmessagebox.h>
//=================================================================================
// class : GeometryGUI_BoxDlg()
// purpose : Constructs a GeometryGUI_BoxDlg 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.
//=================================================================================
GeometryGUI_BoxDlg::GeometryGUI_BoxDlg( 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( "GeometryGUI",tr("ICON_DLG_BOX_2P")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_BOX_DXYZ")));
if ( !name )
setName( "GeometryGUI_BoxDlg" );
resize( 335, 220 );
setCaption( tr( "GEOM_BOX_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_BoxDlgLayout = new QGridLayout( this );
GeometryGUI_BoxDlgLayout->setSpacing( 6 );
GeometryGUI_BoxDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_BOX" ) );
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_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_1, 0, 3 );
Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
Constructor1->setText( tr( "" ) );
Constructor1->setPixmap( image0 );
Constructor1->setChecked( TRUE );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
Constructor2->setText( tr( "" ) );
Constructor2->setPixmap( image2 );
Constructor2->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
GeometryGUI_BoxDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_BoxDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupPoints = new QGroupBox( this, "GroupPoints" );
GroupPoints->setGeometry( QRect( 10, 10, 280, 90 ) );
GroupPoints->setTitle( tr( "GEOM_DIAGONAL_POINTS" ) );
GroupPoints->setFrameShape( QGroupBox::Box );
GroupPoints->setFrameShadow( QGroupBox::Sunken );
GroupPoints->setColumnLayout(0, Qt::Vertical );
GroupPoints->layout()->setSpacing( 0 );
GroupPoints->layout()->setMargin( 0 );
GroupPointsLayout = new QGridLayout( GroupPoints->layout() );
GroupPointsLayout->setAlignment( Qt::AlignTop );
GroupPointsLayout->setSpacing( 6 );
GroupPointsLayout->setMargin( 11 );
SelectButtonPt2 = new QPushButton( GroupPoints, "SelectButtonPt2" );
SelectButtonPt2->setText( tr( "" ) );
SelectButtonPt2->setPixmap( image1 );
GroupPointsLayout->addWidget( SelectButtonPt2, 1, 1 );
LineEditPt1 = new QLineEdit( GroupPoints, "LineEditPt1" );
GroupPointsLayout->addWidget( LineEditPt1, 0, 2 );
LineEditPt2 = new QLineEdit( GroupPoints, "LineEditPt2" );
GroupPointsLayout->addWidget( LineEditPt2, 1, 2 );
SelectButtonPt1 = new QPushButton( GroupPoints, "SelectButtonPt1" );
SelectButtonPt1->setText( tr( "" ) );
SelectButtonPt1->setPixmap( image1 );
SelectButtonPt1->setToggleButton( FALSE );
GroupPointsLayout->addWidget( SelectButtonPt1, 0, 1 );
TextLabelPt1 = new QLabel( GroupPoints, "TextLabelPt1" );
TextLabelPt1->setText( tr( "GEOM_POINT_I" ).arg("1") );
TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
TextLabelPt1->setFrameShape( QLabel::NoFrame );
TextLabelPt1->setFrameShadow( QLabel::Plain );
GroupPointsLayout->addWidget( TextLabelPt1, 0, 0 );
TextLabelPt2 = new QLabel( GroupPoints, "TextLabelPt2" );
TextLabelPt2->setText( tr( "GEOM_POINT_I" ).arg("2") );
TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
GroupPointsLayout->addWidget( TextLabelPt2, 1, 0 );
GeometryGUI_BoxDlgLayout->addWidget( GroupPoints, 1, 0 );
/***************************************************************/
GroupDimensions = new QGroupBox( this, "GroupDimensions" );
GroupDimensions->setGeometry( QRect( 11, 75, 310, 80 ) );
GroupDimensions->setTitle( tr( "GEOM_BOX_OBJ" ) );
GroupDimensions->setColumnLayout(0, Qt::Vertical );
GroupDimensions->setMinimumSize( QSize( 0, 90 ) );
GroupDimensions->layout()->setSpacing( 0 );
GroupDimensions->layout()->setMargin( 0 );
GroupDimensionsLayout = new QGridLayout( GroupDimensions->layout() );
GroupDimensionsLayout->setAlignment( Qt::AlignTop );
GroupDimensionsLayout->setSpacing( 6 );
GroupDimensionsLayout->setMargin( 11 );
TextLabel_DZ = new QLabel( GroupDimensions, "TextLabel_DZ" );
TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
GroupDimensionsLayout->addWidget( TextLabel_DZ, 0, 4 );
TextLabel_DY = new QLabel( GroupDimensions, "TextLabel_DY" );
TextLabel_DY->setText( tr( "GEOM_DY" ) );
GroupDimensionsLayout->addWidget( TextLabel_DY, 0, 2 );
TextLabel_DX = new QLabel( GroupDimensions, "TextLabel_DX" );
TextLabel_DX->setText( tr( "GEOM_DX" ) );
GroupDimensionsLayout->addWidget( TextLabel_DX, 0, 0 );
/* Spin boxes construction */
SpinBox_DX = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DX" ) ;
GroupDimensionsLayout->addWidget( SpinBox_DX, 0, 1 );
SpinBox_DY = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DY" ) ;
GroupDimensionsLayout->addWidget( SpinBox_DY, 0, 3 );
SpinBox_DZ = new GeometryGUI_SpinBox( GroupDimensions, "GeomSpinBox_DZ" ) ;
GroupDimensionsLayout->addWidget( SpinBox_DZ, 0, 5 );
QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupDimensionsLayout->addItem( spacer1, 1, 3 );
GeometryGUI_BoxDlgLayout->addWidget( GroupDimensions, 1, 0 );
/* Initialisations */
Init(Sel) ;
}
//=================================================================================
// function : ~DialogBox_Box()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_BoxDlg::~GeometryGUI_BoxDlg()
{
// no need to delete child widgets, Qt does it all for us
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::Init(SALOME_Selection *Sel)
{
/* Get setting of step value from file configuration */
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes */
SpinBox_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
SpinBox_DX->SetValue( 200.0 ) ;
SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
SpinBox_DY->SetValue( 200.0 ) ;
SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
SpinBox_DZ->SetValue( 200.0 ) ;
GroupPoints->show();
GroupDimensions->hide() ;
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditPt1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myPoint1.SetCoord( 0.0, 0.0, 0.0 );
myPoint2.SetCoord( 0.0, 0.0, 0.0 );
myOkPoint1 = myOkPoint2 = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO previous selection into argument ?
/* Vertices Filter for all arguments */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
mySelection->AddFilter( myVertexFilter ); /* filter for next selection */
/* 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) ), this, SLOT( ConstructorsClicked(int) ) ) ;
connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SpinBox_DX, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_DY, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_DZ, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL ( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ;
/* To close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_BoxDlg::ConstructorsClicked(int constructorId)
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupPoints->show();
GroupDimensions->hide() ;
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditPt1 ;
Constructor1->setChecked( TRUE );
LineEditPt1->setText("") ;
LineEditPt2->setText("") ;
myOkPoint1 = myOkPoint2 = false ;
/* filter for next selection */
mySelection->AddFilter( myVertexFilter );
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break;
}
case 1:
{
GroupPoints->hide();
GroupDimensions->show();
myConstructorId = constructorId ;
myOkPoint1 = myOkPoint2 = false ;
disconnect( mySelection, 0, this, 0 );
double initValue = 200.0 ;
SpinBox_DX->SetValue( initValue ) ;
SpinBox_DY->SetValue( initValue ) ;
SpinBox_DZ->SetValue( initValue ) ;
myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
myPoint2.SetCoord( initValue, initValue,initValue ) ;
mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::ClickOnApply()
{
//NRI+ : 02/12/2202 - BugID 1065
// if (mySimulationTopoDs.IsNull())
// return;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
//NRI+ : 02/12/2202 - BugID 1065 mySelection->ClearFilters() ;
if(myOkPoint1 && myOkPoint2)
myGeomGUI->MakeBoxAndDisplay( myPoint1, myPoint2 ) ;
break ;
}
case 1 :
{
/* Recup args and call method */
double vx = SpinBox_DX->GetValue() ;
double vy = SpinBox_DY->GetValue() ;
double vz = SpinBox_DZ->GetValue() ;
myPoint1.SetCoord(0.0, 0.0, 0.0) ;
myPoint2.SetCoord(vx, vy, vz) ;
myGeomGUI->MakeBoxAndDisplay( myPoint1, myPoint2 ) ;
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed
//=================================================================================
void GeometryGUI_BoxDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QString aString = "" ; /* name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditPt1 ) {
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditPt2 ) {
myOkPoint2 = false ;
}
return ;
}
// nbSel == 1
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
myEditCurrentArgument->setText( aString ) ;
myOkPoint1 = true ;
}
else if ( myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
myEditCurrentArgument->setText( aString ) ;
myOkPoint2 = true ;
}
if( myOkPoint1 && myOkPoint2 && TestBoxDimensions( myPoint1, myPoint2 ) ) {
mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: // default constructor
{
if(send == SelectButtonPt1) {
LineEditPt1->setFocus() ;
myEditCurrentArgument = LineEditPt1;
}
else if(send == SelectButtonPt2) {
LineEditPt2->setFocus() ;
myEditCurrentArgument = LineEditPt2;
}
mySelection->AddFilter(myVertexFilter) ;
SelectionIntoArgument() ;
break;
}
case 1:
{
/* nothing to do here */
break;
}
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::ValueChangedInSpinBox( double newValue )
{
if(myConstructorId != 1)
return ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QObject* send = (QObject*)sender() ;
double vx, vy, vz ;
if( send == SpinBox_DX ) {
vx = newValue ;
vy = SpinBox_DY->GetValue() ;
vz = SpinBox_DZ->GetValue() ;
} else if ( send == SpinBox_DY ) {
vx = SpinBox_DX->GetValue() ;
vy = newValue ;
vz = SpinBox_DZ->GetValue() ;
} else if (send == SpinBox_DZ ) {
vx = SpinBox_DX->GetValue() ;
vy = SpinBox_DY->GetValue() ;
vz = newValue ;
}
myPoint1.SetCoord(0.0, 0.0, 0.0) ;
myPoint2.SetCoord(vx, vy, vz) ;
if ( TestBoxDimensions( myPoint1, myPoint2 ) ) {
mySimulationTopoDs = BRepPrimAPI_MakeBox( myPoint1, myPoint2 ).Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditPt1 )
myEditCurrentArgument = LineEditPt1 ;
else if ( send == LineEditPt2 )
myEditCurrentArgument = LineEditPt2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupDimensions->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
GroupPoints->setEnabled(false) ;
mySelection->ClearFilters() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->SetActiveDialogBox(0) ;
myGeomGUI->EraseSimulationShape() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupDimensions->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
GroupPoints->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent [REDEFINED]
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_BoxDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : TestBoxDimensions()
// purpose :
//=================================================================================
bool GeometryGUI_BoxDlg::TestBoxDimensions(gp_Pnt P1, gp_Pnt P2)
{
if ( ( fabs( P1.X() - P2.X() ) > Precision::Confusion() ) &&
( fabs( P1.Y() - P2.Y() ) > Precision::Confusion() ) &&
( fabs( P1.Z() - P2.Z() ) > Precision::Confusion() ) )
return true ;
return false ;
}

View File

@ -0,0 +1,139 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_BoxDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_BOX_H
#define DIALOGBOX_BOX_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <gp_Pnt.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <Precision.hxx>
#include <qvariant.h>
#include <qdialog.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QLabel;
class QPushButton;
class GeometryGUI_SpinBox;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_BoxDlg
// purpose :
//=================================================================================
class GeometryGUI_BoxDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_BoxDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_BoxDlg();
private :
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e );
void Init(SALOME_Selection* Sel) ;
bool TestBoxDimensions( gp_Pnt P1, gp_Pnt P2 ) ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */
SALOME_Selection* mySelection ; /* User shape selection */
gp_Pnt myPoint1 ; /* Points containing the vector */
gp_Pnt myPoint2 ;
bool myOkPoint1 ; /* true when myPoint is defined */
bool myOkPoint2 ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QGroupBox* GroupPoints;
QPushButton* SelectButtonPt1;
QPushButton* SelectButtonPt2;
QLineEdit* LineEditPt2;
QLineEdit* LineEditPt1;
QLabel* TextLabelPt1;
QLabel* TextLabelPt2;
QGroupBox* GroupDimensions ;
QLabel* TextLabel_DX ;
QLabel* TextLabel_DY ;
QLabel* TextLabel_DZ ;
GeometryGUI_SpinBox* SpinBox_DX ;
GeometryGUI_SpinBox* SpinBox_DY ;
GeometryGUI_SpinBox* SpinBox_DZ ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_BoxDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupPointsLayout;
QGridLayout* GroupDimensionsLayout;
};
#endif // DIALOGBOX_BOX_H

View File

@ -0,0 +1,527 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CenterMassDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CenterMassDlg.h"
#include "GeometryGUI.h"
#include <BRepBuilderAPI_MakeVertex.hxx>
#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 <qvalidator.h>
#include <qpixmap.h>
//=================================================================================
// class : GeometryGUI_CenterMassDlg()
// purpose : Constructs a GeometryGUI_CenterMassDlg 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.
//=================================================================================
GeometryGUI_CenterMassDlg::GeometryGUI_CenterMassDlg( 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( "GeometryGUI",tr("ICON_DLG_CENTERMASS")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_CenterMassDlg" );
resize( 398, 219 );
setCaption( tr( "GEOM_CMASS_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CenterMassDlgLayout = new QGridLayout( this );
GeometryGUI_CenterMassDlgLayout->setSpacing( 6 );
GeometryGUI_CenterMassDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CenterMassDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CMASS" ) );
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_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 1 );
GeometryGUI_CenterMassDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT" ) );
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 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEdit_X = new QLineEdit( GroupC1, "LineEdit_X" );
LineEdit_X->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_X->sizePolicy().hasHeightForWidth() ) );
LineEdit_X->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_X->setEnabled( FALSE );
LineEdit_X->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_X, 1, 2 );
TextLabel_Z = new QLabel( GroupC1, "TextLabel_Z" );
TextLabel_Z->setText( tr( "GEOM_Z" ) );
TextLabel_Z->setMinimumSize( QSize( 15, 0 ) );
TextLabel_Z->setFrameShape( QLabel::NoFrame );
TextLabel_Z->setFrameShadow( QLabel::Plain );
TextLabel_Z->setMaximumSize( QSize( 15, 32767 ) );
GroupC1Layout->addWidget( TextLabel_Z, 1, 5 );
LineEdit_Z = new QLineEdit( GroupC1, "LineEdit_Z" );
LineEdit_Z->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Z->sizePolicy().hasHeightForWidth() ) );
LineEdit_Z->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_Z->setEnabled( FALSE );
LineEdit_Z->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_Z, 1, 6 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
LineEdit_Y = new QLineEdit( GroupC1, "LineEdit_Y" );
LineEdit_Y->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Y->sizePolicy().hasHeightForWidth() ) );
LineEdit_Y->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_Y->setEnabled( FALSE );
LineEdit_Y->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_Y, 1, 4 );
TextLabel_Y = new QLabel( GroupC1, "TextLabel_Y" );
TextLabel_Y->setText( tr( "GEOM_Y" ) );
TextLabel_Y->setMinimumSize( QSize( 15, 0 ) );
TextLabel_Y->setFrameShape( QLabel::NoFrame );
TextLabel_Y->setFrameShadow( QLabel::Plain );
TextLabel_Y->setMaximumSize( QSize( 15, 32767 ) );
GroupC1Layout->addWidget( TextLabel_Y, 1, 3 );
TextLabel_X = new QLabel( GroupC1, "TextLabel_X" );
TextLabel_X->setText( tr( "GEOM_X" ) );
TextLabel_X->setMinimumSize( QSize( 15, 0 ) );
TextLabel_X->setFrameShape( QLabel::NoFrame );
TextLabel_X->setFrameShadow( QLabel::Plain );
TextLabel_X->setMaximumSize( QSize( 15, 32767 ) );
GroupC1Layout->addWidget( TextLabel_X, 1, 1 );
TextLabel_Center = new QLabel( GroupC1, "TextLabel_Center" );
TextLabel_Center->setText( tr( "GEOM_CENTER" ) );
TextLabel_Center->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Center->setFrameShape( QLabel::NoFrame );
TextLabel_Center->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabel_Center, 1, 0 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setMinimumSize( QSize( 260, 0 ) );
GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 6 );
GeometryGUI_CenterMassDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_CenterMassDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CenterMassDlg::~GeometryGUI_CenterMassDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::Init( SALOME_Selection* Sel )
{
LineEdit_X->setMaxLength( 9 );
LineEdit_Y->setMaxLength( 9 );
LineEdit_Z->setMaxLength( 9 );
QDoubleValidator *Va = new QDoubleValidator( -999999, +999999, 3, LineEdit_X ) ;
QDoubleValidator *Vb = new QDoubleValidator( -999999, +999999, 3, LineEdit_Y ) ;
QDoubleValidator *Vc = new QDoubleValidator( -999999, +999999, 3, LineEdit_Z ) ;
LineEdit_X->setValidator( Va ) ;
LineEdit_Y->setValidator( Vb ) ;
LineEdit_Z->setValidator( Vc ) ;
myConstructorId = 0 ;
LineEdit_X->setText("") ;
LineEdit_Y->setText("") ;
LineEdit_Z->setText("") ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
mySimulationTopoDs.Nullify() ;
myShape.Nullify() ;
myOkCenterMass = false ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CenterMassDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
if( myOkCenterMass) {
myGeomGUI->MakeCDGAndDisplay( myGeomShape ) ;
}
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_CenterMassDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
myEditCurrentArgument->setText("") ;
myOkCenterMass = false ;
Standard_Boolean testResult ;
LineEdit_X->setText("") ;
LineEdit_Y->setText("") ;
LineEdit_Z->setText("") ;
QString aString = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
return ;
}
/* nbSel == 1 */
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, this->myShape) )
return ;
myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myEditCurrentArgument->setText(aString) ;
if( this->CalculateAndDisplayCenterMass() ) {
myOkCenterMass = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
myGeomGUI->EraseSimulationShape() ;
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CenterMassDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : CalculateAndDisplayCenterMass()
// purpose :
//=================================================================================
bool GeometryGUI_CenterMassDlg::CalculateAndDisplayCenterMass()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
try {
QString resString;
GProp_GProps System;
if ( this->myShape.ShapeType() == TopAbs_VERTEX) {
myGeomGUI->VertexToPoint( this->myShape, this->myCenterMass );
}
else if ( this->myShape.ShapeType() == TopAbs_EDGE || this->myShape.ShapeType() == TopAbs_WIRE ) {
BRepGProp::LinearProperties(this->myShape, System);
this->myCenterMass = System.CentreOfMass() ;
}
else if ( this->myShape.ShapeType() == TopAbs_FACE || this->myShape.ShapeType() == TopAbs_SHELL ) {
BRepGProp::SurfaceProperties(this->myShape, System);
this->myCenterMass = System.CentreOfMass() ;
}
else {
BRepGProp::VolumeProperties(this->myShape, System);
this->myCenterMass = System.CentreOfMass() ;
}
BRepBuilderAPI_MakeVertex V(this->myCenterMass) ;
mySimulationTopoDs = V.Shape() ;
resString = tr("%1").arg( myCenterMass.X(), 12, 'f', 6 ) ;
LineEdit_X->setText(resString) ;
resString = tr("%1").arg( myCenterMass.Y(), 12, 'f', 6 ) ;
LineEdit_Y->setText(resString) ;
resString = tr("%1").arg( myCenterMass.Z(), 12, 'f', 6 ) ;
LineEdit_Z->setText(resString) ;
if( !mySimulationTopoDs.IsNull() ) {
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return true ;
}
}
catch(Standard_Failure) {
MESSAGE("Catch intercepted in CalculateAndDisplayCenterMass()" << endl ) ;
}
return false ;
}

View File

@ -0,0 +1,121 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CenterMassDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
#ifndef DIALOGBOX_CMASS_H
#define DIALOGBOX_CMASS_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_CenterMassDlg
// purpose :
//=================================================================================
class GeometryGUI_CenterMassDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CenterMassDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CenterMassDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
bool CalculateAndDisplayCenterMass() ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
TopoDS_Shape myShape ; /* Shape argument */
gp_Pnt myCenterMass ;
bool myOkCenterMass ; /* true after center of mass simulation calculation */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEdit_X;
QLabel* TextLabel_Z;
QLineEdit* LineEdit_Z;
QLabel* TextLabelC1A1;
QLineEdit* LineEdit_Y;
QLabel* TextLabel_Y;
QLabel* TextLabel_X;
QLabel* TextLabel_Center;
QLineEdit* LineEditC1A1;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnCancel();
void ClickOnOk() ;
void ClickOnApply();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_CenterMassDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_CMASS_H

View File

@ -0,0 +1,934 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ChamferDlg.cxx
// Author : Damien COQUERET
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_ChamferDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "QAD_RightFrame.h"
#include "OCCViewer_Viewer3d.h"
#include "utilities.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 <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <BRepFilletAPI_MakeChamfer.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
//=================================================================================
// class : GeometryGUI_ChamferDlg()
// purpose : Constructs a GeometryGUI_ChamferDlg 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.
//=================================================================================
GeometryGUI_ChamferDlg::GeometryGUI_ChamferDlg( QWidget* parent,
const char* name,
SALOME_Selection* Sel,
Handle (AIS_InteractiveContext) ic,
bool modal,
WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
/***************************************************************/
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_ALL")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_EDGE")));
QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CHAMFER_FACE")));
if ( !name )
setName( "GeometryGUI_ChamferDlg" );
resize( 365, 220 );
setCaption( tr( "GEOM_CHAMFER_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_ChamferDlgLayout = new QGridLayout( this );
GeometryGUI_ChamferDlgLayout->setSpacing( 6 );
GeometryGUI_ChamferDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_ChamferDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CHAMFER" ) );
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 );
Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
Constructor2->setText( tr( "" ) );
Constructor2->setPixmap( image2 );
Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
Constructor2->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
Constructor3->setText( tr( "" ) );
Constructor3->setPixmap( image3 );
Constructor3->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
GeometryGUI_ChamferDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_CHAMFER_ALL" ) );
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( "GEOM_MAIN_OBJECT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_D1" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_D2" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A3->setFrameShape( QLabel::NoFrame );
TextLabelC1A3->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
// LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
// LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
// GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
// LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
// LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
// GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
GeometryGUI_ChamferDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupC2 = new QGroupBox( this, "GroupC2" );
GroupC2->setTitle( tr( "GEOM_CHAMFER_EDGES" ) );
GroupC2->setMinimumSize( QSize( 0, 0 ) );
GroupC2->setFrameShape( QGroupBox::Box );
GroupC2->setFrameShadow( QGroupBox::Sunken );
GroupC2->setColumnLayout(0, Qt::Vertical );
GroupC2->layout()->setSpacing( 0 );
GroupC2->layout()->setMargin( 0 );
GroupC2Layout = new QGridLayout( GroupC2->layout() );
GroupC2Layout->setAlignment( Qt::AlignTop );
GroupC2Layout->setSpacing( 6 );
GroupC2Layout->setMargin( 11 );
TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC2A1->setFrameShape( QLabel::NoFrame );
TextLabelC2A1->setFrameShadow( QLabel::Plain );
GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
TextLabelC2A2->setText( tr( "GEOM_D1" ) );
TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC2A2->setFrameShape( QLabel::NoFrame );
TextLabelC2A2->setFrameShadow( QLabel::Plain );
GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
TextLabelC2A3 = new QLabel( GroupC2, "TextLabelC2A3" );
TextLabelC2A3->setText( tr( "GEOM_D2" ) );
TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC2A3->setFrameShape( QLabel::NoFrame );
TextLabelC2A3->setFrameShadow( QLabel::Plain );
GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
// LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
// LineEditC2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A2->sizePolicy().hasHeightForWidth() ) );
// GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
// LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
// LineEditC2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC2A3->sizePolicy().hasHeightForWidth() ) );
// GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
SpinBox_C2A3 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A3" ) ;
SpinBox_C2A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A3->sizePolicy().hasHeightForWidth() ) );
GroupC2Layout->addWidget( SpinBox_C2A3, 2, 2 );
SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
SelectButtonC2A1->setText( tr( "" ) );
SelectButtonC2A1->setPixmap( image1 );
SelectButtonC2A1->setToggleButton( FALSE );
SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
GeometryGUI_ChamferDlgLayout->addWidget( GroupC2, 1, 0 );
/***************************************************************/
GroupC3 = new QGroupBox( this, "GroupC3" );
GroupC3->setTitle( tr( "GEOM_CHAMFER_FACES" ) );
GroupC3->setMinimumSize( QSize( 0, 0 ) );
GroupC3->setFrameShape( QGroupBox::Box );
GroupC3->setFrameShadow( QGroupBox::Sunken );
GroupC3->setColumnLayout(0, Qt::Vertical );
GroupC3->layout()->setSpacing( 0 );
GroupC3->layout()->setMargin( 0 );
GroupC3Layout = new QGridLayout( GroupC3->layout() );
GroupC3Layout->setAlignment( Qt::AlignTop );
GroupC3Layout->setSpacing( 6 );
GroupC3Layout->setMargin( 11 );
TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC3A1->setFrameShape( QLabel::NoFrame );
TextLabelC3A1->setFrameShadow( QLabel::Plain );
GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
TextLabelC3A2->setText( tr( "GEOM_D1" ) );
TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC3A2->setFrameShape( QLabel::NoFrame );
TextLabelC3A2->setFrameShadow( QLabel::Plain );
GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
TextLabelC3A3 = new QLabel( GroupC3, "TextLabelC3A3" );
TextLabelC3A3->setText( tr( "GEOM_D2" ) );
TextLabelC3A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC3A3->setFrameShape( QLabel::NoFrame );
TextLabelC3A3->setFrameShadow( QLabel::Plain );
GroupC3Layout->addWidget( TextLabelC3A3, 2, 0 );
LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
// LineEditC3A2 = new QLineEdit( GroupC3, "LineEditC3A2" );
// LineEditC3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A2->sizePolicy().hasHeightForWidth() ) );
// GroupC3Layout->addWidget( LineEditC3A2, 1, 2 );
// LineEditC3A3 = new QLineEdit( GroupC3, "LineEditC3A3" );
// LineEditC3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC3A3->sizePolicy().hasHeightForWidth() ) );
// GroupC3Layout->addWidget( LineEditC3A3, 2, 2 );
SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
SpinBox_C3A3 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A3" ) ;
SpinBox_C3A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A3->sizePolicy().hasHeightForWidth() ) );
GroupC3Layout->addWidget( SpinBox_C3A3, 2, 2 );
SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
SelectButtonC3A1->setText( tr( "" ) );
SelectButtonC3A1->setPixmap( image1 );
SelectButtonC3A1->setToggleButton( FALSE );
SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
GeometryGUI_ChamferDlgLayout->addWidget( GroupC3, 1, 0 );
/* Initialisation */
Init( Sel, ic ) ;
}
//=================================================================================
// function : ~GeometryGUI_ChamferDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_ChamferDlg::~GeometryGUI_ChamferDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
{
/* Get setting of step value from file configuration */
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes */
SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD1 */
SpinBox_C1A2->SetValue( 50 ) ;
SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* myD2 */
SpinBox_C1A3->SetValue( 50 ) ;
SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C2A2->SetValue( 50 ) ;
SpinBox_C2A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C2A3->SetValue( 50 ) ;
SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C3A2->SetValue( 50 ) ;
SpinBox_C3A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C3A3->SetValue( 50 ) ;
GroupC1->show();
GroupC2->hide() ;
GroupC3->hide() ;
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
mySelection = Sel ;
myEditCurrentArgument = LineEditC1A1 ;
myShape.Nullify() ;
myD1 = 50.0 ;
myOkD1 = true ;
myD2 = 50.0 ;
myOkD2 = true ;
myIC = ic ;
myUseLocalContext = false ;
myOkShape = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
mySimulationTopoDs.Nullify() ;
/* Filters definition */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C3A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_ChamferDlg::ConstructorsClicked(int constructorId)
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myEditCurrentArgument->setText(tr("")) ;
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext();
if(myUseLocalContext ) {
myIC->CloseLocalContext(this->myLocalContextId);
myGeomGUI->OnDisplayAll(true) ;
myUseLocalContext = false ;
}
}
myOkShape = false ;
myD1 = 50.0 ;
myD2 = 50.0 ;
myOkD1 = true ;
myOkD2 = true ;
myConstructorId = constructorId ;
switch (constructorId)
{
case 0: /* Chamfer All */
{
GroupC1->show();
GroupC2->hide() ;
GroupC3->hide() ;
myEditCurrentArgument = LineEditC1A1 ;
SpinBox_C1A2->SetValue( 50 ) ;
SpinBox_C1A3->SetValue( 50 ) ;
LineEditC1A1->setText(tr("")) ;
myShapeType = -1;
break;
}
case 1: /* Chamfer edges */
{
myShapeType = 6;
GroupC1->hide();
GroupC2->show() ;
GroupC3->hide() ;
myEditCurrentArgument = LineEditC2A1 ;
SpinBox_C2A2->SetValue( 50 ) ;
SpinBox_C2A3->SetValue( 50 ) ;
LineEditC2A1->setText(tr("")) ;
break ;
}
case 2: /* Chamfer Faces */
{
myShapeType = 4;
GroupC1->hide();
GroupC2->hide() ;
GroupC3->show() ;
myEditCurrentArgument = LineEditC3A1 ;
SpinBox_C3A2->SetValue( 50 ) ;
SpinBox_C3A3->SetValue( 50 ) ;
LineEditC3A1->setText(tr("")) ;
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
bool testResult = false ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 : /* Chamfer All */
{
if(myOkD1 && myOkD2) {
if( myOkShape ) {
testResult = myGeomGUI->OnChamferGetAll( myShape, myD1, myD2, myShapeType, myShapeIOR ) ;
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
}
else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
case 1 : /* Chamfer Edge */
{
if(myOkD1 && myOkD2) {
if( myOkShape ) {
testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
myLocalContextId, myUseLocalContext );
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
}
else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
case 2 : /* Chamfer Face */
{
if(myOkD1 && myOkD2) {
if( myOkShape ) {
testResult = myGeomGUI->OnChamferGetSelected( myShape, myShapeIOR, myD1, myD2, myShapeType,
myLocalContextId, myUseLocalContext ) ;
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
}
else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext();
if(this->myUseLocalContext ) {
myIC->CloseLocalContext(this->myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
}
reject() ;
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_ChamferDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
/* Reset all arguments and local context when selection as changed */
this->ResetStateOfDialog() ;
/* Future name of argument */
QString aString = "";
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel == 1 ) {
TopoDS_Shape S ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if( !IO->hasEntry() ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
return ;
}
if ( !S.IsNull() && S.ShapeType() <= 2 ) {
if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
myEditCurrentArgument->setText(aString) ;
myShape = S ;
myOkShape = true ;
}
if ( IO->hasEntry() ) {
SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
myShapeIOR = anIOR->Value();
myOkShape = true ;
myShape = S ;
myEditCurrentArgument->setText(aString) ;
}
}
}
MakePreview();
}
} else
return;
if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
/* local context is defined into the method */
myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
myUseLocalContext = true ;
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
}
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC2A1 )
myEditCurrentArgument = LineEditC2A1 ;
else if ( send == LineEditC3A1 )
myEditCurrentArgument = LineEditC3A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0:
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
SelectionIntoArgument() ;
}
break;
}
case 1:
{
if(send ==SelectButtonC2A1 ) {
LineEditC2A1->setFocus() ;
myEditCurrentArgument = LineEditC2A1;
SelectionIntoArgument() ;
}
break;
}
case 2:
{
if(send ==SelectButtonC3A1 ) {
LineEditC3A1->setFocus() ;
myEditCurrentArgument = LineEditC3A1;
SelectionIntoArgument() ;
}
break;
}
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ValueChangedInSpinBox( double newValue )
{
QObject* send = (QObject*)sender();
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
if( send == SpinBox_C1A2 || send == SpinBox_C2A2 || send == SpinBox_C3A2 ) { /* D1 */
myD1 = newValue ;
myOkD1 = true ;
MakePreview();
return ;
}
if( send == SpinBox_C1A3 || send == SpinBox_C2A3 || send == SpinBox_C3A3 ) { /* D2 */
myD2 = newValue ;
myOkD2 = true ;
MakePreview();
return ;
}
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
this->ResetStateOfDialog() ;
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupC2->setEnabled(false) ;
GroupC3->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
myGeomGUI->SetActiveDialogBox(0) ;
myGeomGUI->OnDisplayAll(true) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupC2->setEnabled(true) ;
GroupC3->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::enterEvent( QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ResetStateOfDialog()
// purpose :
//=================================================================================
void GeometryGUI_ChamferDlg::ResetStateOfDialog()
{
this->myOkShape = false ;
this->myEditCurrentArgument->setText("") ;
/* Close its local contact if opened */
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext();
if(this->myUseLocalContext) {
myIC->CloseLocalContext(this->myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
}
return ;
}
void GeometryGUI_ChamferDlg::MakePreview()
{
TopoDS_Shape tds ;
try
{
BRepFilletAPI_MakeChamfer MC(myShape);
switch (myConstructorId)
{
case 0: /* Chamfer All */
{
TopTools_IndexedDataMapOfShapeListOfShape M;
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,M);
for (int i = 1;i<=M.Extent();i++)
{
TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
MC.Add(myD1, myD2,E,F);
}
tds = MC.Shape();
break;
}
// case 1: /* Chamfer edges */
// case 2: /* Chamfer Faces */
}
if (!tds.IsNull())
{
mySimulationTopoDs = tds;
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
}
catch(Standard_Failure)
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
}
}

View File

@ -0,0 +1,172 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ChamferDlg.h
// Author : Damien COQUERET
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CHAMFER_H
#define DIALOGBOX_CHAMFER_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include "GeometryGUI_SpinBox.h"
// Qt Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
// Open CASCADE Includes
#include <AIS_InteractiveContext.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QToolButton;
class QLabel;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_ChamferDlg
// purpose :
//=================================================================================
class GeometryGUI_ChamferDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_ChamferDlg( QWidget* parent = 0,
const char* name = 0,
SALOME_Selection* Sel = 0,
Handle (AIS_InteractiveContext) ic = 0,
bool modal = FALSE,
WFlags fl = 0 );
~GeometryGUI_ChamferDlg();
private :
void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void ResetStateOfDialog() ;
/* Interactive and local context management see also : bool myUseLocalContext() */
Handle (AIS_InteractiveContext) myIC ; /* Interactive context */
Standard_Integer myLocalContextId ; /* identify a local context used by this method */
bool myUseLocalContext ; /* true when this method as opened a local context */
QDoubleValidator *myVa ; /* Double validator for numeric input */
QDoubleValidator *myVb ; /* Double validator for numeric input */
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape ;
bool myOkShape ;
char* myShapeIOR ;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
int myShapeType ;
TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */
void MakePreview();
bool myOkD1 ;
double myD1 ;
bool myOkD2 ;
double myD2 ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QRadioButton* Constructor3;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A1;
GeometryGUI_SpinBox* SpinBox_C1A2 ;
QLabel* TextLabelC1A2;
GeometryGUI_SpinBox* SpinBox_C1A3 ;
QLabel* TextLabelC1A3;
QGroupBox* GroupC2;
QPushButton* SelectButtonC2A1;
QLineEdit* LineEditC2A1;
QLabel* TextLabelC2A1;
GeometryGUI_SpinBox* SpinBox_C2A2 ;
QLabel* TextLabelC2A2;
GeometryGUI_SpinBox* SpinBox_C2A3;
QLabel* TextLabelC2A3;
QGroupBox* GroupC3;
QPushButton* SelectButtonC3A1;
QLineEdit* LineEditC3A1;
QLabel* TextLabelC3A1;
GeometryGUI_SpinBox* SpinBox_C3A2 ;
QLabel* TextLabelC3A2;
GeometryGUI_SpinBox* SpinBox_C3A3;
QLabel* TextLabelC3A3;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_ChamferDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
QGridLayout* GroupC3Layout;
};
#endif // DIALOGBOX_CHAMFER_H

View File

@ -0,0 +1,402 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CheckShape.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CheckShape.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// Open Cascade Include
#include <BRepCheck_Analyzer.hxx>
// QT Includes
#include <qtextview.h>
#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 : GeometryGUI_CheckShape()
// purpose : Constructs a GeometryGUI_CheckShape 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.
//=================================================================================
GeometryGUI_CheckShape::GeometryGUI_CheckShape( 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( "GeometryGUI",tr("ICON_DLG_CHECKSHAPE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "DialogBox_CHECKSHAPE" );
resize( 303, 275 );
setCaption( tr( "GEOM_CHECK_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CheckShapeLayout = new QGridLayout( this );
GeometryGUI_CheckShapeLayout->setSpacing( 6 );
GeometryGUI_CheckShapeLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CHECK_SHAPE" ) );
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)3, (QSizePolicy::SizeType)0,
Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 60, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
GeometryGUI_CheckShapeLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_CHECK_INFOS") );
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 );
LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 );
SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 );
Text = new QTextView(GroupConstructor1);
Text->setTextFormat( Qt::PlainText );
GroupConstructor1Layout->addMultiCellWidget( Text, 1, 1, 0, 2 );
GeometryGUI_CheckShapeLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
// buttonApply = new QPushButton( GroupButtons, "buttonApply" );
// buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
// buttonApply->setAutoDefault( TRUE );
// GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_8, 0, 0 );
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( "GEOM_BUT_OK" ) );
// buttonOk->setAutoDefault( TRUE );
// buttonOk->setDefault( TRUE );
// GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CheckShapeLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_CheckShape()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CheckShape::~GeometryGUI_CheckShape()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::Init( SALOME_Selection* Sel )
{
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
SelectedName = "";
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CheckShape::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_CheckShape::SelectionIntoArgument()
{
Text->setText("") ;
myEditCurrentArgument->setText("") ;
SelectedName = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, SelectedName) ;
if ( nbSel != 1 ) {
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if( S.IsNull() ) {
myEditCurrentArgument->setText( "" );
return ;
}
LineEditC1A1->setText(SelectedName) ;
this->Check(S) ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : Check()
// purpose :
//=================================================================================
void GeometryGUI_CheckShape::Check(const TopoDS_Shape S)
{
if( S.IsNull() )
return ;
try {
BRepCheck_Analyzer ana(S,false);
if (ana.IsValid())
Text->setText( "This Shape seems to be valid." );
else
Text->setText( "This Shape is not valid." );
}
catch(Standard_Failure) {
MESSAGE("Catch intercepted in Check()" << endl ) ;
}
return ;
}

View File

@ -0,0 +1,110 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CheckShape.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CHECKSHAPE_H
#define DIALOGBOX_CHECKSHAPE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <Precision.hxx>
#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 QTextView;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_CheckShape
// purpose :
//=================================================================================
class GeometryGUI_CheckShape : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CheckShape( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CheckShape();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void Check(const TopoDS_Shape S) ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A1;
QTextView* Text;
QString SelectedName;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnCancel();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_CheckShapeLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupConstructor1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_CHECKSHAPE_H

View File

@ -0,0 +1,504 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CircleDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CircleDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "utilities.h"
#include <BRepAdaptor_Curve.hxx>
#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 <qvalidator.h>
#include <qpixmap.h>
//=================================================================================
// class : GeometryGUI_CircleDlg()
// purpose : Constructs a GeometryGUI_CircleDlg 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.
//=================================================================================
GeometryGUI_CircleDlg::GeometryGUI_CircleDlg( 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( "GeometryGUI",tr("ICON_DLG_CIRCLE_PV")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_CircleDlg" );
resize( 303, 251 );
setCaption( tr( "GEOM_CIRCLE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CircleDlgLayout = new QGridLayout( this );
GeometryGUI_CircleDlgLayout->setSpacing( 6 );
GeometryGUI_CircleDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
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 );
GeometryGUI_CircleDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_ARGUMENTS" ) );
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( "GEOM_CENTER_POINT" ) );
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 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_RADIUS" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 );
GeometryGUI_CircleDlgLayout->addWidget( GroupC1, 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 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
GeometryGUI_CircleDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_CircleDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CircleDlg::~GeometryGUI_CircleDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::Init( SALOME_Selection* Sel )
{
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes */
SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C1A3->SetValue( 100.0 ) ; /* = myRadius */
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myRadius = 100.0 ;
myOkPoint1 = myOkDir = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
mySelection->AddFilter(myVertexFilter) ; /* first filter used */
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CircleDlg::ConstructorsClicked(int constructorId)
{
/* only a constructor now */
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
switch(myConstructorId)
{
case 0 :
{
if(myOkPoint1 && myOkDir) {
myGeomGUI->MakeCircleAndDisplay( myPoint1, myDir, myRadius) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_CircleDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
/* Future name of selection */
QString aString = "";
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
LineEditC1A1->setText("") ;
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
LineEditC1A2->setText("") ;
myOkDir = false ;
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
/* gp_Pnt : not used */
if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
LineEditC1A1->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir) */) {
BRepAdaptor_Curve curv(TopoDS::Edge(S));
myDir = curv.Line().Direction();
LineEditC1A2->setText(aString) ;
myOkDir = true ;
}
if( myOkPoint1 && myOkDir ) {
MakeCircleSimulationAndDisplay() ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::SetEditCurrentArgument()
{
mySelection->ClearFilters() ;
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->AddFilter(myVertexFilter) ;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
mySelection->AddFilter(myEdgeFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::ValueChangedInSpinBox( double newValue )
{
myRadius = newValue ;
if (myOkPoint1 && myOkDir) {
MakeCircleSimulationAndDisplay() ;
}
else {
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : MakeCircleSimulationAndDisplay()
// purpose :
//=================================================================================
void GeometryGUI_CircleDlg::MakeCircleSimulationAndDisplay()
{
myGeomGUI->EraseSimulationShape() ;
try {
gp_Ax2 axis( this->myPoint1, this->myDir ) ;
gp_Circ circ( axis, this->myRadius);
BRepBuilderAPI_MakeEdge MakeEdge( circ );
mySimulationTopoDs = MakeEdge.Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
catch(Standard_Failure) {
MESSAGE( "Exception catched in MakeCircleSimulationAndDisplay" ) ;
}
return ;
}

View File

@ -0,0 +1,126 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CircleDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CIRCLE_H
#define DIALOGBOX_CIRCLE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include "GEOM_EdgeFilter.hxx"
#include "GeometryGUI_SpinBox.h"
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_CircleDlg
// purpose :
//=================================================================================
class GeometryGUI_CircleDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CircleDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CircleDlg();
private :
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
gp_Pnt myPoint1 ;
gp_Dir myDir ;
Standard_Real myRadius ;
bool myOkPoint1 ;
bool myOkDir ;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */
Handle(GEOM_EdgeFilter) myEdgeFilter;
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void Init( SALOME_Selection* Sel ) ;
void MakeCircleSimulationAndDisplay() ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A1;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A2;
QLineEdit* LineEditC1A2;
QLabel* TextLabelC1A1;
QLabel* TextLabelC1A3;
GeometryGUI_SpinBox* SpinBox_C1A3;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_CircleDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_CIRCLE_H

View File

@ -0,0 +1,467 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CommonDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CommonDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_CommonDlg()
// purpose : Constructs a GeometryGUI_CommonDlg 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.
//=================================================================================
GeometryGUI_CommonDlg::GeometryGUI_CommonDlg( 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( "GeometryGUI",tr("ICON_DLG_COMMON")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_CommonDlg" );
resize( 322, 220 );
setCaption( tr( "GEOM_COMMON_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CommonDlgLayout = new QGridLayout( this );
GeometryGUI_CommonDlgLayout->setSpacing( 6 );
GeometryGUI_CommonDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_COMMON" ) );
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 );
GeometryGUI_CommonDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_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 );
LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" );
LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 );
LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" );
LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 );
SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" );
SelectButtonC1A1Shape->setText( tr( "" ) );
SelectButtonC1A1Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 );
SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" );
SelectButtonC1A2Shape->setText( tr( "" ) );
SelectButtonC1A2Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 );
TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" );
TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") );
TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 );
TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" );
TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") );
TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 );
GeometryGUI_CommonDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CommonDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~GeometryGUI_CommonDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CommonDlg::~GeometryGUI_CommonDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myShape1.Nullify() ;
myShape2.Nullify() ;
myConstructorId = 0 ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Shape ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
// TODO previous selection into argument
/* 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( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CommonDlg::ConstructorsClicked(int constructorId)
{
GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Shape ;
LineEditC1A2Shape->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkShape1 && myOkShape2) {
myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 1 ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_CommonDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = ""; /* name of future selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myOkShape1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myOkShape2 = false ;
}
break ;
}
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape1 = S ;
LineEditC1A1Shape->setText(aString) ;
myOkShape1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape2 = S ;
LineEditC1A2Shape->setText(aString) ;
myOkShape2 = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Shape ) {
LineEditC1A1Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A1Shape ;
}
else if(send == SelectButtonC1A2Shape) {
LineEditC1A2Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A2Shape;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1Shape )
myEditCurrentArgument = LineEditC1A1Shape ;
else if ( send == LineEditC1A2Shape )
myEditCurrentArgument = LineEditC1A2Shape ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GeometryGUI_CommonDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CommonDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}

View File

@ -0,0 +1,119 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CommonDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_COMMON_H
#define DIALOGBOX_COMMON_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepAlgoAPI_Common.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_CommonDlg
// purpose :
//=================================================================================
class GeometryGUI_CommonDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CommonDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CommonDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape1 ; /* topology used */
TopoDS_Shape myShape2 ; /* topology used */
GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */
GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */
bool myOkShape1 ;
bool myOkShape2 ; /* to check when arguments are defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Shape;
QLineEdit* LineEditC1A2Shape;
QPushButton* SelectButtonC1A1Shape;
QPushButton* SelectButtonC1A2Shape;
QLabel* TextLabelC1A2Shape;
QLabel* TextLabelC1A1Shape;
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* GeometryGUI_CommonDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_COMMON_H

View File

@ -0,0 +1,375 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CompoundDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CompoundDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_CompoundDlg()
// purpose : Constructs a GeometryGUI_CompoundDlg 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.
//=================================================================================
GeometryGUI_CompoundDlg::GeometryGUI_CompoundDlg( 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( "GeometryGUI",tr("ICON_DLG_BUILD_COMPOUND")));
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_CompoundDlg" );
resize( 303, 175 );
setCaption( tr( "GEOM_COMPOUND_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CompoundDlgLayout = new QGridLayout( this );
GeometryGUI_CompoundDlgLayout->setSpacing( 6 );
GeometryGUI_CompoundDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_COMPOUND" ) );
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 );
GeometryGUI_CompoundDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CompoundDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_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( "GEOM_OBJECTS" ) );
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 );
GeometryGUI_CompoundDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_CompoundDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CompoundDlg::~GeometryGUI_CompoundDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkListShapes = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CompoundDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
if(myOkListShapes) {
myGeomGUI->MakeCompoundAndDisplay( myListShapes ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_CompoundDlg::SelectionIntoArgument()
{
/* All this for first constructor */
// if(myEditCurrentArgument == LineEditC1A1 )
myOkListShapes = false;
myEditCurrentArgument->setText("") ;
QString aString = ""; /* name of selection */
int nbSel = mySelection->IObjectCount() ;
if ( nbSel == 0 )
return;
aString = tr( "%1_objects" ).arg( nbSel );
myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ;
myEditCurrentArgument->setText(aString) ;
myOkListShapes = true ;
/* no simulation */
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::LineEditReturnPressed()
{
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CompoundDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,106 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CompoundDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_COMPOUND_H
#define DIALOGBOX_COMPOUND_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_CompoundDlg
// purpose :
//=================================================================================
class GeometryGUI_CompoundDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CompoundDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CompoundDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
GEOM::GEOM_Gen::ListOfIOR myListShapes ;
bool myOkListShapes ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
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 LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_CompoundDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_COMPOUND_H

View File

@ -0,0 +1,788 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ConeDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_ConeDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "utilities.h"
#include <BRepAdaptor_Curve.hxx>
#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 : GeometryGUI_ConeDlg()
// purpose : Constructs a GeometryGUI_ConeDlg 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.
//=================================================================================
GeometryGUI_ConeDlg::GeometryGUI_ConeDlg( 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( "GeometryGUI",tr("ICON_DLG_CONE_PV")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CONE_DXYZ")));
if ( !name )
setName( "GeometryGUI_ConeDlg" );
resize( 303, 309 );
setCaption( tr( "GEOM_CONE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_ConeDlgLayout = new QGridLayout( this );
GeometryGUI_ConeDlgLayout->setSpacing( 6 );
GeometryGUI_ConeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CONE" ) );
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() ) );
Constructor1->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
Constructor2->setText( tr( "" ) );
Constructor2->setMinimumSize( QSize( 50, 0 ) );
Constructor2->setPixmap( image2 );
Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
GeometryGUI_ConeDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_ConeDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_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 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A3->setFrameShape( QLabel::NoFrame );
TextLabelC1A3->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
SpinBox_C1A3 = new GeometryGUI_SpinBox(GroupC1, "GeomSpinBox_C1A3" ) ;
SpinBox_C1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A3->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A3 , 2, 2 );
TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
TextLabelC1A4->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A4->setFrameShape( QLabel::NoFrame );
TextLabelC1A4->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A4 , 3, 2 ) ;
TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
TextLabelC1A5->setText( tr( "GEOM_HEIGHT" ) );
TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A5->setFrameShape( QLabel::NoFrame );
TextLabelC1A5->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A5, 4, 0 );
SpinBox_C1A5 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A5" ) ;
SpinBox_C1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A5->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A5 , 4, 2 ) ;
GeometryGUI_ConeDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupC2 = new QGroupBox( this, "GroupC2" );
GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
GroupC2->setColumnLayout(0, Qt::Vertical );
GroupC2->layout()->setSpacing( 0 );
GroupC2->layout()->setMargin( 0 );
GroupC2Layout = new QGridLayout( GroupC2->layout() );
GroupC2Layout->setAlignment( Qt::AlignTop );
GroupC2Layout->setSpacing( 6 );
GroupC2Layout->setMargin( 11 );
TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) );
GroupC2Layout->addWidget( TextLabel_Height, 2, 0 );
TextLabel_Radius1 = new QLabel( GroupC2, "TextLabel_Radius1" );
TextLabel_Radius1->setText( tr( "GEOM_RADIUS_I" ).arg("1") );
GroupC2Layout->addWidget( TextLabel_Radius1, 0, 0 );
TextLabel_Radius2 = new QLabel( GroupC2, "TextLabel_Radius2" );
TextLabel_Radius2->setText( tr( "GEOM_RADIUS_I" ).arg("2") );
GroupC2Layout->addWidget( TextLabel_Radius2, 1, 0 );
SpinBox_Radius1 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius1" ) ;
GroupC2Layout->addWidget( SpinBox_Radius1 , 0, 1 ) ;
SpinBox_Radius2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius2" ) ;
GroupC2Layout->addWidget( SpinBox_Radius2 , 1, 1 ) ;
SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
GroupC2Layout->addWidget( SpinBox_Height , 2, 1 ) ;
QSpacerItem* spacer1 = new QSpacerItem( 20, 60, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC2Layout->addItem( spacer1 );
GeometryGUI_ConeDlgLayout->addWidget(GroupC2 , 1, 0 );
/***************************************************************/
/* Initialisations */
Init(Sel) ;
}
//=================================================================================
// function : ~GeometryGUI_ConeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_ConeDlg::~GeometryGUI_ConeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::Init( SALOME_Selection* Sel )
{
/* Get setting of step value from file configuration */
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes */
SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
SpinBox_C1A3->SetValue( 100.0 ) ;
SpinBox_C1A4->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
SpinBox_C1A4->SetValue( 0.0 ) ;
SpinBox_C1A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
SpinBox_C1A5->SetValue( 300.0 ) ;
SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; /* radius 1 */
SpinBox_Radius1->SetValue( 100.0 ) ;
SpinBox_Radius2->RangeStepAndValidator( 0.000, 999.999, step, 3 ) ; /* radius 2 */
SpinBox_Radius2->SetValue( 0.0 ) ;
SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* algebric height */
SpinBox_Height->SetValue( 300.0 ) ;
GroupC1->show();
GroupC2->hide();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myRadius1 = 100.0 ;
myRadius2 = 0.0 ;
myHeight = 300.0 ;
myOkRadius1 = true ;
myOkRadius2 = true ;
myOkHeight = true ;
myOkPoint1 = false ;
myOkDir = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
/* first filter used */
mySelection->AddFilter(myVertexFilter) ;
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C1A5, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Radius2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_ConeDlg::ConstructorsClicked(int constructorId)
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
switch(myConstructorId)
{
case 0 :
{
GroupC1->hide();
GroupC2->show();
myConstructorId = constructorId ;
myOkHeight = myOkRadius1 = myOkRadius2 = myOkPoint1 = myOkDir = true ;
SpinBox_Radius1->SetValue( 100.0 ) ; /* radius 1 */
SpinBox_Radius2->SetValue( 0.0 ) ; /* radius 2 */
SpinBox_Height->SetValue( 300.0 ) ; /* height */
disconnect( mySelection, 0, this, 0 );
myRadius1 = 100.0 ;
myRadius2 = 0.0 ;
myHeight = 300.0 ;
myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
if( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
MakeConeSimulationAndDisplay() ;
}
break ;
}
case 1 :
{
GroupC2->hide();
GroupC1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1 ;
myOkHeight = myOkRadius1 = myOkRadius2 = true ;
myOkPoint1 = myOkDir = false ;
SpinBox_C1A3->SetValue( 100.0 ) ; /* radius 1 */
SpinBox_C1A4->SetValue( 0.0 ) ; /* radius 2 */
SpinBox_C1A5->SetValue( 300.0 ) ; /* height */
myRadius1 = 100.0 ;
myRadius2 = 0.0 ;
myHeight = 300.0 ;
disconnect( mySelection, 0, this, 0 );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
}
break ;
}
case 1 :
{
if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
myGeomGUI->MakeConeAndDisplay( myPoint1, aDir, myRadius1, myRadius2, fabs(myHeight) ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_ConeDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
/* Future name of selection */
QString aString = "";
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
LineEditC1A1->setText("") ;
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
LineEditC1A2->setText("") ;
myOkDir = false ;
}
return ;
}
/* nbSel == 1 ! */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
/* gp_Pnt : not used */
if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
LineEditC1A1->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
BRepAdaptor_Curve curv(TopoDS::Edge(S));
myDir = curv.Line().Direction();
LineEditC1A2->setText(aString) ;
myOkDir = true ;
}
if( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
MakeConeSimulationAndDisplay() ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->AddFilter(myVertexFilter) ;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
mySelection->AddFilter(myEdgeFilter) ;
}
SelectionIntoArgument() ;
break;
}
case 1:
{
break ;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
const QString objectUserName = LE->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
LE->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::ValueChangedInSpinBox( double newValue )
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QObject* send = (QObject*)sender();
if( send == SpinBox_C1A3 || send == SpinBox_Radius1 ) { /* radius1 */
myRadius1 = newValue ;
myOkRadius1 = true ;
} else if( send == SpinBox_C1A4 || send == SpinBox_Radius2 ) { /* radius2 */
myRadius2 = newValue ;
myOkRadius2 = true ;
}
else if( send == SpinBox_C1A5 || send == SpinBox_Height ) { /* algebric height */
myHeight = newValue ;
myOkHeight = true ;
}
if ( myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight ) {
MakeConeSimulationAndDisplay() ;
}
return ;
}
//=================================================================================
// function : TextChangedInLineEdit()
// purpose :
//=================================================================================
// void GeometryGUI_ConeDlg::TextChangedInLineEdit(const QString& newText)
// {
// myGeomGUI->EraseSimulationShape() ;
// mySimulationTopoDs.Nullify() ;
// QLineEdit* send = (QLineEdit*)sender();
// QString newT = strdup(newText) ;
// int i ;
// if(send == LineEditC1A3) { /* radius1 */
// if( myVa->validate(newT, i) == myVa->Acceptable ) {
// myRadius1 = newText.toFloat() ;
// myOkRadius1 = true ;
// }
// else {
// myOkRadius1 = false ;
// }
// } else if(send == LineEditC1A4) { /* radius2 */
// if( myVb->validate(newT, i) == myVb->Acceptable ) {
// myRadius2 = newText.toFloat() ;
// myOkRadius2 = true ;
// }
// else {
// myOkRadius2 = false ;
// }
// } else if(send == LineEditC1A5) { /* algebric height */
// if( myVc->validate(newT, i) == myVc->Acceptable ) {
// myHeight = newText.toFloat() ;
// if( fabs(myHeight) > Precision::Confusion() )
// myOkHeight = true ;
// else
// myOkHeight = false ;
// }
// }else if(send == LineEdit_Radius1) { /* radius1 */
// if( myVa->validate(newT, i) == myVa->Acceptable ) {
// myRadius1 = newText.toFloat() ;
// myOkRadius1 = true ;
// }
// else {
// myOkRadius1 = false ;
// }
// } else if(send == LineEdit_Radius2) { /* radius2 */
// if( myVb->validate(newT, i) == myVb->Acceptable ) {
// myRadius2 = newText.toFloat() ;
// myOkRadius2 = true ;
// }
// else {
// myOkRadius2 = false ;
// }
// } else if(send == LineEdit_Height) { /* algebric height */
// if( myVc->validate(newT, i) == myVc->Acceptable ) {
// myHeight = newText.toFloat() ;
// if( fabs(myHeight) > Precision::Confusion() )
// myOkHeight = true ;
// else
// myOkHeight = false ;
// }
// }
// if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 && myOkHeight) {
// MakeConeSimulationAndDisplay() ;
// }
// return ;
// }
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupC2->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupC2->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : MakeConeSimulationAndDisplay()
// purpose :
//=================================================================================
void GeometryGUI_ConeDlg::MakeConeSimulationAndDisplay()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
gp_Dir aDir = myDir ;
try {
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
gp_Ax2 anAxis(this->myPoint1, aDir) ;
if( fabs(myRadius1 - myRadius2) <= Precision::Confusion() ) {
mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, (myRadius1+myRadius2)/2.0, fabs(myHeight) ).Shape() ;
}
else {
if( fabs(myHeight) > Precision::Confusion() )
mySimulationTopoDs = BRepPrimAPI_MakeCone( anAxis, myRadius1, myRadius2, fabs(myHeight) ).Shape() ;
}
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
catch(Standard_Failure) {
MESSAGE( "Exception catched in MakeConeSimulationAndDisplay" ) ;
}
return ;
}

View File

@ -0,0 +1,152 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_ConeDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CONE_H
#define DIALOGBOX_CONE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include "GEOM_EdgeFilter.hxx"
#include "GeometryGUI_SpinBox.h"
#include <BRepPrimAPI_MakeCone.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <Precision.hxx>
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QSpinBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_ConeDlg
// purpose :
//=================================================================================
class GeometryGUI_ConeDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_ConeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_ConeDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void MakeConeSimulationAndDisplay() ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape mySimulationTopoDs ;
gp_Pnt myPoint1 ; /* Topology used */
gp_Dir myDir ;
bool myOkPoint1 ;
bool myOkDir ; /* to check when argument is defined */
Standard_Real myRadius1 ;
Standard_Real myRadius2 ;
Standard_Real myHeight ;
bool myOkRadius1 ;
bool myOkRadius2 ;
bool myOkHeight ;
QDoubleValidator *myVa ; /* Double validator for numeric input myRadius1 */
QDoubleValidator *myVb ; /* Double validator for numeric input myRadius2 */
QDoubleValidator *myVc ; /* Double validator for numeric input myHeight */
int myConstructorId ; /* Current constructor id = radio button id */
QWidget* myEditCurrentArgument; /* Current LineEdit or spin box */
Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */
Handle(GEOM_EdgeFilter) myEdgeFilter ; /* Filter selection */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QGroupBox* GroupC1;
QGroupBox* GroupC2;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A2;
QLabel* TextLabelC1A2;
QLabel* TextLabelC1A3;
GeometryGUI_SpinBox* SpinBox_C1A3 ;
QLabel* TextLabelC1A4;
GeometryGUI_SpinBox* SpinBox_C1A4 ;
QLabel* TextLabelC1A5;
GeometryGUI_SpinBox* SpinBox_C1A5 ;
QLabel* TextLabel_Radius1 ;
QLabel* TextLabel_Radius2 ;
QLabel* TextLabel_Height ;
GeometryGUI_SpinBox* SpinBox_Radius1 ;
GeometryGUI_SpinBox* SpinBox_Radius2 ;
GeometryGUI_SpinBox* SpinBox_Height ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_ConeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_CONE_H

View File

@ -0,0 +1,472 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CutDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CutDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_CutDlg()
// purpose : Constructs a GeometryGUI_CutDlg 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.
//=================================================================================
GeometryGUI_CutDlg::GeometryGUI_CutDlg( 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( "GeometryGUI",tr("ICON_DLG_CUT")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_CutDlg" );
resize( 322, 220 );
setCaption( tr( "GEOM_CUT_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CutDlgLayout = new QGridLayout( this );
GeometryGUI_CutDlgLayout->setSpacing( 6 );
GeometryGUI_CutDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CUT" ) );
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 );
GeometryGUI_CutDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_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 );
LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" );
LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 );
LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" );
LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 );
SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" );
SelectButtonC1A1Shape->setText( tr( "" ) );
SelectButtonC1A1Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 );
SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" );
SelectButtonC1A2Shape->setText( tr( "" ) );
SelectButtonC1A2Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 );
TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" );
TextLabelC1A2Shape->setText( tr( "GEOM_TOOL_OBJECT" ) );
TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 );
TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" );
TextLabelC1A1Shape->setText( tr( "GEOM_MAIN_OBJECT" ) );
TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 );
GeometryGUI_CutDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CutDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~GeometryGUI_CutDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CutDlg::~GeometryGUI_CutDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myShape1.Nullify() ;
myShape2.Nullify() ;
myConstructorId = 0 ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Shape ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
// TODO previous selection into argument ?
/* 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( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CutDlg::ConstructorsClicked(int constructorId)
{
GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Shape ;
LineEditC1A2Shape->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::ClickOnApply()
{
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkShape1 && myOkShape2) {
myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 2 ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_CutDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = ""; /* name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myOkShape1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myOkShape2 = false ;
}
break ;
}
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape1 = S ;
LineEditC1A1Shape->setText(aString) ;
myOkShape1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape2 = S ;
LineEditC1A2Shape->setText(aString) ;
myOkShape2 = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Shape ) {
LineEditC1A1Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A1Shape ;
}
else if(send == SelectButtonC1A2Shape) {
LineEditC1A2Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A2Shape;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1Shape )
myEditCurrentArgument = LineEditC1A1Shape ;
else if ( send == LineEditC1A2Shape )
myEditCurrentArgument = LineEditC1A2Shape ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GeometryGUI_CutDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CutDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}

View File

@ -0,0 +1,118 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CutDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CUT_H
#define DIALOGBOX_CUT_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepAlgoAPI_Cut.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_CutDlg
// purpose :
//=================================================================================
class GeometryGUI_CutDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CutDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CutDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape1 ; /* topology used to fuse */
TopoDS_Shape myShape2 ; /* topology used to fuse */
GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */
GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */
bool myOkShape1 ;
bool myOkShape2 ; /* to check when arguments are defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Shape;
QLineEdit* LineEditC1A2Shape;
QPushButton* SelectButtonC1A1Shape;
QPushButton* SelectButtonC1A2Shape;
QLabel* TextLabelC1A2Shape;
QLabel* TextLabelC1A1Shape;
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* GeometryGUI_CutDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_CUT_H

View File

@ -0,0 +1,695 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CylinderDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_CylinderDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "utilities.h"
#include <BRepAdaptor_Curve.hxx>
#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 : GeometryGUI_CylinderDlg()
// purpose : Constructs a GeometryGUI_CylinderDlg 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.
//=================================================================================
GeometryGUI_CylinderDlg::GeometryGUI_CylinderDlg( 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( "GeometryGUI",tr("ICON_DLG_CYLINDER_PV")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_CYLINDER_DXYZ")));
if ( !name )
setName( "GeometryGUI_CylinderDlg" );
resize( 303, 281 );
setCaption( tr( "GEOM_CYLINDER_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_CylinderDlgLayout = new QGridLayout( this );
GeometryGUI_CylinderDlgLayout->setSpacing( 6 );
GeometryGUI_CylinderDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_CylinderDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_CYLINDER" ) );
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 );
Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
Constructor2->setText( tr( "" ) );
Constructor2->setMinimumSize( QSize( 50, 0 ) );
Constructor2->setPixmap( image2 );
Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
GeometryGUI_CylinderDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_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 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_BASE_POINT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setMinimumSize( QSize( 0, 0 ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_VECTOR" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_RADIUS" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A3->setFrameShape( QLabel::NoFrame );
TextLabelC1A3->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
GroupC1Layout->addWidget( SpinBox_C1A3, 2, 2 ) ;
TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
TextLabelC1A4->setText( tr( "GEOM_HEIGHT" ) );
TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A4->setFrameShape( QLabel::NoFrame );
TextLabelC1A4->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
SpinBox_C1A4 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A4" ) ;
GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
GeometryGUI_CylinderDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupC2 = new QGroupBox( this, "GroupC2" );
GroupC2->setTitle( tr( "GEOM_BOX_OBJ" ) );
GroupC2->setColumnLayout(0, Qt::Vertical );
GroupC2->layout()->setSpacing( 0 );
GroupC2->layout()->setMargin( 0 );
GroupC2Layout = new QGridLayout( GroupC2->layout() );
GroupC2Layout->setAlignment( Qt::AlignTop );
GroupC2Layout->setSpacing( 6 );
GroupC2Layout->setMargin( 11 );
TextLabel_Height = new QLabel(GroupC2 , "TextLabel_Height" );
TextLabel_Height->setText( tr( "GEOM_HEIGHT" ) );
GroupC2Layout->addWidget( TextLabel_Height, 1, 0 );
TextLabel_Radius = new QLabel( GroupC2, "TextLabel_Radius" );
TextLabel_Radius->setText( tr( "GEOM_RADIUS" ) );
GroupC2Layout->addWidget( TextLabel_Radius, 0, 0 );
SpinBox_Height = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Height" ) ;
SpinBox_Height->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Height->sizePolicy().hasHeightForWidth() ) );
GroupC2Layout->addWidget( SpinBox_Height, 1, 1 ) ;
SpinBox_Radius = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_Radius" ) ;
SpinBox_Radius->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_Radius->sizePolicy().hasHeightForWidth() ) );
GroupC2Layout->addWidget( SpinBox_Radius, 0, 1 ) ;
QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
GroupC2Layout->addItem( spacer1 );
GeometryGUI_CylinderDlgLayout->addWidget(GroupC2 , 1, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_CylinderDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_CylinderDlg::~GeometryGUI_CylinderDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::Init( SALOME_Selection* Sel )
{
/* Get setting of step value from file configuration */
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes & initial values */
/* First constructor : radius */
SpinBox_C1A3->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
/* First constructor : algebric height */
SpinBox_C1A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
/* Second constructor : radius */
SpinBox_Radius->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
/* Second constructor : algebric height */
SpinBox_Height->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
GroupC1->show();
GroupC2->hide();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
SpinBox_C1A3->SetValue( 100.0 ) ;
SpinBox_C1A4->SetValue( 300.0 ) ;
SpinBox_Radius->SetValue( 100.0 ) ;
SpinBox_Height->SetValue( 300.0 ) ;
myRadius = 100.0 ;
myHeight = 300.0 ;
myOkRadius = true ;
myOkHeight = true ;
myOkPoint1 = false ;
myOkDir = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myEdgeFilter = new GEOM_EdgeFilter( StdSelect_Line, myGeom );
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
/* first filter used */
mySelection->AddFilter(myVertexFilter) ;
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C1A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Radius, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_CylinderDlg::ConstructorsClicked(int constructorId)
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
switch(myConstructorId)
{
case 0 :
{
GroupC1->hide();
GroupC2->show();
myConstructorId = constructorId ;
myOkHeight = myOkRadius = myOkPoint1 = myOkDir = true ;
SpinBox_Radius->SetValue( 100.0 ) ;
SpinBox_Height->SetValue( 300.0 ) ;
myRadius = 100.0 ;
myHeight = 300.0 ;
disconnect( mySelection, 0, this, 0 );
myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
myDir.SetCoord( 0.0, 0.0, 1.0 ) ;
if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
MakeCylinderSimulationAndDisplay() ;
}
break ;
}
case 1 :
{
GroupC2->hide();
GroupC1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1 ;
myOkHeight = myOkRadius = true ;
myOkPoint1 = myOkDir = false ;
LineEditC1A1->setText( tr("") );
SpinBox_C1A3->SetValue( 100.0 ) ;
SpinBox_C1A4->SetValue( 300.0 ) ;
myRadius = 100.0 ;
myHeight = 300.0 ;
disconnect( mySelection, 0, this, 0 );
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
}
break ;
}
case 1 :
{
if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
gp_Dir aDir = myDir ;
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
myGeomGUI->MakeCylinderAndDisplay( myPoint1, aDir, myRadius, fabs(myHeight) ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_CylinderDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QString aString = ""; /* name of future selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
LineEditC1A1->setText("") ;
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
LineEditC1A2->setText("") ;
myOkDir = false ;
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
/* gp_Pnt : not used */
if ( myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
LineEditC1A1->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, notUsed, myDir)*/ ) {
BRepAdaptor_Curve curv(TopoDS::Edge(S));
myDir = curv.Line().Direction();
LineEditC1A2->setText(aString) ;
myOkDir = true ;
}
if( myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
MakeCylinderSimulationAndDisplay() ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->AddFilter(myVertexFilter) ;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
mySelection->AddFilter(myEdgeFilter) ;
}
SelectionIntoArgument() ;
break;
}
case 1:
{
break ;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
const QString objectUserName = LE->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
LE->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::ValueChangedInSpinBox( double newValue )
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QObject* send = (QObject*)sender();
if(send == SpinBox_C1A3 ) { /* radius */
myRadius = newValue ;
myOkRadius = true ;
if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
MakeCylinderSimulationAndDisplay() ;
}
} else if (send == SpinBox_C1A4 ) { /* algebric height */
myHeight = newValue ;
myOkHeight = true ;
if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
MakeCylinderSimulationAndDisplay() ;
}
}
else if (send == SpinBox_Height) { /* algebric height */
myOkHeight = true ;
myHeight = newValue ;
if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
MakeCylinderSimulationAndDisplay() ;
}
}
else if (send == SpinBox_Radius) { /* radius */
myRadius = newValue ;
myOkRadius = true ;
if (myOkPoint1 && myOkDir && myOkRadius && myOkHeight ) {
MakeCylinderSimulationAndDisplay() ;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupC2->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupC2->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : MakeCylinderSimulationAndDisplay()
// purpose :
//=================================================================================
void GeometryGUI_CylinderDlg::MakeCylinderSimulationAndDisplay()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
gp_Dir aDir = this->myDir ;
try {
/* allows user to reverse direction of construction with a negative height */
if( this->myHeight < -Precision::Confusion() ) {
aDir.Reverse() ;
}
gp_Ax2 anAxis(this->myPoint1, aDir) ;
mySimulationTopoDs = BRepPrimAPI_MakeCylinder( anAxis, this->myRadius, fabs(myHeight) ).Shape() ;
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
catch(Standard_Failure) {
MESSAGE( "Exception catched in MakeCylinderSimulationAndDisplay" ) ;
}
return ;
}

View File

@ -0,0 +1,146 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_CylinderDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_CYLINDER_H
#define DIALOGBOX_CYLINDER_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include "GEOM_EdgeFilter.hxx"
#include "GeometryGUI_SpinBox.h"
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <Precision.hxx>
#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 QSpinBox;
class QRadioButton;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_CylinderDlg
// purpose :
//=================================================================================
class GeometryGUI_CylinderDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_CylinderDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_CylinderDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void MakeCylinderSimulationAndDisplay() ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
TopoDS_Shape mySimulationTopoDs ;
SALOME_Selection* mySelection ; /* User shape selection */
gp_Pnt myPoint1 ; /* topology used */
gp_Dir myDir ;
Standard_Real myRadius ;
Standard_Real myHeight ;
bool myOkRadius ;
bool myOkHeight ;
QDoubleValidator *myVa ; /* Double validator for numeric input */
QDoubleValidator *myVb ; /* Double validator for numeric input */
bool myOkPoint1 ;
bool myOkDir ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QWidget* myEditCurrentArgument; /* Current LineEdit or spin box */
Handle(GEOM_ShapeTypeFilter) myVertexFilter ; /* Filter selection */
Handle(GEOM_EdgeFilter) myEdgeFilter ; /* Filter selection */
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QGroupBox* GroupC1;
QGroupBox* GroupC2;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A2;
QLabel* TextLabelC1A2;
QLabel* TextLabelC1A3;
GeometryGUI_SpinBox* SpinBox_C1A3 ;
QLabel* TextLabelC1A4 ;
GeometryGUI_SpinBox* SpinBox_C1A4 ;
QLabel* TextLabel_Radius ;
GeometryGUI_SpinBox* SpinBox_Radius ;
QLabel* TextLabel_Height ;
GeometryGUI_SpinBox* SpinBox_Height ;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_CylinderDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
};
#endif // DIALOGBOX_CYLINDER_H

View File

@ -0,0 +1,589 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_DistanceDlg.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_DistanceDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_RightFrame.h"
#include "utilities.h"
#include "OCCViewer_Viewer3d.h"
#include "OCCViewer_ViewFrame.h"
// Open CASCADE Includes
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
// QT Includes
#include <qmessagebox.h>
#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 : GeometryGUI_DistanceDlg()
// purpose : Constructs a GeometryGUI_DistanceDlg 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.
//=================================================================================
GeometryGUI_DistanceDlg::GeometryGUI_DistanceDlg( 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( "GeometryGUI",tr("ICON_DLG_MINDIST")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_DistanceDlg" );
resize( 322, 220 );
setCaption( tr( "GEOM_MINDIST_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_DistanceDlgLayout = new QGridLayout( this );
GeometryGUI_DistanceDlgLayout->setSpacing( 6 );
GeometryGUI_DistanceDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_DISTANCE" ) );
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 );
GeometryGUI_DistanceDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_MINDIST_OBJ" ) );
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 );
LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" );
LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 );
LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" );
LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 );
SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" );
SelectButtonC1A1Shape->setText( tr( "" ) );
SelectButtonC1A1Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 );
SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" );
SelectButtonC1A2Shape->setText( tr( "" ) );
SelectButtonC1A2Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 );
TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" );
TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") );
TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 );
TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" );
TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") );
TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 );
GeometryGUI_DistanceDlgLayout->addWidget( GroupConstructor1, 1, 0 );
TextLabel_Length = new QLabel( GroupConstructor1, "TextLabel_Length" );
TextLabel_Length->setText( tr( "GEOM_LENGTH" ) );
TextLabel_Length->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Length->setFrameShape( QLabel::NoFrame );
TextLabel_Length->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Length, 2, 0 );
LineEdit_Length = new QLineEdit( GroupConstructor1, "LineEdit_Length" );
LineEdit_Length->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Length->sizePolicy().hasHeightForWidth() ) );
// LineEdit_Length->setEnabled( FALSE );
LineEdit_Length->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_Length, 2, 2 );
/***************************************************************/
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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_DistanceDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~GeometryGUI_DistanceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_DistanceDlg::~GeometryGUI_DistanceDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myShape1.Nullify() ;
myShape2.Nullify() ;
myConstructorId = 0 ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Shape ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
// TODO previous selection into argument ?
/* 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( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_DistanceDlg::ConstructorsClicked(int constructorId)
{
EraseDistance();
myGeomGUI->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Shape ;
LineEditC1A2Shape->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::ClickOnApply()
{
EraseDistance() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkShape1 && myOkShape2) {
this->MakeDistanceSimulationAndDisplay(myShape1 ,myShape2) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::ClickOnCancel()
{
EraseDistance() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_DistanceDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
LineEdit_Length->setText("") ;
myEditCurrentArgument->setText("") ; /* by default */
QString aString = ""; /* the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myOkShape1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myOkShape2 = false ;
}
break ;
}
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape1 = S ;
LineEditC1A1Shape->setText(aString) ;
myOkShape1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape2 = S ;
LineEditC1A2Shape->setText(aString) ;
myOkShape2 = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Shape ) {
LineEditC1A1Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A1Shape ;
}
else if(send == SelectButtonC1A2Shape) {
LineEditC1A2Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A2Shape;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1Shape )
myEditCurrentArgument = LineEditC1A1Shape ;
else if ( send == LineEditC1A2Shape )
myEditCurrentArgument = LineEditC1A2Shape ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GeometryGUI_DistanceDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : MakeDistanceSimulationAndDisplay()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::MakeDistanceSimulationAndDisplay(const TopoDS_Shape& S1, const TopoDS_Shape& S2)
{
LineEdit_Length->setText("") ;
EraseDistance() ;
myGeomGUI->EraseSimulationShape() ;
BRepExtrema_DistShapeShape dst( S1, S2 );
if (dst.IsDone()) {
int i;
for (i=1; i<= dst.NbSolution(); i++) {
gp_Pnt P1,P2;
P1 = (dst.PointOnShape1(i));
P2 = (dst.PointOnShape2(i));
Standard_Real Dist = P1.Distance(P2);
if (Dist<=1.e-9) {
BRepBuilderAPI_MakeVertex MakeVertex(P1);
mySimulationTopoDs = MakeVertex.Vertex();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
LineEdit_Length->setText("0.0") ;
} else {
BRepBuilderAPI_MakeEdge MakeEdge(P1, P2);
mySimulationTopoDs = MakeEdge.Edge();
TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1);
TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2);
QString S;
S.sprintf("%.1f",Dist);
Handle(AIS_LengthDimension) Distance = new AIS_LengthDimension (V1,V2, new Geom_Plane (0.,0.,1.,0.),
Dist, TCollection_ExtendedString(strdup(S)));
LineEdit_Length->setText(S) ;
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
return ;
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
ic->Display( Distance );
ic->UpdateCurrentViewer();
}
}
} else
myGeomGUI->GetDesktop()->putInfo( tr( "GEOM_PRP_MIN_DIST" ) );
}
//=================================================================================
// function : EraseDistance()
// purpose :
//=================================================================================
void GeometryGUI_DistanceDlg::EraseDistance()
{
int count = myGeomGUI->GetActiveStudy()->getStudyFramesCount();
for ( int i = 0; i < count; i++ )
if (myGeomGUI->GetActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
AIS_ListOfInteractive L;
ic->DisplayedObjects(AIS_KOI_Relation,-1,L);
AIS_ListIteratorOfListOfInteractive ite(L);
while (ite.More()) {
ic->Remove( ite.Value() );
ic->UpdateCurrentViewer();
ite.Next();
}
}
}

View File

@ -0,0 +1,125 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_DistanceDlg.h
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_DISTANCE_H
#define DIALOGBOX_DISTANCE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepExtrema_DistShapeShape.hxx>
#include <AIS_LengthDimension.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_DistanceDlg
// purpose :
//=================================================================================
class GeometryGUI_DistanceDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_DistanceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_DistanceDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void MakeDistanceSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 ) ;
void EraseDistance() ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape1 ;
TopoDS_Shape myShape2 ;
GEOM::GEOM_Shape_var myGeomShape1 ;
GEOM::GEOM_Shape_var myGeomShape2 ;
bool myOkShape1 ;
bool myOkShape2 ; /* to check when arguments are defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Shape;
QLineEdit* LineEditC1A2Shape;
QPushButton* SelectButtonC1A1Shape;
QPushButton* SelectButtonC1A2Shape;
QLabel* TextLabelC1A2Shape;
QLabel* TextLabelC1A1Shape;
QLabel* TextLabel_Length;
QLineEdit* LineEdit_Length;
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* GeometryGUI_DistanceDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_DISTANCE_H

View File

@ -0,0 +1,462 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_EdgeDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_EdgeDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_EdgeDlg()
// purpose : Constructs a GeometryGUI_EdgeDlg 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.
//=================================================================================
GeometryGUI_EdgeDlg::GeometryGUI_EdgeDlg( 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( "GeometryGUI",tr("ICON_DLG_BUILD_EDGE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_EdgeDlg" );
resize( 303, 225 );
setCaption( tr( "GEOM_EDGE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_EdgeDlgLayout = new QGridLayout( this );
GeometryGUI_EdgeDlgLayout->setSpacing( 6 );
GeometryGUI_EdgeDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_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 );
GeometryGUI_EdgeDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_POINTS" ) );
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 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_POINT_I" ).arg("1") );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_POINT_I" ).arg("2") );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
GeometryGUI_EdgeDlgLayout->addWidget( GroupC1, 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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_EdgeDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_EdgeDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_EdgeDlg::~GeometryGUI_EdgeDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
// GroupC2->hide();
// GroupC3->hide();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myPoint1.SetCoord( 0.0, 0.0, 0.0 );
myPoint2.SetCoord( 0.0, 0.0, 0.0 );
myOkPoint1 = myOkPoint2 = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filters definition */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
mySelection->AddFilter(myVertexFilter) ; /* first filter used */
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_EdgeDlg::ConstructorsClicked(int constructorId)
{
switch (constructorId)
{
case 0:
{
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkPoint1 && myOkPoint2)
myGeomGUI->MakeLinearEdgeAndDisplay( myPoint1, myPoint2 ) ;
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_EdgeDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QString aString = ""; /* name of future selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
myOkPoint2 = false ;
}
return ;
}
// nbSel == 1 !
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint2 = true ;
}
if( myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
}
mySelection->AddFilter(myVertexFilter) ;
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
// TODO other constructors
//
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_EdgeDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,118 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_EdgeDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_EDGE_H
#define DIALOGBOX_EDGE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_EdgeDlg
// purpose :
//=================================================================================
class GeometryGUI_EdgeDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_EdgeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_EdgeDlg();
private :
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
SALOME_Selection* mySelection ; /* User shape selection */
gp_Pnt myPoint1 ; /* Points containing the vector */
gp_Pnt myPoint2 ;
bool myOkPoint1 ; /* true when myPoint is defined */
bool myOkPoint2 ;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void Init( SALOME_Selection* Sel ) ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A1;
QLineEdit* LineEditC1A2;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A1;
QLabel* TextLabelC1A2;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_EdgeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_EDGE_H

View File

@ -0,0 +1,420 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FaceDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_FaceDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#include <qbuttongroup.h>
#include <qcheckbox.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 : GeometryGUI_FaceDlg()
// purpose : Constructs a GeometryGUI_FaceDlg 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.
//=================================================================================
GeometryGUI_FaceDlg::GeometryGUI_FaceDlg( 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( "GeometryGUI",tr("ICON_DLG_BUILD_FACE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_FaceDlg" );
resize( 303, 208 );
setCaption( tr( "GEOM_FACE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_FaceDlgLayout = new QGridLayout( this );
GeometryGUI_FaceDlgLayout->setSpacing( 6 );
GeometryGUI_FaceDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_FACE" ) );
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 );
GeometryGUI_FaceDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_FACE_FFW" ) );
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( "GEOM_WIRE" ) );
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 );
CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" );
CheckBox1->setText( tr( "GEOM_FACE_OPT" ) );
CheckBox1->setChecked( TRUE );
GroupC1Layout->addWidget( CheckBox1, 1, 2);
GeometryGUI_FaceDlgLayout->addWidget( GroupC1, 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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_FaceDlgLayout->addWidget( GroupButtons, 2, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_FaceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_FaceDlg::~GeometryGUI_FaceDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
CheckBox1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
this->myOkShape = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myWireFilter = new GEOM_ShapeTypeFilter( TopAbs_WIRE, myGeom );
mySelection->AddFilter(myWireFilter) ; /* first filter used */
/* 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( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_FaceDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::ClickOnApply()
{
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkShape) {
myGeomGUI->MakeFaceAndDisplay(this->myGeomShape, this->CheckBox1->isChecked() ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->ResetState() ;
disconnect( mySelection, 0, this, 0 );
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_FaceDlg::SelectionIntoArgument()
{
/* All this for first constructor */
// if(myEditCurrentArgument == LineEditC1A1 )
myOkShape = false;
myEditCurrentArgument->setText("") ;
QString aString = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 )
return ;
// nbSel == 1 !
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(this->mySelection, this->myShape) )
return ;
myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myEditCurrentArgument->setText(aString) ;
this->myOkShape = true ;
/* no simulation */
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->AddFilter(myWireFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
mySelection->ClearFilters() ;
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_FaceDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,113 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FaceDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_FACE_H
#define DIALOGBOX_FACE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QCheckBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_FaceDlg
// purpose :
//=================================================================================
class GeometryGUI_FaceDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_FaceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_FaceDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape ; /* topology used to fuse */
GEOM::GEOM_Shape_var myGeomShape ; /* is myShape */
bool myOkShape ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
Handle(GEOM_ShapeTypeFilter) myWireFilter; /* Filter selection */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QCheckBox* CheckBox1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_FaceDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_FACE_H

View File

@ -0,0 +1,842 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FilletDlg.cxx
// Author : Damien COQUERET
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_FilletDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "utilities.h"
#include "QAD_RightFrame.h"
#include "OCCViewer_Viewer3d.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 <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <TopExp_Explorer.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
//=================================================================================
// class : GeometryGUI_FilletDlg()
// purpose : Constructs a GeometryGUI_FilletDlg 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.
//=================================================================================
GeometryGUI_FilletDlg::GeometryGUI_FilletDlg( QWidget* parent,
const char* name,
SALOME_Selection* Sel,
Handle (AIS_InteractiveContext) ic,
bool modal,
WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
/***************************************************************/
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_ALL")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_EDGE")));
QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLET_FACE")));
if ( !name )
setName( "GeometryGUI_FilletDlg" );
resize( 365, 220 );
setCaption( tr( "GEOM_FILLET_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_FilletDlgLayout = new QGridLayout( this );
GeometryGUI_FilletDlgLayout->setSpacing( 6 );
GeometryGUI_FilletDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_FilletDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_FILLET" ) );
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 );
Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
Constructor2->setText( tr( "" ) );
Constructor2->setPixmap( image2 );
Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
Constructor2->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_2, 0, 3 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
Constructor3 = new QRadioButton( GroupConstructors, "Constructor3" );
Constructor3->setText( tr( "" ) );
Constructor3->setPixmap( image3 );
Constructor3->setMinimumSize( QSize( 50, 0 ) );
GroupConstructorsLayout->addWidget( Constructor3, 0, 4 );
QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_4, 0, 5 );
GeometryGUI_FilletDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_FILLET_ALL" ) );
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( "GEOM_MAIN_OBJECT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_RADIUS" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
SpinBox_C1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A2->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SpinBox_C1A2, 1, 2 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
GeometryGUI_FilletDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupC2 = new QGroupBox( this, "GroupC2" );
GroupC2->setTitle( tr( "GEOM_FILLET_EDGES" ) );
GroupC2->setMinimumSize( QSize( 0, 0 ) );
GroupC2->setFrameShape( QGroupBox::Box );
GroupC2->setFrameShadow( QGroupBox::Sunken );
GroupC2->setColumnLayout(0, Qt::Vertical );
GroupC2->layout()->setSpacing( 0 );
GroupC2->layout()->setMargin( 0 );
GroupC2Layout = new QGridLayout( GroupC2->layout() );
GroupC2Layout->setAlignment( Qt::AlignTop );
GroupC2Layout->setSpacing( 6 );
GroupC2Layout->setMargin( 11 );
TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
TextLabelC2A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC2A1->setFrameShape( QLabel::NoFrame );
TextLabelC2A1->setFrameShadow( QLabel::Plain );
GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
TextLabelC2A2->setText( tr( "GEOM_RADIUS" ) );
TextLabelC2A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC2A2->setFrameShape( QLabel::NoFrame );
TextLabelC2A2->setFrameShadow( QLabel::Plain );
GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
SpinBox_C2A2 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A2" ) ;
SpinBox_C2A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A2->sizePolicy().hasHeightForWidth() ) );
GroupC2Layout->addWidget( SpinBox_C2A2, 1, 2 );
SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
SelectButtonC2A1->setText( tr( "" ) );
SelectButtonC2A1->setPixmap( image1 );
SelectButtonC2A1->setToggleButton( FALSE );
SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
GeometryGUI_FilletDlgLayout->addWidget( GroupC2, 1, 0 );
/***************************************************************/
GroupC3 = new QGroupBox( this, "GroupC3" );
GroupC3->setTitle( tr( "GEOM_FILLET_FACES" ) );
GroupC3->setMinimumSize( QSize( 0, 0 ) );
GroupC3->setFrameShape( QGroupBox::Box );
GroupC3->setFrameShadow( QGroupBox::Sunken );
GroupC3->setColumnLayout(0, Qt::Vertical );
GroupC3->layout()->setSpacing( 0 );
GroupC3->layout()->setMargin( 0 );
GroupC3Layout = new QGridLayout( GroupC3->layout() );
GroupC3Layout->setAlignment( Qt::AlignTop );
GroupC3Layout->setSpacing( 6 );
GroupC3Layout->setMargin( 11 );
TextLabelC3A1 = new QLabel( GroupC3, "TextLabelC3A1" );
TextLabelC3A1->setText( tr( "GEOM_MAIN_OBJECT" ) );
TextLabelC3A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC3A1->setFrameShape( QLabel::NoFrame );
TextLabelC3A1->setFrameShadow( QLabel::Plain );
GroupC3Layout->addWidget( TextLabelC3A1, 0, 0 );
TextLabelC3A2 = new QLabel( GroupC3, "TextLabelC3A2" );
TextLabelC3A2->setText( tr( "GEOM_RADIUS" ) );
TextLabelC3A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC3A2->setFrameShape( QLabel::NoFrame );
TextLabelC3A2->setFrameShadow( QLabel::Plain );
GroupC3Layout->addWidget( TextLabelC3A2, 1, 0 );
LineEditC3A1 = new QLineEdit( GroupC3, "LineEditC3A1" );
GroupC3Layout->addWidget( LineEditC3A1, 0, 2 );
SpinBox_C3A2 = new GeometryGUI_SpinBox( GroupC3, "GeomSpinBox_C3A2" ) ;
SpinBox_C3A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C3A2->sizePolicy().hasHeightForWidth() ) );
GroupC3Layout->addWidget( SpinBox_C3A2, 1, 2 );
SelectButtonC3A1 = new QPushButton( GroupC3, "SelectButtonC3A1" );
SelectButtonC3A1->setText( tr( "" ) );
SelectButtonC3A1->setPixmap( image1 );
SelectButtonC3A1->setToggleButton( FALSE );
SelectButtonC3A1->setMaximumSize( QSize( 28, 32767 ) );
GroupC3Layout->addWidget( SelectButtonC3A1, 0, 1 );
GeometryGUI_FilletDlgLayout->addWidget( GroupC3, 1, 0 );
/* Initialisation */
Init( Sel, ic ) ;
}
//=================================================================================
// function : ~GeometryGUI_FilletDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_FilletDlg::~GeometryGUI_FilletDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
{
/* Get setting of step value from file configuration */
double step ;
QString St = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" ) ;
step = St.toDouble() ;
/* min, max, step and decimals for spin boxes */
SpinBox_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C1A2->SetValue( 50 ) ;
SpinBox_C2A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C2A2->SetValue( 50 ) ;
SpinBox_C3A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
SpinBox_C3A2->SetValue( 50 ) ;
GroupC1->show();
GroupC2->hide() ;
GroupC3->hide() ;
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
mySelection = Sel ;
myEditCurrentArgument = LineEditC1A1 ;
myShape.Nullify() ;
myRadius = 50.0 ;
myOkRadius = true ;
myIC = ic ;
myLocalContextId = -1 ;
myUseLocalContext = false ;
myOkShape = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
mySimulationTopoDs.Nullify() ;
/* Filters definition */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC3A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C2A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( SpinBox_C3A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC3A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_FilletDlg::ConstructorsClicked(int constructorId)
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myEditCurrentArgument->setText(tr("")) ;
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
if(this->myUseLocalContext) {
myIC->CloseLocalContext(this->myLocalContextId) ;
myGeomGUI->OnDisplayAll(true) ;
this->myUseLocalContext = false ;
}
}
myOkShape = false ;
myRadius = 50.0 ;
myOkRadius = true ;
myConstructorId = constructorId ;
// connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
switch (constructorId)
{
case 0: /* Fillet All */
{
myShapeType = -1;
GroupC1->show();
GroupC2->hide() ;
GroupC3->hide() ;
myEditCurrentArgument = LineEditC1A1 ;
SpinBox_C1A2->SetValue( 50 ) ;;
LineEditC1A1->setText(tr("")) ;
break;
}
case 1: /* Fillet edges */
{
myShapeType = 6;
GroupC1->hide();
GroupC2->show() ;
GroupC3->hide() ;
myEditCurrentArgument = LineEditC2A1 ;
SpinBox_C2A2->SetValue( 50 ) ;;
LineEditC2A1->setText(tr("")) ;
break ;
}
case 2: /* Fillet Faces */
{
myShapeType = 4;
GroupC1->hide();
GroupC2->hide() ;
GroupC3->show() ;
myEditCurrentArgument = LineEditC3A1 ;
SpinBox_C3A2->SetValue( 50 ) ;;
LineEditC3A1->setText(tr("")) ;
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
bool testResult = false ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 : /* Fillet All */
{
if(myOkRadius) {
if( myOkShape ) {
testResult = myGeomGUI->OnFilletGetAll( myShape, myRadius, myShapeType, myShapeIOR ) ;
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
} else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
case 1 : /* Fillet Edge */
{
if(myOkRadius) {
if( myOkShape ) {
testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext );
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
} else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
case 2 : /* Fillet Face */
{
if(myOkRadius) {
if( myOkShape ) {
testResult = myGeomGUI->OnFilletGetSelected( myShape, myShapeIOR, myRadius, myShapeType, myLocalContextId, myUseLocalContext ) ;
}
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
} else {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
}
/* Reset all arguments and local context to allow user a new selection ...*/
this->ResetStateOfDialog() ;
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
if(this->myUseLocalContext) {
myIC->CloseLocalContext(this->myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
}
reject() ;
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC2A1 )
myEditCurrentArgument = LineEditC2A1 ;
else if ( send == LineEditC3A1 )
myEditCurrentArgument = LineEditC3A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_FilletDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
/* Reset all arguments and local context when selection as changed */
this->ResetStateOfDialog() ;
/* Future name of argument */
QString aString = "";
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel == 1 ) {
TopoDS_Shape S ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if( !IO->hasEntry() ) {
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY")) ;
return ;
}
if ( !S.IsNull() && S.ShapeType() <= 2 ) {
if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
myEditCurrentArgument->setText(aString) ;
myShape = S ;
myOkShape = true ;
}
if ( IO->hasEntry() ) {
SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
myShapeIOR = anIOR->Value();
myOkShape = true ;
myShape = S ;
myEditCurrentArgument->setText(aString) ;
}
}
}
}
MakePreview();
} else
return;
if( myOkShape && myShapeType!=-1 && myConstructorId != 0 ) {
/* local context is defined into the method */
myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
myUseLocalContext = true ;
myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_EDGE")) ;
}
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0:
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
SelectionIntoArgument() ;
}
break;
}
case 1:
{
if(send ==SelectButtonC2A1 ) {
LineEditC2A1->setFocus() ;
myEditCurrentArgument = LineEditC2A1;
SelectionIntoArgument() ;
}
break;
}
case 2:
{
if(send ==SelectButtonC3A1 ) {
LineEditC3A1->setFocus() ;
myEditCurrentArgument = LineEditC3A1;
SelectionIntoArgument() ;
}
break;
}
}
return ;
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ValueChangedInSpinBox( double newValue )
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
myRadius = newValue ;
myOkRadius = true ;
MakePreview();
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
this->ResetStateOfDialog() ;
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupC2->setEnabled(false) ;
GroupC3->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
myGeomGUI->SetActiveDialogBox(0) ;
myGeomGUI->OnDisplayAll(true) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupC2->setEnabled(true) ;
GroupC3->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::enterEvent( QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ResetStateOfDialog()
// purpose :
//=================================================================================
void GeometryGUI_FilletDlg::ResetStateOfDialog()
{
this->myOkShape = false ;
this->myEditCurrentArgument->setText("") ;
/* Close its local contact if opened */
if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
myIC = v3d->getAISContext(); // myIC = myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getViewerOCC()->getAISContext();
if(this->myUseLocalContext) {
myIC->CloseLocalContext(this->myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
}
return ;
}
void GeometryGUI_FilletDlg::MakePreview()
{
TopoDS_Shape tds ;
try
{
BRepFilletAPI_MakeFillet fill(myShape);
switch (myConstructorId)
{
case 0: /* Fillet All */
{
TopExp_Explorer Exp ( myShape, TopAbs_EDGE );
for (Exp; Exp.More(); Exp.Next())
{
TopoDS_Edge E =TopoDS::Edge(Exp.Current());
fill.Add(E);
}
for (int i = 1;i<=fill.NbContours();i++)
fill.SetRadius(myRadius,i);
tds = fill.Shape();
break;
}
// case 1: /* Fillet edges */
// case 2: /* Fillet Faces */
}
if (!tds.IsNull())
{
mySimulationTopoDs = tds;
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
}
catch(Standard_Failure)
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
}
}

View File

@ -0,0 +1,163 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FilletDlg.h
// Author : Damien COQUERET
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_FILLET_H
#define DIALOGBOX_FILLET_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include "GeometryGUI_SpinBox.h"
// Qt Includes
#include <qvariant.h>
#include <qdialog.h>
#include <qvalidator.h>
// Open CASCADE Includes
#include <AIS_InteractiveContext.hxx>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QFrame;
class QGroupBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QToolButton;
class QLabel;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_FilletDlg
// purpose :
//=================================================================================
class GeometryGUI_FilletDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_FilletDlg( QWidget* parent = 0,
const char* name = 0,
SALOME_Selection* Sel = 0,
Handle (AIS_InteractiveContext) ic = 0,
bool modal = FALSE,
WFlags fl = 0 );
~GeometryGUI_FilletDlg();
private :
void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void ResetStateOfDialog() ;
/* Interactive and local context management see also : bool myUseLocalContext() */
Handle (AIS_InteractiveContext) myIC ; /* Interactive context */
Standard_Integer myLocalContextId ; /* identify a local context used by this method */
bool myUseLocalContext ; /* true when this method as opened a local context */
QDoubleValidator *myVa ; /* Double validator for numeric input */
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */
void MakePreview();
TopoDS_Shape myShape ;
bool myOkShape ;
char* myShapeIOR ;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
int myShapeType ;
bool myOkRadius ;
double myRadius ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QRadioButton* Constructor3;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupC1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A1;
GeometryGUI_SpinBox* SpinBox_C1A2 ;
QLabel* TextLabelC1A2;
QGroupBox* GroupC2;
QPushButton* SelectButtonC2A1;
QLineEdit* LineEditC2A1;
QLabel* TextLabelC2A1;
GeometryGUI_SpinBox* SpinBox_C2A2 ;
QLabel* TextLabelC2A2;
QGroupBox* GroupC3;
QPushButton* SelectButtonC3A1;
QLineEdit* LineEditC3A1;
QLabel* TextLabelC3A1;
GeometryGUI_SpinBox* SpinBox_C3A2 ;
QLabel* TextLabelC3A2;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void LineEditReturnPressed() ;
void ActivateThisDialog() ;
void ValueChangedInSpinBox( double newValue ) ;
protected:
QGridLayout* GeometryGUI_FilletDlgLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupC2Layout;
QGridLayout* GroupC3Layout;
};
#endif // DIALOGBOX_FILLET_H

View File

@ -0,0 +1,644 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FillingDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_FillingDlg.h"
#include "GeometryGUI.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <qbuttongroup.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>
#include <qvalidator.h>
#include <qimage.h>
#include <qpixmap.h>
//=================================================================================
// class : GeometryGUI_FillingDlg()
// purpose : Constructs a GeometryGUI_FillingDlg 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.
//=================================================================================
GeometryGUI_FillingDlg::GeometryGUI_FillingDlg( 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( "GeometryGUI",tr("ICON_DLG_FILLING")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_FillingDlg" );
resize( 303, 275 );
setCaption( tr( "GEOM_FILLING_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_FillingDlgLayout = new QGridLayout( this );
GeometryGUI_FillingDlgLayout->setSpacing( 6 );
GeometryGUI_FillingDlgLayout->setMargin( 11 );
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_FILLING" ) );
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)3, (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 );
GeometryGUI_FillingDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_FillingDlgLayout->addWidget( GroupButtons, 2, 0 );
// GroupC1 = new QGroupBox( this, "GroupC1" );
// GroupC1->setTitle( tr( "GEOM_FILLING_ARG" ) );
// GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) );
// 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 );
// LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
// LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
// GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 3, 5 );
// TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
// TextLabelC1A2->setText( tr( "GEOM_FILLING_MIN_DEG" ) );
// TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
// TextLabelC1A2->setFrameShape( QLabel::NoFrame );
// TextLabelC1A2->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
// LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
// LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
// LineEditC1A2->setMinimumSize( QSize( 40, 0 ) );
// GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 1, 2 );
// TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
// TextLabelC1A3->setText( tr( "GEOM_FILLING_MAX_DEG" ) );
// TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
// TextLabelC1A3->setFrameShape( QLabel::NoFrame );
// TextLabelC1A3->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addWidget( TextLabelC1A3, 1, 4 );
// TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
// TextLabelC1A5->setText( tr( "GEOM_FILLING_TOL_2D" ) );
// TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
// TextLabelC1A5->setFrameShape( QLabel::NoFrame );
// TextLabelC1A5->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addWidget( TextLabelC1A5, 2, 4 );
// LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
// LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
// LineEditC1A3->setMinimumSize( QSize( 40, 0 ) );
// GroupC1Layout->addWidget( LineEditC1A3, 1, 5 );
// LineEditC1A5 = new QLineEdit( GroupC1, "LineEditC1A5" );
// LineEditC1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A5->sizePolicy().hasHeightForWidth() ) );
// LineEditC1A5->setMinimumSize( QSize( 40, 0 ) );
// GroupC1Layout->addWidget( LineEditC1A5, 2, 5 );
// TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
// TextLabelC1A1->setText( tr( "GEOM_FILLING_COMPOUND" ) );
// TextLabelC1A1->setMinimumSize( QSize( 90, 0 ) );
// TextLabelC1A1->setFrameShape( QLabel::NoFrame );
// TextLabelC1A1->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addMultiCellWidget( TextLabelC1A1, 0, 0, 0, 1 );
// SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
// SelectButtonC1A1->setText( tr( "" ) );
// SelectButtonC1A1->setPixmap( image1 );
// GroupC1Layout->addWidget( SelectButtonC1A1, 0, 2 );
// TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
// TextLabelC1A4->setText( tr( "GEOM_FILLING_TOL_3D" ) );
// TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
// TextLabelC1A4->setFrameShape( QLabel::NoFrame );
// TextLabelC1A4->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addWidget( TextLabelC1A4, 2, 0 );
// TextLabelC1A6 = new QLabel( GroupC1, "TextLabelC1A6" );
// TextLabelC1A6->setText( tr( "GEOM_FILLING_NB_ITER" ) );
// TextLabelC1A6->setMinimumSize( QSize( 50, 0 ) );
// TextLabelC1A6->setFrameShape( QLabel::NoFrame );
// TextLabelC1A6->setFrameShadow( QLabel::Plain );
// GroupC1Layout->addWidget( TextLabelC1A6, 3, 0 );
// LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" );
// LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) );
// LineEditC1A4->setMinimumSize( QSize( 40, 0 ) );
// GroupC1Layout->addMultiCellWidget( LineEditC1A4, 2, 2, 1, 2 );
// LineEditC1A6 = new QLineEdit( GroupC1, "LineEditC1A6" );
// LineEditC1A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A6->sizePolicy().hasHeightForWidth() ) );
// LineEditC1A6->setMinimumSize( QSize( 40, 0 ) );
// GroupC1Layout->addMultiCellWidget( LineEditC1A6, 3, 3, 1, 2 );
// QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
// GroupC1Layout->addItem( spacer_3, 1, 3 );
// QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
// GroupC1Layout->addItem( spacer_4, 2, 3 );
// QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
// GroupC1Layout->addMultiCell( spacer_5, 3, 3, 3, 5 );
// GeometryGUI_FillingDlgLayout->addWidget( GroupC1, 1, 0 );
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setMinimumSize( QSize( 0, 0 ) );
GroupC1->setFrameShape( QGroupBox::Box );
GroupC1->setFrameShadow( QGroupBox::Sunken );
GroupC1->setTitle( tr( "GEOM_FILLING_ARG" ) );
GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) );
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 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 3, 6 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_FILLING_MIN_DEG" ) );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2->setFrameShape( QLabel::NoFrame );
TextLabelC1A2->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
TextLabelC1A5->setText( tr( "GEOM_FILLING_TOL_2D" ) );
TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A5->setFrameShape( QLabel::NoFrame );
TextLabelC1A5->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A5, 2, 5 );
LineEditC1A5 = new QLineEdit( GroupC1, "LineEditC1A5" );
LineEditC1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A5->sizePolicy().hasHeightForWidth() ) );
LineEditC1A5->setMinimumSize( QSize( 40, 0 ) );
GroupC1Layout->addWidget( LineEditC1A5, 2, 6 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_FILLING_COMPOUND" ) );
TextLabelC1A1->setMinimumSize( QSize( 90, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addMultiCellWidget( TextLabelC1A1, 0, 0, 0, 1 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 2 );
TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
TextLabelC1A4->setText( tr( "GEOM_FILLING_TOL_3D" ) );
TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A4->setFrameShape( QLabel::NoFrame );
TextLabelC1A4->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A4, 2, 0 );
TextLabelC1A6 = new QLabel( GroupC1, "TextLabelC1A6" );
TextLabelC1A6->setText( tr( "GEOM_FILLING_NB_ITER" ) );
TextLabelC1A6->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A6->setFrameShape( QLabel::NoFrame );
TextLabelC1A6->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A6, 3, 0 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupC1Layout->addItem( spacer_3, 1, 3 );
QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupC1Layout->addMultiCell( spacer_4, 2, 2, 3, 4 );
QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupC1Layout->addMultiCell( spacer_5, 3, 3, 3, 6 );
SpinBox_C1A2 = new QSpinBox( GroupC1, "SpinBox_C1A2" );
SpinBox_C1A2->setMinValue( 1 );
SpinBox_C1A2->setMaxValue( 15 );
SpinBox_C1A2->setWrapping( TRUE );
GroupC1Layout->addMultiCellWidget( SpinBox_C1A2, 1, 1, 1, 2 );
LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" );
LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) );
LineEditC1A4->setMinimumSize( QSize( 40, 0 ) );
GroupC1Layout->addMultiCellWidget( LineEditC1A4, 2, 2, 1, 2 );
TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
TextLabelC1A3->setText( tr( "GEOM_FILLING_MAX_DEG" ) );
TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A3->setFrameShape( QLabel::NoFrame );
TextLabelC1A3->setFrameShadow( QLabel::Plain );
GroupC1Layout->addMultiCellWidget( TextLabelC1A3, 1, 1, 4, 5 );
SpinBox_C1A3 = new QSpinBox( GroupC1, "SpinBox_C1A3" );
SpinBox_C1A3->setMinValue( 1 );
SpinBox_C1A3->setMaxValue( 15 );
SpinBox_C1A3->setWrapping( TRUE );
GroupC1Layout->addWidget( SpinBox_C1A3, 1, 6 );
SpinBox_C1A6 = new QSpinBox( GroupC1, "SpinBox_C1A6" );
SpinBox_C1A6->setMinValue( 1 );
SpinBox_C1A6->setMaxValue( 30 );
SpinBox_C1A6->setWrapping( TRUE );
GroupC1Layout->addMultiCellWidget( SpinBox_C1A6, 3, 3, 1, 2 );
GeometryGUI_FillingDlgLayout->addWidget( GroupC1, 1, 0 );
/* Initialisations */
Init(Sel) ;
}
//=================================================================================
// function : ~GeometryGUI_FillingDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_FillingDlg::~GeometryGUI_FillingDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::Init( SALOME_Selection* Sel )
{
LineEditC1A4->setMaxLength( 10 ); /* myTol3D */
LineEditC1A5->setMaxLength( 10 ); /* myTol2D */
QDoubleValidator *Vc = new QDoubleValidator( 0.00001, +10000.0, 3, LineEditC1A4 ) ;
QDoubleValidator *Vd = new QDoubleValidator( 0.00001, +10000.0, 3, LineEditC1A5 ) ;
LineEditC1A4->setValidator( Vc) ;
LineEditC1A5->setValidator( Vd) ;
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
SpinBox_C1A2->setValue(2) ; /* myMinDeg */
SpinBox_C1A3->setValue(5) ; /* myMaxDeg */
LineEditC1A4->setText("0.0001") ; /* myTol3D */
LineEditC1A5->setText("0.0001") ; /* myTol2D */
SpinBox_C1A6->setValue(5) ; /* myNbIter */
this->myMinDeg = 2 ;
this->myMaxDeg = 5 ;
this->myTol3D = 0.0001 ;
this->myTol2D = 0.0001 ;
this->myNbIter = 5 ;
myOkSectionShape = false ;
mySectionShape.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myCompoundFilter = new GEOM_ShapeTypeFilter( TopAbs_COMPOUND, myGeom );
/* first filter used */
mySelection->AddFilter(myCompoundFilter) ;
/* 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( LineEditC1A1, SIGNAL (returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
/* Displays Dialog */
this->show() ;
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_FillingDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::ClickOnApply()
{
switch(myConstructorId)
{
case 0 :
{
this->myMinDeg = SpinBox_C1A2->value() ;
this->myMaxDeg = SpinBox_C1A3->value() ;
this->myTol3D = LineEditC1A4->text().toDouble();
this->myTol2D = LineEditC1A5->text().toDouble();
this->myNbIter = SpinBox_C1A6->value() ;
if(myOkSectionShape) {
myGeomGUI->MakeFillingAndDisplay( myGeomShape, myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter) ;
}
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_FillingDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ;
QString aString = ""; /* name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
myOkSectionShape = false ;
}
return ;
}
// nbSel == 1
TopoDS_Shape S;
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1 && S.ShapeType() == TopAbs_COMPOUND ) {
myEditCurrentArgument->setText(aString) ;
myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myOkSectionShape = true ;
}
/* no simulation */
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
mySelection->AddFilter(myCompoundFilter) ;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_FillingDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}

View File

@ -0,0 +1,127 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FillingDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_FILLING_H
#define DIALOGBOX_FILLING_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <qvariant.h>
#include <qdialog.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QLabel;
class QLineEdit;
class QSpinBox;
class QPushButton;
class QRadioButton;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_FillingDlg
// purpose :
//=================================================================================
class GeometryGUI_FillingDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_FillingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_FillingDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
GEOM::GEOM_Shape_var myGeomShape ; /* is mySectionShape */
TopoDS_Shape mySectionShape ;
Standard_Integer myMinDeg ;
Standard_Integer myMaxDeg ;
Standard_Real myTol3D ;
Standard_Real myTol2D ;
Standard_Integer myNbIter ;
bool myOkSectionShape ; /* to check when arguments is defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
Handle(GEOM_ShapeTypeFilter) myCompoundFilter ; /* Filter selection */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QGroupBox* GroupC1;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A2;
QLabel* TextLabelC1A3;
QLabel* TextLabelC1A5;
QLineEdit* LineEditC1A5;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLabel* TextLabelC1A4;
QLabel* TextLabelC1A6;
QLineEdit* LineEditC1A4;
QSpinBox* SpinBox_C1A2;
QSpinBox* SpinBox_C1A3;
QSpinBox* SpinBox_C1A6;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void LineEditReturnPressed() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_FillingDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupC1Layout;
};
#endif // DIALOGBOX_FILLING_H

View File

@ -0,0 +1,542 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FillingHoleDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_FillingHoleDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#include <qbuttongroup.h>
#include <qcheckbox.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 : GeometryGUI_FillingHoleDlg()
// purpose : Constructs a GeometryGUI_FillingHoleDlg 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.
//=================================================================================
GeometryGUI_FillingHoleDlg::GeometryGUI_FillingHoleDlg( QWidget* parent,
const char* name,
SALOME_Selection* Sel,
Handle (AIS_InteractiveContext) ic,
bool modal,
WFlags fl )
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_SEWING")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_FillingHoleDlg" );
resize( 303, 203 );
setCaption( tr( "Filling hole" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_FillingHoleDlgLayout = new QGridLayout( this );
GeometryGUI_FillingHoleDlgLayout->setSpacing( 6 );
GeometryGUI_FillingHoleDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "" ) );
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 );
GeometryGUI_FillingHoleDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "" ) );
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 );
Layout2 = new QHBoxLayout;
Layout2->setSpacing( 6 );
Layout2->setMargin( 0 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "Main object" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
Layout2->addWidget( TextLabelC1A1 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
Layout2->addWidget( SelectButtonC1A1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setAlignment( int( QLineEdit::AlignLeft ) );
Layout2->addWidget( LineEditC1A1 );
GroupC1Layout->addLayout( Layout2, 0, 0 );
CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" );
CheckBox1->setText( tr( "Select edges of hole on main object" ) );
CheckBox1->setChecked( FALSE );
GroupC1Layout->addWidget( CheckBox1, 1, 0 );
GeometryGUI_FillingHoleDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupButtons->sizePolicy().hasHeightForWidth() ) );
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 );
buttonClose = new QPushButton( GroupButtons, "buttonClose" );
buttonClose->setText( tr( "&Close" ) );
buttonClose->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonClose, 0, 3 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "&Ok" ) );
buttonOk->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "&Apply" ) );
buttonApply->setAutoDefault( TRUE );
buttonApply->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_2, 0, 2 );
GeometryGUI_FillingHoleDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisations */
Init(Sel, ic) ;
}
//=================================================================================
// function : ~GeometryGUI_FillingHoleDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_FillingHoleDlg::~GeometryGUI_FillingHoleDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
{
GroupC1->show();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myShape.Nullify() ;
myIC = ic ;
myUseLocalContext = false ;
myOkShape = false ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
/* Select sub shapes mode not checked */
CheckBox1->setChecked( FALSE );
myOkSelectSubMode = false ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( buttonClose, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) );
connect( GroupConstructors, SIGNAL( clicked(int) ), this, SLOT( ConstructorsClicked(int) ));
connect( LineEditC1A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ));
connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserSelection() ));
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ));
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnClose() ));
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* display Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_FillingHoleDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose : Same than click on apply but close this dialog.
//=================================================================================
void GeometryGUI_FillingHoleDlg::ClickOnOk()
{
this->ClickOnApply() ;
accept();
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::ClickOnApply()
{
bool testResult = false ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if( myOkShape && myOkSelectSubMode ) {
testResult = myGeomGUI->OnFillingHole( myShape, myShapeIOR, myLocalContextId, myUseLocalContext ) ;
}
if( !testResult ) {
myGeomGUI->GetDesktop()->putInfo(tr("Operation aborted")) ;
}
else {
myGeomGUI->GetDesktop()->putInfo(tr("Operation done"));
}
/* Reset arguments to allow a new selection */
this->ResetStateOfDialog() ;
break ;
}
}
return ;
}
//=================================================================================
// function : ClickOnClose()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::ClickOnClose()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
if(myUseLocalContext) {
myIC->CloseLocalContext(myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
// : used only by SelectButtonC1A1 (LineEditC1A1)
//=================================================================================
void GeometryGUI_FillingHoleDlg::SelectionIntoArgument()
{
/* Reset argument and local context when selection as changed */
this->ResetStateOfDialog() ;
QString aString = ""; /* name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 )
return ;
/* nbSel == 1 */
TopoDS_Shape S ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
// if( !IO->hasEntry() ) {
// myGeomGUI->GetDesktop()->putInfo(tr("Main shape must be in the study before")) ;
// return ;
// }
/* Test the exact type of topology to fill an hole */
if ( !S.IsNull() && ( S.ShapeType() == TopAbs_SOLID || S.ShapeType() == TopAbs_SHELL || S.ShapeType() == TopAbs_COMPOUND ) ) {
if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
myShapeIOR = GIObject->getIOR(); /* the Geom IOR string of selection */
LineEditC1A1->setText(aString) ;
myShape = S ;
myOkShape = true ;
return;
}
if ( IO->hasEntry() ) {
SALOMEDS::Study_var aStudy = myGeomGUI->GetActiveStudy()->getStudyDocument();
SALOMEDS::SObject_var obj = aStudy->FindObjectID( IO->getEntry() );
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR;
if ( !obj->_is_nil() ) {
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
myShapeIOR = anIOR->Value();
myOkShape = true ;
myShape = S ;
LineEditC1A1->setText(aString) ;
return;
}
}
}
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
SelectionIntoArgument() ;
}
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
this->ResetStateOfDialog() ;
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
myGeomGUI->ResetState() ;
myGeomGUI->SetActiveDialogBox(0) ;
myGeomGUI->OnDisplayAll(true) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate other active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it
//=================================================================================
void GeometryGUI_FillingHoleDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_FillingHoleDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnClose() ;
return ;
}
//=================================================================================
// function : ActivateUserSelection()
// purpose : Activate selection of faces when CheckBox1->isChecked()...
//=================================================================================
void GeometryGUI_FillingHoleDlg::ActivateUserSelection()
{
if( !this->myOkShape ) {
this->ResetStateOfDialog() ;
myGeomGUI->GetDesktop()->putInfo(tr("Select main shape first")) ;
return ;
}
this->myOkSelectSubMode = CheckBox1->isChecked() ;
if( this->myUseLocalContext ) {
myIC->CloseLocalContext(myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
if( myOkShape && myOkSelectSubMode ) {
/* local context is defined into the method : GEOM::EDGE sub selection */
TopAbs_ShapeEnum aType = TopAbs_EDGE ;
myGeomGUI->PrepareSubShapeSelection( int(aType), this->myLocalContextId ) ;
myUseLocalContext = true ;
myGeomGUI->GetDesktop()->putInfo(tr("Select edges to fill an hole and click on Ok/Apply")) ;
}
return ;
}
//=================================================================================
// function : ResetStateOfDialog()
// purpose : Completely reset the state of method including local context
//=================================================================================
void GeometryGUI_FillingHoleDlg::ResetStateOfDialog()
{
this->myOkShape = false ;
this->myEditCurrentArgument->setText("") ;
/* Select sub shapes mode not checked */
this->myOkSelectSubMode = false ;
this->CheckBox1->setChecked( FALSE );
/* Close its local contact if opened */
if( this->myUseLocalContext ) {
myIC->CloseLocalContext(this->myLocalContextId) ;
this->myUseLocalContext = false ;
myGeomGUI->OnDisplayAll(true) ;
}
return ;
}

View File

@ -0,0 +1,133 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FillingHoleDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef GEOMETRYGUI_FILLINGHOLE_H
#define GEOMETRYGUI_FILLINGHOLE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <qvariant.h>
#include <qdialog.h>
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QButtonGroup;
class QCheckBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class GeometryGUI;
//=================================================================================
// class : GeometryGUI_FillingHoleDlg
// purpose :
//=================================================================================
class GeometryGUI_FillingHoleDlg : public QDialog
{
Q_OBJECT
public :
GeometryGUI_FillingHoleDlg( QWidget* parent = 0,
const char* name = 0,
SALOME_Selection* Sel = 0,
Handle (AIS_InteractiveContext) ic = 0,
bool modal = FALSE,
WFlags fl = 0 );
~GeometryGUI_FillingHoleDlg();
private :
void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void ResetStateOfDialog() ;
/* Interactive and local context management see also : bool myUseLocalContext() */
Handle (AIS_InteractiveContext) myIC ; /* Interactive context */
Standard_Integer myLocalContextId ; /* identify a local context used by this method */
bool myUseLocalContext ; /* true when this method as opened a local context */
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape ;
char* myShapeIOR ;
bool myOkShape ;
bool myOkSelectSubMode ; /* true = sub mode selection activated */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QCheckBox* CheckBox1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonApply;
QPushButton* buttonClose;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnApply() ;
void ClickOnClose();
void LineEditReturnPressed() ;
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void ActivateUserSelection() ;
protected:
QGridLayout* GeometryGUI_FillingHoleDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QHBoxLayout* Layout2;
QGridLayout* GroupButtonsLayout;
};
#endif // GEOMETRYGUI_FILLINGHOLE_H

View File

@ -0,0 +1,477 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FuseDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_FuseDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_FuseDlg()
// purpose : Constructs a GeometryGUI_FuseDlg 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.
//=================================================================================
GeometryGUI_FuseDlg::GeometryGUI_FuseDlg( 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( "GeometryGUI",tr("ICON_DLG_FUSE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_FuseDlg" );
resize( 322, 220 );
setCaption( tr( "GEOM_FUSE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_FuseDlgLayout = new QGridLayout( this );
GeometryGUI_FuseDlgLayout->setSpacing( 6 );
GeometryGUI_FuseDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_FUSE" ) );
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 );
GeometryGUI_FuseDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_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 );
LineEditC1A2Shape = new QLineEdit( GroupConstructor1, "LineEditC1A2Shape" );
LineEditC1A2Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A2Shape, 1, 2 );
LineEditC1A1Shape = new QLineEdit( GroupConstructor1, "LineEditC1A1Shape" );
LineEditC1A1Shape->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Shape->sizePolicy().hasHeightForWidth() ) );
GroupConstructor1Layout->addWidget( LineEditC1A1Shape, 0, 2 );
SelectButtonC1A1Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A1Shape" );
SelectButtonC1A1Shape->setText( tr( "" ) );
SelectButtonC1A1Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A1Shape, 0, 1 );
SelectButtonC1A2Shape = new QPushButton( GroupConstructor1, "SelectButtonC1A2Shape" );
SelectButtonC1A2Shape->setText( tr( "" ) );
SelectButtonC1A2Shape->setPixmap( image1 );
GroupConstructor1Layout->addWidget( SelectButtonC1A2Shape, 1, 1 );
TextLabelC1A2Shape = new QLabel( GroupConstructor1, "TextLabelC1A2Shape" );
TextLabelC1A2Shape->setText( tr( "GEOM_OBJECT_I" ).arg("2") );
TextLabelC1A2Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A2Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A2Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A2Shape, 1, 0 );
TextLabelC1A1Shape = new QLabel( GroupConstructor1, "TextLabelC1A1Shape" );
TextLabelC1A1Shape->setText( tr( "GEOM_OBJECT_I" ).arg("1") );
TextLabelC1A1Shape->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1Shape->setFrameShape( QLabel::NoFrame );
TextLabelC1A1Shape->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabelC1A1Shape, 0, 0 );
GeometryGUI_FuseDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_FuseDlgLayout->addWidget( GroupButtons, 2, 0 );
/* Initialisation */
Init( Sel ) ;
}
//=================================================================================
// function : ~GeometryGUI_FuseDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_FuseDlg::~GeometryGUI_FuseDlg()
{
/* no need to delete child widgets, Qt does it all for us */
this->destroy(TRUE, TRUE) ;
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::Init( SALOME_Selection* Sel )
{
mySelection = Sel ;
myShape1.Nullify() ;
myShape2.Nullify() ;
myConstructorId = 0 ;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
GroupConstructor1->show();
myConstructorId = 0 ;
myEditCurrentArgument = LineEditC1A1Shape ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
// TODO previous selection into argument ?
/* 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( LineEditC1A1Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2Shape, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( SelectButtonC1A1Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( SelectButtonC1A2Shape, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* Displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_FuseDlg::ConstructorsClicked(int constructorId)
{
GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupConstructor1->show();
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1Shape ;
LineEditC1A2Shape->setText(tr("")) ;
Constructor1->setChecked( TRUE );
myOkShape1 = myOkShape2 = false ;
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
switch(myConstructorId)
{
case 0 :
{
if(myOkShape1 && myOkShape2) {
myGeomGUI->MakeBooleanAndDisplay(myGeomShape1 ,myGeomShape2, 3 ) ;
}
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::ClickOnCancel()
{
myGeomGUI->EraseSimulationShape() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection has changed
//=================================================================================
void GeometryGUI_FuseDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("") ; /* by default */
QString aString = ""; /* the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
switch (myConstructorId)
{
case 0:
{
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myOkShape1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myOkShape2 = false ;
}
break ;
}
}
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
Standard_Boolean testResult ;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if ( myEditCurrentArgument == LineEditC1A1Shape ) {
myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape1 = S ;
LineEditC1A1Shape->setText(aString) ;
myOkShape1 = true ;
}
else if ( myEditCurrentArgument == LineEditC1A2Shape ) {
myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
if( !testResult )
return ;
myShape2 = S ;
LineEditC1A2Shape->setText(aString) ;
myOkShape2 = true ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if( send == SelectButtonC1A1Shape ) {
LineEditC1A1Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A1Shape ;
}
else if(send == SelectButtonC1A2Shape) {
LineEditC1A2Shape->setFocus() ;
myEditCurrentArgument = LineEditC1A2Shape;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1Shape )
myEditCurrentArgument = LineEditC1A1Shape ;
else if ( send == LineEditC1A2Shape )
myEditCurrentArgument = LineEditC1A2Shape ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
}
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void GeometryGUI_FuseDlg::enterEvent( QEvent * )
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_FuseDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate any active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}

View File

@ -0,0 +1,119 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_FuseDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_FUSE_H
#define DIALOGBOX_FUSE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepAlgoAPI_Fuse.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_FuseDlg
// purpose :
//=================================================================================
class GeometryGUI_FuseDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_FuseDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_FuseDlg();
private:
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
TopoDS_Shape myShape1 ; /* topology used to fuse */
TopoDS_Shape myShape2 ; /* topology used to fuse */
GEOM::GEOM_Shape_var myGeomShape1 ; /* is myShape1 */
GEOM::GEOM_Shape_var myGeomShape2 ; /* is myShape2 */
bool myOkShape1 ;
bool myOkShape2 ; /* to check when arguments are defined */
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupConstructor1;
QLineEdit* LineEditC1A1Shape;
QLineEdit* LineEditC1A2Shape;
QPushButton* SelectButtonC1A1Shape;
QPushButton* SelectButtonC1A2Shape;
QLabel* TextLabelC1A2Shape;
QLabel* TextLabelC1A1Shape;
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* GeometryGUI_FuseDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupConstructor1Layout;
};
#endif // DIALOGBOX_FUSE_H

View File

@ -0,0 +1,566 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_InertiaDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
using namespace std;
#include "GeometryGUI_InertiaDlg.h"
#include "GeometryGUI.h"
#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 : GeometryGUI_InertiaDlg()
// purpose : Constructs a GeometryGUI_InertiaDlg 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.
//=================================================================================
GeometryGUI_InertiaDlg::GeometryGUI_InertiaDlg( 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( "GeometryGUI",tr("ICON_DLG_INERTIA")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_InertiaDlg" );
resize( 356, 303 );
setCaption( tr( "GEOM_INERTIA_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_InertiaDlgLayout = new QGridLayout( this );
GeometryGUI_InertiaDlgLayout->setSpacing( 6 );
GeometryGUI_InertiaDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_INERTIA_CONSTR" ) );
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 );
GeometryGUI_InertiaDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_OBJECT_RESULT" ) );
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( "GEOM_OBJECT" ) );
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 );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
LineEditC1A1->setMinimumSize( QSize( 220, 0 ) );
GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 4 );
TextLabel_Matrix = new QLabel( GroupC1, "TextLabel_Matrix" );
TextLabel_Matrix->setText( tr( "GEOM_MATRIX" ) );
TextLabel_Matrix->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Matrix->setFrameShape( QLabel::NoFrame );
TextLabel_Matrix->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabel_Matrix, 1, 0 );
TextLabelMatrix_11 = new QLabel( GroupC1, "TextLabelMatrix_11" );
TextLabelMatrix_11->setText( tr( "GEOM_INERTIA_I" ).arg("1") );
TextLabelMatrix_11->setMinimumSize( QSize( 0, 0 ) );
TextLabelMatrix_11->setFrameShape( QLabel::NoFrame );
TextLabelMatrix_11->setFrameShadow( QLabel::Plain );
TextLabelMatrix_11->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
GroupC1Layout->addWidget( TextLabelMatrix_11, 1, 1 );
TextLabelMatrix_21 = new QLabel( GroupC1, "TextLabelMatrix_21" );
TextLabelMatrix_21->setText( tr( "GEOM_INERTIA_I" ).arg("2") );
TextLabelMatrix_21->setMinimumSize( QSize( 0, 0 ) );
TextLabelMatrix_21->setFrameShape( QLabel::NoFrame );
TextLabelMatrix_21->setFrameShadow( QLabel::Plain );
TextLabelMatrix_21->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
GroupC1Layout->addWidget( TextLabelMatrix_21, 2, 1 );
TextLabelMatrix_31 = new QLabel( GroupC1, "TextLabelMatrix_31" );
TextLabelMatrix_31->setText( tr( "GEOM_INERTIA_I" ).arg("3") );
TextLabelMatrix_31->setMinimumSize( QSize( 0, 0 ) );
TextLabelMatrix_31->setFrameShape( QLabel::NoFrame );
TextLabelMatrix_31->setFrameShadow( QLabel::Plain );
TextLabelMatrix_31->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
GroupC1Layout->addWidget( TextLabelMatrix_31, 3, 1 );
LineEdit_L1C1 = new QLineEdit( GroupC1, "LineEdit_L1C1" );
LineEdit_L1C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C1->sizePolicy().hasHeightForWidth() ) );
LineEdit_L1C1->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L1C1->setEnabled( FALSE );
LineEdit_L1C1->setReadOnly( TRUE );
LineEdit_L1C1->setText( tr( "" ) );
GroupC1Layout->addWidget( LineEdit_L1C1, 1, 2 );
LineEdit_L1C2 = new QLineEdit( GroupC1, "LineEdit_L1C2" );
LineEdit_L1C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C2->sizePolicy().hasHeightForWidth() ) );
LineEdit_L1C2->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L1C2->setEnabled( FALSE );
LineEdit_L1C2->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L1C2, 1, 3 );
LineEdit_L1C3 = new QLineEdit( GroupC1, "LineEdit_L1C3" );
LineEdit_L1C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L1C3->sizePolicy().hasHeightForWidth() ) );
LineEdit_L1C3->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L1C3->setEnabled( FALSE );
LineEdit_L1C3->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L1C3, 1, 4 );
LineEdit_L2C1 = new QLineEdit( GroupC1, "LineEdit_L2C1" );
LineEdit_L2C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C1->sizePolicy().hasHeightForWidth() ) );
LineEdit_L2C1->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L2C1->setEnabled( FALSE );
LineEdit_L2C1->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L2C1, 2, 2 );
LineEdit_L2C2 = new QLineEdit( GroupC1, "LineEdit_L2C2" );
LineEdit_L2C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C2->sizePolicy().hasHeightForWidth() ) );
LineEdit_L2C2->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L2C2->setEnabled( FALSE );
LineEdit_L2C2->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L2C2, 2, 3 );
LineEdit_L2C3 = new QLineEdit( GroupC1, "LineEdit_L2C3" );
LineEdit_L2C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L2C3->sizePolicy().hasHeightForWidth() ) );
LineEdit_L2C3->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L2C3->setEnabled( FALSE );
LineEdit_L2C3->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L2C3, 2, 4 );
LineEdit_L3C1 = new QLineEdit( GroupC1, "LineEdit_L3C1" );
LineEdit_L3C1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C1->sizePolicy().hasHeightForWidth() ) );
LineEdit_L3C1->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L3C1->setEnabled( FALSE );
LineEdit_L3C1->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L3C1, 3, 2 );
LineEdit_L3C2 = new QLineEdit( GroupC1, "LineEdit_L3C2" );
LineEdit_L3C2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C2->sizePolicy().hasHeightForWidth() ) );
LineEdit_L3C2->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L3C2->setEnabled( FALSE );
LineEdit_L3C2->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L3C2, 3, 3 );
LineEdit_L3C3 = new QLineEdit( GroupC1, "LineEdit_L3C3" );
LineEdit_L3C3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_L3C3->sizePolicy().hasHeightForWidth() ) );
LineEdit_L3C3->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_L3C3->setEnabled( FALSE );
LineEdit_L3C3->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_L3C3, 3, 4 );
LineEdit_IX = new QLineEdit( GroupC1, "LineEdit_IX" );
LineEdit_IX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IX->sizePolicy().hasHeightForWidth() ) );
LineEdit_IX->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_IX->setEnabled( FALSE );
LineEdit_IX->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_IX, 4, 2 );
LineEdit_IY = new QLineEdit( GroupC1, "LineEdit_IY" );
LineEdit_IY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IY->sizePolicy().hasHeightForWidth() ) );
LineEdit_IY->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_IY->setEnabled( FALSE );
LineEdit_IY->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_IY, 4, 3 );
LineEdit_IZ = new QLineEdit( GroupC1, "LineEdit_IZ" );
LineEdit_IZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_IZ->sizePolicy().hasHeightForWidth() ) );
LineEdit_IZ->setMinimumSize( QSize( 70, 0 ) );
//LineEdit_IZ->setEnabled( FALSE );
LineEdit_IZ->setReadOnly( TRUE );
GroupC1Layout->addWidget( LineEdit_IZ, 4, 4 );
TextLabel_IXIYIZ = new QLabel( GroupC1, "TextLabel_IXIYIZ" );
TextLabel_IXIYIZ->setText( tr( "GEOM_INERTIA_IXYZ" ) );
TextLabel_IXIYIZ->setMinimumSize( QSize( 50, 0 ) );
TextLabel_IXIYIZ->setFrameShape( QLabel::NoFrame );
TextLabel_IXIYIZ->setFrameShadow( QLabel::Plain );
TextLabel_IXIYIZ->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
GroupC1Layout->addMultiCellWidget( TextLabel_IXIYIZ, 4, 4, 0, 1 );
GeometryGUI_InertiaDlgLayout->addWidget( GroupC1, 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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_8, 0, 0 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
GeometryGUI_InertiaDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_InertiaDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_InertiaDlg::~GeometryGUI_InertiaDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::Init( SALOME_Selection* Sel )
{
LineEdit_L1C1->setMaxLength( 10 );
LineEdit_L1C2->setMaxLength( 10 );
LineEdit_L1C3->setMaxLength( 10 );
LineEdit_L2C1->setMaxLength( 10 );
LineEdit_L2C2->setMaxLength( 10 );
LineEdit_L2C3->setMaxLength( 10 );
LineEdit_L3C1->setMaxLength( 10 );
LineEdit_L3C2->setMaxLength( 10 );
LineEdit_L3C3->setMaxLength( 10 );
LineEdit_IX->setMaxLength( 10 );
LineEdit_IY->setMaxLength( 10 );
LineEdit_IZ->setMaxLength( 10 );
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* signals and slots connections */
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) );
connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_InertiaDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_InertiaDlg::SelectionIntoArgument()
{
LineEdit_L1C1->setText("") ;
LineEdit_L1C2->setText("") ;
LineEdit_L1C3->setText("") ;
LineEdit_L2C1->setText("") ;
LineEdit_L2C2->setText("") ;
LineEdit_L2C3->setText("") ;
LineEdit_L3C1->setText("") ;
LineEdit_L3C2->setText("") ;
LineEdit_L3C3->setText("") ;
LineEdit_IX->setText("") ;
LineEdit_IY->setText("") ;
LineEdit_IZ->setText("") ;
myEditCurrentArgument->setText("") ;
QString aString = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) || S.IsNull() )
return ;
LineEditC1A1->setText(aString) ;
this->CalculateAndDisplayInertia(S) ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : CalculateAndDisplayInertia()
// purpose :
//=================================================================================
void GeometryGUI_InertiaDlg::CalculateAndDisplayInertia(const TopoDS_Shape& S)
{
LineEdit_L1C1->setText("") ;
LineEdit_L1C2->setText("") ;
LineEdit_L1C3->setText("") ;
LineEdit_L2C1->setText("") ;
LineEdit_L2C2->setText("") ;
LineEdit_L2C3->setText("") ;
LineEdit_L3C1->setText("") ;
LineEdit_L3C2->setText("") ;
LineEdit_L3C3->setText("") ;
LineEdit_IX->setText("") ;
LineEdit_IY->setText("") ;
LineEdit_IZ->setText("") ;
if( S.IsNull() )
return ;
try {
QString resString;
GProp_GProps System;
if ( S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
BRepGProp::LinearProperties(S, System);
}
else if ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) {
BRepGProp::SurfaceProperties(S, System);
}
else {
BRepGProp::VolumeProperties(S, System);
}
gp_Mat I = System.MatrixOfInertia() ;
GProp_PrincipalProps Pr = System.PrincipalProperties();
Standard_Real Ix,Iy,Iz;
Pr.Moments(Ix,Iy,Iz);
/* matrix 3x3 */
resString = tr("%1").arg( I(1,1), 12, 'f', 6 ) ;
LineEdit_L1C1->setText(resString) ;
resString = tr("%1").arg( I(1,2), 12, 'f', 6 ) ;
LineEdit_L1C2->setText(resString) ;
resString = tr("%1").arg( I(1,3), 12, 'f', 6 ) ;
LineEdit_L1C3->setText(resString) ;
resString = tr("%1").arg( I(2,1), 12, 'f', 6 ) ;
LineEdit_L2C1->setText(resString) ;
resString = tr("%1").arg( I(2,2), 12, 'f', 6 ) ;
LineEdit_L2C2->setText(resString) ;
resString = tr("%1").arg( I(2,3), 12, 'f', 6 ) ;
LineEdit_L2C3->setText(resString) ;
resString = tr("%1").arg( I(3,1), 12, 'f', 6 ) ;
LineEdit_L3C1->setText(resString) ;
resString = tr("%1").arg( I(3,2), 12, 'f', 6 ) ;
LineEdit_L3C2->setText(resString) ;
resString = tr("%1").arg( I(3,3), 12, 'f', 6 ) ;
LineEdit_L3C3->setText(resString) ;
/* moments */
resString = tr("%1").arg( Ix, 12, 'f', 6 ) ;
LineEdit_IX->setText(resString) ;
resString = tr("%1").arg( Ix, 12, 'f', 6 ) ;
LineEdit_IY->setText(resString) ;
resString = tr("%1").arg( Iz, 12, 'f', 6 ) ;
LineEdit_IZ->setText(resString) ;
}
catch(Standard_Failure) {
MESSAGE("Catch intercepted in CalculateAndDisplayInertia()" << endl ) ;
}
return ;
}

View File

@ -0,0 +1,124 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_InertiaDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_INERTIA_H
#define DIALOGBOX_INERTIA_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
#include <GProp_PrincipalProps.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_InertiaDlg
// purpose :
//=================================================================================
class GeometryGUI_InertiaDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_InertiaDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_InertiaDlg();
void Init( SALOME_Selection* Sel ) ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void CalculateAndDisplayInertia(const TopoDS_Shape& S) ;
GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
SALOME_Selection* mySelection ;
int myConstructorId ; /* Current constructor id = radio button id */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1;
QLabel* TextLabel_Matrix;
QLabel* TextLabelMatrix_11;
QLabel* TextLabelMatrix_21;
QLabel* TextLabelMatrix_31;
QLineEdit* LineEdit_L1C1;
QLineEdit* LineEdit_L1C2;
QLineEdit* LineEdit_L1C3;
QLineEdit* LineEdit_L2C1;
QLineEdit* LineEdit_L2C2;
QLineEdit* LineEdit_L2C3;
QLineEdit* LineEdit_L3C1;
QLineEdit* LineEdit_L3C2;
QLineEdit* LineEdit_L3C3;
QLineEdit* LineEdit_IX;
QLineEdit* LineEdit_IY;
QLineEdit* LineEdit_IZ;
QLabel* TextLabel_IXIYIZ;
QGroupBox* GroupButtons;
QPushButton* buttonApply;
QPushButton* buttonOk;
QPushButton* buttonCancel;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnCancel();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_InertiaDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_INERTIA_H

View File

@ -0,0 +1,518 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_LineDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_LineDlg.h"
#include "GeometryGUI.h"
#include <Precision.hxx>
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
#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 : GeometryGUI_LineDlg()
// purpose : Constructs a GeometryGUI_LineDlg 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.
//=================================================================================
GeometryGUI_LineDlg::GeometryGUI_LineDlg( 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( "GeometryGUI",tr("ICON_DLG_LINE_2P")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_LINE_PV")));
QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_LINE_EDGE")));
if ( !name )
setName( "GeometryGUI_LineDlg" );
resize( 303, 225 );
setCaption( tr( "GEOM_LINE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_LineDlgLayout = new QGridLayout( this );
GeometryGUI_LineDlgLayout->setSpacing( 6 );
GeometryGUI_LineDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_LINE" ) );
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 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer_3, 0, 5 );
GeometryGUI_LineDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupC1 = new QGroupBox( this, "GroupC1" );
GroupC1->setTitle( tr( "GEOM_POINTS" ) );
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 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setText( tr( "" ) );
SelectButtonC1A2->setPixmap( image1 );
GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_POINT_I" ).arg("1") );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
TextLabelC1A2->setText( tr( "GEOM_POINT_I" ).arg("2") );
TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
GeometryGUI_LineDlgLayout->addWidget( GroupC1, 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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "GEOM_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( "GEOM_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_LineDlgLayout->addWidget( GroupButtons, 2, 0 );
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_LineDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_LineDlg::~GeometryGUI_LineDlg()
{
/* no need to delete child widgets, Qt does it all for us */
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::Init( SALOME_Selection* Sel )
{
GroupC1->show();
// GroupC2->hide();
// GroupC3->hide();
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myPoint1.SetCoord( 0.0, 0.0, 0.0 );
myPoint2.SetCoord( 0.0, 0.0, 0.0 );
myOkPoint1 = myOkPoint2 = false ;
mySimulationTopoDs.Nullify() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filters definition */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
myVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX, myGeom );
myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
mySelection->AddFilter(myVertexFilter) ; /* first filter used */
/* 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( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_LineDlg::ConstructorsClicked(int constructorId)
{
myGeomGUI->EraseSimulationShape() ;
switch (constructorId)
{
case 0:
{
GroupC1->show();
//
//
myConstructorId = constructorId ;
myEditCurrentArgument = LineEditC1A1 ;
Constructor1->setChecked( TRUE );
LineEditC1A1->setText(tr("")) ;
LineEditC1A2->setText(tr("")) ;
myOkPoint1 = myOkPoint2 = false ;
/* filter for next selections */
mySelection->ClearFilters() ;
mySelection->AddFilter( myVertexFilter );
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break;
}
case 1:
{
break;
}
case 2:
{
break;
}
}
return ;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::ClickOnOk()
{
this->ClickOnApply() ;
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::ClickOnApply()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
switch(myConstructorId)
{
case 0 :
{
if(myOkPoint1 && myOkPoint2)
myGeomGUI->MakeLineAndDisplay( myPoint1, myPoint2 ) ;
break ;
}
case 1 :
{
break ;
}
case 2 :
{
break ;
}
}
// accept();
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::ClickOnCancel()
{
mySelection->ClearFilters() ;
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender() ;
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else if ( send == LineEditC1A2 )
myEditCurrentArgument = LineEditC1A2 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_LineDlg::SelectionIntoArgument()
{
myGeomGUI->EraseSimulationShape() ;
mySimulationTopoDs.Nullify() ;
QString aString = ""; /* name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
if ( myEditCurrentArgument == LineEditC1A1 ) {
myEditCurrentArgument->setText("") ;
myOkPoint1 = false ;
}
else if ( myEditCurrentArgument == LineEditC1A2 ) {
myEditCurrentArgument->setText("") ;
myOkPoint2 = false ;
}
return ;
}
// nbSel == 1 !
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
/* Constructor 1 treatment */
if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint1 = true ;
}
else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
myEditCurrentArgument->setText(aString) ;
myOkPoint2 = true ;
}
if( myOkPoint1 && myOkPoint2 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
/* Try to add an arrow at simulation shape */
bool notNeedToTest = this->AddArrowToSimulation(mySimulationTopoDs) ;
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
}
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
mySelection->ClearFilters() ;
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
else if(send == SelectButtonC1A2) {
LineEditC1A2->setFocus() ;
myEditCurrentArgument = LineEditC1A2;
}
mySelection->AddFilter(myVertexFilter) ;
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
GroupConstructors->setEnabled(false) ;
GroupC1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
disconnect( mySelection, 0, this, 0 );
myGeomGUI->EraseSimulationShape() ;
mySelection->ClearFilters() ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupC1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
if( !mySimulationTopoDs.IsNull() )
myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_LineDlg::closeEvent( QCloseEvent* e )
{
this->ClickOnCancel() ; /* same than click on cancel button */
}
//=================================================================================
// function : AddArrowToSimulation()
// purpose : An arrow (cone topology) is added to 'modifiedShape'
// : to simulate a vector or an 'oriented line' display. The result is in 'modifiedShape'.
// : If an arrow can't be added returns false and 'modifiedShape' isn't modified !
//=================================================================================
bool GeometryGUI_LineDlg::AddArrowToSimulation( TopoDS_Shape& modifiedShape )
{
TopoDS_Shape arrow ;
/* Try to add a cone simulation shape to show direction of a linear edge */
if( myGeomGUI->CreateArrowForLinearEdge( modifiedShape, arrow ) ) {
TopoDS_Compound Comp ;
BRep_Builder B;
B.MakeCompound (Comp);
B.Add( Comp, modifiedShape ) ;
B.Add( Comp, arrow ) ;
modifiedShape = Comp ;
return true ;
}
return false ;
}

View File

@ -0,0 +1,125 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_LineDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_LINE_H
#define DIALOGBOX_LINE_H
#include "SALOME_Selection.h"
#include "GEOM_ShapeTypeFilter.hxx"
#include <gp_Pnt.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#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 GeometryGUI;
//=================================================================================
// class : GeometryGUI_LineDlg
// purpose :
//=================================================================================
class GeometryGUI_LineDlg : public QDialog
{
Q_OBJECT
public:
GeometryGUI_LineDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
~GeometryGUI_LineDlg();
private :
GEOM::GEOM_Gen_var myGeom ; /* Current Geom object */
GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
SALOME_Selection* mySelection ; /* User shape selection */
gp_Pnt myPoint1 ; /* Points containing the vector */
gp_Pnt myPoint2 ;
bool myOkPoint1 ; /* Are true when myPoint is defined */
bool myOkPoint2 ;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myConstructorId ; /* Current constructor id = radio button id */
Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */
Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */
void closeEvent( QCloseEvent* e ) ;
void enterEvent( QEvent* e);
void Init( SALOME_Selection* Sel ) ;
bool AddArrowToSimulation( TopoDS_Shape& modifiedShape ) ;
QButtonGroup* GroupConstructors;
QRadioButton* Constructor1;
QRadioButton* Constructor2;
QRadioButton* Constructor3;
QGroupBox* GroupC1;
QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A2;
QLineEdit* LineEditC1A1;
QLabel* TextLabelC1A2;
QLineEdit* LineEditC1A2;
QPushButton* SelectButtonC1A1;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void LineEditReturnPressed() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
protected:
QGridLayout* GeometryGUI_LineDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupC1Layout;
QGridLayout* GroupButtonsLayout;
};
#endif // DIALOGBOX_LINE_H

View File

@ -0,0 +1,547 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : GeometryGUI_MaxToleranceDlg.cxx
// Author : Nicolas REJNERI
// Module : GEOM
// $Header$
using namespace std;
#include "GeometryGUI_MaxToleranceDlg.h"
#include "GeometryGUI.h"
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "utilities.h"
// Open CASCADE Includes
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
// 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 : GeometryGUI_MaxToleranceDlg()
// purpose : Constructs a GeometryGUI_MaxToleranceDlg 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.
//=================================================================================
GeometryGUI_MaxToleranceDlg::GeometryGUI_MaxToleranceDlg( 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( "GeometryGUI",tr("ICON_DLG_TOLERANCE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
if ( !name )
setName( "GeometryGUI_MaxToleranceDlg" );
resize( 303, 275 );
setCaption( tr( "GEOM_TOLERANCE_TITLE" ) );
setSizeGripEnabled( TRUE );
GeometryGUI_MaxToleranceDlgLayout = new QGridLayout( this );
GeometryGUI_MaxToleranceDlgLayout->setSpacing( 6 );
GeometryGUI_MaxToleranceDlgLayout->setMargin( 11 );
/***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
GroupConstructors->setTitle( tr( "GEOM_TOLERANCE" ) );
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)3, (QSizePolicy::SizeType)0,
Constructor1->sizePolicy().hasHeightForWidth() ) );
Constructor1->setMinimumSize( QSize( 60, 0 ) );
GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupConstructorsLayout->addItem( spacer, 0, 1 );
GeometryGUI_MaxToleranceDlgLayout->addWidget( GroupConstructors, 0, 0 );
/***************************************************************/
GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
GroupConstructor1->setTitle( tr( "GEOM_TOLERANCE_CONSTR" ) );
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 );
LineEditC1A1 = new QLineEdit( GroupConstructor1, "LineEditC1A1" );
LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
// GroupConstructor1Layout->addWidget( LineEditC1A1, 0, 2 );
SelectButtonC1A1 = new QPushButton( GroupConstructor1, "SelectButtonC1A1" );
SelectButtonC1A1->setText( tr( "" ) );
SelectButtonC1A1->setPixmap( image1 );
// GroupConstructor1Layout->addWidget( SelectButtonC1A1, 0, 1 );
TextLabelC1A1 = new QLabel( GroupConstructor1, "TextLabelC1A1" );
TextLabelC1A1->setText( tr( "GEOM_OBJECT" ) );
TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
TextLabelC1A1->setFrameShape( QLabel::NoFrame );
TextLabelC1A1->setFrameShadow( QLabel::Plain );
// GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 );
QHBoxLayout* bl = new QHBoxLayout;
bl->setMargin(0); bl->setSpacing(6);
bl->addWidget(TextLabelC1A1); bl->addWidget(SelectButtonC1A1); bl->addWidget(LineEditC1A1);
GroupConstructor1Layout->addMultiCellLayout(bl, 0, 0, 0, 2);
TextLabel_Min = new QLabel( GroupConstructor1, "TextLabel_Min" );
TextLabel_Min->setText( tr( "GEOM_MIN" ) );
TextLabel_Min->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Min->setFrameShape( QLabel::NoFrame );
TextLabel_Min->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Min, 1, 1 );
TextLabel_Max = new QLabel( GroupConstructor1, "TextLabel_Max" );
TextLabel_Max->setText( tr( "GEOM_MAX" ) );
TextLabel_Max->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Max->setFrameShape( QLabel::NoFrame );
TextLabel_Max->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Max, 1, 2 );
TextLabel_Face = new QLabel( GroupConstructor1, "TextLabel_Face" );
TextLabel_Face->setText( tr( "GEOM_TOLERANCE_FACE" ) );
TextLabel_Face->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Face->setFrameShape( QLabel::NoFrame );
TextLabel_Face->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Face, 2, 0 );
LineEdit_MinFace = new QLineEdit( GroupConstructor1, "LineEdit_MinFace" );
LineEdit_MinFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinFace->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinFace->setEnabled( FALSE );
LineEdit_MinFace->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinFace, 2, 1 );
LineEdit_MaxFace = new QLineEdit( GroupConstructor1, "LineEdit_MaxFace" );
LineEdit_MaxFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxFace->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxFace->setEnabled( FALSE );
LineEdit_MaxFace->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxFace, 2, 2 );
TextLabel_Edge = new QLabel( GroupConstructor1, "TextLabel_Edge" );
TextLabel_Edge->setText( tr( "GEOM_TOLERANCE_EDGE" ) );
TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Edge->setFrameShape( QLabel::NoFrame );
TextLabel_Edge->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Edge, 3, 0 );
LineEdit_MinEdge = new QLineEdit( GroupConstructor1, "LineEdit_MinEdge" );
LineEdit_MinEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinEdge->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinEdge->setEnabled( FALSE );
LineEdit_MinEdge->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinEdge, 3, 1 );
LineEdit_MaxEdge = new QLineEdit( GroupConstructor1, "LineEdit_MaxEdge" );
LineEdit_MaxEdge->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxEdge->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxEdge->setEnabled( FALSE );
LineEdit_MaxEdge->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxEdge, 3, 2 );
TextLabel_Vertex = new QLabel( GroupConstructor1, "TextLabel_Vertex" );
TextLabel_Vertex->setText( tr( "GEOM_TOLERANCE_VERTEX" ) );
TextLabel_Vertex->setMinimumSize( QSize( 50, 0 ) );
TextLabel_Vertex->setFrameShape( QLabel::NoFrame );
TextLabel_Vertex->setFrameShadow( QLabel::Plain );
GroupConstructor1Layout->addWidget( TextLabel_Vertex, 4, 0 );
LineEdit_MinVertex = new QLineEdit( GroupConstructor1, "LineEdit_MinVertex" );
LineEdit_MinVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MinVertex->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MinVertex->setEnabled( FALSE );
LineEdit_MinVertex->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MinVertex, 4, 1 );
LineEdit_MaxVertex = new QLineEdit( GroupConstructor1, "LineEdit_MaxVertex" );
LineEdit_MaxVertex->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0,
LineEdit_MaxVertex->sizePolicy().hasHeightForWidth() ) );
//LineEdit_MaxVertex->setEnabled( FALSE );
LineEdit_MaxVertex->setReadOnly( TRUE );
GroupConstructor1Layout->addWidget( LineEdit_MaxVertex, 4, 2 );
GeometryGUI_MaxToleranceDlgLayout->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( "GEOM_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 1 );
// buttonApply = new QPushButton( GroupButtons, "buttonApply" );
// buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
// buttonApply->setAutoDefault( TRUE );
// GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_8 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_8, 0, 0 );
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( "GEOM_BUT_OK" ) );
// buttonOk->setAutoDefault( TRUE );
// buttonOk->setDefault( TRUE );
// GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
GeometryGUI_MaxToleranceDlgLayout->addWidget( GroupButtons, 2, 0 );
/***************************************************************/
Init(Sel) ; /* Initialisations */
}
//=================================================================================
// function : ~GeometryGUI_MaxToleranceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
GeometryGUI_MaxToleranceDlg::~GeometryGUI_MaxToleranceDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::Init( SALOME_Selection* Sel )
{
myConstructorId = 0 ;
Constructor1->setChecked( TRUE );
myEditCurrentArgument = LineEditC1A1 ;
mySelection = Sel;
myGeomGUI = GeometryGUI::GetGeometryGUI() ;
myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
// TODO : previous selection into argument ?
/* Filter definitions */
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
myGeom = GEOM::GEOM_Gen::_narrow(comp);
/* 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( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
/* to close dialog if study change */
connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
/* Move widget on the botton right corner of main widget */
int x, y ;
myGeomGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ; /* displays Dialog */
return ;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void GeometryGUI_MaxToleranceDlg::ConstructorsClicked(int constructorId)
{
return ;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::ClickOnCancel()
{
disconnect( mySelection, 0, this, 0 );
myGeomGUI->ResetState() ;
reject() ;
return ;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void GeometryGUI_MaxToleranceDlg::SelectionIntoArgument()
{
LineEdit_MinFace->setText("") ;
LineEdit_MinEdge->setText("") ;
LineEdit_MinVertex->setText("") ;
LineEdit_MaxFace->setText("") ;
LineEdit_MaxEdge->setText("") ;
LineEdit_MaxVertex->setText("") ;
myEditCurrentArgument->setText("") ;
QString aString = ""; /* future the name of selection */
int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
if ( nbSel != 1 ) {
return ;
}
/* nbSel == 1 */
TopoDS_Shape S;
if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
return ;
if( S.IsNull() ) {
myEditCurrentArgument->setText( "" );
return ;
}
LineEditC1A1->setText(aString) ;
this->CalculateMaxTolerance(S) ;
return ;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
switch (myConstructorId)
{
case 0: /* default constructor */
{
if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus() ;
myEditCurrentArgument = LineEditC1A1;
}
SelectionIntoArgument() ;
break;
}
}
return ;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if( send == LineEditC1A1 )
myEditCurrentArgument = LineEditC1A1 ;
else
return ;
/* User name of object input management */
/* If successfull the selection is changed and signal emitted... */
/* so SelectionIntoArgument() is automatically called. */
const QString objectUserName = myEditCurrentArgument->text() ;
QWidget* thisWidget = (QWidget*)this ;
if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
myEditCurrentArgument->setText( objectUserName ) ;
}
return ;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::DeactivateActiveDialog()
{
if ( GroupConstructors->isEnabled() ) {
disconnect( mySelection, 0, this, 0 );
GroupConstructors->setEnabled(false) ;
GroupConstructor1->setEnabled(false) ;
GroupButtons->setEnabled(false) ;
}
return ;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::ActivateThisDialog()
{
/* Emit a signal to deactivate the active dialog */
myGeomGUI->EmitSignalDeactivateDialog() ;
GroupConstructors->setEnabled(true) ;
GroupConstructor1->setEnabled(true) ;
GroupButtons->setEnabled(true) ;
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
return ;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::enterEvent(QEvent* e)
{
if ( GroupConstructors->isEnabled() )
return ;
ActivateThisDialog() ;
return ;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::closeEvent( QCloseEvent* e )
{
/* same than click on cancel button */
this->ClickOnCancel() ;
return ;
}
//=================================================================================
// function : CalculateMaxTolerance()
// purpose :
//=================================================================================
void GeometryGUI_MaxToleranceDlg::CalculateMaxTolerance(const TopoDS_Shape& S)
{
LineEdit_MinFace->setText("") ;
LineEdit_MinEdge->setText("") ;
LineEdit_MinVertex->setText("") ;
LineEdit_MaxFace->setText("") ;
LineEdit_MaxEdge->setText("") ;
LineEdit_MaxVertex->setText("") ;
if( S.IsNull() )
return ;
Standard_Real T,TMF,TME,TMV,TmF,TmE,TmV;
Standard_Integer nbF,nbE,nbV;
TMF=TME=TMV=-RealLast();
TmF=TmE=TmV=RealLast();
nbF=nbE=nbV=0;
bool m_isFace = false;
bool m_isEdge = false;
bool m_isVertex = false;
try
{
for( TopExp_Explorer ExF(S,TopAbs_FACE); ExF.More(); ExF.Next() )
{
m_isFace = true;
TopoDS_Face Face=TopoDS::Face(ExF.Current());
T=BRep_Tool::Tolerance(Face);
if(T>TMF) TMF=T;
if(T<TmF) TmF=T;
nbF++;
}
for( TopExp_Explorer ExE(S,TopAbs_EDGE); ExE.More(); ExE.Next() )
{
m_isEdge = true;
TopoDS_Edge Edge=TopoDS::Edge(ExE.Current());
T=BRep_Tool::Tolerance(Edge);
if(T>TME) TME=T;
if(T<TmE) TmE=T;
nbE++;
}
for( TopExp_Explorer ExV(S,TopAbs_VERTEX); ExV.More(); ExV.Next() )
{
m_isVertex = true;
TopoDS_Vertex Vertex=TopoDS::Vertex(ExV.Current());
T=BRep_Tool::Tolerance(Vertex);
if(T>TMV) TMV=T;
if(T<TmV) TmV=T;
nbV++;
}
if (m_isFace)
{
LineEdit_MinFace->setText( tr("%1").arg( TmF, 5, 'e', 8 ) ) ;
LineEdit_MaxFace->setText( tr("%1").arg( TMF, 5, 'e', 8 ) ) ;
}
else
{
LineEdit_MinFace->setText( "" ) ;
LineEdit_MaxFace->setText( "" ) ;
}
if (m_isEdge)
{
LineEdit_MinEdge->setText( tr("%1").arg( TmE, 5, 'e', 8 ) ) ;
LineEdit_MaxEdge->setText( tr("%1").arg( TME, 5, 'e', 8 ) ) ;
}
else
{
LineEdit_MinEdge->setText( "" ) ;
LineEdit_MaxEdge->setText( "" ) ;
}
if (m_isVertex)
{
LineEdit_MinVertex->setText( tr("%1").arg( TmV, 5, 'e', 8 ) ) ;
LineEdit_MaxVertex->setText( tr("%1").arg( TMV, 5, 'e', 8 ) ) ;
}
else
{
LineEdit_MinVertex->setText( "" ) ;
LineEdit_MaxVertex->setText( "" ) ;
}
}
catch(Standard_Failure)
{
MESSAGE("Catch intercepted in CalculateMaxTolerance()" << endl ) ;
}
return ;
}

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