--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+# 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@
+
--- /dev/null
+// 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.cc file
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GEOM_Gen_i.hh"
+
+#include "Partition_Spliter.hxx"
+#include "Archimede_VolumeSection.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "utilities.h"
+
+#include <stdio.h>
+
+// Cascade headers
+
+#include <Standard_Failure.hxx>
+
+#include <gp_Circ.hxx>
+#include <gp_Pln.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Line.hxx>
+#include <GeomFill_Line.hxx>
+#include <GeomFill_AppSurf.hxx>
+#include <GeomFill_SectionGenerator.hxx>
+#include <Geom_BSplineSurface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GC_MakeArcOfCircle.hxx>
+#include <GC_Root.hxx>
+
+#include <BRepCheck_Analyzer.hxx>
+#include <BRepAlgoAPI.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+#include <BRepOffsetAPI_Sewing.hxx>
+#include <BRepOffsetAPI_MakePipe.hxx>
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <BRepLib.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+
+#include <BRepBuilderAPI_MakeShell.hxx>
+#include <BRepPrim_Builder.hxx>
+#include <BRepBuilderAPI_MakeSolid.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepPrimAPI_MakeRevol.hxx>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepPrimAPI_MakeTorus.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepPrimAPI_MakeSphere.hxx>
+#include <BRepPrimAPI_MakeCylinder.hxx>
+#include <BRepPrimAPI_MakeCone.hxx>
+#include <BRepFilletAPI_MakeFillet.hxx>
+#include <BRepFilletAPI_MakeChamfer.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_Quilt.hxx>
+#include <BRep_Tool.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <Precision.hxx>
+
+//VRV: OCC 4.0 migration
+#include <STEPControl_Reader.hxx>
+#include <IGESControl_Reader.hxx>
+//VRV: OCC 4.0 migration
+
+#include <IFSelect_ReturnStatus.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+//VRV: OCC 4.0 migration
+#include <IGESControl_Writer.hxx>
+#include <IGESControl_Controller.hxx>
+#include <STEPControl_Writer.hxx>
+#include <Interface_Static.hxx>
+//#include <STEPControlStd_StepModelType.hxx>
+//VRV: OCC 4.0 migration
+
+#include <TopoDS_Shape.hxx>
+#include <TopAbs.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Solid.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_Array1OfShape.hxx>
+
+#include <IGESData_IGESEntity.hxx>
+
+#include <TDF_Tool.hxx>
+#include <TDF_Label.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TDF_Reference.hxx>
+#include <TDF_Data.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TNaming_Tool.hxx>
+// #include <TDocStd_Owner.hxx>
+
+#include "SALOMEDS_Tool.hxx"
+#include "GEOMDS_Commands.hxx"
+#include "GEOMDS_Explorer.hxx"
+
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+//============================================================================
+// function : GEOM_Gen_i()
+// purpose : 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) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+{
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+ // SCRUTE(this)
+ name_service = new SALOME_NamingService(_orb);
+ myOCAFApp = new GEOMDS_Application();
+ myStudyID = -1;
+ GetCurrentStudy(0);//for correct work of SuperVisor
+}
+
+
+
+//============================================================================
+// function : ~GEOM_Gen_i()
+// purpose : destructor
+//============================================================================
+GEOM_Gen_i::~GEOM_Gen_i() {
+ delete name_service;
+}
+
+
+//============================================================================
+// function : IORToLocalPersistentID()
+// purpose :
+//============================================================================
+char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
+ const char* IORString,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
+{
+ GEOM::GEOM_Shape_var aShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(IORString));
+ if (!CORBA::is_nil(aShape)) {
+ return strdup(aShape->ShapeId());
+ }
+ return 0;
+}
+
+
+//============================================================================
+// function : LocalPersistentIDToIOR()
+// purpose : Create/Load CORBA object from a persistent ref (an entry)
+// : Used when a study is loaded
+// : The IOR (IORName) of object created is returned
+//============================================================================
+char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
+ const char* aLocalPersistentID,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean isASCII)
+{
+ SALOMEDS::Study_var myStudy = theSObject->GetStudy();
+ GetCurrentStudy(myStudy->StudyId());
+ Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(myStudyIDToDoc(myStudy->StudyId()));
+ CORBA::String_var aPersRefString = aLocalPersistentID;
+
+ /* For a GEOM::GEOM_Shape the pers_ref is the Entry in the OCAF document */
+ TCollection_ExtendedString MainIOR;
+ TDF_Label Lab;
+ TDF_Tool::Label(aDoc->GetData(), aPersRefString, Lab );
+
+ Handle(TNaming_NamedShape) NS;
+ Lab.FindAttribute( TNaming_NamedShape::GetID(), NS );
+ TopoDS_Shape S = TNaming_Tool::GetShape(NS);
+
+ /* shapetype, index=0, topo, orb, shapetype, ismain=true and name are setted and modified later ? */
+ GEOM::GEOM_Shape_var result = CreateObject(S);
+ GEOMDS_Commands GC( aDoc->Main() ) ;
+
+ if ( GC.HasIOR(Lab) ) { /* shape already created/loaded */
+ return 0 ;
+ }
+
+ /******************* Dependent object (not a main shape) *********************/
+ if( GC.IsDependentShape(Lab) ) {
+
+ TDF_Label mainLabel ;
+ Standard_Boolean mainShapeOk = GC.GetMainShapeLabel(Lab, mainLabel) ;
+
+ /* Main object not yet loaded we load/create it */
+ if( !GC.HasIOR(mainLabel) ) {
+
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(mainLabel,entry);
+ CORBA::String_var ent = strdup(entry.ToCString());
+
+ /* Create the main object recursively */
+ MainIOR = LocalPersistentIDToIOR(theSObject, ent, isMultiFile, isASCII) ;
+ } else {
+ GC.ReturnNameIOR( mainLabel, MainIOR );
+ }
+
+ result->MainName( TCollection_AsciiString(MainIOR).ToCString() ) ;
+ result->IsMainShape(false) ;
+ result->ShapeId(aPersRefString);
+
+ Handle(TDF_Reference) aRef;
+ Lab.FindAttribute( TDF_Reference::GetID(), aRef );
+ TDF_Label myL = aRef->Get() ;
+ Handle(TNaming_NamedShape) NN;
+ myL.FindAttribute( TNaming_NamedShape::GetID(), NN );
+ TopoDS_Shape mainTopo = TNaming_Tool::GetShape(NN);
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+
+ if(S.ShapeType() != TopAbs_COMPOUND) {
+ /* to set the index of a unique sub shape (Explode All ONLY for the moment !) */
+ ListOfID->length(1);
+ int index = 1;
+ TopTools_MapOfShape M;
+ TopExp_Explorer Exp ;
+ for( Exp.Init(mainTopo, TopAbs_ShapeEnum( result->ShapeType() )) ; Exp.More(); Exp.Next() ) {
+ if ( M.Add(Exp.Current()) ) {
+ if(Exp.Current().IsSame(S) ) {
+ ListOfID[0] = index;
+ break;
+ }
+ index++ ;
+ }
+ }
+ result->Index(ListOfID) ;
+ return result->Name();
+ }
+ else {
+ /* Here is a TopAbs_COMPOUND : we set the list/index for a compound : containing two or more sub shapes */
+ /* Warning : the Corba shape has a shapetype Compound : in GEOMDS_Client we have to retrieve the kind of */
+ /* subshapes contained in this compound ! */
+ TopTools_SequenceOfShape SS;
+ TopoDS_Iterator it ;
+ TopExp_Explorer exp ;
+ TopAbs_ShapeEnum subType ;
+
+ /* Set all sub shapes in a sequence of shapes */
+ for ( it.Initialize( S, true, true ) ; it.More(); it.Next() ) {
+ subType = it.Value().ShapeType() ;
+ SS.Append( it.Value() ) ;
+ }
+
+ ListOfID->length( SS.Length() ) ;
+ int j, k ; /* in TopTools_SequenceOfShape index start at 1 */
+
+ for( k=1; k<=SS.Length(); k++ ) {
+ j = 1 ;
+ for( exp.Init( mainTopo, subType ); exp.More(); exp.Next() ) {
+ if( exp.Current().IsSame( SS.Value(k) ) ) {
+ ListOfID[k-1] = j ;
+ }
+ j++ ;
+ }
+ }
+ result->Index(ListOfID) ;
+ return result->Name();
+ }
+
+ }
+ /******************* Independent object (not a sub shape) *********************/
+ else {
+ result->IsMainShape(true) ;
+ if( !GC.AddIORNameAttribute(Lab, result->Name() ) ) {
+ MESSAGE("in LocalPersistentIDToIOR, NAME/IOR attribute already exist." << endl ) ;
+ }
+ Handle(TNaming_NamedShape) NamedShape ;
+ bool notTested = Lab.FindAttribute(TNaming_NamedShape::GetID(), NamedShape) ;
+ result->ShapeId(aPersRefString);
+ return result->Name();
+ }
+}
+
+//============================================================================
+// function : CanPublishInStudy
+// purpose :
+//============================================================================
+bool GEOM_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
+{
+ GEOM::GEOM_Shape_var aShape = GEOM::GEOM_Shape::_narrow(theIOR);
+ return !(aShape->_is_nil());
+}
+
+
+//============================================================================
+// function : PublishInStudy
+// purpose :
+//============================================================================
+SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject,
+ CORBA::Object_ptr theObject,
+ const char* theName) throw (SALOME::SALOME_Exception)
+{
+ SALOMEDS::SObject_var aResultSO;
+ if(CORBA::is_nil(theObject)) return aResultSO;
+
+ GEOM::GEOM_Shape_var aShape = GEOM::GEOM_Shape::_narrow(theObject);
+ if(aShape->_is_nil()) return aResultSO;
+
+ if(theStudy->_is_nil()) return aResultSO;
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
+
+ SALOMEDS::SComponent_var aFather = theStudy->FindComponent("GEOM");
+ if (aFather->_is_nil()) {
+ aFather = aStudyBuilder->NewComponent("GEOM");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName");
+ SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue("Geometry");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributePixMap");
+ SALOMEDS::AttributePixMap::_narrow(anAttr)->SetPixMap("ICON_OBJBROWSER_Geometry");
+ aStudyBuilder->DefineComponentInstance(aFather, GEOM_Gen::_this());
+ }
+ if (aFather->_is_nil()) return aResultSO;
+
+ if (CORBA::is_nil(theSObject)) {
+ aResultSO = aStudyBuilder->NewObject(aFather);
+ } else {
+ if (!theSObject->ReferencedObject(aResultSO))
+ THROW_SALOME_CORBA_EXCEPTION("Publish in study supervision graph error",SALOME::BAD_PARAM);
+ }
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aShape->Name());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
+ SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ TCollection_AsciiString aShapeName("Shape_");
+
+ if ( aShape->ShapeType() == GEOM::COMPOUND ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
+ aShapeName = "Compound_";
+ } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
+ aShapeName = "Compsolid_";
+ } else if ( aShape->ShapeType() == GEOM::SOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
+ aShapeName = "Solid_";
+ } else if ( aShape->ShapeType() == GEOM::SHELL ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
+ aShapeName = "Shell_";
+ } else if ( aShape->ShapeType() == GEOM::FACE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
+ aShapeName = "Face_";
+ } else if ( aShape->ShapeType() == GEOM::WIRE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
+ aShapeName = "Wire_";
+ } else if ( aShape->ShapeType() == GEOM::EDGE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
+ aShapeName = "Edge_";
+ } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
+ aShapeName = "Vertex_";
+ }
+ if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
+ else aShapeName = TCollection_AsciiString(strdup(theName));
+
+ //Set a name of the added shape
+ anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
+ SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
+ aNameAttrib->SetValue(aShapeName.ToCString());
+
+ //Add a reference to published object
+// aStudyBuilder->Addreference(theObject, aResultSO);
+ return aResultSO._retn();
+}
+
+
+//============================================================================
+// function : Save()
+// purpose : save OCAF/Geom document
+//============================================================================
+SALOMEDS::TMPFile* GEOM_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile) {
+ SALOMEDS::TMPFile_var aStreamFile;
+ // Get a temporary directory to store a file
+ TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(1);
+ // Prepare a file name to open
+ TCollection_AsciiString aNameWithExt(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+ aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
+ aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
+ // Build a full file name of temporary file
+ TCollection_AsciiString aFullName = aTmpDir + aNameWithExt;
+ // Save GEOM component in this file
+ myOCAFApp->SaveAs(myCurrentOCAFDoc, aFullName);
+ // Conver a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.ToCString(), aSeq.in(), isMultiFile);
+ // Remove the created file and tmp directory
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+ // Return the created byte stream
+ return aStreamFile._retn();
+}
+
+SALOMEDS::TMPFile* GEOM_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile) {
+ SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
+ return aStreamFile._retn();
+}
+
+
+CORBA::Boolean GEOM_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile) {
+
+ if (theStream.length() <= 9) {
+ MESSAGE("The TMPFile is too short : " << theStream.length() << " bytes ");
+ return false;
+ }
+
+ // Get a temporary directory for a file
+ TCollection_AsciiString aTmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ // Conver the byte stream theStream to a file and place it in tmp directory
+ SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
+ aTmpDir.ToCString(),
+ isMultiFile);
+
+ // Prepare a file name to open
+ TCollection_AsciiString aNameWithExt(aSeq[0]);
+ TCollection_AsciiString aFullName = aTmpDir + aNameWithExt;
+
+ // Open document
+ if (myOCAFApp->Open(aFullName, myCurrentOCAFDoc) != CDF_RS_OK) return false;
+
+ // Remove the created file and tmp directory
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
+
+ SALOMEDS::Study_var Study = theComponent->GetStudy();
+ TCollection_AsciiString name( strdup(Study->Name()) );
+
+ int StudyID = Study->StudyId();
+ myStudyIDToDoc.Bind( StudyID, myCurrentOCAFDoc );
+ myStudyID = StudyID;
+
+ /* We clear all IOR (nameIOR) attributes of all objects before reconstruction */
+ /* This information will be setted when each object is reconstructed */
+ GEOMDS_Commands GC( myCurrentOCAFDoc->Main() ) ;
+ GC.ClearAllIOR(myCurrentOCAFDoc->Main());
+
+ return true;
+}
+
+CORBA::Boolean GEOM_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theStream,
+ const char* theURL,
+ bool isMultiFile) {
+ return Load(theComponent, theStream, theURL, isMultiFile);
+}
+
+// //============================================================================
+// // function : Save()
+// // purpose : save OCAF/Geom document
+// //============================================================================
+// void GEOM_Gen_i::Save(const char *IORSComponent, const char *aUrlOfFile)
+// {
+
+// TCollection_ExtendedString path(strdup(aUrlOfFile));
+// TCollection_ExtendedString pathWithExt = path + TCollection_ExtendedString(".sgd");
+// myOCAFApp->SaveAs(myCurrentOCAFDoc,pathWithExt);
+// }
+
+
+// //============================================================================
+// // function : Load()
+// // purpose : Load OCAF/Geom document
+// //============================================================================
+// void GEOM_Gen_i::Load(const char *IORSComponent, const char *aUrlOfFile)
+// {
+
+// TCollection_ExtendedString path(strdup(aUrlOfFile));
+// TCollection_ExtendedString pathWithExt = path + TCollection_ExtendedString(".sgd");
+
+// myOCAFApp->Open(pathWithExt,myCurrentOCAFDoc);
+
+// SALOMEDS::SComponent_var SC = SALOMEDS::SComponent::_narrow(_orb->string_to_object(IORSComponent));
+// SALOMEDS::Study_var Study = SC->GetStudy();
+// TCollection_AsciiString name( strdup(Study->Name()) );
+
+// int StudyID = Study->StudyId();
+// myStudyIDToDoc.Bind( StudyID, myCurrentOCAFDoc );
+// myStudyID = StudyID;
+
+// /* We clear all IOR (nameIOR) attributes of all objects before reconstruction */
+// /* This information will be setted when each object is reconstructed */
+// GEOMDS_Commands GC( myCurrentOCAFDoc->Main() ) ;
+// GC.ClearAllIOR(myCurrentOCAFDoc->Main());
+
+// return ;
+// }
+
+
+//============================================================================
+// function : Close()
+// purpose :
+//============================================================================
+void GEOM_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
+{
+ int anID = theComponent->GetStudy()->StudyId();
+ if (anID == myStudyID) GetCurrentStudy(0); // set default value of current study ID, if current is deleted
+ if (myStudyIDToDoc.IsBound(anID)) {
+ // close document in the application
+// Handle(TDocStd_Owner) anOwner;
+ Handle(TDocStd_Document) aDoc = Handle(TDocStd_Document)::DownCast(myStudyIDToDoc.Find(anID));
+// Handle(TDocStd_Document) anEmptyDoc;
+// if (aDoc->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) {
+// anOwner->SetDocument(anEmptyDoc);
+// cout<<"********** Nullify owner of document"<<endl;
+// }
+ myOCAFApp->Close(aDoc);
+ myStudyIDToDoc.UnBind(anID); // remove document from GEOM documents data map
+ }
+}
+
+//============================================================================
+// function : CanCopy()
+// purpose :
+//============================================================================
+CORBA::Boolean GEOM_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
+ // Try to retrieve known by Geometry component GEOM_shape by given IOR
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
+ GEOM::GEOM_Shape_var aShape = GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ // If the object is null one it can't be copied: return false
+ if (aShape->_is_nil()) return false;
+ return true;
+}
+
+//============================================================================
+// function : CopyFrom()
+// purpose :
+//============================================================================
+SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
+ // Declare a sequence of the byte to store the copied object
+ SALOMEDS::TMPFile_var aStreamFile;
+
+ // Try to get GEOM_Shape object by given SObject
+ SALOMEDS::GenericAttribute_var anAttr;
+ if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false;
+ GEOM::GEOM_Shape_var aShape = GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value());
+ // If the object is null one it can't be copied: return false
+ if (aShape->_is_nil()) return aStreamFile._retn();
+
+ GetCurrentStudy(theObject->GetStudy()->StudyId());
+
+ // Convert a TopoDS_Shape to a stream of bytes
+ TopoDS_Shape aTopology = GetTopoShape(aShape);
+ if (aTopology.IsNull()) return aStreamFile._retn();
+ ostrstream aStreamedShape;
+ BRepTools::Write(aTopology, aStreamedShape);
+ int aSize = aStreamedShape.pcount();
+ char* aBuffer = new char[aSize];
+ memcpy(aBuffer, aStreamedShape.str(), aSize);
+ aStreamedShape.rdbuf()->freeze(0);
+
+ aStreamFile = new SALOMEDS::TMPFile(aSize, aSize, (CORBA::Octet*)aBuffer, 1);
+
+ // Assign an ID = 1 the the type GEOM_Shape
+ theObjectID = 1;
+
+ // Return created TMPFile
+ return aStreamFile._retn();
+}
+
+//============================================================================
+// function : CanPaste()
+// purpose :
+//============================================================================
+CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
+ // The Geometry component can paste only objects copied by Geometry component
+ // and with the object type = 1
+// cout<<"********** GEOM_Gen_i::CanPaste ("<<theComponentName<<","<<theObjectID<<")"<<endl;
+ if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
+ return true;
+}
+
+//============================================================================
+// function : PasteInto()
+// purpose :
+//============================================================================
+SALOMEDS::SObject_ptr GEOM_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
+ CORBA::Long theObjectID,
+ SALOMEDS::SObject_ptr theObject) {
+ // Find the current Study and StudyBuilder
+ SALOMEDS::Study_var aStudy = theObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ // Retrieve a TopoDS_Shape from byte stream
+ TopoDS_Shape aTopology;
+ istrstream aStreamedBrep((char*) &theStream[0], theStream.length());
+ BRep_Builder aBuilder;
+ try {
+ BRepTools::Read(aTopology, aStreamedBrep, aBuilder);
+ } catch (Standard_Failure) {
+// cout<<"GEOM_Gen_i::PasteInto exception"<<endl;
+ return false;
+ }
+
+ // Create new object in Geometry component using retrieved topology
+ GEOM::GEOM_Shape_var aShape = CreateObject(aTopology);
+ GetCurrentStudy(aStudy->StudyId());
+ const char *anEntry = InsertInLabel(aTopology, aShape->Name(), myCurrentOCAFDoc) ;
+ aShape->ShapeId(anEntry) ;
+
+ // SObject of the created shape is theObject or new Child of Component if theObject == geom component
+ SALOMEDS::SObject_var aNewSO;
+ if (strcmp(theObject->GetFatherComponent()->GetID(),theObject->GetID()) == 0) {
+ aNewSO = aStudyBuilder->NewObject(theObject);
+ } else aNewSO = SALOMEDS::SObject::_duplicate(theObject);
+ // Add IORAttribute to the Study and set IOR of the created GEOM_Shape to it
+ SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aNewSO, "AttributeIOR");
+ SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aShape->Name());
+
+ // Return the created in the Study SObject
+ return aNewSO._retn();
+}
+
+//============================================================================
+// function : ComponentDataType()
+// purpose :
+//============================================================================
+char* GEOM_Gen_i::ComponentDataType()
+{
+ return strdup("GEOM");
+}
+
+//============================================================================
+// function : register()
+// purpose : register 'name' in 'name_service'
+//============================================================================
+void GEOM_Gen_i::register_name(char * name)
+{
+ GEOM::GEOM_Gen_ptr g = GEOM::GEOM_Gen::_narrow(POA_GEOM::GEOM_Gen::_this());
+ name_service->Register(g, strdup(name));
+}
+
+
+
+//================================================================================
+// function : SequenceOfShapeFromListOfGeomShape()
+// purpose : Define a sequence of shapes from 'listShapes' and return its length.
+// : No control is made on shapes !
+//================================================================================
+int GEOM_Gen_i::SequenceOfShapeFromListOfGeomShape( const GEOM::GEOM_Gen::ListOfGeomShapes& listShapes,
+ TopTools_SequenceOfShape& SS )
+{
+ int nbShapes = listShapes.length() ;
+ if( nbShapes < 1)
+ return 0 ;
+
+ for(int i=0; i<nbShapes; i++) {
+ GEOM::GEOM_Shape_var aGeomShape = listShapes[i] ;
+ TopoDS_Shape aShape = GetTopoShape(aGeomShape) ;
+ SS.Append(aShape) ;
+ }
+ return nbShapes ;
+}
+
+
+
+
+//=================================================================================
+// function : GetTopoShape()
+// purpose : Returns a TopoDS_Shape from a GEOM::GEOM_Shape_ptr in 'myCurrentOCAFDoc'
+// : A null shape is returned if not possible
+//=================================================================================
+TopoDS_Shape GEOM_Gen_i::GetTopoShape(GEOM::GEOM_Shape_ptr shape_ptr)
+{
+ TopoDS_Shape tds ;
+
+ TDF_Label lab ;
+ Handle(TDF_Data) D = myCurrentOCAFDoc->GetData() ;
+ TDF_Tool::Label( D, strdup(shape_ptr->ShapeId()), lab, true ) ;
+ Handle(TNaming_NamedShape) NamedShape ;
+ bool res = lab.FindAttribute(TNaming_NamedShape::GetID(), NamedShape) ;
+
+ if( !res ) {
+ return tds ; /* a null shape is returned */
+ }
+ else {
+ return TNaming_Tool::GetShape(NamedShape) ;
+ }
+}
+
+
+
+//=================================================================================
+// function : GetStringFromIOR()
+// purpose : returns a string that represents a 'GEOM::GEOM_Shape_var'
+//=================================================================================
+const char* GEOM_Gen_i::GetStringFromIOR(GEOM::GEOM_Shape_var shapeIOR) {
+ const char * ret = _orb->object_to_string(shapeIOR) ;
+ return ret ;
+}
+
+
+
+//=================================================================================
+// function : GetIORFromString()
+// purpose : returns a 'GEOM::GEOM_Shape_var' from a string representing it
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::GetIORFromString(const char* stringIOR) {
+ GEOM::GEOM_Shape_var shapeIOR = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(stringIOR)) ;
+ return shapeIOR ;
+}
+
+
+
+//==================================================================================
+// function : InsertInLabel()
+// purpose : Insert S = Shape and mystr = name in a new Label of Geom/OCAF document
+// : and returns the corresponding OCAF entry
+//==================================================================================
+const char * GEOM_Gen_i::InsertInLabel(TopoDS_Shape S, const char *mystr, Handle(TDocStd_Document) OCAFDoc)
+{
+ GEOMDS_Commands GC(OCAFDoc->Main());
+ /* add attributs S and mystr in a new label */
+ TDF_Label Lab = GC.AddShape (S, strdup(mystr));
+
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab,entry);
+ const char *ent = entry.ToCString() ;
+ return ent ;
+}
+
+
+//==================================================================================
+// function : InsertInLabelDependentShape()
+// purpose : Insert S = Shape and its nameIor in a new Label of Geom/OCAF document
+// : insert also a reference attribute (a label) to the main shape 'mainshap_ptr'.
+// : and returns the corresponding OCAF entry of the new label.
+//==================================================================================
+const char * GEOM_Gen_i::InsertInLabelDependentShape( TopoDS_Shape S,
+ const char *nameIor,
+ GEOM::GEOM_Shape_ptr mainshape_ptr,
+ Handle(TDocStd_Document) OCAFDoc )
+{
+ GEOMDS_Commands GC(OCAFDoc->Main());
+ /* add attributs S and nameIor in a new label */
+
+ /* retrieve the label of the main shape in the document */
+ TDF_Label mainRefLab;
+ TDF_Tool::Label(OCAFDoc->GetData(), mainshape_ptr->ShapeId(), mainRefLab);
+
+ /* add attributs : S, nameIor and ref to main */
+ TDF_Label Lab = GC.AddDependentShape(S, strdup(nameIor), mainRefLab);
+
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab, entry);
+ const char *ent = entry.ToCString() ;
+ return ent ;
+}
+
+
+//=================================================================================
+// function : InsertInLabelOneArgument()
+// purpose :
+//=================================================================================
+void GEOM_Gen_i::InsertInLabelOneArgument(TopoDS_Shape main_topo,
+ GEOM::GEOM_Shape_ptr shape_ptr,
+ TopoDS_Shape result_topo,
+ GEOM::GEOM_Shape_ptr result,
+ Handle(TDocStd_Document) OCAFDoc)
+{
+ /* Put shape and name into geom/OCAF doc */
+ GEOMDS_Commands GC(OCAFDoc->Main());
+ /* Add attributs 'shape' and 'name_ior' in a new label */
+ TDF_Label Lab = GC.Generated( main_topo, result_topo, result->Name() );
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab, entry);
+ result->ShapeId( entry.ToCString() ) ;
+
+ /* Create a new label */
+ TDF_Label NewLab = Lab.NewChild();
+ TCollection_ExtendedString Value("Arguments");
+ TDataStd_Name::Set(NewLab,Value);
+
+ TDF_Label NewLab1 = NewLab.NewChild();
+ TDF_Label RefLab;
+ TDF_Tool::Label(OCAFDoc->GetData(), shape_ptr->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab1, RefLab);
+}
+
+
+//=================================================================================
+// function : InsertInLabelMoreArguments()
+// purpose :
+//=================================================================================
+void GEOM_Gen_i::InsertInLabelMoreArguments(TopoDS_Shape main_topo,
+ GEOM::GEOM_Shape_ptr result,
+ const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
+ Handle(TDocStd_Document) OCAFDoc)
+{
+ /* Put shape and name into geom/OCAF doc */
+ GEOMDS_Commands GC(OCAFDoc->Main());
+ /* Add attributs TopoDS and name_ior in a new label */
+ TDF_Label Lab = GC.AddShape(main_topo, result->Name() );
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab, entry);
+
+ /* Create a new label */
+ TDF_Label NewLab = Lab.NewChild();
+ TCollection_ExtendedString Value("Arguments");
+ TDataStd_Name::Set(NewLab, Value);
+
+ for (unsigned int ind = 0; ind < ListShapes.length(); ind++) {
+
+ TDF_Label NewLab1 = NewLab.NewChild();
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[ind] );
+
+ TDF_Label RefLab;
+ TDF_Tool::Label(OCAFDoc->GetData(), aShape->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab1, RefLab);
+ }
+ result->ShapeId(entry.ToCString());
+}
+
+
+
+//=================================================================================
+// function: NbLabels()
+// purpose :
+//=================================================================================
+CORBA::Short GEOM_Gen_i::NbLabels()
+{
+ return TDF_Tool::NbLabels( myCurrentOCAFDoc->Main() );
+}
+
+
+
+//=================================================================================
+// function: GetCurrentStudy()
+// purpose : Finds or creates the geom/OCAF document corresponding to the index
+// 'StudyID'
+//=================================================================================
+void GEOM_Gen_i::GetCurrentStudy(CORBA::Long StudyID)
+{
+ /* If StudyID is known we link myCurrentOCAFDoc to it */
+ if (myStudyIDToDoc.IsBound(StudyID)) {
+ myCurrentOCAFDoc = Handle(TDocStd_Document)::DownCast(myStudyIDToDoc(StudyID));
+ }
+ /* Create a new OCAFDoc and link it to 'StudyID' argument */
+ else {
+ myOCAFApp->NewDocument("SALOME_GEOM",myCurrentOCAFDoc);
+ myStudyIDToDoc.Bind(StudyID,myCurrentOCAFDoc);
+ }
+ myStudyID = StudyID;
+}
+
+
+//================================================================================
+// function : CreateObject()
+// purpose : private function to create a complete CORBA object and return it
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::CreateObject(TopoDS_Shape& tds)
+{
+// if ( tds.ShapeType() == TopAbs_COMPOUND ) {
+// TopoDS_Iterator itr(tds);
+// TopoDS_Shape res;
+// int i = 0;
+// while (itr.More()) {
+// i++;
+// res = itr.Value();
+// itr.Next();
+// }
+
+// if ( i == 1 )
+// tds = res;
+// }
+
+ GEOM::shape_type st = GEOM::shape_type(tds.ShapeType()) ; /* casting */
+
+ /* Create the CORBA servant holding the TopoDS_Shape */
+ GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
+ GEOM::GEOM_Shape::ListOfSubShapeID_var index = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ index->length(0);
+ GEOM_Shape_i * shape_servant = new GEOM_Shape_i(tds, _orb, engine, index, st, true);
+ GEOM::GEOM_Shape_var shape = GEOM::GEOM_Shape::_narrow(shape_servant->_this());
+
+ /* Create and set the name (IOR of shape converted into a string) */
+ string name_ior = _orb->object_to_string(shape) ;
+ shape->Name( name_ior.c_str() );
+ shape->NameType( "" );
+ return shape;
+}
+
+//=======================================================================
+//function : CreateSubObject
+//purpose :
+//=======================================================================
+
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::CreateSubObject(const TopoDS_Shape& SubShape,
+ const GEOM::GEOM_Shape_ptr MainShape,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
+{
+ GEOM::shape_type st = GEOM::shape_type(SubShape.ShapeType()) ; /* casting */
+
+ /* Create the CORBA servant holding the TopoDS_Shape */
+ GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
+ GEOM_Shape_i * shape_servant =
+ new GEOM_Shape_i(SubShape, _orb, engine, ListOfID, st, false);
+ GEOM::GEOM_Shape_var shape = GEOM::GEOM_Shape::_narrow(shape_servant->_this());
+
+ /* Create and set the name (IOR of shape converted into a string) */
+ string name_ior = _orb->object_to_string(shape) ;
+ shape->Name( name_ior.c_str() );
+ /* create and set the mainname (IOR of shape converted into a string) */
+ const char *mainname_ior = _orb->object_to_string(MainShape) ;
+ shape->MainName(mainname_ior);
+ /* precaution : NameType will be set precisely in GUI */
+ shape->NameType( "" );
+ /* add 'SubShape' its 'nameIOR' and a reference to the main shape thanks to method below */
+ const char *entry =
+ InsertInLabelDependentShape(SubShape, shape->Name(), MainShape, myCurrentOCAFDoc) ;
+ shape->ShapeId( entry ) ;
+
+ return shape;
+}
+
+//=======================================================================
+// function : SuppressFacesGlue()
+// purpose : Define a compound of shells after suppress of mapFaces in the
+// : shape S and return the number of shells of the compound.
+//=======================================================================
+int GEOM_Gen_i::SuppressFacesGlue( const TopoDS_Shape& S,
+ const TopTools_MapOfShape& mapFaces,
+ TopoDS_Shape& aCompoundOfShells )
+ throw (SALOME::SALOME_Exception)
+{
+ BRepTools_Quilt Glue;
+ aCompoundOfShells.Nullify() ;
+
+ for ( TopExp_Explorer exp( S, TopAbs_FACE); exp.More(); exp.Next() ) {
+ const TopoDS_Face& F = TopoDS::Face(exp.Current());
+ if ( !mapFaces.Contains(F) ) {
+ /* this face must not to be suppressed */
+ Glue.Add(F);
+ }
+ }
+
+ /* Use specif method to calculate the compound of shells */
+ aCompoundOfShells = Glue.Shells();
+
+ if( aCompoundOfShells.ShapeType() != TopAbs_COMPOUND ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SuppressFacesGlue() : not a GEOM::COMPOUND", SALOME::BAD_PARAM);
+ }
+
+ /* explore Compound for verification and return the number of shells */
+ int numberOfShell = 0 ;
+ for ( TopExp_Explorer exp1( aCompoundOfShells, TopAbs_SHELL); exp1.More(); exp1.Next() )
+ numberOfShell++ ;
+
+ return numberOfShell ;
+}
+
+
+//=====================================================================================
+// function : GetIndexTopology()
+// purpose : return the index of a sub shape in a shape (index starts at 1)
+// : Return -1 if not found
+//=====================================================================================
+int GEOM_Gen_i::GetIndexTopology(const TopoDS_Shape& subshape, const TopoDS_Shape& mainShape)
+{
+ if( mainShape.IsNull() || subshape.IsNull() )
+ return -1 ;
+
+ int index = 1;
+ if (subshape.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 (it.Value().IsSame(subshape))
+ return index;
+ else
+ index++;
+ CL.Append( it.Value() );
+ }
+ }
+ }
+ }
+ else
+ {
+ TopExp_Explorer Exp ( mainShape, subshape.ShapeType() );
+ TopTools_MapOfShape M;
+ while ( Exp.More() )
+ {
+ if ( M.Add(Exp.Current()) )
+ {
+ if ( Exp.Current().IsSame(subshape) )
+ return index;
+ index++;
+ }
+ Exp.Next();
+ }
+ }
+ return -1;
+}
+
+
+//================================================================================
+// function : IndexOfFacesOfSubShell()
+// purpose : Return a list of indices corresponding to the faces of a 'subShell'
+// : in the main shape 'S'
+//================================================================================
+GEOM::GEOM_Shape::ListOfSubShapeID* GEOM_Gen_i::IndexOfFacesOfSubShell( const TopoDS_Shape& S,
+ const TopoDS_Shape subShell )
+ throw (SALOME::SALOME_Exception)
+{
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ListOfID->length(0) ;
+ if( subShell.IsNull() || subShell.ShapeType() != TopAbs_SHELL ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::IndexOfFacesOfSubShell() : null shape or not a GEOM::SHELL", SALOME::BAD_PARAM);
+ }
+
+ /* put faces of subShell in a Map of faces */
+ int j = 0 ;
+ TopTools_MapOfShape mapFaces ;
+ for( TopExp_Explorer Exp1( subShell, TopAbs_FACE ); Exp1.More(); Exp1.Next() ) {
+ mapFaces.Add(Exp1.Current() ) ;
+ j++ ;
+ }
+
+ if( j<1 )
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::IndexOfFacesOfSubShell() : no faces in sub shell", SALOME::BAD_PARAM);
+
+ /* Find index of each face of subshell in the main topology and put its index in ListOfID */
+ int size = 0 ;
+ for ( TopExp_Explorer Exp2(S, TopAbs_FACE); Exp2.More(); Exp2.Next() ) {
+
+ const TopoDS_Face& F = TopoDS::Face( Exp2.Current() ) ;
+
+ if( mapFaces.Contains(F) ) {
+ int n = GetIndexTopology( F, S ) ;
+ if( n<=0 ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::IndexOfFacesOfSubShell() : no index found", SALOME::BAD_PARAM);
+ }
+ size++;
+ ListOfID->length(size) ;
+ ListOfID[size-1] = n ;
+ }
+ }
+
+ return ListOfID._retn() ;
+}
+
+
+
+//================================================================================
+// function : ListOfIDIntoMapOfShapes()
+// purpose : Define a MapOfShapes from a main topology 'S' a 'subShapeType'
+// : and a list of indices 'L'.
+// : Return true if 'aMap' is not empty
+//================================================================================
+bool GEOM_Gen_i::ListOfIDIntoMapOfShapes( const TopoDS_Shape& S,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& L,
+ const int subShapeType,
+ TopTools_MapOfShape& aMap )
+{
+ if( L.length() < 1 || S.IsNull() ) {
+ return false ;
+ }
+
+ aMap.Clear() ;
+ for( int k=0; k<L.length(); k++ ) {
+ /* indices start at 1 in list L */
+ int j = 1 ;
+ TopExp_Explorer exp ;
+ TopTools_MapOfShape M;
+ for( exp.Init( S, TopAbs_ShapeEnum(subShapeType) ); exp.More(); exp.Next() ) {
+ if ( M.Add(exp.Current()) )
+ {
+ if( L[k] == j ) {
+ aMap.Add( exp.Current() ) ;
+ }
+ j++ ;
+ }
+ }
+ }
+ return true ;
+}
+
+
+
+//================================================================================
+// function : ListOfIDIntoSequenceOfShapes()
+// purpose : Define 'aSequenceOfShapes' from a main topology 'S' a 'subShapeType'
+// : and a list of indices 'L'.
+// : Return true if 'aSequenceOfShapes' is not empty
+//================================================================================
+bool GEOM_Gen_i::ListOfIDIntoSequenceOfShapes( const TopoDS_Shape& S,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& L,
+ const int subShapeType,
+ TopTools_SequenceOfShape& aSequenceOfShapes )
+{
+ if( L.length() < 1 || S.IsNull() ) {
+ return false ;
+ }
+
+ aSequenceOfShapes.Clear() ;
+ for( int k=0; k<L.length(); k++ ) {
+ /* indices start at 1 in list L */
+ int j = 1 ;
+ TopExp_Explorer exp ;
+ for( exp.Init( S, TopAbs_ShapeEnum(subShapeType) ); exp.More(); exp.Next() ) {
+ if( L[k] == j ) {
+ aSequenceOfShapes.Append( exp.Current() ) ;
+ }
+ j++ ;
+ }
+ }
+ return true ;
+}
+
+
+
+//================================================================================
+// function : SuppressFaces()
+// purpose : Suppress faces contained in ListOfID from 'shape'.
+// : Return a list of Geom shapes each one is a main shape GEOM::FACE or GEOM::SHELL
+//================================================================================
+GEOM::GEOM_Gen::ListOfGeomShapes* GEOM_Gen_i::SuppressFaces( GEOM::GEOM_Shape_ptr shape,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Gen::ListOfGeomShapes_var listOfGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
+ listOfGeomShapes->length(0) ;
+
+ TopoDS_Shape mainShape = GetTopoShape(shape);
+ if( mainShape.IsNull() )
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SuppressFaces() : null argument shape", SALOME::BAD_PARAM);
+
+ if( ListOfID.length() < 1 )
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SuppressFaces() : empty ListOfID", SALOME::BAD_PARAM);
+
+ /* Define 'mapFaces' a map of faces to be suppressed in mainShape */
+ TopTools_MapOfShape mapFaces ;
+ if( !ListOfIDIntoMapOfShapes(mainShape, ListOfID, TopAbs_FACE, mapFaces ) ) {
+ return listOfGeomShapes._retn();
+ }
+
+ /* Call algorithm to calculate a compound of shells resulting of face suppression */
+ int numberOfShells = 0 ;
+ TopoDS_Shape aCompoundOfShells ;
+ numberOfShells = SuppressFacesGlue(mainShape, mapFaces, aCompoundOfShells) ;
+ if(numberOfShells < 1) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::Suppressfaces() : no shells", SALOME::BAD_PARAM);
+ }
+
+ /* Create a shell for each shell contained in 'aCompoundOfShells' and */
+ /* put it in the list of GeomShapes to be returned. */
+ /* But if the shell is composed of only a face we create a face and not a shell */
+ int i = 0 ;
+ for( TopExp_Explorer exp(aCompoundOfShells, TopAbs_SHELL); exp.More(); exp.Next() ) {
+
+ const TopoDS_Shell& aShell = TopoDS::Shell( exp.Current() );
+ if( aShell.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::Suppressfaces() : null shell", SALOME::BAD_PARAM);
+ }
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var aList = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ aList = IndexOfFacesOfSubShell(mainShape, aShell) ;
+
+ if( aList->length() < 1 ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SuppressFaces() : aList is empty", SALOME::BAD_PARAM);
+ }
+
+ TopoDS_Shape aShellOrFace ;
+ /* Only a face into the shell : we create a single face instead of a shell : 'aList' is unchanged */
+ if( aList->length() == 1 ) {
+ TopExp_Explorer exp ;
+ exp.Init( aShell, TopAbs_FACE ) ;
+ exp.More() ;
+ aShellOrFace = exp.Current() ;
+ }
+ else {
+ aShellOrFace = aShell ;
+ }
+
+ /* Create CORBA object */
+ GEOM::GEOM_Shape_var result = CreateObject(aShellOrFace) ;
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Suppress Faces aborted : null result", SALOME::BAD_PARAM);
+ }
+
+ InsertInLabelOneArgument(mainShape, shape, aShellOrFace, result, myCurrentOCAFDoc) ;
+ i++ ;
+ listOfGeomShapes->length(i) ;
+ listOfGeomShapes[i-1] = result ;
+ }
+
+ return listOfGeomShapes._retn() ;
+}
+
+
+
+//================================================================================
+// function : IsShapeInSequence()
+// purpose : return true is aShape is in SS. The test method is 'IsSame()'
+//================================================================================
+bool GEOM_Gen_i::IsShapeInSequence(const TopTools_SequenceOfShape& SS, const TopoDS_Shape& aShape)
+{
+ if( aShape.IsNull() || SS.IsEmpty() )
+ return false ;
+ for( int i=1; i<=SS.Length(); i++) {
+ if( SS.Value(i).IsSame(aShape) )
+ return true ;
+ }
+ return false ;
+}
+
+
+//================================================================================
+// function : FreeEdgesFromMapOfFace()
+// purpose : Define MS a map of all edges of faces of 'MSfaces'
+// : All multiple edges are removed !
+//================================================================================
+void GEOM_Gen_i::FreeEdgesFromMapOfFace( const TopTools_MapOfShape& MSfaces,
+ TopTools_MapOfShape& MS )
+{
+ MS.Clear() ;
+ TopTools_MapOfShape Multiple ;
+ TopTools_MapIteratorOfMapOfShape it ;
+ for( it.Initialize(MSfaces); it.More(); it.Next() ) {
+ TopoDS_Shape aFace = it.Key() ;
+ TopExp_Explorer exp ;
+ for( exp.Init( aFace, TopAbs_EDGE); exp.More(); exp.Next() ) {
+ if( !Multiple.Contains( exp.Current() ) && !MS.Add( exp.Current() ) ) {
+ MS.Remove( exp.Current() ) ;
+ Multiple.Add( exp.Current() ) ;
+ }
+ }
+ }
+ return ;
+}
+
+
+//================================================================================
+// function : MapRemoveSequence()
+// purpose : In term of shapes ST = MS - SSRemove
+// :
+//================================================================================
+void GEOM_Gen_i::MapRemoveSequence( const TopTools_MapOfShape& MS,
+ const TopTools_SequenceOfShape& SSRemove,
+ TopTools_SequenceOfShape& ST )
+{
+ ST.Clear() ;
+ TopTools_MapIteratorOfMapOfShape it ;
+ for( it.Initialize(MS); it.More(); it.Next() ) {
+ TopoDS_Shape aShape = it.Key() ;
+ if( !IsShapeInSequence( SSRemove, aShape ) )
+ ST.Append( aShape ) ;
+ }
+ return ;
+}
+
+
+
+//================================================================================
+// function : SuppressHoleSubRoutine()
+// purpose : Define recursively 'MSfacesSuppress' a list of faces to suppress in a hole
+//================================================================================
+void GEOM_Gen_i::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)
+{
+ TopTools_MapOfShape MS ;
+ TopTools_SequenceOfShape SU ;
+ FreeEdgesFromMapOfFace(MSfaces, MS) ; /* MS = free edges of MSfaces */
+ MapRemoveSequence(MS, SSedgesOfWire, SU) ; /* SU = MS - SSedgesOfWire */
+
+ if( SU.IsEmpty() ) {
+ return ;
+ }
+
+ /* Here SU contains new edges to find new faces to suppress */
+ /* Define the list of faces of SU edges that aren't in faces of MSfacesSuppress in order to add into */
+ /* For each edge we have a map of all its faces : it's in 'aMapEdgesFaces' */
+ TopTools_MapOfShape MSfacesTmp ;
+ for( int v=1; v<=SU.Length(); v++ ) {
+ TopoDS_Shape E = SU.Value(v) ;
+ TopoDS_Shape F ;
+ TopTools_ListOfShape LF ;
+ int ind = aMapEdgesFaces.FindIndex(E) ;
+
+ /* LF is the list of faces for an edge of SU : may be empty no matter */
+ LF = aMapEdgesFaces.FindFromIndex(ind) ;
+
+ TopTools_ListIteratorOfListOfShape it ;
+ for( it.Initialize(LF); it.More(); it.Next() ) {
+ F = it.Value() ;
+ if( withEndFace == false ) {
+ if( F.IsSame(aFace) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHoleSubRoutine() : hole traversing or ?", SALOME::BAD_PARAM);
+ if( !MSfacesSuppress.Contains(F) ) {
+ MSfacesSuppress.Add(F) ;
+ MSfacesTmp.Add(F) ; // Dont remove the 'if' !
+ }
+ }
+ else { /* withEndFace == true */
+ if( F.IsSame(aFace) && !F.IsSame(endFace) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHoleSubRoutine() : hole traversing incoherent ?", SALOME::BAD_PARAM);
+
+ if( F.IsSame(endFace) ) {
+ /* We have reached endFace if selection was correct so we add */
+ /* edge in a map to find later the corresponding endWire (hole */
+ MSwireEndEdges.Add(E) ;
+ }
+ else {
+ if( !MSfacesSuppress.Contains(F) ) {
+ MSfacesSuppress.Add(F) ;
+ MSfacesTmp.Add(F) ;
+ }
+ }
+ }
+ }
+ }
+ /* Call recursively this routine */
+ SuppressHoleSubRoutine( mainShape, aFace, SSedgesOfWire, aMapEdgesFaces, MSfacesTmp, MSfacesSuppress, withEndFace, endFace, MSwireEndEdges ) ;
+}
+
+
+
+//================================================================================
+// function : GetShapeFromIndex()
+// purpose : Find 'tds' a sub shape of 'aShape' according to 'aList' that contains
+// : a unique index !
+// : Warning : index must be setted with the same exploration logic !
+// : So 'index' is calculated with no shape doublons !
+//================================================================================
+bool GEOM_Gen_i::GetShapeFromIndex( const TopoDS_Shape& aShape,
+ const TopAbs_ShapeEnum aType,
+ const int index,
+ TopoDS_Shape& tds )
+
+{
+ if (aShape.IsNull() || index < 1)
+ return false ;
+ /* Indices start at 1 */
+ int j = 1 ;
+ bool found = false ;
+ TopExp_Explorer exp ;
+ TopTools_MapOfShape M;
+ for( exp.Init( aShape, aType ); exp.More(); exp.Next() ) {
+ if( M.Add(exp.Current()) ) { /* if not a doublon : we compare */
+ if( index == j ) {
+ tds = exp.Current() ;
+ return true ;
+ }
+ j++ ;
+ }
+ }
+ return false ;
+}
+
+
+
+//================================================================================
+// function : SuppressHolesInFaceOrShell() Main method.
+// purpose : Suppress holes identified by wires in a single face or shell
+//
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::SuppressHolesInFaceOrShell( GEOM::GEOM_Shape_ptr shapeFaceShell,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdWires )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+
+ if( ListIdWires.length() < 1 )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace : no holes selected", SALOME::BAD_PARAM);
+
+ const TopoDS_Shape tds = GetTopoShape(shapeFaceShell) ;
+ if( tds.IsNull() || !BRepAlgoAPI::IsValid(tds) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace() : non valid main argument", SALOME::BAD_PARAM);
+
+ /* Create a map of wires/holes to suppress */
+ TopTools_MapOfShape MapHoles ;
+ for ( int i = 0; i < ListIdWires.length(); i++ ) {
+ TopoDS_Shape W ;
+ if( !GetShapeFromIndex( tds, TopAbs_WIRE, ListIdWires[i], W ) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace() : bad index ?", SALOME::BAD_PARAM);
+ MapHoles.Add( W ) ;
+ }
+
+ /* Test if argument is a face or shell */
+ bool isFace ;
+ if( tds.ShapeType() == TopAbs_FACE )
+ isFace = true ;
+ else if ( tds.ShapeType() == TopAbs_SHELL )
+ isFace = false ;
+ else
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace() : not a face or a shell", SALOME::BAD_PARAM);
+
+ /* Define two maps : all faces and faces to that will be modified */
+ TopTools_MapOfShape MapFacesToModify ;
+ TopTools_MapOfShape MapFacesAll ;
+ TopExp_Explorer expF ;
+ for( expF.Init( tds, TopAbs_FACE); expF.More(); expF.Next() ) {
+ TopoDS_Face F = TopoDS::Face( expF.Current() ) ;
+ MapFacesAll.Add(F) ;
+ TopExp_Explorer expW ;
+ for( expW.Init( F, TopAbs_WIRE); expW.More(); expW.Next() ) {
+ TopoDS_Wire W = TopoDS::Wire( expW.Current() ) ;
+ if( MapHoles.Contains(W) ) {
+ MapFacesToModify.Add(F) ;
+ }
+ }
+ }
+
+ /* Define faces not modified */
+ TopTools_MapOfShape MapFacesNotModified ;
+ TopTools_MapIteratorOfMapOfShape it ;
+ for( it.Initialize(MapFacesAll); it.More(); it.Next() ) {
+ TopoDS_Face FF = TopoDS::Face( it.Key() ) ;
+ if( !MapFacesToModify.Contains(FF) )
+ MapFacesNotModified.Add(FF) ;
+ }
+
+ if( MapFacesToModify.IsEmpty() )
+ THROW_SALOME_CORBA_EXCEPTION("Error : empty map of faces", SALOME::BAD_PARAM);
+
+ if( isFace && MapFacesToModify.Extent() != 1 )
+ THROW_SALOME_CORBA_EXCEPTION("Incoherent", SALOME::BAD_PARAM);
+
+ /* Main argument is a face */
+ if( isFace && MapFacesToModify.Extent() == 1 ) {
+ TopoDS_Face resultFace ;
+ if( !RebuildFaceRemovingHoles( TopoDS::Face(tds), MapHoles, resultFace ) )
+ THROW_SALOME_CORBA_EXCEPTION(" Problem : !RebuildFaceRemovingHoles()", SALOME::BAD_PARAM);
+ /* Creation of CORBA object : face topology */
+ result = CreateObject(resultFace);
+ InsertInLabelOneArgument(tds, shapeFaceShell, resultFace, result, myCurrentOCAFDoc) ;
+ return result ;
+ }
+
+ /* Main argument is a shell : rebuild faces modified */
+ TopTools_MapOfShape MapFacesModified ;
+ for( it.Initialize(MapFacesToModify); it.More(); it.Next() ) {
+ TopoDS_Face FF = TopoDS::Face( it.Key() ) ;
+ TopoDS_Face resF ;
+ if( !RebuildFaceRemovingHoles( FF, MapHoles, resF ) )
+ THROW_SALOME_CORBA_EXCEPTION(" Problem shell : !RebuildFaceRemovingHoles()", SALOME::BAD_PARAM);
+ MapFacesModified.Add(resF) ;
+ }
+
+ /* Rebuild the shell with faces modified and non modified */
+ TopoDS_Shell resultShell ;
+ BRepPrim_Builder B;
+ B.MakeShell(resultShell) ;
+ TopTools_MapIteratorOfMapOfShape it1 ;
+ for( it1.Initialize(MapFacesModified); it1.More(); it1.Next() )
+ B.AddShellFace( resultShell,TopoDS::Face( it1.Key() ) ) ;
+ for( it1.Initialize(MapFacesNotModified); it1.More(); it1.Next() )
+ B.AddShellFace( resultShell,TopoDS::Face( it1.Key() ) ) ;
+
+ B.CompleteShell(resultShell) ;
+
+ if( resultShell.IsNull() )
+ THROW_SALOME_CORBA_EXCEPTION("Null or not valid result Shell", SALOME::BAD_PARAM) ;
+
+ /* Creation of CORBA object : shell topology */
+ result = CreateObject(resultShell);
+ InsertInLabelOneArgument(tds, shapeFaceShell, resultShell, result, myCurrentOCAFDoc) ;
+ return result ;
+}
+
+
+//================================================================================
+// function : RebuildFaceRemovingHoles()
+// purpose : Rebuild a face removing holes that are in 'mapHoles'.
+// : NB : 'mapHoles' may content more holes than necessary
+//================================================================================
+bool GEOM_Gen_i::RebuildFaceRemovingHoles( const TopoDS_Face& aFace,
+ const TopTools_MapOfShape& mapHoles,
+ TopoDS_Shape& resultFace )
+{
+ /* Get the outer wire of the face 'aFace' */
+ TopoDS_Wire outW = BRepTools::OuterWire( aFace ) ;
+ if( outW.IsNull() || !BRepAlgoAPI::IsValid(outW) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace : bad outer wire of 'aFace'", SALOME::BAD_PARAM);
+
+ /* Rebuild a face avoiding holes in the map 'mapHoles' */
+ Handle(Geom_Surface) Surface = BRep_Tool::Surface(aFace) ;
+ TopoDS_Face F2 = BRepBuilderAPI_MakeFace( Surface, outW, true ) ;
+
+ if( F2.Orientation() != aFace.Orientation() )
+ F2.Orientation( aFace.Orientation() ) ;
+
+ BRepBuilderAPI_MakeFace aBuilder( F2 ) ;
+ bool foundAndKeepHoles = false ;
+ TopExp_Explorer exp ;
+
+ for( exp.Init( aFace, TopAbs_WIRE); exp.More(); exp.Next() ) {
+ TopoDS_Wire hole = TopoDS::Wire( exp.Current() ) ;
+ if( !mapHoles.Contains(hole) && !exp.Current().IsEqual(outW) ) {
+ aBuilder.Add( hole) ;
+ if( !aBuilder.IsDone() )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHolesInFace : builder problem !", SALOME::BAD_PARAM);
+
+ resultFace = TopoDS::Face(aBuilder) ;
+ foundAndKeepHoles = true ;
+ }
+ }
+
+ if( !foundAndKeepHoles )
+ resultFace = F2 ;
+ else
+ resultFace = TopoDS::Face(aBuilder) ;
+
+ return true ;
+}
+
+
+
+
+//================================================================================
+// function : SuppressHole() Main method.
+// purpose : Suppress an hole identified by a wire in a face of shape
+// : ListIdFace contains a unique index of face in shape
+// : ListIdWire contains a unique index of wire in face !!!
+// : ListIdEndFace is used only when hole traverse.
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::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)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Face aFace ;
+ TopoDS_Wire aWire ;
+ TopoDS_Face endFace ;
+ bool withEndFace ;
+ TopoDS_Shape tmp ;
+
+ /* Retrieve 'aShape' the initial main shape selection */
+ const TopoDS_Shape aShape = GetTopoShape(shape);
+
+ if( !BRepAlgoAPI::IsValid(aShape) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : non valid main shape", SALOME::BAD_PARAM);
+
+ if( ListIdFace.length() != 1 || ListIdWire.length() != 1 )
+ THROW_SALOME_CORBA_EXCEPTION("bad list", SALOME::BAD_PARAM);
+
+ /* Retrieve 'aFace' selection */
+ if( !GetShapeFromIndex( aShape, TopAbs_FACE, ListIdFace[0], tmp ) ) {
+ THROW_SALOME_CORBA_EXCEPTION("face not found", SALOME::BAD_PARAM);
+ }
+ else {
+ aFace = TopoDS::Face(tmp) ;
+ }
+ if( !BRepAlgoAPI::IsValid(aFace) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : face shape not valid", SALOME::BAD_PARAM);
+
+ /* Retrieve 'aWire' selection : Warning : index of wire refers to the face ! */
+ TopoDS_Shape aTmp ;
+ if( !GetShapeFromIndex( aFace, TopAbs_WIRE, ListIdWire[0], aTmp ) ) {
+ THROW_SALOME_CORBA_EXCEPTION("wire not found", SALOME::BAD_PARAM);
+ }
+ else {
+ aWire = TopoDS::Wire(aTmp) ;
+ }
+ if( !BRepAlgoAPI::IsValid(aWire) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : bad wire" , SALOME::BAD_PARAM);
+
+ /* Get the outer wire of aFace */
+ TopoDS_Wire outerW = BRepTools::OuterWire( aFace ) ;
+ if( outerW.IsNull() || !BRepAlgoAPI::IsValid(outerW) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : bad outer wire", SALOME::BAD_PARAM);
+
+ /* Test bad user selection aWire */
+ if( aWire.IsSame(outerW) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : outerW = aWire", SALOME::BAD_PARAM);
+
+ /* Test if 'endFace' is used as argument and seems to be a valid one */
+ /* NB : 'endFace' is optional and used when hole to suppress traverse 'aShape' */
+ if( ListIdEndFace.length() == 0 ) {
+ withEndFace = false ;
+ }
+ else {
+ TopoDS_Shape aTemp ;
+ if( !GetShapeFromIndex( aShape, TopAbs_FACE, ListIdEndFace[0], aTemp ) || tmp.IsNull() || !BRepAlgoAPI::IsValid(aTemp) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : non valid endFace", SALOME::BAD_PARAM);
+
+ /* Test if 'endFace' as at least one hole */
+ endFace = TopoDS::Face(aTemp) ;
+
+ TopExp_Explorer fExp ;
+ int nbWires = 0 ;
+ for( fExp.Init(endFace, TopAbs_WIRE); fExp.More(); fExp.Next() ) {
+ TopoDS_Wire W = TopoDS::Wire( fExp.Current() ) ;
+ if( !W.IsNull() && BRepAlgoAPI::IsValid(W) )
+ nbWires++ ;
+ }
+ if(nbWires > 1)
+ withEndFace = true ; /* at least 2 wires : outer wire plus an hole or more */
+ else
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SuppressHole() : end face selection ?", SALOME::BAD_PARAM);
+ }
+
+ /* Find edges of aWire and test if degenerated */
+ TopTools_SequenceOfShape SSedgesOfWire ;
+ TopExp_Explorer wireExp ;
+ for( wireExp.Init(aWire, TopAbs_EDGE); wireExp.More(); wireExp.Next() ) {
+ TopoDS_Edge E = TopoDS::Edge( wireExp.Current() ) ;
+ if( E.IsNull() || BRep_Tool::Degenerated(E) ) {
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : found bad edge", SALOME::BAD_PARAM);
+ }
+ else {
+ SSedgesOfWire.Append( wireExp.Current() ) ;
+ }
+ }
+ if( SSedgesOfWire.Length() < 1 )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : no edge(s) for aWire", SALOME::BAD_PARAM);
+
+ /* Retrieve face ancestors of all edges of 'aWire' but avoiding 'aFace' */
+
+ TopTools_IndexedDataMapOfShapeListOfShape aMapEdgesFaces;
+ TopTools_MapIteratorOfMapOfShape anIt ;
+ TopTools_MapOfShape MFSuppress ;
+ TopTools_MapOfShape MFSuppressTmp ;
+ bool wireOnFace = false ;
+
+ TopExp::MapShapesAndAncestors(aShape, TopAbs_EDGE, TopAbs_FACE, aMapEdgesFaces) ;
+ for( int h=1; h<=SSedgesOfWire.Length(); h++ ) {
+
+ TopoDS_Shape anEdgeOfWire = SSedgesOfWire.Value(h) ;
+ int ind = aMapEdgesFaces.FindIndex(anEdgeOfWire) ;
+ if(ind < 1)
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : index of edge", SALOME::BAD_PARAM);
+
+ TopTools_ListOfShape LF;
+ LF = aMapEdgesFaces.FindFromIndex(ind) ; /* Contains all faces ancestors of an edge of wire */
+ if( LF.IsEmpty() )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : no face for an edge", SALOME::BAD_PARAM);
+
+ /* Filter faces avoiding 'aFace' */
+ TopTools_ListIteratorOfListOfShape it ;
+ for( it.Initialize(LF); it.More(); it.Next() ) {
+ TopoDS_Face F = TopoDS::Face( it.Value() ) ;
+ if( !F.IsSame(aFace) ) {
+ MFSuppressTmp.Add(F) ;
+ MFSuppress.Add(F) ;
+ }
+ else {
+ wireOnFace = true ;
+ }
+ }
+ }
+
+ if( !wireOnFace ) {
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : wire not on selected face", SALOME::BAD_PARAM);
+ }
+
+ /* Call routine to define faces to suppress and and optional endWire on endFace */
+ TopTools_MapOfShape MSwireEndEdges ; /* will contain edges of final wire (hole) */
+ SuppressHoleSubRoutine( aShape, aFace, SSedgesOfWire, aMapEdgesFaces, MFSuppressTmp, MFSuppress, withEndFace, endFace, MSwireEndEdges ) ;
+
+ TopoDS_Wire endWire ;
+ if( withEndFace ) {
+
+ if( MSwireEndEdges.Extent() < 1 )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : MSwireEndEdges.Extent() < 1", SALOME::BAD_PARAM);
+
+ if( !FindCompareWireHoleOnFace( endFace, MSwireEndEdges, endWire ) )
+ THROW_SALOME_CORBA_EXCEPTION("in GEOM_Gen_i::SupressHole() : no endWire found", SALOME::BAD_PARAM);
+ }
+
+ /* Build 'resTds' : a shape containing a compound of faces */
+ TopoDS_Shape resTds;
+ if( !withEndFace && !BuildShapeHoleNotTraversing( aShape, aFace, aWire, MFSuppress, resTds ) )
+ THROW_SALOME_CORBA_EXCEPTION("Rebuild result shape has aborted", SALOME::BAD_PARAM);
+
+ if( withEndFace && !BuildShapeHoleTraversing( aShape, aFace, aWire, MFSuppress, endFace, endWire, resTds ) )
+ THROW_SALOME_CORBA_EXCEPTION("Rebuild result shape has aborted (end hole)", SALOME::BAD_PARAM);
+
+ /* Reconstruction of final shape with 'resTds' : a compound of faces after hole suppressing */
+ /* Actual limitation is : 'aShape' must not contain more than a solid or a shell ! */
+ TopoDS_Shape finalShape ;
+
+ TopExp_Explorer exp ;
+ unsigned int nbSolid = 0 ;
+ TopoDS_Solid aSolid ;
+ for( exp.Init(aShape, TopAbs_SOLID); exp.More(); exp.Next() ) {
+ aSolid = TopoDS::Solid( exp.Current() ) ;
+ nbSolid++ ;
+ if( nbSolid > 1 )
+ THROW_SALOME_CORBA_EXCEPTION("Limitation : main shape contents more than one solid", SALOME::BAD_PARAM);
+ }
+
+ unsigned int nbShell = 0 ;
+ TopoDS_Shell aShell ;
+ for( exp.Init(aShape, TopAbs_SHELL); exp.More(); exp.Next() ) {
+ aShell = TopoDS::Shell( exp.Current() ) ;
+ nbShell++ ;
+ if( nbShell > 1 )
+ THROW_SALOME_CORBA_EXCEPTION("Limitation : main shape contents more than one shell", SALOME::BAD_PARAM);
+ }
+
+ /* No shells and no solids : can send a compound even for a single face, see GUI ! */
+ if( nbShell == 0 ) {
+ finalShape = resTds ;
+ }
+
+ /* a shell */
+ TopoDS_Shell shellResult ;
+ if( nbShell == 1 ) {
+ if ( !BuildShellWithFaceCompound( TopoDS::Compound(resTds), shellResult ) )
+ THROW_SALOME_CORBA_EXCEPTION("Error after BuildShellWithFaceCompound()", SALOME::BAD_PARAM);
+ finalShape = shellResult ;
+ }
+
+ /* a solid with a shell */
+ if( nbSolid == 1 && nbShell == 1) {
+ BRepBuilderAPI_MakeSolid B;
+ B.Add(shellResult) ;
+ if( !B.IsDone() )
+ THROW_SALOME_CORBA_EXCEPTION("Error : !B.IsDone()", SALOME::BAD_PARAM);
+ finalShape = B.Solid() ;
+ }
+
+ result = CreateObject(finalShape);
+ InsertInLabelOneArgument(aShape, shape, finalShape, result, myCurrentOCAFDoc) ;
+ return result ;
+}
+
+
+
+//================================================================================
+// function : BuildShellWithFaceCompound()
+// purpose : Build a shell with a compound of faces.
+//================================================================================
+bool GEOM_Gen_i::BuildShellWithFaceCompound( const TopoDS_Compound Comp,
+ TopoDS_Shell& resultShell )
+{
+ resultShell.Nullify() ;
+ BRepPrim_Builder B ;
+ B.MakeShell(resultShell) ;
+ TopExp_Explorer ex ;
+ int i = 0 ;
+ for( ex.Init( Comp, TopAbs_FACE); ex.More(); ex.Next() ) {
+ TopoDS_Face F = TopoDS::Face( ex.Current() ) ;
+ if( !BRepAlgoAPI::IsValid(F) ) {
+ return false ;
+ }
+ B.AddShellFace( resultShell, F ) ;
+ }
+ B.CompleteShell(resultShell) ;
+ if( resultShell.IsNull() ) {
+ return false ;
+ }
+ return true ;
+}
+
+
+//================================================================================
+// function : FindCompareWireHoleOnFace()
+// purpose : Try to find a wire on 'aFace' which edges are same than those
+// : into 'MSwireEdges' map. 'aFoundWire' is defined and 'true' returned.
+// : 'MSwireEdges' represents generally an hole an 'aFace'.
+// : The outer wire of 'aFace' is avoided !
+//================================================================================
+bool GEOM_Gen_i::FindCompareWireHoleOnFace( const TopoDS_Face& F,
+ const TopTools_MapOfShape& MSwireEdges,
+ TopoDS_Wire& aFoundWire )
+{
+ aFoundWire.Nullify() ;
+
+ if( F.IsNull() )
+ return false ;
+
+ /* Get the outer wire of aFace */
+ TopoDS_Wire outerW = BRepTools::OuterWire(F) ;
+ if( outerW.IsNull() || !BRepAlgoAPI::IsValid(outerW) ) {
+ return false ;
+ }
+
+ int nbEdges = MSwireEdges.Extent() ;
+ if( nbEdges < 1 ) {
+ return false ;
+ }
+
+ TopExp_Explorer exp1 ;
+ TopExp_Explorer exp2 ;
+ for ( exp1.Init(F, TopAbs_WIRE) ; exp1.More(); exp1.Next() ) {
+ TopoDS_Wire W = TopoDS::Wire( exp1.Current() ) ;
+ int i = 0 ;
+ if( !W.IsSame(outerW) ) {
+ for ( exp2.Init( W, TopAbs_EDGE) ; exp2.More(); exp2.Next() ) {
+ TopoDS_Edge E = TopoDS::Edge( exp2.Current() ) ;
+ if( MSwireEdges.Contains(E) ) {
+ i++ ;
+ if( i == nbEdges ) {
+ aFoundWire = W ;
+ return true ;
+ }
+ }
+ }
+ }
+ }
+ return false ;
+}
+
+
+//================================================================================
+// function : BuildShapeHoleNotTraversing()
+// purpose : Define 'resultTds' a reconstruction of 'aShape' after modification
+// : on 'aFace' where 'aWire is removed' and suppression of faces 'MFSuppress'
+// : ( Used as a sub routine of SuppressHole() )
+//================================================================================
+bool GEOM_Gen_i::BuildShapeHoleNotTraversing( const TopoDS_Shape& aShape,
+ const TopoDS_Face& aFace,
+ const TopoDS_Wire& aWire,
+ const TopTools_MapOfShape& MFSuppress,
+ TopoDS_Shape& resultTds )
+ throw (SALOME::SALOME_Exception)
+{
+ BRep_Builder B;
+ TopExp_Explorer exp ;
+ TopoDS_Face newFace ;
+
+ resultTds.Nullify() ;
+ TopoDS_Compound Comp ;
+ B.MakeCompound (Comp);
+
+ try {
+
+ /* Explore all faces of 'aShape' to rebuild a compound */
+ for ( exp.Init(aShape, TopAbs_FACE) ; exp.More(); exp.Next() ) {
+
+ TopoDS_Face F1 = TopoDS::Face( exp.Current() );
+ /* Rebuild face(s) not suppressed */
+ if( !MFSuppress.Contains(F1) ) {
+
+ if( F1.IsEqual( aFace ) ) {
+ TopTools_MapOfShape MSwire ;
+ MSwire.Add(aWire) ;
+ if( !RebuildFaceRemovingHoles(aFace, MSwire, newFace) ) {
+ return false ;
+ }
+ B.Add( Comp, newFace ) ;
+ }
+ else {
+ /* For any other face not suppressed */
+ B.Add( Comp, F1 ) ;
+ }
+ }
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("in BuildShapeHoleNotTraversing() : Exception catched", SALOME::BAD_PARAM);
+ }
+ resultTds = Comp ;
+ return true ;
+}
+
+
+
+//================================================================================
+// function : BuildShapeHoleTraversing()
+// purpose : Define 'resultTds' a reconstruction of 'aShape' after modifications.
+// : On 'aFace' 'aWire is removed'
+// : On 'endFace' 'endWire' is removed.
+// : Faces of 'MFSuppress' are removed.
+// : ( Used as a sub routine of SuppressHole() )
+//================================================================================
+bool GEOM_Gen_i::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)
+{
+ BRep_Builder B;
+ TopExp_Explorer exp ;
+ TopoDS_Face newFace ;
+
+ resultTds.Nullify() ;
+ TopoDS_Compound Comp ;
+ B.MakeCompound (Comp);
+
+ /* Necessary to use general method */
+ TopTools_MapOfShape MSwire1 ;
+ MSwire1.Add(aWire) ;
+ TopTools_MapOfShape MSwire2 ;
+ MSwire2.Add(endWire) ;
+
+ try {
+
+ /* Explore all faces of 'aShape' to rebuild a compound */
+ for ( exp.Init(aShape, TopAbs_FACE) ; exp.More(); exp.Next() ) {
+ TopoDS_Face F1 = TopoDS::Face( exp.Current() );
+
+ /* Rebuild face(s) not suppressed */
+ if( !MFSuppress.Contains(F1) ) {
+
+ /* Rebuild 'aFace' */
+ if( F1.IsEqual( aFace ) && !F1.IsEqual( endFace ) ) {
+ if( !RebuildFaceRemovingHoles(aFace, MSwire1, newFace) ) {
+ return false ;
+ }
+ B.Add(Comp, newFace) ;
+ }
+
+ /* Rebuild 'endFace' */
+ if( !F1.IsEqual( aFace ) && F1.IsEqual( endFace ) ) {
+ if( !RebuildFaceRemovingHoles(endFace, MSwire2, newFace) ) {
+ return false ;
+ }
+ B.Add(Comp, newFace) ;
+ }
+
+ /* Hole in the same face : aFace = endFace */
+ if( F1.IsEqual( aFace ) && F1.IsEqual( endFace ) ) {
+ TopoDS_Face FF ;
+ if( !RebuildFaceRemovingHoles(aFace, MSwire1, newFace) || !RebuildFaceRemovingHoles(newFace, MSwire2, FF) ) {
+ return false ;
+ }
+ B.Add( Comp, FF ) ;
+ }
+
+ /* For any other face not suppressed */
+ if( !F1.IsEqual(aFace) && !F1.IsEqual( endFace ) ) {
+ B.Add( Comp, F1 ) ;
+ }
+
+ }
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("in BuildShapeHoleTraversing() : Exception catched", SALOME::BAD_PARAM);
+ }
+ resultTds = Comp ;
+ return true ;
+}
+
+//=======================================================================
+//function : SortShapes
+//purpose :
+//=======================================================================
+
+static void SortShapes(TopTools_ListOfShape& SL)
+{
+ Standard_Integer MaxShapes = SL.Extent();
+ TopTools_Array1OfShape aShapes (1,MaxShapes);
+ TColStd_Array1OfInteger OrderInd(1,MaxShapes);
+ TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z;
+ TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z;
+
+ // Computing of CentreOfMass
+ Standard_Integer Index;
+ GProp_GProps GPr;
+ gp_Pnt GPoint;
+ TopTools_ListIteratorOfListOfShape it(SL);
+ for (Index=1; it.More(); Index++)
+ {
+ TopoDS_Shape S = it.Value();
+ SL.Remove( it ); // == it.Next()
+ aShapes(Index) = S;
+ OrderInd.SetValue (Index, Index);
+ if (S.ShapeType() == TopAbs_VERTEX)
+ {
+ GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S ));
+ Length.SetValue( Index, (Standard_Real) S.Orientation());
+ }
+ else
+ {
+ BRepGProp::LinearProperties (S, GPr);
+ GPoint = GPr.CentreOfMass();
+ Length.SetValue( Index, GPr.Mass() );
+ }
+ MidXYZ.SetValue(Index,
+ GPoint.X()*999 + GPoint.Y()*99 + GPoint.Z()*0.9);
+ }
+ // Sorting
+ Standard_Integer aTemp;
+ Standard_Boolean exchange, Sort = Standard_True;
+ while (Sort)
+ {
+ Sort = Standard_False;
+ for (Index=1; Index < MaxShapes; Index++)
+ {
+ if (MidXYZ(OrderInd(Index)) > MidXYZ(OrderInd(Index+1)))
+ exchange = Standard_True;
+ else if (MidXYZ(OrderInd(Index)) == MidXYZ(OrderInd(Index+1)) &&
+ Length(OrderInd(Index)) > Length(OrderInd(Index+1)) )
+ exchange = Standard_True;
+ else
+ exchange = Standard_False;
+ if (exchange)
+ {
+ aTemp = OrderInd(Index);
+ OrderInd(Index) = OrderInd(Index+1);
+ OrderInd(Index+1) = aTemp;
+ Sort = Standard_True;
+ }
+ }
+ }
+ for (Index=1; Index <= MaxShapes; Index++)
+ SL.Append( aShapes( OrderInd(Index) ));
+}
+
+//================================================================================
+// function : SubShape()
+// purpose : Method for GUI or TUI
+//================================================================================
+
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::SubShape(GEOM::GEOM_Shape_ptr shape,
+ CORBA::Short ShapeType,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
+ throw (SALOME::SALOME_Exception)
+{
+ return SubShapesOne(shape, (TopAbs_ShapeEnum) ShapeType, ListOfID);
+}
+
+//================================================================================
+// function : SubShapeSorted()
+// purpose : Method for GUI or TUI
+//================================================================================
+
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::SubShapeSorted(GEOM::GEOM_Shape_ptr shape,
+ CORBA::Short ShapeType,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
+ throw (SALOME::SALOME_Exception)
+{
+ return SubShapesOne(shape, (TopAbs_ShapeEnum) ShapeType, ListOfID, Standard_True);
+}
+
+//================================================================================
+// function : SubShapesOne()
+// purpose :
+//================================================================================
+
+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 Sort)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape mainShape;
+ TopoDS_Shape mainTopo = GetTopoShape(shape);
+
+ bool main = false;
+ while ( !main ) {
+ if ( shape->IsMainShape() ) {
+ mainShape = GetTopoShape(shape);
+ main = true;
+ } else
+ shape = GetIORFromString( shape->MainName() );
+ }
+
+ if(ListOfID.length() < 1) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SubShape() : bad list of shapes",
+ SALOME::BAD_PARAM);
+ }
+
+ /* Create a sequence of all sub shapes */
+ TopTools_ListOfShape listShape;
+
+ TopTools_MapOfShape mapShape;
+ TopExp_Explorer exp ;
+ for ( exp.Init( mainShape, TopAbs_ShapeEnum(ShapeType)) ; exp.More(); exp.Next() ) {
+ if ( mapShape.Add( exp.Current() ) )
+ listShape.Append ( exp.Current() );
+ }
+
+ if (listShape.IsEmpty()) return shape;
+
+ if (Sort)
+ SortShapes(listShape);
+
+ TopTools_SequenceOfShape SS;
+ TopTools_ListIteratorOfListOfShape it (listShape);
+ for (; it.More(); it.Next())
+ SS.Append( it.Value() );
+
+ TopoDS_Shape SubShape;
+ if (ListOfID.length() == 1)
+ SubShape = SS.Value(ListOfID[0]);
+ else
+ {
+ BRep_Builder B;
+ TopoDS_Compound Comp;
+ B.MakeCompound (Comp);
+ unsigned int ind;
+ for ( ind = 0; ind < ListOfID.length(); ind++ )
+ B.Add( Comp, SS.Value(ListOfID[ind]) );
+ SubShape = Comp;
+ }
+
+ if ( !TNaming_Tool::HasLabel( myCurrentOCAFDoc->Main(), SubShape ) )
+ result = CreateSubObject( SubShape, shape, ListOfID);
+ else {
+ int TransDef;
+ TDF_Label Lab = TNaming_Tool::Label( myCurrentOCAFDoc->Main(), SubShape, TransDef );
+ Handle(TDataStd_Name) Att;
+ if ( Lab.FindAttribute( TDataStd_Name::GetID(), Att ) ) {
+ TCollection_AsciiString nameIOR( Att->Get() );
+ result = GEOM::GEOM_Shape::_narrow(_orb->string_to_object( nameIOR.ToCString() ));
+ if ( strcmp( result->MainName(), _orb->object_to_string(shape) ) != 0 ) {
+ result = CreateSubObject( SubShape, shape, ListOfID);
+ }
+ }
+ }
+
+ return result;
+}
+
+
+//================================================================================
+// function : SubShapeAll()
+// purpose : Explode a shape in all sub shapes with a type (Method for TUI or GUI)
+//================================================================================
+
+GEOM::GEOM_Gen::ListOfGeomShapes* GEOM_Gen_i::SubShapeAll(GEOM::GEOM_Shape_ptr shape,
+ CORBA::Short ShapeType)
+ throw (SALOME::SALOME_Exception)
+{
+ return SubShapesAll(shape, (TopAbs_ShapeEnum) ShapeType);
+}
+
+//================================================================================
+// function : SubShapeAllSorted()
+// purpose : Explode a shape in all sub shapes with a type (Method for TUI or GUI)
+//================================================================================
+
+GEOM::GEOM_Gen::ListOfGeomShapes* GEOM_Gen_i::SubShapeAllSorted(GEOM::GEOM_Shape_ptr shape,
+ CORBA::Short ShapeType)
+ throw (SALOME::SALOME_Exception)
+{
+ return SubShapesAll(shape, (TopAbs_ShapeEnum) ShapeType, Standard_True);
+}
+
+//================================================================================
+// function : SubShapeAllSorted()
+// purpose :
+//================================================================================
+
+GEOM::GEOM_Gen::ListOfGeomShapes* GEOM_Gen_i::SubShapesAll(GEOM::GEOM_Shape_ptr shape,
+ const TopAbs_ShapeEnum ShapeType,
+ const Standard_Boolean Sort)
+ throw (SALOME::SALOME_Exception)
+{
+ /* List of sub shapes returned */
+ GEOM::GEOM_Gen::ListOfGeomShapes_var listOfGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
+ listOfGeomShapes->length(0) ;
+
+ TopoDS_Shape mainTopo = GetTopoShape(shape);
+ TopoDS_Shape mainShape;
+ bool main = false;
+ while ( !main ) {
+ if ( shape->IsMainShape() ) {
+ mainShape = GetTopoShape(shape);
+ main = true;
+ } else
+ shape = GetIORFromString( shape->MainName() );
+ }
+
+ if( mainTopo.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("In GEOM_Gen_i::SubShapeAll() : null main shape",
+ SALOME::BAD_PARAM);
+ }
+
+ /* List/index : field set for any sub shape */
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ListOfID->length(1) ;
+
+ // retrieve all subshapes
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ if (mainTopo.ShapeType()==TopAbs_COMPOUND && ShapeType==TopAbs_SHAPE)
+ {
+ TopoDS_Iterator It(mainTopo,Standard_True,Standard_True );
+ for ( ; It.More(); It.Next() )
+ if (mapShape.Add( It.Value() ))
+ listShape.Append( It.Value() );
+ }
+ else
+ {
+ TopExp_Explorer exp ( mainTopo, ShapeType);
+ for ( ; exp.More(); exp.Next() )
+ if (mapShape.Add( exp.Current() ))
+ listShape.Append( exp.Current() );
+ }
+
+ if (Sort)
+ SortShapes(listShape);
+
+ /* Create all sub shapes */
+ int index;
+ GEOM::GEOM_Shape_var result;
+
+ TopTools_ListIteratorOfListOfShape itSub (listShape);
+ for (index = 1; itSub.More(); itSub.Next(), ++index)
+ {
+ const TopoDS_Shape& SubShape = itSub.Value();
+ // check if SubShape is already in OCAFDS and ...
+ if ( TNaming_Tool::HasLabel( myCurrentOCAFDoc->Main(), SubShape ) )
+ {
+ int TransDef;
+ TDF_Label Lab = TNaming_Tool::Label( myCurrentOCAFDoc->Main(), SubShape, TransDef );
+ Handle(TDataStd_Name) Att;
+ if ( Lab.FindAttribute( TDataStd_Name::GetID(), Att ) )
+ {
+ TCollection_AsciiString nameIOR( Att->Get() );
+ result = GEOM::GEOM_Shape::_narrow(_orb->string_to_object( nameIOR.ToCString() ));
+ // ... it is subshape of <shape>
+ if ( strcmp( result->MainName(), _orb->object_to_string(shape) ) == 0 )
+ {
+ listOfGeomShapes->length(index) ;
+ listOfGeomShapes[index-1] = result ;
+ continue;
+ }
+ }
+ }
+
+// if (Sort)
+// ListOfID[0] = index;
+// else
+ ListOfID[0] = GetIndexTopology( SubShape, mainShape ) ;
+ result = CreateSubObject( SubShape, shape, ListOfID);
+ /* Add each sub shape in the list returned */
+ listOfGeomShapes->length(index) ;
+ listOfGeomShapes[index-1] = result ;
+ }
+
+ return listOfGeomShapes._retn() ;
+}
+
+
+//=================================================================================
+// function : MakeBoolean()
+// purpose : Boolean operation according to the type 'operation'
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeBoolean(GEOM::GEOM_Shape_ptr shape1,
+ GEOM::GEOM_Shape_ptr shape2,
+ CORBA::Long operation)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape shape ;
+ TopoDS_Shape aShape1 ;
+ TopoDS_Shape aShape2 ;
+
+ try {
+ aShape1 = GetTopoShape(shape1) ;
+ aShape2 = GetTopoShape(shape2) ;
+
+ if( aShape1.IsNull() || aShape2.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Boolean aborted : argument shape is null", SALOME::BAD_PARAM);
+ }
+
+ switch (operation)
+ {
+ case 1 : /* Common */
+ shape = BRepAlgoAPI_Common(aShape1, aShape2).Shape();
+ break ;
+ case 2 : /* Cut */
+ shape = BRepAlgoAPI_Cut(aShape1, aShape2).Shape();
+ break ;
+ case 3 : /* Fuse */
+ shape = BRepAlgoAPI_Fuse(aShape1, aShape2).Shape();
+ break ;
+ case 4 : /* Section */
+ shape = BRepAlgoAPI_Section(aShape1, aShape2).Shape();
+ break ;
+ default :
+ MESSAGE("Boolean operation not known : " << operation ) ;
+ return result ;
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in boolean operation", SALOME::BAD_PARAM);
+ }
+
+ /* We test the validity of resulting shape */
+ if( !BRepAlgoAPI::IsValid(shape) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Boolean aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(shape) ;
+
+ /* put shape and name into geom/OCAF doc */
+ GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
+ /* add attributs 'shape' and' name_io'r in a new label */
+ TDF_Label Lab = GC.Generated(aShape1, shape, result->Name() );
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab, entry);
+ result->ShapeId( entry.ToCString() ) ;
+
+ /* Create a new label */
+ TDF_Label NewLab = Lab.NewChild();
+ TCollection_ExtendedString Value("Arguments");
+ TDataStd_Name::Set(NewLab,Value);
+
+ TDF_Label NewLab1 = NewLab.NewChild();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), shape1->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab1, RefLab);
+
+ TDF_Label NewLab2 = NewLab.NewChild();
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), shape2->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab2, RefLab);
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeFuse()
+// purpose : Special purpose !
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFuse(GEOM::GEOM_Shape_ptr shape1,
+ GEOM::GEOM_Shape_ptr shape2)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape aShape1 = GetTopoShape(shape1) ;
+ TopoDS_Shape aShape2 = GetTopoShape(shape2) ;
+ if( aShape1.IsNull() || aShape2.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Fuse aborted : shape in argument is null", SALOME::BAD_PARAM);
+ }
+ TopoDS_Shape shape;
+ try {
+ shape = BRepAlgoAPI_Fuse(aShape1, aShape2).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in Fuse operation", SALOME::BAD_PARAM);
+ }
+
+ /* We test the validity of resulting shape */
+ if( !BRepAlgoAPI::IsValid(shape) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Fuse aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(shape) ;
+
+ /* put shape and name into geom/OCAF doc */
+ GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
+ /* add attributs 'shape' and' name_io'r in a new label */
+ TDF_Label Lab = GC.Generated(aShape1, shape, result->Name() );
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab, entry);
+ result->ShapeId( entry.ToCString() ) ;
+
+ /* Create a new label */
+ TDF_Label NewLab = Lab.NewChild();
+ TCollection_ExtendedString Value("Arguments");
+ TDataStd_Name::Set(NewLab,Value);
+
+ TDF_Label NewLab1 = NewLab.NewChild();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), shape1->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab1, RefLab);
+
+ TDF_Label NewLab2 = NewLab.NewChild();
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), shape2->ShapeId(), RefLab);
+ TDF_Reference::Set(NewLab2, RefLab);
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeAxisStruct()
+// purpose : Create a structure GEOM::AxisStruct (see IDL file)
+//================================================================================
+GEOM::AxisStruct GEOM_Gen_i::MakeAxisStruct(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z,
+ CORBA::Double vx,
+ CORBA::Double vy,
+ CORBA::Double vz)
+{
+ GEOM::AxisStruct A ;
+ A.x = x ; A.y = y ; A.z = z ;
+ A.vx = vx ; A.vy = vy ; A.vz = vz ;
+ return A ;
+}
+
+
+//================================================================================
+// function : MakePointStruct()
+// purpose : Create a structure GEOM::PointStruct (see IDL file)
+//================================================================================
+GEOM::PointStruct GEOM_Gen_i::MakePointStruct(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+{
+ beginService( "GEOM_Gen_i::MakePointStruct" );
+ GEOM::PointStruct p ;
+ p.x = x ; p.y = y ; p.z = z ;
+ endService( "GEOM_Gen_i::MakePointStruct" );
+ return p ;
+}
+
+//================================================================================
+// function : MakeDirection()
+// purpose : Create a structure GEOM::DirStruct (see IDL file)
+//================================================================================
+GEOM::DirStruct GEOM_Gen_i::MakeDirection(const GEOM::PointStruct& p)
+{
+ GEOM::DirStruct d ;
+ d.PS.x = p.x ; d.PS.y = p.y ; d.PS.z = p.z ;
+ return d ;
+ }
+
+//=================================================================================
+// function : MakeBox()
+// purpose : Create a box topology.
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeBox(CORBA::Double x1,
+ CORBA::Double y1,
+ CORBA::Double z1,
+ CORBA::Double x2,
+ CORBA::Double y2,
+ CORBA::Double z2)
+ throw (SALOME::SALOME_Exception)
+{
+ gp_Pnt P1(x1,y1,z1);
+ gp_Pnt P2(x2,y2,z2);
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ try {
+ tds = BRepPrimAPI_MakeBox(P1,P2).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBox", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Box aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry) ;
+ return result;
+}
+
+
+//================================================================================
+// function : MakeCylinder
+// purpose : Create a cylinder topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCylinder(const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct,
+ CORBA::Double radius,
+ CORBA::Double height)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+ gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
+ gp_Dir d(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ gp_Ax2 axis(p, d) ;
+
+ try {
+ tds = BRepPrimAPI_MakeCylinder(axis, radius, height).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeCylinder", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Cylinder aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+
+
+//================================================================================
+// function : MakeSphere()
+// purpose : Make a sphere topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSphere(CORBA::Double x1,
+ CORBA::Double y1,
+ CORBA::Double z1,
+ CORBA::Double radius)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ try {
+ tds = BRepPrimAPI_MakeSphere(gp_Pnt(x1,y1,z1), radius).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeSphere", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Sphere aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result;
+}
+
+
+
+//================================================================================
+// function : MakeTorus()
+// purpose : Create a torus topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeTorus( const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct,
+ CORBA::Double major_radius,
+ CORBA::Double minor_radius )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+ gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
+ gp_Dir d(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ gp_Ax2 axis(p, d) ;
+
+ try {
+ tds = BRepPrimAPI_MakeTorus(axis, major_radius, minor_radius).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeTorus", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make torus aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeCone()
+// purpose : Create a cone topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCone(const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct,
+ CORBA::Double radius1,
+ CORBA::Double radius2,
+ CORBA::Double height)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+ gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
+ gp_Dir d(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ gp_Ax2 axis(p, d) ;
+
+ try {
+ /* Cone doesn't work if same radius */
+ if( fabs(radius1-radius2) <= Precision::Confusion() ) {
+ tds = BRepPrimAPI_MakeCylinder(axis, (radius1+radius2)/2.0, height).Shape();
+ }
+ else {
+ tds = BRepPrimAPI_MakeCone(axis, radius1, radius2, height).Shape();
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeCone", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Cone aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+
+
+//==================================================================================
+// function : ImportIGES()
+// purpose : Import shape from an IGES (IGS) file
+// : LPN modified 7 mai 2002
+//==================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportIGES(const char* filename)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ //VRV: OCC 4.0 migration
+ IGESControl_Reader aReader;
+ //VRV: OCC 4.0 migration
+ try {
+ IFSelect_ReturnStatus stat = aReader.ReadFile((char*)filename);
+ if ( stat != IFSelect_RetDone ) {
+ THROW_SALOME_CORBA_EXCEPTION("Error in reading import file", SALOME::BAD_PARAM); }
+
+ MESSAGE("ImportIGES : all Geometry Transfer" << endl ) ;
+ aReader.Clear();
+ aReader.TransferRoots(false);
+
+ MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes() << endl );
+ TopoDS_Shape shape = aReader.OneShape();
+
+ if ( !shape.IsNull() ) {
+ /* Final CORBA object creation */
+ result = CreateObject(shape) ;
+ const char *entry = InsertInLabel( shape, result->Name(), myCurrentOCAFDoc ) ;
+ result->ShapeId(entry);
+ return result ;
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportIGES()", SALOME::BAD_PARAM);
+ }
+
+ THROW_SALOME_CORBA_EXCEPTION("Import IGES aborted : internal error", SALOME::BAD_PARAM);
+}
+
+
+
+//==================================================================================
+// function : ImportSTEP()
+// purpose : Import shape from an STEP (stp) file
+// : 'result' is a compound of shapes if file contains more entities.
+//==================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportSTEP(const char* filename)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ //VRV: OCC 4.0 migration
+ STEPControl_Reader aReader;
+ //VRV: OCC 4.0 migration
+
+ TopoDS_Compound compound;
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ try {
+ IFSelect_ReturnStatus status = aReader.ReadFile((char*)filename);
+
+ if (status == IFSelect_RetDone) {
+ Standard_Boolean failsonly = Standard_False ;
+ aReader.PrintCheckLoad (failsonly, IFSelect_ItemsByEntity);
+ /* Root transfers */
+ Standard_Integer nbr = aReader.NbRootsForTransfer();
+ aReader.PrintCheckTransfer (failsonly, IFSelect_ItemsByEntity);
+
+ for ( Standard_Integer n=1; n <= nbr; n++) {
+
+ Standard_Boolean ok = aReader.TransferRoot(n);
+ /* Collecting resulting entities */
+ Standard_Integer nbs = aReader.NbShapes();
+ if (nbs == 0)
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM) ;
+
+ for ( Standard_Integer i=1; i<=nbs; i++ ) {
+ TopoDS_Shape aShape = aReader.Shape(i);
+ if ( aShape.IsNull() )
+ THROW_SALOME_CORBA_EXCEPTION("Null shape in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM) ;
+
+ /* For a single entity */
+ if(nbr == 1 && nbs == 1) {
+ result = CreateObject(aShape) ;
+ const char *entry = InsertInLabel(aShape, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+ }
+ else {
+ B.Add( compound, aShape ) ;
+ }
+ }
+ }
+
+ TopoDS_Shape tds = compound ;
+ result = CreateObject(tds) ;
+ if( CORBA::is_nil(result) )
+ THROW_SALOME_CORBA_EXCEPTION("Translation aborted : null result", SALOME::BAD_PARAM);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+ }
+
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportStep", SALOME::BAD_PARAM);
+ }
+ return result ;
+}
+
+
+//==================================================================================
+// function : Partition()
+// purpose :
+//==================================================================================
+
+GEOM::GEOM_Shape_ptr
+ GEOM_Gen_i::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)
+{
+ GEOM::GEOM_Shape_var aResult;
+ TopoDS_Shape tds ;
+ //MESSAGE ("In Partition");
+ try {
+
+ unsigned int ind, nbshapes = 0;
+ nbshapes += ListShapes.length() + ListTools.length();
+ nbshapes += ListKeepInside.length() + ListRemoveInside.length();
+
+ Partition_Spliter PS;
+ TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
+
+ // add object shapes that are in ListShapes;
+ for ( ind = 0; ind < ListShapes.length(); ind++) {
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ if(Shape.IsNull() ) {
+ //MESSAGE ( "In Partition a shape is null" );
+ THROW_SALOME_CORBA_EXCEPTION("In Partition a shape is null", SALOME::BAD_PARAM);
+ }
+ if ( ShapesMap.Add( Shape ))
+ PS.AddShape(Shape);
+ }
+
+ // add tool shapes that are in ListTools and not in ListShapes;
+ for (ind = 0; ind < ListTools.length(); ind++) {
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListTools[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ if(Shape.IsNull() ) {
+ //MESSAGE ( "In Partition a tool shape is null" );
+ THROW_SALOME_CORBA_EXCEPTION("In Partition a shape is null", SALOME::BAD_PARAM);
+ }
+ if ( !ShapesMap.Contains( Shape ) && ToolsMap.Add( Shape ))
+ PS.AddTool(Shape);
+ }
+
+ // add shapes that are in ListKeepInside, as object shapes;
+ for (ind = 0; ind < ListKeepInside.length(); ind++) {
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListKeepInside[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ if(Shape.IsNull() ) {
+ //MESSAGE ( "In Partition a Keep Inside shape is null" );
+ THROW_SALOME_CORBA_EXCEPTION("In Partition a shape is null", SALOME::BAD_PARAM);
+ }
+ if (!ToolsMap.Contains( Shape ) &&
+ ShapesMap.Add( Shape ))
+ PS.AddShape(Shape);
+ }
+
+ // add shapes that are in ListRemoveInside, as object shapes;
+ for (ind = 0; ind < ListRemoveInside.length(); ind++) {
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListRemoveInside[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ if(Shape.IsNull() ) {
+ //MESSAGE ( "In Partition a Remove Inside shape is null" );
+ THROW_SALOME_CORBA_EXCEPTION("In Partition a shape is null", SALOME::BAD_PARAM);
+ }
+ if (!ToolsMap.Contains( Shape ) &&
+ ShapesMap.Add( Shape ) )
+ PS.AddShape(Shape);
+ }
+
+ PS.Compute ((TopAbs_ShapeEnum) Limit);
+
+ // suppress result outside of shapes in KInsideMap
+ for (ind = 0; ind < ListKeepInside.length(); ind++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListKeepInside[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ PS.KeepShapesInside( Shape );
+ }
+
+ // suppress result inside of shapes in RInsideMap
+ for (ind = 0; ind < ListRemoveInside.length(); ind++) {
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListRemoveInside[ind] );
+ TopoDS_Shape Shape = GetTopoShape(aShape);
+ PS.RemoveShapesInside( Shape );
+ }
+
+ tds = PS.Shape();
+
+ if( !BRepAlgoAPI::IsValid(tds) ) {
+ //MESSAGE ( "In Partition: non valid shape result" );
+ THROW_SALOME_CORBA_EXCEPTION("Partition aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+ }
+ catch (Standard_Failure) {
+ //MESSAGE ( "In Partition: Exception catched in GEOM_Gen_i::Partition()" );
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::Partition", SALOME::BAD_PARAM);
+ }
+
+ aResult = CreateObject(tds) ;
+
+ /* add attributs S and mystr in a new label */
+ GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
+ TDF_Label Lab = GC.AddShape(tds, aResult->Name() );
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(Lab,entry);
+ aResult->ShapeId( entry.ToCString() ) ;
+
+ // add arguments
+
+ /* Create a new label */
+ TDF_Label NewLab = Lab.NewChild();
+ TCollection_ExtendedString Value("Arguments");
+ TDataStd_Name::Set(NewLab,Value);
+
+ // object shapes
+ for (unsigned int ind = 0; ind < ListShapes.length(); ind++) {
+ TDF_Label NewLab1 = NewLab.NewChild();
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[ind] );
+ Standard_CString anEntry = aShape->ShapeId();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), anEntry, RefLab);
+ TDF_Reference::Set(NewLab1,RefLab);
+ }
+ // tool shapes
+ for (unsigned int ind = 0; ind < ListTools.length(); ind++) {
+ TDF_Label NewLab1 = NewLab.NewChild();
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListTools[ind] );
+ Standard_CString anEntry = aShape->ShapeId();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), anEntry, RefLab);
+ TDF_Reference::Set(NewLab1,RefLab);
+ }
+ // limit shapes 1
+ for (unsigned int ind = 0; ind < ListKeepInside.length(); ind++) {
+ TDF_Label NewLab1 = NewLab.NewChild();
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListKeepInside[ind] );
+ Standard_CString anEntry = aShape->ShapeId();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), anEntry, RefLab);
+ TDF_Reference::Set(NewLab1,RefLab);
+ }
+ // limit shapes 2
+ for (unsigned int ind = 0; ind < ListRemoveInside.length(); ind++) {
+ TDF_Label NewLab1 = NewLab.NewChild();
+
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListRemoveInside[ind] );
+ Standard_CString anEntry = aShape->ShapeId();
+ TDF_Label RefLab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), anEntry, RefLab);
+ TDF_Reference::Set(NewLab1,RefLab);
+ }
+
+ return aResult;
+}
+
+
+
+//==================================================================================
+// function : MakeFilling()
+// purpose : Create a surface from section curves filling
+//==================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFilling(GEOM::GEOM_Shape_ptr myShape,
+ CORBA::Short mindeg,
+ CORBA::Short maxdeg,
+ CORBA::Double tol3d,
+ CORBA::Double tol2d,
+ CORBA::Short nbiter)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Face tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeFilling aborted : null shape or not a compound", SALOME::BAD_PARAM);
+ }
+
+ try {
+ /* we verify the contents of the shape */
+ TopExp_Explorer Ex ;
+ TopoDS_Shape Scurrent ;
+ Standard_Real First, Last ;
+ Handle(Geom_Curve) C ;
+ GeomFill_SectionGenerator Section ;
+
+ Standard_Integer i = 0 ;
+ for(Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) {
+ Scurrent = Ex.Current() ;
+ if( Scurrent.IsNull() || Scurrent.ShapeType() != TopAbs_EDGE) {
+ THROW_SALOME_CORBA_EXCEPTION("Initial shape doesn't contain only edges !", SALOME::BAD_PARAM);
+ }
+ C = BRep_Tool::Curve(TopoDS::Edge(Scurrent), First, Last);
+ C = new Geom_TrimmedCurve(C, First, Last);
+ Section.AddCurve(C) ;
+ i++ ;
+ }
+
+ /* a 'tolerance' is used to compare 2 knots : see GeomFill_Generator.cdl */
+ /* We set 'tolerance' = tol3d */
+ // Section.Perform( tol3d ) ; NRI */
+ Section.Perform( Precision::Confusion() ) ;
+ Handle(GeomFill_Line) Line = new GeomFill_Line(i) ;
+
+ GeomFill_AppSurf App(mindeg, maxdeg, tol3d, tol2d, nbiter) ; /* user parameters */
+ App.Perform(Line, Section) ;
+
+ if (!App.IsDone()) {
+ THROW_SALOME_CORBA_EXCEPTION("Filling aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+ Standard_Integer UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots;
+ App.SurfShape(UDegree, VDegree, NbUPoles, NbVPoles, NbUKnots, NbVKnots);
+ Handle(Geom_BSplineSurface) GBS = new Geom_BSplineSurface(App.SurfPoles(),
+ App.SurfWeights(),
+ App.SurfUKnots(),
+ App.SurfVKnots(),
+ App.SurfUMults(),
+ App.SurfVMults(),
+ App.UDegree(),
+ App.VDegree());
+
+ if( GBS.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Filling aborted", SALOME::BAD_PARAM);
+ }
+ tds = BRepBuilderAPI_MakeFace(GBS) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFilling", SALOME::BAD_PARAM);
+ }
+
+ /* We test the validity of resulting shape */
+ if( !BRepAlgoAPI::IsValid(tds) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Filling aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ }
+
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeGlueFaces()
+// purpose :
+//=================================================================================
+
+TopoDS_Face GEOM_Gen_i::FindSameFace(const TopoDS_Shape& aShape,
+ const TopoDS_Face& F,
+ double tol3d)
+{
+ TopoDS_Face aFace;
+ bool isSame = false;
+ for (TopExp_Explorer exf(aShape,TopAbs_FACE); exf.More(); exf.Next())
+ {
+ //MESSAGE("--- test a face");
+ int nbFound = 0;
+ aFace = TopoDS::Face(exf.Current());
+ TopTools_ListOfShape liste1;
+ TopTools_ListOfShape liste2;
+ for (TopExp_Explorer exp(aFace,TopAbs_VERTEX); exp.More(); exp.Next())
+ {
+ const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current());
+ liste1.Append(V);
+ }
+ for (TopExp_Explorer exp(F,TopAbs_VERTEX); exp.More(); exp.Next())
+ {
+ const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current());
+ liste2.Append(V);
+ }
+ isSame = false;
+ if (liste1.Extent() == liste2.Extent())
+ {
+ TopTools_ListIteratorOfListOfShape it1(liste1);
+ isSame = true;
+ for (; it1.More(); it1.Next())
+ {
+ bool foundSamePoint = false;
+ gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(it1.Value()));
+ TopTools_ListIteratorOfListOfShape it2(liste2);
+ for (it2; it2.More(); it2.Next())
+ {
+ gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(it2.Value()));
+ double d = P1.Distance(P2);
+ if (d < tol3d)
+ {
+ nbFound++;
+ //MESSAGE(" found Same Point : "<<nbFound<<" - "<<P1.X()<<" "<<P1.Y()<<" "<<P1.Z());
+ foundSamePoint = true;
+ break;
+ }
+ }
+ isSame = isSame && foundSamePoint;
+ if (! isSame) break; // a vertex does not correspond : not same face
+ }
+ }
+ if (isSame)
+ {
+ //MESSAGE(" --- Found Same Face");
+ break; // a face corresponding to F is found
+ }
+ }
+ if (! isSame) aFace.Nullify(); // return null face
+ return aFace;
+}
+
+TopoDS_Edge GEOM_Gen_i::FindSameEdge(const TopoDS_Face& nf,
+ TopoDS_Edge& Eold,
+ double tol3d)
+{
+ TopoDS_Face newFace = TopoDS::Face(nf.Oriented(TopAbs_REVERSED));
+ TopoDS_Vertex VFirst, VLast;
+ TopExp::Vertices(Eold, VFirst, VLast);
+ gp_Pnt Pf = BRep_Tool::Pnt(VFirst);
+ gp_Pnt Pl = BRep_Tool::Pnt(VLast);
+ TopoDS_Edge Enew;
+ for (TopExp_Explorer ee(newFace,TopAbs_EDGE); ee.More(); ee.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(ee.Current());
+ TopoDS_Vertex VFn, VLn;
+ TopExp::Vertices(E, VFn, VLn);
+ gp_Pnt Pfn = BRep_Tool::Pnt(VFn);
+ gp_Pnt Pln = BRep_Tool::Pnt(VLn);
+ double dff = Pf.Distance(Pfn);
+ double dfl = Pf.Distance(Pln);
+ double dlf = Pl.Distance(Pfn);
+ double dll = Pl.Distance(Pln);
+ if ((dff < tol3d) && (dll <tol3d))
+ {
+ //MESSAGE("--- edge forward " <<Pf.X()<<" "<<Pf.Y()<<" "<<Pf.Z()<<" "<<Pl.X()<<" "<<Pl.Y()<<" "<<Pl.Z());
+ Enew = TopoDS::Edge(E.Oriented(TopAbs_FORWARD));
+ Eold = TopoDS::Edge(Eold.Oriented(TopAbs_FORWARD));
+ break;
+ }
+ if ((dfl < tol3d) && (dlf <tol3d))
+ {
+ //MESSAGE("--- edge reversed " <<Pf.X()<<" "<<Pf.Y()<<" "<<Pf.Z()<<" "<<Pl.X()<<" "<<Pl.Y()<<" "<<Pl.Z());
+ Enew = TopoDS::Edge(E.Oriented(TopAbs_REVERSED));
+ Eold = TopoDS::Edge(Eold.Oriented(TopAbs_FORWARD));
+ break;
+ }
+ }
+ return Enew;
+}
+
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeGlueFaces(GEOM::GEOM_Shape_ptr myShape,
+ double tol3d)
+ throw (SALOME::SALOME_Exception)
+{
+
+ // prendre un premier shell dans la liste des shells
+ // initialiser un compshell avec ce shell
+ // tant qu'il reste des shells dans la liste
+ // chercher un shell qui a des faces en commun avec le compshell
+ // creer un BRepTools_Quilt
+ // recenser les faces communes issues du compshell, les ajouter au quilt
+ // recenser les faces restantes du shell a inclure, les ajouter au quilt
+ // recenser les edges en double, a remplacer
+ // pour chaque paire d'edge
+ // tester l'orientation relative des aretes
+ // bind dans le quilt de Eold.Forward et Enew.Forward (ou reverse)
+ // recuperer le nouveau shell
+ // l'incorporer dans le compshell
+ // appliquer BRepTools_SameParameter au compshell
+ // (rendre parametres 2D des edges identiques aux parametres 3D)
+
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ TopoDS_Compound C;
+ BRep_Builder bu;
+ bu.MakeCompound(C); // empty compound;
+ TopTools_ListOfShape shellList;
+ for (TopExp_Explorer exp(aShape,TopAbs_SHELL); exp.More(); exp.Next())
+ {
+ const TopoDS_Shell& S = TopoDS::Shell(exp.Current());
+ shellList.Append(S);
+ }
+ TopTools_ListIteratorOfListOfShape its(shellList);
+ if ( ! its.More())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("glue aborted : no shell in shape", SALOME::BAD_PARAM);
+ }
+ TopoDS_Shell S = TopoDS::Shell(its.Value());
+ bu.Add(C, S); // add first shell to compound
+ shellList.Remove(its);
+ its.Initialize(shellList);
+ bool shellAdded = true;
+ while ((shellList.Extent() > 0) && shellAdded)
+ {
+ //MESSAGE("more shells : "<< shellList.Extent());
+ shellAdded = false;
+ its.Initialize(shellList);
+ for(; its.More(); its.Next())
+ {
+ //MESSAGE("one more shell to try");
+ TopTools_ListOfShape newFaces; // common faces from new compound
+ TopTools_ListOfShape oldFaces; // common faces from shell to add
+ TopTools_ListOfShape addFaces; // not common faces from shell to add
+ TopTools_ListOfShape newEdges; // common edges from new compound
+ TopTools_ListOfShape oldEdges; // common edges from face to add
+ TopoDS_Compound CFN;
+ TopoDS_Compound CFO;
+ bu.MakeCompound(CFN); // empty compound for new faces
+ bu.MakeCompound(CFO); // empty compound for old faces
+ S = TopoDS::Shell(its.Value());
+ for (TopExp_Explorer exp(S,TopAbs_FACE); exp.More(); exp.Next())
+ {
+ //MESSAGE("--- try to find corresponding face in new compound");
+ TopoDS_Face F = TopoDS::Face(exp.Current());
+ TopoDS_Face newFace = FindSameFace(C,F,tol3d);
+ if (! newFace.IsNull())
+ {
+ //MESSAGE("--- face found");
+ newFaces.Append(newFace);
+ bu.Add(CFN, newFace); // common faces from new compound
+ oldFaces.Append(F);
+ for (TopExp_Explorer ee(F,TopAbs_EDGE);ee.More();ee.Next())
+ {
+ //MESSAGE("--- find edge pair");
+ TopoDS_Edge Eold = TopoDS::Edge(ee.Current());
+ const TopoDS_Edge& Enew = FindSameEdge(newFace, Eold, tol3d);
+ oldEdges.Append(Eold);
+ newEdges.Append(Enew);
+ }
+ }
+ else
+ {
+ //MESSAGE("---");
+ addFaces.Append(F);
+ bu.Add(CFO, F); // not common faces from shell to add
+ }
+ }
+ if ( !newFaces.IsEmpty())
+ {
+ //MESSAGE("--- some faces found ---");
+ shellAdded = true;
+ BRepTools_Quilt glue;
+ glue.Add(CFN);
+ TopTools_ListIteratorOfListOfShape ito(oldEdges);
+ TopTools_ListIteratorOfListOfShape itn(newEdges);
+ for (; ito.More(); ito.Next())
+ {
+ //MESSAGE("--- bind");
+ glue.Bind(TopoDS::Edge(ito.Value()), TopoDS::Edge(itn.Value()));
+ itn.Next();
+ }
+ glue.Add(CFO);
+ TopoDS_Compound newc = TopoDS::Compound(glue.Shells());
+ for (TopExp_Explorer exs(newc,TopAbs_SHELL); exs.More(); exs.Next())
+ {
+ TopoDS_Shell NS = TopoDS::Shell(exs.Current());
+ bu.Add(C, NS);
+ }
+ shellList.Remove(its);
+ //MESSAGE("--- remove shell from list");
+ break;
+ }
+ }
+ }
+ //MESSAGE("---" << shellList.Extent() << " " << shellAdded);
+
+ TopExp_Explorer exp(C,TopAbs_SHELL);
+ Standard_Integer ish=0;
+ TopoDS_Compound Res;
+ TopoDS_Solid Sol;
+ BRep_Builder B;
+ B.MakeCompound(Res);
+ TopoDS_Shape theShape;
+
+ for (; exp.More(); exp.Next())
+ {
+ TopoDS_Shape Sh = exp.Current();
+ B.MakeSolid(Sol);
+ B.Add(Sol,Sh);
+ BRepClass3d_SolidClassifier SC(Sol);
+ SC.PerformInfinitePoint(1.E-6); // cf. BRepFill_Confusion() - BRepFill_Evolved.cxx
+ if (SC.State() == TopAbs_IN)
+ {
+ B.MakeSolid(Sol);
+ B.Add(Sol,Sh.Reversed());
+ }
+ B.Add(Res,Sol);
+ ish++;
+ }
+ if (ish == 1) { theShape = Sol;}
+ else { theShape = Res;}
+
+ BRepLib::SameParameter(theShape, 1.E-5, Standard_True);
+ tds = theShape;
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ //MESSAGE("---");
+ return result;
+}
+
+//=================================================================================
+// function : MakeSewing()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSewing( const GEOM::GEOM_Gen::ListOfIOR& ListShapes,
+ CORBA::Double precision )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ BRepOffsetAPI_Sewing aMethod ;
+
+ try {
+ /* default OCC is 1.0e-06 */
+ aMethod.Init(precision, Standard_False);
+ for ( unsigned int i = 0; i < ListShapes.length(); i++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[i] );
+ TopoDS_Shape Shape = GetTopoShape(aShape) ;
+ if( Shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeSewing aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ aMethod.Add(Shape) ;
+ }
+
+ aMethod.Perform() ;
+ tds = aMethod.SewedShape() ;
+ if( !BRepAlgoAPI::IsValid(tds) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Sewing aborted : non valid shape", SALOME::BAD_PARAM);
+ }
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Sewing aborted : null shape", SALOME::BAD_PARAM);
+ }
+ }
+ catch (Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeSewing", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds);
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ;
+ return result;
+}
+
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSewingShape( GEOM::GEOM_Shape_ptr aShape,
+ CORBA::Double precision )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds, S ;
+ BRepOffsetAPI_Sewing aMethod ;
+
+ try {
+ S = GetTopoShape(aShape) ;
+ if(S.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("In Sewing a Shape is null", SALOME::BAD_PARAM);
+ }
+
+ /* default OCC is 1.0e-06 */
+ aMethod.Init(precision, Standard_False);
+ for ( TopExp_Explorer exp( S, TopAbs_FACE); exp.More(); exp.Next() ) {
+ const TopoDS_Face& F = TopoDS::Face(exp.Current());
+ aMethod.Add(F) ;
+ }
+
+ aMethod.Perform() ;
+ tds = aMethod.SewedShape() ;
+ if( !BRepAlgoAPI::IsValid(tds) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Sewing aborted : non valid shape", SALOME::BAD_PARAM);
+ }
+ }
+ catch (Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeSewing", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry) ;
+ return result;
+}
+
+//==================================================================================
+// function : OrientationChange()
+// purpose : Change the orientation of a new shape
+// : TopAbs_FORWARD < -- > TopAbs_REVERSED
+//
+// : WARNING : for the moment we make a new shape !
+//==================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::OrientationChange(GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ BRep_Builder aBuilder;
+
+ TopoDS_Shape shape = GetTopoShape(aShape) ;
+ if( shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepBuilderAPI_Copy Copy(shape);
+ if( Copy.IsDone() ) {
+ TopoDS_Shape tds = Copy.Shape();
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Orientation aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ if( tds.Orientation() == TopAbs_FORWARD)
+ tds.Orientation(TopAbs_REVERSED) ;
+ else
+ tds.Orientation(TopAbs_FORWARD) ;
+
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(shape, aShape, tds, result, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//==================================================================================
+// function : GetReferencedObjects()
+// purpose :
+//==================================================================================
+GEOM::GEOM_Gen::ListOfIOR* GEOM_Gen_i::GetReferencedObjects(GEOM::GEOM_Shape_ptr shape)
+{
+ GEOM::GEOM_Gen::ListOfIOR_var aList = new GEOM::GEOM_Gen::ListOfIOR;
+ aList->length(0);
+
+ if (shape->_is_nil()) return aList._retn();
+
+ Standard_CString entry = shape->ShapeId();
+ TDF_Label Lab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), entry, Lab);
+
+ Handle(TDataStd_Name) Att;
+ Lab.FindAttribute(TDataStd_Name::GetID(),Att);
+
+ TDF_ChildIterator ChildIterator(Lab);
+ if (ChildIterator.More()) {
+ TDF_Label L = ChildIterator.Value();
+ Handle(TDataStd_Name) Att;
+ L.FindAttribute(TDataStd_Name::GetID(),Att);
+ if (Att->Get().IsEqual(TCollection_ExtendedString("Arguments")) ) {
+
+ TDF_ChildIterator ChildIterator1(L);
+ unsigned int i = 0;
+
+ while (ChildIterator1.More()) {
+ TDF_Label L = ChildIterator1.Value();
+
+ Handle(TDF_Reference) Ref;
+ if (L.FindAttribute(TDF_Reference::GetID(),Ref)) {
+ i++;
+ }
+ ChildIterator1.Next();
+ }
+ aList->length(i);
+ i = 0;
+ TDF_ChildIterator ChildIterator2(L);
+ while (ChildIterator2.More()) {
+ TDF_Label L = ChildIterator2.Value();
+ Handle(TDF_Reference) Ref;
+ if (L.FindAttribute(TDF_Reference::GetID(),Ref)) {
+ TDF_Label L = Ref->Get();
+
+ Handle(TDataStd_Name) Att;
+ L.FindAttribute(TDataStd_Name::GetID(),Att);
+ TCollection_AsciiString nameIOR (Att->Get()) ;
+ aList[i] = strdup( nameIOR.ToCString() );
+ i++;
+ }
+
+ ChildIterator2.Next();
+ }
+ }
+ }
+ return aList._retn();
+}
+
+//==================================================================================
+// function : GetObjects()
+// purpose :
+//==================================================================================
+GEOM::GEOM_Gen::ListOfIOR* GEOM_Gen_i::GetObjects(GEOM::GEOM_Shape_ptr shape)
+{
+ GEOM::GEOM_Gen::ListOfIOR_var aList = new GEOM::GEOM_Gen::ListOfIOR;
+ aList->length(0);
+
+ Standard_CString entry = shape->ShapeId();
+ TDF_Label Lab;
+ TDF_Tool::Label(myCurrentOCAFDoc->GetData(), entry, Lab);
+
+ Handle(TDataStd_Name) Att;
+ Lab.FindAttribute(TDataStd_Name::GetID(),Att);
+
+ TDF_ChildIterator ChildIterator(Lab);
+ unsigned int i = 0;
+ while (ChildIterator.More()) {
+ TDF_Label L = ChildIterator.Value();
+ Handle(TDataStd_Name) Att;
+ L.FindAttribute(TDataStd_Name::GetID(),Att);
+
+ if (!Att->Get().IsEqual(TCollection_ExtendedString("Arguments")) ) {
+ i++;
+ }
+ ChildIterator.Next();
+ }
+
+ aList->length(i);
+ i = 0;
+ TDF_ChildIterator ChildIterator1(Lab);
+ while (ChildIterator1.More()) {
+ TDF_Label L = ChildIterator1.Value();
+ Handle(TDataStd_Name) Att;
+ L.FindAttribute(TDataStd_Name::GetID(),Att);
+
+ if (!Att->Get().IsEqual(TCollection_ExtendedString("Arguments")) ) {
+ TCollection_AsciiString nameIOR (Att->Get());
+ aList[i] = strdup( nameIOR.ToCString() );
+ i++;
+ }
+ ChildIterator1.Next();
+ }
+ return aList._retn();
+}
+
+
+//==================================================================================
+// function : Import
+// purpose : Import shape from a BREP file
+//==================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportBREP(const char* filename)
+ throw (SALOME::SALOME_Exception)
+{
+ TopoDS_Shape tds ;
+ GEOM::GEOM_Shape_var result ;
+
+ try {
+ BRep_Builder aBuilder;
+ BRepTools::Read(tds, strdup(filename), aBuilder) ;
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Import BRep aborted", SALOME::BAD_PARAM);
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ImportBREP", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result;
+}
+
+
+//================================================================================
+// function : MakePlane()
+// purpose : Make a plane topology (non infinite)
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakePlane(const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct,
+ CORBA::Double trimsize)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+
+ try {
+ gp_Pnt aPoint(pstruct.x, pstruct.y, pstruct.z) ;
+ gp_Dir aDirection(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ /* we make a trimmed plane */
+ gp_Pln gplane(aPoint, aDirection) ;
+ tds = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakePlane", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Plane aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+//=================================================================================
+// function : MakeVertex()
+// purpose : Create a Vertex topology.
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeVertex(CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+
+ GEOM::GEOM_Shape_var result ;
+ gp_Pnt P(x,y,z);
+ TopoDS_Shape tds = BRepBuilderAPI_MakeVertex(P).Shape();
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Vertex/Point aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeFace()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFace( GEOM::GEOM_Shape_ptr wire,
+ CORBA::Boolean wantplanarface )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape aShape;
+ TopoDS_Shape tds;
+
+ try {
+ aShape = GetTopoShape(wire) ;
+ if( aShape.IsNull() || aShape.ShapeType() != TopAbs_WIRE ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeFace aborted : null or inappropriate shape", SALOME::BAD_PARAM);
+ }
+ TopoDS_Wire W = TopoDS::Wire(aShape) ;
+ tds = BRepBuilderAPI_MakeFace(W, wantplanarface).Shape() ;
+ if( !tds.IsNull() ) {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, wire, tds, result, myCurrentOCAFDoc) ;
+ }
+ else {
+ THROW_SALOME_CORBA_EXCEPTION("Null result in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM);
+ }
+ }
+ catch (Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM);
+ }
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeLine
+// purpose : Make a Line topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeLine(const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ gp_Pnt P1(pstruct.x, pstruct.y, pstruct.z);
+ gp_Pnt P2(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ TopoDS_Shape tds ;
+
+ try {
+ tds = BRepBuilderAPI_MakeEdge(P1, P2).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeLine", SALOME::BAD_PARAM);
+ }
+
+ if ( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Line aborted : null shape", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ }
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeVector()
+// purpose : Make a vector
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeVector(const GEOM::PointStruct& pstruct1,
+ const GEOM::PointStruct& pstruct2)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+
+ try {
+ gp_Pnt P1(pstruct1.x, pstruct1.y, pstruct1.z);
+ gp_Pnt P2(pstruct2.x, pstruct2.y, pstruct2.z) ;
+ tds = BRepBuilderAPI_MakeEdge(P1, P2).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeVector", SALOME::BAD_PARAM);
+ }
+
+ if ( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Vector aborted : null shape", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ }
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeCircle()
+// purpose :
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCircle(const GEOM::PointStruct& pstruct,
+ const GEOM::DirStruct& dstruct,
+ CORBA::Double radius)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+
+ try {
+ gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
+ gp_Dir d(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
+ gp_Ax2 axis(p, d) ;
+ gp_Circ circ( axis, radius);
+ BRepBuilderAPI_MakeEdge MakeEdge( circ );
+ tds = MakeEdge.Edge();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeCircle", SALOME::BAD_PARAM);
+ }
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Circle aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+//================================================================================
+// function : MakeArc()
+// purpose : make an arc of circle from pInit to pEnd and passing on pCircle
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeArc(const GEOM::PointStruct& pInit,
+ const GEOM::PointStruct& pCircle,
+ const GEOM::PointStruct& pEnd)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ try {
+ gp_Pnt pI(pInit.x, pInit.y, pInit.z) ;
+ gp_Pnt pC(pCircle.x, pCircle.y, pCircle.z) ;
+ gp_Pnt pE(pEnd.x, pEnd.y, pEnd.z) ;
+
+ GC_MakeArcOfCircle arc( pI, pC, pE ) ;
+ if( !arc.IsDone() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Arc not done", SALOME::BAD_PARAM);
+ }
+ BRepBuilderAPI_MakeEdge MakeEdge( arc );
+ TopoDS_Shape tds = MakeEdge.Edge();
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Null result : arc not done", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeArc", SALOME::BAD_PARAM);
+ }
+ return result ;
+}
+
+
+
+//=================================================================================
+// function : MakeTranslation()
+// purpose : Translate a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeTranslation( GEOM::GEOM_Shape_ptr myShape,
+ CORBA::Double x,
+ CORBA::Double y,
+ CORBA::Double z)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Translation aborted : null shape", SALOME::BAD_PARAM);
+ }
+ gp_Vec theVector(x,y,z) ;
+ gp_Trsf theTransformation ;
+ theTransformation.SetTranslation(theVector) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ TopoDS_Shape tds = myBRepTransformation.Shape() ;
+
+ result = CreateObject(tds) ;
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("Translation aborted : null result", SALOME::BAD_PARAM);
+ }
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeMultiTranslation1D()
+// purpose : Multi-Translate a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeMultiTranslation1D( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::DirStruct& dir,
+ CORBA::Double step,
+ CORBA::Short nbtimes )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() )
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiTranslation1D aborted : null shape", SALOME::BAD_PARAM);
+
+ try {
+ int i ;
+ double DX, DY, DZ ;
+ gp_Trsf theTransformation ;
+ gp_Vec myVec ;
+ gp_Vec Vec( dir.PS.x, dir.PS.y, dir.PS.z ) ;
+ Vec.Normalize();
+ TopoDS_Compound compound;
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ for ( i = 0; i < nbtimes; i++ ) {
+ DX = i * step * Vec.X() ;
+ DY = i * step * Vec.Y() ;
+ DZ = i * step * Vec.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+ theTransformation.SetTranslation(myVec) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ tds = compound ;
+ result = CreateObject(tds) ;
+ }
+ catch (Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeMultiTranslation1D", SALOME::BAD_PARAM);
+ }
+
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiTranslation1D aborted : null result", SALOME::BAD_PARAM);
+ }
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeMultiTranslation2D()
+// purpose : Multi-Translate a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeMultiTranslation2D( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::DirStruct& dir1,
+ CORBA::Double step1,
+ CORBA::Short nbtimes1,
+ const GEOM::DirStruct& dir2,
+ CORBA::Double step2,
+ CORBA::Short nbtimes2 )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiTranslation2D aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ try {
+ int i, j ;
+ double DX, DY, DZ ;
+ gp_Trsf theTransformation ;
+ gp_Vec myVec ;
+ gp_Vec Vec1( dir1.PS.x, dir1.PS.y, dir1.PS.z ) ;
+ Vec1.Normalize();
+ gp_Vec Vec2( dir2.PS.x, dir2.PS.y, dir2.PS.z ) ;
+ Vec2.Normalize();
+ TopoDS_Compound compound;
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ for ( i = 0; i < nbtimes1; i++ ) {
+ for ( j = 0; j < nbtimes2; j++ ) {
+ DX = i * step1 * Vec1.X() + j * step2 * Vec2.X() ;
+ DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y() ;
+ DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+ theTransformation.SetTranslation(myVec) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ }
+ tds = compound ;
+ result = CreateObject(tds) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeMultiTranslation2D", SALOME::BAD_PARAM);
+ }
+
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiTranslation2D aborted : null result", SALOME::BAD_PARAM);
+ }
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeMultiRotation1D()
+// purpose : Multi-Rotate a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeMultiRotation1D( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::DirStruct& dir,
+ const GEOM::PointStruct& loc,
+ CORBA::Short nbtimes)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiRotation1D aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ try {
+
+ int i ;
+ gp_Pnt P(loc.x, loc.y, loc.z) ;
+ gp_Dir D(dir.PS.x, dir.PS.y, dir.PS.z) ;
+ gp_Ax1 AX1(P, D) ;
+
+ double angle = 360.0/nbtimes ;
+ gp_Trsf theTransformation ;
+ TopoDS_Compound compound;
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ for ( i = 0; i < nbtimes; i++ ) {
+ theTransformation.SetRotation(AX1, i*angle*PI180) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ tds = compound ;
+ result = CreateObject(tds) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeMultiRotation1D", SALOME::BAD_PARAM);
+ }
+
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiRotation1D aborted : null result", SALOME::BAD_PARAM);
+ }
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeMultiRotation2D()
+// purpose : Multi-Rotate a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeMultiRotation2D( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::DirStruct& dir,
+ const GEOM::PointStruct& loc,
+ CORBA::Double ang,
+ CORBA::Short nbtimes1,
+ CORBA::Double step,
+ CORBA::Short nbtimes2 )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiRotation2D aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ try {
+
+ int i, j ;
+ double DX, DY, DZ ;
+ gp_Pnt P(loc.x, loc.y, loc.z) ;
+ gp_Dir D(dir.PS.x, dir.PS.y, dir.PS.z) ;
+ gp_Ax1 AX1(P, D) ;
+ gp_Trsf theTransformation1 ;
+ gp_Trsf theTransformation2 ;
+ gp_Pnt P1 ;
+ GProp_GProps System ;
+
+ if ( aShape.ShapeType() == TopAbs_VERTEX) {
+ P1 = BRep_Tool::Pnt(TopoDS::Vertex( aShape ));
+ }
+ else if ( aShape.ShapeType() == TopAbs_EDGE || aShape.ShapeType() == TopAbs_WIRE ) {
+ BRepGProp::LinearProperties(aShape, System);
+ P1 = System.CentreOfMass() ;
+ }
+ else if ( aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL ) {
+ BRepGProp::SurfaceProperties(aShape, System);
+ P1 = System.CentreOfMass() ;
+ }
+ else {
+ BRepGProp::VolumeProperties(aShape, System);
+ P1 = System.CentreOfMass() ;
+ }
+
+ Handle(Geom_Line) Line = new Geom_Line(AX1);
+ gp_Pnt P2 = GeomAPI_ProjectPointOnCurve( P1, Line ) ;
+
+ if ( P1.IsEqual(P2, Precision::Confusion() ) )
+ THROW_SALOME_CORBA_EXCEPTION("Points are confused", SALOME::BAD_PARAM);
+
+ gp_Vec Vec(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z()) ;
+ Vec.Normalize();
+
+ gp_Vec myVec ;
+ TopoDS_Compound compound;
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ for ( i = 0; i < nbtimes2; i++ ) {
+ for ( j = 0; j < nbtimes1; j++ ) {
+ DX = i * step * Vec.X() ;
+ DY = i * step * Vec.Y() ;
+ DZ = i * step * Vec.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+ theTransformation1.SetTranslation(myVec) ;
+ theTransformation2.SetRotation(AX1, j*ang*PI180) ;
+ BRepBuilderAPI_Transform myBRepTransformation1(aShape, theTransformation1, Standard_False) ;
+ BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ;
+ B.Add( compound, myBRepTransformation2.Shape() );
+ }
+ }
+ tds = compound ;
+ result = CreateObject(tds) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeMultiRotation2D", SALOME::BAD_PARAM);
+ }
+
+ if( CORBA::is_nil(result) ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeMultiRotation2D aborted : null result", SALOME::BAD_PARAM);
+ }
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeCopy()
+// purpose : Copy a 3D shape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCopy( GEOM::GEOM_Shape_ptr Shape)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(Shape) ;
+ if(aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Copy aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ BRepBuilderAPI_Copy Copy(aShape);
+ if( Copy.IsDone() ) {
+ tds = Copy.Shape();
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, Shape, tds, result, myCurrentOCAFDoc) ;
+ }
+
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeMirrorByPlane()
+// purpose : build a shape by symmetry of 'myShape' with 'shapePlane' in argument
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeMirrorByPlane(GEOM::GEOM_Shape_ptr myShape,
+ GEOM::GEOM_Shape_ptr shapePlane)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ TopoDS_Shape aShapePlane = GetTopoShape(shapePlane) ;
+ if( aShape.IsNull() || aShapePlane.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Mirror aborted : null shape argument", SALOME::BAD_PARAM);
+ }
+
+ try {
+ Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(aShapePlane)) ;
+ Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf) ;
+ const gp_Ax3 pos = myPlane->Position() ;
+ const gp_Pnt loc = pos.Location() ; /* location of the plane */
+ const gp_Dir dir = pos.Direction() ; /* Main direction of the plane (Z axis) */
+
+ /* plane used for mirroring */
+ gp_Ax2 pln(loc, dir) ;
+ gp_Trsf theTransformation ;
+ theTransformation.SetMirror(pln) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+
+ tds = myBRepTransformation.Shape() ;
+ if(tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Mirror aborted", SALOME::BAD_PARAM);
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeMirrorByPlane", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds) ;
+
+ /* Insert arguments in ocaf */
+ GEOM::GEOM_Gen::ListOfIOR_var ListShapes = new GEOM::GEOM_Gen::ListOfIOR;
+ ListShapes->length(2);
+ ListShapes[0] = GetStringFromIOR(GEOM::GEOM_Shape::_duplicate(myShape)) ;
+ ListShapes[1] = GetStringFromIOR(GEOM::GEOM_Shape::_duplicate(shapePlane)) ;
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ;
+ return result ;
+}
+
+
+
+//=================================================================================
+// function : MakeRotation()
+// purpose : Rotation of a 3D shape around an axis
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeRotation( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::AxisStruct& axis,
+ CORBA::Double angle)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Rotation aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+
+ try {
+ gp_Pnt P(axis.x, axis.y, axis.z) ;
+ gp_Dir D(axis.vx, axis.vy, axis.vz) ;
+ gp_Ax1 AX(P, D) ;
+
+ gp_Trsf theTransformation ;
+ theTransformation.SetRotation(AX, angle) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ tds = myBRepTransformation.Shape() ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeRotation", SALOME::BAD_PARAM);
+ }
+
+ if ( !tds.IsNull() ) {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeScaleTransform()
+// purpose : Make a shape multipling another by a scale factor
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeScaleTransform(GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::PointStruct& theCenterOfScale,
+ CORBA::Double factor)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Scale aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+
+ try {
+ gp_Pnt Pcenter(theCenterOfScale.x, theCenterOfScale.y, theCenterOfScale.z) ;
+ gp_Trsf theTransformation ;
+ theTransformation.SetScale(Pcenter, factor) ;
+ BRepBuilderAPI_Transform myBRepTransformation(aShape, theTransformation, Standard_False) ;
+ tds = myBRepTransformation.Shape() ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeScaleTransform", SALOME::BAD_PARAM);
+ }
+
+ if ( !tds.IsNull() ) {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeCompound()
+// purpose : Make a compound from a list containing one or more shapes
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCompound( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Compound C;
+ BRep_Builder aBuilder;
+ aBuilder.MakeCompound(C) ;
+
+ for ( unsigned int i = 0; i < ListShapes.length(); i++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[i] );
+ TopoDS_Shape Shape = GetTopoShape(aShape) ;
+ if( Shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Compound aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ aBuilder.Add(C, Shape) ;
+ }
+
+ if ( C.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Null result : Compound operation aborted", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(C) ;
+ InsertInLabelMoreArguments(C, result, ListShapes, myCurrentOCAFDoc) ;
+ }
+ return result;
+}
+
+
+
+//================================================================================
+// function : MakeEdge()
+// purpose : Make a linear edge with 2 points
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeEdge(const GEOM::PointStruct& pstruct1,
+ const GEOM::PointStruct& pstruct2)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+
+ try {
+ gp_Pnt P1(pstruct1.x, pstruct1.y, pstruct1.z);
+ gp_Pnt P2(pstruct2.x, pstruct2.y, pstruct2.z) ;
+ tds = BRepBuilderAPI_MakeEdge(P1, P2).Shape();
+ if ( tds.IsNull() )
+ THROW_SALOME_CORBA_EXCEPTION("MakeEdge aborted : null result", SALOME::BAD_PARAM);
+ }
+ catch (Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in MakeEdge", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds) ;
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry);
+ return result ;
+}
+
+
+
+//=================================================================================
+// function : MakeWire()
+// purpose : Make a wire from a list containing one or more edges or wires that can
+// be connected
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeWire( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ BRepBuilderAPI_MakeWire MW ;
+ TopoDS_Shape tds, Shape ;
+
+ try {
+ for ( unsigned int i = 0; i < ListShapes.length(); i++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString( ListShapes[i] );
+ Shape = GetTopoShape(aShape) ;
+ if( Shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeWire aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ if( Shape.ShapeType() == TopAbs_EDGE )
+ MW.Add( TopoDS::Edge(Shape) ) ;
+ if (Shape.ShapeType() == TopAbs_WIRE )
+ MW.Add( TopoDS::Wire(Shape) ) ;
+ }
+ tds = MW ;
+
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeWire", SALOME::BAD_PARAM);
+ }
+
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Wire operation aborted : null result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ;
+ }
+ return result;
+}
+
+
+
+//=================================================================================
+// function : MakeRevolution()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeRevolution(GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::AxisStruct& axis,
+ double angle)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Revolution aborted : null shape", SALOME::BAD_PARAM);
+ }
+ try {
+ gp_Pnt P(axis.x, axis.y, axis.z) ;
+ gp_Dir D(axis.vx, axis.vy, axis.vz);
+ gp_Ax1 AX(P,D);
+ tds = BRepPrimAPI_MakeRevol(aShape, AX, angle);
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeRevolution", SALOME::BAD_PARAM);
+ }
+
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Revolution aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakePipe()
+// purpose : Create a shape by sweeping a baseShape along a pathShape
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakePipe( GEOM::GEOM_Shape_ptr pathShape,
+ GEOM::GEOM_Shape_ptr baseShape )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Wire aWire ;
+ TopoDS_Shape pathTds = GetTopoShape(pathShape) ;
+ TopoDS_Shape baseTds = GetTopoShape(baseShape) ;
+
+ if( baseTds.IsNull() || pathTds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakePipe aborted : null shape argument", SALOME::BAD_PARAM);
+ }
+
+ if( pathTds.ShapeType() == TopAbs_WIRE ) {
+ aWire = TopoDS::Wire(pathTds) ;
+ }
+ else {
+ if ( pathTds.ShapeType() == TopAbs_EDGE ) {
+ TopoDS_Edge aEdge = TopoDS::Edge(pathTds) ;
+ aWire = BRepBuilderAPI_MakeWire(aEdge);
+ }
+ else {
+ THROW_SALOME_CORBA_EXCEPTION("MakePipe aborted : bad shape type", SALOME::BAD_PARAM);
+ }
+ }
+
+ try {
+ tds = BRepOffsetAPI_MakePipe(aWire, baseTds) ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakePipe", SALOME::BAD_PARAM);
+ }
+
+ if ( !BRepAlgoAPI::IsValid(tds) ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakePipe aborted : non valid shape result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+
+ /* Insert arguments in ocaf */
+ GEOM::GEOM_Gen::ListOfIOR_var ListShapes = new GEOM::GEOM_Gen::ListOfIOR;
+ ListShapes->length(2);
+ ListShapes[0] = GetStringFromIOR(GEOM::GEOM_Shape::_duplicate(pathShape)) ;
+ ListShapes[1] = GetStringFromIOR(GEOM::GEOM_Shape::_duplicate(baseShape)) ;
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakePrism()
+// purpose : uses myShape as base and the vector P1 to P2
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakePrism( GEOM::GEOM_Shape_ptr myShape,
+ const GEOM::PointStruct& P1,
+ const GEOM::PointStruct& P2 )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(myShape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Prism aborted : null shape operation", SALOME::BAD_PARAM);
+ }
+
+ try {
+ gp_Vec Vector (P2.x - P1.x, P2.y - P1.y, P2.z - P1.z) ;
+ tds = BRepPrimAPI_MakePrism(aShape, Vector, Standard_False).Shape() ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakePipe", SALOME::BAD_PARAM);
+ }
+
+ if ( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Prism aborted", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(aShape, myShape, tds, result, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//=================================================================================
+// function : MakeCDG()
+// purpose : Create a CDG topology.
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCDG(GEOM::GEOM_Shape_ptr aShape)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape shape = GetTopoShape(aShape) ;
+ GProp_GProps System;
+ gp_Pnt myCenterMass ;
+
+ if( shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeCDG aborted : null shape argument", SALOME::BAD_PARAM);
+ }
+
+ try {
+ if ( shape.ShapeType() == TopAbs_VERTEX) {
+ myCenterMass = BRep_Tool::Pnt(TopoDS::Vertex( shape ));
+ }
+ else if ( shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_WIRE ) {
+ BRepGProp::LinearProperties(shape, System);
+ myCenterMass = System.CentreOfMass() ;
+ }
+ else if ( shape.ShapeType() == TopAbs_FACE || shape.ShapeType() == TopAbs_SHELL ) {
+ BRepGProp::SurfaceProperties(shape, System);
+ myCenterMass = System.CentreOfMass() ;
+ }
+ else {
+ BRepGProp::VolumeProperties(shape, System);
+ myCenterMass = System.CentreOfMass() ;
+ }
+
+ tds = BRepBuilderAPI_MakeVertex(myCenterMass).Shape() ;
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeCDG", SALOME::BAD_PARAM);
+ }
+
+ if ( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make CDG aborted : null shape result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ InsertInLabelOneArgument(shape, aShape, tds, result, myCurrentOCAFDoc) ;
+ }
+ return result ;
+}
+
+
+//=================================================================================
+// function : Archimede()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::Archimede(GEOM::GEOM_Shape_ptr aShape,
+ CORBA::Double aWeight,
+ CORBA::Double aWaterDensity,
+ CORBA::Double aMeshingDeflection)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+
+ double cste = -1;
+ if (aWaterDensity != 0.)
+ cste = aWeight/aWaterDensity;
+ else
+ THROW_SALOME_CORBA_EXCEPTION("Water density is null", SALOME::BAD_PARAM);
+
+ TopoDS_Shape shape = GetTopoShape(aShape) ;
+ if( shape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ gp_Dir direct(0.0,0.0,1.0);
+ gp_Pnt PosPlan(0.0,0.0,0.0);
+ Geom_Plane PP (PosPlan,direct);
+ Handle(Geom_Geometry) G = PP.Copy();
+ Handle(Geom_Plane) P = Handle(Geom_Plane)::DownCast(G);
+
+ gp_Dir Zdirection(0.0,0.0,1.0);
+ VolumeSection VOL( shape, aMeshingDeflection);
+ VOL.SetPlane(P);
+ Handle (Geom_RectangularTrimmedSurface) SurfaceTrimmee;
+
+ if(Zdirection.IsEqual(direct,Precision::Angular()) == Standard_False) {
+ VOL.MakeRotation(direct);
+ }
+
+ VOL.CenterOfGravity();
+ SurfaceTrimmee = VOL.TrimSurf();
+ Standard_Real Cote = VOL.Archimede( cste, aMeshingDeflection );
+
+ if ( Cote == -1 ) {
+ double Zmin,Zmax;
+ VOL.getZ(Zmin,Zmax);
+ double volume = VOL.CalculateVolume( Zmax ) * aWaterDensity;
+
+ char msg[100]="";
+ sprintf(msg, "shape sinks to the bottom : Weigth max = %.1f", volume);
+
+ THROW_SALOME_CORBA_EXCEPTION(msg, SALOME::BAD_PARAM);
+ }
+
+ SurfaceTrimmee=VOL.AjustePlan(SurfaceTrimmee,Cote,PosPlan);
+ if(Zdirection.IsEqual(direct,Precision::Angular()) == Standard_False) {
+ SurfaceTrimmee=VOL.InvMakeRotation(direct,SurfaceTrimmee);
+ }
+
+ Standard_Real u1,u2,v1,v2;
+ SurfaceTrimmee->Bounds(u1,u2,v1,v2);
+ TopoDS_Face tirant = BRepBuilderAPI_MakeFace(SurfaceTrimmee, u1, u2, v1, v2);
+
+ if (tirant.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Result is null", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tirant);
+ InsertInLabelOneArgument(shape, aShape, tirant, result, myCurrentOCAFDoc) ;
+
+ return result;
+}
+
+
+//================================================================================
+// function : MakeFillet()
+// purpose : Create a cylinder topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::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_var result;
+ TopoDS_Shape tds ;
+
+ const TopoDS_Shape aShape = GetTopoShape(shape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepFilletAPI_MakeFillet fill(aShape);
+
+ try {
+ /* case all */
+ if(ListOfID.length() == 0) {
+ TopExp_Explorer Exp ( aShape, 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(radius,i);
+ }
+ tds = fill.Shape();
+
+ } else {
+
+ /* case selection */
+ for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) {
+ TopoDS_Shape ss ;
+ if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) {
+ TopoDS_Edge E = TopoDS::Edge(ss) ;
+ fill.Add( E );
+ }
+ }
+ for (int i = 1;i<=fill.NbContours();i++) {
+ fill.SetRadius(radius,i);
+ }
+ tds = fill.Shape();
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFillet", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Fillet aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ;
+
+ return result ;
+}
+
+
+//================================================================================
+// function : MakeChamfer
+// purpose : Create a Chamfer topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::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)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+
+ const TopoDS_Shape aShape = GetTopoShape(shape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepFilletAPI_MakeChamfer MC(aShape);
+
+ try {
+ /* case all */
+ TopTools_IndexedDataMapOfShapeListOfShape M;
+ TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,M);
+ if(ListOfID.length() == 0) {
+ 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(d1,d2,E,F);
+ }
+ tds = MC.Shape();
+
+ } else {
+
+ /* case selection */
+ for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) {
+ TopoDS_Shape ss ;
+ if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) {
+ TopoDS_Edge E = TopoDS::Edge( ss ) ;
+ TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First());
+ if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
+ MC.Add(d1,d2,E,F);
+ }
+ }
+ tds = MC.Shape();
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeChamfer", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Chamfer aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ;
+
+ return result ;
+}
+
+//=================================================================================
+// function : CheckShape()
+// purpose :
+//=================================================================================
+CORBA::Boolean GEOM_Gen_i::CheckShape(GEOM::GEOM_Shape_ptr shape)
+ throw (SALOME::SALOME_Exception)
+{
+ TopoDS_Shape S = GetTopoShape(shape) ;
+ if( S.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepCheck_Analyzer ana(S,false);
+ if (ana.IsValid())
+ return 1;
+
+ return 0;
+}
+
+//=================================================================================
+// function : MakePlacedBox()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::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_var result ;
+ TopoDS_Shape tds ;
+
+ CORBA::Double x2, y2, z2 ;
+
+ try {
+ x2 = x1 + delta1 ;
+ y2 = y1 + delta2 ;
+ z2 = z1 + delta3 ;
+
+ gp_Pnt P1(x1,y1,z1);
+ gp_Pnt P2(x2,y2,z2);
+
+ tds = BRepPrimAPI_MakeBox(P1,P2).Shape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBox", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Box aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry) ;
+
+ return result;
+}
+
+//=================================================================================
+// function : MakePanel()
+// purpose :
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakePanel(GEOM::GEOM_Shape_ptr shape,
+ CORBA::Short directiontype,
+ CORBA::Double delta)
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ TopoDS_Shape aShape = GetTopoShape(shape) ;
+ Bnd_Box B ;
+ Standard_Real axmin,aymin,azmin,axmax,aymax,azmax ;
+ GEOM::PointStruct pstruct1, pstruct2, pstruct3, pstruct4 ;
+
+ if(aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("MakePanel aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+
+ try {
+ BRepBndLib::Add(aShape,B);
+ B.Enlarge(10.);
+ B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
+
+ switch (directiontype)
+ {
+ case 1 : /* X */
+ pstruct1 = MakePointStruct( delta, aymin, azmin ) ;
+ pstruct2 = MakePointStruct( delta, aymin, azmax ) ;
+ pstruct3 = MakePointStruct( delta, aymax, azmax ) ;
+ pstruct4 = MakePointStruct( delta, aymax, azmin ) ;
+ break ;
+ case 2 : /* Y */
+ pstruct1 = MakePointStruct( axmin, delta, azmin ) ;
+ pstruct2 = MakePointStruct( axmin, delta, azmax ) ;
+ pstruct3 = MakePointStruct( axmax, delta, azmax ) ;
+ pstruct4 = MakePointStruct( axmax, delta, azmin ) ;
+ break ;
+ case 3 : /* Z */
+ pstruct1 = MakePointStruct( axmin, aymin, delta ) ;
+ pstruct2 = MakePointStruct( axmin, aymax, delta ) ;
+ pstruct3 = MakePointStruct( axmax, aymax, delta ) ;
+ pstruct4 = MakePointStruct( axmax, aymin, delta ) ;
+ break ;
+ default :
+ return result ;
+ }
+
+ GEOM::GEOM_Shape_ptr Edge1 = MakeEdge(pstruct1, pstruct2);
+ GEOM::GEOM_Shape_ptr Edge2 = MakeEdge(pstruct2, pstruct3);
+ GEOM::GEOM_Shape_ptr Edge3 = MakeEdge(pstruct3, pstruct4);
+ GEOM::GEOM_Shape_ptr Edge4 = MakeEdge(pstruct4, pstruct1);
+
+ GEOM::GEOM_Gen::ListOfIOR_var aList = new GEOM::GEOM_Gen::ListOfIOR;
+ aList->length(4);
+ aList[0]=strdup(Edge1->Name());
+ aList[1]=strdup(Edge2->Name());
+ aList[2]=strdup(Edge3->Name());
+ aList[3]=strdup(Edge4->Name());
+
+ GEOM::GEOM_Shape_ptr aWire = MakeWire( aList );
+ GEOM::GEOM_Shape_ptr aFace = MakeFace( aWire, true ) ;
+ tds = GetTopoShape(aFace);
+
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakePanel", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make PanelsPartition aborted : null shape", SALOME::BAD_PARAM);
+ }
+
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry) ;
+
+ return result;
+}
+
+
+void GEOM_Gen_i::ExportIGES(const char* filename,GEOM::GEOM_Shape_ptr theShape)
+ throw (SALOME::SALOME_Exception)
+{
+ if (theShape->_is_nil())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export IGES aborted", SALOME::BAD_PARAM);
+ }
+ TopoDS_Shape tds = GetTopoShape(theShape);
+ if (tds.IsNull())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export IGES aborted", SALOME::BAD_PARAM);
+ }
+ try
+ {
+ //VRV: OCC 4.0 migration
+ IGESControl_Controller::Init();
+ IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
+ Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
+ //VRV: OCC 4.0 migration
+
+ ICW.AddShape (tds);
+ ICW.ComputeModel();
+ char * aname = strdup(filename);
+ Standard_Boolean result = ICW.Write( aname );
+ free(aname);
+ }
+ catch(Standard_Failure)
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ExportIGES", SALOME::BAD_PARAM);
+ }
+}
+
+void GEOM_Gen_i::ExportBREP(const char* filename,GEOM::GEOM_Shape_ptr theShape)
+ throw (SALOME::SALOME_Exception)
+{
+ if (theShape->_is_nil())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export BRep aborted", SALOME::BAD_PARAM);
+ }
+ TopoDS_Shape tds = GetTopoShape(theShape);
+ if (tds.IsNull())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export BRep aborted", SALOME::BAD_PARAM);
+ }
+ try
+ {
+ char * aname = strdup(filename);
+ Standard_Boolean result = BRepTools::Write(tds,aname);
+ free(aname);
+ }
+ catch(Standard_Failure)
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ExportBREP", SALOME::BAD_PARAM);
+ }
+}
+
+void GEOM_Gen_i::ExportSTEP(const char* filename,GEOM::GEOM_Shape_ptr theShape)
+ throw (SALOME::SALOME_Exception)
+{
+ if (theShape->_is_nil())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export STEP aborted", SALOME::BAD_PARAM);
+ }
+ TopoDS_Shape tds = GetTopoShape(theShape);
+ if (tds.IsNull())
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Export STEP aborted", SALOME::BAD_PARAM);
+ }
+ try
+ {
+ IFSelect_ReturnStatus status ;
+ //VRV: OCC 4.0 migration
+ STEPControl_Writer aWriter;
+ status = aWriter.Transfer( tds, STEPControl_ManifoldSolidBrep ) ;
+ //VRV: OCC 4.0 migration
+ if ( status == IFSelect_RetDone )
+ {
+ char * aname = strdup(filename);
+ status = aWriter.Write( aname ) ;
+ free(aname);
+ }
+ }
+ catch(Standard_Failure)
+ {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::ExportBREP", SALOME::BAD_PARAM);
+ }
+}
+
+
+//=====================================================================================
+// EXPORTED METHODS
+//=====================================================================================
+extern "C"
+{
+ PortableServer::ObjectId * GeometryEngine_factory(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char * interfaceName)
+ {
+MESSAGE("mygeom")
+ GEOM_Gen_i * myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
+MESSAGE("mygeom")
+ myGEOM_Gen_i->register_name("/myGEOM_Gen"); // NRI : 11/07/2002 : Add for Supervision example
+MESSAGE("mygeom")
+ return myGEOM_Gen_i->getId() ;
+ }
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+# 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@
+
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+# 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@
+
--- /dev/null
+-- 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;
+
--- /dev/null
+-- 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;
--- /dev/null
+// 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");
+}
+
+
+
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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() {}
\ No newline at end of file
--- /dev/null
+// 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
--- /dev/null
+-- 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;
--- /dev/null
+// 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 ;
+ }
+}
--- /dev/null
+// 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
--- /dev/null
+// 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"
+
+
+
+
--- /dev/null
+// 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
\ No newline at end of file
--- /dev/null
+// 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
--- /dev/null
+// 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>
+
--- /dev/null
+// 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
--- /dev/null
+// 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>
+
--- /dev/null
+// 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
--- /dev/null
+// 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>
+
--- /dev/null
+-- 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;
--- /dev/null
+// 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();
+}
+
+
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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"
+
+
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+# 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@
+
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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() {}
+
--- /dev/null
+// 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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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() {}
+
--- /dev/null
+// 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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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() {}
+
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+# 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@
+
--- /dev/null
+// 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.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI.h"
+
+// SALOME Includes
+# include "Utils_ORB_INIT.hxx"
+# include "Utils_SINGLETON.hxx"
+
+#include "QAD.h"
+#include "QAD_Tools.h"
+#include "QAD_Config.h"
+#include "QAD_Settings.h"
+#include "QAD_RightFrame.h"
+#include "QAD_MessageBox.h"
+#include "QAD_Resource.h"
+#include "QAD_FileDlg.h"
+
+#include "OCCViewer_ViewPort.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_Viewer3d.h"
+
+#include "SALOME_NamingService.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+#include "SALOME_InteractiveObject.hxx"
+
+#include "SALOMEGUI_ImportOperation.h"
+#include "SALOMEGUI_QtCatchCorbaException.hxx"
+#include "SALOMEGUI_NameDlg.h"
+#include "utilities.h"
+
+// Open CASCADE Includes
+#include <AIS_Shape.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Drawer.hxx>
+#include <AIS_Trihedron.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepGProp.hxx>
+#include <BRepExtrema_DistShapeShape.hxx>
+#include <GProp_GProps.hxx>
+#include <GProp_PrincipalProps.hxx>
+
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepPrimAPI_MakeCylinder.hxx>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <BRepPrimAPI_MakeSphere.hxx>
+#include <BRepPrimAPI_MakeRevol.hxx>
+#include <BRepPrimAPI_MakeTorus.hxx>
+#include <BRepPrimAPI_MakeCone.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+
+#include <BRepTools.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
+#include <Geom_Circle.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Axis2Placement.hxx>
+#include <Geom_TrimmedCurve.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GC_MakeArcOfCircle.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Mat.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+
+//VRV: OCC 4.0 migration
+#include <IGESControl_Writer.hxx>
+#include <IGESControl_Controller.hxx>
+#include <STEPControl_Writer.hxx>
+//#include <STEPControlStd_StepModelType.hxx>
+//VRV: OCC 4.0 migration
+
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <Precision.hxx>
+#include <ProjLib.hxx>
+#include <ElSLib.hxx>
+
+#include <IFSelect_ReturnStatus.hxx>
+#include <Interface_Static.hxx>
+
+// QT Includes
+#define INCLUDE_MENUITEM_DEF
+#include <qapplication.h>
+#include <qmenudata.h>
+#include <qmenubar.h>
+#include <qpopupmenu.h>
+#include <qfont.h>
+#include <qstring.h>
+#include <qcheckbox.h>
+#include <qcolordialog.h>
+#include <qmessagebox.h>
+#include <qspinbox.h>
+#include <qlist.h>
+#include <qwidget.h>
+#include <qevent.h>
+#include <qlineedit.h>
+
+#include "VTKViewer_RenderWindowInteractor.h"
+#include "VTKViewer_ViewFrame.h"
+#include "GEOM_Actor.h"
+#include "GEOM_Client.hxx"
+#include "GEOM_AISShape.hxx"
+#include "GEOM_AssemblyBuilder.h"
+#include "GEOM_InteractiveObject.hxx"
+
+
+#include "GeometryGUI_aParameterDlg.h"
+
+#include "GeometryGUI_PointDlg.h" // Method POINT
+#include "GeometryGUI_BoxDlg.h" // Method BOX
+#include "GeometryGUI_VectorDlg.h" // Method VECTOR
+#include "GeometryGUI_PlaneDlg.h" // Method PLANE
+#include "GeometryGUI_PrismDlg.h" // Method PRISM
+#include "GeometryGUI_FuseDlg.h" // Method FUSE
+#include "GeometryGUI_CommonDlg.h" // Method COMMON
+#include "GeometryGUI_CutDlg.h" // Method CUT
+#include "GeometryGUI_SectionDlg.h" // Method SECTION
+
+#include "GeometryGUI_LineDlg.h" // Method LINE
+#include "GeometryGUI_ScaleDlg.h" // Method SCALE
+#include "GeometryGUI_MirrorDlg.h" // Method MIRROR
+#include "GeometryGUI_SphereDlg.h" // Method SPHERE
+#include "GeometryGUI_CircleDlg.h" // Method CIRCLE
+#include "GeometryGUI_RevolDlg.h" // Method REVOL
+#include "GeometryGUI_RotationDlg.h" // Method ROTATION
+#include "GeometryGUI_TranslationDlg.h" // Method TRANSLATION
+#include "GeometryGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
+#include "GeometryGUI_MultiRotationDlg.h" // Method MULTI ROTATION
+#include "GeometryGUI_ArcDlg.h" // Method ARC
+#include "GeometryGUI_PipeDlg.h" // Method PIPE
+#include "GeometryGUI_CylinderDlg.h" // Method CYLINDER
+#include "GeometryGUI_ConeDlg.h" // Method CONE
+#include "GeometryGUI_TorusDlg.h" // Method TORUS
+#include "GeometryGUI_FillingDlg.h" // Method FILLING
+#include "GeometryGUI_SewingDlg.h" // Method SEWING
+#include "GeometryGUI_CompoundDlg.h" // Method GEOM::COMPOUND
+#include "GeometryGUI_EdgeDlg.h" // Method GEOM::EDGE
+#include "GeometryGUI_OrientationDlg.h" // Method ORIENTATION
+#include "GeometryGUI_PartitionDlg.h" // Method PARTITION
+#include "GeometryGUI_SubShapeDlg.h" // Method EXPLODE
+#include "GeometryGUI_WireDlg.h" // Method GEOM::WIRE
+#include "GeometryGUI_WorkingPlaneDlg.h" // Method WORKING PLANE
+#include "GeometryGUI_PropertiesDlg.h" // Method PROPERTIES
+#include "GeometryGUI_CenterMassDlg.h" // Method CENTER MASS
+#include "GeometryGUI_InertiaDlg.h" // Method INERTIA
+#include "GeometryGUI_FaceDlg.h" // Method GEOM::FACE
+#include "GeometryGUI_FilletDlg.h" // Method FILLET
+#include "GeometryGUI_ChamferDlg.h" // Method CHAMFER
+#include "GeometryGUI_FillingHoleDlg.h" // Method FILLING HOLE
+#include "GeometryGUI_SuppressFacesDlg.h" // Method SUPPRESS FACES
+#include "GeometryGUI_CheckShape.h" // Method CHECKSHAPE
+#include "GeometryGUI_ArchimedeDlg.h" // Method ARCHIMEDE
+#include "GeometryGUI_TransparencyDlg.h" // Method TRANSPARENCY adjustement
+#include "GeometryGUI_NbIsosDlg.h" // Method ISOS adjustement
+#include "GeometryGUI_BndBoxDlg.h" // Method BNDBOX
+#include "GeometryGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE
+#include "GeometryGUI_WhatisDlg.h" // Method WHATIS
+#include "GeometryGUI_DistanceDlg.h" // Method DISTANCE
+#include "GeometryGUI_SuppressHoleDlg.h" // Method SUPPRESS HOLE
+
+
+static Handle(AIS_Shape) theConstructionShape = new AIS_Shape(TopoDS_Shape());
+static Handle(GEOM_AISShape) theSelectedShape = new GEOM_AISShape(TopoDS_Shape(), "");
+
+static AIS_ListOfInteractive ListDisplayedObject;
+
+static bool Settings_AddInStudy = false;
+static bool Settings_Copy = false;
+static Standard_CString Fatherior = "";
+static GEOM_Client ShapeReader;
+
+/* The object itself created in the static method 'GetOrCreateGeometryGUI()' */
+static GeometryGUI* GeomGUI = 0;
+
+
+
+//=======================================================================
+// class : CustomItem
+// purpose : Set Font to a text.
+//=======================================================================
+class CustomItem : public QCustomMenuItem
+{
+public:
+ CustomItem( const QString& s, const QFont& f )
+ : string( s ), font( f ){};
+ ~CustomItem(){}
+
+ void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
+ {
+ p->setFont ( font );
+ p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
+ }
+
+ QSize sizeHint()
+ {
+ return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
+ }
+private:
+ QString string;
+ QFont font;
+};
+
+
+
+
+//=======================================================================
+// function : GeometryGUI()
+// purpose : Constructor
+//=======================================================================
+GeometryGUI::GeometryGUI() :
+ QObject()
+{
+}
+
+//=======================================================================
+// function : ~GeometryGUI()
+// purpose : Destructor
+//=======================================================================
+GeometryGUI::~GeometryGUI()
+{
+}
+
+
+//=======================================================================
+// function : GetGeometryGUI() static
+// purpose : Returns current 'GeomGUI' a static pointer
+//=======================================================================
+GeometryGUI* GeometryGUI::GetGeometryGUI( )
+{
+ return GeomGUI;
+}
+
+
+//=====================================================================================
+// function : GetIndex()
+// purpose : Get the index of a sub shape in a main shape : index start at 1
+//=====================================================================================
+int GeometryGUI::GetIndex(const TopoDS_Shape& subshape,
+ const TopoDS_Shape& shape,
+ int /*ShapeType*/)
+{
+ if( shape.IsNull() || subshape.IsNull() )
+ return -1 ;
+
+ int index = 1;
+ if (subshape.ShapeType() == TopAbs_COMPOUND)
+ {
+ TopoDS_Iterator it;
+ TopTools_ListOfShape CL;
+ CL.Append( shape );
+ 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 (it.Value().IsSame(subshape))
+ return index;
+ else
+ index++;
+ CL.Append( it.Value() );
+ }
+ }
+ }
+ }
+ else
+ {
+ TopExp_Explorer Exp ( shape, subshape.ShapeType() );
+ TopTools_MapOfShape M;
+ while ( Exp.More() )
+ {
+ if ( M.Add(Exp.Current()) )
+ {
+ if ( Exp.Current().IsSame(subshape) )
+ return index;
+ index++;
+ }
+ Exp.Next();
+ }
+ }
+ return -1;
+}
+
+//=======================================================================
+// function : GetOrCreateGeometryGUI()
+// purpose : Gets or create an object 'GeometryGUI' with initialisations
+// : Returns 'GeomGUI' as a pointer
+//=======================================================================
+GeometryGUI* GeometryGUI::GetOrCreateGeometryGUI( QAD_Desktop* desktop )
+{
+ if( GeomGUI == 0 ) {
+ GeomGUI = new GeometryGUI;
+ GeomGUI->myActiveDialogBox = 0 ;
+ GeomGUI->mySimulationShape = new AIS_Shape(TopoDS_Shape());
+ GeomGUI->myState = -1 ;
+ GeomGUI->myDesktop = desktop ;
+ GeomGUI->myActiveStudy = desktop->getActiveStudy();
+ GeomGUI->mySimulationActor = vtkActorCollection::New() ;
+
+ GeomGUI->myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
+
+ Engines::Component_var comp = desktop->getEngine("FactoryServer", "Geometry");
+ GeomGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp);
+
+ /* GetCurrentStudy */
+ int studyId = GeomGUI->myActiveStudy->getStudyId();
+ GeomGUI->myComponentGeom->GetCurrentStudy(studyId);
+
+ GeomGUI->myNbGeom = GeomGUI->myComponentGeom->NbLabels();
+ } else {
+ /* study may have changed */
+ GeomGUI->myActiveStudy = desktop->getActiveStudy();
+ }
+ return GeomGUI;
+}
+
+
+//=================================================================================
+// function : VertexToPoint()
+// purpose : If S can be converted in a gp_Pnt returns true and the result is P
+//=================================================================================
+bool GeometryGUI::VertexToPoint( const TopoDS_Shape& S, gp_Pnt& P )
+{
+ if( S.IsNull() || S.ShapeType() != TopAbs_VERTEX )
+ return false ;
+ P = BRep_Tool::Pnt(TopoDS::Vertex( S ));
+ return true ;
+}
+
+
+//=================================================================================
+// function : LinearEdgeExtremities()
+// purpose : If S can be converted in a linear edge and if initial an final points
+// : distance is sufficient, returns true else returns false.
+// : Resulting points are respectively P1 and P2
+//=================================================================================
+bool GeometryGUI::LinearEdgeExtremities( const TopoDS_Shape& S, gp_Pnt& P1, gp_Pnt& P2 )
+{
+ if( S.IsNull() || S.ShapeType() != TopAbs_EDGE )
+ return false ;
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ if (curv.GetType() != GeomAbs_Line)
+ return false ;
+
+ curv.D0( curv.FirstParameter(), P1 );
+ curv.D0( curv.LastParameter(), P2 );
+
+ if( P1.Distance(P2) <= Precision::Confusion() )
+ return false ;
+
+ return true ;
+}
+
+//=================================================================================
+// function : GetBipointDxDyDz()
+// purpose :
+//=================================================================================
+void GeometryGUI::GetBipointDxDyDz( gp_Pnt P1, gp_Pnt P2, double& dx, double& dy, double& dz )
+{
+ dx = P2.X() - P1.X() ;
+ dy = P2.Y() - P1.Y() ;
+ dz = P2.Z() - P1.Z() ;
+ return ;
+}
+
+//=======================================================================
+// function : GetTopoFromSelection()
+// purpose : Define tds from a single selection and retuen true
+//=======================================================================
+bool GeometryGUI::GetTopoFromSelection(SALOME_Selection *Sel, TopoDS_Shape& tds)
+{
+ if(Sel->IObjectCount() != 1)
+ return false ;
+
+ Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
+ /* case SObject */
+ if ( IO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->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);
+ tds = this->GetShapeFromIOR(anIOR->Value());
+ if(tds.IsNull() )
+ return false ;
+ else
+ return true ;
+ }
+ }
+ }
+
+ if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ Standard_CString ior = "";
+ Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
+ ior = GIObject->getIOR();
+ tds = this->GetShapeFromIOR(ior);
+ if(tds.IsNull() )
+ return false ;
+ else
+ return true ;
+ }
+
+ return false;
+}
+
+
+
+//=====================================================================================
+// function : PrepareSubShapeSelection()
+// purpose : ( localContextId of the method is opened and defined here)
+//=====================================================================================
+bool GeometryGUI::PrepareSubShapeSelection(const int SubShapeType, Standard_Integer& returnLocalContextId)
+{
+ //* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ return false;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ /* local context opening */
+ SetDisplayedObjectList() ;
+ OnDisplayOnly();
+
+ returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found);
+ if ( found && SubShapeType >= Shape->Shape().ShapeType()) {
+ ic->Load(Shape, (8 - SubShapeType), Standard_True);
+ ic->HilightWithColor(Shape, Quantity_NOC_RED);
+ }
+ }
+ myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
+ return true ;
+}
+
+
+
+//=====================================================================================
+// function : PrepareSubShapeSelectionArgumentShape()
+// purpose : ( localContextId of the method is opened and defined here )
+//=====================================================================================
+bool GeometryGUI::PrepareSubShapeSelectionArgumentShape( const TopoDS_Shape& aShape,
+ const int SubShapeType,
+ Standard_Integer& returnLocalContextId )
+{
+ //* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ return false;
+
+ if( aShape.IsNull() )
+ return false ;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ /* local context opening */
+ SetDisplayedObjectList() ;
+ OnDisplayOnly();
+
+ returnLocalContextId = ic->OpenLocalContext(Standard_False, Standard_True, Standard_False, Standard_False) ;
+
+ Handle(GEOM_AISShape) Shape = new GEOM_AISShape(aShape, "") ;
+ ic->Display(Shape, 0, (8 - SubShapeType));
+
+ // Not Load(...) but Display(...)
+ // ic->Load(Shape, (8 - SubShapeType), Standard_True);
+ ic->HilightWithColor(Shape, Quantity_NOC_RED);
+
+ myDesktop->putInfo (tr("GEOM_PRP_SELECT_SUBSHAPES"));
+ return true ;
+}
+
+
+
+//=======================================================================
+// function : GetNameOfSelectedIObjects()
+// purpose : Define the name geom++ or other name of mono or multi sel.
+//=======================================================================
+int GeometryGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel,
+ QString& aName )
+{
+ int nbSel = Sel->IObjectCount() ;
+ if ( nbSel == 1 ) {
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ aName = IObject->getName();
+ } else {
+ aName = tr( "%1_objects" ).arg( nbSel );
+ }
+ return nbSel;
+}
+
+
+//=======================================================================
+// function : ConvertIOinGEOMAISShape()
+// purpose :
+//=======================================================================
+Handle(GEOM_AISShape) GeometryGUI::ConvertIOinGEOMAISShape( const Handle(SALOME_InteractiveObject)& IO,
+ Standard_Boolean& testResult,
+ bool onlyInActiveView )
+{
+ Handle(GEOM_AISShape) res;
+ int nbSf = myActiveStudy->getStudyFramesCount();
+ for ( int i = 0; i < nbSf; i++ ) {
+ QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
+ if ( sf->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ List.Append(List1);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ if ( aSh->hasIO() ) {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
+ if ( GIO->isSame( IO ) ) {
+ if ( onlyInActiveView ) {
+ if ( sf == myActiveStudy->getActiveStudyFrame() ) {
+ testResult = true;
+ return aSh;
+ }
+ } else {
+ testResult = true;
+ return aSh;
+ }
+ }
+ }
+ }
+ ite.Next();
+ }
+ }
+ }
+ testResult = false;
+ return res;
+}
+
+//=======================================================================
+// function : ConvertIORinGEOMAISShape()
+// purpose :
+//=======================================================================
+Handle(GEOM_AISShape) GeometryGUI::ConvertIORinGEOMAISShape( const char * IOR,
+ Standard_Boolean& testResult,
+ bool onlyInActiveView )
+{
+Handle(GEOM_AISShape) resultShape;
+testResult = false;
+ int nbSf = myActiveStudy->getStudyFramesCount();
+ for ( int i = 0; i < nbSf; i++ )
+ {
+ QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
+ if ( sf->getTypeView() == VIEW_OCC )
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ List.Append(List1);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More())
+ {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
+ {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ if ( aSh->hasIO() )
+ {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
+ Standard_CString theIOR = GIO->getIOR();
+ if ( strcmp( IOR, theIOR ) == 0 )
+ {
+ if ( onlyInActiveView )
+ {
+ if ( sf == myActiveStudy->getActiveStudyFrame() )
+ {
+ testResult = true;
+ resultShape = aSh;
+ return resultShape;
+ }
+ }
+ else
+ {
+ testResult = true;
+ resultShape = aSh;
+ return resultShape;
+ }
+ }
+ }
+ }
+ ite.Next();
+ }
+ }
+ }
+return resultShape;
+}
+//=======================================================================
+// function : ConvertIORinGEOMActor()
+// purpose :
+//=======================================================================
+GEOM_Actor* GeometryGUI::ConvertIORinGEOMActor( const char * IOR,
+ Standard_Boolean& testResult,
+ bool onlyInActiveView )
+{
+ int nbSf = GeomGUI->myActiveStudy->getStudyFramesCount();
+ for ( int i = 0; i < nbSf; i++ ) {
+ QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
+ if ( sf->getTypeView() == VIEW_VTK ) {
+ vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theActors = Renderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor *ac = theActors->GetNextActor();
+ while(!(ac==NULL)) {
+ if ( ac->IsA("GEOM_Actor") ) {
+ GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
+ if ( anActor->hasIO() ) {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(anActor->getIO());
+ Standard_CString theIOR = GIO->getIOR();
+ if ( strcmp( IOR, theIOR ) == 0 ) {
+ if ( onlyInActiveView ) {
+ if ( sf == GeomGUI->myActiveStudy->getActiveStudyFrame() ) {
+ testResult = true;
+ return anActor;
+ }
+ } else {
+ testResult = true;
+ return anActor;
+ }
+ }
+ }
+ }
+ ac = theActors->GetNextActor();
+ }
+ }
+ }
+ testResult = false;
+ return GEOM_Actor::New();
+}
+
+//=======================================================================
+// function : ConvertIOinGEOMShape()
+// purpose :
+//=======================================================================
+GEOM::GEOM_Shape_ptr GeometryGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
+ Standard_Boolean& testResult )
+{
+ GEOM::GEOM_Shape_ptr aShape ;
+ testResult = false ;
+
+ /* case SObject */
+ if ( IO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->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);
+ aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ;
+ testResult = true ;
+ return aShape;
+ }
+ }
+ }
+ /* case Graphical Object */
+ if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
+ Standard_CString ior = GIObject->getIOR();
+ testResult = true ;
+ aShape = myComponentGeom->GetIORFromString(ior) ;
+ return aShape;
+ }
+ return aShape ;
+}
+
+
+//=======================================================================
+// function : ConvertListOfIOInListOfIOR()
+// purpose :
+//=======================================================================
+void GeometryGUI::ConvertListOfIOInListOfIOR( const SALOME_ListIO& aList,
+ GEOM::GEOM_Gen::ListOfIOR& listIOR )
+{
+ int nbSel = aList.Extent();
+ listIOR.length(nbSel) ;
+ int j=0;
+ SALOME_ListIteratorOfListIO It( aList );
+ for ( int i=0; It.More(); It.Next(), i++ )
+ {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+ if ( IObject->hasEntry() )
+ {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() && obj->FindAttribute(anAttr, "AttributeIOR") )
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ CORBA::ORB_var& _orb = init.orb() ;
+ CORBA::String_var theValue = anIOR->Value();
+ CORBA::Object_var theObj = _orb->string_to_object(theValue);
+ if (theObj->_is_a("IDL:GEOM/GEOM_Shape:1.0"))
+ {
+ listIOR[j] = strdup(theValue) ;
+ j++;
+ }
+ }
+ }
+ else if ( IObject->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IObject );
+ Standard_CString ior = GIObject->getIOR();
+ listIOR[j] = strdup(ior) ;
+ j++;
+ }
+ }
+ listIOR.length(j) ;
+}
+
+
+//=================================================================================
+// function : GetShapeTypeString()
+// purpose : for a single shape
+//=================================================================================
+bool GeometryGUI::GetShapeTypeString( const TopoDS_Shape& aShape, Standard_CString& aTypeString )
+{
+ if( aShape.IsNull() ) {
+ aTypeString = "aNullShape" ;
+ return false ;
+ }
+ switch (aShape.ShapeType() )
+ {
+ case TopAbs_COMPOUND:
+ { aTypeString = strdup(tr("GEOM_COMPOUND")) ; return true ; }
+ case TopAbs_COMPSOLID:
+ { aTypeString = strdup(tr("GEOM_COMPOUNDSOLID")) ; return true ; }
+ case TopAbs_SOLID:
+ { aTypeString = strdup(tr("GEOM_SOLID")) ; return true ; }
+ case TopAbs_SHELL:
+ { aTypeString = strdup(tr("GEOM_SHELL")) ; return true ; }
+ case TopAbs_FACE:
+ {
+ BRepAdaptor_Surface surf(TopoDS::Face(aShape));
+ if ( surf.GetType() == GeomAbs_Plane ) {
+ aTypeString = strdup(tr("GEOM_PLANE")) ;
+ return true ;
+ } else if ( surf.GetType() == GeomAbs_Cylinder ) {
+ aTypeString = strdup(tr("GEOM_SURFCYLINDER")) ;
+ return true ;
+ } else if ( surf.GetType() == GeomAbs_Sphere ) {
+ aTypeString = strdup(tr("GEOM_SURFSPHERE")) ;
+ return true ;
+ } else if ( surf.GetType() == GeomAbs_Torus ) {
+ aTypeString = strdup(tr("GEOM_SURFTORUS")) ;
+ return true ;
+ } else if ( surf.GetType() == GeomAbs_Cone ) {
+ aTypeString = strdup(tr("GEOM_SURFCONE")) ;
+ return true ;
+ } else {
+ aTypeString = strdup(tr("GEOM_FACE")) ;
+ return true ;
+ }
+ }
+ case TopAbs_WIRE:
+ { aTypeString = strdup(tr("GEOM_WIRE")) ; return true ; }
+ case TopAbs_EDGE:
+ {
+ BRepAdaptor_Curve curv(TopoDS::Edge(aShape));
+ if ( curv.GetType() == GeomAbs_Line ) {
+ if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
+ (Abs(curv.LastParameter()) >= 1E6 )) {
+ aTypeString = strdup(tr("GEOM_LINE")) ;
+ } else
+ aTypeString = strdup(tr("GEOM_EDGE")) ;
+ return true ;
+ } else if ( curv.GetType() == GeomAbs_Circle ) {
+ if ( curv.IsClosed() )
+ aTypeString = strdup(tr("GEOM_CIRCLE")) ;
+ else
+ aTypeString = strdup(tr("GEOM_ARC")) ;
+ return true ;
+ } else {
+ aTypeString = strdup(tr("GEOM_EDGE")) ;
+ return true ;
+ }
+ }
+ case TopAbs_VERTEX:
+ { aTypeString = strdup(tr("GEOM_VERTEX")) ; return true ; }
+ case TopAbs_SHAPE:
+ { aTypeString = strdup(tr("GEOM_SHAPE")) ; return true ; }
+ }
+ return false ;
+}
+
+
+//=================================================================================
+// function : CreateArrowForLinearEdge()
+// purpose : Create a cone topology to be used to display an arrow in the middle
+// : of an edge showing its orientation. (For simulation and Viewer OCC only)
+//=================================================================================
+bool GeometryGUI::CreateArrowForLinearEdge( const TopoDS_Shape& tds, TopoDS_Shape& ArrowCone )
+{
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC || tds.ShapeType() != TopAbs_EDGE )
+ return false;
+
+ OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
+ Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
+ Standard_Real Width, Height ;
+ view3d->Size(Width, Height) ;
+ const Standard_Real aHeight = (Width + Height) / 50.0 ;
+
+ try {
+ Standard_Real first, last ;
+ Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
+ if( !curv->IsCN(1) )
+ return false ;
+
+ const Standard_Real param = (first+last) / 2.0 ;
+ gp_Pnt middleParamPoint ;
+ gp_Vec V1 ;
+ curv->D1( param, middleParamPoint, V1) ;
+ if ( V1.Magnitude() < Precision::Confusion() )
+ return false ;
+
+ /* Topology orientation not geom orientation */
+ if( tds.Orientation() == TopAbs_REVERSED )
+ V1 *= -1.0 ;
+
+ gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1) ) ;
+ const Standard_Real radius1 = aHeight / 5.0 ;
+ if( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() ) {
+ ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape() ;
+ return true ;
+ }
+ }
+ catch(Standard_Failure) {
+ // OCC failures are hard to catch in GUI.
+ // This because of the position for #include <Standard_ErrorHandler.hxx> that is very critic to find
+ // in SALOME environment : compilation error !
+ }
+ return false ;
+}
+
+
+//=======================================================================
+// function : SelectionByNameInDialogs()
+// purpose : Called when user has entered a name of object in a LineEdit.
+// : The selection is changed. Dialog box will receive the
+// : corresponding signal to manage this event.
+//=======================================================================
+bool GeometryGUI::SelectionByNameInDialogs( QWidget* aWidget, const QString& objectUserName, SALOME_Selection* Sel )
+{
+
+ /* Find SObject with name in component GEOM */
+ SALOMEDS::Study_var ST = this->myActiveStudy->getStudyDocument() ;
+ SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ;
+ listSO = ST->FindObjectByName( objectUserName, "GEOM" ) ;
+
+ if ( listSO->length() < 1 ) {
+ const QString caption = tr("GEOM_WRN_WARNING") ;
+ const QString text = tr("GEOM_NAME_INCORRECT") ;
+ const QString button0 = tr("GEOM_BUT_OK") ;
+ QMessageBox::warning( aWidget, caption, text, button0 ) ;
+ return false ;
+ }
+ /* More than one object with same name */
+ if ( listSO->length() > 1 ) {
+ const QString caption = tr("GEOM_WRN_WARNING") ;
+ const QString text = tr("GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE") ;
+ const QString button0 = tr("GEOM_BUT_OK") ;
+ QMessageBox::warning( aWidget, caption, text, button0 ) ;
+ return false ;
+ }
+
+ SALOMEDS::SObject_var theObj = listSO[0] ;
+ /* Create a SALOME_InteractiveObject with a SALOME::SObject */
+ Standard_CString anEntry = theObj->GetID() ;
+ Handle(SALOME_InteractiveObject) SI = new SALOME_InteractiveObject( anEntry, "GEOM", strdup(objectUserName) ) ;
+
+ /* Add as a selected object */
+ /* Clear any previous selection : */
+ /* Warning the LineEdit is purged because of signal currentSelectionChanged ! */
+ Sel->ClearIObjects() ;
+ Sel->AddIObject( SI ) ;
+ return true ;
+}
+
+
+//=======================================================================
+// function : MakePointAndDisplay
+// purpose :
+//=======================================================================
+void GeometryGUI::MakePointAndDisplay( const double x, const double y, const double z )
+{
+ try {
+ GEOM::GEOM_Shape_var P = myComponentGeom->MakeVertex( x, y, z );
+ P->NameType( tr("GEOM_VERTEX") );
+ if ( Display( P, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+
+//=======================================================================
+// function : MakeVectorAndDisplay()
+// purpose :
+//=======================================================================
+void GeometryGUI::MakeVectorAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
+{
+ try {
+ GEOM::PointStruct pstruct1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
+ GEOM::PointStruct pstruct2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
+ GEOM::GEOM_Shape_var Vector = myComponentGeom->MakeVector( pstruct1, pstruct2 );
+ Vector->NameType(tr("GEOM_VECTOR"));
+ if ( Display( Vector, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+//=======================================================================
+// function : MakeBoxAndDisplay()
+// purpose :
+//=======================================================================
+void GeometryGUI::MakeBoxAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
+{
+ try {
+ GEOM::GEOM_Shape_var box = myComponentGeom->MakeBox( P1.X(), P1.Y(), P1.Z(), P2.X(), P2.Y(), P2.Z() );
+ box->NameType(tr("GEOM_BOX"));
+ if ( Display( box, "") ) {
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+
+
+//=======================================================================
+// function : MakePlaneAndDisplay()
+// purpose : Plane point is P1 and dx, dy, dz define a normal vector
+//=======================================================================
+void GeometryGUI::MakePlaneAndDisplay( const gp_Pnt P1, const Standard_Real dx,
+ const Standard_Real dy, const Standard_Real dz,
+ const Standard_Real TrimSize )
+{
+ try {
+ gp_Dir aDirection;
+ aDirection.SetCoord(dx, dy, dz) ;
+ gp_Ax2 Axis( P1, aDirection );
+
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct(aDirection.X(), aDirection.Y(), aDirection.Z()) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+ GEOM::GEOM_Shape_ptr plane = myComponentGeom->MakePlane(pstruct, dstruct, TrimSize) ;
+ plane->NameType(tr("GEOM_PLANE"));
+ if ( Display( plane, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+//=======================================================================
+// function : MakeWorkingPlane()
+// purpose : Change the point of view3d
+//=======================================================================
+void GeometryGUI::MakeWorkingPlane( const gp_Pnt P, const gp_Dir D)
+{
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_OCC) {
+ GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ return ;
+ }
+ OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewPort();
+ Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)vp)->getView();
+ view3d->SetAt( P.X(), P.Y(), P.Z() );
+ view3d->SetProj( D.X(), D.Y(), D.Z() );
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+}
+
+
+//=======================================================================
+// function : MakePrismAndDisplay()
+// purpose : P1 and P2 is to define a vector for prism
+//=======================================================================
+void GeometryGUI::MakePrismAndDisplay( GEOM::GEOM_Shape_ptr BaseShape, const gp_Pnt P1, const gp_Pnt P2 )
+{
+ try {
+ GEOM::PointStruct PS1 = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z() ) ;
+ GEOM::PointStruct PS2 = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z() ) ;
+ if( BaseShape->_is_nil() ) {
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePrism( BaseShape, PS1, PS2 ) ;
+ if (result->_is_nil()) {
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeLineAndDisplay()
+// purpose : Create an infinite oriented line (linear edge in fact)
+//=====================================================================================
+void GeometryGUI::MakeLineAndDisplay( const gp_Pnt InitPoint, const gp_Pnt LastPoint )
+{
+ gp_Pnt P1,P2;
+ double dx, dy, dz ;
+ GetBipointDxDyDz( InitPoint, LastPoint, dx, dy, dz ) ;
+ Standard_Real length = InitPoint.Distance(LastPoint) ;
+ if( length <= Precision::Confusion() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+
+ Standard_Real coeff = 1E6 / length ;
+
+ /* To create a line with length = 1E6 */
+ /* Precision::Infinite() is 1E100 in OCC */
+ P1.SetX( InitPoint.X() - (coeff * dx) ) ;
+ P1.SetY( InitPoint.Y() - (coeff * dy) ) ;
+ P1.SetZ( InitPoint.Z() - (coeff * dz) ) ;
+
+ P2.SetX( LastPoint.X() + (coeff * dx) ) ;
+ P2.SetY( LastPoint.Y() + (coeff * dy) ) ;
+ P2.SetZ( LastPoint.Z() + (coeff * dz) ) ;
+
+ try {
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct(P1.X(), P1.Y(), P1.Z()) ;
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct(P2.X(), P2.Y(), P2.Z()) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeLine(pstruct, dstruct) ;
+ if(result->_is_nil()) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+ result->NameType(tr("GEOM_LINE"));
+
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_READY"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+
+//=======================================================================
+// function : MakeBooleanAndDisplay()
+// purpose :
+//=======================================================================
+void GeometryGUI::MakeBooleanAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2, const short operation )
+{
+ try {
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeBoolean( Shape1, Shape2, operation ) ;
+ if (result->_is_nil()) {
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeSphere()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeSphereAndDisplay( const gp_Pnt aCenterPoint, const double aRadius )
+{
+ try {
+ if( aRadius <= Precision::Confusion() ) {
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("GEOM_WRN_WARNING"),
+ tr ("GEOM_WRN_RADIUS_NULL"), tr ("GEOM_BUT_YES") );
+ return ;
+ }
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeSphere(aCenterPoint.X(),aCenterPoint.Y(),aCenterPoint.Z(), aRadius);
+ result->NameType(tr("GEOM_SPHERE"));
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeConeAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeConeAndDisplay( const gp_Pnt BasePoint,
+ const gp_Dir aDir,
+ const double Radius1,
+ const double Radius2,
+ const double aHeight )
+{
+ try {
+ if( ( Radius1 <= Precision::Confusion() && Radius2 <= Precision::Confusion() ) || aHeight <= Precision::Confusion() )
+ return ;
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCone( pstruct, dstruct, Radius1, Radius2, aHeight ) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+ result->NameType(tr("GEOM_CONE"));
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeCylinderAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeCylinderAndDisplay( const gp_Pnt BasePoint,
+ const gp_Dir aDir,
+ const double Radius,
+ const double aHeight )
+{
+ try {
+ if( Radius <= Precision::Confusion() || aHeight <= Precision::Confusion() )
+ return ;
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
+ GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCylinder(pstruct, dstruct, Radius, aHeight) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+ result->NameType(tr("GEOM_CYLINDER"));
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeTorusAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeTorusAndDisplay( const gp_Pnt BasePoint,
+ const gp_Dir aDir,
+ const double Radius1,
+ const double Radius2 )
+{
+ try {
+ if( Radius1 <= Precision::Confusion() || Radius2 <= Precision::Confusion() )
+ return ;
+
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( BasePoint.X(), BasePoint.Y(), BasePoint.Z() ) ;
+ GEOM::PointStruct d = myComponentGeom ->MakePointStruct( aDir.X(), aDir.Y(), aDir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeTorus(pstruct, dstruct, Radius1, Radius2) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+ result->NameType(tr("GEOM_TORUS"));
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakePipeAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakePipeAndDisplay( GEOM::GEOM_Shape_ptr aPath, GEOM::GEOM_Shape_ptr aBase )
+{
+ try {
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakePipe(aPath, aBase);
+ if ( !result->_is_nil() && Display( result, "") ) {
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ myDesktop->putInfo( tr("GEOM_PRP_DONE") );
+ }
+ else {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeFillingAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeFillingAndDisplay( GEOM::GEOM_Shape_ptr SectionShape,
+ const short mindeg,
+ const short maxdeg,
+ const double tol3d,
+ const double tol2d,
+ const short nbiter )
+{
+ try {
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeFilling( SectionShape,
+ mindeg, maxdeg,
+ tol3d, tol2d, nbiter );
+ if (result->_is_nil()) {
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ return ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+
+//=====================================================================================
+// function : MakeMirrorAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeMirrorAndDisplay( GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2 )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeMirrorByPlane( Shape1, Shape2 );
+ if (result->_is_nil()) {
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType( Shape1->NameType() );
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeSewingAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeSewingAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR,
+ const Standard_Real precision )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeSewing(listShapesIOR, precision) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if( Display( result, "") )
+ myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
+ return ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+//=====================================================================================
+// function : MakeCompoundAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeCompoundAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCompound(listShapesIOR) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType(tr("GEOM_COMPOUND"));
+ if( Display( result, "" ))
+ myDesktop->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeFaceAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeFaceAndDisplay( GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeFace( aWire, wantPlanar) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ if ( wantPlanar )
+ result->NameType(tr("GEOM_PLANE"));
+ else
+ result->NameType(tr("GEOM_FACE"));
+ if( Display( result, "") )
+ myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+
+//=====================================================================================
+// function : MakeLinearEdgeAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeLinearEdgeAndDisplay( const gp_Pnt P1, const gp_Pnt P2 )
+{
+ try {
+ GEOM::PointStruct ps1 = myComponentGeom->MakePointStruct( P1.X(), P1.Y(), P1.Z() ) ;
+ GEOM::PointStruct ps2 = myComponentGeom->MakePointStruct( P2.X(), P2.Y(), P2.Z() ) ;
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeEdge( ps1, ps2 ) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType(tr("GEOM_EDGE"));
+ if( Display( result, "") )
+ myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ catch(const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeOrientationChangeAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeOrientationChangeAndDisplay( GEOM::GEOM_Shape_ptr Shape )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->OrientationChange( Shape ) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType( Shape->NameType() );
+ if ( Display( result, "" ))
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ return ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+//=====================================================================================
+// function : MakeScaleAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeScaleAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, const Standard_Real factor )
+{
+ try {
+ GEOM::PointStruct P = myComponentGeom->MakePointStruct(centralPoint.X(), centralPoint.Y(), centralPoint.Z() ) ;
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeScaleTransform(Shape, P, factor) ;
+ // result->NameType(tr("GEOM_SCALE"));
+ result->NameType( Shape->NameType() );
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ else
+ myDesktop->putInfo (tr("GEOM_PRP_NULLSHAPE")) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=======================================================================================
+// function : MakeRevolutionAndDisplay()
+// purpose :
+//=======================================================================================
+void GeometryGUI::MakeRevolutionAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, const gp_Dir dir, const Standard_Real revolAngle )
+{
+ try {
+ GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
+ GEOM::GEOM_Shape_ptr result = myComponentGeom->MakeRevolution(Shape, axis, revolAngle) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=======================================================================================
+// function : MakeRotationAndDisplay()
+// purpose :
+//=======================================================================================
+void GeometryGUI::MakeRotationAndDisplay( GEOM::GEOM_Shape_ptr Shape,
+ const gp_Pnt loc,
+ const gp_Dir dir,
+ const Standard_Real angle )
+{
+ try {
+ const GEOM::AxisStruct axis = myComponentGeom->MakeAxisStruct(loc.X(), loc.Y(), loc.Z(), dir.X(), dir.Y(), dir.Z() ) ;
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeRotation(Shape, axis, angle);
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( Shape->NameType() );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeTranslationAndDisplay()
+// purpose : Translate a shape
+//=================================================================================
+void GeometryGUI::MakeTranslationAndDisplay( GEOM::GEOM_Shape_ptr Shape, gp_Vec V )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeTranslation( Shape, V.X(), V.Y(), V.Z() ) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( Shape->NameType() );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+//=================================================================================
+// function : MakeMultiTranslation1DAndDisplay()
+// purpose : Multi-Translate a shape
+//=================================================================================
+void GeometryGUI::MakeMultiTranslation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const double Step, const short NbTimes )
+{
+ try {
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation1D( Shape, dstruct, Step, NbTimes );
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( tr("GEOM_COMPOUND") );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeMultiTranslation2DAndDisplay()
+// purpose : Multi-Translate a shape
+//=================================================================================
+void GeometryGUI::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 )
+{
+ try {
+ GEOM::PointStruct d1 = myComponentGeom->MakePointStruct( Dir1.X(), Dir1.Y(), Dir1.Z() ) ;
+ GEOM::DirStruct dstruct1 = myComponentGeom->MakeDirection(d1) ;
+ GEOM::PointStruct d2 = myComponentGeom->MakePointStruct( Dir2.X(), Dir2.Y(), Dir2.Z() ) ;
+ GEOM::DirStruct dstruct2 = myComponentGeom->MakeDirection(d2) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiTranslation2D( Shape, dstruct1, Step1, NbTimes1, dstruct2, Step2, NbTimes2 );
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( tr("GEOM_COMPOUND") );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeMultiRotation1DAndDisplay()
+// purpose : Multi-Rotate a shape
+//=================================================================================
+void GeometryGUI::MakeMultiRotation1DAndDisplay( GEOM::GEOM_Shape_ptr Shape, const gp_Dir Dir, const gp_Pnt Loc, const short NbTimes )
+{
+ try {
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation1D( Shape, dstruct, pstruct, NbTimes );
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( tr("GEOM_COMPOUND") );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeMultiRotation2DAndDisplay()
+// purpose : Multi-Rotate a shape
+//=================================================================================
+void GeometryGUI::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 )
+{
+ try {
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct( Dir.X(), Dir.Y(), Dir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( Loc.X(), Loc.Y(), Loc.Z() ) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeMultiRotation2D( Shape, dstruct, pstruct, Ang, NbTimes1, Step, NbTimes2 );
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( tr("GEOM_COMPOUND") );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+
+//=======================================================================================
+// function : MakeArcAndDisplay()
+// purpose : Make an arc of circle from InitPoint to CirclePoint and passing on EndPoint
+//=======================================================================================
+void GeometryGUI::MakeArcAndDisplay( gp_Pnt InitPoint, gp_Pnt CirclePoint, gp_Pnt EndPoint )
+{
+ gp_Vec v1( CirclePoint, InitPoint ) ;
+ gp_Vec v2( CirclePoint, EndPoint ) ;
+ if( v1.IsParallel(v2, Precision::Angular() ) )
+ return ;
+
+ try {
+ GEOM::PointStruct pI = myComponentGeom->MakePointStruct( InitPoint.X(), InitPoint.Y(), InitPoint.Z() );
+ GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CirclePoint.X(), CirclePoint.Y(), CirclePoint.Z() );
+ GEOM::PointStruct pE = myComponentGeom->MakePointStruct( EndPoint.X(), EndPoint.Y(), EndPoint.Z() );
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeArc(pI, pC, pE) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return ;
+ }
+ result->NameType(tr("GEOM_ARC"));
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakeCircleAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeCircleAndDisplay( const gp_Pnt CenterPoint, const gp_Dir dir, const Standard_Real Radius )
+{
+ try {
+ GEOM::PointStruct pstruct = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() ) ;
+ GEOM::PointStruct d = myComponentGeom->MakePointStruct( dir.X(), dir.Y(), dir.Z() ) ;
+ GEOM::DirStruct dstruct = myComponentGeom->MakeDirection(d) ;
+
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCircle(pstruct, dstruct, Radius) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType(tr("GEOM_CIRCLE"));
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+
+//=====================================================================================
+// function : MakeWireAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeWireAndDisplay( GEOM::GEOM_Gen::ListOfIOR& listShapesIOR )
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeWire(listShapesIOR) ;
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType(tr("GEOM_WIRE"));
+ if( Display( result, "") )
+ myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+
+//=====================================================================================
+// function : MakePartitionAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::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)
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->Partition(listShapesIOR,
+ listToolsIOR,
+ listKeepInsIOR,
+ listRemoveInsIOR,
+ (CORBA::Short) limit);
+ if( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_NULLSHAPE")) ;
+ return ;
+ }
+ result->NameType(tr("GEOM_PARTITION"));
+ if( Display( result, "") )
+ myDesktop ->putInfo(tr("GEOM_PRP_DONE")) ;
+ return ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+//=======================================================================
+// function : SetState()
+// purpose : Sets myState = aState a private field indicating which methode is active
+//=======================================================================
+void GeometryGUI::SetState(int aState )
+{ this->myState = aState ; return ; }
+
+
+//=======================================================================
+// function : ResetState()
+// purpose : Sets myState = -1 a private field indicating which methode is active
+//=======================================================================
+void GeometryGUI::ResetState()
+{ this->myState = -1 ; return ; }
+
+
+//=======================================================================
+// function : EmitSignalDeactivateDialog()
+// purpose : Emit a signal to deactivate the active dialog Box
+//=======================================================================
+void GeometryGUI::EmitSignalDeactivateDialog()
+{
+ emit this->SignalDeactivateActiveDialog() ;
+ return ;
+}
+
+//=======================================================================
+// function : EmitSignalCloseAllDialogs()
+// purpose : Emit a signal to deactivate all non modal dialogs box
+//=======================================================================
+void GeometryGUI::EmitSignalCloseAllDialogs()
+{
+ emit this->SignalCloseAllDialogs() ;
+ return ;
+}
+
+
+//=======================================================================
+// function : GetActiveDialogBox()
+// purpose :
+//=======================================================================
+QDialog* GeometryGUI::GetActiveDialogBox()
+{
+ return this->myActiveDialogBox ;
+}
+
+
+//=======================================================================
+// function : SetActiveDialogBox()
+// purpose :
+//=======================================================================
+void GeometryGUI::SetActiveDialogBox(QDialog* aDlg)
+{
+ this->myActiveDialogBox = (QDialog*)aDlg ;
+ return ;
+}
+
+
+//=======================================================================
+// function : GetActiveStudy()
+// purpose :
+//=======================================================================
+QAD_Study* GeometryGUI::GetActiveStudy()
+{
+ return this->myActiveStudy ;
+}
+
+
+//=======================================================================
+// function : GetActiveDesktop()
+// purpose :
+//=======================================================================
+QAD_Desktop* GeometryGUI::GetDesktop()
+{
+ return this->myDesktop ;
+}
+
+
+//=====================================================================================
+// function : OnSubShapeGetAll()
+// purpose : Explode a shape in all sub shapes with a SubShapeType
+//=====================================================================================
+bool GeometryGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
+{
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
+ if ( theObj->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
+ return false ;
+ }
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+ SALOMEDS::AttributePixMap_var aPixmap;
+
+ /* We create a sub object for each sub shape as attribute of the main object */
+ /* Each sub object contains list (length=1) containing its index in the main shape */
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
+ GEOM::GEOM_Shape_var aResult ;
+
+ try {
+ listGeomShapes = myComponentGeom->SubShapeAll( aShape, SubShapeType );
+ if( listGeomShapes->length() < 1 ) {
+ myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
+ return false ;
+ }
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ /* open transaction */
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+
+ TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
+ TopoDS_Shape mainShape;
+ bool main = false;
+ while ( !main ) {
+ if ( aShape->IsMainShape() ) {
+ mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
+ main = true;
+ } else
+ aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
+ }
+
+ /* Loop on each sub shape created */
+ /* int i = 1 ; /* index for the nameType */
+ for( int j=0; j<listGeomShapes->length(); j++) {
+
+ /* Get each sub shape extracted CORBA and OCC */
+ aResult = listGeomShapes[j] ;
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
+
+ if ( S.IsNull() ) {
+ myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
+ return false;
+ }
+
+// NRI : Following lines are commented according to bugID SAL695 (see history)
+// BRepCheck_Analyzer anAnalyzer(S);
+// if(!anAnalyzer.IsValid()) {
+// myDesktop->putInfo (tr("GEOM_PRP_ABORT"));
+// MESSAGE("#### An exploded shape number "<< j << " is not valid");
+// op->abort();
+// return false;
+// }
+
+ /* Set the nameType of sub shape */
+ char* nameG = (char *)malloc(20);
+ Standard_CString Type;
+ if ( GetShapeTypeString(S, Type) ) {
+ aResult->NameType( Type );
+ sprintf (nameG, "%s_%d", Type, GetIndex( S, mainShape, SubShapeType ) );
+ }
+ else {
+ aResult->NameType( tr("GEOM_SHAPE") );
+ sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
+ }
+ SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
+
+ bool allreadyexist = false;
+
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ Handle(GEOM_AISShape) result = new GEOM_AISShape( S, nameG );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
+
+ MESSAGE ( "SO->_is_nil() " << SO->_is_nil() )
+
+ if ( SO->_is_nil() ) {
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(nameG);
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aResult->Name());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ MESSAGE( " Type " << S.ShapeType() )
+ if ( S.ShapeType() == TopAbs_COMPOUND ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
+ } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
+ } else if ( S.ShapeType() == TopAbs_SOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
+ } else if ( S.ShapeType() == TopAbs_SHELL ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
+ } else if ( S.ShapeType() == TopAbs_FACE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
+ } else if ( S.ShapeType() == TopAbs_WIRE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
+ } else if ( S.ShapeType() == TopAbs_EDGE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
+ } else if ( S.ShapeType() == TopAbs_VERTEX ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
+ }
+
+ MESSAGE ( " aPixmap->GetPixMap " << aPixmap->GetPixMap() )
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, newObj);
+ IO->setEntry(newObj->GetID());
+
+ aResult->StudyShapeId( newObj->GetID() );
+ } else {
+ allreadyexist = true;
+ if ( ! SObjectExist(theObj, aResult->Name()) ) {
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
+ aStudyBuilder->Addreference(newObj1, SO);
+ IO->setEntry(SO->GetID());
+ aResult->StudyShapeId( SO->GetID() );
+ }
+ }
+
+ result->setIO( IO );
+ result->setName( nameG );
+ if ( !allreadyexist )
+ ic->Display(result);
+
+ } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ int themode = myRenderInter->GetDisplayMode();
+ vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
+
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior,"GEOM");
+
+ if ( SO->_is_nil() ) {
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aResult->Name());
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(nameG);
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ if ( S.ShapeType() == TopAbs_COMPOUND ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
+ } else if ( S.ShapeType() == TopAbs_COMPSOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
+ } else if ( S.ShapeType() == TopAbs_SOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
+ } else if ( S.ShapeType() == TopAbs_SHELL ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
+ } else if ( S.ShapeType() == TopAbs_FACE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
+ } else if ( S.ShapeType() == TopAbs_WIRE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
+ } else if ( S.ShapeType() == TopAbs_EDGE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
+ } else if ( S.ShapeType() == TopAbs_VERTEX ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
+ }
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, newObj);
+ IO->setEntry(newObj->GetID());
+ } else {
+ allreadyexist = true;
+ if ( ! SObjectExist(theObj, aResult->Name()) ) {
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
+ aStudyBuilder->Addreference(newObj1, SO);
+ IO->setEntry(SO->GetID());
+ }
+ }
+
+ if ( !allreadyexist ) {
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ GActor->setIO( IO );
+ GActor->setName( nameG );
+ theRenderer->AddActor(GActor);
+ renWin->Render();
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ }
+ }
+
+ /* commit transaction */
+ op->finish();
+
+ myActiveStudy->updateObjBrowser();
+ myDesktop->putInfo (tr("GEOM_PRP_READY"));
+ return true ;
+}
+
+
+
+//=====================================================================================
+// function : GetIndexSubShapeSelected()
+// purpose : Define a ListOfID of sub shapes selected in ShapeTopo with SubShapeType
+// : Method used by Dialogs
+//=====================================================================================
+bool GeometryGUI::GetIndexSubShapeSelected( const TopoDS_Shape& ShapeTopo,
+ const int SubShapeType,
+ GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID,
+ Standard_Integer& aLocalContextId,
+ bool& myUseLocalContext )
+{
+ //* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ ic->InitSelected();
+ int nbSelected = ic->NbSelected();
+ ListOfID.length(nbSelected);
+
+
+ //***************** DEFINE INDEX OF EACH SELECTION *********************//
+ int i = 0 ;
+ ic->InitSelected(); /* to restart */
+ while( ic->MoreSelected() ) {
+
+ /* Find index of sub shape into main shape */
+ TopExp_Explorer Exp ( ShapeTopo, TopAbs_ShapeEnum(SubShapeType) );
+ int index = 1;
+ bool found = false ;
+ while ( Exp.More() ) {
+ if ( (Exp.Current()).IsSame( ic->SelectedShape()) ) {
+ found = true ;
+ break;
+ }
+ index++;
+ Exp.Next();
+ }
+ if( !found ) {
+ /* Manage local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+ return false ;
+ }
+ ListOfID[i] = index ;
+ i++;
+ ic->NextSelected();
+ }
+ //***************** END *********************//
+
+ /* Manage local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+
+ return true ;
+}
+
+
+//=====================================================================================
+// function : OnSubShapeGetSelected()
+// purpose :
+//=====================================================================================
+bool GeometryGUI::OnSubShapeGetSelected( const TopoDS_Shape& ShapeTopo,
+ const char* ShapeTopoIOR,
+ const int SubShapeType,
+ Standard_Integer& aLocalContextId,
+ bool& myUseLocalContext )
+{
+ //* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
+ if ( theObj->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
+ return false ;
+ }
+
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ if( myUseLocalContext == false ) {
+ /* local context is from DialogBox */
+ MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
+ return false ;
+ }
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ TopoDS_Shape mainTopo = ShapeReader.GetShape(myComponentGeom, aShape);
+
+ TopoDS_Shape mainShape;
+ bool main = false;
+ while ( !main ) {
+ if ( aShape->IsMainShape() ) {
+ mainShape = ShapeReader.GetShape(myComponentGeom, aShape);
+ main = true;
+ } else
+ aShape = myComponentGeom->GetIORFromString( aShape->MainName() );
+ }
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ic->InitSelected();
+ int nbSelected = ic->NbSelected();
+ ListOfID->length(nbSelected);
+
+ TopoDS_Compound compound;
+ ic->InitSelected(); /* to init again */
+ BRep_Builder B;
+ B.MakeCompound( compound );
+
+ int i = 0;
+ /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
+ /* the compound is homogenous by selection */
+ while(ic->MoreSelected()) {
+ int index = GetIndex( ic->SelectedShape(), mainShape, SubShapeType );
+ ListOfID[i] = index ;
+ B.Add( compound, ic->SelectedShape() );
+ i++;
+ ic->NextSelected();
+ }
+
+ /* Test if user has selected sub shapes */
+ if( ListOfID->length() < 1 )
+ return false ;
+
+ GEOM::GEOM_Shape_var aResult ;
+ try {
+ aResult = myComponentGeom->SubShape( aShape, SubShapeType, ListOfID );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ /* local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+
+ char* nameG = (char *)malloc(20);
+ Standard_CString Type;
+
+ Handle(GEOM_AISShape) result;
+ Handle(GEOM_InteractiveObject) IO ;
+
+ // if ( ! SObjectExist(theObj, aResult->Name()) ) {
+ if ( nbSelected == 1 ) {
+ TopExp_Explorer Exp ( compound, TopAbs_ShapeEnum(SubShapeType) );
+ if ( Exp.More() ) {
+ if ( GetShapeTypeString(Exp.Current(),Type) ) {
+ aResult->NameType( Type );
+ sprintf (nameG, "%s_%d", Type, GetIndex( Exp.Current(), mainTopo, SubShapeType ) );
+ } else {
+ aResult->NameType( tr("GEOM_SHAPE") );
+ sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
+ }
+ result = new GEOM_AISShape( Exp.Current(), nameG );
+ IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
+ }
+ }
+ else {
+ if ( GetShapeTypeString(compound,Type) ) {
+ aResult->NameType( Type );
+ sprintf (nameG, "%s_%d", Type, this->myNbGeom++ );
+ } else {
+ aResult->NameType( tr("GEOM_SHAPE") );
+ sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
+ }
+ result = new GEOM_AISShape( compound, nameG );
+ IO = new GEOM_InteractiveObject(aResult->Name(), Fatherior, "GEOM");
+ }
+
+ SALOMEDS::SObject_var SO = aStudy->FindObjectIOR( aResult->Name() );
+
+ /* open transaction */
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+ SALOMEDS::AttributePixMap_var aPixmap;
+
+ bool allreadyexist = false;
+
+ if ( SO->_is_nil() ) {
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject( theObj );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aResult->Name());
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(result->getName());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ if ( result->Shape().ShapeType() == TopAbs_COMPOUND ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
+ } else if ( result->Shape().ShapeType() == TopAbs_COMPSOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
+ } else if ( result->Shape().ShapeType() == TopAbs_SOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
+ } else if ( result->Shape().ShapeType() == TopAbs_SHELL ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
+ } else if ( result->Shape().ShapeType() == TopAbs_FACE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
+ } else if ( result->Shape().ShapeType() == TopAbs_WIRE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
+ } else if ( result->Shape().ShapeType() == TopAbs_EDGE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
+ } else if ( result->Shape().ShapeType() == TopAbs_VERTEX ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
+ }
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, newObj);
+
+ IO->setEntry(newObj->GetID());
+ aResult->StudyShapeId(newObj->GetID());
+ } else {
+ allreadyexist = true;
+ if ( ! SObjectExist(theObj, aResult->Name()) ) {
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
+ aStudyBuilder->Addreference(newObj1, SO);
+
+ IO->setEntry(SO->GetID());
+ aResult->StudyShapeId(SO->GetID());
+ }
+ }
+
+ /* commit transaction */
+ op->finish();
+
+ result->setIO( IO );
+ result->setName( nameG );
+
+ if ( !allreadyexist )
+ ic->Display(result);
+
+ this->OnDisplayAll(true);
+ myActiveStudy->updateObjBrowser();
+ myDesktop->putInfo (tr("GEOM_PRP_READY"));
+
+ return true ;
+}
+
+
+//=====================================================================================
+// function : OnSuppressFaces()
+// purpose : To suppress faces from a shape
+// : The result is one or more shells/faces as main shapes !
+//=====================================================================================
+bool GeometryGUI::OnSuppressFaces( const TopoDS_Shape& ShapeTopo,
+ const char* ShapeTopoIOR,
+ const Standard_Integer& aLocalContextId,
+ bool& myUseLocalContext )
+{
+ /* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
+ if ( theObj->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
+ return false ;
+ }
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ if( myUseLocalContext == false ) {
+ /* local context is from DialogBox */
+ MESSAGE("Error : No local context opened for suppress faces method" << endl ) ;
+ return false ;
+ }
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ic->InitSelected();
+ int nbSelected = ic->NbSelected();
+ ListOfID->length(nbSelected);
+
+ /* Create a list of indices of faces to be suppressed */
+ int i = 0;
+ const int SubShapeType = 4 ; /* GEOM::FACE type */
+ ic->InitSelected(); /* to repositioning at beginning */
+ while( ic->MoreSelected() ) {
+ int index = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
+ ListOfID[i] = index ;
+ i++;
+ ic->NextSelected();
+ }
+
+ /* Close local context opened in DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+
+ /* Here is the main shape */
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
+
+ /* Call geom method that return a list of shells/faces as result of suppress */
+ try {
+ listGeomShapes = myComponentGeom->SuppressFaces( aShape, ListOfID );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ /* Test list of shells/faces */
+ if( listGeomShapes->length() < 1 ) {
+ return false ;
+ }
+
+ /* Loop on each object created */
+ for( int i=0; i<listGeomShapes->length(); i++ ) {
+
+ GEOM::GEOM_Shape_var aShellOrFace = listGeomShapes[i] ;
+ TopoDS_Shape S = ShapeReader.GetShape( this->myComponentGeom, aShellOrFace );
+
+ if( S.IsNull() ) {
+ return false ;
+ }
+
+ char* nameG = (char *)malloc(20);
+ Standard_CString Type;
+ if ( GetShapeTypeString(S, Type) ) {
+ aShellOrFace->NameType( Type );
+ sprintf (nameG, "%s_%d", Type, this->myNbGeom++);
+ }
+ else {
+ aShellOrFace->NameType( tr("GEOM_SHAPE") );
+ sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), this->myNbGeom++ );
+ }
+
+ /* Display with name */
+ if( !Display( aShellOrFace, nameG) ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return false ;
+ }
+ }
+
+ myDesktop->putInfo (tr("GEOM_PRP_READY"));
+ return true ;
+}
+
+
+//=====================================================================================
+// function : OnSuppressHole()
+// purpose : To suppress an hole on a shape 'ShapeTopo'.
+// : 'ListOfIdEndFace' may be an empty list.
+// : This means that hole do not traverse ShapeTopo.
+// : Warning : the hole to be suppressed must be defined by one or two single closed wires !
+//=====================================================================================
+bool GeometryGUI::OnSuppressHole( const char* ShapeTopoIOR,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdFace,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWire,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdEndFace )
+{
+ /* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ try {
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHole( aShape, ListOfIdFace, ListOfIdWire, ListOfIdEndFace ) ;
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ aResult->NameType( type );
+
+ if ( Display( aResult, "" ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return true ;
+}
+
+
+//=====================================================================================
+// function : OnSuppressHolesInFaceOrShell()
+// purpose : To suppress one or more holes on a face
+// : 'ListOfIdWires' contains indices or wires/holes.
+//=====================================================================================
+bool GeometryGUI::OnSuppressHolesInFaceOrShell( const char* ShapeTopoIOR,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfIdWires )
+{
+ /* Test the type of viewer */
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ try {
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var aResult = myComponentGeom->SuppressHolesInFaceOrShell( aShape, ListOfIdWires ) ;
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ aResult->NameType( type );
+
+ if ( Display( aResult, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return true ;
+}
+
+
+
+//=======================================================================
+// function : activeStudyChanged()
+// purpose : static
+//=======================================================================
+void GeometryGUI::activeStudyChanged( QAD_Desktop* parent )
+{
+ MESSAGE ("GeometryGUI::activeStudyChanged init.")
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+ if(GeomGUI != 0) {
+
+ if (GeomGUI->myState == CURRENT_SKETCH) {
+ GeomGUI->mySketcher.Clear();
+ GeomGUI->ResetState();
+ }
+
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ bool ViewOCC = false;
+ if ( GeomGUI->myDesktop->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
+ ViewOCC = true;
+
+ Mb->setItemEnabled( 312, ViewOCC); //Sketch
+ Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
+ Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
+
+ Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
+ Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
+
+ GeomGUI->EraseSimulationShape() ;
+ GeomGUI->EmitSignalCloseAllDialogs() ;
+ GeomGUI = 0 ;
+ }
+
+ // GeomGUI->SetSettings( parent );
+ // MESSAGE ("GeometryGUI::activeStudyChanged done.")
+ return ;
+}
+
+
+//=======================================================================
+// function : DefineDlgPosition()
+// purpose : Define x and y the default position for a dialog box
+//=======================================================================
+bool GeometryGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
+{
+ /* Here the position is on the bottom right corner - 10 */
+ QAD_Desktop* PP = QAD_Application::getDesktop() ;
+ x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
+ y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
+ return true ;
+}
+
+//=======================================================================
+// function : OnGUIEvent() [static]
+// purpose : manage all events on GUI
+//=======================================================================
+bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+{
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ OCCViewer_Viewer3d* v3d;
+ Handle(AIS_InteractiveContext) ic;
+ vtkRenderer* Renderer;
+
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+
+ bool ViewOCC = false;
+
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ ic = v3d->getAISContext();
+ ViewOCC = true;
+ Mb->setItemEnabled( 312, ViewOCC);//Sketch
+ Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
+ Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
+
+ Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
+ Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
+
+ } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+
+ // OnSuppressFaces, OnSuppressHole, SETTINGS - SHADING COLOR, SETTINGS - ISOS, SETTINGS : STEP VALUE FOR SPIN BOXES, SKETCHER, ISOS - POPUP VIEWER,
+ Mb->setItemEnabled( 312, ViewOCC);//Sketch
+ Mb->setItemEnabled( 309, ViewOCC);//SuppressFace
+ Mb->setItemEnabled( 314, ViewOCC);//SuppressHole
+
+ Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
+ Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
+ } else {
+ return 0;
+ }
+
+ if (GeomGUI->myState == CURRENT_SKETCH && theCommandID != 10000 && theCommandID != 10001 && theCommandID != 10002 && theCommandID != 10003 && theCommandID != 10004 && theCommandID != 10006 && theCommandID != 10007 && theCommandID != 10008 && theCommandID != 10010 && theCommandID != 10011 && theCommandID != 10012 && theCommandID != 10013 && theCommandID != 10014 && theCommandID != 3133 && theCommandID != 3134)
+ return false;
+
+ switch (theCommandID)
+ {
+ case 31: // COPY
+ GeomGUI->OnEditCopy();
+ break;
+
+ case 33: // DELETE
+ GeomGUI->OnEditDelete();
+ break;
+
+ case 111:
+ {
+ GeomGUI->SetState(111);
+ GeomGUI->Import();
+ GeomGUI->ResetState();
+ break;
+ }
+ case 112:
+ {
+ GeomGUI->SetState(112);
+ GeomGUI->Import();
+ GeomGUI->ResetState();
+ break;
+ }
+ case 113: // IMPORT STEP
+ {
+ GeomGUI->SetState(113);
+ GeomGUI->Import();
+ GeomGUI->ResetState();
+ break;
+ }
+
+ case 121: // EXPORT BREP
+ {
+ GeomGUI->SetState(121);
+ GeomGUI->Export();
+ GeomGUI->ResetState();
+ break;
+ }
+
+ case 122: // EXPORT IGES
+ {
+ GeomGUI->SetState(122);
+ GeomGUI->Export();
+ GeomGUI->ResetState();
+ break;
+ }
+
+ case 123: // EXPORT STEP
+ {
+ GeomGUI->SetState(123);
+ GeomGUI->Export();
+ GeomGUI->ResetState();
+ break;
+ }
+
+ case 303: // EXPLODE : use ic
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SubShapeDlg *aDlg = new GeometryGUI_SubShapeDlg( parent, "", Sel, ic ) ;
+ break ;
+ }
+
+ case 304: // GEOM::EDGE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_EdgeDlg *aDlg = new GeometryGUI_EdgeDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 305: // GEOM::WIRE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_WireDlg *aDlg = new GeometryGUI_WireDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 306: // GEOM::FACE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_FaceDlg *aDlg = new GeometryGUI_FaceDlg ( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 308: // GEOM::COMPOUND
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CompoundDlg *aDlg = new GeometryGUI_CompoundDlg ( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 309: // SUPPRESS FACES : use ic
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SuppressFacesDlg *aDlg = new GeometryGUI_SuppressFacesDlg( parent, "", Sel, ic ) ;
+ break ;
+ }
+
+ case 314: // SUPPRESS HOLES : use ic
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SuppressHoleDlg *aDlg = new GeometryGUI_SuppressHoleDlg( parent, "", Sel, ic ) ;
+ }
+ else {
+ GeomGUI->myDesktop->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ }
+ break ;
+ }
+ case 501: // SEWING
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SewingDlg *aDlg = new GeometryGUI_SewingDlg ( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 502: // ORIENTATION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_OrientationDlg *aDlg = new GeometryGUI_OrientationDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 601: // PROPERTIES (Length, surface, volume)
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PropertiesDlg *aDlg = new GeometryGUI_PropertiesDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 604: // CDG : Center of mass
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CenterMassDlg *aDlg = new GeometryGUI_CenterMassDlg ( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 605: // INERTIA
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_InertiaDlg *aDlg = new GeometryGUI_InertiaDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 607: // MAXTOLERANCE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_MaxToleranceDlg *aDlg = new GeometryGUI_MaxToleranceDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 608: // WHATIS
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_WhatisDlg *aDlg = new GeometryGUI_WhatisDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 609: // CHECKSHAPE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CheckShape *aDlg = new GeometryGUI_CheckShape( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 701: // SETTINGS - COPY
+ {
+ QMenuData* pp;
+ QMenuItem* item = parent->menuBar()->findItem(701,&pp);
+ bool check = !pp->isItemChecked(701);
+ pp->setItemChecked(701,check);
+ Settings_Copy = check;
+ QAD_CONFIG->addSetting( "Geometry:SettingsCopy", Settings_Copy );
+ break;
+ }
+
+ case 702: // SETTINGS - ADD IN STUDY
+ {
+ QMenuData* pp;
+ QMenuItem* item = parent->menuBar()->findItem(702,&pp);
+ bool check = !pp->isItemChecked(702);
+ pp->setItemChecked(702,check);
+ Settings_AddInStudy = check;
+
+ QAD_CONFIG->addSetting( "Geometry:SettingsAddInStudy", Settings_AddInStudy );
+ break;
+ }
+
+ case 703: // SETTINGS - SHADING COLOR
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+
+ QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
+ QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
+ QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
+ QColor color;
+ if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() ) {
+ color = QColor (SCr.toInt(),
+ SCg.toInt(),
+ SCb.toInt());
+ } else {
+ Quantity_Color Default = Quantity_Color();
+ color = QColor ( (int)Default.Red() * 255.0,
+ (int)Default.Green()* 255.0,
+ (int)Default.Blue() * 255.0 );
+ }
+
+ QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() );
+ if ( c.isValid() ) {
+ GeomGUI->myShadingColor = Quantity_Color(c.red() / 255.0,
+ c.green()/ 255.0,
+ c.blue() / 255.0,
+ Quantity_TOC_RGB);
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ List.Append(List1);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ aSh->SetShadingColor( GeomGUI->myShadingColor );
+ ic->Redisplay( aSh, Standard_True, Standard_True);
+ }
+ ite.Next();
+ }
+
+ ic->UpdateCurrentViewer();
+
+ QAD_CONFIG->addSetting("Geometry:SettingsShadingColorRed", c.red() );
+ QAD_CONFIG->addSetting("Geometry:SettingsShadingColorGreen", c.green() );
+ QAD_CONFIG->addSetting("Geometry:SettingsShadingColorBlue", c.blue() );
+ }
+ break;
+ }
+
+
+ case 704: // SETTINGS - ISOS
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+
+ QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
+ QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
+ if ( !IsoU.isEmpty() )
+ ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
+ else
+ IsoU = "1";
+ if ( !IsoV.isEmpty() )
+ ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
+ else
+ IsoV = "1";
+
+ GeometryGUI_NbIsosDlg * NbIsosDlg = new GeometryGUI_NbIsosDlg( QAD_Application::getDesktop(),
+ tr("GEOM_MEN_ISOS"), TRUE );
+ int UIso = IsoU.toInt();
+ int VIso = IsoV.toInt();
+
+ NbIsosDlg->SpinBoxU->setValue(UIso) ;
+ NbIsosDlg->SpinBoxV->setValue(VIso) ;
+
+ if ( NbIsosDlg->exec() ) {
+ UIso = NbIsosDlg->SpinBoxU->text().toInt() ;
+ VIso = NbIsosDlg->SpinBoxV->text().toInt() ;
+
+ ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
+ ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
+ QAD_CONFIG->addSetting( "Geometry:SettingsIsoU", NbIsosDlg->SpinBoxU->text() ); /* text format */
+ QAD_CONFIG->addSetting( "Geometry:SettingsIsoV", NbIsosDlg->SpinBoxV->text() ); /* text format */
+ }
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ List.Append(List1);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ ic->InitCurrent();
+ if ( ic->NbCurrents() )
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ Handle (AIS_Drawer) CurDrawer;
+ CurDrawer = aSh->Attributes();
+ CurDrawer->UIsoAspect()->SetNumber( UIso );
+ CurDrawer->VIsoAspect()->SetNumber( VIso );
+ ic->SetLocalAttributes(aSh, CurDrawer);
+ ic->Redisplay(aSh);
+ }
+ ite.Next();
+ }
+ ic->UpdateCurrentViewer();
+ break;
+ }
+
+ case 705: // SETTINGS : STEP VALUE FOR SPIN BOXES
+ {
+ //NRI if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ //NRI break;
+
+ QString step = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
+ if( step.isEmpty() )
+ step = "100.0" ;
+
+ Standard_Boolean res = false ;
+ double dd = Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3 ) ;
+ if( res ) {
+ QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", QString("%1").arg(dd) ) ;
+
+ /* Emit signal to GeometryGUI_SpinBoxes */
+ GeomGUI->SignalDefaultStepValueChanged( dd ) ;
+ }
+ else
+ parent->putInfo(tr("GEOM_PRP_ABORT"));
+
+ break ;
+ }
+
+ case 801: // ADD IN STUDY - POPUP VIEWER
+ {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ const SALOME_ListIO& ListSelected = Sel->StoredIObjects();
+ SALOME_ListIteratorOfListIO It( ListSelected );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ GeomGUI->AddInStudy(true, IObject);
+ }
+ /* Is set on the dialog box */
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+
+ case 901: // RENAME
+ {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for ( ; It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ if ( !obj->_is_nil() ) {
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+
+ QString nm = QString( aName->Value() );
+ nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), nm );
+ if ( !nm.isEmpty() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ GeomGUI->myActiveStudy->renameIObject( IObject, nm );
+ QApplication::restoreOverrideCursor();
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ case 903: // DISPLAY OBJECT BROWSER
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ SALOMEDS::SObject_var fatherSF =
+ aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ if(myRenderInter->isInViewer(IObject)) {
+ myRenderInter->Display(IObject);
+ }
+ else {
+ // Create new actor
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+
+ vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theAllActors = theRenderer->GetActors();
+ theAllActors->InitTraversal();
+ vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
+ Handle(SALOME_InteractiveObject) anIObj;
+ // don't create new study object if it already exists
+ bool isDisplayed = false;
+ while(!(actor==NULL)) {
+ SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
+ if (Gactor!=NULL) {
+ if (Gactor->hasIO()) {
+ if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
+ isDisplayed = true;
+ anIObj = Gactor->getIO();
+ if (!anIObj.IsNull()) myRenderInter->Display(anIObj);
+ }
+ }
+ }
+ actor=(vtkActor*)(theAllActors->GetNextActor());
+ }
+ if (!isDisplayed) {
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+
+ vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
+ int themode = myRenderInter->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
+ IO->setEntry(obj->GetID());
+ GActor->setIO( IO );
+ GActor->setName( IObject->getName() );
+
+ theRenderer->AddActor(GActor);
+ renWin->Render();
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ }
+ // next item iteration
+ if (useSubItems) {
+ anIter->Next();
+ anAttr = SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ }
+ GeomGUI->myActiveStudy->updateObjBrowser( true );
+ QApplication::restoreOverrideCursor();
+
+ } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+ SALOMEDS::SObject_var fatherSF =
+ aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ if ( v3d->isInViewer( IObject, true ) ) {
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
+ if ( found ) {
+ ic->Display(aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ // searchin for already displayed objects with the same shape
+ AIS_ListOfInteractive aDisplayed;
+ ic->DisplayedObjects(aDisplayed);
+ AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
+ Handle(AIS_Shape) anAISShape;
+ for(;anIObjects.More();anIObjects.Next()) {
+ anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
+ if (!anAISShape.IsNull()) {
+ if (anAISShape->Shape().IsSame(Shape)) break;
+ anAISShape.Nullify();
+ }
+ }
+ if (!anAISShape.IsNull()) {
+ if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape);
+ } else {
+ if (!useSubItems) {
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+ }
+
+ Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
+ aSh->SetShadingColor( GeomGUI->myShadingColor );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
+ Fatherior,
+ "GEOM");
+ IO->setEntry(obj->GetID());
+ aSh->setIO( IO );
+ aSh->setName( aName->Value() );
+ ic->Display (aSh);
+ if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+ }
+ // next item iteration
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ }
+ GeomGUI->myActiveStudy->updateObjBrowser( true );
+ QApplication::restoreOverrideCursor();
+ }
+ break;
+ }
+
+ case 3011: // POINT
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PointDlg *aDlg = new GeometryGUI_PointDlg( parent, "", Sel, ic ) ;
+ break;
+ }
+
+ case 3012: // LINE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_LineDlg *aDlg = new GeometryGUI_LineDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 3013: // CIRCLE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CircleDlg *aDlg = new GeometryGUI_CircleDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 3015: // ARC
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_ArcDlg *aDlg = new GeometryGUI_ArcDlg( parent, "", Sel ) ;
+ break ;
+ }
+
+ case 3016: // VECTOR
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_VectorDlg *aDlg = new GeometryGUI_VectorDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3017: // PLANE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PlaneDlg *aDlg = new GeometryGUI_PlaneDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3018: // WORKING PLANE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_WorkingPlaneDlg *aDlg = new GeometryGUI_WorkingPlaneDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 312: // SKETCHER
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ break;
+
+ GeomGUI->EmitSignalDeactivateDialog() ;
+
+ ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
+
+ GeomGUI->mySketcher = Sketch( v3d->getViewer3d() );
+ GeomGUI->SetState(CURRENT_SKETCH);
+
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+
+ QMenuItem* item = Mb->findItem(10010,&pp);
+ GeomGUI->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
+ item = Mb->findItem(10011,&pp);
+ GeomGUI->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
+ item = Mb->findItem(10012,&pp);
+ GeomGUI->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
+ item = Mb->findItem(10013,&pp);
+ GeomGUI->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
+ item = Mb->findItem(10014,&pp);
+ GeomGUI->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
+
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+ item = Mb->findItem(3133,&pp);
+ pp->setItemChecked(3133,false);
+ item = Mb->findItem(3134,&pp);
+ pp->setItemChecked(3134,false);
+ break;
+ }
+
+ case 3021: // BOX
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_BoxDlg *aDlg = new GeometryGUI_BoxDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3022: // CYLINDER
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CylinderDlg *aDlg = new GeometryGUI_CylinderDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3023: // SPHERE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SphereDlg *aDlg = new GeometryGUI_SphereDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3024: // TORUS
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_TorusDlg *aDlg = new GeometryGUI_TorusDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3025: // CONE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_ConeDlg *aDlg = new GeometryGUI_ConeDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 3131:
+ {
+ break;
+ }
+
+ case 3133: // sketcher
+ {
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(3133,&pp);
+ pp->setItemChecked(3133,!pp->isItemChecked(3133));
+ if (pp->isItemChecked(3133) == true)
+ GeomGUI->mySketcher.SetTransitionStatus(TANGENT);
+ else
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+
+ pp->setItemChecked(3134,false);
+ break;
+ }
+
+ case 3134: // sketcher
+ {
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(3134,&pp);
+ pp->setItemChecked(3134,!pp->isItemChecked(3134));
+ if (pp->isItemChecked(3134) == true)
+ GeomGUI->mySketcher.SetTransitionStatus(PERPENDICULAR);
+ else
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+
+ pp->setItemChecked(3133,false);
+ break;
+ }
+
+ case 4011: // FUSE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_FuseDlg *aDlg = new GeometryGUI_FuseDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4012: // COMMON
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CommonDlg *aDlg = new GeometryGUI_CommonDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4013: // CUT
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_CutDlg *aDlg = new GeometryGUI_CutDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4014: // SECTION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_SectionDlg *aDlg = new GeometryGUI_SectionDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4021: // TRANSLATION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_TranslationDlg *aDlg = new GeometryGUI_TranslationDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4022: // ROTATION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_RotationDlg *aDlg = new GeometryGUI_RotationDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4030: // MULTI TRANSLATION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_MultiTranslationDlg *aDlg = new GeometryGUI_MultiTranslationDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4040: // MULTI ROTATION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_MultiRotationDlg *aDlg = new GeometryGUI_MultiRotationDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4023: // MIRROR
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_MirrorDlg *aDlg = new GeometryGUI_MirrorDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4024: // SCALE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_ScaleDlg *aDlg = new GeometryGUI_ScaleDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4025: // PARTITION
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PartitionDlg *aDlg = new GeometryGUI_PartitionDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4026: // ARCHIMEDE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_ArchimedeDlg *aDlg = new GeometryGUI_ArchimedeDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4027: // FILLET
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_FilletDlg *aDlg = new GeometryGUI_FilletDlg( parent, "", Sel, ic ) ;
+ break;
+ }
+
+ case 4028: // CHAMFER
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_ChamferDlg *aDlg = new GeometryGUI_ChamferDlg( parent, "", Sel, ic ) ;
+ break;
+ }
+
+ case 4031: // PRISM
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PrismDlg *aDlg = new GeometryGUI_PrismDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4032: // REVOL
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_RevolDlg *aDlg = new GeometryGUI_RevolDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4033: // FILLING
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_FillingDlg *aDlg = new GeometryGUI_FillingDlg( parent, "", Sel ) ;
+ break;
+ }
+
+ case 4034: // PIPE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_PipeDlg *aDlg = new GeometryGUI_PipeDlg(parent, "", Sel ) ;
+ break;
+ }
+
+ case 5001: // CHECK GEOMETRY
+ {
+ QAD_PyEditor* PyEditor = GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getPyEditor();
+ PyEditor->setText("from GEOM_usinggeom import *\n");
+ PyEditor->setText(">>> ");
+ PyEditor->handleReturn();
+ break;
+ }
+
+ case 6021: // SHADING - WIREFRAME
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+ VTKViewer_RenderWindowInteractor* myRenderInter=
+ ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ QApplication::setOverrideCursor(waitCursor);
+
+ int themode = myRenderInter->GetDisplayMode();
+ if( themode==0 ) {
+ myRenderInter->SetDisplayMode(1);
+ GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
+ } else {
+ myRenderInter->SetDisplayMode(0);
+ GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
+ AIS_DisplayMode mode = ( AIS_DisplayMode )ic->DisplayMode();
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ AIS_DisplayMode newmode = (mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame);
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ List.Append(List1);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ ic->SetDisplayMode(aSh,Standard_Integer(newmode),true);
+ }
+ ite.Next();
+ }
+
+ ic->SetDisplayMode( newmode, Standard_False);
+ if ( newmode == 1 )
+ GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
+ else
+ GeomGUI->GetDesktop()->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
+
+ QApplication::restoreOverrideCursor();
+ }
+ break;
+ }
+
+ case 6022: // DISPLAY ALL
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+ //VTK
+ ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->DisplayAll();
+ else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
+ GeomGUI->OnDisplayAll();
+ break;
+ }
+
+ case 6023: // DISPLAY ONLY
+ case 8023: // DISPLAY ONLY - POPUP VIEWER
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+ // VTK
+ GeomGUI->OnVTKDisplayOnly();
+ }
+ else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
+ GeomGUI->OnDisplayOnly();
+ break;
+ }
+
+ case 6024: // ERASE ALL
+ {
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+ //VTK
+ ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor()->EraseAll();
+ }
+ else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
+ ic->EraseAll(Standard_True, Standard_False);
+ ic->Display(v3d->getTrihedron());
+ }
+
+ //NRI SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ //NRI Sel->ClearInteractiveObjects();
+ break;
+ }
+
+ case 6025 : // ERASE ONLY
+ case 8022 : // ERASE - POPUP VIEWER
+ {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
+ // VTK
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+ for(;It.More();It.Next()) {
+ anIObject = It.Value();
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ if(myRenderInter->isInViewer(anIObject)) {
+ myRenderInter->Erase(anIObject);
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ // searchin for already displayed objects with the same shape
+ vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theAllActors = theRenderer->GetActors();
+ theAllActors->InitTraversal();
+ vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
+ Handle(SALOME_InteractiveObject) anIObj;
+ // don't create new study object if it already exists
+ bool isDisplayed = false;
+ while(!(actor==NULL)) {
+ SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
+ if (Gactor!=NULL) {
+ if (Gactor->hasIO()) {
+ if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
+ isDisplayed = true;
+ anIObj = Gactor->getIO();
+ if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
+ }
+ }
+ }
+ actor=(vtkActor*)(theAllActors->GetNextActor());
+ }
+ }
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ }
+// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+// for(;It.More();It.Next()) {
+// Handle(SALOME_InteractiveObject) IOS = It.Value();
+ // GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
+ }
+ else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
+ // OCC
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+ for(;It.More();It.Next()) {
+ anIObject = It.Value();
+ if ( v3d->isInViewer( anIObject, true ) ) {
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
+ if ( found ) {
+ ic->Erase(aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ // searchin for already displayed objects with the same shape
+ AIS_ListOfInteractive aDisplayed;
+ ic->DisplayedObjects(aDisplayed);
+ AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
+ Handle(AIS_Shape) anAISShape;
+ for(;anIObjects.More();anIObjects.Next()) {
+ anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
+ if (!anAISShape.IsNull()) {
+ if (anAISShape->Shape().IsSame(Shape)) break;
+ anAISShape.Nullify();
+ }
+ }
+ if (!anAISShape.IsNull()) {
+ if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
+ }
+ }
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ }
+ }
+ Sel->ClearIObjects();
+ break;
+ }
+
+
+ case 6060: // BOUNDING BOX
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_BndBoxDlg *aDlg = new GeometryGUI_BndBoxDlg(parent, "", Sel ) ;
+ break ;
+ }
+
+ case 6061: // MIN DISTANCE
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_DistanceDlg *aDlg = new GeometryGUI_DistanceDlg(parent, "", Sel ) ;
+ break ;
+ }
+
+ case 8021: // WIREFRAME-SHADING
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ myRenderInter->SwitchRepresentation(IOS, false);
+ }
+ myRenderInter->Render();
+ QApplication::restoreOverrideCursor();
+ }
+ else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape( IObject, found, true );
+ if (!Shape.IsNull()) {
+ AIS_DisplayMode mode = ( AIS_DisplayMode )Shape->DisplayMode();
+ if ( mode == -1 )
+ mode = ( AIS_DisplayMode )ic->DisplayMode();
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ ic->SetDisplayMode(Shape, mode == AIS_WireFrame ? AIS_Shaded : AIS_WireFrame, false);
+ }
+ QApplication::restoreOverrideCursor();
+ }
+ ic->UpdateCurrentViewer();
+ }
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+
+ case 8031: // COLOR - POPUP VIEWER
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+
+ Handle(SALOME_InteractiveObject) FirstIOS = Sel->firstIObject();
+ if(!FirstIOS.IsNull()) {
+
+ QColor initcolor = myRenderInter->GetColor(FirstIOS);
+
+ QColor c = QColorDialog::getColor( initcolor,
+ QAD_Application::getDesktop() );
+
+ if ( c.isValid() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ myRenderInter->SetColor(IOS,c);
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ }
+ }
+ else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IO, found, true);
+ if ( found ) {
+ Quantity_Color CSFColor;
+ Shape->Color( CSFColor );
+
+ QColor c = QColorDialog::getColor( QColor(CSFColor.Red() * 255.0,
+ CSFColor.Green()* 255.0,
+ CSFColor.Blue() * 255.0 ),
+ QAD_Application::getDesktop() );
+
+ if ( c.isValid() ) {
+ CSFColor = Quantity_Color ( c.red()/255., c.green()/255., c.blue()/255., Quantity_TOC_RGB );
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
+ if ( found ) {
+ Shape->SetColor ( CSFColor );
+ Shape->SetShadingColor ( CSFColor );
+ }
+ }
+ }
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+
+ case 8032: // TRANSPARENCY - POPUP VIEWER
+ {
+ GeomGUI->EmitSignalDeactivateDialog() ;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ GeometryGUI_TransparencyDlg *aDlg = new GeometryGUI_TransparencyDlg( parent, "", Sel, ic ) ;
+ break ;
+ }
+
+ case 8033: // ISOS - POPUP VIEWER
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ else {
+ ic->InitCurrent();
+ if ( ic->MoreCurrent() ) {
+ Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+ QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
+ QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
+
+ if ( !IsoU.isEmpty() )
+ ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
+ else
+ IsoU = "1";
+ if ( !IsoV.isEmpty() )
+ ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
+ else
+ IsoV = "1";
+
+ GeometryGUI_NbIsosDlg * NbIsosDlg =
+ new GeometryGUI_NbIsosDlg(QAD_Application::getDesktop(), tr("GEOM_MEN_ISOS"), TRUE );
+
+ NbIsosDlg->SpinBoxU->setValue(IsoU.toInt());
+ NbIsosDlg->SpinBoxV->setValue(IsoV.toInt());
+
+ if ( NbIsosDlg->exec() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ for ( ; ic->MoreCurrent (); ic->NextCurrent () ) {
+ Handle (AIS_Drawer) CurDrawer;
+
+ CurDrawer = ic->Current()->Attributes();
+ CurDrawer->UIsoAspect()->SetNumber( NbIsosDlg->SpinBoxU->text().toInt() );
+ CurDrawer->VIsoAspect()->SetNumber( NbIsosDlg->SpinBoxV->text().toInt() );
+
+ ic->SetLocalAttributes(CurObject, CurDrawer);
+ ic->Redisplay(CurObject);
+ }
+ }
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ break;
+ }
+
+ case 9022 : // ERASE - OBJBROSER POPUP
+ {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+ for(;It.More();It.Next()) {
+ anIObject = It.Value();
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+// Handle(SALOME_InteractiveObject) IObject;
+ if(myRenderInter->isInViewer(anIObject)) {
+ myRenderInter->Erase(anIObject);
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ // searchin for already displayed objects with the same shape
+ vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theAllActors = theRenderer->GetActors();
+ theAllActors->InitTraversal();
+ vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
+ Handle(SALOME_InteractiveObject) anIObj;
+ // don't create new study object if it already exists
+ bool isDisplayed = false;
+ while(!(actor==NULL)) {
+ SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
+ if (Gactor!=NULL) {
+ if (Gactor->hasIO()) {
+ if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
+ isDisplayed = true;
+ anIObj = Gactor->getIO();
+ if (!anIObj.IsNull()) myRenderInter->Erase(anIObj);
+ }
+ }
+ }
+ actor=(vtkActor*)(theAllActors->GetNextActor());
+ }
+ }
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+// for(;It.More();It.Next()) {
+// Handle(SALOME_InteractiveObject) IOS = It.Value();
+// GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
+ }
+// SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
+// for(;It.More();It.Next()) {
+// Handle(SALOME_InteractiveObject) IOS = It.Value();
+// GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor()->Erase(IOS);;
+// }
+ }
+ else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ // OCC
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+ for(;It.More();It.Next()) {
+ anIObject = It.Value();
+ if ( v3d->isInViewer( anIObject, true ) ) {
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( anIObject, found, true );
+ if ( found ) {
+ ic->Erase(aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ // searchin for already displayed objects with the same shape
+ AIS_ListOfInteractive aDisplayed;
+ ic->DisplayedObjects(aDisplayed);
+ AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
+ Handle(AIS_Shape) anAISShape;
+ for(;anIObjects.More();anIObjects.Next()) {
+ anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
+ if (!anAISShape.IsNull()) {
+ if (anAISShape->Shape().IsSame(Shape)) break;
+ anAISShape.Nullify();
+ }
+ }
+ if (!anAISShape.IsNull()) {
+ if (ic->IsDisplayed(anAISShape)) ic->Erase(anAISShape);
+ }
+ }
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ }
+// QAD_Viewer3d* v3d = GeomGUI->myActiveStudy->getActiveStudyFrame()->getViewerOCC();
+// Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+// myContext->EraseSelected();
+ }
+
+ Sel->ClearIObjects();
+ break;
+ }
+
+ case 9023 : // DISPLAY ONLY - OBJBROSER POPUP
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
+ GeomGUI->OnVTKDisplayOnly();
+ else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC )
+ GeomGUI->OnDisplayOnly();
+ break;
+ }
+
+ case 9024 : // OPEN - OBJBROSER POPUP
+ {
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+ for(;It.More();It.Next()) {
+ anIObject = It.Value();
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( anIObject->getEntry() );
+ SALOMEDS::AttributePersistentRef_var aPersist;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ // this SObject may be GEOM module root SObject
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ SALOMEDS::GenericAttribute_var anAttr;
+ bool useSubItems = false;
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
+ useSubItems = true;
+ obj = subobj;
+ }
+ else anIter->Next();
+ }
+ obj->FindAttribute(anAttr, "AttributePersistentRef");
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ if (!obj->FindAttribute(anAttr, "AttributeIOR") &&
+ obj->FindAttribute(anAttr, "AttributePersistentRef")) {
+ // load
+ Engines::Component_var comp = GeomGUI->myDesktop->getEngine("FactoryServer","Geometry");
+ if (!CORBA::is_nil(comp)) {
+ SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
+
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = GeomGUI->myActiveStudy->getStudyDocument()->NewBuilder();
+ aStudyBuilder->LoadWith(GeomGUI->myActiveStudy->getStudyDocument()->FindComponent("GEOM"),driver);
+
+ } else {
+ MESSAGE("Component is null");
+ }
+ }
+ if (useSubItems) {
+ anIter->Next();
+ obj = anIter->Value();
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ break;
+ }
+
+ case 10000 : // SKETCH Segment
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchSegment();
+ break;
+ }
+ case 10001 : // SKETCH Arc
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchArc();
+ break;
+ }
+ case 10002 : // SKETCH Set Angle
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchSetAngle();
+ break;
+ }
+ case 10003 : // SKETCH Set X
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchSetx();
+ break;
+ }
+ case 10004 : // SKETCH Set Y
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchSety();
+ break;
+ }
+ case 10006 : // SKETCH Delete
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchDelete();
+ break;
+ }
+ case 10007 : // SKETCH End
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchEnd();
+ break;
+ }
+ case 10008 : // SKETCH Close
+ {
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ break;
+ GeomGUI->OnSketchClose();
+ break;
+ }
+ case 10010 : // SKETCH OptionsOnofflengthdimension
+ {
+ GeomGUI->OnSketchOptionsOnofflengthdimension();
+ break;
+ }
+ case 10011 : // SKETCH OptionsOnoffangledimension
+ {
+ GeomGUI->OnSketchOptionsOnoffangledimension();
+ break;
+ }
+ case 10012 : // SKETCH OptionsOnoffradiusdimension
+ {
+ GeomGUI->OnSketchOptionsOnoffradiusdimension();
+ break;
+ }
+ case 10013 : // SKETCH OptionsOnoffxdimension
+ {
+ GeomGUI->OnSketchOptionsOnoffxdimension();
+ break;
+ }
+ case 10014 : // SKETCH OptionsOnoffydimension
+ {
+ GeomGUI->OnSketchOptionsOnoffydimension();
+ break;
+ }
+
+ default:
+ {
+ parent->putInfo( tr("GEOM_PRP_COMMAND").arg(theCommandID ) );
+ break;
+ }
+ }
+
+ return true ;
+}
+
+//=======================================================================
+// function : ConvertClickToPoint()
+// purpose : Returns the point clicked in 3D view
+//=======================================================================
+gp_Pnt GeometryGUI::ConvertClickToPoint( Standard_Real x,
+ Standard_Real y,
+ Handle(V3d_View) aView )
+{
+ V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
+ aView->Eye(XEye, YEye, ZEye);
+
+ aView->At(XAt, YAt, ZAt);
+ gp_Pnt EyePoint(XEye, YEye, ZEye);
+ gp_Pnt AtPoint(XAt, YAt, ZAt);
+
+ gp_Vec EyeVector(EyePoint, AtPoint);
+ gp_Dir EyeDir(EyeVector);
+
+ gp_Pln PlaneOfTheView = gp_Pln(AtPoint,EyeDir);
+ Standard_Real X, Y, Z;
+ aView->Convert(x, y, X, Y, Z);
+ gp_Pnt ConvertedPoint(X, Y, Z);
+
+ gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint);
+ gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(),
+ ConvertedPointOnPlane.Y(),
+ PlaneOfTheView);
+ return ResultPoint;
+}
+
+
+
+
+//==================================================================================
+// function : 0nMousePress()
+// purpose : [static] manage mouse events
+//==================================================================================
+bool GeometryGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ MESSAGE ( "GeometryGUI::OnMousePress")
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ return false;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
+
+ /* Get the clicked or selected point */
+ gp_Pnt thePoint;
+
+ if ( GeomGUI->myState == CURRENT_SKETCH) {
+ GeomGUI->mySketcher.ValidateEdge();
+ if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(313,&pp);
+ pp->setItemEnabled( 313, true); // SKETCH CONTRAINTS
+ }
+ } else if( GeomGUI->myState == POINT_METHOD ) {
+
+ GeomGUI->EraseSimulationShape() ;
+ GeometryGUI_PointDlg *DialogPt = (GeometryGUI_PointDlg*)(GeomGUI->myActiveDialogBox) ;
+
+ if ( DialogPt->UseLocalContext() ) {
+ ic->InitSelected();
+ if ( pe->state() == Qt::ShiftButton )
+ v3d->getAISSelector()->shiftSelect(); /* Append selection */
+ else
+ v3d->getAISSelector()->select(); /* New selection */
+
+ if ( ic->MoreSelected() ) {
+ thePoint = BRep_Tool::Pnt( TopoDS::Vertex(ic->SelectedShape()) );
+ }
+ else
+ thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
+ }
+ else
+ thePoint = ConvertClickToPoint(pe->x(), pe->y(), ( (OCCViewer_ViewPort3d*)vp)->getView() );
+
+ if( DialogPt != 0 ) {
+ DialogPt->PointIntoCoordinates(thePoint, true) ; /* display point */
+ }
+ else {
+ // MESSAGE ("On Mouse Press : myActiveDialogBox is null" << endl) ;
+ GeomGUI->myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ }
+ }
+
+ return false ;
+}
+
+
+//=======================================================================
+// function : OnMouseMove()
+// purpose : [static] manage mouse events
+//=======================================================================
+bool GeometryGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ return false;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ OCCViewer_ViewPort* vp = ((OCCViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getViewPort();
+
+ if ( GeomGUI->myState == CURRENT_SKETCH)
+ GeomGUI->mySketcher.MakeCurrentEdge( pe->x(), pe->y(), ((OCCViewer_ViewPort3d*)vp)->getView() );
+
+ return true;
+}
+
+
+//================================================================================
+// function : SetDisplayedObjectList()
+// purpose :
+//================================================================================
+void GeometryGUI::SetDisplayedObjectList()
+{
+ if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ return;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ ListDisplayedObject.Clear();
+
+ Handle (AIS_InteractiveContext) aContext = v3d->getAISContext();
+ aContext->DisplayedObjects( ListDisplayedObject );
+}
+
+
+
+//=====================================================================================
+// function : OnDisplayAll()
+// purpose :
+//=====================================================================================
+void GeometryGUI::OnDisplayAll(bool onlyPreviousDisplayedObject)
+{
+ if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ return;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+
+ myContext->Display(v3d->getTrihedron());
+
+ if ( !onlyPreviousDisplayedObject ) {
+ AIS_ListOfInteractive List1;
+ myContext->ObjectsInCollector(List1);
+ AIS_ListIteratorOfListOfInteractive ite1(List1);
+ while (ite1.More()) {
+ if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
+ if ( aSh->hasIO() ) {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
+ if ( v3d->isInViewer(GIO, true) ) {
+ myContext->Display(aSh);
+ }
+ }
+ }
+ ite1.Next();
+ }
+ } else {
+ AIS_ListIteratorOfListOfInteractive ite(ListDisplayedObject);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ if ( aSh->hasIO() ) {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
+ if ( v3d->isInViewer(GIO,true) ) {
+ myContext->Display(aSh);
+ }
+ }
+ }
+ ite.Next();
+ }
+ }
+}
+
+
+
+
+//=====================================================================================
+// function : OnVTKDisplayOnly()
+// purpose :
+//=====================================================================================
+void GeometryGUI::OnVTKDisplayOnly()
+{
+
+ // Erase all not selected actors
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ vtkRenderer* aren = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theActors = aren->GetActors();
+ theActors->InitTraversal();
+ vtkActor *ac = theActors->GetNextActor();
+ while(!(ac==NULL)) {
+ if ( ac->IsA("SALOME_Actor") ) {
+ SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+ if(!anActor->isHighlighted()) anActor->VisibilityOff();
+ }
+ ac = theActors->GetNextActor();
+ }
+
+ // Display selection
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ if(myRenderInter->isInViewer(IObject)) {
+ myRenderInter->Display(IObject);
+ }
+ else {
+ // Create new actor
+ if ( !obj->_is_nil() ) {
+ if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
+ break;
+ // If selected object contains displayable subobjects, then do nothing
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ if (CORBA::is_nil(aShape)) continue;
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+
+ vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ int themode = myRenderInter->GetDisplayMode();
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ GActor->setIO( IObject );
+ GActor->setName( IObject->getName() );
+
+ theRenderer->AddActor(GActor);
+ vtkRenderWindow *renWin
+ = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->GetRenderWindow();
+ renWin->Render();
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ }
+ }
+ }
+ GeomGUI->myActiveStudy->updateObjBrowser( true );
+ QApplication::restoreOverrideCursor();
+}
+
+
+
+//=====================================================================================
+// function : OnDisplayOnly()
+// purpose :
+//=====================================================================================
+void GeometryGUI::OnDisplayOnly()
+{
+ if (myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ return;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ if (!ic->IsSelected( aSh )) {
+ ic->Erase( aSh, Standard_True, Standard_True );
+ }
+ }
+ ite.Next();
+ }
+
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+
+ SALOME_ListIteratorOfListIO It1( Sel->StoredIObjects() );
+ for(;It1.More();It1.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It1.Value();
+
+
+ SALOMEDS::SObject_var fatherSF =
+ aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
+ if ( v3d->isInViewer( IObject, true ) ) {
+ AIS_ListOfInteractive List1;
+ ic->ObjectsInCollector(List1);
+ AIS_ListIteratorOfListOfInteractive ite1(List1);
+ while (ite1.More()) {
+ if (ite1.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite1.Value());
+ if ( aSh->hasIO() ) {
+ Handle(GEOM_InteractiveObject) GIO = Handle(GEOM_InteractiveObject)::DownCast(aSh->getIO());
+ if ( IObject->isSame( GIO ) ) {
+ ic->Display(aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ break;
+ }
+ }
+ }
+ ite1.Next();
+ }
+ } else {
+ if ( IObject->hasEntry() ) {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !obj->_is_nil() ) {
+ if (obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
+ if (CORBA::is_nil(aShape)) continue;
+ TopoDS_Shape Shape = ShapeReader.GetShape(myComponentGeom, aShape);
+
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+ }
+
+ Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
+
+ IO->setEntry(obj->GetID());
+ aSh->setIO( IO );
+ aSh->setName( aName->Value() );
+ ic->Display (aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//===============================================================================
+// function : OnEditDelete()
+// purpose :
+//===============================================================================
+void GeometryGUI::OnEditDelete()
+{
+ if ( QAD_MessageBox::warn2
+ ( QAD_Application::getDesktop(),
+ tr ("GEOM_WRN_WARNING"),
+ tr ("GEOM_REALLY_DELETE"),
+ tr ("GEOM_BUT_YES"), tr ("GEOM_BUT_NO"), 1, 0, 0) != 1 )
+ return;
+
+ int nbSf = myActiveStudy->getStudyFramesCount();
+
+ Standard_Boolean found;
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ for(;It.More();It.Next()) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ if ( IObject->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
+
+ /* Erase child graphical objects */
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO);
+ for (; it->More();it->Next()) {
+ SALOMEDS::SObject_var CSO= it->Value();
+ if (CSO->FindAttribute(anAttr, "AttributeIOR") ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ /* Delete child(s) shape in Client : */
+ const TCollection_AsciiString ASCior(anIOR->Value()) ;
+ ShapeReader.RemoveShapeFromBuffer( ASCior ) ;
+
+ for ( int i = 0; i < nbSf; i++ ) {
+ QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
+ if ( sf->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+ Handle(GEOM_AISShape) Result = GeomGUI->ConvertIORinGEOMAISShape( anIOR->Value(), found );
+ if ( found )
+ myContext->Erase( Result, true, false );
+ } else if ( sf->getTypeView() == VIEW_VTK ) {
+ //vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer();
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
+ GEOM_Actor* ac = GeomGUI->ConvertIORinGEOMActor( anIOR->Value(), found );
+ if ( found ) {
+ //Renderer->RemoveActor(ac);
+ if ( ac->hasIO() )
+ myRenderInter->Remove( ac->getIO() );
+ }
+ }
+ }
+ }
+ }
+
+ /* Erase main graphical object */
+ for ( int i = 0; i < nbSf; i++ ) {
+ QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i);
+ if ( sf->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+ Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape( IObject, found );
+ if ( found )
+ myContext->Erase( Result, true, false );
+ } else if ( sf->getTypeView() == VIEW_VTK ) {
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor();
+ myRenderInter->Remove( IObject );
+ }
+ }
+
+ /* Delete main shape in Client : */
+ if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ const TCollection_AsciiString ASCIor(anIOR->Value()) ;
+ ShapeReader.RemoveShapeFromBuffer( ASCIor ) ;
+ }
+
+ /* Erase objects in Study */
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() );
+ if ( !obj->_is_nil() ) {
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+ aStudyBuilder->RemoveObject(obj);
+ op->finish();
+ }
+
+ } /* IObject->hasEntry() */
+ } /* more/next */
+
+ /* Clear any previous selection */
+ Sel->ClearIObjects() ;
+ myActiveStudy->updateObjBrowser();
+}
+
+
+//==============================================================================
+// function : OnEditCopy()
+// purpose :
+//==============================================================================
+void GeometryGUI::OnEditCopy()
+{
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
+
+ const SALOME_ListIO& List = Sel->StoredIObjects();
+
+ GeomGUI->ConvertListOfIOInListOfIOR( List, listIOR);
+
+ Sel->ClearIObjects();
+
+ for (unsigned int ind = 0; ind < listIOR->length();ind++) {
+ GEOM::GEOM_Shape_var aShapeInit = myComponentGeom->GetIORFromString(listIOR[ind]);
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCopy(aShapeInit) ;
+ result->NameType( aShapeInit->NameType() );
+ this->Display(result);
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+
+ myDesktop->putInfo(tr("GEOM_PRP_READY"));
+}
+
+
+
+//=====================================================================================
+// function : OnKeyPress()
+// purpose : [static]
+//=====================================================================================
+bool GeometryGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
+ return false;
+
+ return true ;
+}
+
+
+
+//=====================================================================================
+// function : DisplaySimulationShape()
+// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
+//=====================================================================================
+void GeometryGUI::DisplaySimulationShape(const TopoDS_Shape& S)
+{
+ if( S.IsNull() )
+ return ;
+
+ //NRI DEBUG : 14/02/2002
+ if ( myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC )
+ return ;
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ try {
+ /* erase any previous */
+ ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
+ ic->ClearPrs( this->mySimulationShape );
+ this->mySimulationShape = new AIS_Shape( TopoDS_Shape() ) ;
+ this->mySimulationShape->Set( S ) ;
+ this->mySimulationShape->SetColor(Quantity_NOC_VIOLET) ;
+ ic->Deactivate( this->mySimulationShape );
+ ic->Display( this->mySimulationShape, Standard_False );
+ ic->UpdateCurrentViewer();
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in GeometryGUI::DisplaySimulationShape " ) ;
+ }
+ this->mySimulationShape->UnsetColor() ;
+ return ;
+}
+
+
+
+//==================================================================================
+// function : EraseSimulationShape()
+// purpose : Clears the display of 'mySimulationShape' a pure graphical shape
+//==================================================================================
+void GeometryGUI::EraseSimulationShape()
+{
+ int count = myActiveStudy->getStudyFramesCount();
+ for ( int i = 0; i < count; i++ ) {
+ if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ ic->Erase( this->mySimulationShape, Standard_True, Standard_False );
+ ic->ClearPrs( this->mySimulationShape );
+ ic->UpdateCurrentViewer();
+
+ } else if (myActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK ) { // VTK
+ }
+ }
+ // MESSAGE ( " GeometryGUI::EraseSimulationShape done. " )
+}
+
+
+
+//=====================================================================================
+// function : Import
+// purpose : BRep, Iges, Step
+//=====================================================================================
+bool GeometryGUI::Import( )
+{
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ GEOM::GEOM_Shape_var aShape;
+ QString file;
+ QStringList filtersList ;
+
+ switch ( GeomGUI->myState )
+ {
+ case 111 : // Import BREP
+ {
+ filtersList.append( tr("GEOM_MEN_IMPORT_BREP") );
+ filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
+
+ file = QAD_FileDlg::getFileName(myDesktop,
+ "",
+ filtersList,
+ tr("GEOM_MEN_IMPORT"),
+ true);
+ if ( !file.isEmpty() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try {
+ aShape = myComponentGeom->ImportBREP( file.latin1() );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ break;
+ }
+ case 112 : // Import IGES
+ {
+ filtersList.append( tr("GEOM_MEN_IMPORT_IGES") ) ;
+ filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
+
+ file = QAD_FileDlg::getFileName(myDesktop,
+ "",
+ filtersList,
+ tr("GEOM_MEN_IMPORT"),
+ true);
+ if ( !file.isEmpty() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try {
+ aShape = myComponentGeom->ImportIGES( file.latin1() );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ break;
+ }
+ case 113 : // Import STEP
+ {
+ filtersList.append( tr("GEOM_MEN_IMPORT_STEP") ) ;
+ filtersList.append( tr("GEOM_MEN_ALL_FILES") ) ;
+
+ file = QAD_FileDlg::getFileName(myDesktop,
+ "",
+ filtersList,
+ tr("GEOM_MEN_IMPORT"),
+ true);
+ if ( !file.isEmpty() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try {
+ aShape = myComponentGeom->ImportSTEP( file.latin1() );
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ break;
+ }
+ }
+
+ if ( !file.isEmpty() ) {
+ myDesktop->putInfo( tr("GEOM_PRP_LOADING").arg(QAD_Tools::getFileNameFromPath( file )) );
+
+ SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID( myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributePixMap_var aPixmap;
+ int aLocked = false;
+ if (father->_is_nil()) {
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+ aLocked = aStudy->GetProperties()->IsLocked();
+ if (aLocked) aStudy->GetProperties()->SetLocked(false);
+ father = aStudyBuilder->NewComponent("GEOM");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
+ if (aLocked) aStudy->GetProperties()->SetLocked(true);
+ op->finish();
+ }
+// if (aLocked) return false;
+ aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
+ father->ComponentIOR( Fatherior );
+
+ QString nameShape = QAD_Tools::getFileNameFromPath(file,false) + QString("_%1").arg(this->myNbGeom++);
+
+ if ( Display ( aShape, strdup(nameShape.latin1())) ) {
+ myActiveStudy->setMessage( tr("GEOM_INF_LOADED").arg(QAD_Tools::getFileNameFromPath( file )) );
+ myDesktop->putInfo( tr("GEOM_PRP_READY"));
+ }
+ }
+ QApplication::restoreOverrideCursor();
+ return true ;
+}
+
+
+//=====================================================================================
+// function : Export
+// purpose : BRep, Iges, Step
+//=====================================================================================
+bool GeometryGUI::Export( )
+{
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ GEOM::GEOM_Shape_var aShape;
+
+ static QString filters[] = { tr("GEOM_MEN_IMPORT_BREP"),
+ tr("GEOM_MEN_IMPORT_IGES"),
+ tr("GEOM_MEN_IMPORT_STEP") };
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( this->myActiveStudy->getSelection() );
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+
+ switch ( GeomGUI->myState )
+ {
+ case 121 :
+ {
+ for(;It.More();It.Next()) {
+ QApplication::restoreOverrideCursor();
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
+ // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
+ if ( found ) {
+ QString file = QAD_FileDlg::getFileName(myDesktop,
+ QString( IObject->getName() ) + ".brep",
+ tr("GEOM_MEN_IMPORT_BREP"),
+ tr("GEOM_MEN_EXPORT"),
+ false);
+ if ( !file.isEmpty() && !aShape->_is_nil() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ // Standard_Boolean result = BRepTools::Write(Shape->Shape(), strdup(file.latin1()) );
+ try {
+ GeomGUI->myComponentGeom->ExportBREP(strdup( file.latin1()), aShape);
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ }
+ }
+ }
+ break;
+ }
+ case 122 :
+ {
+ for(;It.More();It.Next()) {
+ QApplication::restoreOverrideCursor();
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
+ // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
+ if ( found ) {
+ QString file = QAD_FileDlg::getFileName(myDesktop,
+ QString( IObject->getName() ) + ".igs",
+ tr("GEOM_MEN_IMPORT_IGES"),
+ tr("GEOM_MEN_EXPORT"),
+ false);
+ if ( !file.isEmpty() && !aShape->_is_nil() ) {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try {
+ GeomGUI->myComponentGeom->ExportIGES(strdup( file.latin1()), aShape);
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+// //VRV: OCC 4.0 migration
+// IGESControl_Controller::Init();
+// IGESControl_Writer ICW (Interface_Static::CVal("XSTEP.iges.unit"),
+// Interface_Static::IVal("XSTEP.iges.writebrep.mode"));
+// //VRV: OCC 4.0 migration
+
+// ICW.AddShape (Shape->Shape());
+// ICW.ComputeModel();
+// Standard_Boolean result = ICW.Write( strdup(file.latin1()) );
+ }
+ }
+ }
+ break;
+ }
+
+ case 123 :
+ {
+// bool test = false ;
+// IFSelect_ReturnStatus status ;
+// //VRV: OCC 4.0 migration
+// STEPControl_Writer aWriter;
+// //VRV: OCC 4.0 migration
+ QString file;
+
+ for( ; It.More(); It.Next() ) {
+// GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
+ QApplication::restoreOverrideCursor();
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ GEOM::GEOM_Shape_var aShape = GeomGUI->ConvertIOinGEOMShape(IObject, found);
+ // Handle(GEOM_AISShape) Shape = ConvertIOinGEOMAISShape(IObject, found, true);
+ if ( found ) {
+ file = QAD_FileDlg::getFileName(myDesktop,
+ QString( IObject->getName() ) + ".stp",
+ tr("GEOM_MEN_IMPORT_STEP"),
+ tr("GEOM_MEN_EXPORT"),
+ false);
+ if ( !file.isEmpty() && !aShape->_is_nil() ) {
+
+ QApplication::setOverrideCursor( Qt::waitCursor ) ;
+ try {
+ GeomGUI->myComponentGeom->ExportSTEP(strdup( file.latin1()), aShape);
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+// //VRV: OCC 4.0 migration
+// status = aWriter.Transfer( Shape->Shape(), STEPControl_ManifoldSolidBrep ) ;
+// //VRV: OCC 4.0 migration
+// test = true ;
+// if ( status != IFSelect_RetDone ) {
+// QApplication::restoreOverrideCursor() ;
+// return false ;
+// }
+ }
+ }
+ }
+// if(test) {
+// status = aWriter.Write( strdup(file.latin1()) ) ;
+// QApplication::restoreOverrideCursor() ;
+// return status ;
+// }
+ break;
+ }
+
+ }
+ QApplication::restoreOverrideCursor() ;
+}
+
+
+//=====================================================================================
+// function : Display()
+// purpose : Displays a CORBA shape
+//=====================================================================================
+bool GeometryGUI::Display( GEOM::GEOM_Shape_ptr aShape,
+ Standard_CString name)
+{
+ // MESSAGE ( "GeometryGUI::Display init ")
+ Handle(GEOM_InteractiveObject) IO;
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ Sel->ClearIObjects();
+
+ if( aShape->_is_nil() ) {
+ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(),
+ tr ("GEOM_WRN_WARNING"),
+ tr ("GEOM_PRP_ABORT"),
+ tr ("GEOM_BUT_OK") );
+ return false ;
+ }
+
+ TopoDS_Shape shape = ShapeReader.GetShape(myComponentGeom, aShape);
+
+ if ( shape.IsNull() )
+ return false;
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributePixMap_var aPixmap;
+
+ SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
+ int aLocked = false;
+ if (father->_is_nil()) {
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+ aLocked = aStudy->GetProperties()->IsLocked();
+ if (aLocked) aStudy->GetProperties()->SetLocked(false);
+ father = aStudyBuilder->NewComponent("GEOM");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
+ myActiveStudy->updateObjBrowser();
+ if (aLocked) aStudy->GetProperties()->SetLocked(true);
+ op->finish();
+ }
+// if (aLocked) return false;
+
+ aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
+ father->ComponentIOR( Fatherior );
+
+ TCollection_AsciiString nameG("");
+ Standard_CString Type;
+ if ( TCollection_AsciiString(name).IsEqual(Standard_CString("")) ) {
+ if ( TCollection_AsciiString(aShape->NameType()).IsEqual(Standard_CString("")) ) {
+ Standard_CString type;
+ GetShapeTypeString(shape,type);
+ aShape->NameType( type );
+ nameG += TCollection_AsciiString( type ) + TCollection_AsciiString("_") +
+ TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
+ } else
+ nameG += TCollection_AsciiString( aShape->NameType()) + TCollection_AsciiString("_") +
+ TCollection_AsciiString( GeomGUI->myNbGeom++ ) + TCollection_AsciiString("\0");
+ } else
+ nameG = TCollection_AsciiString(name);
+
+ // VTK
+ if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ int themode = myRenderInter->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(shape,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+
+ IO = new GEOM_InteractiveObject(aShape->Name(),
+ Fatherior,
+ "GEOM");
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ GActor->setIO( IO );
+ GActor->setName( nameG.ToCString() );
+
+ theRenderer->AddActor(GActor);
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ // OCC
+ else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ Handle(GEOM_AISShape) theResult = new GEOM_AISShape( shape, nameG.ToCString() );
+ theResult->SetShadingColor( myShadingColor );
+ IO = new GEOM_InteractiveObject(aShape->Name(),
+ Fatherior,
+ "GEOM");
+ theResult->setIO( IO );
+ theResult->setName( nameG.ToCString() );
+
+ /* Precaution : close any local context to permit the display */
+ if ( ic->HasOpenedContext() ) {
+ ic->CloseAllContexts();
+ }
+
+// if(isInfinite)
+// theResult->SetInfiniteState() ;
+
+ ic->Display(theResult);
+ }
+
+ Sel->AddIObject( IO, false );
+ myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint();
+ if ( Settings_AddInStudy )
+ GeomGUI->AddInStudy( false, IO );
+
+ return true;
+}
+
+
+//=====================================================================================
+// function : AddInStudy()
+// purpose : anIOShape or a selected shape
+//=====================================================================================
+bool GeometryGUI::AddInStudy( bool selection,
+ const Handle(SALOME_InteractiveObject)& anIO)
+{
+ SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
+ if ( !( !Settings_AddInStudy || selection ) ) {
+ Sel->ClearIObjects();
+ }
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributePixMap_var aPixmap;
+ SALOMEDS::AttributeIOR_var anIOR;
+ SALOMEDS::AttributeSelectable_var aSelAttr;
+
+ SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
+ int aLocked = false;
+ if (father->_is_nil()) {
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+ aLocked = aStudy->GetProperties()->IsLocked();
+ if (aLocked) aStudy->GetProperties()->SetLocked(false);
+ father = aStudyBuilder->NewComponent("GEOM");
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue( tr("GEOM_MEN_COMPONENT") );
+ anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_Geometry" );
+ if (aLocked) aStudy->GetProperties()->SetLocked(true);
+ op->finish();
+ }
+// if (aLocked) return false;
+
+ aStudyBuilder->DefineComponentInstance( father, myComponentGeom );
+ father->ComponentIOR( Fatherior );
+
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(myActiveStudy->getActiveStudyFrame()->entry());
+
+ Handle(GEOM_AISShape) GAISShape;
+ GEOM_Actor* GActor;
+ Handle(GEOM_InteractiveObject) GIO;
+ bool found = false;
+
+ // VTK
+ if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ vtkRenderer *Renderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+
+ vtkActorCollection* theActors = Renderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor *ac = theActors->GetNextActor();
+ while(!(ac==NULL)) {
+ if ( ac->IsA("GEOM_Actor") ) {
+ GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( ac );
+ if ( anActor->hasIO() ) {
+ Handle(SALOME_InteractiveObject) IO = anActor->getIO();
+ if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
+ if ( anIO->isSame( GIO ) ) {
+ found = true;
+ GActor = anActor;
+ break;
+ }
+ }
+ }
+ }
+ ac = theActors->GetNextActor();
+ }
+
+ if ( !found )
+ return false;
+ }
+ // OCC
+ else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ AIS_ListOfInteractive List;
+ ic->DisplayedObjects(List);
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ while (ite.More()) {
+ if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
+ if ( aSh->hasIO() ) {
+ Handle(SALOME_InteractiveObject) IO = aSh->getIO();
+ if ( IO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ GIO = Handle(GEOM_InteractiveObject)::DownCast( IO );
+ if ( anIO->isSame( GIO ) ) {
+ found = true;
+ GAISShape = aSh;
+ break;
+ }
+ }
+ }
+ }
+ ite.Next();
+ }
+
+ if ( !found )
+ return false;
+ }
+
+ if ( !Settings_AddInStudy || selection ) {
+ QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), anIO->getName() );
+ if ( !Name.isEmpty() ) {
+ // VTK
+ if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ GActor->setName( strdup(Name.latin1()) );
+ }
+ // OCC
+ else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ GAISShape->setName( strdup(Name.latin1()) );
+ }
+ } else {
+ return false;
+ }
+ }
+
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father);
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GIO->getIOR() );
+
+ /* For the shape inserted into the study we set its field 'studyshapeid' */
+ /* so the shape will contain its corresponding entry in the study Ocaf doc. */
+ aShape->StudyShapeId(newObj->GetID()) ;
+
+ GIO->setEntry(newObj->GetID());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ anIOR->SetValue(aShape->Name());
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+
+ anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ if ( aShape->ShapeType() == GEOM::COMPOUND ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPOUND" );
+ } else if ( aShape->ShapeType() == GEOM::COMPSOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_COMPSOLID" );
+ } else if ( aShape->ShapeType() == GEOM::SOLID ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SOLID" );
+ } else if ( aShape->ShapeType() == GEOM::SHELL ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_SHELL" );
+ } else if ( aShape->ShapeType() == GEOM::FACE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_FACE" );
+ } else if ( aShape->ShapeType() == GEOM::WIRE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_WIRE" );
+ } else if ( aShape->ShapeType() == GEOM::EDGE ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_EDGE" );
+ } else if ( aShape->ShapeType() == GEOM::VERTEX ) {
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_VERTEX" );
+ }
+
+ // VTK
+ if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ GActor->setIO( GIO );
+ aName->SetValue(GActor->getName());
+ }
+ // OCC
+ else if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ GAISShape->setIO( GIO );
+ aName->SetValue(GAISShape->getName());
+ }
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1,newObj);
+
+ GEOM::GEOM_Gen::ListOfIOR_var listIOR = new GEOM::GEOM_Gen::ListOfIOR;
+ listIOR = myComponentGeom->GetReferencedObjects(aShape);
+
+ if (listIOR->length()>0) {
+ SALOMEDS::SObject_var Arguments = aStudyBuilder->NewObject(newObj);
+ anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ aName->SetValue(tr("GEOM_ARGUMENTS"));
+ anAttr = aStudyBuilder->FindOrCreateAttribute(Arguments, "AttributeSelectable");
+ aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr);
+ aSelAttr->SetSelectable(false);
+
+ bool ObjectReferenced = false;
+ for (unsigned int ind = 0; ind < listIOR->length();ind++) {
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(listIOR[ind]);
+
+ if ( !theObj->_is_nil() ) {
+ SALOMEDS::SObject_var RefObject = aStudyBuilder->NewObject(Arguments);
+ aStudyBuilder->Addreference(RefObject, theObj);
+ ObjectReferenced = true;
+ }
+ }
+
+ if ( !ObjectReferenced )
+ aStudyBuilder->RemoveObject(Arguments);
+ }
+
+ op->finish();
+
+
+ if ( !Settings_AddInStudy || selection ) {
+ myActiveStudy->updateObjBrowser();
+ } else {
+ myActiveStudy->updateObjBrowser(false);
+ Sel->AddIObject( GIO );
+ }
+
+ // MESSAGE ( " highlihght done" )
+ return true;
+
+}
+
+
+//=====================================================================================
+// function : GetShapeFromIOR()
+// purpose : exist also as static method !
+//=====================================================================================
+TopoDS_Shape GeometryGUI::GetShapeFromIOR( QString IOR )
+{
+ TopoDS_Shape result;
+ if( IOR.stripWhiteSpace().isEmpty() )
+ return result;
+ ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
+ CORBA::ORB_var& _orb = init.orb() ;
+ CORBA::Object_var obj = _orb->string_to_object( (char*)(IOR.latin1()) );
+ if ( CORBA::is_nil( obj ) )
+ return result;
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( IOR );
+ if (!aShape->_is_nil()) {
+ result = ShapeReader.GetShape( myComponentGeom, aShape );
+ }
+ return result;
+}
+
+
+//=====================================================================================
+// function : SetSettings()
+// purpose : [static]
+//=====================================================================================
+bool GeometryGUI::SetSettings( QAD_Desktop* parent )
+{
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ //DCQ parent->menuBar()->setItemEnabled( 504, false); // CORRECTING
+ //DCQ parent->menuBar()->setItemEnabled( 6062, false); // RADIUS
+ //VSR parent->menuBar()->setItemEnabled( 701, false); // AUTOMATIC COPY
+ parent->menuBar()->setItemEnabled( 313, false); // SKETCH CONTRAINTS
+ parent->menuBar()->setItemEnabled( 3131, false); // SKETCH SET PLAN
+
+ /* Shading Color */
+ QString SCr = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorRed");
+ QString SCg = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorGreen");
+ QString SCb = QAD_CONFIG->getSetting("Geometry:SettingsShadingColorBlue");
+ if( !SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty() )
+ GeomGUI->myShadingColor = Quantity_Color ( SCr.toInt()/255., SCg.toInt()/255., SCb.toInt()/255.,
+ Quantity_TOC_RGB );
+
+ /* Wireframe or Shading */
+ int DisplayMode = 0;
+ if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
+ DisplayMode = ic->DisplayMode();
+ } else if ( parent->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)parent->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ DisplayMode = myRenderInter->GetDisplayMode();
+ }
+
+ if ( DisplayMode == 1 )
+ parent->menuBar()->changeItem(6021, tr("GEOM_MEN_WIREFRAME") );
+ else
+ parent->menuBar()->changeItem(6021, tr("GEOM_MEN_SHADING") );
+
+ /* Copy */
+// QString Copy = QAD_CONFIG->getSetting("Geometry:SettingsCopy");
+// if ( !Copy.isEmpty() ) {
+// Settings_Copy = Copy.toInt();
+// QMenuData* pp;
+// parent->menuBar()->findItem(701,&pp);
+// pp->setItemChecked(701, Settings_Copy);
+// }
+ QMenuData* pp;
+ if ( parent->menuBar()->findItem(701,&pp) )
+ pp->removeItem(701);
+
+ /* Add in Study */
+ QString AddInStudy = QAD_CONFIG->getSetting("Geometry:SettingsAddInStudy");
+ if ( !AddInStudy.isEmpty() )
+ Settings_AddInStudy = AddInStudy.toInt();
+ else
+ Settings_AddInStudy = 1;
+ parent->menuBar()->findItem(702,&pp);
+ pp->setItemChecked(702, Settings_AddInStudy);
+
+ /* step value */
+ QString S = QAD_CONFIG->getSetting( "Geometry:SettingsGeomStep" );
+ if( S.isEmpty() )
+ QAD_CONFIG->addSetting( "Geometry:SettingsGeomStep", "100" );
+
+ /* isos */
+ QAD_Study* ActiveStudy = parent->getActiveStudy();
+ int count = ActiveStudy->getStudyFramesCount();
+
+ bool ViewOCC = false;
+ for ( int i = 0; i < count; i++ ) {
+ if ( ActiveStudy->getStudyFrame(i)->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ QString IsoU = QAD_CONFIG->getSetting("Geometry:SettingsIsoU");
+ QString IsoV = QAD_CONFIG->getSetting("Geometry:SettingsIsoV");
+ if ( !IsoU.isEmpty() )
+ ic->DefaultDrawer()->UIsoAspect()->SetNumber(IsoU.toInt());
+ if ( !IsoV.isEmpty() )
+ ic->DefaultDrawer()->VIsoAspect()->SetNumber(IsoV.toInt());
+
+ ViewOCC = true;
+ }
+ }
+
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+
+ Mb->setItemEnabled( 312, ViewOCC); //Sketch
+ Mb->setItemEnabled( 309, ViewOCC); //SuppressFace
+ Mb->setItemEnabled( 314, ViewOCC); //SuppressHole
+
+ Mb->setItemEnabled( 703, ViewOCC);// ShadingColor Settings
+ Mb->setItemEnabled( 704, ViewOCC);// Isos Settings
+
+ return true;
+}
+
+
+//=====================================================================================
+// function : DefinePopup()
+// purpose : [static]
+//=====================================================================================
+void GeometryGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+{
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+
+ theObject = "";
+ if ( Sel->IObjectCount() == 1 )
+ {
+ Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
+ if (IO->hasEntry())
+ {
+ SALOMEDS::SObject_var sobj = GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry());
+ if (!sobj->_is_nil())
+ {
+ SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
+ if (strcmp(scomp->GetID(), IO->getEntry()) == 0)
+ {
+ // component is selected
+ theObject = "Component";
+ }
+ }
+ }
+ }
+
+ if ( ( theParent.compare("Viewer")==0 ) )
+ {
+ if ( GeomGUI->myState == CURRENT_SKETCH )
+ theContext = "Sketch";
+ else
+ {
+ if ( Sel->IObjectCount() > 0 )
+ theContext = "";
+ else
+ theContext = "NothingSelected";
+ }
+ }
+ else
+ theContext = "";
+
+}
+
+//=====================================================================================
+// function : CustomPopup()
+// purpose : [static]
+//=====================================================================================
+bool GeometryGUI::CustomPopup( QAD_Desktop* parent,
+ QPopupMenu* popup,
+ const QString& theContext,
+ const QString& theParent,
+ const QString& theObject )
+{
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(parent);
+
+ /* Deactivate any non modal dialog box to get the neutral point */
+ GeomGUI->EmitSignalDeactivateDialog() ;
+
+ SALOME_Selection* Sel = SALOME_Selection::Selection( GeomGUI->myActiveStudy->getSelection() );
+ int nbSel = Sel->IObjectCount();
+
+ if ( (nbSel == 0) && ( theContext.compare("Sketch")!=0 ) )
+ return false;
+
+
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC)
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->
+ getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+ if ( theParent.compare("Viewer")==0 )
+ {
+ if ( theContext.compare("Sketch")==0 )
+ {
+ SketchStatus myCS = GeomGUI->mySketcher.GetCurrentStatus();
+ popup->setCheckable(TRUE);
+ if (myCS==SEGMENT)
+ {
+ popup->setItemChecked(10000,true);
+ popup->setItemChecked(10001,false);
+ }
+ else if (myCS==ARC_CHORD)
+ {
+ popup->setItemChecked(10000,false);
+ popup->setItemChecked(10001,true);
+ }
+
+ return true;
+ }
+ else
+ if (theObject.compare("Component") == 0)
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID);
+ return true;
+ }
+ else
+ {
+ QFont f = QApplication::font();
+ f.setBold( TRUE );
+ if (nbSel==1)
+ {
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
+ if ( IObject->hasEntry() )
+ popup->setItemEnabled( 801, false );
+ else
+ popup->setItemEnabled( 801, true );
+
+ if (IObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject)))
+ {
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Result = GeomGUI->ConvertIOinGEOMAISShape(IObject, found, true);
+
+ if ( found )
+ {
+ if ( Result->DisplayMode() == 1 )
+ popup->changeItem(8021, tr("GEOM_MEN_WIREFRAME") );
+ else
+ popup->changeItem(8021, tr("GEOM_MEN_SHADING") );
+ }
+ }
+
+ if ( !(v3d->isInViewer( IObject ) && v3d->isVisible( IObject )) )
+ popup->removeItem(QAD_Erase_Popup_ID);
+ else
+ popup->removeItem(QAD_Display_Popup_ID);
+
+ }
+ else
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID);
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ),
+ QAD_TopLabel_Popup_ID, 0 );
+ popup->setItemEnabled( 801, false );
+ }
+ }
+ return true;
+ }
+ else
+ if ( theParent.compare("ObjectBrowser")==0 )
+ {
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ int id = popup->idAt(0); // separator
+ if (id < 0) popup->removeItem(id);
+
+ // checking for GEOM label in the selected list
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+
+ bool useSubItems = false;
+ bool needOpen = false;
+ bool needDisplay = false;
+ bool needErase = false;
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ for(;It.More();It.Next())
+ {
+ anIObject = It.Value();
+ if (!anIObject->hasEntry())
+ continue;
+
+ if (v3d->isInViewer(anIObject) && v3d->isVisible(anIObject))
+ needErase = true;
+ else
+ needDisplay = true;
+ SALOMEDS::SObject_var obj =
+ GeomGUI->myActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
+ if (!obj->_is_nil())
+ {
+ GEOM::GEOM_Shape_var aShape;
+ if (obj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
+ if (str && strlen(str))
+ aShape = GeomGUI->myComponentGeom-> GetIORFromString(str);
+ }
+ else
+ if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
+ needOpen = true;
+ if (aShape->_is_nil())
+ {
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->
+ getStudyDocument()->NewChildIterator(obj);
+ while (anIter->More())
+ {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
+ {
+ useSubItems = true;
+ needErase = true;
+ needDisplay = true;
+ }
+ else
+ if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
+ {
+ needOpen = true;
+ useSubItems = true;
+ }
+ anIter->Next();
+ }
+ }
+ }
+ }
+ // remove useless popup items
+ if (nbSel != 1) popup->removeItem(901); // rename
+ if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
+ if (!needOpen)
+ {
+ int index = popup->indexOf(9024);
+ popup->removeItem(9024); // open
+ popup->removeItemAt(index); // separator under Open
+
+ if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
+ if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
+ if (!needDisplay && !needErase)
+ {
+ int id = popup->idAt(popup->count()-1); // last item
+ popup->removeItem(id); // separator
+ }
+ }
+ else
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
+ popup->removeItem(QAD_Display_Popup_ID);
+ popup->removeItem(QAD_Erase_Popup_ID);
+ if (nbSel!=1)
+ {
+ int id = popup->idAt(popup->count()-1); // last item
+ popup->removeItem(id); // separator
+ }
+ }
+ return true;
+ }
+ // MESSAGE ( " CUSTOM POPUP VIEWER OCC done. ")
+ }
+ else
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK)
+ {
+ // MESSAGE ( " CUSTOM POPUP VIEWER VTK ")
+ if ( ( theParent.compare("Viewer")==0 ) )
+ {
+
+ popup->setItemEnabled( 8033, false );
+ if (theObject.compare("Component") == 0)
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID);
+ return true;
+ }
+
+ //int id = popup->idAt(0);
+ QFont f = QApplication::font();
+ f.setBold( TRUE );
+
+ if (nbSel==1)
+ {
+ Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), QAD_TopLabel_Popup_ID, 0 );
+ if ( IObject->hasEntry() )
+ {
+ popup->setItemEnabled( 801, false );
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var SO = aStudy->FindObjectID( IObject->getEntry() );
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ if ( !SO->_is_nil() )
+ {
+ if (SO->FindAttribute(anAttr, "AttributeIOR") )
+ {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ Standard_Boolean found;
+ GEOM_Actor* Result = GeomGUI->ConvertIORinGEOMActor(anIOR->Value(), found, true);
+ if ( found )
+ {
+ if ( Result->getDisplayMode() == 1 )
+ popup->changeItem(8021, "Wireframe" );
+ else
+ popup->changeItem(8021, "Shading" );
+
+ if ( !Result->GetVisibility() )
+ popup->removeItem(QAD_Erase_Popup_ID);
+ else
+ popup->removeItem(QAD_Display_Popup_ID);
+ }
+ else
+ popup->removeItem(QAD_Erase_Popup_ID);
+ }
+ }
+ }
+ else
+ popup->setItemEnabled( 801, true );
+ }
+ else
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID);
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ popup->insertItem( new CustomItem ( tr("GEOM_MEN_POPUP_NAME").arg(nbSel), f ), QAD_TopLabel_Popup_ID, 0 );
+ popup->setItemEnabled( 801, false );
+ }
+ return true;
+ }
+ else
+ if ( theParent.compare("ObjectBrowser")==0 )
+ {
+ popup->removeItem(QAD_TopLabel_Popup_ID);
+ int id = popup->idAt(0); // separator
+ if (id < 0) popup->removeItem(id);
+
+ // checking for GEOM label in the selected list
+ SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) anIObject;
+
+ bool useSubItems = false;
+ bool needOpen = false;
+ bool needDisplay = false;
+ bool needErase = false;
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->
+ getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ for(;It.More();It.Next())
+ {
+ anIObject = It.Value();
+ if ( !anIObject->hasEntry() )
+ continue;
+
+ if (myRenderInter->isInViewer(anIObject) && myRenderInter->isVisible(anIObject))
+ needErase = true;
+ else
+ needDisplay = true;
+
+ SALOMEDS::SObject_var obj = GeomGUI->myActiveStudy->getStudyDocument()
+ ->FindObjectID( anIObject->getEntry() );
+ if (!obj->_is_nil()) {
+ GEOM::GEOM_Shape_var aShape;
+ if (obj->FindAttribute(aTmpAttr, "AttributeIOR")){
+ char *str = SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value();
+ if (str && strlen(str))
+ aShape = GeomGUI->myComponentGeom->GetIORFromString(str);
+ }
+ else
+ if (obj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
+ needOpen = true;
+ if (aShape->_is_nil())
+ {
+ SALOMEDS::ChildIterator_var anIter =
+ GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ while (anIter->More())
+ {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR"))
+ {
+ useSubItems = true;
+ needDisplay = true;
+ needErase = true;
+ }
+ else
+ if (subobj->FindAttribute(aTmpAttr, "AttributePersistentRef"))
+ {
+ needOpen = true;
+ useSubItems = true;
+ }
+ anIter->Next();
+ }
+ }
+ }
+ }
+ // remove useless popup items
+ if (nbSel != 1) popup->removeItem(901); // rename
+ if (useSubItems) popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
+ if (!needOpen)
+ {
+ int index = popup->indexOf(9024);
+ popup->removeItem(9024); // open
+ popup->removeItemAt(index); // separator under Open
+
+ if (!needDisplay) popup->removeItem(QAD_Display_Popup_ID);
+ if (!needErase) popup->removeItem(QAD_Erase_Popup_ID);
+ if (!needDisplay && !needErase)
+ {
+ int id = popup->idAt(popup->count()-1); // last item
+ popup->removeItem(id); // separator
+ }
+ }
+ else
+ {
+ popup->removeItem(QAD_DisplayOnly_Popup_ID); // display only
+ popup->removeItem(QAD_Display_Popup_ID);
+ popup->removeItem(QAD_Erase_Popup_ID);
+ if (nbSel!=1)
+ {
+ int id = popup->idAt(popup->count()-1); // last item
+ popup->removeItem(id); // separator
+ }
+ }
+ return true;
+ // MESSAGE ( " CUSTOM POPUP VIEWER VTK done.")
+ }
+ } else
+ { // other viewer types not supported.
+ while (1)
+ {
+ int id = popup->idAt(0);
+ if (id <= QAD_TopLabel_Popup_ID && id != -1)
+ popup->removeItemAt(0);
+ else
+ break;
+ }
+ popup->removeItem(QAD_DisplayOnly_Popup_ID);
+ popup->removeItem(QAD_Display_Popup_ID);
+ popup->removeItem(QAD_Erase_Popup_ID);
+ int id = popup->idAt(popup->count()-1); // last item
+ if (id < 0 && id != -1) popup->removeItem(id); // separator
+ return false;
+ }
+ return false;
+}
+
+void GeometryGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
+{
+ /* Create or retrieve an object GeomGUI */
+ GeometryGUI::GetOrCreateGeometryGUI(QAD_Application::getDesktop());
+
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ OCCViewer_Viewer3d* v3d;
+ Handle(AIS_InteractiveContext) ic;
+ vtkRenderer* Renderer;
+
+ if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ v3d = ((OCCViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ ic = v3d->getAISContext();
+ } else if ( GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ Renderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ } else
+ return;
+
+ if (theIO.IsNull())
+ MESSAGE("BuildPresentation(): null SALOME_InteractiveObject passed")
+
+ if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+
+ SALOMEDS::SObject_var fatherSF =
+ aStudy->FindObjectID(GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
+
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
+
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ if(myRenderInter->isInViewer(theIO)) {
+ myRenderInter->Display(theIO, false);
+ }
+ else {
+ // Create new actor
+ if ( !obj->_is_nil() ) {
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ // this SObject may be GEOM module root SObject
+
+ bool useSubItems = false;
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ } else anIter->Next();
+ }
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+
+ vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)GeomGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
+ vtkActorCollection* theAllActors = theRenderer->GetActors();
+ theAllActors->InitTraversal();
+ vtkActor* actor = (vtkActor*)theAllActors->GetNextActor();
+ Handle(SALOME_InteractiveObject) anIObj;
+ // don't create new study object if it already exists
+ bool isDisplayed = false;
+ while(!(actor==NULL)) {
+ SALOME_Actor* Gactor = SALOME_Actor::SafeDownCast(actor);
+ if (Gactor!=NULL) {
+ if (Gactor->hasIO()) {
+ if (strcmp(Gactor->getIO()->getEntry(),obj->GetID())==0) {
+ isDisplayed = true;
+ anIObj = Gactor->getIO();
+ if (!anIObj.IsNull()) myRenderInter->Display(anIObj, false);
+ }
+ }
+ }
+ actor=(vtkActor*)(theAllActors->GetNextActor());
+ }
+ if (!isDisplayed) {
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+
+ vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
+ int themode = myRenderInter->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(), Fatherior,"GEOM");
+ IO->setEntry(obj->GetID());
+ GActor->setIO( IO );
+ GActor->setName( theIO->getName() );
+
+ theRenderer->AddActor(GActor);
+ // renWin->Render();
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ }
+ // next item iteration
+ if (useSubItems) {
+ anIter->Next();
+ anAttr = SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ // No viewer update should be done here!
+ //myRenderInter->Render();
+ //GeomGUI->myActiveStudy->updateObjBrowser( true );
+ } else if (GeomGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ SALOMEDS::SObject_var fatherSF =
+ aStudy->FindObjectID( GeomGUI->myActiveStudy->getActiveStudyFrame()->entry());
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+
+ if ( v3d->isInViewer( theIO, true ) ) {
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) aSh = GeomGUI->ConvertIOinGEOMAISShape( theIO, found, true );
+ if ( found ) {
+ ic->Display(aSh, false);
+ ic->AddOrRemoveCurrentObject(aSh, false);
+ }
+
+ } else {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( theIO->getEntry() );
+ if ( !obj->_is_nil() ) {
+ MESSAGE("BuildPresentation(): SObject not null")
+ if ( obj->FindAttribute(anAttr, "AttributeIOR")) {
+ MESSAGE("BuildPresentation(): SObject has IOR")
+ // this SObject may be GEOM module root SObject
+
+ bool useSubItems = false;
+ SALOMEDS::ChildIterator_var anIter = GeomGUI->myActiveStudy->getStudyDocument()->NewChildIterator(obj);
+ if (GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value())->_is_nil()) {
+ while (anIter->More() && !useSubItems) {
+ SALOMEDS::SObject_var subobj = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttr;
+ if (subobj->FindAttribute(aTmpAttr, "AttributeIOR")) {
+ if (!GeomGUI->myComponentGeom->GetIORFromString(SALOMEDS::AttributeIOR::_narrow(aTmpAttr)->Value())->_is_nil()) {
+ anAttr = aTmpAttr;
+ obj = subobj;
+ useSubItems = true;
+ } else anIter->Next();
+ } else anIter->Next();
+ }
+ }
+
+ while(useSubItems?anIter->More():!anAttr->_is_nil()) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = GeomGUI->myComponentGeom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(GeomGUI->myComponentGeom,aShape);
+ if (Shape.IsNull())
+ MESSAGE("BuildPresentation(): TopoDS_Shape is null!")
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ MESSAGE("BuildPresentation(): SObject has Name")
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ // searchin for already displayed objects with the same shape
+ AIS_ListOfInteractive aDisplayed;
+ ic->DisplayedObjects(aDisplayed);
+ AIS_ListIteratorOfListOfInteractive anIObjects(aDisplayed);
+ Handle(AIS_Shape) anAISShape;
+ for(;anIObjects.More();anIObjects.Next()) {
+ anAISShape = Handle(AIS_Shape)::DownCast(anIObjects.Value());
+ if (!anAISShape.IsNull()) {
+ if (anAISShape->Shape().IsSame(Shape)) break;
+ anAISShape.Nullify();
+ }
+ }
+ if (!anAISShape.IsNull()) {
+ if (!ic->IsDisplayed(anAISShape)) ic->Display(anAISShape, false);
+ } else {
+ if (!useSubItems) {
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( GeomGUI->myActiveStudy );
+ op->start();
+ if (fatherSF->_is_nil())
+ MESSAGE("BuildPresentation(): fatherSF is nil!")
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+ }
+ Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
+ aSh->SetShadingColor( GeomGUI->myShadingColor );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
+ Fatherior,
+ "GEOM");
+ IO->setEntry(obj->GetID());
+ aSh->setIO( IO );
+ aSh->setName( aName->Value() );
+ ic->Display (aSh, false);
+ if (!useSubItems) ic->AddOrRemoveCurrentObject(aSh, false);
+ }
+ }
+ // next item iteration
+ if (useSubItems) {
+ anIter->Next();
+ anAttr=SALOMEDS::GenericAttribute::_nil();
+ while (anIter->More() && anAttr->_is_nil()) {
+ SALOMEDS::SObject_var subobject = anIter->Value();
+ SALOMEDS::GenericAttribute_var aTmpAttribute;
+ if (subobject->FindAttribute(aTmpAttribute, "AttributeIOR")) {
+ anAttr = aTmpAttribute;
+ obj = subobject;
+ } else anIter->Next();
+ }
+ } else
+ anAttr = SALOMEDS::GenericAttribute::_nil();
+ }
+ }
+ }
+ }
+ // No viewer update should be done here!
+ //GeomGUI->myActiveStudy->updateObjBrowser( true );
+ //ic->UpdateCurrentViewer();
+ }
+}
+
+//=======================================================================
+// function : Parameter()
+// purpose : return a parameter (float) from a dialog box
+//
+// avalue1 : is a float or integer used as a default value displayed
+// aTitle1 : is the title for aValue1
+// aTitle : is the main title
+// bottom : maximum value to be entered
+// top : minimum value to be entered
+// decimals : number of decimals
+//=======================================================================
+double GeometryGUI::Parameter( Standard_Boolean& res,
+ const char* aValue1,
+ const char* aTitle1,
+ const char* aTitle,
+ const double bottom,
+ const double top,
+ const int decimals )
+{
+ GeometryGUI_aParameterDlg * Dialog =
+ new GeometryGUI_aParameterDlg(aValue1,
+ aTitle1,
+ QAD_Application::getDesktop(),
+ aTitle,
+ TRUE,
+ 0,
+ bottom,
+ top,
+ decimals) ;
+ int r = Dialog->exec() ;
+ float X = 0.0 ;
+ if ( r == QDialog::Accepted ) {
+ res = Standard_True;
+ X = Dialog->getValue();
+ } else
+ res = Standard_False;
+ delete Dialog;
+ return X;
+}
+
+
+//=======================================================================
+// function : OnSketchSegment()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchSegment()
+{
+ this->mySketcher.ChangeMode(SEGMENT);
+}
+
+
+//=======================================================================
+// function : OnSketchArc()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchArc()
+{
+ this->mySketcher.ChangeMode(ARC_CHORD);
+}
+
+//=======================================================================
+// function : OnSketchSetAngle()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchSetAngle()
+{
+ Standard_Real anAngle = this->mySketcher.GetSegmentAngle()/PI180;
+ Sketch::fitInResol(anAngle);
+ Standard_Boolean res = false ;
+ QString Value = QString("%1").arg( anAngle );
+ anAngle = Parameter(res, Value, tr("GEOM_MEN_ANGLE"), tr("GEOM_MEN_ENTER_ANGLE"), -180.0, +180.0, 6 )*PI180 ;
+
+ if( res ) {
+ this->mySketcher.SetSegmentAngle(anAngle);
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(3133,&pp);
+ pp->setItemChecked(3133,false);
+ item = Mb->findItem(3134,&pp);
+ pp->setItemChecked(3134,false);
+ }
+
+}
+
+
+//=======================================================================
+// function : OnSketchSetx()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchSetx()
+{
+ Standard_Boolean res = false;
+ double X = Parameter( res,
+ "0.",
+ tr("GEOM_MEN_X"),
+ tr("GEOM_MEN_SKETCHER_X"),
+ 2.0 * Precision::Confusion(),
+ 1E6,
+ 6 ) ;
+ if (res)
+ this->mySketcher.SetXDimension(X);
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(3133,&pp);
+ pp->setItemChecked(3133,false);
+ item = Mb->findItem(3134,&pp);
+ pp->setItemChecked(3134,false);
+}
+
+//=======================================================================
+// function : OnSketchSety()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchSety()
+{
+ Standard_Boolean res = false;
+ double Y = Parameter( res,
+ "0.",
+ tr("GEOM_MEN_Y"),
+ tr("GEOM_MEN_SKETCHER_Y"),
+ 2.0 * Precision::Confusion(),
+ 1E6,
+ 6 ) ;
+ if (res)
+ this->mySketcher.SetYDimension(Y);
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(3133,&pp);
+ pp->setItemChecked(3133,false);
+ item = Mb->findItem(3134,&pp);
+ pp->setItemChecked(3134,false);
+}
+
+
+//=======================================================================
+// function : OnSketchDelete()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchDelete()
+{
+ if (GeomGUI->mySketcher.GetmyEdgesNumber() == 1 ) {
+ QMenuBar* Mb = GeomGUI->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(313,&pp);
+ pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+ }
+
+ if (this->mySketcher.Delete())
+ GeomGUI->ResetState();
+}
+
+
+//=======================================================================
+// function : OnSketchClose()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchClose()
+{
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+
+ TopoDS_Wire W = this->mySketcher.Close();
+ if ( !W.IsNull() ) {
+ //
+ GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
+ listShapes->length(0);
+ unsigned int i = 0;
+
+ BRepTools_WireExplorer Ex(W);
+ while ( Ex.More() ) {
+ TopoDS_Edge E = Ex.Current();
+ gp_Pnt pt1 , pt2 ;
+
+ pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
+ pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
+
+ gp_Pnt CenterPoint;
+ Handle(Geom_Curve) Curve;
+ Handle(Geom_Circle) Circle;
+ gp_Circ Circ;
+ Standard_Real First,Last;
+
+ Curve = BRep_Tool::Curve(E,First,Last);
+ if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
+ Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
+ Circ = Circle->Circ(); // gp_Circ
+
+ Curve->D0( (First + Last) / 2. , CenterPoint );
+
+ GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
+ GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
+ GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
+
+ GEOM::GEOM_Shape_var arc;
+
+ try {
+ arc = myComponentGeom->MakeArc(pI, pC, pE) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ listShapes->length(i+1);
+ listShapes[i] = strdup(arc->Name());
+ i++;
+ } else {
+ GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
+ GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
+ GEOM::GEOM_Shape_var segment;
+
+ try {
+ segment = myComponentGeom->MakeEdge(pI,pE) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ listShapes->length(i+1);
+ listShapes[i] = strdup(segment->Name());
+ i++;
+ }
+ Ex.Next();
+ }
+ GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ Wire->NameType( type );
+
+ if ( Display(Wire, "" )) {
+ QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ }
+ GeomGUI->ResetState();
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(313,&pp);
+ pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+}
+
+
+
+//=======================================================================
+// function : OnSketchEnd()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchEnd()
+{
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)this->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) myContext = v3d->getAISContext();
+
+ TopoDS_Wire W = this->mySketcher.End();
+ if (!W.IsNull()) {
+ //
+ GEOM::GEOM_Gen::ListOfIOR_var listShapes = new GEOM::GEOM_Gen::ListOfIOR;
+ listShapes->length(0);
+ unsigned int i = 0;
+
+ BRepTools_WireExplorer Ex(W);
+ while ( Ex.More() ) {
+ TopoDS_Edge E = TopoDS::Edge( Ex.Current() );
+
+ gp_Pnt pt1 , pt2 ;
+ pt1 = BRep_Tool::Pnt(TopExp::FirstVertex(E));
+ pt2 = BRep_Tool::Pnt(TopExp::LastVertex(E));
+
+ gp_Pnt CenterPoint;
+ Handle(Geom_Curve) Curve;
+ Handle(Geom_Circle) Circle;
+ gp_Circ Circ;
+ Standard_Real First,Last;
+
+ Curve = BRep_Tool::Curve(E,First,Last);
+ if(Curve->IsKind(STANDARD_TYPE(Geom_Circle))) {
+ Circle = Handle(Geom_Circle)::DownCast(Curve); // pointer on geom_circ
+ Circ = Circle->Circ(); // gp_Circ
+
+ Curve->D0( (First + Last) / 2. , CenterPoint );
+
+ GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
+ GEOM::PointStruct pC = myComponentGeom->MakePointStruct( CenterPoint.X(), CenterPoint.Y(), CenterPoint.Z() );
+ GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
+
+ GEOM::GEOM_Shape_var arc;
+
+ try {
+ arc = myComponentGeom->MakeArc(pI, pC, pE) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ listShapes->length(i+1);
+ listShapes[i] = strdup(arc->Name());
+ i++;
+ } else {
+ GEOM::PointStruct pI = myComponentGeom->MakePointStruct( pt1.X(), pt1.Y(), pt1.Z() );
+ GEOM::PointStruct pE = myComponentGeom->MakePointStruct( pt2.X(), pt2.Y(), pt2.Z() );
+ GEOM::GEOM_Shape_var segment;
+
+ try {
+ segment = myComponentGeom->MakeEdge(pI,pE) ;
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ listShapes->length(i+1);
+ listShapes[i] = strdup(segment->Name());
+ i++;
+ }
+ Ex.Next();
+ }
+
+ GEOM::GEOM_Shape_var Wire = myComponentGeom->MakeWire(listShapes) ;
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, Wire);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ Wire->NameType( type );
+
+ if ( Display(Wire, "") ) {
+ QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ }
+ GeomGUI->ResetState();
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(313,&pp);
+ pp->setItemEnabled( 313, false); // SKETCH CONTRAINTS
+ GeomGUI->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+}
+
+//=======================================================================
+// function : OnSettingsNoconstraint()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSettingsNoconstraint()
+{
+ this->mySketcher.SetTransitionStatus(NOCONSTRAINT);
+}
+
+//=======================================================================
+// function : OnSettingsPerpendicular()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSettingsPerpendicular()
+{
+ this->mySketcher.SetTransitionStatus(PERPENDICULAR);
+}
+
+//=======================================================================
+// function : OnSettingsTangent()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSettingsTangent()
+{
+ this->mySketcher.SetTransitionStatus(TANGENT);
+}
+
+//=======================================================================
+// function : OnSketchOptionsOnoffangledimension()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchOptionsOnoffangledimension()
+{
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(10011,&pp);
+ pp->setItemChecked(10011,!pp->isItemChecked(10011));
+ this->mySketcher.SetParameterVisibility(ANGLE_PARAMETER,pp->isItemChecked(10011));
+}
+
+//=======================================================================
+// function : OnSketchOptionsOnofflengthdimension()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchOptionsOnofflengthdimension()
+{
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(10010,&pp);
+ pp->setItemChecked(10010,!pp->isItemChecked(10010));
+ this->mySketcher.SetParameterVisibility(LENGTH_PARAMETER,pp->isItemChecked(10010));
+}
+
+//=======================================================================
+// function : OnSketchOptionsOnoffradiusdimension()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchOptionsOnoffradiusdimension()
+{
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(10012,&pp);
+ pp->setItemChecked(10012,!pp->isItemChecked(10012));
+ this->mySketcher.SetParameterVisibility(RADIUS_PARAMETER,pp->isItemChecked(10012));
+}
+
+
+//=======================================================================
+// function : OnSketchOptionsOnoffxdimension()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchOptionsOnoffxdimension()
+{
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(10013,&pp);
+ pp->setItemChecked(10013,!pp->isItemChecked(10013));
+ this->mySketcher.SetParameterVisibility(XVALUE_PARAMETER,pp->isItemChecked(10013));
+}
+
+//=======================================================================
+// function : OnSketchOptionsOnoffydimension()
+// purpose :
+//=======================================================================
+void GeometryGUI::OnSketchOptionsOnoffydimension()
+{
+ QMenuBar* Mb = this->myDesktop->getMainMenuBar();
+ QMenuData* pp;
+ QMenuItem* item = Mb->findItem(10014,&pp);
+ pp->setItemChecked(10014,!pp->isItemChecked(10014));
+ this->mySketcher.SetParameterVisibility(YVALUE_PARAMETER,pp->isItemChecked(10014));
+}
+
+
+//=======================================================================
+// function : Archimede()
+// purpose :
+//=======================================================================
+void GeometryGUI::Archimede( const Handle(SALOME_InteractiveObject)& IO,
+ const double aWeight,
+ const double aWaterDensity,
+ const double aMeshingDeflection )
+{
+ try {
+ if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ Handle(GEOM_InteractiveObject) GIO =
+ Handle(GEOM_InteractiveObject)::DownCast( IO );
+ GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( GIO->getIOR() );
+
+ GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
+ Result->NameType(tr("GEOM_PLANE"));
+ if ( Display(Result, "") ) {
+ QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ return;
+ }
+ if ( IO->hasEntry() ) {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->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);
+ GEOM::GEOM_Shape_var Shape = GeomGUI->myComponentGeom->GetIORFromString( anIOR->Value() );
+ GEOM::GEOM_Shape_var Result = GeomGUI->myComponentGeom->Archimede( Shape, aWeight, aWaterDensity, aMeshingDeflection);
+ Result->NameType(tr("GEOM_PLANE"));
+ if ( Display(Result, "") ) {
+ QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ }
+ }
+ }
+
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+}
+
+
+//=====================================================================================
+// EXPORTED METHODS
+//=====================================================================================
+extern "C"
+{
+ bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+ {
+ return GeometryGUI::OnGUIEvent(theCommandID, parent);
+ }
+
+ bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+ {
+ return GeometryGUI::OnKeyPress (pe, parent, studyFrame);
+ }
+
+ bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+ {
+ return GeometryGUI::OnMousePress (pe, parent, studyFrame);
+ }
+
+ bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+ {
+ return GeometryGUI::OnMouseMove (pe, parent, studyFrame);
+ }
+
+ bool SetSettings ( QAD_Desktop* parent )
+ {
+ return GeometryGUI::SetSettings( parent );
+ }
+
+ bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
+ const QString & theParent, const QString & theObject )
+ {
+ return GeometryGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
+ }
+
+ void definePopup ( QString & theContext, QString & theParent, QString & theObject )
+ {
+ GeometryGUI::DefinePopup( theContext, theParent, theObject );
+ }
+
+ bool activeStudyChanged ( QAD_Desktop* parent )
+ {
+ GeometryGUI::activeStudyChanged( parent );
+ }
+
+ void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
+ {
+ GeometryGUI::BuildPresentation(theIO);
+ }
+
+ void supportedViewType(int* buffer, int bufferSize)
+ {
+ if (!buffer || !bufferSize) return;
+ buffer[0] = (int)VIEW_OCC;
+ if (--bufferSize) buffer[1] = (int)VIEW_VTK;
+ }
+}
+
+//=====================================================================================
+// function : OnFilletGetAll()
+// purpose :
+//=====================================================================================
+bool GeometryGUI::OnFilletGetAll(const TopoDS_Shape& ShapeTopo, const double Radius, const int SubShapeType, const char* ShapeTopoIOR)
+{
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ListOfID->length(0);
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
+ if ( theObj->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
+ return false ;
+ }
+
+ try {
+ if( Radius <= Precision::Confusion() )
+ return false;
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeFillet(aShape, Radius, SubShapeType, ListOfID) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return false;
+ }
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result, "" ))
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return true;
+}
+
+//=====================================================================================
+// function : OnFilletGetSelected()
+// purpose :
+//=====================================================================================
+bool GeometryGUI::OnFilletGetSelected(const TopoDS_Shape& ShapeTopo,
+ const char* ShapeTopoIOR,
+ const double Radius,
+ const int SubShapeType,
+ Standard_Integer& aLocalContextId,
+ bool& myUseLocalContext )
+{
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ if( myUseLocalContext == false ) {
+ /* No local context opened for fillet method */
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return false ;
+ }
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ic->InitSelected();
+ int nbSelected = ic->NbSelected();
+ int i = 0;
+ ic->InitSelected();
+
+ while(ic->MoreSelected()) {
+ TopoDS_Shape s = ic->SelectedShape();
+ if ( s.ShapeType() == TopAbs_FACE ) {
+ TopExp_Explorer Exp( s, TopAbs_EDGE );
+ TopTools_MapOfShape M ;
+ while ( Exp.More() ) {
+ if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
+ ListOfID->length( i + 1 );
+ ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
+ i++ ;
+ }
+ Exp.Next();
+ }
+ }
+ else {
+ ListOfID->length( i + 1 );
+ ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType );
+ i++;
+ }
+ ic->NextSelected();
+ }
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var aResult ;
+ try {
+ aResult = myComponentGeom->MakeFillet( aShape, Radius, 6, ListOfID );
+
+ /* local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ aResult->NameType( type );
+
+ if ( Display( aResult, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ if ( myUseLocalContext ) {
+ /* local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+
+ this->OnDisplayAll(true);
+ myActiveStudy->updateObjBrowser();
+ myDesktop->putInfo (tr("GEOM_PRP_READY"));
+
+ return true ;
+}
+
+//=====================================================================================
+// function : OnChamferGetAll()
+// purpose :
+//=====================================================================================
+bool GeometryGUI::OnChamferGetAll(const TopoDS_Shape& ShapeTopo, const double D1, const double D2, const int SubShapeType, const char* ShapeTopoIOR)
+{
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ListOfID->length(0);
+
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR( ShapeTopoIOR );
+ if ( theObj->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
+ return false ;
+ }
+
+ try {
+ if( D1 <= Precision::Confusion() )
+ return false;
+ if( D2 <= Precision::Confusion() )
+ return false;
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeChamfer(aShape, D1, D2, SubShapeType, ListOfID) ;
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return false;
+ }
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, result);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ result->NameType( type );
+
+ if ( Display( result, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return true;
+}
+
+//=====================================================================================
+// function : OnChamferGetSelected()
+// purpose :
+//=====================================================================================
+bool GeometryGUI::OnChamferGetSelected(const TopoDS_Shape& ShapeTopo,
+ const char* ShapeTopoIOR,
+ const double D1, const double D2, const int SubShapeType,
+ Standard_Integer& aLocalContextId,
+ bool& myUseLocalContext)
+{
+ if ( this->myActiveStudy->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ return false;
+ }
+
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
+
+ if( myUseLocalContext == false ) {
+ /* No local context opened for chamfer method */
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT"));
+ return false ;
+ }
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ ic->InitSelected();
+ int nbSelected = ic->NbSelected();
+ int i = 0;
+ ic->InitSelected();
+
+ while(ic->MoreSelected()) {
+ TopoDS_Shape s = ic->SelectedShape();
+ if ( s.ShapeType() == TopAbs_FACE ) {
+ TopExp_Explorer Exp( s, TopAbs_EDGE );
+ TopTools_MapOfShape M ;
+ while ( Exp.More() ) {
+ if( M.Add(Exp.Current() )) { /* if a new edge : do not add doublons indices */
+ ListOfID->length( i + 1 );
+ ListOfID[i] = GetIndex( Exp.Current(), ShapeTopo, (int)TopAbs_EDGE ) ;
+ i++ ;
+ }
+ Exp.Next();
+ }
+ }
+ else {
+ ListOfID->length( i + 1 );
+ ListOfID[i] = GetIndex( ic->SelectedShape(), ShapeTopo, SubShapeType ) ;
+ i++;
+ }
+ ic->NextSelected();
+ }
+
+ GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( ShapeTopoIOR );
+ GEOM::GEOM_Shape_var aResult ;
+ try {
+ aResult = myComponentGeom->MakeChamfer( aShape, D1, D2, 6, ListOfID );
+
+ /* local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+
+ TopoDS_Shape S = ShapeReader.GetShape(myComponentGeom, aResult);
+ Standard_CString type;
+ GetShapeTypeString(S,type);
+ aResult->NameType( type );
+
+ if ( Display( aResult, "") )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+
+ if ( myUseLocalContext ) {
+ /* local context from DialogBox */
+ ic->CloseLocalContext(aLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+
+ this->OnDisplayAll(true);
+ myActiveStudy->updateObjBrowser();
+ myDesktop->putInfo (tr("GEOM_PRP_READY"));
+
+ return true ;
+}
+
+//=====================================================================================
+// function : MakeCDGAndDisplay()
+// purpose :
+//=====================================================================================
+void GeometryGUI::MakeCDGAndDisplay(GEOM::GEOM_Shape_ptr Shape)
+{
+ try {
+ GEOM::GEOM_Shape_var result = myComponentGeom->MakeCDG( Shape );
+ if ( result->_is_nil() ) {
+ myDesktop->putInfo(tr("GEOM_PRP_ABORT") );
+ return ;
+ }
+ result->NameType( tr("GEOM_POINT") );
+ if ( Display( result ) )
+ myDesktop->putInfo(tr("GEOM_PRP_DONE"));
+ }
+ catch (const SALOME::SALOME_Exception& S_ex) {
+ QtCatchCorbaException(S_ex);
+ }
+ return ;
+}
+
+bool GeometryGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR) {
+ SALOMEDS::Study_var aStudy = GeomGUI->myActiveStudy->getStudyDocument();
+ SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
+ SALOMEDS::SObject_var RefSO;
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeIOR_var anIOR;
+ for (; it->More();it->Next()) {
+ SALOMEDS::SObject_var SO= it->Value();
+ if (SO->FindAttribute(anAttr, "AttributeIOR") ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if ( strcmp( anIOR->Value(), IOR ) == 0 )
+ return true;
+ }
+ if ( SO->ReferencedObject( RefSO ) ) {
+ if (RefSO->FindAttribute(anAttr, "AttributeIOR") ) {
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ if ( strcmp( anIOR->Value(), IOR ) == 0 )
+ return true;
+ }
+ }
+ }
+ return false;
+}
--- /dev/null
+// 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
+
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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() ;
+ }
+}
--- /dev/null
+// 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
+
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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();
+ }
+ }
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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() ;
+ }
+}
--- /dev/null
+// 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
+
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
+
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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 ;
+}
--- /dev/null
+// 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.h
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_MAXTOLERANCE_H
+#define DIALOGBOX_MAXTOLERANCE_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_MaxToleranceDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_MaxToleranceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_MaxToleranceDlg();
+
+private:
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ void CalculateMaxTolerance(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;
+
+ QLabel* TextLabel_Min;
+ QLabel* TextLabel_Max;
+
+ QLabel* TextLabel_Face;
+ QLabel* TextLabel_Edge;
+ QLabel* TextLabel_Vertex;
+
+ QLineEdit* LineEdit_MinFace;
+ QLineEdit* LineEdit_MinEdge;
+ QLineEdit* LineEdit_MinVertex;
+
+ QLineEdit* LineEdit_MaxFace;
+ QLineEdit* LineEdit_MaxEdge;
+ QLineEdit* LineEdit_MaxVertex;
+
+ 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_MaxToleranceDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_MAXTOLERANCE_H
--- /dev/null
+// 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_MirrorDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_MirrorDlg.h"
+
+#include "GeometryGUI.h"
+
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "utilities.h"
+
+#include <Geom_Plane.hxx>
+#include <BRep_Tool.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_MirrorDlg()
+// purpose : Constructs a GeometryGUI_MirrorDlg 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_MirrorDlg::GeometryGUI_MirrorDlg( 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_MIRROR")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_MirrorDlg" );
+ resize( 303, 225 );
+ setCaption( tr( "GEOM_MIRROR_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_MirrorDlgLayout = new QGridLayout( this );
+ GeometryGUI_MirrorDlgLayout->setSpacing( 6 );
+ GeometryGUI_MirrorDlgLayout->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_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_MirrorDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_MIRROR" ) );
+ 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 );
+ GeometryGUI_MirrorDlgLayout->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 );
+ 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 );
+ TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_PLANE_MIRROR" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A2->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A2->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
+ SelectButtonC1A1->setText( tr( "" ) );
+ SelectButtonC1A1->setPixmap( image1 );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
+ GeometryGUI_MirrorDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_MirrorDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_MirrorDlg::~GeometryGUI_MirrorDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::Init( SALOME_Selection* Sel )
+{
+ mySelection = Sel ;
+ myShape1.Nullify() ;
+ myShape2.Nullify() ;
+ mySimulationTopoDs.Nullify() ;
+ myConstructorId = 0 ;
+
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ GroupC1->show();
+
+ myEditCurrentArgument = LineEditC1A1 ;
+ 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);
+ /* Filter definition */
+
+ myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom );
+
+ // 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( 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( 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_MirrorDlg::ConstructorsClicked(int constructorId)
+{
+ GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ;
+
+ switch (constructorId)
+ {
+ case 0:
+ {
+ GroupC1->show();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ LineEditC1A2->setText(tr("")) ;
+ Constructor1->setChecked( TRUE );
+ myOkShape1 = myOkShape2 = false ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkShape1 && myOkShape2) {
+ myGeomGUI->MakeMirrorAndDisplay(myGeomShape1 ,myGeomShape2 ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection has changed
+//=================================================================================
+void GeometryGUI_MirrorDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ QString aString = ""; /* name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myOkShape1 = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ 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 == LineEditC1A1 ) {
+ myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myShape1 = S ;
+ LineEditC1A1->setText(aString) ;
+ myOkShape1 = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myShape2 = S ;
+ LineEditC1A2->setText(aString) ;
+ myOkShape2 = true ;
+ }
+
+ if(myOkShape1 && myOkShape2) {
+ MakeMirrorSimulationAndDisplay( myShape1, myShape2 ) ;
+ }
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : MakeMirrorSimulationAndDisplay()
+// purpose : S1 is a shape and S2 a mirror.
+//=================================================================================
+void GeometryGUI_MirrorDlg::MakeMirrorSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
+{
+ this->mySimulationTopoDs.Nullify() ;
+
+ try {
+ Handle(Geom_Surface) surf = BRep_Tool::Surface(TopoDS::Face(S2)) ;
+ Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf) ;
+ const gp_Ax3 pos = myPlane->Position() ;
+ const gp_Pnt loc = pos.Location() ; /* location of the plane */
+ const gp_Dir dir = pos.Direction() ; /* Main direction of the plane (Z axis) */
+
+ /* plane used for mirroring */
+ gp_Ax2 pln(loc, dir) ;
+ gp_Trsf theTransformation ;
+ theTransformation.SetMirror(pln) ;
+ BRepBuilderAPI_Transform myBRepTransformation( S1, theTransformation, Standard_False ) ;
+
+ this->mySimulationTopoDs = myBRepTransformation.Shape() ;
+ if( this->mySimulationTopoDs.IsNull() )
+ return ;
+ else
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeMirrorSimulationAndDisplay" ) ;
+ return ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if( send == SelectButtonC1A1 ) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection->ClearFilters() ;
+ SelectionIntoArgument() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myFaceFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::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 : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void GeometryGUI_MirrorDlg::enterEvent( QEvent * )
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MirrorDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate any active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupC1->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ return ;
+}
--- /dev/null
+// 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_MirrorDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_MIRROR_H
+#define DIALOGBOX_MIRROR_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_FaceFilter.hxx"
+
+#include <BRepBuilderAPI_Transform.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_MirrorDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_MirrorDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_MirrorDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_MirrorDlg();
+
+private :
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e); /* Mouse enter the QWidget */
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeMirrorSimulationAndDisplay( const TopoDS_Shape& S1, const TopoDS_Shape& S2 ) ;
+
+ 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 */
+ TopoDS_Shape mySimulationTopoDs; /* Shape used for simulation display */
+ bool myOkShape1 ;
+ bool myOkShape2 ; /* to check when arguments are defined */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ Handle(GEOM_FaceFilter) myFaceFilter; /* To filter selections */
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupC1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ QPushButton* SelectButtonC1A1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+
+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_MirrorDlgLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_MIRROR_H
--- /dev/null
+// 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_MultiTranslationDlg.cxx
+// Author : Damien COQUERET
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_MultiRotationDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Config.h"
+#include "utilities.h"
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <TopoDS_Compound.hxx>
+#include <Geom_Line.hxx>
+#include <Precision.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+
+#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 <qvalidator.h>
+#include <qpixmap.h>
+#include <qspinbox.h>
+
+
+//=================================================================================
+// class : GeometryGUI_MultiRotationDlg()
+// purpose : Constructs a GeometryGUI_MultiRotationDlg 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_MultiRotationDlg::GeometryGUI_MultiRotationDlg( 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_MULTIROTATION_SIMPLE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_MULTIROTATION_DOUBLE")));
+
+ if ( !name )
+ setName( "GeometryGUI_MultiTranlationDlg" );
+ resize( 303, 251 );
+ setCaption( tr( "GEOM_MULTIROTATION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_MultiRotationDlgLayout = new QGridLayout( this );
+ GeometryGUI_MultiRotationDlgLayout->setSpacing( 6 );
+ GeometryGUI_MultiRotationDlgLayout->setMargin( 11 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_MULTIROTATION" ) );
+ 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 );
+
+ GeometryGUI_MultiRotationDlgLayout->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_MultiRotationDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_MULTIROTATION_SIMPLE" ) );
+ 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_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_NB_TIMES" ) );
+ 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" );
+ GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
+
+ /* a QSpinBox */
+ SpinBox_C1A3 = new QSpinBox( GroupC1, "SpinBox_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 );
+
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ SelectButtonC1A2->setToggleButton( FALSE );
+ SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+
+ GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ /***************************************************************/
+
+ GroupC2 = new QGroupBox( this, "GroupC2" );
+ GroupC2->setTitle( tr( "GEOM_MULTIROTATION_DOUBLE" ) );
+ 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_VECTOR" ) );
+ 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_ANGLE" ) );
+ TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A3->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A3->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
+
+ TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" );
+ TextLabelC2A4->setText( tr( "GEOM_NB_TIMES" ) );
+ TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A4->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A4->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 );
+
+ TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" );
+ TextLabelC2A5->setText( tr( "GEOM_STEP" ) );
+ TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A5->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A5->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A5, 5, 0 );
+
+ TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" );
+ TextLabelC2A6->setText( tr( "GEOM_NB_TIMES" ) );
+ TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A6->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A6->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 );
+
+ LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
+ GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
+
+ LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
+ GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
+
+ /* a GeometryGUI_SpinBox */
+ 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 );
+ /* a QSpinBox */
+ SpinBox_C2A4 = new QSpinBox( GroupC2, "SpinBox_C2A4" ) ;
+ SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 );
+
+ /* a GeometryGUI_SpinBox */
+ SpinBox_C2A5 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A5" ) ;
+ SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A5, 5, 2 );
+ /* a QSpinBox */
+ SpinBox_C2A6 = new QSpinBox( GroupC2, "SpinBox_C2A6" ) ;
+ SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 );
+
+ CheckBoxReverse = new QCheckBox( GroupC2, "CheckBoxReverse" );
+ CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) );
+ GroupC2Layout->addWidget( CheckBoxReverse, 4, 0 );
+
+ SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
+ SelectButtonC2A1->setText( tr( "" ) );
+ SelectButtonC2A1->setPixmap( image1 );
+ SelectButtonC2A1->setToggleButton( FALSE );
+ SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
+
+ SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
+ SelectButtonC2A2->setText( tr( "" ) );
+ SelectButtonC2A2->setPixmap( image1 );
+ SelectButtonC2A2->setToggleButton( FALSE );
+ SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
+
+ GeometryGUI_MultiRotationDlgLayout->addWidget( GroupC2, 1, 0 );
+
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+//=================================================================================
+// function : ~GeometryGUI_MultiRotationDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_MultiRotationDlg::~GeometryGUI_MultiRotationDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::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 geom spin boxes */
+ SpinBox_C2A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* angle : constructor 2 */
+ SpinBox_C2A3->SetValue( 45.0 ) ;
+ SpinBox_C2A5->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step : constructor 2 */
+ SpinBox_C2A5->SetValue( 50.0 ) ;
+
+ /* min, max, step for QT spin boxes */
+ SpinBox_C1A3->setMinValue( 2 ); /* myNbTimes : constructor 1 */
+ SpinBox_C1A3->setMaxValue( 10000 );
+ SpinBox_C1A3->setWrapping( TRUE );
+ SpinBox_C1A3->setValue(2) ;
+
+ SpinBox_C2A4->setMinValue( 2 ); /* myNbTimes1 : constructor 2 */
+ SpinBox_C2A4->setMaxValue( 10000 );
+ SpinBox_C2A4->setWrapping( TRUE );
+ SpinBox_C2A4->setValue(2) ;
+
+ SpinBox_C2A6->setMinValue( 2 ); /* myNbTimes2 : constructor 2 */
+ SpinBox_C2A6->setMaxValue( 10000 );
+ SpinBox_C2A6->setWrapping( TRUE );
+ SpinBox_C2A6->setValue(2) ;
+
+ myAng = 45.0 ;
+ myStep = 50.0 ;
+ myNbTimes1 = 2;
+ myNbTimes2 = 2;
+
+ GroupC1->show();
+ GroupC2->hide() ;
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ myOkBase = myOkDir = false ;
+ mySimulationTopoDs.Nullify() ;
+ myBase.Nullify() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ // TODO : set 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 );
+
+ /* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ /* GeometryGUI_SpinBox */
+ connect( SpinBox_C2A3, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ;
+ connect( SpinBox_C2A5, SIGNAL ( valueChanged( double) ), this, SLOT( valueChangedInSpinBox( double) ) ) ;
+
+ /* QSpinBox */
+ connect( SpinBox_C1A3, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */
+ connect( SpinBox_C2A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
+ connect( SpinBox_C2A6, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
+
+ connect( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
+
+ 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 : ReverseAngle()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ReverseAngle(int state)
+{
+ myAng = -myAng ;
+ SpinBox_C2A3->SetValue( myAng ) ;
+ if( myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ConstructorsClicked(int constructorId)
+{
+ myEditCurrentArgument->setText(tr("")) ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ myAng = 45.0 ;
+ myStep = 50.0 ;
+ myNbTimes1 = 2;
+ myNbTimes2 = 2;
+
+ myOkBase = myOkDir = false ;
+ myConstructorId = constructorId ;
+
+ switch (constructorId)
+ {
+ case 0: /* Rotate simple */
+ {
+ GroupC1->show();
+ GroupC2->hide() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ SpinBox_C1A3->setValue( 2 ) ;
+ LineEditC1A1->setText(tr("")) ;
+ LineEditC1A2->setText(tr("")) ;
+ break;
+ }
+
+ case 1: /* Rotate double */
+ {
+ GroupC1->hide();
+ GroupC2->show() ;
+ myEditCurrentArgument = LineEditC2A1 ;
+ SpinBox_C2A3->SetValue( 45.0 ) ;
+ SpinBox_C2A4->setValue( 2 ) ;
+ SpinBox_C2A5->SetValue( 50.0 ) ;
+ SpinBox_C2A6->setValue( 2 ) ;
+ LineEditC2A1->setText(tr("")) ;
+ LineEditC2A2->setText(tr("")) ;
+ break ;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkBase && myOkDir) {
+ myGeomGUI->MakeMultiRotation1DAndDisplay( myGeomShape, myDir, myLoc, myNbTimes1 ) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ if(myOkBase && myOkDir) {
+ myGeomGUI->MakeMultiRotation2DAndDisplay( myGeomShape, myDir, myLoc, myAng, myNbTimes1, myStep, myNbTimes2 ) ;
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender() ;
+ if( send == LineEditC1A1 )
+ myEditCurrentArgument = LineEditC1A1 ;
+ else if ( send == LineEditC1A2 )
+ myEditCurrentArgument = LineEditC1A2 ;
+ else if ( send == LineEditC2A1 )
+ myEditCurrentArgument = LineEditC2A1;
+ else if ( send == LineEditC2A2 )
+ myEditCurrentArgument = LineEditC2A2 ;
+ 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_MultiRotationDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Name of future selection */
+ QString aString = "";
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+
+ TopoDS_Shape S;
+ Standard_Boolean testResult ;
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkDir = false ;
+ }
+ return ;
+ }
+
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myEditCurrentArgument->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir = curv.Line().Direction();
+ myLoc = curv.Line().Location();
+ myEditCurrentArgument->setText(aString) ;
+ myOkDir = true ;
+ }
+
+ if (myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkDir = false ;
+ }
+ return ;
+ }
+
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myEditCurrentArgument->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir = curv.Line().Direction();
+ myLoc = curv.Line().Location();
+ myEditCurrentArgument->setText(aString) ;
+ myOkDir = true ;
+ }
+
+ if ( myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ case 1 :
+ {
+ if(send == SelectButtonC2A1) {
+ LineEditC2A1->setFocus() ;
+ myEditCurrentArgument = LineEditC2A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC2A2) {
+ LineEditC2A2->setFocus() ;
+ myEditCurrentArgument = LineEditC2A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ValueChangedInt()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ValueChangedInt( int newIntValue )
+{
+ QSpinBox* send = (QSpinBox*)sender();
+
+ if( send == SpinBox_C1A3 ) {
+ myNbTimes1 = newIntValue ;
+ }
+ else if(send == SpinBox_C2A4 ) {
+ myNbTimes1 = newIntValue ;
+ }
+ else if(send == SpinBox_C2A6 ) {
+ myNbTimes2 = newIntValue ;
+ }
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if (myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if (myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose : (specifig for GeometryGUI_SpinBox)
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::ValueChangedInSpinBox( double newValue )
+{
+ GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
+
+ if( send == SpinBox_C2A3 ) {
+ myAng = newValue ;
+ }
+ else if( send == SpinBox_C2A5 ) {
+ myStep = newValue ;
+ }
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if (myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if (myOkBase && myOkDir ) {
+ MakeMultiRotationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::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() ;
+ myGeomGUI->ResetState() ;
+ myGeomGUI->SetActiveDialogBox(0) ;
+ myGeomGUI->OnDisplayAll(true) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::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() ) );
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeMultiRotationSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiRotationDlg::MakeMultiRotationSimulationAndDisplay()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ gp_Trsf theTransformation ;
+ gp_Trsf theTransformation1 ;
+ gp_Trsf theTransformation2 ;
+ mySimulationTopoDs.Nullify() ;
+
+ int i ;
+ int j ;
+ Standard_Real DX ;
+ Standard_Real DY ;
+ Standard_Real DZ ;
+ GProp_GProps System ;
+ gp_Pnt myPoint ;
+ TopoDS_Compound compound;
+ BRep_Builder B;
+
+ B.MakeCompound( compound );
+
+ if ( myBase.ShapeType() == TopAbs_VERTEX) {
+ myGeomGUI->VertexToPoint( myBase, myPoint );
+ }
+ else if ( myBase.ShapeType() == TopAbs_EDGE || myBase.ShapeType() == TopAbs_WIRE ) {
+ BRepGProp::LinearProperties(myBase, System);
+ myPoint = System.CentreOfMass() ;
+ }
+ else if ( myBase.ShapeType() == TopAbs_FACE || myBase.ShapeType() == TopAbs_SHELL ) {
+ BRepGProp::SurfaceProperties(myBase, System);
+ myPoint = System.CentreOfMass() ;
+ }
+ else {
+ BRepGProp::VolumeProperties(myBase, System);
+ myPoint = System.CentreOfMass() ;
+ }
+
+ TopoDS_Shape S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
+
+ try {
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ gp_Ax1 AX1( myLoc, myDir ) ;
+ Standard_Real angle = 360/myNbTimes1;
+ for ( i = 0; i < myNbTimes1; i++ ) {
+ theTransformation.SetRotation(AX1, i*angle*PI180) ;
+ BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ mySimulationTopoDs = compound;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ break;
+ }
+ case 1 :
+ {
+ gp_Ax1 AX2( myLoc, myDir ) ;
+ Handle(Geom_Line) Line = new Geom_Line(AX2);
+ gp_Pnt P2 = GeomAPI_ProjectPointOnCurve( myPoint, Line ) ;
+ if ( myPoint.IsEqual(P2, Precision::Confusion() ) )
+ return;
+ gp_Vec Vec(P2, myPoint) ;
+ Vec.Normalize();
+
+ for ( i = 0; i < myNbTimes2; i++ ) {
+ for ( j = 0; j < myNbTimes1; j++ ) {
+ DX = i * myStep * Vec.X() ;
+ DY = i * myStep * Vec.Y() ;
+ DZ = i * myStep * Vec.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+
+ theTransformation1.SetTranslation(myVec) ;
+ theTransformation2.SetRotation(AX2, j*myAng*PI180) ;
+ BRepBuilderAPI_Transform myBRepTransformation1(S, theTransformation1, Standard_False) ;
+ BRepBuilderAPI_Transform myBRepTransformation2(myBRepTransformation1.Shape(), theTransformation2, Standard_False) ;
+ B.Add( compound, myBRepTransformation2.Shape() );
+ }
+ }
+ mySimulationTopoDs = compound ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ break;
+ }
+ }
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;
+ return ;
+ }
+ return ;
+}
--- /dev/null
+// 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_MultiRotationDlg.h
+// Author : Damien COQUERET
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_MULTIROTATION_H
+#define DIALOGBOX_MULTIROTATION_H
+
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOM_EdgeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+#include <qvalidator.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QSpinBox;
+class QRadioButton;
+class GeometryGUI;
+
+//=================================================================================
+// class : GeometryGUI_MultiRotationDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_MultiRotationDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_MultiRotationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_MultiRotationDlg();
+
+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 */
+ TopoDS_Shape myBase ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
+
+ gp_Vec myVec ;
+ int myNbTimes1 ;
+ int myNbTimes2 ;
+ Standard_Real myAng ;
+ Standard_Real myStep ;
+ gp_Dir myDir ;
+ gp_Pnt myLoc ;
+
+ bool myOkBase ;
+ bool myOkDir ;
+ bool myOkAng ;
+
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeMultiRotationSimulationAndDisplay() ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QRadioButton* Constructor2;
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+
+ QGroupBox* GroupC1;
+ QPushButton* SelectButtonC1A1;
+ QPushButton* SelectButtonC1A2;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ QLabel* TextLabelC1A3;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QSpinBox* SpinBox_C1A3; /* int : Nb times */
+
+ QGroupBox* GroupC2;
+ QPushButton* SelectButtonC2A1;
+ QPushButton* SelectButtonC2A2;
+ QLabel* TextLabelC2A1;
+ QLabel* TextLabelC2A2;
+ QLabel* TextLabelC2A3;
+ QLabel* TextLabelC2A4;
+ QLabel* TextLabelC2A5;
+ QLabel* TextLabelC2A6;
+
+ QLineEdit* LineEditC2A1;
+ QLineEdit* LineEditC2A2;
+ GeometryGUI_SpinBox* SpinBox_C2A3 ; /* double : angle */
+ QSpinBox* SpinBox_C2A4; /* int : Nb times 1 */
+ GeometryGUI_SpinBox* SpinBox_C2A5 ; /* double : step value */
+ QSpinBox* SpinBox_C2A6; /* int : Nb times 2 */
+
+ QCheckBox* CheckBoxReverse;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void LineEditReturnPressed() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ReverseAngle(int) ;
+ void ValueChangedInSpinBox( double newValue ) ; /* for GeometryGUI_SpinBox */
+ void ValueChangedInt( int newIntValue ) ; /* for QT spin box ! not const ! */
+
+protected:
+ QGridLayout* GeometryGUI_MultiRotationDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+ QGridLayout* GroupC2Layout;
+};
+
+#endif // DIALOGBOX_MULTIROTATION_H
--- /dev/null
+// 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_MultiTranslationDlg.cxx
+// Author : Damien COQUERET
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_MultiTranslationDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Config.h"
+#include "utilities.h"
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepGProp.hxx>
+#include <GProp_GProps.hxx>
+#include <TopoDS_Compound.hxx>
+
+#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>
+#include <qspinbox.h>
+
+
+//=================================================================================
+// class : GeometryGUI_MultiTranslationDlg()
+// purpose : Constructs a GeometryGUI_MultiTranslationDlg 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_MultiTranslationDlg::GeometryGUI_MultiTranslationDlg( 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_MULTITRANSLATION_SIMPLE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
+
+ if ( !name )
+ setName( "GeometryGUI_MultiTranlationDlg" );
+ resize( 303, 251 );
+ setCaption( tr( "GEOM_MULTITRANSLATION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_MultiTranslationDlgLayout = new QGridLayout( this );
+ GeometryGUI_MultiTranslationDlgLayout->setSpacing( 6 );
+ GeometryGUI_MultiTranslationDlgLayout->setMargin( 11 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_MULTITRANSLATION" ) );
+ 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 );
+
+ GeometryGUI_MultiTranslationDlgLayout->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_MultiTranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_MULTITRANSLATION_SIMPLE" ) );
+ 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_VECTOR_U" ) );
+ 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_STEP_U" ) );
+ 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_NB_TIMES_U" ) );
+ TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A4->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A4->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A4, 3, 0 );
+
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
+
+ /* a GeometryGUI_SpinBox */
+ 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 );
+ /* a QSpinBox */
+ SpinBox_C1A4 = new QSpinBox( GroupC1, "SpinBox_C1A4" ) ;
+ SpinBox_C1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C1A4->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SpinBox_C1A4, 3, 2 );
+
+ CheckBoxReverse0 = new QCheckBox( GroupC1, "CheckBoxReverse0" );
+ CheckBoxReverse0->setText( tr( "GEOM_REVERSE_U" ) );
+ GroupC1Layout->addWidget( CheckBoxReverse0, 5, 0 );
+
+ SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
+ SelectButtonC1A1->setText( tr( "" ) );
+ SelectButtonC1A1->setPixmap( image1 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ SelectButtonC1A1->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ SelectButtonC1A2->setToggleButton( FALSE );
+ SelectButtonC1A2->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+
+ GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ /***************************************************************/
+
+ GroupC2 = new QGroupBox( this, "GroupC2" );
+ GroupC2->setTitle( tr( "GEOM_MULTITRANSLATION_DOUBLE" ) );
+ 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_VECTOR_U" ) );
+ 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_VECTOR_V" ) );
+ TextLabelC2A3->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A3->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A3->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A3, 2, 0 );
+
+ TextLabelC2A4 = new QLabel( GroupC2, "TextLabelC2A4" );
+ TextLabelC2A4->setText( tr( "GEOM_STEP_U" ) );
+ TextLabelC2A4->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A4->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A4->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A4, 3, 0 );
+
+ TextLabelC2A5 = new QLabel( GroupC2, "TextLabelC2A5" );
+ TextLabelC2A5->setText( tr( "GEOM_NB_TIMES_U" ) );
+ TextLabelC2A5->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A5->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A5->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A5, 4, 0 );
+
+ TextLabelC2A6 = new QLabel( GroupC2, "TextLabelC2A6" );
+ TextLabelC2A6->setText( tr( "GEOM_STEP_V" ) );
+ TextLabelC2A6->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A6->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A6->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A6, 6, 0 );
+
+ TextLabelC2A7 = new QLabel( GroupC2, "TextLabelC2A7" );
+ TextLabelC2A7->setText( tr( "GEOM_NB_TIMES_V" ) );
+ TextLabelC2A7->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A7->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A7->setFrameShadow( QLabel::Plain );
+ GroupC2Layout->addWidget( TextLabelC2A7, 7, 0 );
+
+ LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
+ GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
+
+ LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
+ GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
+
+ LineEditC2A3 = new QLineEdit( GroupC2, "LineEditC2A3" );
+ GroupC2Layout->addWidget( LineEditC2A3, 2, 2 );
+
+ /* a GeometryGUI_SpinBox */
+ SpinBox_C2A4 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A4" ) ;
+ SpinBox_C2A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A4->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A4, 3, 2 );
+ /* a QSpinBox */
+ SpinBox_C2A5 = new QSpinBox( GroupC2, "SpinBox_C2A5" ) ;
+ SpinBox_C2A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A5->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A5, 4, 2 );
+
+ /* a GeometryGUI_SpinBox */
+ SpinBox_C2A6 = new GeometryGUI_SpinBox( GroupC2, "GeomSpinBox_C2A6" ) ;
+ SpinBox_C2A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A6->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A6, 6, 2 );
+ /* a QSpinBox */
+ SpinBox_C2A7 = new QSpinBox( GroupC2, "SpinBox_C2A7" ) ;
+ SpinBox_C2A7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, SpinBox_C2A7->sizePolicy().hasHeightForWidth() ) );
+ GroupC2Layout->addWidget( SpinBox_C2A7, 7, 2 );
+
+
+ CheckBoxReverse1 = new QCheckBox( GroupC2, "CheckBoxReverse1" );
+ CheckBoxReverse1->setText( tr( "GEOM_REVERSE_U" ) );
+ GroupC2Layout->addWidget( CheckBoxReverse1, 5, 0 );
+
+ CheckBoxReverse2 = new QCheckBox( GroupC2, "CheckBoxReverse2" );
+ CheckBoxReverse2->setText( tr( "GEOM_REVERSE_V" ) );
+ GroupC2Layout->addWidget( CheckBoxReverse2, 8, 0 );
+
+ SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
+ SelectButtonC2A1->setText( tr( "" ) );
+ SelectButtonC2A1->setPixmap( image1 );
+ SelectButtonC2A1->setToggleButton( FALSE );
+ SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
+
+ SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
+ SelectButtonC2A2->setText( tr( "" ) );
+ SelectButtonC2A2->setPixmap( image1 );
+ SelectButtonC2A2->setToggleButton( FALSE );
+ SelectButtonC2A2->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
+
+ SelectButtonC2A3 = new QPushButton( GroupC2, "SelectButtonC2A3" );
+ SelectButtonC2A3->setText( tr( "" ) );
+ SelectButtonC2A3->setPixmap( image1 );
+ SelectButtonC2A3->setToggleButton( FALSE );
+ SelectButtonC2A3->setMaximumSize( QSize( 28, 32767 ) );
+ GroupC2Layout->addWidget( SelectButtonC2A3, 2, 1 );
+
+ GeometryGUI_MultiTranslationDlgLayout->addWidget( GroupC2, 1, 0 );
+
+ /***************************************************************/
+
+
+ Init(Sel) ; /* Initialisations */
+}
+
+//=================================================================================
+// function : ~GeometryGUI_MultiTranslationDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_MultiTranslationDlg::~GeometryGUI_MultiTranslationDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+ this->destroy(TRUE, TRUE) ;
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::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 geom spin boxes */
+ SpinBox_C1A3->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 1 */
+ SpinBox_C1A3->SetValue( 50 ) ;
+ SpinBox_C2A4->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step U : constructor 2 */
+ SpinBox_C2A4->SetValue( 50 ) ;
+ SpinBox_C2A6->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ; /* step V : constructor 2 */
+ SpinBox_C2A6->SetValue( 50 ) ;
+
+ /* min, max, step for QT spin boxes */
+ SpinBox_C1A4->setMinValue( 1 ); /* myNbTimes1 : constructor 1 */
+ SpinBox_C1A4->setMaxValue( 10000 );
+ SpinBox_C1A4->setWrapping( TRUE );
+ SpinBox_C1A4->setValue(2) ;
+
+ SpinBox_C2A5->setMinValue( 1 ); /* myNbTimes1 : constructor 2 */
+ SpinBox_C2A5->setMaxValue( 10000 );
+ SpinBox_C2A5->setWrapping( TRUE );
+ SpinBox_C2A5->setValue(2) ;
+
+ SpinBox_C2A7->setMinValue( 1 ); /* myNbTimes2 : constructor 2 */
+ SpinBox_C2A7->setMaxValue( 10000 );
+ SpinBox_C2A7->setWrapping( TRUE );
+ SpinBox_C2A7->setValue(2) ;
+
+ myStep1 = 50.0 ;
+ myStep2 = 50.0 ;
+ myNbTimes1 = 2 ;
+ myNbTimes2 = 2 ;
+
+ GroupC1->show();
+ GroupC2->hide() ;
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ myOkBase = myOkDir1 = myOkDir2 = false ;
+ mySimulationTopoDs.Nullify() ;
+ myBase.Nullify() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ // TODO : set 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 );
+
+ /* 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( SelectButtonC2A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC2A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC2A3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ /* GeometryGUI_SpinBox */
+ connect( SpinBox_C1A3, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+ connect( SpinBox_C2A4, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+ connect( SpinBox_C2A6, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC1A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A3, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ /* QSpinBox */
+ connect( SpinBox_C1A4, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ; /* Not const ! */
+ connect( SpinBox_C2A5, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
+ connect( SpinBox_C2A7, SIGNAL ( valueChanged(int) ), this, SLOT( ValueChangedInt(int) ) ) ;
+
+ connect( CheckBoxReverse0, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
+ connect( CheckBoxReverse1, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle1(int) ) ) ;
+ connect( CheckBoxReverse2, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle2(int) ) ) ;
+
+ 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 : ReverseAngle1()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ReverseAngle1(int state)
+{
+ myStep1 = -myStep1 ;
+ SpinBox_C1A3->SetValue( myStep1 ) ;
+ SpinBox_C2A4->SetValue( myStep1 ) ;
+ if( myOkBase && myOkDir1 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ReverseAngle2()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ReverseAngle2(int state)
+{
+ myStep2 = -myStep2 ;
+ SpinBox_C2A6->SetValue( myStep2 ) ;
+ if( myOkBase && myOkDir1 && myOkDir2 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId)
+{
+ myEditCurrentArgument->setText(tr("")) ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ myStep1 = 50.0 ;
+ myStep2 = 50.0 ;
+ myNbTimes1 = 2;
+ myNbTimes2 = 2;
+
+ myOkBase = myOkDir1 = myOkDir2 = false ;
+ myConstructorId = constructorId ;
+
+ switch (constructorId)
+ {
+ case 0: /* Translate simple */
+ {
+ GroupC1->show();
+ GroupC2->hide() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ SpinBox_C1A3->SetValue(50) ;
+ SpinBox_C1A4->setValue(2) ;
+ LineEditC1A1->setText(tr("")) ;
+ LineEditC1A2->setText(tr("")) ;
+ break;
+ }
+
+ case 1: /* Translate double */
+ {
+ GroupC1->hide();
+ GroupC2->show() ;
+ myEditCurrentArgument = LineEditC2A1 ;
+ SpinBox_C2A4->SetValue(50) ;
+ SpinBox_C2A5->setValue(2) ;
+ SpinBox_C2A6->SetValue(50) ;
+ SpinBox_C2A7->setValue(2) ;
+ LineEditC2A1->setText(tr("")) ;
+ LineEditC2A2->setText(tr("")) ;
+ LineEditC2A3->setText(tr("")) ;
+ break ;
+ }
+
+ }
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkBase && myOkDir1 ) {
+ myGeomGUI->MakeMultiTranslation1DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1 ) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ if(myOkBase && myOkDir1 && myOkDir2 ) {
+ myGeomGUI->MakeMultiTranslation2DAndDisplay( myGeomShape, myDir1, myStep1, myNbTimes1, myDir2, myStep2, myNbTimes2 ) ;
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender() ;
+ if( send == LineEditC1A1 )
+ myEditCurrentArgument = LineEditC1A1 ;
+ else if ( send == LineEditC1A2 )
+ myEditCurrentArgument = LineEditC1A2 ;
+ else if ( send == LineEditC2A1 )
+ myEditCurrentArgument = LineEditC2A1;
+ else if ( send == LineEditC2A2 )
+ myEditCurrentArgument = LineEditC2A2 ;
+ else if ( send == LineEditC2A3 )
+ myEditCurrentArgument = LineEditC2A3 ;
+ 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_MultiTranslationDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Future name of selection */
+ QString aString = "";
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+
+ TopoDS_Shape S;
+ Standard_Boolean testResult ;
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkDir1 = false ;
+ }
+ return ;
+ }
+
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myEditCurrentArgument->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir1 = curv.Line().Direction();
+ myEditCurrentArgument->setText(aString) ;
+ myOkDir1 = true ;
+ }
+
+ if (myOkBase && myOkDir1 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkDir1 = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A3 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkDir2 = false ;
+ }
+ return ;
+ }
+
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myEditCurrentArgument->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir1 = curv.Line().Direction();
+ myEditCurrentArgument->setText(aString) ;
+ myOkDir1 = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A3 ) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir2 = curv.Line().Direction();
+ myEditCurrentArgument->setText(aString) ;
+ myOkDir2 = true ;
+ }
+
+ if (myOkBase && myOkDir1 && myOkDir2 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ case 1 :
+ {
+ if(send == SelectButtonC2A1) {
+ LineEditC2A1->setFocus() ;
+ myEditCurrentArgument = LineEditC2A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC2A2) {
+ LineEditC2A2->setFocus() ;
+ myEditCurrentArgument = LineEditC2A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ else if(send == SelectButtonC2A3) {
+ LineEditC2A3->setFocus() ;
+ myEditCurrentArgument = LineEditC2A3;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ValueChangedInt()
+// purpose : (General QT SpinBox)
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ValueChangedInt( int newIntValue )
+{
+ QSpinBox* send = (QSpinBox*)sender();
+
+ /* First constructor */
+ if( send == SpinBox_C1A4 ) {
+ myNbTimes1 = newIntValue ;
+ }
+ /* Second constructor */
+ else if( send == SpinBox_C2A5 ) {
+ myNbTimes1 = newIntValue ;
+ }
+ else if( send == SpinBox_C2A7 ) {
+ myNbTimes2 = newIntValue ;
+ }
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if (myOkBase && myOkDir1 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if (myOkBase && myOkDir1 && myOkDir2 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose : (specifig for GeometryGUI_SpinBox)
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::ValueChangedInSpinBox( double newValue )
+{
+ GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender();
+
+ /* First constructor */
+ if( send == SpinBox_C1A3 ) {
+ myStep1 = newValue ;
+ }
+ /* Second constructor */
+ else if( send == SpinBox_C2A4 ) {
+ myStep1 = newValue ;
+ }
+ else if( send == SpinBox_C2A6 ) {
+ myStep2 = newValue ;
+ }
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ if (myOkBase && myOkDir1 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ case 1 :
+ {
+ if (myOkBase && myOkDir1 && myOkDir2 ) {
+ MakeMultiTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::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() ;
+ myGeomGUI->ResetState() ;
+ myGeomGUI->SetActiveDialogBox(0) ;
+ myGeomGUI->OnDisplayAll(true) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::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() ) );
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeMultiTranslationSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_MultiTranslationDlg::MakeMultiTranslationSimulationAndDisplay()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ gp_Trsf theTransformation ;
+ mySimulationTopoDs.Nullify() ;
+
+ int i ;
+ int j ;
+ Standard_Real DX ;
+ Standard_Real DY ;
+ Standard_Real DZ ;
+ GProp_GProps System ;
+ gp_Pnt myPoint ;
+ TopoDS_Compound compound;
+ BRep_Builder B;
+
+ B.MakeCompound( compound );
+ TopoDS_Shape S ;
+
+ try {
+
+ BRepGProp::LinearProperties(myBase, System);
+ myPoint = System.CentreOfMass() ;
+ S = BRepBuilderAPI_MakeVertex(myPoint).Shape();
+
+ switch (myConstructorId)
+ {
+ case 0 :
+ {
+ gp_Vec Vec(myDir1) ;
+ Vec.Normalize();
+
+ for ( i = 0; i < myNbTimes1; i++ ) {
+ DX = i * myStep1 * Vec.X() ;
+ DY = i * myStep1 * Vec.Y() ;
+ DZ = i * myStep1 * Vec.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+
+ theTransformation.SetTranslation(myVec) ;
+ BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ mySimulationTopoDs = compound;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ break;
+ }
+ case 1 :
+ {
+ gp_Vec Vec1(myDir1) ;
+ Vec1.Normalize();
+ gp_Vec Vec2(myDir2) ;
+ Vec2.Normalize();
+
+ for ( i = 0; i < myNbTimes1; i++ ) {
+ for ( j = 0; j < myNbTimes2; j++ ) {
+ DX = i * myStep1 * Vec1.X() + j * myStep2 * Vec2.X() ;
+ DY = i * myStep1 * Vec1.Y() + j * myStep2 * Vec2.Y() ;
+ DZ = i * myStep1 * Vec1.Z() + j * myStep2 * Vec2.Z() ;
+ myVec.SetCoord( DX, DY, DZ ) ;
+
+ theTransformation.SetTranslation(myVec) ;
+ BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
+ B.Add( compound, myBRepTransformation.Shape() );
+ }
+ }
+ mySimulationTopoDs = compound ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ break;
+ }
+ }
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeMultitranslationSimulationAndDisplay" ) ;
+ return ;
+ }
+ return ;
+}
--- /dev/null
+// 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_MultiTranslationDlg.h
+// Author : Damien COQUERET
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_MULTITRANSLATION_H
+#define DIALOGBOX_MULTITRANSLATION_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOM_EdgeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QSpinBox;
+class QLineEdit;
+class QPushButton;
+class QSpinBox;
+class QRadioButton;
+class GeometryGUI;
+
+//=================================================================================
+// class : GeometryGUI_MultiTranslationDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_MultiTranslationDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_MultiTranslationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_MultiTranslationDlg();
+
+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 */
+ TopoDS_Shape myBase ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
+
+ gp_Vec myVec ;
+ int myNbTimes1 ;
+ int myNbTimes2 ;
+ Standard_Real myStep1 ;
+ Standard_Real myStep2 ;
+ gp_Dir myDir1 ;
+ gp_Dir myDir2 ;
+
+ bool myOkBase ;
+ bool myOkDir1 ;
+ bool myOkDir2 ;
+
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeMultiTranslationSimulationAndDisplay() ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QRadioButton* Constructor2;
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+
+ QGroupBox* GroupC1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+
+ QLabel* TextLabelC1A3;
+ QLabel* TextLabelC1A4;
+ GeometryGUI_SpinBox* SpinBox_C1A3 ;
+ QSpinBox* SpinBox_C1A4 ;
+
+ QGroupBox* GroupC2;
+ QPushButton* SelectButtonC2A2;
+ QLineEdit* LineEditC2A1;
+ QLineEdit* LineEditC2A2;
+ QPushButton* SelectButtonC2A1;
+ QLineEdit* LineEditC2A3;
+ QPushButton* SelectButtonC2A3;
+ QLabel* TextLabelC2A1;
+ QLabel* TextLabelC2A2;
+ QLabel* TextLabelC2A3;
+
+ QLabel* TextLabelC2A4;
+ QLabel* TextLabelC2A5;
+ QLabel* TextLabelC2A6;
+ QLabel* TextLabelC2A7;
+ GeometryGUI_SpinBox* SpinBox_C2A4 ;
+ QSpinBox* SpinBox_C2A5;
+ GeometryGUI_SpinBox* SpinBox_C2A6 ;
+ QSpinBox* SpinBox_C2A7 ;
+
+ QCheckBox* CheckBoxReverse0;
+ QCheckBox* CheckBoxReverse1;
+ QCheckBox* CheckBoxReverse2;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void LineEditReturnPressed() ;
+ void ReverseAngle1(int) ;
+ void ReverseAngle2(int) ;
+ void ValueChangedInSpinBox( double newValue ) ; /* for GeometryGUI_SpinBox */
+ void ValueChangedInt( int newIntValue ) ; /* for QT spin box ! not const ! */
+
+protected:
+ QGridLayout* GeometryGUI_MultiTranslationDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+ QGridLayout* GroupC2Layout;
+};
+
+#endif // DIALOGBOX_MULTITRANSLATION_H
--- /dev/null
+// 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_NbIsosDlg.cxx
+// Author :
+// Module : GEOM
+// $Header:
+
+using namespace std;
+#include "GeometryGUI_NbIsosDlg.h"
+#include "GeometryGUI.h"
+#include "QAD_Tools.h"
+
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qgroupbox.h>
+#include <qlayout.h>
+#include <qspinbox.h>
+
+//=================================================================================
+// class : GeometryGUI_NbIsosDlg()
+// purpose : Constructs a GeometryGUI_NbIsosDlg 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_NbIsosDlg::GeometryGUI_NbIsosDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ if ( !name )
+ setName( "GeometryGUI_NbIsosDlg" );
+ setCaption( name );
+ setSizeGripEnabled( TRUE );
+ QGridLayout* MyDialogLayout = new QGridLayout( this );
+ MyDialogLayout->setSpacing( 6 );
+ MyDialogLayout->setMargin( 11 );
+
+ /***************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setSpacing( 0 );
+ GroupC1->layout()->setMargin( 0 );
+ QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
+ GroupC1Layout->setAlignment( Qt::AlignTop );
+ GroupC1Layout->setSpacing( 6 );
+ GroupC1Layout->setMargin( 11 );
+
+ TextLabel1 = new QLabel( GroupC1, "TextLabel1" );
+ TextLabel1->setText( tr( "GEOM_MEN_ISOU") );
+ GroupC1Layout->addWidget( TextLabel1, 0, 0 );
+
+ SpinBoxU = new QSpinBox( GroupC1, "SpinBoxU" );
+ SpinBoxU->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBoxU->setMinValue( 1 );
+ SpinBoxU->setValue( 1 );
+ GroupC1Layout->addWidget( SpinBoxU, 0, 1 );
+
+ TextLabel2 = new QLabel( GroupC1, "TextLabel2" );
+ TextLabel2->setText( tr( "GEOM_MEN_ISOV") ) ;
+ GroupC1Layout->addWidget( TextLabel2, 0, 2 );
+
+ SpinBoxV = new QSpinBox( GroupC1, "SpinBoxV");
+ SpinBoxV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpinBoxV->setValue( 1 );
+ SpinBoxV->setMinValue( 1 );
+ GroupC1Layout->addWidget( SpinBoxV, 0, 3 );
+
+ /***************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ buttonOk = new QPushButton( GroupButtons, "buttonOk" );
+ buttonOk->setText( tr( "GEOM_BUT_OK" ) ) ;
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+
+ GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
+ buttonCancel->setText( tr( "GEOM_BUT_CANCEL" ) ) ;
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+ /***************************************************************/
+
+ MyDialogLayout->addWidget( GroupC1, 0, 0 );
+ MyDialogLayout->addWidget( GroupButtons, 1, 0 );
+
+ /* Retrieve GeomGUI */
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ // signals and slots connections
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ /* Move widget on the botton right corner of main widget */
+ QAD_Tools::centerWidget( this, parent );
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_NbIsosDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_NbIsosDlg::~GeometryGUI_NbIsosDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
--- /dev/null
+// 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_NbIsosDlg.h
+// Author :
+// Module : GEOM
+// $Header:
+
+#ifndef GEOMETRYGUI_NBISOSDLG_H
+#define GEOMETRYGUI_NBISOSDLG_H
+
+#include <qdialog.h>
+
+class QLabel;
+class QSpinBox;
+class QPushButton;
+class GeometryGUI;
+
+//=================================================================================
+// class : GeometryGUI_NbIsosDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_NbIsosDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_NbIsosDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_NbIsosDlg();
+
+ GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
+
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QLabel* TextLabel1 ;
+ QLabel* TextLabel2 ;
+ QSpinBox* SpinBoxU ;
+ QSpinBox* SpinBoxV ;
+};
+
+#endif // GEOMETRYGUI_NBISOSDLG_H
--- /dev/null
+// 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_OrientationDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_OrientationDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Config.h"
+#include "utilities.h"
+
+#include <TopoDS_Compound.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <TopExp_Explorer.hxx>
+
+#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 <qvalidator.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+
+//=================================================================================
+// class : GeometryGUI_OrientationDlg()
+// purpose : Constructs a GeometryGUI_OrientationDlg 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_OrientationDlg::GeometryGUI_OrientationDlg( 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_ORIENTATION")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ if ( !name )
+ setName( "GeometryGUI_OrientationDlg" );
+ resize( 303, 242 );
+ setCaption( tr( "GEOM_ORIENTATION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_OrientationDlgLayout = new QGridLayout( this );
+ GeometryGUI_OrientationDlgLayout->setSpacing( 6 );
+ GeometryGUI_OrientationDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_ORIENTATION" ) );
+ 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_OrientationDlgLayout->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_OrientationDlgLayout->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 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+
+ /* Spin box construction */
+ SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A2" ) ;
+ GroupC1Layout->addWidget( SpinBox_C1A2, 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_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_VECTOR_LENGTH" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" );
+ CheckBoxReverse->setText( tr( "GEOM_ORIENTATION_OPT" ) );
+ GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 2 );
+ GeometryGUI_OrientationDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+
+}
+
+//=================================================================================
+// function : ~GeometryGUI_OrientationDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_OrientationDlg::~GeometryGUI_OrientationDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::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_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_C1A2->SetValue( 25.0 ) ; /* = myLength */
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ CheckBoxReverse->setChecked( FALSE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ myLength = 25.0 ;
+ myOkShape = false ;
+ myOkLength = true;
+ mySimulationTopoDs.Nullify() ;
+ myShape.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);
+
+ /* 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( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseOrientation(int) ) ) ;
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( SpinBox_C1A2, 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_OrientationDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::ClickOnApply()
+{
+ /* Leave simulation display in this method ! */
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkShape && CheckBoxReverse->isChecked() && myOkLength == true ) {
+ myGeomGUI->MakeOrientationChangeAndDisplay( myGeomShape ) ;
+ CheckBoxReverse->setChecked( FALSE );
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::ClickOnCancel()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::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 : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_OrientationDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ this->mySimulationTopoDs.Nullify() ;
+
+ /* Name of future selection */
+ QString aString = "";
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ LineEditC1A1->setText("") ;
+ this->myOkShape = false ;
+ }
+ return ;
+ }
+
+ /* nbSel == 1 ! */
+ TopoDS_Shape S;
+ Standard_Boolean testResult ;
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ /* Constructor */
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ LineEditC1A1->setText(aString) ;
+ myShape = S ;
+ myOkShape = true ;
+ }
+
+ if( myOkShape && myOkLength ) {
+ MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::ValueChangedInSpinBox( double newValue )
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ QObject* send = (QObject*)sender() ;
+ if( send == SpinBox_C1A2 ) {
+ this->myLength = newValue ;
+ myOkLength = true ;
+ }
+
+ if ( myConstructorId == 0 && myOkShape && myOkLength == true ) {
+ MakeOrientationSimulationAndDisplay( this->myShape, this->myLength ) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ GroupC1->setEnabled(true) ;
+
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_OrientationDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+
+//===========================================================================================
+// function : ReverseOrientation()
+// purpose :
+//===========================================================================================
+void GeometryGUI_OrientationDlg::ReverseOrientation(int state)
+{
+ if( this->myOkShape && myOkLength == true ) {
+ MakeOrientationSimulationAndDisplay( this->myShape, this-> myLength ) ;
+ }
+ return ;
+}
+
+
+//===========================================================================================
+// function : MakeOrientationSimulationAndDisplay()
+// purpose : Create 'aCompound1' and 'aCompound2' each contains edges oriented
+// : respectively FORWARD and REVERSE for all faces of 'aTopoDS'
+// : These edges represent normal vectors on faces of 'aTopoDS'
+// : For a unique edge an arrow is displayed to show its orientation.
+//===========================================================================================
+void GeometryGUI_OrientationDlg::MakeOrientationSimulationAndDisplay(const TopoDS_Shape& aTopoDS, Standard_Real length )
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ TopoDS_Compound aCompound1, aCompound2 ;
+ TopoDS_Compound NullComp ;
+ BRep_Builder aBuilder1, aBuilder2;
+ aCompound1 = aCompound2 = NullComp ;
+ aBuilder1.MakeCompound(aCompound1) ;
+ aBuilder2.MakeCompound(aCompound2) ;
+
+ if( aTopoDS.IsNull() )
+ return ;
+
+ /* Case of an edge */
+ if( aTopoDS.ShapeType() == TopAbs_EDGE ) {
+ /* Try to display a cone simulation shape to show direction of edge */
+ TopoDS_Shape tmpShape = aTopoDS ;
+ if( this->CheckBoxReverse->isChecked() ) {
+ if( aTopoDS.Orientation() == TopAbs_FORWARD)
+ tmpShape.Orientation(TopAbs_REVERSED) ;
+ else
+ tmpShape.Orientation(TopAbs_FORWARD) ;
+ }
+ if( myGeomGUI->CreateArrowForLinearEdge( tmpShape, mySimulationTopoDs ) ) {
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ return ;
+ }
+
+
+ gp_Pnt P1, P2 ;
+ gp_Vec V, V1, V2 ;
+ TopExp_Explorer ex( aTopoDS, TopAbs_FACE );
+ int test = 0 ;
+ while (ex.More()) {
+
+ const TopoDS_Face& F = TopoDS::Face(ex.Current());
+ /* find the center of the minmax */
+ BRepAdaptor_Surface SF(F);
+ Standard_Real u, v, x;
+
+ u = SF.FirstUParameter();
+ x = SF.LastUParameter();
+ if ( Precision::IsInfinite(u) ) {
+ if( Precision::IsInfinite(x) ) u = 0.0 ; else u = x ;
+ }
+ else if ( !Precision::IsInfinite(x) )
+ u = (u+x) / 2.0 ;
+
+ v = SF.FirstVParameter();
+ x = SF.LastVParameter();
+ if ( Precision::IsInfinite(v) ) {
+ if ( Precision::IsInfinite(x) ) v = 0.0 ; else v = x ;
+ }
+ else if ( !Precision::IsInfinite(x) )
+ v = (v+x) / 2.0 ;
+
+ SF.D1( u, v, P1, V1, V2 );
+ V = V1.Crossed(V2);
+ x = V.Magnitude();
+ if ( x > 1.e-10 )
+ V.Multiply( length/x );
+ else {
+ V.SetCoord( length/2.0, 0.0, 0.0 ) ;
+ MESSAGE ("Null normal in Orientation " << endl ) ;
+ }
+
+ P2 = P1;
+ /* test orientation of each face and displays forward (aCompound1) */
+ if( F.Orientation() == TopAbs_FORWARD )
+ P2.Translate(V);
+ else
+ P2.Translate(-V) ;
+ BRepBuilderAPI_MakeEdge anEdge(P1, P2) ;
+ aBuilder1.Add( aCompound1, anEdge ) ;
+
+ P2 = P1;
+ /* test orientation of each face and displays forward (aCompound2) */
+ if( F.Orientation() == TopAbs_FORWARD )
+ P2.Translate(-V);
+ else
+ P2.Translate(V) ;
+ anEdge = BRepBuilderAPI_MakeEdge(P1, P2) ;
+ aBuilder2.Add( aCompound2, anEdge ) ;
+
+ ex.Next();
+ test++ ;
+ }
+
+ /* display simulation compounds */
+ if( test > 0 && this->CheckBoxReverse->isChecked() ) {
+ mySimulationTopoDs = aCompound1 ;
+ }
+ else if ( test > 0 && !CheckBoxReverse->isChecked() ) {
+ mySimulationTopoDs = aCompound2 ;
+ }
+ if(!mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
+
+ return ;
+}
--- /dev/null
+// 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_OrientationDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_ORIENTATION_H
+#define DIALOGBOX_ORIENTATION_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <Precision.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+#include <qvalidator.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : DialogBox_ORIENTATION
+// purpose :
+//=================================================================================
+class GeometryGUI_OrientationDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_OrientationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_OrientationDlg();
+
+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 */
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myShape */
+ TopoDS_Shape myShape ; /* topology used */
+ Standard_Real myLength ; /* to simulate normal vector */
+ bool myOkShape ;
+ bool myOkLength ;
+ QDoubleValidator *myVa ; /* Double validator for numeric input */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeOrientationSimulationAndDisplay( const TopoDS_Shape& aTopoDS, Standard_Real length ) ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+ QGroupBox* GroupC1;
+ QLineEdit* LineEditC1A1;
+ GeometryGUI_SpinBox* SpinBox_C1A2 ;
+
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ QCheckBox* CheckBoxReverse;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void LineEditReturnPressed() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ReverseOrientation(int state) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+
+ QGridLayout* GeometryGUI_OrientationDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_ORIENTATION_H
--- /dev/null
+// 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_PartitionDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PartitionDlg.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 <qimage.h>
+#include <qpixmap.h>
+
+#define MIN_EDIT_SIZE 150
+
+//=================================================================================
+// class : GeometryGUI_PartitionDlg()
+// purpose : Constructs a GeometryGUI_PartitionDlg 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_PartitionDlg::GeometryGUI_PartitionDlg( 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_PARTITION")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+// QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PARTITION_KEEP_FACES")));
+
+ if ( !name )
+ setName( "GeometryGUI_PartitionDlg" );
+ setCaption( tr( "GEOM_PARTITION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ QGridLayout* GeometryGUI_PartitionDlgLayout = new QGridLayout( this );
+ GeometryGUI_PartitionDlgLayout->setSpacing( 6 );
+ GeometryGUI_PartitionDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ /* Constructor group */
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) );
+ GroupConstructors->setColumnLayout(0, Qt::Vertical );
+ GroupConstructors->layout()->setSpacing( 0 );
+ GroupConstructors->layout()->setMargin( 0 );
+ QGridLayout* GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
+ GroupConstructorsLayout->setAlignment( Qt::AlignTop );
+ GroupConstructorsLayout->setSpacing( 6 );
+ GroupConstructorsLayout->setMargin( 11 );
+
+ Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
+ Constructor1->setPixmap( image0 );
+ Constructor1->setChecked( TRUE );
+ Constructor1->setMinimumSize( QSize( 50, 0 ) );
+ GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
+ GroupConstructorsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 0 );
+
+ GeometryGUI_PartitionDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ /* Arguments group */
+ /***************************************************************/
+ /* Shapes and Tools */
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_PARTITION" ) );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setSpacing( 0 );
+ GroupC1->layout()->setMargin( 0 );
+ QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
+ GroupC1Layout->setAlignment( Qt::AlignTop );
+ GroupC1Layout->setSpacing( 6 );
+ GroupC1Layout->setMargin( 11 );
+
+ TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
+ TextLabelC1A1->setText( tr( "GEOM_OBJECTS" ) );
+ GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
+ SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
+ SelectButtonC1A1->setPixmap( image1 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ LineEditC1A1->setMinimumSize(MIN_EDIT_SIZE, 0);
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+
+ TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_TOOL_OBJECT" ) );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setPixmap( image1 );
+ SelectButtonC1A2->setToggleButton( FALSE );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ LineEditC1A2->setMinimumSize(MIN_EDIT_SIZE, 0);
+ GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
+
+ /* Limit */
+ TextLabelComboBox1 = new QLabel( GroupC1, "TextLabelComboBox1" );
+ TextLabelComboBox1->setText( tr( "RECONSTRUCTION_LIMIT") );
+ GroupC1Layout->addWidget( TextLabelComboBox1, 2, 0 );
+ ComboBox1 = new QComboBox( FALSE, GroupC1, "ComboBox1" );
+ ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ ComboBox1->setMinimumSize(MIN_EDIT_SIZE, 0);
+ GroupC1Layout->addWidget( ComboBox1, 2, 2 );
+
+ GeometryGUI_PartitionDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ /***************************************************************/
+ /* Result suppresion */
+ /***************************************************************/
+ GroupC2 = new QGroupBox( this, "GroupC2" );
+ GroupC2->setTitle( tr( "SUPPRESS_RESULT") );
+ GroupC2->setColumnLayout(0, Qt::Vertical );
+ GroupC2->layout()->setSpacing( 0 );
+ GroupC2->layout()->setMargin( 0 );
+ QGridLayout* GroupC2Layout = new QGridLayout( GroupC2->layout() );
+ GroupC2Layout->setAlignment( Qt::AlignTop );
+ GroupC2Layout->setSpacing( 6 );
+ GroupC2Layout->setMargin( 11 );
+
+ TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
+ TextLabelC2A1->setText( tr( "SUPPRESS_RESULT_INSIDE") );
+ GroupC2Layout->addWidget( TextLabelC2A1, 0, 0 );
+ SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
+ SelectButtonC2A1->setPixmap( image1 );
+ GroupC2Layout->addWidget( SelectButtonC2A1, 0, 1 );
+ LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
+ GroupC2Layout->addWidget( LineEditC2A1, 0, 2 );
+
+ TextLabelC2A2 = new QLabel( GroupC2, "TextLabelC2A2" );
+ TextLabelC2A2->setText( tr( "SUPPRESS_RESULT_OUTSIDE") );
+ GroupC2Layout->addWidget( TextLabelC2A2, 1, 0 );
+ SelectButtonC2A2 = new QPushButton( GroupC2, "SelectButtonC2A2" );
+ SelectButtonC2A2->setPixmap( image1 );
+ GroupC2Layout->addWidget( SelectButtonC2A2, 1, 1 );
+ LineEditC2A2 = new QLineEdit( GroupC2, "LineEditC2A2" );
+ GroupC2Layout->addWidget( LineEditC2A2, 1, 2 );
+
+ GeometryGUI_PartitionDlgLayout->addWidget( GroupC2, 2, 0 );
+
+ /***************************************************************/
+ /* <OK>, <Apply>, <Cancel> buttons */
+ /***************************************************************/
+ GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ buttonOk = new QPushButton( GroupButtons, "buttonOk" );
+ buttonOk->setText( tr( "GEOM_BUT_OK" ) );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+
+ buttonApply = new QPushButton( GroupButtons, "buttonApply" );
+ buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
+ buttonApply->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
+
+ GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 );
+
+ buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
+ buttonCancel->setText( tr( "GEOM_BUT_CLOSE" ) );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
+
+ GeometryGUI_PartitionDlgLayout->addWidget( GroupButtons, 3, 0 );
+
+ /***************************************************************/
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_PartitionDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_PartitionDlg::~GeometryGUI_PartitionDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::Init( SALOME_Selection* Sel )
+{
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myOkListShapes = myOkListTools = myOkKeepShape = myOkRemoveShape = false ;
+
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ /* type for sub shape selection */
+// ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SHAPE" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SOLID" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_SHELL" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_FACE" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_WIRE" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_EDGE" ) );
+ ComboBox1->insertItem( tr( "RECONSTRUCTION_LIMIT_VERTEX" ) );
+
+ /* Current item is 'Shape' */
+ ComboBox1->setCurrentItem(0);
+ myLimit = ComboBox1->currentItem();
+
+ /* 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( ComboBox1, SIGNAL( activated(int) ), this, SLOT( ComboTextChanged() ) );
+
+ connect( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC1A2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( SelectButtonC2A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC2A2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( LineEditC1A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC1A2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A2, 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 */
+
+ ComboTextChanged();
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ if (myOkListShapes || myOkListTools || myOkKeepShape || myOkRemoveShape)
+ {
+ GEOM::shape_type limit;
+ switch (myLimit) {
+// case 0: limit = GEOM::SOLID ; break;
+ case 0: limit = GEOM::SHAPE ; break;
+ case 1: limit = GEOM::SHELL ; break;
+ case 2: limit = GEOM::FACE ; break;
+ case 3: limit = GEOM::WIRE ; break;
+ case 4: limit = GEOM::EDGE ; break;
+ case 5: limit = GEOM::VERTEX; break;
+ default:limit = GEOM::SHAPE;
+ }
+ myGeomGUI->MakePartitionAndDisplay (myListShapes,
+ myListTools,
+ myListKeepInside,
+ myListRemoveInside,
+ limit);
+
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::ClickOnCancel()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose :
+//=================================================================================
+// void GeometryGUI_PartitionDlg::ConstructorsClicked(int constructorId)
+// {
+// }
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_PartitionDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ QString aString = ""; /* name of selection */
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+
+ if ( nbSel < 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myOkListShapes = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myOkListTools = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myOkListTools = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ myOkListTools = false ;
+ }
+ return ;
+ }
+
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkListShapes = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListTools) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkListTools = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A1 ) {
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListRemoveInside) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkKeepShape = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC2A2 ) {
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListKeepInside) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkRemoveShape = true ;
+ }
+ /* no simulation */
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+
+ if (send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2 ;
+ }
+ else if(send == SelectButtonC2A1) {
+ LineEditC2A1->setFocus() ;
+ myEditCurrentArgument = LineEditC2A1 ;
+ }
+ else if(send == SelectButtonC2A2) {
+ LineEditC2A2->setFocus() ;
+ myEditCurrentArgument = LineEditC2A2 ;
+ }
+ SelectionIntoArgument() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEditC1A1 )
+ myEditCurrentArgument = LineEditC1A1 ;
+ else if ( send == LineEditC1A2 )
+ myEditCurrentArgument = LineEditC1A2 ;
+ else if ( send == LineEditC2A1 )
+ myEditCurrentArgument = LineEditC2A1 ;
+ else if ( send == LineEditC2A2 )
+ myEditCurrentArgument = LineEditC2A2 ;
+ 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_PartitionDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupC2->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupC1->setEnabled(true) ;
+ GroupC2->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PartitionDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+//=======================================================================
+//function : ComboTextChanged
+//purpose :
+//=======================================================================
+
+void GeometryGUI_PartitionDlg::ComboTextChanged()
+{
+
+ myLimit = ComboBox1->currentItem();
+ GroupC2->setEnabled( ComboBox1->currentItem() < 3 );
+
+ return ;
+}
--- /dev/null
+// 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_PartitionDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_PARTITION_H
+#define DIALOGBOX_PARTITION_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <qdialog.h>
+
+class QButtonGroup;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QComboBox;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_PartitionDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PartitionDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PartitionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_PartitionDlg();
+
+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 ;
+ GEOM::GEOM_Gen::ListOfIOR myListTools ;
+ GEOM::GEOM_Gen::ListOfIOR myListRemoveInside ;
+ GEOM::GEOM_Gen::ListOfIOR myListKeepInside ;
+
+ bool myOkListShapes ; /* to check when argument is defined */
+ bool myOkListTools ; /* to check when argument is defined */
+ bool myOkKeepShape ; /* to check when argument is defined */
+ bool myOkRemoveShape ; /* to check when argument is defined */
+ int myLimit;
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+
+ /* common buttons */
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+
+ /* constructor radiobuttons */
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+
+ /* Arguments group */
+ QGroupBox* GroupC1;
+ QLineEdit* LineEditC1A1;
+ QLabel* TextLabelC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLineEdit* LineEditC1A2;
+ QLabel* TextLabelC1A2;
+ QPushButton* SelectButtonC1A2;
+
+ /* limit */
+ QComboBox* ComboBox1;
+ QLabel* TextLabelComboBox1;
+
+ /* Keep Inside and Remove Inside feilds */
+ QGroupBox* GroupC2;
+ QLineEdit* LineEditC2A1;
+ QLabel* TextLabelC2A1;
+ QPushButton* SelectButtonC2A1;
+ QLineEdit* LineEditC2A2;
+ QLabel* TextLabelC2A2;
+ QPushButton* SelectButtonC2A2;
+
+private slots:
+
+ //void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void LineEditReturnPressed() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ComboTextChanged() ;
+};
+
+#endif // DIALOGBOX_PARTITION_H
--- /dev/null
+// 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_PipeDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PipeDlg.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>
+
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <BRepOffsetAPI_MakePipe.hxx>
+#include <BRepAlgoAPI.hxx>
+
+
+//=================================================================================
+// class : GeometryGUI_PipeDlg()
+// purpose : Constructs a GeometryGUI_PipeDlg 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_PipeDlg::GeometryGUI_PipeDlg( 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_PIPE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_PipeDlg" );
+ resize( 303, 225 );
+ setCaption( tr( "GEOM_PIPE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_PipeDlgLayout = new QGridLayout( this );
+ GeometryGUI_PipeDlgLayout->setSpacing( 6 );
+ GeometryGUI_PipeDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_PIPE" ) );
+ 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_PipeDlgLayout->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_PipeDlgLayout->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 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 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_BASE_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_PATH_OBJECT" ) );
+ 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 );
+ GeometryGUI_PipeDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_PipeDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_PipeDlg::~GeometryGUI_PipeDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::Init( SALOME_Selection* Sel )
+{
+ mySelection = Sel ;
+ myShape1.Nullify() ;
+ myShape2.Nullify() ;
+ myConstructorId = 0 ;
+
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ Constructor1->setChecked( TRUE );
+ myOkShape1 = myOkShape2 = false ;
+
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+ mySimulationTopoDs.Nullify() ;
+
+ 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( 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( 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_PipeDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ //GeometryGUI::GetGeometryGUI()->EraseSimulationShape() ;
+
+ switch (constructorId)
+ {
+ case 0:
+ {
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnAply()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkShape1 && myOkShape2) {
+ myGeomGUI->MakePipeAndDisplay(myGeomShape2 ,myGeomShape1) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::ClickOnCancel()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection has changed
+//=================================================================================
+void GeometryGUI_PipeDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ myEditCurrentArgument->setText("") ;
+ QString aString = ""; /* name of future selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myOkShape1 = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ 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 == LineEditC1A1 &&
+ S.ShapeType() != TopAbs_COMPSOLID &&
+ S.ShapeType() != TopAbs_COMPOUND &&
+ S.ShapeType() != TopAbs_SOLID &&
+ S.ShapeType() != TopAbs_SHAPE ) {
+ myGeomShape1 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myShape1 = S ;
+ LineEditC1A1->setText(aString) ;
+ myOkShape1 = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 && ( S.ShapeType() == TopAbs_WIRE || S.ShapeType() == TopAbs_EDGE) ) {
+ myGeomShape2 = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myShape2 = S ;
+ LineEditC1A2->setText(aString) ;
+ myOkShape2 = true ;
+ }
+
+ if (myOkShape1 && myOkShape2 && !myShape1.IsNull() && !myShape2.IsNull())
+ {
+ //Make preview
+ TopoDS_Shape tds ;
+ TopoDS_Wire aWire ;
+
+ if( myShape2.ShapeType() == TopAbs_WIRE )
+ aWire = TopoDS::Wire(myShape2) ;
+ else
+ if ( myShape2.ShapeType() == TopAbs_EDGE )
+ {
+ TopoDS_Edge aEdge = TopoDS::Edge(myShape2) ;
+ aWire = BRepBuilderAPI_MakeWire(aEdge);
+
+ }
+
+ try
+ {
+ tds = BRepOffsetAPI_MakePipe(aWire,myShape1 ) ;
+ if ( BRepAlgoAPI::IsValid(tds) )
+ {
+ //Draw Pipe
+ mySimulationTopoDs = tds;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ }
+ catch(Standard_Failure)
+ {
+ }
+ }
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if( send == SelectButtonC1A1 ) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::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 : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ }
+ return ;
+}
+
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void GeometryGUI_PipeDlg::enterEvent( QEvent * )
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PipeDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate any 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 ;
+}
--- /dev/null
+// 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_PipeDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_PIPE_H
+#define DIALOGBOX_PIPE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <BRepOffsetAPI_MakePipe.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_PipeDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PipeDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PipeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_PipeDlg();
+
+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 */
+ // Handle(GEOM_ShapeTypeFilter) myEdgFilter ; /* Filter selection */
+ // Handle(GEOM_ShapeTypeFilter) myWireFilter ; /* Filter selection */
+
+ TopoDS_Shape mySimulationTopoDs ; /* Shape used for simulation display */
+
+ 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;
+
+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_PipeDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_PIPE_H
--- /dev/null
+// 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_PlaneDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PlaneDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Config.h"
+#include "utilities.h"
+
+#include <BRepAdaptor_Surface.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <Precision.hxx>
+
+#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 <qlabel.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qvalidator.h>
+#include <qevent.h>
+
+
+//=================================================================================
+// class : GeometryGUI_PlaneDlg()
+// purpose : Constructs a GeometryGUI_PlaneDlg 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_PlaneDlg::GeometryGUI_PlaneDlg( 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_PLANE_PV")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PLANE_DXYZ")));
+ QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_PLANE_FACE")));
+
+ if ( !name )
+ setName( "GeometryGUI_PlaneDlg" );
+ resize( 365, 220 );
+ setCaption( tr( "GEOM_PLANE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_PlaneDlgLayout = new QGridLayout( this );
+ GeometryGUI_PlaneDlgLayout->setSpacing( 6 );
+ GeometryGUI_PlaneDlgLayout->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_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_PlaneDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_PLANE" ) );
+ 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_PlaneDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ GroupPointDirection = new QGroupBox( this, "GroupPointDirection" );
+ GroupPointDirection->setTitle( tr( "GEOM_PLANE_PV" ) );
+ GroupPointDirection->setColumnLayout(0, Qt::Vertical );
+ GroupPointDirection->layout()->setSpacing( 0 );
+ GroupPointDirection->layout()->setMargin( 0 );
+ GroupPointDirectionLayout = new QGridLayout( GroupPointDirection->layout() );
+ GroupPointDirectionLayout->setAlignment( Qt::AlignTop );
+ GroupPointDirectionLayout->setSpacing( 6 );
+ GroupPointDirectionLayout->setMargin( 11 );
+ LineEditDirection = new QLineEdit( GroupPointDirection, "LineEditDirection" );
+ LineEditDirection->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditDirection->sizePolicy().hasHeightForWidth() ) );
+ GroupPointDirectionLayout->addWidget( LineEditDirection, 1, 2 );
+ LineEditPt1 = new QLineEdit( GroupPointDirection, "LineEditPt1" );
+ LineEditPt1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt1->sizePolicy().hasHeightForWidth() ) );
+ GroupPointDirectionLayout->addWidget( LineEditPt1, 0, 2 );
+ SelectButtonPt1 = new QPushButton( GroupPointDirection, "SelectButtonPt1" );
+ SelectButtonPt1->setText( tr( "" ) );
+ SelectButtonPt1->setPixmap( image1 );
+ GroupPointDirectionLayout->addWidget( SelectButtonPt1, 0, 1 );
+ SelectButtonDirection = new QPushButton( GroupPointDirection, "SelectButtonDirection" );
+ SelectButtonDirection->setText( tr( "" ) );
+ SelectButtonDirection->setPixmap( image1 );
+ GroupPointDirectionLayout->addWidget( SelectButtonDirection, 1, 1 );
+ TextLabelDirection = new QLabel( GroupPointDirection, "TextLabelDirection" );
+ TextLabelDirection->setText( tr( "GEOM_VECTOR" ) );
+ TextLabelDirection->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelDirection->setFrameShape( QLabel::NoFrame );
+ TextLabelDirection->setFrameShadow( QLabel::Plain );
+ GroupPointDirectionLayout->addWidget( TextLabelDirection, 1, 0 );
+ TextLabelPt1 = new QLabel( GroupPointDirection, "TextLabelPt1" );
+ TextLabelPt1->setText( tr( "GEOM_POINT" ) );
+ TextLabelPt1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelPt1->setFrameShape( QLabel::NoFrame );
+ TextLabelPt1->setFrameShadow( QLabel::Plain );
+ GroupPointDirectionLayout->addWidget( TextLabelPt1, 0, 0 );
+
+ SpinBox_C1Size = new GeometryGUI_SpinBox( GroupPointDirection, "SpinBox_C1Size" );
+ GroupPointDirectionLayout->addWidget( SpinBox_C1Size, 2, 2 );
+ TextLabelC1Size = new QLabel( GroupPointDirection, "TextLabelC1Size" );
+ TextLabelC1Size->setText( tr( "GEOM_PLANE_SIZE" ) );
+ TextLabelC1Size->setMinimumSize( QSize( 60, 0 ) );
+ GroupPointDirectionLayout->addWidget( TextLabelC1Size, 2, 0 );
+
+ GeometryGUI_PlaneDlgLayout->addWidget( GroupPointDirection, 1, 0 );
+
+ /***************************************************************/
+ GroupPointPlusCoordinates = new QGroupBox( this, "GroupPointPlusCoordinates" );
+ GroupPointPlusCoordinates->setTitle( tr( "GEOM_PLANE_PVC" ) );
+ GroupPointPlusCoordinates->setColumnLayout(0, Qt::Vertical );
+ GroupPointPlusCoordinates->layout()->setSpacing( 0 );
+ GroupPointPlusCoordinates->layout()->setMargin( 0 );
+ GroupPointPlusCoordinatesLayout = new QGridLayout( GroupPointPlusCoordinates->layout() );
+ GroupPointPlusCoordinatesLayout->setAlignment( Qt::AlignTop );
+ GroupPointPlusCoordinatesLayout->setSpacing( 6 );
+ GroupPointPlusCoordinatesLayout->setMargin( 11 );
+
+ LineEditPt2 = new QLineEdit( GroupPointPlusCoordinates, "LineEditPt2" );
+ LineEditPt2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditPt2->sizePolicy().hasHeightForWidth() ) );
+ GroupPointPlusCoordinatesLayout->addMultiCellWidget( LineEditPt2, 0, 0, 5, 8 );
+
+ SelectButtonPt2 = new QPushButton( GroupPointPlusCoordinates, "SelectButtonPt2" );
+ SelectButtonPt2->setText( tr( "" ) );
+ SelectButtonPt2->setPixmap( image1 );
+ SelectButtonPt2->setMaximumSize( QSize( 28, 32767 ) );
+ GroupPointPlusCoordinatesLayout->addWidget( SelectButtonPt2, 0, 4 );
+
+ TextLabelPt2 = new QLabel( GroupPointPlusCoordinates, "TextLabelPt2" );
+ TextLabelPt2->setText( tr( "GEOM_POINT" ) );
+ TextLabelPt2->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelPt2->setFrameShape( QLabel::NoFrame );
+ TextLabelPt2->setFrameShadow( QLabel::Plain );
+ GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelPt2, 0, 0, 0, 3 );
+
+ SpinBox_DX = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DX" );
+ SpinBox_DX->setMinimumSize( QSize( 50, 0 ) );
+ SpinBox_DX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DX->sizePolicy().hasHeightForWidth() ) );
+ GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_DX, 1, 1, 3, 4 );
+
+ SpinBox_DY = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DY" );
+ SpinBox_DY->setMinimumSize( QSize( 50, 0 ) );
+ SpinBox_DY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DY->sizePolicy().hasHeightForWidth() ) );
+ GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DY, 1, 6 );
+
+ SpinBox_DZ = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_DZ" );
+ SpinBox_DZ->setMinimumSize( QSize( 50, 0 ) );
+ SpinBox_DZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DZ->sizePolicy().hasHeightForWidth() ) );
+ GroupPointPlusCoordinatesLayout->addWidget( SpinBox_DZ, 1, 8 );
+
+ TextLabel_DX = new QLabel( GroupPointPlusCoordinates, "TextLabel_DX" );
+ TextLabel_DX->setText( tr( "GEOM_DX" ) );
+ GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DX, 1, 2 );
+
+ TextLabel_DY = new QLabel( GroupPointPlusCoordinates, "TextLabel_DY" );
+ TextLabel_DY->setText( tr( "GEOM_DY" ) );
+ GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DY, 1, 5 );
+
+ TextLabel_DZ = new QLabel( GroupPointPlusCoordinates, "TextLabel_DZ" );
+ TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
+ GroupPointPlusCoordinatesLayout->addWidget( TextLabel_DZ, 1, 7 );
+
+ TextLabelCoordinates = new QLabel( GroupPointPlusCoordinates, "TextLabelCoordinates" );
+ TextLabelCoordinates->setText( tr( "GEOM_COOR" ) );
+ TextLabelCoordinates->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelCoordinates->setFrameShape( QLabel::NoFrame );
+ TextLabelCoordinates->setFrameShadow( QLabel::Plain );
+ GroupPointPlusCoordinatesLayout->addWidget( TextLabelCoordinates, 1, 0 );
+
+ TextLabelC2Size = new QLabel( GroupPointPlusCoordinates, "TextLabelC2Size" );
+ TextLabelC2Size->setText( tr( "GEOM_PLANE_SIZE" ) );
+ TextLabelC2Size->setMinimumSize( QSize( 60, 0 ) );
+ GroupPointPlusCoordinatesLayout->addMultiCellWidget( TextLabelC2Size, 2, 2, 0, 1 );
+
+ SpinBox_C2Size = new GeometryGUI_SpinBox( GroupPointPlusCoordinates, "SpinBox_C2Size" );
+ GroupPointPlusCoordinatesLayout->addMultiCellWidget( SpinBox_C2Size, 2, 2, 5, 8 );
+
+ QSpacerItem* spacer_c = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupPointPlusCoordinatesLayout->addMultiCell( spacer_c, 2, 2, 2, 4 );
+ QSpacerItem* spacer_d = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupPointPlusCoordinatesLayout->addItem( spacer_d, 1, 1 );
+
+ GeometryGUI_PlaneDlgLayout->addWidget( GroupPointPlusCoordinates, 1, 0 );
+
+ /***************************************************************/
+
+ GroupFace = new QGroupBox( this, "GroupFace" );
+ GroupFace->setTitle( tr( "GEOM_FACE" ) );
+ GroupFace->setColumnLayout(0, Qt::Vertical );
+ GroupFace->layout()->setSpacing( 0 );
+ GroupFace->layout()->setMargin( 0 );
+ GroupFaceLayout = new QGridLayout( GroupFace->layout() );
+ GroupFaceLayout->setAlignment( Qt::AlignTop );
+ GroupFaceLayout->setSpacing( 6 );
+ GroupFaceLayout->setMargin( 11 );
+
+ TextLabelFace = new QLabel( GroupFace, "TextLabelFace" );
+ TextLabelFace->setFrameShadow( QLabel::Plain );
+ TextLabelFace->setFrameShape( QLabel::NoFrame );
+ TextLabelFace->setText( tr( "GEOM_SELECTION" ) );
+ TextLabelFace->setMinimumSize( QSize( 50, 0 ) );
+ GroupFaceLayout->addMultiCellWidget( TextLabelFace, 0, 0, 0, 1 );
+
+ SelectButtonFace = new QPushButton( GroupFace, "SelectButtonFace" );
+ SelectButtonFace->setText( tr( "" ) );
+ SelectButtonFace->setPixmap( image1 );
+ SelectButtonFace->setMaximumSize( QSize( 28, 32767 ) );
+ GroupFaceLayout->addWidget( SelectButtonFace, 0, 2 );
+
+ LineEditFace = new QLineEdit( GroupFace, "LineEditFace" );
+ LineEditFace->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditFace->sizePolicy().hasHeightForWidth() ) );
+ GroupFaceLayout->addWidget( LineEditFace, 0, 3 );
+
+ TextLabelC3Size = new QLabel( GroupFace, "TextLabelC3Size" );
+ TextLabelC3Size->setText( tr( "GEOM_PLANE_SIZE" ) );
+ TextLabelC3Size->setMinimumSize( QSize( 60, 0 ) );
+ GroupFaceLayout->addWidget( TextLabelC3Size, 1, 0 );
+
+ SpinBox_C3Size = new GeometryGUI_SpinBox( GroupFace, "SpinBox_C3Size" );
+ SpinBox_C3Size->setCaption( tr( "" ) );
+ GroupFaceLayout->addWidget( SpinBox_C3Size, 1, 3 );
+
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupFaceLayout->addMultiCell( spacer, 1, 1, 1, 2 );
+ QSpacerItem* spacer_e = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ GroupFaceLayout->addItem( spacer_e, 2, 3 );
+ GeometryGUI_PlaneDlgLayout->addWidget( GroupFace, 1, 0 );
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_PlaneDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_PlaneDlg::~GeometryGUI_PlaneDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+ this->destroy(TRUE, TRUE) ;
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::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_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DX->SetValue( 1.0 ) ;
+ SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DY->SetValue( 1.0 ) ;
+ SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DZ->SetValue( 1.0 ) ;
+
+ this->myTrimSize = 2000.0 ;
+ SpinBox_C1Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
+ SpinBox_C1Size->SetValue( myTrimSize ) ;
+ SpinBox_C2Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
+ SpinBox_C2Size->SetValue( myTrimSize ) ;
+ SpinBox_C3Size->RangeStepAndValidator( +0.001, 10000000.0, step, 5 ) ;
+ SpinBox_C3Size->SetValue( myTrimSize ) ;
+
+ GroupPointDirection->show();
+ GroupPointPlusCoordinates->hide() ;
+ GroupFace->hide() ;
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+
+ mySelection = Sel ;
+ myEditCurrentArgument = LineEditPt1 ;
+ mySimulationTopoDs.Nullify() ;
+ myPoint1.SetCoord( 0.0, 0.0, 0.0 );
+ myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
+
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ 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 );
+ myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom );
+ /* Filter for the next selection */
+ 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( LineEditPt1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditDirection, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( LineEditPt2, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditFace, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( SelectButtonPt1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonPt2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonFace, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonDirection, 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( SpinBox_C1Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
+ connect( SpinBox_C2Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
+ connect( SpinBox_C3Size, SIGNAL ( ValueChangedSignal( const double) ), this, SLOT( ValueChangedInSpinBox( const double) ) ) ;
+
+ 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_PlaneDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+ myOkPoint1 = myOkDirection = myOkCoordinates = myOkPlanarFace = false ;
+ mySelection->ClearFilters() ;
+ myConstructorId = constructorId ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+ switch (constructorId)
+ {
+ case 0: /* plane from a point and a direction (vector, edge...) */
+ {
+ GroupPointDirection->show();
+ GroupPointPlusCoordinates->hide() ;
+ GroupFace->hide() ;
+ myEditCurrentArgument = LineEditPt1 ;
+ LineEditPt1->setText(tr("")) ;
+ LineEditDirection->setText(tr("")) ;
+
+ /* for the first argument */
+ mySelection->AddFilter(myVertexFilter) ;
+ break;
+ }
+
+ case 1: /* plane from a point and vector coordinates */
+ {
+ GroupPointDirection->hide() ;
+ GroupPointPlusCoordinates->show() ;
+ GroupFace->hide() ;
+ myEditCurrentArgument = LineEditPt2 ;
+ LineEditPt2->setText(tr("")) ;
+ SpinBox_DX->SetValue( 1.0 ) ;
+ SpinBox_DY->SetValue( 1.0 ) ;
+ SpinBox_DZ->SetValue( 1.0 ) ;
+ myOkCoordinates = true ;
+
+ /* for the first argument */
+ mySelection->AddFilter(myVertexFilter) ;
+ break ;
+ }
+
+ case 2: /* plane from a planar face selection */
+ {
+ GroupPointDirection->hide() ;
+ GroupPointPlusCoordinates->hide() ;
+ GroupFace->show() ;
+ myEditCurrentArgument = LineEditFace ;
+ LineEditFace->setText(tr("")) ;
+
+ /* for the first argument */
+ mySelection->AddFilter(myFaceFilter) ;
+ break ;
+ }
+
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 : /* args are myPoint1 and myDx, myDy, myDz from a vector(edge) */
+ {
+ if(myOkPoint1 && myOkDirection) {
+ myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
+ }
+ break ;
+ }
+
+ case 1 : /* args are myPoint1 and myDx, myDy, myDz from a Spin Box */
+ {
+ if(myOkPoint1) {
+ myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
+ }
+ break ;
+ }
+
+ case 2 : /* arg is a planar face selection */
+ {
+ if(myOkPlanarFace) {
+ myGeomGUI->MakePlaneAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize) ;
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection has changed
+//=================================================================================
+void GeometryGUI_PlaneDlg::SelectionIntoArgument()
+{
+
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Future name of argument */
+ QString aString = "";
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if ( myEditCurrentArgument == LineEditPt1 ) {
+ LineEditPt1->setText("") ;
+ myOkPoint1 = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditDirection ) {
+ LineEditDirection->setText("") ;
+ myOkDirection = false ;
+ }
+ break ;
+ }
+ case 1:
+ {
+ if ( myEditCurrentArgument == LineEditPt2 ) {
+ LineEditPt2->setText("") ;
+ myOkPoint1 = false ;
+ }
+ break ;
+ }
+
+ case 2:
+ {
+ if ( myEditCurrentArgument == LineEditFace ) {
+ LineEditFace->setText("") ;
+ if ( aString.compare("") == 0 )
+ myOkPlanarFace = false ;
+ else
+ myOkPlanarFace = true ;
+ }
+ break ;
+ }
+
+ }
+ return ;
+ }
+
+ /* nbSel == 1 */
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+
+ /* FIRST CONSTRUCTOR */
+ if ( myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
+ LineEditPt1->setText(aString) ;
+ myOkPoint1 = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditDirection ) {
+ /* We verify if the selection is a linear edge */
+ gp_Pnt Pfirst, Plast ;
+ if( myGeomGUI->LinearEdgeExtremities(S, Pfirst, Plast ) ) {
+ myGeomGUI->GetBipointDxDyDz( Pfirst, Plast, myDx, myDy, myDz) ;
+ LineEditDirection->setText(aString) ;
+ myOkDirection = true ;
+ this->myTrimSize = SpinBox_C1Size->GetValue() ;
+ }
+ }
+
+ /* SECOND CONSTRUCTOR */
+ else if ( myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
+ LineEditPt2->setText(aString) ;
+ /* Get arguments */
+ myDx = SpinBox_DX->GetValue() ;
+ myDy = SpinBox_DY->GetValue() ;
+ myDz = SpinBox_DZ->GetValue() ;
+ this->myTrimSize = SpinBox_C2Size->GetValue() ;
+ myOkPoint1 = true ;
+ myOkCoordinates = true ;
+ }
+
+ /* THIRD CONSTRUCTOR */
+ else if ( myEditCurrentArgument == LineEditFace) {
+ if( myOkPlanarFace ) {
+ LineEditFace->setText(aString) ;
+ BRepAdaptor_Surface surf(TopoDS::Face(S));
+ gp_Pln Plane = surf.Plane();
+
+ gp_Pnt myPoint1 = Plane.Location();
+ gp_Ax1 ax = Plane.Axis();
+ myDx = (ax.Direction()).X() ;
+ myDy = (ax.Direction()).Y() ;
+ myDz = (ax.Direction()).Z() ;
+ this->myTrimSize = SpinBox_C3Size->GetValue() ;
+ }
+ }
+
+ /* Call method simulation */
+ if( ( myOkPoint1 && myOkDirection) || ( myOkPoint1 && myOkCoordinates ) || myOkPlanarFace ) {
+ if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion()*Precision::Confusion() ) {
+ MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ mySelection->ClearFilters() ;
+
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if(send == SelectButtonPt1) {
+ LineEditPt1->setFocus() ;
+ myEditCurrentArgument = LineEditPt1;
+ mySelection->AddFilter(myVertexFilter) ;
+ }
+ else if(send == SelectButtonDirection) {
+ LineEditDirection->setFocus() ;
+ myEditCurrentArgument = LineEditDirection;
+ /* Edge filter here */
+ mySelection->AddFilter(myEdgeFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+
+ case 1:
+ {
+ if(send == SelectButtonPt2) {
+ LineEditPt2->setFocus() ;
+ myEditCurrentArgument = LineEditPt2;
+ /* Vertex filter here */
+ mySelection->AddFilter(myVertexFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+
+ case 2:
+ {
+ if(send == SelectButtonFace) {
+ LineEditFace->setFocus() ;
+ myEditCurrentArgument = LineEditFace;
+ /* Face filter here */
+ mySelection->AddFilter(myFaceFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::ValueChangedInSpinBox( double newValue )
+{
+ QObject* send = (QObject*)sender() ;
+
+ if( send == SpinBox_DX ) {
+ myDx = newValue ;
+ myDy = SpinBox_DY->GetValue() ;
+ myDz = SpinBox_DZ->GetValue() ;
+ } else if( send == SpinBox_DY ) {
+ myDx = SpinBox_DX->GetValue() ;
+ myDy = newValue ;
+ myDz = SpinBox_DZ->GetValue() ;
+ } else if( send == SpinBox_DZ ) {
+ myDx = SpinBox_DX->GetValue() ;
+ myDy = SpinBox_DY->GetValue() ;
+ myDz = newValue ;
+ } else if( send == SpinBox_C1Size || send == SpinBox_C2Size || send == SpinBox_C3Size ) {
+ myTrimSize = newValue ;
+ } else
+ return ;
+
+ if ( myDx*myDx + myDy*myDy + myDz*myDz > Precision::Confusion() * Precision::Confusion() ) {
+ MakePlaneSimulationAndDisplay( myPoint1, myDx, myDy, myDz, myTrimSize ) ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEditPt1 )
+ myEditCurrentArgument = LineEditPt1 ;
+ else if ( send == LineEditDirection )
+ myEditCurrentArgument = LineEditDirection ;
+ else if ( send == LineEditPt2 )
+ myEditCurrentArgument = LineEditPt2 ;
+ else if ( send == LineEditFace )
+ myEditCurrentArgument = LineEditFace ;
+ 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_PlaneDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupPointDirection->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ GroupFace->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+
+ GroupConstructors->setEnabled(true) ;
+ GroupPointDirection->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ GroupFace->setEnabled(true) ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::enterEvent( QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+}
+
+
+
+//=================================================================================
+// function : MakePlaneSimulationAndDisplay(()
+// purpose :
+//=================================================================================
+void GeometryGUI_PlaneDlg::MakePlaneSimulationAndDisplay( const gp_Pnt& P1,
+ const Standard_Real dx,
+ const Standard_Real dy,
+ const Standard_Real dz,
+ const Standard_Real trimsize )
+{
+ try {
+ gp_Dir aDirection( dx, dy, dz ) ;
+ /* We make a trimmed plane */
+ gp_Pln gplane(P1, aDirection) ;
+ mySimulationTopoDs = BRepBuilderAPI_MakeFace(gplane, -trimsize, +trimsize, -trimsize, +trimsize) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakePlaneSimulation" << endl ) ;
+ return ;
+ }
+
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
--- /dev/null
+// 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_PlaneDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_PLANE_H
+#define DIALOGBOX_PLANE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOM_FaceFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <gp_Pnt.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+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_PlaneDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PlaneDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PlaneDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_PlaneDlg();
+
+private :
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+
+ 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 ; /* Point on the plane */
+
+ Standard_Real myDx ;
+ Standard_Real myDy ;
+ Standard_Real myDz ;
+ Standard_Real myTrimSize ;
+
+ bool myOkPoint1 ; /* true when argument is defined */
+ bool myOkDirection ;
+ bool myOkCoordinates ;
+ bool myOkPlanarFace ;
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+
+ Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filters selection */
+ Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */
+ Handle(GEOM_FaceFilter) myFaceFilter; /* Filters selection */
+
+ // Constructors
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QRadioButton* Constructor2;
+ QRadioButton* Constructor3;
+
+ // Constructor with a point + direction (vector)
+ QGroupBox* GroupPointDirection;
+
+ QLabel* TextLabelPt1;
+ QPushButton* SelectButtonPt1;
+ QLineEdit* LineEditPt1;
+
+ QLabel* TextLabelDirection;
+ QPushButton* SelectButtonDirection;
+ QLineEdit* LineEditDirection;
+
+ QLabel* TextLabelC1Size;
+ GeometryGUI_SpinBox* SpinBox_C1Size ;
+
+ // Constructor with a point + dx, dy, dz coordinates
+ QGroupBox* GroupPointPlusCoordinates;
+
+ QLabel* TextLabelPt2;
+ QPushButton* SelectButtonPt2;
+ QLineEdit* LineEditPt2;
+
+ QLabel* TextLabelCoordinates;
+ QLabel* TextLabel_DX;
+ QLabel* TextLabel_DY;
+ QLabel* TextLabel_DZ;
+ GeometryGUI_SpinBox* SpinBox_DX ;
+ GeometryGUI_SpinBox* SpinBox_DY ;
+ GeometryGUI_SpinBox* SpinBox_DZ ;
+
+ QLabel* TextLabelC2Size;
+ GeometryGUI_SpinBox* SpinBox_C2Size ;
+
+ // Constructor with a face
+ QGroupBox* GroupFace;
+
+ QLabel* TextLabelFace;
+ QPushButton* SelectButtonFace;
+ QLineEdit* LineEditFace;
+
+ QLabel* TextLabelC3Size;
+ GeometryGUI_SpinBox* SpinBox_C3Size ;
+
+ // BUTTONS
+ 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() ;
+ void MakePlaneSimulationAndDisplay( const gp_Pnt& P,
+ const Standard_Real dx,
+ const Standard_Real dy,
+ const Standard_Real dz,
+ const Standard_Real trimSize ) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+
+ QGridLayout* GeometryGUI_PlaneDlgLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupPointDirectionLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupPointPlusCoordinatesLayout;
+ QGridLayout* GroupFaceLayout;
+ QHBoxLayout* Layout2 ;
+};
+
+#endif // DIALOGBOX_PLANE_H
--- /dev/null
+// 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_PointDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PointDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_RightFrame.h"
+#include "QAD_Config.h"
+#include "QAD_Desktop.h"
+#include "QAD_Tools.h"
+#include "OCCViewer_Viewer3d.h"
+#include "utilities.h"
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAlgoAPI.hxx>
+#include <Geom_Curve.hxx>
+
+#include <qbuttongroup.h>
+#include <qframe.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qvalidator.h>
+#include <qevent.h>
+
+
+
+//=================================================================================
+// class : GeometryGUI_PointDlg()
+// purpose : Constructs a GeometryGUI_PointDlg 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_PointDlg::GeometryGUI_PointDlg( QWidget* parent,
+ const char* name,
+ SALOME_Selection* Sel,
+ const 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_POINT")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_POINT_EDGE")));
+
+ if ( !name )
+ setName( "GeometryGUI_PointDlg" );
+ resize( 303, 185 );
+ setCaption( tr( "GEOM_POINT_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_PointDlgLayout = new QGridLayout( this );
+ GeometryGUI_PointDlgLayout->setSpacing( 6 );
+ GeometryGUI_PointDlgLayout->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_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_PointDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "Constructors" ) );
+ 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( FALSE );
+ 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 );
+
+ Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
+ Constructor2->setText( tr( "" ) );
+ Constructor2->setPixmap( image2 );
+ Constructor2->setChecked( TRUE );
+ Constructor2->setMinimumSize( QSize( 50, 0 ) );
+
+ GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
+ QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupConstructorsLayout->addItem( spacer_3, 0, 3 );
+
+ GeometryGUI_PointDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+
+ /***************************************************************/
+ GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
+ GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
+ GroupCoordinates->setColumnLayout(0, Qt::Vertical );
+ GroupCoordinates->layout()->setSpacing( 0 );
+ GroupCoordinates->layout()->setMargin( 0 );
+ GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
+ GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
+ GroupCoordinatesLayout->setSpacing( 6 );
+ GroupCoordinatesLayout->setMargin( 11 );
+
+ TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" );
+ TextLabel_X->setText( tr( "GEOM_X" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 );
+ TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" );
+ TextLabel_Y->setText( tr( "GEOM_Y" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 );
+ TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" );
+ TextLabel_Z->setText( tr( "GEOM_Z" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 );
+
+ /* Spin boxes construction */
+ SpinBox_X = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_X" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 );
+ SpinBox_Y = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Y" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 );
+ SpinBox_Z = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_Z" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 );
+ GeometryGUI_PointDlgLayout->addWidget( GroupCoordinates, 1, 0 );
+
+ /***************************************************************/
+ GroupWithEdge = new QGroupBox( this, "GroupWithEdge" );
+ GroupWithEdge->setTitle( tr( "GEOM_PARAM_POINT" ) );
+ GroupWithEdge->setFrameShape( QGroupBox::Box );
+ GroupWithEdge->setFrameShadow( QGroupBox::Sunken );
+ GroupWithEdge->setColumnLayout(0, Qt::Vertical );
+ GroupWithEdge->layout()->setSpacing( 0 );
+ GroupWithEdge->layout()->setMargin( 0 );
+ GroupWithEdgeLayout = new QGridLayout( GroupWithEdge->layout() );
+ GroupWithEdgeLayout->setAlignment( Qt::AlignTop );
+ GroupWithEdgeLayout->setSpacing( 6 );
+ GroupWithEdgeLayout->setMargin( 11 );
+
+ LineEdit_Edge = new QLineEdit( GroupWithEdge, "LineEdit_Edge" );
+ GroupWithEdgeLayout->addWidget( LineEdit_Edge, 0, 2 );
+
+ SelectButton_Edge = new QPushButton( GroupWithEdge, "SelectButton_Edge" );
+ SelectButton_Edge->setText( tr( "" ) );
+ SelectButton_Edge->setPixmap( image1 );
+ SelectButton_Edge->setToggleButton( FALSE );
+ GroupWithEdgeLayout->addWidget( SelectButton_Edge, 0, 1 );
+
+ /* Spin box */
+ SpinBox_Parameter = new GeometryGUI_SpinBox( GroupWithEdge, "SpinBox_Parameter" );
+ GroupWithEdgeLayout->addWidget( SpinBox_Parameter, 1, 2 );
+
+ TextLabel_Edge = new QLabel( GroupWithEdge, "TextLabel_Edge" );
+ TextLabel_Edge->setText( tr( "GEOM_EDGE" ) );
+ TextLabel_Edge->setMinimumSize( QSize( 50, 0 ) );
+ TextLabel_Edge->setFrameShape( QLabel::NoFrame );
+ TextLabel_Edge->setFrameShadow( QLabel::Plain );
+ GroupWithEdgeLayout->addWidget( TextLabel_Edge, 0, 0 );
+
+ TextLabel_Parameter = new QLabel( GroupWithEdge, "TextLabel_Parameter" );
+ TextLabel_Parameter->setText( tr( "GEOM_PARAMETER" ) );
+ TextLabel_Parameter->setMinimumSize( QSize( 50, 0 ) );
+ TextLabel_Parameter->setFrameShape( QLabel::NoFrame );
+ TextLabel_Parameter->setFrameShadow( QLabel::Plain );
+ GroupWithEdgeLayout->addWidget( TextLabel_Parameter, 1, 0 );
+
+ GeometryGUI_PointDlgLayout->addWidget( GroupWithEdge, 1, 0 );
+ /***************************************************************/
+
+ /* Initialisation and display */
+ Init(Sel, ic) ;
+
+ /* Move widget on the botton right corner of main widget */
+ QAD_Tools::alignWidget(this, parent, AlignBottom | AlignRight);
+ /* Display Dialog */
+ this->show() ;
+}
+
+
+//=======================================================================
+// function : ~GeometryGUI_PointDlg()
+// purpose : Destructor
+//=======================================================================
+GeometryGUI_PointDlg::~GeometryGUI_PointDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::Init(SALOME_Selection* Sel, const 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_X->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_X->SetValue( 0.0 ) ;
+ SpinBox_Y->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_Y->SetValue( 0.0 ) ;
+ SpinBox_Z->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_Z->SetValue( 0.0 ) ;
+
+ /* spin box for parameter on edge */
+ double specificStep = 0.1 ;
+ SpinBox_Parameter->RangeStepAndValidator( -999999.99999, 999999.99999, specificStep, 5 ) ;
+ SpinBox_Parameter->SetValue( 0.50 ) ;
+ myParameter = 0.50 ;
+
+ GroupCoordinates->show();
+ GroupWithEdge->hide() ;
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+
+ /* filter for the second constructor */
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ myGeom = GEOM::GEOM_Gen::_narrow(comp);
+ myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
+
+ bool displayPoint = false ;
+ mySelection = Sel ;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+ myGeomGUI->SetState(POINT_METHOD) ;
+
+ mySelection = Sel;
+ myOkEdge = false ;
+
+ /* manages local context selection */
+ myIC = ic ;
+
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ myLocalContextId = myIC->OpenLocalContext();
+ myGeomGUI->SetDisplayedObjectList();
+ /* sub shapes selection */
+ myLocalContextMode = TopAbs_VERTEX ;
+ myIC->ActivateStandardMode(myLocalContextMode) ;
+ myUseLocalContext = true ;
+ } else {
+ myUseLocalContext = false ;
+ }
+
+
+ myPoint.SetCoord( 0.0, 0.0, 0.0 ) ;
+ TopoDS_Shape S;
+
+ if( myGeomGUI->GetTopoFromSelection(mySelection, S) ) {
+
+ /* Filter a possibly previous selection and try to put it into coordinates */
+ if( myGeomGUI->VertexToPoint( S, myPoint) )
+ displayPoint = false ;
+ else
+ displayPoint = true ;
+ }
+ else {
+ displayPoint = true ;
+ }
+
+ mySimulationTopoDs.Nullify() ;
+ PointIntoCoordinates(myPoint, displayPoint) ;
+
+ /* 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( SelectButton_Edge, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( GroupConstructors, SIGNAL(clicked(int) ), this, SLOT( ConstructorsClicked(int) ) ) ;
+
+ connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
+ connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
+ connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
+
+ connect( SpinBox_Parameter, SIGNAL ( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ) ;
+ connect( LineEdit_Edge, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ),this, SLOT( DeactivateActiveDialog() ) ) ;
+ connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
+ // connect( mySelection, SIGNAL ( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ) ; done in constructor clicked !
+
+ /* 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 this Dialog */
+}
+
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::ValueChangedInSpinBox( double newValue )
+{
+ GeometryGUI_SpinBox* send = (GeometryGUI_SpinBox*)sender() ;
+ double vx, vy, vz ;
+ if( send == SpinBox_X ) {
+ vx = newValue ;
+ vy = SpinBox_Y->GetValue() ;
+ vz = SpinBox_Z->GetValue() ;
+ } else if ( send == SpinBox_Y ) {
+ vx = SpinBox_X->GetValue() ;
+ vy = newValue ;
+ vz = SpinBox_Z->GetValue() ;
+ } else if (send == SpinBox_Z ) {
+ vx = SpinBox_X->GetValue() ;
+ vy = SpinBox_Y->GetValue() ;
+ vz = newValue ;
+ } else if (send == SpinBox_Parameter ) {
+ myParameter = newValue ;
+ } else
+ return ;
+
+
+ switch (myConstructorId) {
+ case 0: // default constructor
+ {
+ myPoint.SetCoord(vx, vy, vz) ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape() ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ break ;
+ }
+ case 1:
+ {
+ this->SelectionIntoArgument() ;
+ break ;
+ }
+ }
+
+ return ;
+}
+
+
+
+//=======================================================================
+// funcion : PointIntoCoordinates()
+// purpose : Sets user point coordinates into this dialog Spin boxes
+// : and displays it or not according to 'bool displayPoint'
+//=======================================================================
+void GeometryGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint)
+{
+ switch (myConstructorId) {
+ case 0 : {
+ SpinBox_X->SetValue( P.X() ) ;
+ SpinBox_Y->SetValue( P.Y() ) ;
+ SpinBox_Z->SetValue( P.Z() ) ;
+ this->myPoint.SetCoord( P.X(), P.Y(), P.Z() ) ;
+ if( displayPoint ) {
+ mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape() ;
+ myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ // TODO
+ break ;
+ }
+ }
+
+ return ;
+}
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_PointDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+ myConstructorId = constructorId ;
+ switch (constructorId)
+ {
+ case 0:
+ {
+ if ( myUseLocalContext == false && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ myLocalContextId = myIC->OpenLocalContext();
+ myGeomGUI->SetDisplayedObjectList();
+ /* sub shapes selection */
+ myLocalContextMode = TopAbs_VERTEX ;
+ myIC->ActivateStandardMode(myLocalContextMode) ;
+ myUseLocalContext = true ;
+ }
+ mySelection->ClearFilters() ;
+ GroupCoordinates->show();
+ GroupWithEdge->hide() ;
+ /* Display point simulation */
+ PointIntoCoordinates( this->myPoint, true ) ;
+ disconnect( mySelection, 0, this, 0 );
+ break;
+ }
+ case 1:
+ {
+ if ( myUseLocalContext == true && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ myIC->CloseLocalContext(myLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+ LineEdit_Edge->setText("") ;
+ mySelection->AddFilter( myEdgeFilter );
+ GroupCoordinates->hide();
+ GroupWithEdge->show() ;
+ myOkEdge = false ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEdit_Edge ) {
+ /* User name of object input management */
+ /* If successfull the selection is changed and signal emitted... */
+ /* so SelectionIntoArgument() is automatically called. */
+ const QString objectUserName = send->text() ;
+ QWidget* thisWidget = (QWidget*)this ;
+ if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
+ LineEdit_Edge->setText( objectUserName ) ;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=======================================================================
+// function : ClickOnApply()
+// purpose :
+//=======================================================================
+void GeometryGUI_PointDlg::ClickOnApply()
+{
+
+ myGeomGUI->EraseSimulationShape() ;
+
+ /* Close local context */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ myIC->CloseLocalContext(myLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+
+ switch (myConstructorId) {
+
+ case 0 :
+ {
+ /* Recup args and call method */
+ double x = SpinBox_X->GetValue() ;
+ double y = SpinBox_Y->GetValue() ;
+ double z = SpinBox_Z->GetValue() ;
+
+ myGeomGUI->MakePointAndDisplay(x,y,z) ; /* WARNING : no display if a local context is opened */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ /* no display if a local context is opened */
+ myLocalContextId = myIC->OpenLocalContext();
+ myGeomGUI->SetDisplayedObjectList();
+ /* sub shapes selection */
+ myLocalContextMode = TopAbs_VERTEX ;
+ myIC->ActivateStandardMode(myLocalContextMode);
+ myUseLocalContext = true ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ if( myOkEdge == true ) {
+ /* this constructor method has no idl interface : we use same than constructor 0 */
+ myGeomGUI->MakePointAndDisplay( myPoint.X(), myPoint.Y(), myPoint.Z() ) ;
+ }
+ break ;
+ }
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed (for constructors not using local context)
+//=================================================================================
+void GeometryGUI_PointDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ LineEdit_Edge->setText("") ;
+ QString aString = "" ; /* future name of selection */
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ this->myOkEdge = false ;
+ return ;
+ }
+
+ // nbSel == 1
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ switch (myConstructorId)
+ {
+ case 0:
+ break ;
+ case 1:
+ {
+ LineEdit_Edge->setText(aString) ;
+ if( S.ShapeType() == TopAbs_EDGE ) {
+ if( CalculateVertexOnCurve( TopoDS::Edge(S), myParameter, mySimulationTopoDs) ) {
+ if ( myGeomGUI->VertexToPoint( mySimulationTopoDs, myPoint ) ) {
+ this->myOkEdge = true ;
+ myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
+ }
+ }
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: // default constructor
+ break;
+ case 1:
+ {
+ if(send == SelectButton_Edge) {
+ LineEdit_Edge->setFocus() ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=======================================================================
+// function : UseLocalContext()
+// purpose : Return true when this method has opened a local context
+// : Used from GeometryGUI
+//=======================================================================
+bool GeometryGUI_PointDlg::UseLocalContext()
+{
+ return this->myUseLocalContext ;
+}
+
+
+//=======================================================================
+// function : closeEvent()
+// purpose :
+//=======================================================================
+void GeometryGUI_PointDlg::closeEvent(QCloseEvent* e)
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=======================================================================
+// function : ClickOnCancel()
+// purpose :
+//=======================================================================
+void GeometryGUI_PointDlg::ClickOnCancel()
+{
+ if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ myIC = v3d->getAISContext();
+ if ( myIC->HasOpenedContext() ) {
+ myIC->CloseLocalContext(myLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+ }
+ mySelection->ClearFilters() ;
+ myGeomGUI->SetActiveDialogBox(0) ;
+ myGeomGUI->EraseSimulationShape() ;
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose : to reactivate this dialog box when mouse enter onto the window
+//=================================================================================
+void GeometryGUI_PointDlg::enterEvent( QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose : public slot to deactivate if active
+//=================================================================================
+void GeometryGUI_PointDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+
+ mySelection->ClearFilters() ;
+ GroupConstructors->setEnabled(false) ;
+ GroupCoordinates->setEnabled(false) ;
+ GroupWithEdge->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ myGeomGUI->EraseSimulationShape() ;
+ myGeomGUI->ResetState() ;
+ myGeomGUI->SetActiveDialogBox(0) ;
+ if ( myConstructorId == 0 && myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ myIC->CloseLocalContext(myLocalContextId) ;
+ myUseLocalContext = false ;
+ }
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PointDlg::ActivateThisDialog( )
+{
+
+ if ( !GroupConstructors->isEnabled() ) { /* if not active */
+
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupCoordinates->setEnabled(true) ;
+ GroupWithEdge->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+
+ myGeomGUI->SetState(POINT_METHOD) ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ if ( myConstructorId == 0 ) {
+
+ mySelection->ClearFilters() ;
+ if( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ myIC = v3d->getAISContext();
+ myLocalContextId = myIC->OpenLocalContext();
+ myGeomGUI->SetDisplayedObjectList();
+ /* sub shapes selection */
+ myLocalContextMode = TopAbs_VERTEX ;
+ myIC->ActivateStandardMode(myLocalContextMode);
+ myUseLocalContext = true ;
+ }
+ }
+
+ if ( myConstructorId == 1 )
+ mySelection->AddFilter( myEdgeFilter );
+
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : CalculateVertexOnCurve()
+// purpose : Calculate a Vertex on the curve given by 'anEdge'.
+// : The position of resultVertex is given by aParameter.
+// : For a linear edge, aParameter=0.0 gives the first vertex of edge
+// : aParameter=1.0 gives the last vertex of edge
+// : aParameter=0.5 gives the vertex on the middle of edge
+// : It is possible to get vertices out of edge using values > 1.0 or < 0.0
+//=================================================================================
+bool GeometryGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex)
+{
+ if( anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge) )
+ return false ;
+
+ Standard_Real first, last ;
+ Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last);
+ if( !curv->IsCN(0) )
+ return false ;
+
+ Standard_Real param;
+ if( anEdge.Orientation() == TopAbs_FORWARD ) {
+ param = first + (last-first) * aParameter ;
+ }
+ else {
+ param = last + (first-last) * aParameter ;
+ }
+ gp_Pnt paramPoint ;
+ curv->D0( param, paramPoint ) ;
+ resultVertex = BRepBuilderAPI_MakeVertex(paramPoint);
+ return true ;
+}
+
--- /dev/null
+// 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_PointDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_POINT_H
+#define DIALOGBOX_POINT_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <gp_Pnt.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QFrame;
+class QGroupBox;
+class QLabel;
+class QSpinBox;
+class QPushButton;
+class QRadioButton;
+class GeometryGUI;
+
+#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Drawer.hxx>
+
+
+//=================================================================================
+// class : GeometryGUI_PointDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PointDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PointDlg( QWidget* parent = 0, const char* name = 0,
+ SALOME_Selection* Sel = 0,
+ const Handle(AIS_InteractiveContext)& ic = 0,
+ bool modal = FALSE,
+ WFlags fl = 0 );
+
+ ~GeometryGUI_PointDlg();
+
+private :
+
+ SALOME_Selection* mySelection ; /* Current selection */
+ TopoDS_Shape mySimulationTopoDs; /* Shape used to display a simulation */
+ gp_Pnt myPoint ; /* Is 'mySimulationTopoDs' */
+ GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
+ GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
+
+ /* Interactive and local context management see also : bool UseLocalContext() */
+ Handle (AIS_InteractiveContext) myIC ; /* Interactive context from IAPP */
+ Standard_Integer myLocalContextId ; /* identify a local context for this method */
+ TopAbs_ShapeEnum myLocalContextMode ; /* identify a selection mode into local context */
+ bool myUseLocalContext ; /* true when method as opened a local context */
+
+ int myConstructorId ; /* Current constructor id = radio button id */
+ double myParameter ; /* Parameter used to create a vertex on edge (point on curve) */
+ bool myOkEdge ; /* true when an edge is selected by user */
+
+ Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* filter for selection */
+
+ void Init(SALOME_Selection* Sel, const Handle(AIS_InteractiveContext)& ic) ; /* Initialize dialog */
+ void enterEvent(QEvent* e);
+ void closeEvent(QCloseEvent* e) ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QRadioButton* Constructor2;
+
+ QGroupBox* GroupCoordinates;
+ QLabel* TextLabel_X;
+ QLabel* TextLabel_Y;
+ QLabel* TextLabel_Z;
+
+ GeometryGUI_SpinBox* SpinBox_X ;
+ GeometryGUI_SpinBox* SpinBox_Y ;
+ GeometryGUI_SpinBox* SpinBox_Z ;
+
+ QGroupBox* GroupWithEdge;
+ QLabel* TextLabel_Edge;
+ QPushButton* SelectButton_Edge;
+ QLineEdit* LineEdit_Edge;
+ QLabel* TextLabel_Parameter;
+ GeometryGUI_SpinBox* SpinBox_Parameter;
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void LineEditReturnPressed() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ValueChangedInSpinBox( double newValue ) ;
+ bool CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex) ;
+
+public:
+ void PointIntoCoordinates(gp_Pnt P, bool displayPoint) ;
+ bool UseLocalContext() ; /* return true if method has opened a local context */
+
+protected:
+ QGridLayout* GeometryGUI_PointDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupCoordinatesLayout;
+ QGridLayout* GroupWithEdgeLayout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_POINT_H
--- /dev/null
+// 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_PrismDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PrismDlg.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 <qvalidator.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qlineedit.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qevent.h>
+#include <qlabel.h>
+
+
+
+//=================================================================================
+// class : GeometryGUI_PrismDlg()
+// purpose : Constructs a GeometryGUI_PrismDlg 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_PrismDlg::GeometryGUI_PrismDlg( 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_PRISM")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_PrismDlg" );
+ resize( 303, 225 );
+ setCaption( tr( "GEOM_PRISM_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_PrismDlgLayout = new QGridLayout( this );
+ GeometryGUI_PrismDlgLayout->setSpacing( 6 );
+ GeometryGUI_PrismDlgLayout->setMargin( 11 );
+
+ /**************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_PRISM" ) );
+ 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() ) );
+ GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupConstructorsLayout->addItem( spacer, 0, 2 );
+ GeometryGUI_PrismDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /**************************************************************/
+ GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
+ GroupConstructor1->setTitle( tr( "GEOM_PRISM_BSV" ) );
+ 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 );
+ LineEditC1A2Line = new QLineEdit( GroupConstructor1, "LineEditC1A2Line" );
+ LineEditC1A2Line->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Line->sizePolicy().hasHeightForWidth() ) );
+ GroupConstructor1Layout->addMultiCellWidget( LineEditC1A2Line, 1, 1, 2, 3 );
+ LineEditC1A1Base = new QLineEdit( GroupConstructor1, "LineEditC1A1Base" );
+ LineEditC1A1Base->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Base->sizePolicy().hasHeightForWidth() ) );
+ GroupConstructor1Layout->addMultiCellWidget( LineEditC1A1Base, 0, 0, 2, 3 );
+ SelectButtonC1A1Base = new QPushButton( GroupConstructor1, "SelectButtonC1A1Base" );
+ SelectButtonC1A1Base->setText( tr( "" ) );
+ SelectButtonC1A1Base->setPixmap( image1 );
+ GroupConstructor1Layout->addWidget( SelectButtonC1A1Base, 0, 1 );
+ SelectButtonC1A2Line = new QPushButton( GroupConstructor1, "SelectButtonC1A2Line" );
+ SelectButtonC1A2Line->setText( tr( "" ) );
+ SelectButtonC1A2Line->setPixmap( image1 );
+ GroupConstructor1Layout->addWidget( SelectButtonC1A2Line, 1, 1 );
+ TextLabelBase = new QLabel( GroupConstructor1, "TextLabelBase" );
+ TextLabelBase->setText( tr( "GEOM_BASE" ) );
+ TextLabelBase->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelBase->setFrameShape( QLabel::NoFrame );
+ TextLabelBase->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabelBase, 0, 0 );
+ TextLabelVector = new QLabel( GroupConstructor1, "TextLabelVector" );
+ TextLabelVector->setText( tr( "GEOM_VECTOR" ) );
+ TextLabelVector->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelVector->setFrameShape( QLabel::NoFrame );
+ TextLabelVector->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabelVector, 1, 0 );
+
+ SpinBox_C1A3Height = new GeometryGUI_SpinBox( GroupConstructor1, "GeomSpinBox_C1A3Height" ) ;
+ SpinBox_C1A3Height->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_C1A3Height->sizePolicy().hasHeightForWidth() ) );
+ GroupConstructor1Layout->addWidget( SpinBox_C1A3Height, 2, 3 );
+
+ CheckBoxC3A1Reverse = new QCheckBox( GroupConstructor1, "CheckBoxC3A1Reverse" );
+ CheckBoxC3A1Reverse->setText( tr( "GEOM_REVERSE" ) );
+ GroupConstructor1Layout->addMultiCellWidget( CheckBoxC3A1Reverse, 2, 2, 0, 1 );
+ TextLabelHeight = new QLabel( GroupConstructor1, "TextLabelHeight" );
+ TextLabelHeight->setText( tr( "GEOM_HEIGHT" ) );
+ TextLabelHeight->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelHeight->setFrameShape( QLabel::NoFrame );
+ TextLabelHeight->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabelHeight, 2, 2 );
+ GeometryGUI_PrismDlgLayout->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_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_PrismDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_PrismDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_PrismDlg::~GeometryGUI_PrismDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::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_C1A3Height->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_C1A3Height->SetValue( 100.0 ) ; /* = myHeight */
+
+ myHeight = 100.000 ;
+ mySelection = Sel ;
+ mySimulationTopoDs.Nullify() ;
+ myBaseTopo.Nullify() ;
+ myConstructorId = 0 ;
+ myDx = myDy = myDz = 0.0 ;
+
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ GroupConstructor1->show();
+ myConstructorId = 0 ;
+ myEditCurrentArgument = LineEditC1A1Base ;
+ Constructor1->setChecked( TRUE );
+ myOkBase = myOkLine = false ;
+
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ /* Retrieves geom component */
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ myGeom = GEOM::GEOM_Gen::_narrow(comp);
+ /* Filters definition */
+ myEdgeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myGeom );
+
+
+ // TODO first selection into 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( SelectButtonC1A1Base, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( SelectButtonC1A2Line, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+
+ connect( LineEditC1A1Base, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC1A2Line, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( CheckBoxC3A1Reverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseVector(int) ) ) ;
+
+ connect( SpinBox_C1A3Height, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+
+ 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_PrismDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+
+ switch (constructorId)
+ {
+ case 0: /* base shape + an edge used as a vector */
+ {
+ GroupConstructor1->show();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditC1A1Base ;
+ LineEditC1A2Line->setText(tr("")) ;
+
+ SpinBox_C1A3Height->SetValue(100) ;
+ myHeight = 100.0 ;
+
+ Constructor1->setChecked( TRUE );
+ myOkBase = myOkLine = false ;
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::ClickOnApply()
+{
+ gp_Pnt P1, P2 ;
+
+ if( !myOkBase || !myOkLine )
+ return ;
+
+ try {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ gp_Vec Vec(myDx, myDy, myDz );
+ Vec.Normalize() ;
+ Vec *= myHeight ;
+ P1.SetCoord( 0.0, 0.0, 0.0 ) ;
+ P2.SetCoord( Vec.X(), Vec.Y(), Vec.Z() ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if( myOkBase && myOkLine ) {
+ myGeomGUI->MakePrismAndDisplay( myGeomShape, P1, P2 ) ;
+ }
+ break ;
+ }
+ }
+ }
+ catch(Standard_Failure) {
+ MESSAGE("Exception intercepted in GeometryGUI_PrismDlg" << endl ) ;
+ return ;
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection has changed
+//=================================================================================
+void GeometryGUI_PrismDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Future the name of selection */
+ QString aString = "";
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if ( myEditCurrentArgument == LineEditC1A1Base ) {
+ LineEditC1A1Base->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2Line ) {
+ LineEditC1A2Line->setText("") ;
+ myOkLine = false ;
+ }
+ break ;
+ }
+ }
+ return ;
+ }
+
+ /* nbSel == 1 */
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ gp_Pnt aPoint1, aPoint2 ;
+
+ if ( myEditCurrentArgument == LineEditC1A1Base ) {
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ Standard_Boolean testResult ;
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult)
+ return ;
+ if ( S.ShapeType() <= 2 )
+ return;
+
+ LineEditC1A1Base->setText(aString) ;
+ myBaseTopo = S ;
+ myOkBase = true ;
+ }
+
+ else if ( myEditCurrentArgument == LineEditC1A2Line && myGeomGUI->LinearEdgeExtremities(S, aPoint1, aPoint2) ) {
+ myGeomGUI->GetBipointDxDyDz( aPoint1, aPoint2, myDx, myDy, myDz ) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkLine = true ;
+ }
+
+ if( myOkBase && myOkLine ) {
+ MakePrismSimulationAndDisplay( myBaseTopo ) ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : MakePrismSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::MakePrismSimulationAndDisplay( const TopoDS_Shape& S )
+{
+ try {
+ gp_Vec Vec(myDx, myDy, myDz );
+ Vec.Normalize() ;
+ Vec *= myHeight ;
+ mySimulationTopoDs = BRepPrimAPI_MakePrism(S, Vec, Standard_False).Shape() ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakePrismSimulationAndDisplay" << endl ) ;
+ return ;
+ }
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
+
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ mySelection->ClearFilters() ;
+
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if( send == SelectButtonC1A1Base ) {
+ LineEditC1A1Base->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1Base ;
+ }
+ else if(send == SelectButtonC1A2Line) {
+ LineEditC1A2Line->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2Line;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::ValueChangedInSpinBox( double newValue )
+{
+ QObject* send = (QObject*)sender();
+
+ if( send == SpinBox_C1A3Height ) {
+ myHeight = newValue ;
+ if( myOkBase && myOkLine ) {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ MakePrismSimulationAndDisplay( myBaseTopo ) ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEditC1A1Base )
+ myEditCurrentArgument = LineEditC1A1Base ;
+ else if ( send == LineEditC1A2Line )
+ myEditCurrentArgument = LineEditC1A2Line ;
+ 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_PrismDlg::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_PrismDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void GeometryGUI_PrismDlg::enterEvent( QEvent * )
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PrismDlg::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 : ReverseVector()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_PrismDlg::ReverseVector(int state)
+{
+ myDx = -myDx ;
+ myDy = -myDy ;
+ myDz = -myDz ;
+ if(myOkBase && myOkLine) {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ MakePrismSimulationAndDisplay( myBaseTopo ) ;
+ }
+ return ;
+}
--- /dev/null
+// 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_PrismDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_PRISM_H
+#define DIALOGBOX_PRISM_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <BRepPrimAPI_MakePrism.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_PrismDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PrismDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PrismDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_PrismDlg();
+
+private :
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void MakePrismSimulationAndDisplay( const TopoDS_Shape& S) ;
+
+ 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 */
+ Standard_Real myDx ;
+ Standard_Real myDy ;
+ Standard_Real myDz ;
+ Standard_Real myHeight ; /* Height used for prism (extrusion) */
+ TopoDS_Shape myBaseTopo ; /* topology used as base of prism */
+ GEOM::GEOM_Shape_var myGeomShape ; /* that is myBaseTopo */
+ bool myOkBase ;
+ bool myOkLine ; /* to check when arguments myDx, myDy, myDz are defined */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filters selection */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupConstructor1;
+
+ QLineEdit* LineEditC1A1Base;
+ QLineEdit* LineEditC1A2Line;
+ QPushButton* SelectButtonC1A1Base;
+ QPushButton* SelectButtonC1A2Line;
+ QLabel* TextLabelBase;
+ QLabel* TextLabelVector;
+ GeometryGUI_SpinBox* SpinBox_C1A3Height;
+ QCheckBox* CheckBoxC3A1Reverse;
+ QLabel* TextLabelHeight;
+
+ 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() ;
+ void ReverseVector(int state) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_PrismDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_PRISM_H
--- /dev/null
+// 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_PropertiesDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_PropertiesDlg.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>
+
+#include <TopExp_Explorer.hxx>
+
+
+//=================================================================================
+// class : GeometryGUI_PropertiesDlg()
+// purpose : Constructs a GeometryGUI_PropertiesDlg 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_PropertiesDlg::GeometryGUI_PropertiesDlg( 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_BASICPROPERTIES")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_PropertiesDlg" );
+ resize( 303, 275 );
+ setCaption( tr( "GEOM_PROPERTIES_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_PropertiesDlgLayout = new QGridLayout( this );
+ GeometryGUI_PropertiesDlgLayout->setSpacing( 6 );
+ GeometryGUI_PropertiesDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_PROPERTIES" ) );
+ 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_PropertiesDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
+ GroupConstructor1->setTitle( tr( "GEOM_PROPERTIES_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 );
+ 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, 1, 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, 1, 2 );
+ LineEdit_Surface = new QLineEdit( GroupConstructor1, "LineEdit_Surface" );
+ LineEdit_Surface->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Surface->sizePolicy().hasHeightForWidth() ) );
+ //LineEdit_Surface->setEnabled( FALSE );
+ LineEdit_Surface->setReadOnly( TRUE );
+ GroupConstructor1Layout->addWidget( LineEdit_Surface, 2, 2 );
+ TextLabel_Surface = new QLabel( GroupConstructor1, "TextLabel_Surface" );
+ TextLabel_Surface->setText( tr( "GEOM_PROPERTIES_SURFACE" ) );
+ TextLabel_Surface->setMinimumSize( QSize( 50, 0 ) );
+ TextLabel_Surface->setFrameShape( QLabel::NoFrame );
+ TextLabel_Surface->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabel_Surface, 2, 0 );
+ TextLabel_Volume = new QLabel( GroupConstructor1, "TextLabel_Volume" );
+ TextLabel_Volume->setText( tr( "GEOM_PROPERTIES_VOLUME" ) );
+ TextLabel_Volume->setMinimumSize( QSize( 50, 0 ) );
+ TextLabel_Volume->setFrameShape( QLabel::NoFrame );
+ TextLabel_Volume->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabel_Volume, 3, 0 );
+ LineEdit_Volume = new QLineEdit( GroupConstructor1, "LineEdit_Volume" );
+ LineEdit_Volume->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEdit_Volume->sizePolicy().hasHeightForWidth() ) );
+ //LineEdit_Volume->setEnabled( FALSE );
+ LineEdit_Volume->setReadOnly( TRUE );
+ GroupConstructor1Layout->addWidget( LineEdit_Volume, 3, 2 );
+ GeometryGUI_PropertiesDlgLayout->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_PropertiesDlgLayout->addWidget( GroupButtons, 2, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_PropertiesDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_PropertiesDlg::~GeometryGUI_PropertiesDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::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_PropertiesDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::ClickOnCancel()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_PropertiesDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ LineEdit_Length->setText("") ;
+ LineEdit_Surface->setText("") ;
+ LineEdit_Volume->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() || S.ShapeType() == TopAbs_VERTEX ) {
+ myEditCurrentArgument->setText( "" );
+ return ;
+ }
+
+ LineEditC1A1->setText(aString) ;
+
+ /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */
+ if( myGeomGUI->CreateArrowForLinearEdge( S, mySimulationTopoDs ) ) {
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ this->CalculateAndDisplayProperties(S) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::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_PropertiesDlg::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_PropertiesDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ disconnect( mySelection, 0, this, 0 );
+ GroupConstructors->setEnabled(false) ;
+ GroupConstructor1->setEnabled(false) ;
+ myGeomGUI->EraseSimulationShape() ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::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() ) );
+
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : CalculateAndDisplayProperties()
+// purpose :
+//=================================================================================
+void GeometryGUI_PropertiesDlg::CalculateAndDisplayProperties(const TopoDS_Shape& S)
+{
+ LineEdit_Length->setText("") ;
+ LineEdit_Surface->setText("") ;
+ LineEdit_Volume->setText("") ;
+ if( S.IsNull() )
+ return ;
+
+ Standard_Real result;
+ GProp_GProps LProps;
+ GProp_GProps SProps;
+ QString resString;
+
+ try
+ {
+ BRepGProp::LinearProperties(S,LProps);
+ result = LProps.Mass();
+ if (!IsEqual( result, 0.0))
+ {
+ resString = tr("%1").arg( result, 12, 'f', 6 ) ;
+ LineEdit_Length->setText(resString) ;
+ }
+
+ BRepGProp::SurfaceProperties(S, SProps);
+ result = SProps.Mass();
+ if (!IsEqual( result, 0.0))
+ {
+ resString = tr("%1").arg( result, 12, 'f', 6 ) ;
+ LineEdit_Surface->setText(resString) ;
+ }
+
+ result = 0.0;
+ if (S.ShapeType() < TopAbs_SHELL)
+ {
+ for( TopExp_Explorer Exp(S,TopAbs_SOLID); Exp.More(); Exp.Next() )
+ {
+ GProp_GProps VProps;
+ BRepGProp::VolumeProperties(Exp.Current(), VProps);
+ result += VProps.Mass();
+ }
+ }
+ if (!IsEqual( result, 0.0 ))
+ {
+ resString = tr("%1").arg( result, 12, 'f', 6 ) ;
+ LineEdit_Volume->setText(resString) ;
+ }
+ }
+ catch(Standard_Failure)
+ {
+ MESSAGE("Catch intercepted in CalculateAndDisplayProperties()" << endl ) ;
+ }
+ return ;
+}
--- /dev/null
+// 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_PropertiesDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+
+#ifndef DIALOGBOX_PROPERTIES_H
+#define DIALOGBOX_PROPERTIES_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_PropertiesDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_PropertiesDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_PropertiesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_PropertiesDlg();
+
+private:
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ void CalculateAndDisplayProperties(const TopoDS_Shape& S) ;
+
+ 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 */
+
+ int myConstructorId ; /* Current constructor id = radio button id */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupConstructor1;
+ QLineEdit* LineEditC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+
+ QLabel* TextLabel_Length;
+ QLabel* TextLabel_Surface;
+ QLabel* TextLabel_Volume;
+
+ QLineEdit* LineEdit_Length;
+ QLineEdit* LineEdit_Surface;
+ QLineEdit* LineEdit_Volume;
+
+ 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_PropertiesDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_PROPERTIES_H
--- /dev/null
+// 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_RevolDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_RevolDlg.h"
+
+#include <BRepAdaptor_Curve.hxx>
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Config.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 <qvalidator.h>
+#include <qpixmap.h>
+
+//=================================================================================
+// class : GeometryGUI_RevolDlg()
+// purpose : Constructs a GeometryGUI_RevolDlg 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_RevolDlg::GeometryGUI_RevolDlg( 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_REVOL")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_RevolDlg" );
+ resize( 303, 251 );
+ setCaption( tr( "GEOM_REVOLUTION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_RevolDlgLayout = new QGridLayout( this );
+ GeometryGUI_RevolDlgLayout->setSpacing( 6 );
+ GeometryGUI_RevolDlgLayout->setMargin( 11 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_REVOLUTION" ) );
+ 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_RevolDlgLayout->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_RevolDlgLayout->addWidget( GroupButtons, 2, 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_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 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
+ SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 );
+
+ TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_AXIS" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ SelectButtonC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
+ SelectButtonC1A2->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 2, 3 );
+
+ CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" );
+ CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) );
+ GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 1 );
+ TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
+ TextLabelC1A3->setText( tr( "GEOM_ANGLE" ) );
+ TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A3, 2, 2 );
+ SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
+ GroupC1Layout->addWidget( SpinBox_C1A3, 2, 3 );
+
+ GeometryGUI_RevolDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_RevolDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_RevolDlg::~GeometryGUI_RevolDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::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( -999.999, 999.999, step, 3 ) ;
+ SpinBox_C1A3->SetValue( 45.0 ) ; /* = myAngle */
+ myAngle = 45.0 ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ myOkBase = false ;
+ myOkAxis = false ;
+
+ mySimulationTopoDs.Nullify() ;
+ myBase.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 );
+
+ /* 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( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
+
+ 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 : ReverseAngle()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_RevolDlg::ReverseAngle(int state)
+{
+ myAngle = -myAngle ;
+ SpinBox_C1A3->SetValue( myAngle ) ;
+
+ if(myOkBase && myOkAxis) {
+ MakeRevolutionSimulationAndDisplay(myBase) ;
+ } else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_RevolDlg::ConstructorsClicked(int constructorId)
+{
+ /* only a constructor now */
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkBase && myOkAxis) {
+ myGeomGUI->MakeRevolutionAndDisplay( myGeomShape, myLoc, myDir, myAngle*PI180 ) ;
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::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_RevolDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ QString aString = ""; /* name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ LineEditC1A1->setText("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ LineEditC1A2->setText("") ;
+ myOkAxis = 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 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+
+ /* test if appropriate shape for revol */
+ TopAbs_ShapeEnum aType = S.ShapeType() ;
+ if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType != TopAbs_COMPOUND )
+ return ;
+
+ LineEditC1A1->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, myLoc, myDir) */) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir = curv.Line().Direction();
+ myLoc = curv.Line().Location();
+ LineEditC1A2->setText(aString) ;
+ myOkAxis = true ;
+ }
+
+ if( myOkBase && myOkAxis ) {
+ MakeRevolutionSimulationAndDisplay( myBase) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::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_RevolDlg::ValueChangedInSpinBox( double newValue )
+{
+ myAngle = newValue ;
+ if ( myOkBase && myOkAxis ) {
+ MakeRevolutionSimulationAndDisplay(myBase) ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::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_RevolDlg::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_RevolDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : MakeRevolutionSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_RevolDlg::MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S)
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ if( S.IsNull() )
+ return ;
+
+ TopAbs_ShapeEnum aType = S.ShapeType() ;
+ if(aType != TopAbs_VERTEX && aType != TopAbs_EDGE && aType != TopAbs_WIRE && aType != TopAbs_FACE && aType != TopAbs_SHELL && aType !=TopAbs_COMPOUND )
+ return ;
+
+ try {
+ gp_Ax1 AX( this->myLoc, this->myDir);
+ mySimulationTopoDs = BRepPrimAPI_MakeRevol(S, AX, this->myAngle*PI180 );
+ myGeomGUI->DisplaySimulationShape(mySimulationTopoDs) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeRevolutionSimulationAndDisplay" ) ;
+ }
+ return ;
+}
--- /dev/null
+// 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_RevolDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_REVOLUTION_H
+#define DIALOGBOX_REVOLUTION_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 <BRepPrimAPI_MakeRevol.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+#include <qvalidator.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_RevolDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_RevolDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_RevolDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_RevolDlg();
+
+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 */
+ TopoDS_Shape myBase ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
+
+ gp_Pnt myLoc ;
+ gp_Dir myDir ;
+
+ Standard_Real myAngle ;
+
+ bool myOkBase ;
+ bool myOkAxis ;
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeRevolutionSimulationAndDisplay( const TopoDS_Shape& S) ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+ QGroupBox* GroupC1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ GeometryGUI_SpinBox* SpinBox_C1A3 ; /* for angle */
+ QLabel* TextLabelC1A3;
+ QCheckBox* CheckBoxReverse;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void LineEditReturnPressed() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ReverseAngle(int state) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_RevolDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_REVOLUTION_H
--- /dev/null
+// 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_RotationDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_RotationDlg.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 <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 <qvalidator.h>
+#include <qpixmap.h>
+
+
+//=================================================================================
+// class : GeometryGUI_RotationDlg()
+// purpose : Constructs a GeometryGUI_RotationDlg 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_RotationDlg::GeometryGUI_RotationDlg( 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_ROTATION")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_RotationDlg" );
+ resize( 303, 251 );
+ setCaption( tr( "GEOM_ROTATION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_RotationDlgLayout = new QGridLayout( this );
+ GeometryGUI_RotationDlgLayout->setSpacing( 6 );
+ GeometryGUI_RotationDlgLayout->setMargin( 11 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_ROTATION" ) );
+ 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_RotationDlgLayout->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_RotationDlgLayout->addWidget( GroupButtons, 2, 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 );
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ SelectButtonC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
+ SelectButtonC1A2->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 );
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 2, 3 );
+ SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
+ SelectButtonC1A1->setText( tr( "" ) );
+ SelectButtonC1A1->setPixmap( image1 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
+ SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+
+ 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 );
+ TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_AXIS" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+
+ SpinBox_C1A3 = new GeometryGUI_SpinBox( GroupC1, "GeomSpinBox_C1A3" ) ;
+ GroupC1Layout->addWidget( SpinBox_C1A3, 2, 3 );
+
+ TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
+ TextLabelC1A3->setText( tr( "GEOM_ANGLE" ) );
+ TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A3, 2, 2 );
+ CheckBoxReverse = new QCheckBox( GroupC1, "CheckBoxReverse" );
+ CheckBoxReverse->setText( tr( "GEOM_REVERSE" ) );
+ GroupC1Layout->addMultiCellWidget( CheckBoxReverse, 2, 2, 0, 1 );
+ GeometryGUI_RotationDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ Init(Sel) ; /* Initialisations */
+}
+
+//=================================================================================
+// function : ~GeometryGUI_RotationDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_RotationDlg::~GeometryGUI_RotationDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::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( -999.999, 999.999, step, 3 ) ;
+ SpinBox_C1A3->SetValue( 45.0 ) ; /* = myAngle */
+ myAngle = 45.0 ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myOkBase = myOkAxis = false ;
+ mySimulationTopoDs.Nullify() ;
+ myBase.Nullify() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ // TODO : set 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 );
+
+ /* 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( CheckBoxReverse, SIGNAL (stateChanged(int) ), this, SLOT( ReverseAngle(int) ) ) ;
+
+ 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 : ReverseAngle()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_RotationDlg::ReverseAngle(int state)
+{
+ myAngle = -myAngle ;
+ SpinBox_C1A3->SetValue( myAngle ) ;
+ if( myOkBase && myOkAxis ) {
+ MakeRotationSimulationAndDisplay( myBase ) ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_RotationDlg::ConstructorsClicked(int constructorId)
+{
+ /* only a constructor now */
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkBase && myOkAxis) {
+ myGeomGUI->MakeRotationAndDisplay( myGeomShape, myLoc, myDir, myAngle*PI180) ;
+ }
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::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_RotationDlg::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("") ;
+ myOkBase = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ LineEditC1A2->setText("") ;
+ myOkAxis = 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 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ LineEditC1A1->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 /*&& myGeomGUI->LinearLocationAndDirection(S, myLoc, myDir) */) {
+ BRepAdaptor_Curve curv(TopoDS::Edge(S));
+ myDir = curv.Line().Direction();
+ myLoc = curv.Line().Location();
+ LineEditC1A2->setText(aString) ;
+ myOkAxis = true ;
+ }
+
+ if( myOkBase && myOkAxis ) {
+ MakeRotationSimulationAndDisplay( myBase) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->ClearFilters() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myEdgeFilter) ;
+ }
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::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_RotationDlg::ValueChangedInSpinBox( double newValue )
+{
+ myAngle = newValue ;
+ if (myOkBase && myOkAxis) {
+ MakeRotationSimulationAndDisplay(myBase) ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::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_RotationDlg::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_RotationDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : MakeRotationSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_RotationDlg::MakeRotationSimulationAndDisplay( const TopoDS_Shape& S)
+{
+ myGeomGUI->EraseSimulationShape() ;
+
+ if( S.IsNull() )
+ return ;
+
+ try {
+ gp_Ax1 AX( this->myLoc, this->myDir ) ;
+ gp_Trsf theTransformation ;
+ theTransformation.SetRotation(AX, this->myAngle*PI180 ) ;
+ BRepBuilderAPI_Transform myBRepTransformation(S, theTransformation, Standard_False) ;
+ this->mySimulationTopoDs = myBRepTransformation.Shape() ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeRotationSimulationAndDisplay" ) ;
+ return ;
+ }
+ return ;
+}
--- /dev/null
+// 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_RotationDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_ROTATION_H
+#define DIALOGBOX_ROTATION_H
+
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOM_EdgeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <TopLoc_Location.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.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_RotationDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_RotationDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_RotationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_RotationDlg();
+
+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 */
+ TopoDS_Shape myBase ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
+
+ gp_Pnt myLoc ;
+ gp_Dir myDir ;
+ Standard_Real myAngle ;
+
+ bool myOkBase ;
+ bool myOkAxis ;
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_EdgeFilter) myEdgeFilter; /* Filter selection */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeRotationSimulationAndDisplay( const TopoDS_Shape& S) ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+ QGroupBox* GroupC1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ GeometryGUI_SpinBox* SpinBox_C1A3 ; /* for angle */
+ QLabel* TextLabelC1A3;
+ QCheckBox* CheckBoxReverse;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void LineEditReturnPressed() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ReverseAngle(int state) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_RotationDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_ROTATION_H
--- /dev/null
+// 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_ScaleDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_ScaleDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "utilities.h"
+
+#include <BRepBuilderAPI_Transform.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_ScaleDlg()
+// purpose : Constructs a GeometryGUI_ScaleDlg 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_ScaleDlg::GeometryGUI_ScaleDlg( 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_SCALE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_ScaleDlg" );
+ resize( 303, 253 );
+ setCaption( tr( "GEOM_SCALE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_ScaleDlgLayout = new QGridLayout( this );
+ GeometryGUI_ScaleDlgLayout->setSpacing( 6 );
+ GeometryGUI_ScaleDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SCALE" ) );
+ 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 );
+ GeometryGUI_ScaleDlgLayout->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 );
+ 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 );
+ TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_CENTRAL_POINT" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A2->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A2->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
+ SelectButtonC1A1->setText( tr( "" ) );
+ SelectButtonC1A1->setPixmap( image1 );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+ SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
+ SelectButtonC1A2->setText( tr( "" ) );
+ SelectButtonC1A2->setPixmap( image1 );
+ GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+ LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
+ GroupC1Layout->addWidget( LineEditC1A2, 1, 2 );
+ LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
+ GroupC1Layout->addWidget( LineEditC1A3, 2, 2 );
+ TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
+ TextLabelC1A3->setText( tr( "GEOM_SCALE_FACTOR" ) );
+ TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
+ GroupC1Layout->addWidget( TextLabelC1A3, 2, 0 );
+ GeometryGUI_ScaleDlgLayout->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_ScaleDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+//=================================================================================
+// function : ~GeometryGUI_ScaleDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_ScaleDlg::~GeometryGUI_ScaleDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::Init( SALOME_Selection* Sel )
+{
+
+ LineEditC1A3->setMaxLength( 10 );
+ QDoubleValidator *Va = new QDoubleValidator( -999999, +999999, 3, LineEditC1A3 ) ;
+ LineEditC1A3->setValidator( Va ) ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myPoint1.SetCoord( 0.0, 0.0, 0.0 );
+ myOkPoint1 = myOkBaseTopo = false ;
+ myFactor = 2.0 ;
+ LineEditC1A3->setText("2.0") ;
+ mySimulationTopoDs.Nullify() ;
+ myBaseTopo.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( LineEditC1A3, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ;
+ 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_ScaleDlg::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 = myOkBaseTopo = false ;
+ myFactor = 2.0 ;
+ /* filter for next selections */
+ mySelection->ClearFilters() ;
+ mySelection->AddFilter( myVertexFilter );
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if( myOkBaseTopo && myOkPoint1 )
+ myGeomGUI->MakeScaleAndDisplay(myGeomShape, myPoint1, myFactor ) ;
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::ClickOnCancel()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::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 : TextChangedInLineEdit()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::TextChangedInLineEdit(const QString& newText)
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if(send == LineEditC1A3) {
+ myGeomGUI->EraseSimulationShape() ;
+ myFactor = newText.toFloat();
+ if( fabs(myFactor) > 0.00001 && myOkBaseTopo && myOkPoint1 )
+ MakeScaleSimulationAndDisplay(myBaseTopo) ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_ScaleDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ QString aString = ""; /* name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkBaseTopo = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 ) {
+ myEditCurrentArgument->setText("") ;
+ myOkPoint1 = false ;
+ }
+ return ;
+ }
+
+ // nbSel == 1
+ TopoDS_Shape S;
+ Standard_Boolean testResult ;
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ /* Constructor */
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ myEditCurrentArgument->setText(aString) ;
+ myBaseTopo = S ;
+ myOkBaseTopo = true ;
+ }
+ else if ( myEditCurrentArgument == LineEditC1A2 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
+ myEditCurrentArgument->setText(aString) ;
+ myOkPoint1 = true ;
+ }
+
+ if( myOkBaseTopo && myOkPoint1 ) {
+ MakeScaleSimulationAndDisplay( myBaseTopo ) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->ClearFilters() ;
+ SelectionIntoArgument() ;
+ }
+ else if(send == SelectButtonC1A2) {
+ LineEditC1A2->setFocus() ;
+ myEditCurrentArgument = LineEditC1A2;
+ mySelection->AddFilter(myVertexFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::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_ScaleDlg::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_ScaleDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : MakeScaleSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_ScaleDlg::MakeScaleSimulationAndDisplay( const TopoDS_Shape& S )
+{
+ this->mySimulationTopoDs.Nullify() ;
+
+ try {
+ gp_Trsf theTransformation ;
+ theTransformation.SetScale( myPoint1, myFactor) ;
+ BRepBuilderAPI_Transform myBRepTransformation( S, theTransformation, Standard_False) ;
+ mySimulationTopoDs = myBRepTransformation.Shape() ;
+ if( mySimulationTopoDs.IsNull() )
+ return ;
+ else
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeScaleSimulationAndDisplay" ) ;
+ return ;
+ }
+ return ;
+}
--- /dev/null
+// 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_ScaleDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SCALE_H
+#define DIALOGBOX_SCALE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.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_ScaleDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_ScaleDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_ScaleDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_ScaleDlg();
+
+private :
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e );
+ void Init(SALOME_Selection* Sel) ;
+ void MakeScaleSimulationAndDisplay( const TopoDS_Shape& S ) ;
+
+ 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 */
+ TopoDS_Shape myBaseTopo ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBaseTopo */
+ Standard_Real myFactor ;
+ bool myOkPoint1 ; /* true when myPoint1 is defined */
+ bool myOkBaseTopo ; /* true when myBaseTopo is defined */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* filter for selection */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupC1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ QPushButton* SelectButtonC1A1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QLineEdit* LineEditC1A3;
+ QLabel* TextLabelC1A3;
+ 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() ;
+ void TextChangedInLineEdit(const QString& newText) ;
+
+protected:
+ QGridLayout* GeometryGUI_ScaleDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_SCALE_H
--- /dev/null
+// 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_SectionDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SectionDlg.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_SectionDlg()
+// purpose : Constructs a GeometryGUI_SectionDlg 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_SectionDlg::GeometryGUI_SectionDlg( 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_SECTION")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_SectionDlg" );
+ resize( 303, 224 );
+ setCaption( tr( "GEOM_SECTION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SectionDlgLayout = new QGridLayout( this );
+ GeometryGUI_SectionDlgLayout->setSpacing( 6 );
+ GeometryGUI_SectionDlgLayout->setMargin( 11 );
+
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SECTION" ) );
+ 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_SectionDlgLayout->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_SectionDlgLayout->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_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_SectionDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /* Initialisation */
+ Init( Sel ) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SectionDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SectionDlg::~GeometryGUI_SectionDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+ this->destroy(TRUE, TRUE) ;
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SectionDlg::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) ),this, 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_SectionDlg::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_SectionDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SectionDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkShape1 && myOkShape2) {
+ myGeomGUI->MakeBooleanAndDisplay(myGeomShape1, myGeomShape2, 4 ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_SectionDlg::ClickOnCancel()
+{
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection has changed
+//=================================================================================
+void GeometryGUI_SectionDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ QString aString = ""; /* future 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_SectionDlg::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_SectionDlg::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_SectionDlg::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_SectionDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose : when mouse enter onto the QWidget
+//=================================================================================
+void GeometryGUI_SectionDlg::enterEvent( QEvent * )
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SectionDlg::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 ;
+}
--- /dev/null
+// 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_SectionDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header:
+
+#ifndef DIALOGBOX_SECTION_H
+#define DIALOGBOX_SECTION_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <BRepAlgoAPI_Section.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_SectionDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SectionDlg : public QDialog{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SectionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_SectionDlg();
+
+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* LineEditC1A2Shape;
+ QLineEdit* LineEditC1A1Shape;
+ 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_SectionDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_SECTION_H
--- /dev/null
+// 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_SewingDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SewingDlg.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 <qvalidator.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+
+
+
+//=================================================================================
+// class : GeometryGUI_SewingDlg()
+// purpose : Constructs a GeometryGUI_SewingDlg 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_SewingDlg::GeometryGUI_SewingDlg( 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_SEWING")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_SewingDlg" );
+ resize( 303, 219 );
+ setCaption( tr( "GEOM_SEWING_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SewingDlgLayout = new QGridLayout( this );
+ GeometryGUI_SewingDlgLayout->setSpacing( 6 );
+ GeometryGUI_SewingDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SEWING" ) );
+ 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_SewingDlgLayout->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_SewingDlgLayout->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" );
+ LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
+ 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 );
+ 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_PRECISION" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A2->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A2->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
+ GeometryGUI_SewingDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SewingDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SewingDlg::~GeometryGUI_SewingDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::Init( SALOME_Selection* Sel )
+{
+ LineEditC1A1->setMaxLength( 10 );
+ QDoubleValidator *Va = new QDoubleValidator( -0.000001, +10000.0, 3, LineEditC1A1 ) ;
+ LineEditC1A1->setValidator( Va ) ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ this->myOkListShapes = false ;
+ this->myPrecision = 0.00001 ;
+ LineEditC1A2->setText("0.00001") ;
+ 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( 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 (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_SewingDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::ClickOnApply()
+{
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkListShapes) {
+ myGeomGUI->MakeSewingAndDisplay( myListShapes, myPrecision ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::ClickOnCancel()
+{
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_SewingDlg::SelectionIntoArgument()
+{
+ /* All this for first constructor */
+ // if(myEditCurrentArgument == LineEditC1A1 )
+
+ myOkListShapes = false;
+ myEditCurrentArgument->setText("") ;
+ QString aString = ""; /* name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel < 2 ) {
+ return ;
+ }
+
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkListShapes = true ;
+ /* no simulation */
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::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_SewingDlg::LineEditReturnPressed()
+{
+ this->myPrecision = LineEditC1A2->text().toFloat();
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::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_SewingDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SewingDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
--- /dev/null
+// 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_SewingDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SEWING_H
+#define DIALOGBOX_SEWING_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 GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_SewingDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SewingDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SewingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_SewingDlg();
+
+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_Gen::ListOfIOR myListShapes ;
+ Standard_Real myPrecision ;
+ 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* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QGroupBox* GroupC1;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+
+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_SewingDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_SEWING_H
--- /dev/null
+// 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_ShellDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_ShellDlg.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_ShellDlg()
+// purpose : Constructs a GeometryGUI_ShellDlg 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_ShellDlg::GeometryGUI_ShellDlg( QWidget* parent, const char* name, SALOME_Selection* Sel = 0, 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_SHELL")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ if ( !name )
+ setName( "GeometryGUI_ShellDlg" );
+ resize( 303, 190 );
+ setCaption( tr( "GEOM_SHELL_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_ShellDlgLayout = new QGridLayout( this );
+ GeometryGUI_ShellDlgLayout->setSpacing( 6 );
+ GeometryGUI_ShellDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SHELL" ) );
+ 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_ShellDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_SHELL_LIST" ) );
+ 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->addWidget( LineEditC1A1, 0, 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_FACES" ) );
+ TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A1->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A1->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
+ GeometryGUI_ShellDlgLayout->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_ShellDlgLayout->addWidget( GroupButtons, 2, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_ShellDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_ShellDlg::~GeometryGUI_ShellDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::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( 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( 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_ShellDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::ClickOnApply()
+{
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkListShapes) {
+ // myGeomGUI->MakeShellAndDisplay( myListShapes ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::ClickOnCancel()
+{
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_ShellDlg::SelectionIntoArgument()
+{
+ /* All this for first constructor */
+ // if(myEditCurrentArgument == LineEditC1A1 )
+ myEditCurrentArgument->setText("") ;
+ myOkListShapes = false;
+
+ QString aString = ""; /* name of future selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel < 1 ) {
+ return ;
+ }
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ;
+
+ myEditCurrentArgument->setText(aString) ;
+ myOkListShapes = true ;
+ /* no simulation */
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::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_ShellDlg::LineEditReturnPressed()
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ disconnect( mySelection, 0, this, 0 );
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::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_ShellDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_ShellDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
--- /dev/null
+// 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_ShellDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SHELL_H
+#define DIALOGBOX_SHELL_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_ShellDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_ShellDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_ShellDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_ShellDlg();
+
+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 argument is defined */
+
+ int myConstructorId ; /* Current constructor id = radio button id */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupC1;
+ QLineEdit* LineEditC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+
+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_ShellDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+ QHBoxLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_SHELL_H
--- /dev/null
+// 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_SphereDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SphereDlg.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 <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_SphereDlg()
+// purpose : Constructs a GeometryGUI_SphereDlg 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_SphereDlg::GeometryGUI_SphereDlg( 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_SPHERE_P")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_SPHERE_DXYZ")));
+
+ if ( !name )
+ setName( "GeometryGUI_SphereDlg" );
+ resize( 303, 219 );
+ setCaption( tr( "GEOM_SPHERE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SphereDlgLayout = new QGridLayout( this );
+ GeometryGUI_SphereDlgLayout->setSpacing( 6 );
+ GeometryGUI_SphereDlgLayout->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_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_SphereDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SPHERE" ) );
+ 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, 3 );
+ Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
+ Constructor1->setText( tr( "" ) );
+ Constructor1->setPixmap( image0 );
+ Constructor1->setChecked( TRUE );
+ Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
+ Constructor1->setMinimumSize( QSize( 50, 0 ) );
+ GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
+ QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
+ Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
+ Constructor2->setText( tr( "" ) );
+ GroupConstructors->insert( Constructor2, 1 );
+ Constructor2->setMinimumSize( QSize( 50, 0 ) );
+ Constructor2->setPixmap( image2 );
+ GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
+ GeometryGUI_SphereDlgLayout->addWidget( GroupConstructors, 0, 0 );
+ GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
+ GroupConstructor1->setTitle( tr( "GEOM_SPHERE_CR" ) );
+ 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_CENTER" ) );
+ TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A1->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A1->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabelC1A1, 0, 0 );
+ TextLabelC1A2 = new QLabel( GroupConstructor1, "TextLabelC1A2" );
+ TextLabelC1A2->setText( tr( "GEOM_RADIUS" ) );
+ TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A2->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A2->setFrameShadow( QLabel::Plain );
+ GroupConstructor1Layout->addWidget( TextLabelC1A2, 1, 0 );
+
+ SpinBox_C1A2 = new GeometryGUI_SpinBox( GroupConstructor1, "GeomSpinBox_C1A2" ) ;
+ GroupConstructor1Layout->addWidget( SpinBox_C1A2, 1, 2 );
+
+ GeometryGUI_SphereDlgLayout->addWidget( GroupConstructor1, 1, 0 );
+
+ /***************************************************************/
+ GroupConstructor2 = new QGroupBox( this, "GroupConstructor2" );
+ GroupConstructor2->setTitle( tr( "GEOM_SPHERE_RO" ) );
+ GroupConstructor2->setColumnLayout(0, Qt::Vertical );
+ GroupConstructor2->layout()->setSpacing( 0 );
+ GroupConstructor2->layout()->setMargin( 0 );
+ GroupConstructor2Layout = new QGridLayout( GroupConstructor2->layout() );
+ GroupConstructor2Layout->setAlignment( Qt::AlignTop );
+ GroupConstructor2Layout->setSpacing( 6 );
+ GroupConstructor2Layout->setMargin( 11 );
+
+ SpinBox_C2A1 = new GeometryGUI_SpinBox( GroupConstructor2, "GeomSpinBox_C2A1" ) ;
+ GroupConstructor2Layout->addWidget( SpinBox_C2A1, 0, 1 );
+
+ TextLabelC2A1 = new QLabel( GroupConstructor2, "TextLabelC2A1" );
+ TextLabelC2A1->setText( tr( "GEOM_RADIUS" ) );
+ TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A1->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A1->setFrameShadow( QLabel::Plain );
+ GroupConstructor2Layout->addWidget( TextLabelC2A1, 0, 0 );
+ QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ GroupConstructor2Layout->addItem( spacer_5, 1, 1 );
+ GeometryGUI_SphereDlgLayout->addWidget( GroupConstructor2, 1, 0 );
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SphereDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SphereDlg::~GeometryGUI_SphereDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::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_C1A2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_C1A2->SetValue( 100.0 ) ;
+ SpinBox_C2A1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_C2A1->SetValue( 100.0 ) ;
+
+ GroupConstructor1->show();
+ GroupConstructor2->hide();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myPoint1.SetCoord( 0.0, 0.0, 0.0 );
+
+ myRadius = 100.0 ;
+ myOkRadius = true ;
+ myOkPoint1 = false ;
+
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ /* 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( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( SpinBox_C1A2, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+ connect( SpinBox_C2A1, 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_SphereDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+
+ switch (constructorId)
+ {
+ case 0:
+ {
+ GroupConstructor1->show();
+ GroupConstructor2->hide();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = SpinBox_C1A2 ;
+ LineEditC1A1->setText(tr("")) ;
+ SpinBox_C1A2->SetValue( 100.0 ) ;
+ myRadius = 100.0 ;
+ myOkRadius = true ;
+ myOkPoint1 = false ;
+ /* filter for next selections */
+ mySelection->ClearFilters() ;
+ mySelection->AddFilter( myVertexFilter );
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ break;
+ }
+ case 1:
+ {
+ GroupConstructor1->hide();
+ GroupConstructor2->show();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = SpinBox_C2A1 ;;
+ SpinBox_C2A1->SetValue( 100.0 ) ;
+ myRadius = 100.0 ;
+ myOkRadius = true ;
+ myPoint1.SetCoord( 0.0, 0.0, 0.0 ); /* at origin */
+ myOkPoint1 = false ;
+ mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape();
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ /* no filters here */
+ mySelection->ClearFilters() ;
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if( myOkPoint1 && myOkRadius ) {
+ myGeomGUI->MakeSphereAndDisplay( myPoint1, myRadius ) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ if( myOkRadius )
+ myGeomGUI->MakeSphereAndDisplay( myPoint1, myRadius ) ;
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::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_SphereDlg::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 ;
+ }
+ return ;
+ }
+
+ /* nbSel == 1 ! */
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ /* Constructor 1 treatment */
+ if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
+ LineEditC1A1->setText(aString) ;
+ myOkPoint1 = true ;
+ }
+
+ if( ( myOkPoint1 || myConstructorId == 1 ) && myOkRadius ) {
+ mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape();
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::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. */
+ 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_SphereDlg::ValueChangedInSpinBox( double newValue )
+{
+ myRadius = newValue ;
+ myOkRadius = true ;
+
+ if ( ( myOkPoint1 || myConstructorId == 1 ) && myOkRadius ) {
+ mySimulationTopoDs = BRepPrimAPI_MakeSphere(myPoint1, myRadius).Shape();
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ mySelection->AddFilter(myVertexFilter) ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ case 1:
+ {
+ /* no selection button here */
+ break;
+ }
+
+ }
+ return ;
+}
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+
+ GroupConstructors->setEnabled(false) ;
+ GroupConstructor1->setEnabled(false) ;
+ GroupConstructor2->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ mySelection->ClearFilters() ;
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate other active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupConstructor1->setEnabled(true) ;
+ GroupConstructor2->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SphereDlg::closeEvent( QCloseEvent* e )
+{
+ this->ClickOnCancel() ; /* same than click on cancel button */
+}
+
+
+
--- /dev/null
+// 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_SphereDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SPHERE_H
+#define DIALOGBOX_SPHERE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <gp_Pnt.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRepPrimAPI_MakeSphere.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 QSpinBox;
+class QPushButton;
+class GeometryGUI_SpinBox;
+class QRadioButton;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_SphereDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SphereDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SphereDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_SphereDlg();
+
+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 */
+
+ Standard_Real myRadius ;
+ bool myOkRadius ;
+ QDoubleValidator *myVa ; /* Double validator for numeric input myRadius in LineEditC1A2 */
+ QDoubleValidator *myVb ; /* Double validator for numeric input myRadius in LineEditC2A1 */
+
+ bool myOkPoint1 ; /* Are true when myPoint is defined */
+ QWidget* myEditCurrentArgument; /* Current LineEdit or SpinBox */
+ 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 ) ;
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QRadioButton* Constructor2;
+ QGroupBox* GroupConstructor1;
+ QLineEdit* LineEditC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ // QLineEdit* LineEditC1A2;
+ QGroupBox* GroupConstructor2;
+ // QLineEdit* LineEditC2A1;
+ GeometryGUI_SpinBox* SpinBox_C1A2 ;
+ GeometryGUI_SpinBox* SpinBox_C2A1 ;
+ QLabel* TextLabelC2A1;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void LineEditReturnPressed() ;
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_SphereDlgLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupConstructor2Layout;
+};
+
+#endif // DIALOGBOX_SPHERE_H
--- /dev/null
+// 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_SpinBox.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SpinBox.h"
+#include "GeometryGUI.h"
+#include <qvalidator.h>
+//#include <qpushbutton.h>
+//#include "utilities.h"
+
+//=================================================================================
+// class : GeometryGUI_SpinBox()
+// purpose : constructor of specific widget accepting floats in double precision.
+//=================================================================================
+GeometryGUI_SpinBox::GeometryGUI_SpinBox( QWidget* parent, const char* name )
+: QAD_SpinBoxDbl( parent, name)
+{
+ /* when step value is changed in myGeomGUI */
+ connect( GeometryGUI::GetGeometryGUI(), SIGNAL( SignalDefaultStepValueChanged( double )), this, SLOT( SetStep( double ) ) );
+}
+
+
+//=================================================================================
+// function : SetStep() [SLOT]
+// purpose :
+//=================================================================================
+void GeometryGUI_SpinBox::SetStep( double newStep )
+{
+ setLineStep( newStep );
+}
+
+//=================================================================================
+// function : ~GeometryGUI_SpinBox()
+// purpose : destructor
+//=================================================================================
+GeometryGUI_SpinBox::~GeometryGUI_SpinBox()
+{
+}
+
+//=================================================================================
+// function : SetValue()
+// purpose :
+//=================================================================================
+void GeometryGUI_SpinBox::SetValue( double v )
+{
+ setValue( v );
+}
+
+//=================================================================================
+// function : GetValue()
+// purpose : returns a double
+//=================================================================================
+double GeometryGUI_SpinBox::GetValue( )
+{
+ return value();
+}
+
+//=================================================================================
+// function : GetString()
+// purpose : returns a QString
+//=================================================================================
+QString GeometryGUI_SpinBox::GetString( )
+{
+ return cleanText();
+}
+
+//=================================================================================
+// function : RangeStepAndValidator()
+// purpose :
+//=================================================================================
+void GeometryGUI_SpinBox::RangeStepAndValidator( double min, double max, double step, unsigned short decimals )
+{
+ setRange( min, max );
+ setLineStep( step );
+ ( ( QDoubleValidator* )validator() )->setRange( min, max, decimals ) ;
+}
--- /dev/null
+// 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_SpinBox.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef GEOMSPINBOX_H
+#define GEOMSPINBOX_H
+
+#include "QAD_SpinBoxDbl.h"
+
+class GeometryGUI ;
+
+//=================================================================================
+// class : GeometryGUI_SpinBox
+// purpose : Derivated from QSpinBox class and modified to accept floats
+//=================================================================================
+class GeometryGUI_SpinBox : public QAD_SpinBoxDbl
+{
+ Q_OBJECT
+
+public :
+ GeometryGUI_SpinBox( QWidget* parent, const char* name = 0 );
+ ~GeometryGUI_SpinBox();
+
+ void RangeStepAndValidator( double min = -1000000.0,
+ double max = +1000000.0,
+ double step = 100.0,
+ unsigned short decimals = 3 );
+ void SetValue( double v );
+ double GetValue();
+ QString GetString();
+
+public slots:
+ void SetStep( double newStep );
+
+};
+#endif // GEOMSPINBOX_H
--- /dev/null
+// 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_SubShapeDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SubShapeDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_RightFrame.h"
+#include "OCCViewer_Viewer3d.h"
+#include "utilities.h"
+
+#include <TopExp_Explorer.hxx>
+
+#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 <qmessagebox.h>
+
+//=================================================================================
+// class : GeometryGUI_SubShapeDlg()
+// purpose : Constructs a GeometryGUI_SubShapeDlg 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_SubShapeDlg::GeometryGUI_SubShapeDlg( 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_SUBSHAPE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_SUBSHAPE" );
+ resize( 303, 239 );
+ setCaption( tr( "GEOM_SUBSHAPE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SubShapeDlgLayout = new QGridLayout( this );
+ GeometryGUI_SubShapeDlgLayout->setSpacing( 6 );
+ GeometryGUI_SubShapeDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SUB_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)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_SubShapeDlgLayout->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_SubShapeDlgLayout->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_MAIN_OBJECT" ) );
+ TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC1A1->setFrameShape( QLabel::NoFrame );
+ TextLabelC1A1->setFrameShadow( QLabel::Plain );
+ GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 );
+ TextLabelComboBox1 = new QLabel( GroupC1, "TextLabelComboBox1" );
+ TextLabelComboBox1->setText( tr( "GEOM_SUBSHAPE_TYPE" ) );
+ GroupC1Layout->addMultiCellWidget( TextLabelComboBox1, 1, 1, 0, 1 );
+ ComboBox1 = new QComboBox( FALSE, GroupC1, "ComboBox1" );
+ ComboBox1->setMaxCount( 100 );
+ GroupC1Layout->addMultiCellWidget( ComboBox1, 1, 1, 2, 3 );
+ CheckBox1 = new QCheckBox( GroupC1, "CheckBox1" );
+ CheckBox1->setText( tr( "GEOM_SUBSHAPE_SELECT" ) );
+ CheckBox1->setChecked( FALSE );
+ GroupC1Layout->addMultiCellWidget( CheckBox1, 2, 2, 0, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 2, 3 );
+ 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_SubShapeDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ /* Initialisations */
+ Init(Sel, ic) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SubShapeDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SubShapeDlg::~GeometryGUI_SubShapeDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::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 ;
+ myLocalContextId = -1;
+ myAbort = false ;
+ myOkShape = false ;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ /* type for sub shape selection */
+ ComboBox1->insertItem("Compound");
+ ComboBox1->insertItem("Compsolid");
+ ComboBox1->insertItem("Solid");
+ ComboBox1->insertItem("Shell");
+ ComboBox1->insertItem("Face");
+ ComboBox1->insertItem("Wire");
+ ComboBox1->insertItem("Edge");
+ ComboBox1->insertItem("Vertex");
+ ComboBox1->insertItem("Shape");
+
+ myWithShape = true;
+ myShapeType = ComboBox1->currentItem();
+
+ /* Select sub shapes mode not checked */
+ CheckBox1->setChecked( FALSE );
+ myOkSelectSubMode = CheckBox1->isChecked();
+
+ // 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) ), this, SLOT( ConstructorsClicked(int) ) );
+
+ connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
+ connect( CheckBox1, SIGNAL (stateChanged(int) ), this, SLOT( AllOrNotAll() ) ) ;
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
+ connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
+
+ connect( ComboBox1, SIGNAL( activated(int) ), this, SLOT( ComboTextChanged() ) );
+
+ /* 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_SubShapeDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+
+ /* User has aborted or not operation of explode all with many sub shapes */
+ if( this->myAbort == false )
+ this->ClickOnCancel() ;
+ else
+ this->myAbort = false ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ bool testResult = false ;
+
+ this->myAbort = false ; /* Not aborted by default */
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ /* Explode all sub shapes */
+ if( myOkShape && !myOkSelectSubMode ) {
+
+ /* More than 30 subshapes : ask confirmation */
+ unsigned int nb = NumberOfSubShapes( myShape, myShapeType ) ;
+ if( nb > 30 ) {
+ const QString caption = tr("GEOM_CONFIRM") ;
+ const QString text = tr("GEOM_CONFIRM_INFO").arg(nb) ;
+ const QString button0 = tr("GEOM_BUT_EXPLODE") ;
+ const QString button1 = tr("GEOM_BUT_CANCEL") ;
+
+ if( QMessageBox::warning( this, caption, text, button0, button1 ) == 0 )
+ testResult = myGeomGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ;
+ else
+ this->myAbort = true ; /* aborted */
+ }
+ else {
+ testResult = myGeomGUI->OnSubShapeGetAll( myShape, myShapeIOR, myShapeType ) ;
+ }
+ }
+ /* explode only selected sub shapes */
+ else if( myOkShape && myOkSelectSubMode ) {
+ testResult = myGeomGUI->OnSubShapeGetSelected( myShape, myShapeIOR, myShapeType, myLocalContextId, myUseLocalContext ) ;
+ }
+ if( !testResult ) {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
+ this->myAbort = true;
+ }
+ else {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ /* Reset all arguments and local context to allow user a new selection ...*/
+ this->ResetStateOfDialog() ;
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::ClickOnCancel()
+{
+ 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(myUseLocalContext) {
+ myIC->CloseLocalContext(myLocalContextId) ;
+ myGeomGUI->OnDisplayAll(true) ;
+ this->myUseLocalContext = false ;
+ }
+ }
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+// : used only by SelectButtonC1A1 (LineEditC1A1)
+//=================================================================================
+void GeometryGUI_SubShapeDlg::SelectionIntoArgument()
+{
+
+ /* Reset all arguments and local context when selection as changed */
+ this->ResetStateOfDialog() ;
+
+ QString aString = ""; /* future name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+
+ if ( nbSel != 1 ) {
+ LineEditC1A1->setText("") ;
+ myOkShape = false;
+ 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("GEOM_PRP_SHAPE_IN_STUDY")) ;
+ return ;
+ }
+
+ if ( !S.IsNull() && S.ShapeType() != TopAbs_VERTEX )
+ {
+ 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 ;
+ }
+ else
+ {
+ 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) ;
+ }
+ }
+ }
+
+ int SelectedShapeType = ComboBox1->currentItem();
+ int count = ComboBox1->count();
+ if ( myWithShape ) count = count - 1;
+
+ int i = 0;
+ while ( i <= myShape.ShapeType() ) {
+ ComboBox1->removeItem(0);
+ i++;
+ }
+
+ if (myShape.ShapeType()==TopAbs_COMPOUND)
+ {
+ if (myWithShape == false) {
+ ComboBox1->insertItem("Shape");
+ myWithShape = true;
+ }
+ }
+ else
+ {
+ if (myWithShape == true) {
+ ComboBox1->removeItem( ComboBox1->count() -1 );
+ myWithShape = false;
+ }
+ }
+
+ int count1 = ComboBox1->count();
+ if ( myWithShape ) count1 = count1 - 1;
+
+ if ( SelectedShapeType > myShape.ShapeType() ) {
+ if ( SelectedShapeType == 8 ) {
+ if ( myShape.ShapeType() != TopAbs_COMPOUND ) {
+ ComboBox1->setCurrentItem(0);
+ myShapeType = 8 - count1;
+ }
+ } else {
+ ComboBox1->setCurrentItem( count1 - count + SelectedShapeType );
+ myShapeType = 8 - count1 + ComboBox1->currentItem();
+ }
+ } else {
+ ComboBox1->setCurrentItem(0);
+ myShapeType = 8 - count1;
+ }
+ }
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::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_SubShapeDlg::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_SubShapeDlg::DeactivateActiveDialog()
+{
+ /* Check if active */
+ 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_SubShapeDlg::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 :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : AllOrNotAll()
+// purpose : Allow user selection of all or only selected sub shapes
+// : Called when 'CheckBox1' state change
+//=================================================================================
+void GeometryGUI_SubShapeDlg::AllOrNotAll()
+{
+
+ /* No sub shape selection if main shape not selected */
+ if( !this->myOkShape ) {
+ ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ;
+ return ;
+ }
+
+ if (myShapeType ==TopAbs_SHAPE && myShape.ShapeType()==TopAbs_COMPOUND)
+ {
+ /* Select sub shapes mode not checked */
+ myOkSelectSubMode = false ;
+ CheckBox1->setChecked( FALSE );
+ //no meaning to allow user selection for type = shape
+ //TODO - add another message
+ //myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FIRST")) ;
+ return ;
+ }
+
+ myOkSelectSubMode = CheckBox1->isChecked() ;
+
+ 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(myLocalContextId) ;
+ this->myUseLocalContext = false ;
+ myGeomGUI->OnDisplayAll(true) ;
+ }
+ } else {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ return;
+ }
+
+ if( myOkShape && myOkSelectSubMode ) {
+ /* local context is defined into the method */
+ myGeomGUI->PrepareSubShapeSelection( this->myShapeType, this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ResetStateOfDialog()
+// purpose : Completely reset the state of method including local context
+//=================================================================================
+void GeometryGUI_SubShapeDlg::ResetStateOfDialog()
+{
+ /* To leave current selection if explode all as been aborted by user */
+ if( this->myAbort == true ) {
+ this->myOkShape = false ;
+ this->myEditCurrentArgument->setText("") ;
+ }
+ else {
+ ; /* nothing to do : keep selection argument */
+ }
+
+ int SelectedShapeType = ComboBox1->currentItem();
+ int count = ComboBox1->count();
+ if ( myWithShape ) count = count - 1;
+ /* type for sub shape selection */
+ ComboBox1->clear();
+ ComboBox1->insertItem("Compound");
+ ComboBox1->insertItem("Compsolid");
+ ComboBox1->insertItem("Solid");
+ ComboBox1->insertItem("Shell");
+ ComboBox1->insertItem("Face");
+ ComboBox1->insertItem("Wire");
+ ComboBox1->insertItem("Edge");
+ ComboBox1->insertItem("Vertex");
+ ComboBox1->insertItem("Shape");
+ this->myWithShape=true;
+ ComboBox1->setCurrentItem( 8 - count + SelectedShapeType );
+
+
+ /* unpress buttons : due to abort box*/
+ this->buttonApply->setDown(FALSE) ;
+ this->buttonOk->setDown(FALSE) ;
+
+ /* Select sub shapes mode not checked */
+ this->myOkSelectSubMode = false ;
+ this->CheckBox1->setChecked( FALSE );
+
+ /* 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 ;
+}
+
+
+
+//=================================================================================
+// function : ComboTextChanged()
+// purpose :
+//=================================================================================
+void GeometryGUI_SubShapeDlg::ComboTextChanged()
+{
+ if ( myOkShape )
+ this->myShapeType = ComboBox1->currentItem() + myShape.ShapeType() + 1;
+ else
+ this->myShapeType = ComboBox1->currentItem();
+
+ /* Select sub shapes mode not checked */
+ CheckBox1->setChecked( FALSE );
+ myOkSelectSubMode = FALSE ;
+
+ 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(myLocalContextId) ;
+ this->myUseLocalContext = false ;
+ myGeomGUI->OnDisplayAll(true) ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : NumberOfSubShapes()
+// purpose :
+//=================================================================================
+unsigned int GeometryGUI_SubShapeDlg::NumberOfSubShapes( const TopoDS_Shape& S, const int shapeType )
+{
+ if( S.IsNull() )
+ return 0 ;
+
+ unsigned int index = 0 ;
+ TopExp_Explorer Exp( S, TopAbs_ShapeEnum(shapeType) );
+ TopTools_MapOfShape M;
+ while ( Exp.More() ) {
+ if ( M.Add(Exp.Current()) )
+ index++;
+ Exp.Next();
+ }
+ M.Clear() ;
+ return index ;
+}
+
+
--- /dev/null
+// 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_SubShapeDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SUBSHAPE_H
+#define DIALOGBOX_SUBSHAPE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QComboBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_SubShapeDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SubShapeDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SubShapeDlg( QWidget* parent = 0,
+ const char* name = 0,
+ SALOME_Selection* Sel = 0,
+ Handle (AIS_InteractiveContext) ic = 0,
+ bool modal = FALSE,
+ WFlags fl = 0 );
+
+ ~GeometryGUI_SubShapeDlg();
+
+private :
+
+ void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ void ResetStateOfDialog() ;
+
+ unsigned int NumberOfSubShapes( const TopoDS_Shape& S, const int shapeType ) ;
+
+
+ /* 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 ;
+ int myShapeType ; /* define a type of topology mode of sub selection */
+
+ bool myWithShape ; /* check if Shape item exists */
+
+ bool myOkSelectSubMode ; /* true = sub mode selection activated */
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ bool myAbort ; /* Indicate if sub Shape All has been aborted by user */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+ QPushButton* buttonApply;
+ QGroupBox* GroupC1;
+ QPushButton* SelectButtonC1A1;
+ QLineEdit* LineEditC1A1;
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelComboBox1;
+ QComboBox* ComboBox1;
+
+ QCheckBox* CheckBox1;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void LineEditReturnPressed() ;
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void AllOrNotAll() ;
+ void ComboTextChanged() ;
+
+protected:
+ QGridLayout* GeometryGUI_SubShapeDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_SUBSHAPE_H
--- /dev/null
+// 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_SuppressFacesDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SuppressFacesDlg.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_SuppressFacesDlg()
+// purpose : Constructs a GeometryGUI_SuppressFacesDlg 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_SuppressFacesDlg::GeometryGUI_SuppressFacesDlg( 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_SUPRESS_FACE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_SuppressFacesDlg" );
+ resize( 322, 203 );
+ setCaption( tr( "GEOM_SUPRESSFACE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SuppressFacesDlgLayout = new QGridLayout( this );
+ GeometryGUI_SuppressFacesDlgLayout->setSpacing( 6 );
+ GeometryGUI_SuppressFacesDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_SUPRESSFACE" ) );
+ 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_SuppressFacesDlgLayout->addWidget( GroupConstructors, 0, 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 );
+ Layout2 = new QHBoxLayout;
+ Layout2->setSpacing( 6 );
+ Layout2->setMargin( 0 );
+ TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
+ TextLabelC1A1->setText( tr( "GEOM_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( "GEOM_SUPRESSFACE_SELECT" ) );
+ CheckBox1->setChecked( FALSE );
+ GroupC1Layout->addWidget( CheckBox1, 1, 0 );
+ GeometryGUI_SuppressFacesDlgLayout->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 );
+ //
+ 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_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupButtonsLayout->addItem( spacer_2, 0, 2 );
+ buttonClose = new QPushButton( GroupButtons, "buttonClose" );
+ buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) );
+ buttonClose->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonClose, 0, 3 );
+ GeometryGUI_SuppressFacesDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /* Initialisations */
+ Init(Sel, ic) ;
+
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SuppressFacesDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SuppressFacesDlg::~GeometryGUI_SuppressFacesDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::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( 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_SuppressFacesDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose : Same than click on apply but close this dialog.
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ accept();
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::ClickOnApply()
+{
+ bool testResult = false ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if( myOkShape && myOkSelectSubMode ) {
+ testResult = myGeomGUI->OnSuppressFaces( myShape, myShapeIOR, myLocalContextId, myUseLocalContext ) ;
+ }
+ if( !testResult ) {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_ABORT")) ;
+ }
+ else {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_DONE")) ;
+ }
+ /* Reset arguments to allow a new selection */
+ this->ResetStateOfDialog() ;
+ break ;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnClose()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::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_SuppressFacesDlg::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("GEOM_PRP_SHAPE_IN_STUDY")) ;
+ return ;
+ }
+
+ /* Test the exact type of topology to suppress faces into */
+ 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_SuppressFacesDlg::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_SuppressFacesDlg::LineEditReturnPressed()
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::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_SuppressFacesDlg::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_SuppressFacesDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnClose() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateUserSelection()
+// purpose : Activate selection of faces when CheckBox1->isChecked()...
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::ActivateUserSelection()
+{
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ if( !this->myOkShape ) {
+ this->ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_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 : 4 = FACES sub selection */
+ myGeomGUI->PrepareSubShapeSelection( int(TopAbs_FACE), this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_SELECT_FACE")) ;
+ }
+ } else {
+ CheckBox1->setChecked( false );
+ }
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ResetStateOfDialog()
+// purpose : Completely reset the state of method including local context
+//=================================================================================
+void GeometryGUI_SuppressFacesDlg::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 ;
+}
--- /dev/null
+// 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_SuppressFacesDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_SUPPRESSFACES_H
+#define DIALOGBOX_SUPPRESSFACES_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_SuppressFacesDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SuppressFacesDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SuppressFacesDlg( QWidget* parent = 0,
+ const char* name = 0,
+ SALOME_Selection* Sel = 0,
+ Handle (AIS_InteractiveContext) ic = 0,
+ bool modal = FALSE,
+ WFlags fl = 0 );
+
+ ~GeometryGUI_SuppressFacesDlg();
+
+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;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonApply;
+ QPushButton* buttonClose;
+
+ QCheckBox* CheckBox1;
+
+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_SuppressFacesDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+ QHBoxLayout* Layout2;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_SUPPRESSFACES_H
--- /dev/null
+// 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_SuppressHoleDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_SuppressHoleDlg.h"
+#include "GeometryGUI.h"
+
+#include "TopExp_Explorer.hxx"
+
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_RightFrame.h"
+#include "OCCViewer_Viewer3d.h"
+#include "utilities.h"
+
+#include <qapplication.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_SuppressHoleDlg()
+// purpose : Constructs a GeometryGUI_SuppressHoleDlg 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_SuppressHoleDlg::GeometryGUI_SuppressHoleDlg( 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_SUPRESS_HOLE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_SUPRESS_HOLE_FACE_SHELL")));
+
+ if ( !name )
+ setName( "GeometryGUI_SuppressHoleDlg" );
+ resize( 303, 204 );
+ setCaption( tr( "GEOM_SUPPRESSHOLE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_SuppressHoleLayout = new QGridLayout( this );
+ GeometryGUI_SuppressHoleLayout->setSpacing( 6 );
+ GeometryGUI_SuppressHoleLayout->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 );
+
+ Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
+ Constructor2->setText( tr( "" ) );
+ Constructor2->setPixmap( image2 );
+ Constructor2->setChecked( TRUE );
+ Constructor2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor2->sizePolicy().hasHeightForWidth() ) );
+ Constructor2->setMinimumSize( QSize( 50, 0 ) );
+ GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
+ QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupConstructorsLayout->addItem( spacer_4, 0, 3 );
+ GeometryGUI_SuppressHoleLayout->addWidget( GroupConstructors, 0, 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 QHBoxLayout( 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 );
+ buttonOk->setAccel( 276824143 );
+ GroupButtonsLayout->addWidget( buttonOk );
+ QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupButtonsLayout->addItem( spacer_2 );
+ buttonApply = new QPushButton( GroupButtons, "buttonApply" );
+ buttonApply->setText( tr( "GEOM_BUT_APPLY" ) );
+ buttonApply->setAutoDefault( TRUE );
+ buttonApply->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonApply );
+ buttonClose = new QPushButton( GroupButtons, "buttonClose" );
+ buttonClose->setText( tr( "GEOM_BUT_CLOSE" ) );
+ buttonClose->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonClose );
+ GeometryGUI_SuppressHoleLayout->addWidget( GroupButtons, 2, 0 );
+
+ /* First constructor */
+ 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( "GEOM_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( "GEOM_SUPPRESSHOLE_SELECTFACE" ) );
+ CheckBox1->setChecked( FALSE );
+ GroupC1Layout->addWidget( CheckBox1, 1, 0 );
+
+ CheckBox2 = new QCheckBox( GroupC1, "CheckBox2" );
+ CheckBox2->setText( tr( "GEOM_SUPPRESSHOLE_SELECTWIRE" ) );
+ CheckBox2->setChecked( FALSE );
+ GroupC1Layout->addWidget( CheckBox2, 2, 0 );
+
+ CheckBox3 = new QCheckBox( GroupC1, "CheckBox3" );
+ CheckBox3->setText( tr( "GEOM_SUPPRESSHOLE_SELECTFACE_END" ) );
+ CheckBox3->setChecked( FALSE );
+ GroupC1Layout->addWidget( CheckBox3, 3, 0 );
+ GeometryGUI_SuppressHoleLayout->addWidget( GroupC1, 1, 0 );
+
+ /* Second constructor */
+ GroupC2 = new QGroupBox( this, "GroupC2" );
+ GroupC2->setTitle( tr( "" ) );
+ 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 );
+
+ Layout3 = new QHBoxLayout;
+ Layout3->setSpacing( 6 );
+ Layout3->setMargin( 0 );
+
+ TextLabelC2A1 = new QLabel( GroupC2, "TextLabelC2A1" );
+ TextLabelC2A1->setText( tr( "GEOM_SUPPRESSHOLE_FACE_SHELL" ) );
+ TextLabelC2A1->setMinimumSize( QSize( 50, 0 ) );
+ TextLabelC2A1->setFrameShape( QLabel::NoFrame );
+ TextLabelC2A1->setFrameShadow( QLabel::Plain );
+ Layout3->addWidget( TextLabelC2A1 );
+
+ SelectButtonC2A1 = new QPushButton( GroupC2, "SelectButtonC2A1" );
+ SelectButtonC2A1->setText( tr( "" ) );
+ SelectButtonC2A1->setPixmap( image1 );
+ SelectButtonC2A1->setToggleButton( FALSE );
+ SelectButtonC2A1->setMaximumSize( QSize( 28, 32767 ) );
+ Layout3->addWidget( SelectButtonC2A1 );
+
+ LineEditC2A1 = new QLineEdit( GroupC2, "LineEditC2A1" );
+ LineEditC2A1->setAlignment( int( QLineEdit::AlignLeft ) );
+ Layout3->addWidget( LineEditC2A1 );
+
+ GroupC2Layout->addLayout( Layout3, 0, 0 );
+ QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ GroupC2Layout->addItem( spacer_3, 2, 0 );
+
+ CheckBoxC2_1 = new QCheckBox( GroupC2, "CheckBoxC2_1" );
+ CheckBoxC2_1->setText( tr( "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE" ) );
+ CheckBoxC2_1->setChecked( FALSE );
+
+ GroupC2Layout->addWidget( CheckBoxC2_1, 1, 0 );
+ GeometryGUI_SuppressHoleLayout->addWidget( GroupC2, 1, 0 );
+
+
+ /* Initialisations */
+ Init(Sel, ic) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_SuppressHoleDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_SuppressHoleDlg::~GeometryGUI_SuppressHoleDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic )
+{
+ GroupC1->show();
+ GroupC2->hide();
+
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myShape.Nullify() ;
+
+ myIC = ic ;
+ myUseLocalContext = false ;
+ myOkShape = false ;
+ myOkSelectFace = false ;
+
+ myListOfIdFace = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ myListOfIdWire = new GEOM::GEOM_Shape::ListOfSubShapeID;
+ myListOfIdEndFace = new GEOM::GEOM_Shape::ListOfSubShapeID;
+
+ myListOfIdFace->length(0) ;
+ myListOfIdWire->length(0) ;
+ myListOfIdEndFace->length(0) ;
+
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ /* Select sub modes not checked */
+ CheckBox1->setChecked( FALSE ); /* sub mode GEOM::FACE */
+ CheckBox2->setChecked( FALSE ); /* sub mode GEOM::WIRE */
+ CheckBox3->setChecked( FALSE ); /* sub mode END GEOM::FACE */
+
+ CheckBoxC2_1->setChecked( FALSE ); /* sub mode GEOM::WIRE(S) */
+
+ // 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( SelectButtonC1A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ));
+ connect( SelectButtonC2A1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ));
+
+ connect( CheckBox1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserFaceSelection() ));
+ connect( CheckBox2, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWireSelection() ));
+ connect( CheckBox3, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserEndFaceSelection() ));
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+ connect( LineEditC2A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ /* for the second constructor */
+ connect( CheckBoxC2_1, SIGNAL( stateChanged(int) ), this, SLOT( ActivateUserWiresOnFaceShellSelection() ));
+
+ 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_SuppressHoleDlg::ConstructorsClicked(int constructorId)
+{
+ switch (constructorId)
+ {
+ case 0:
+ {
+ GroupC1->show();
+ GroupC2->hide();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ LineEditC1A1->setText(tr("")) ;
+ myOkShape = false ;
+ myOkSelectFace = false ;
+ this->ResetPartial() ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ break;
+ }
+ case 1:
+ {
+ GroupC1->hide();
+ GroupC2->show();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditC2A1 ;
+ LineEditC2A1->setText(tr("")) ;
+ myOkShape = false ;
+ this->ResetPartial() ;
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ this->ResetPartial() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose : Same than click on apply but close this dialog.
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ accept();
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ bool testResult = false ;
+
+ if( !myOkShape )
+ return ;
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if( !myOkSelectFace )
+ return ;
+
+ if( CheckBox2->isChecked() ) {
+
+ if( !CheckBox3->isChecked() ) {
+
+ /* Call method to get sub shape selection of GEOM::WIRE */
+ bool aTest = myGeomGUI->GetIndexSubShapeSelected(myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
+
+ myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
+ if( !aTest || myListOfIdWire->length() != 1 ) {
+ CheckBox2->setChecked(FALSE) ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ }
+ else {
+ myListOfIdEndFace->length(0) ; /* no end face */
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ testResult = myGeomGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ;
+ QApplication::restoreOverrideCursor();
+ }
+ }
+ else { /* CheckBox3->isChecked() */
+
+ /* Call method to get sub shape selection of END GEOM::FACE */
+ bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdEndFace, myLocalContextId, myUseLocalContext) ;
+
+ myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
+ if( !aTest || myListOfIdEndFace->length() != 1 ) {
+ CheckBox3->setChecked(FALSE) ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ }
+ else {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ testResult = myGeomGUI->OnSuppressHole( myShapeIOR, myListOfIdFace, myListOfIdWire, myListOfIdEndFace ) ;
+ QApplication::restoreOverrideCursor();
+ }
+ }
+ }
+ break ;
+ }
+
+ case 1: /* second constructor */
+ {
+ if( CheckBoxC2_1->isChecked() ) {
+
+ /* Call method to get sub shape selection of one or more GEOM::WIRE(s) on a face or a shell */
+ bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
+
+ myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
+
+ if( !aTest || myListOfIdWire->length() < 1 ) {
+ CheckBoxC2_1->setChecked(FALSE) ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ }
+ else {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ testResult = myGeomGUI->OnSuppressHolesInFaceOrShell( myShapeIOR, myListOfIdWire ) ;
+ QApplication::restoreOverrideCursor();
+ }
+ }
+ break ;
+ }
+ }
+
+
+ if( !testResult )
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ else
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_DONE") ) ;
+
+ /* Reset arguments to allow a new selection */
+ this->ResetStateOfDialog() ;
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnClose()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ClickOnClose()
+{
+ 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(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 and SelectButtonC2A1
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::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 ( S.IsNull() || S.ShapeType() == TopAbs_VERTEX || S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
+ return ;
+ }
+
+ /* Test the exact type of topology to suppress faces into. */
+ /* For the second constructor a face or shell selection is needed */
+ if ( myConstructorId == 0 || ( myConstructorId == 1 && ( S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL ) ) ) {
+
+ if ( IO->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
+ Handle(GEOM_InteractiveObject) GIObject = Handle(GEOM_InteractiveObject)::DownCast( IO );
+
+ /* The Geom IOR string of selection */
+ myShapeIOR = GIObject->getIOR();
+ myEditCurrentArgument->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 ;
+ myEditCurrentArgument->setText(aString) ;
+ return;
+ }
+ }
+ }
+
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ case 1:
+ {
+ if(send == SelectButtonC2A1) {
+ LineEditC2A1->setFocus() ;
+ myEditCurrentArgument = LineEditC2A1;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEditC1A1 )
+ myEditCurrentArgument = LineEditC1A1 ;
+ else if ( send == LineEditC2A1)
+ myEditCurrentArgument = LineEditC2A1;
+ 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_SuppressHoleDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+
+ this->ResetStateOfDialog() ;
+
+ disconnect( mySelection, 0, this, 0 );
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupC2->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+
+ myGeomGUI->ResetState() ;
+ myGeomGUI->SetActiveDialogBox(0) ;
+ myGeomGUI->OnDisplayAll(true) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate other active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+
+ GroupConstructors->setEnabled(true) ;
+ GroupC1->setEnabled(true) ;
+ GroupC2->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_SuppressHoleDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnClose() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateUserFaceSelection()
+// purpose : Called when CheckBox1 state has changed. (Face selection is ckecked)
+// : Be careful user must first select a face then a wire !
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ActivateUserFaceSelection()
+{
+ if( !this->myOkShape ) {
+ this->ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_MAIN_OBJECT") ) ;
+ return ;
+ }
+
+ /* Test the viewer type VTK */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ this->ResetStateOfDialog() ;
+ return;
+ }
+
+ if( CheckBox1->isChecked() ) {
+
+ /* local context is opened into the method : Prepare GEOM::FACE sub selection */
+ myGeomGUI->PrepareSubShapeSelection( int(TopAbs_FACE), this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE") ) ;
+ }
+ else {
+ this->ResetPartial() ;
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateUserWireSelection()
+// purpose : Called when CheckBox2 state has changed. (Wire selection is ckecked)
+// : Be careful user must first select a face then a wire !
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ActivateUserWireSelection()
+{
+
+ if( !this->myOkShape ) {
+ this->ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
+ return ;
+ }
+
+ /* Test the type of viewer VTK */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ this->ResetStateOfDialog() ;
+ return;
+ }
+
+ if( CheckBox1->isChecked() ) {
+
+ /* Get sub shape selection GEOM::FACE : local context is closed */
+ bool aTest = myGeomGUI->GetIndexSubShapeSelected(myShape, int(TopAbs_FACE), myListOfIdFace, myLocalContextId, myUseLocalContext) ;
+
+ myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
+ if( !aTest || myListOfIdFace->length() != 1 ) {
+ CheckBox1->setChecked(FALSE) ;
+ myOkSelectFace = false ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ }
+ else {
+ myOkSelectFace = true ;
+ }
+ }
+ else {
+ this->ResetPartial() ;
+ return ;
+ }
+
+
+ if( CheckBox2->isChecked() ) {
+
+ /* Get the face selection */
+ this->myFace = FaceFromList(myShape, myListOfIdFace) ;
+ /* Local context is opened into the method : Prepare GEOM::WIRE sub selection into a face */
+ myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myFace, int(TopAbs_WIRE), this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTWIRE") ) ;
+ }
+ else {
+ this->ResetPartial() ;
+ }
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ActivateUserlEndFaceSelection()
+// purpose : Called when CheckBox3 state has changed. ( Optional End Face selection )
+// : Be careful user must first select a face then a wire then this optional end face !
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ActivateUserEndFaceSelection()
+{
+
+ if( !this->myOkShape ) {
+ this->ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
+ return ;
+ }
+
+ /* Test the type of viewer VTK */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ this->ResetStateOfDialog() ;
+ return;
+ }
+
+
+ if( CheckBox2->isChecked() ) {
+ /* Call method to get sub shape selection for the GEOM::WIRE into myFace : local context is closed */
+ bool aTest = myGeomGUI->GetIndexSubShapeSelected(this->myFace, int(TopAbs_WIRE), myListOfIdWire, myLocalContextId, myUseLocalContext) ;
+
+ myGeomGUI->OnDisplayAll(true) ; /* Display all objects so that next method using ic can memorize them */
+
+ if( !aTest || myListOfIdWire->length() != 1 ) {
+ CheckBox2->setChecked(FALSE) ;
+ CheckBox3->setChecked(FALSE) ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_PRP_ABORT") ) ;
+ return ;
+ }
+ }
+ else {
+ this->ResetPartial() ;
+ return ;
+ }
+
+
+ if( CheckBox3->isChecked() ) {
+ /* Local context is opened into the method : prepare GEOM::FACE(end) into myShape sub selection */
+ myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_FACE), this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECTFACE_END") ) ;
+ }
+ else {
+ this->ResetPartial() ;
+ }
+
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ActivateUserWiresOnFaceShellSelection()
+// purpose : Called when CheckBoxC2_1 state has changed.
+// : Only for second constructor !
+// : Prepare selection for wire(s) on main object that is a face or a shell
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ActivateUserWiresOnFaceShellSelection()
+{
+
+ if( !this->myOkShape ) {
+ this->ResetStateOfDialog() ;
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_MAIN_OBJECT") ) ;
+ return ;
+ }
+
+ /* Test the type of viewer VTK */
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC ) {
+ myGeomGUI->GetDesktop()->putInfo(tr("GEOM_PRP_NOT_FOR_VTK_VIEWER") ) ;
+ this->ResetStateOfDialog() ;
+ return;
+ }
+
+ if( CheckBoxC2_1->isChecked() ) {
+ /* Local context is opened to prepare GEOM::WIRE(S) selection into 'myShape' that is a (main) face */
+ myGeomGUI->PrepareSubShapeSelectionArgumentShape( this->myShape, int(TopAbs_WIRE), this->myLocalContextId ) ;
+ myUseLocalContext = true ;
+ myGeomGUI->GetDesktop()->putInfo( tr("GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE") ) ;
+ }
+ else {
+ this->ResetPartial() ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : FaceFromList()
+// purpose : Return the face (selected by user) that is a sub shape of 'aShape'
+// : and which unique index is in 'ListOfSub'.
+// : This allows opening a local context with this face loaded.
+// : See : myGeomGUI->PrepareSubShapeSelectionArgumentShape(...)
+//=================================================================================
+TopoDS_Shape GeometryGUI_SuppressHoleDlg::FaceFromList( const TopoDS_Shape& aShape,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub )
+{
+ TopoDS_Shape tds ;
+ tds.Nullify() ;
+ if( ListOfSub.length() != 1 || aShape.IsNull() )
+ return tds ;
+
+ int i = ListOfSub[0] ;
+ TopExp_Explorer exp ;
+ int j = 1 ;
+ for( exp.Init(aShape, TopAbs_FACE); exp.More(); exp.Next() ) {
+ if(j == i)
+ return exp.Current() ;
+ j++ ;
+ }
+ return tds ;
+}
+
+
+
+
+//=================================================================================
+// function : ResetStateOfDialog()
+// purpose : Completely reset the state of method including local context
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ResetStateOfDialog()
+{
+ this->myOkShape = false ;
+ this->myEditCurrentArgument->setText("") ;
+
+ /* Partial reset and more ...*/
+ this->ResetPartial() ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ResetPartial()
+// purpose : Partially reset to keep only main selection
+//=================================================================================
+void GeometryGUI_SuppressHoleDlg::ResetPartial()
+{
+ /* Select sub shape modes not checked */
+ this->myOkSelectFace = false ;
+ this->CheckBox1->setChecked( FALSE );
+ this->CheckBox2->setChecked( FALSE );
+ this->CheckBox3->setChecked( FALSE );
+ this->CheckBoxC2_1->setChecked( FALSE );
+
+ myListOfIdFace->length(0) ;
+ myListOfIdWire->length(0) ;
+ myListOfIdEndFace->length(0) ;
+
+ /* 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 ;
+}
--- /dev/null
+// 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_SuppressHoleDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef GEOMETRYGUI_SUPPRESSHOLE_H
+#define GEOMETRYGUI_SUPPRESSHOLE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class GeometryGUI;
+
+//=================================================================================
+// class : GeometryGUI_SuppressHoleDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_SuppressHoleDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_SuppressHoleDlg( QWidget* parent = 0,
+ const char* name = 0,
+ SALOME_Selection* Sel = 0,
+ Handle (AIS_InteractiveContext) ic = 0,
+ bool modal = FALSE,
+ WFlags fl = 0 );
+
+ ~GeometryGUI_SuppressHoleDlg();
+
+private :
+
+ void Init( SALOME_Selection* Sel, Handle (AIS_InteractiveContext) ic ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* Mouse enter the QWidget (to reactivate it) */
+
+ void ResetStateOfDialog() ;
+ void ResetPartial() ;
+
+ /* Return the face selected by user from the main shape and index in a ListOfSub */
+ TopoDS_Shape FaceFromList( const TopoDS_Shape& aShape,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfSub ) ;
+
+ 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 ; /* Main shape selected */
+ TopoDS_Shape myFace ; /* Face selected */
+
+ char* myShapeIOR ;
+ bool myOkShape ;
+
+ bool myOkSelectFace ; /* true = sub mode GEOM::FACE selection done */
+ bool myOkSelectWire ; /* true = sub mode GEOM::WIRE selection done (first wire) */
+
+ GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdFace ; /* After selection contains index of face into myShape */
+ GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdWire ; /* After selection contains index of wire into myFace */
+ GEOM::GEOM_Shape::ListOfSubShapeID_var myListOfIdEndFace ; /* After selection contains index of end face into myShape */
+
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonApply;
+ QPushButton* buttonClose;
+ QGroupBox* GroupC1;
+ QLabel* TextLabelC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLineEdit* LineEditC1A1;
+ QCheckBox* CheckBox1;
+ QCheckBox* CheckBox2;
+ QCheckBox* CheckBox3;
+
+ /* Second constructor */
+ QRadioButton* Constructor2;
+ QGroupBox* GroupC2;
+ QLabel* TextLabelC2A1;
+ QPushButton* SelectButtonC2A1;
+ QLineEdit* LineEditC2A1;
+ QCheckBox* CheckBoxC2_1;
+
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnApply() ;
+ void ClickOnClose();
+
+ void LineEditReturnPressed() ;
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ActivateUserFaceSelection() ;
+ void ActivateUserWireSelection() ;
+ void ActivateUserEndFaceSelection() ;
+
+ /* For the second constructor */
+ void ActivateUserWiresOnFaceShellSelection() ;
+
+
+protected:
+
+ QGridLayout* GeometryGUI_SuppressHoleLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QHBoxLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+ QHBoxLayout* Layout2;
+
+ QGridLayout* GroupC2Layout;
+ QHBoxLayout* Layout3;
+};
+
+#endif // GEOMETRYGUI_SUPPRESSHOLE_H
--- /dev/null
+// 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_Swig.cxx
+// Author : Nicolas REJNERI, Paul RASCLE
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_Swig.hxx"
+#include "utilities.h"
+
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "QAD_Study.h"
+#include "QAD_StudyFrame.h"
+#include "QAD_RightFrame.h"
+#include "SALOMEGUI_ImportOperation.h"
+
+#include "OCCViewer_Viewer3d.h"
+#include <TopExp_Explorer.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <GeomAbs_CurveType.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+
+#include "VTKViewer_RenderWindowInteractor.h"
+#include "VTKViewer_ViewFrame.h"
+
+#include "GEOM_Actor.h"
+#include "GEOM_Client.hxx"
+#include "GEOM_AISShape.hxx"
+#include "GEOM_AssemblyBuilder.h"
+#include "GEOM_InteractiveObject.hxx"
+
+static GEOM_Client ShapeReader;
+
+GeometryGUI_Swig::GeometryGUI_Swig()
+{
+ // MESSAGE("Constructeur");
+}
+
+GeometryGUI_Swig::~GeometryGUI_Swig()
+{
+ // MESSAGE("Destructeur");
+}
+
+void GeometryGUI_Swig::createAndDisplayGO(const char* Entry)
+{
+ // MESSAGE("createAndDisplayGO");
+ QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
+ SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
+
+ Standard_CString Fatherior = "";
+ SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
+ aStudyBuilder->DefineComponentInstance( father, Geom );
+ father->ComponentIOR( Fatherior );
+
+ SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(ActiveStudy->getActiveStudyFrame()->entry());
+
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID(Entry);
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributeIOR_var anIOR;
+ // Create new actor
+ if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
+ return;
+ anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+ GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(anIOR->Value());
+ TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
+
+ if ( !obj->_is_nil() ) {
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ // open transaction
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( ActiveStudy );
+ op->start();
+
+ SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->finish();
+
+ if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
+ //vtkQGLRenderWindowInteractor* myRenderInter = ActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ int themode = myRenderInter->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
+ Fatherior,
+ "GEOM");
+ IO->setEntry(obj->GetID());
+ GActor->setIO( IO );
+ GActor->setName( aName->Value() );
+
+ myRenderInter->Display(GActor);
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ myRenderInter->Update();
+ }
+ else if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ // QAD_Viewer3d* v3d = ActiveStudy->getActiveStudyFrame()->getViewerOCC();
+ Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
+ Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
+ Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
+ Fatherior,
+ "GEOM");
+
+ IO->setEntry(obj->GetID());
+ aSh->setIO( IO );
+ aSh->setName( aName->Value() );
+ ic->Display (aSh);
+ ic->AddOrRemoveCurrentObject(aSh, true);
+ }
+ }
+ }
+ ActiveStudy->updateObjBrowser( true );
+}
+
+int GeometryGUI_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
+{
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
+
+ GEOM::GEOM_Shape_var aMainShape = Geom->GetIORFromString(IOR);
+ TopoDS_Shape shape = ShapeReader.GetShape(Geom, aMainShape);
+
+ GEOM::GEOM_Shape_var aSubShape = Geom->GetIORFromString(SubIOR);
+ TopoDS_Shape subshape = ShapeReader.GetShape(Geom, aSubShape);
+
+ TopExp_Explorer Exp ( shape, subshape.ShapeType() );
+ int index = 1;
+ TopTools_MapOfShape M;
+ while ( Exp.More() ) {
+ if ( M.Add(Exp.Current()) ) {
+ if ( Exp.Current().IsSame(subshape) )
+ return index;
+ index++;
+ }
+ Exp.Next();
+ }
+ return -1;
+}
+
+const char* GeometryGUI_Swig::getShapeTypeString(const char* IOR)
+{
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
+
+ GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(IOR);
+ TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape);
+
+ if( shape.IsNull() ) {
+ return "Null Shape" ;
+ }
+
+ switch (shape.ShapeType() )
+ {
+ case TopAbs_COMPOUND:
+ { return "Compound" ;}
+ case TopAbs_COMPSOLID:
+ { return "Compound Solid" ;}
+ case TopAbs_SOLID:
+ { return "Solid" ;}
+ case TopAbs_SHELL:
+ { return "Shell" ;}
+ case TopAbs_FACE:
+ {
+ BRepAdaptor_Surface surf(TopoDS::Face(shape));
+ if ( surf.GetType() == GeomAbs_Plane ) {
+ return "Plane" ;
+ } else if ( surf.GetType() == GeomAbs_Cylinder ) {
+ return "Cylindrical Face" ;
+ } else if ( surf.GetType() == GeomAbs_Sphere ) {
+ return "Spherical Face" ;
+ } else if ( surf.GetType() == GeomAbs_Torus ) {
+ return "Toroidal Face" ;
+ } else if ( surf.GetType() == GeomAbs_Cone ) {
+ return "Conical Face" ;
+ } else {
+ return "GEOM::FACE" ;
+ }
+ }
+ case TopAbs_WIRE:
+ { return "Wire" ;}
+ case TopAbs_EDGE:
+ {
+ BRepAdaptor_Curve curv(TopoDS::Edge(shape));
+ if ( curv.GetType() == GeomAbs_Line ) {
+ if ( (Abs(curv.FirstParameter()) >= 1E6 ) ||
+ (Abs(curv.LastParameter()) >= 1E6 )) {
+ return "Line" ;
+ } else
+ return "Edge" ;
+ } else if ( curv.GetType() == GeomAbs_Circle ) {
+ if ( curv.IsClosed() )
+ return "Circle" ;
+ else
+ return "Arc" ;
+ } else {
+ return "Edge" ;
+ }
+ }
+ case TopAbs_VERTEX:
+ { return "Vertex" ;}
+ case TopAbs_SHAPE:
+ { return "Shape" ;}
+ }
+}
+
+
+const char* GeometryGUI_Swig::getShapeTypeIcon(const char* IOR)
+{
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
+
+ GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(IOR);
+
+ if( aShape->_is_nil() ) {
+ return "None" ;
+ }
+
+ switch (aShape->ShapeType() )
+ {
+ case TopAbs_COMPOUND:
+ { return "ICON_OBJBROWSER_COMPOUND" ;}
+ case TopAbs_COMPSOLID:
+ { return "ICON_OBJBROWSER_COMPSOLID" ;}
+ case TopAbs_SOLID:
+ { return "ICON_OBJBROWSER_SOLID" ;}
+ case TopAbs_SHELL:
+ { return "ICON_OBJBROWSER_SHELL" ;}
+ case TopAbs_FACE:
+ { return "ICON_OBJBROWSER_FACE" ;}
+ case TopAbs_WIRE:
+ { return "ICON_OBJBROWSER_WIRE" ;}
+ case TopAbs_EDGE:
+ { return "ICON_OBJBROWSER_EDGE" ;}
+ case TopAbs_VERTEX:
+ { return "ICON_OBJBROWSER_VERTEX" ;}
+ }
+ return "None";
+}
+
+void GeometryGUI_Swig::setDisplayMode(const char* Entry, int mode)
+{
+ QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
+ Handle(SALOME_InteractiveObject) IO =
+ myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
+
+ if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
+ VTKViewer_RenderWindowInteractor* myRenderInter =
+ ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+
+ myRenderInter->SwitchRepresentation(IO, mode);
+ myRenderInter->Update();
+ }
+ else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ v3d->SwitchRepresentation(IO, mode);
+ }
+}
+
+void GeometryGUI_Swig::setColor(const char* Entry, int red, int green, int blue)
+{
+ QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
+ QColor c = QColor (red, green, blue);
+ Handle(SALOME_InteractiveObject) IO =
+ myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
+
+ if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
+ VTKViewer_RenderWindowInteractor* myRenderInter =
+ ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ myRenderInter->SetColor(IO,c);
+ myRenderInter->Update();
+ }
+ else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ v3d->SetColor(IO,c);
+ }
+}
+
+void GeometryGUI_Swig::setTransparency(const char* Entry, float transp)
+{
+ QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
+ Handle(SALOME_InteractiveObject) IO =
+ myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
+
+ if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
+ VTKViewer_RenderWindowInteractor* myRenderInter =
+ ((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ myRenderInter->SetTransparency(IO,transp);
+ myRenderInter->Update();
+ }
+ else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
+ {
+ OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
+ v3d->SetTransparency(IO,transp);
+ }
+}
--- /dev/null
+// 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_Swig.hxx
+// Author : Nicolas REJNERI, Paul RASCLE
+// Module : GEOM
+// $Header$
+
+#ifndef _GeometryGUI_SWIG_HXX_
+#define _GeometryGUI_SWIG_HXX_
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+class GEOM_Client;
+
+class GeometryGUI_Swig
+{
+public:
+ GeometryGUI_Swig();
+ ~GeometryGUI_Swig();
+
+ void createAndDisplayGO(const char* Entry);
+ void setDisplayMode(const char* Entry, int mode);
+ void setColor(const char* Entry, int red, int green, int blue);
+ void setTransparency(const char* Entry, float transp);
+
+ int getIndexTopology(const char *SubEntry, const char *Entry);
+ const char* getShapeTypeString(const char *Entry);
+ const char* getShapeTypeIcon(const char *Ior);
+};
+
+
+#endif
--- /dev/null
+// 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_Swig.i
+// Author : Nicolas REJNERI, Paul RASCLE
+// Module : GEOM
+// $Header$
+
+%{
+#include "GeometryGUI_Swig.hxx"
+%}
+
+class GeometryGUI_Swig
+{
+ public:
+ GeometryGUI_Swig();
+ ~GeometryGUI_Swig();
+
+ void createAndDisplayGO(const char* Entry);
+ int getIndexTopology(const char *SubEntry, const char *Entry);
+ const char* getShapeTypeString(const char *Entry);
+
+ void setDisplayMode(const char* Entry, int mode);
+ void setColor(const char* Entry, int red, int green, int blue);
+ void setTransparency(const char* Entry, float transp);
+ const char* getShapeTypeIcon(const char *Ior);
+};
--- /dev/null
+// 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_TorusDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_TorusDlg.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_TorusDlg()
+// purpose : Constructs a GeometryGUI_TorusDlg 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_TorusDlg::GeometryGUI_TorusDlg( 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_TORUS_PV")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_TORUS_DXYZ")));
+
+ if ( !name )
+ setName( "GeometryGUI_TorusDlg" );
+ resize( 303, 219 );
+ setCaption( tr( "GEOM_TORUS_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_TorusDlgLayout = new QGridLayout( this );
+ GeometryGUI_TorusDlgLayout->setSpacing( 6 );
+ GeometryGUI_TorusDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_TORUS" ) );
+ 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, 2 );
+ GeometryGUI_TorusDlgLayout->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_TorusDlgLayout->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 );
+
+ GeometryGUI_TorusDlgLayout->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_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 );
+
+ QSpacerItem* spacer1 = new QSpacerItem( 20, 62, QSizePolicy::Minimum, QSizePolicy::Fixed );
+ GroupC2Layout->addItem( spacer1 );
+ GeometryGUI_TorusDlgLayout->addWidget(GroupC2 , 1, 0 );
+
+ /***************************************************************/
+
+ /* Initialisations */
+ Init(Sel) ;
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_TorusDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_TorusDlg::~GeometryGUI_TorusDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::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 ) ;
+ SpinBox_C1A4->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_Radius1->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+ SpinBox_Radius2->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ;
+
+ GroupC1->show();
+ GroupC2->hide();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ SpinBox_C1A3->SetValue( 300.0 ) ;
+ SpinBox_C1A4->SetValue( 100.0 ) ;
+ SpinBox_Radius1->SetValue( 300.0 ) ;
+ SpinBox_Radius2->SetValue( 100.0 ) ;
+ myRadius1 = 300.0 ;
+ myRadius2 = 100.0 ;
+
+ myOkRadius1 = true ;
+ myOkRadius2 = 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_Radius1, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ;
+ connect( SpinBox_Radius2, 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_TorusDlg::ConstructorsClicked(int constructorId)
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->EraseSimulationShape() ;
+
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ GroupC1->hide();
+ GroupC2->show();
+ myConstructorId = constructorId ;
+ myOkRadius1 = myOkPoint1 = myOkRadius2 = myOkDir = true ;
+
+ SpinBox_C1A3->SetValue( 300.0 ) ; /* radius 1 */
+ SpinBox_C1A4->SetValue( 100.0 ) ; /* radius 2 */
+ myRadius1 = 300.0 ;
+ myRadius2 = 100.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 && myOkRadius1 && myOkRadius2 ) {
+ gp_Dir aDir = myDir ;
+
+ MakeTorusSimulationAndDisplay() ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ GroupC2->hide();
+ GroupC1->show();
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ myOkRadius1 = myOkRadius2 = true ;
+ myOkPoint1 = myOkDir = false ;
+
+ SpinBox_Radius1->SetValue( 300.0 ) ;
+ SpinBox_Radius2->SetValue( 100.0 ) ;
+ myRadius1 = 300.0 ;
+ myRadius2 = 100.0 ;
+
+ LineEditC1A1->setText( tr("") );
+ disconnect( mySelection, 0, this, 0 );
+ break ;
+ }
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::ClickOnApply()
+{
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
+ myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ if(myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
+ myGeomGUI->MakeTorusAndDisplay( myPoint1, myDir, myRadius1, myRadius2 ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::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_TorusDlg::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( myConstructorId == 0 && myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
+ MakeTorusSimulationAndDisplay() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::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_TorusDlg::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_TorusDlg::ValueChangedInSpinBox( double newValue )
+{
+ QObject* send = (QObject*)sender();
+
+ if(send == SpinBox_C1A3 ) {
+ myRadius1 = newValue ;
+ myOkRadius1 = true ;
+ }
+ else if(send == SpinBox_C1A4 ) {
+ myRadius2 = newValue ;
+ myOkRadius2 = true ;
+ }
+ else if(send == SpinBox_Radius1 ) {
+ myRadius1 = newValue ;
+ myOkRadius1 = true ;
+ }
+ else if(send == SpinBox_Radius2 ) {
+ myRadius2 = newValue ;
+ myOkRadius2 = true ;
+ }
+
+ if (myOkPoint1 && myOkDir && myOkRadius1 && myOkRadius2 ) {
+ MakeTorusSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::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_TorusDlg::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_TorusDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeTorusSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_TorusDlg::MakeTorusSimulationAndDisplay()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ try {
+ gp_Ax2 anAxis(this->myPoint1, this->myDir) ;
+ mySimulationTopoDs = BRepPrimAPI_MakeTorus( anAxis, this->myRadius1, this->myRadius2 ).Shape() ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ catch(Standard_Failure) {
+ MESSAGE( "Exception catched in MakeTorusSimulationAndDisplay" ) ;
+ }
+ return ;
+}
+
--- /dev/null
+// 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_TorusDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_TORUS_H
+#define DIALOGBOX_TORUS_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GEOM_EdgeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <TopoDS_Shape.hxx>
+#include <BRepPrimAPI_MakeTorus.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.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 QSpinBox ;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_TorusDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_TorusDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_TorusDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_TorusDlg();
+
+private:
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ void MakeTorusSimulationAndDisplay() ;
+
+ 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 ;
+ bool myOkPoint1 ;
+ bool myOkDir ; /* to check when arguments is defined */
+
+ Standard_Real myRadius1 ;
+ Standard_Real myRadius2 ;
+ bool myOkRadius1 ;
+ bool myOkRadius2 ;
+ QDoubleValidator *myVa ; /* Double validator for numeric input myRadius1 */
+ QDoubleValidator *myVb ; /* Double validator for numeric input myRadius2 */
+
+ 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* GroupC1;
+ QGroupBox* GroupC2;
+ QPushButton* SelectButtonC1A1;
+ QPushButton* SelectButtonC1A2;
+ QLineEdit* LineEditC1A1;
+ QLineEdit* LineEditC1A2;
+
+ GeometryGUI_SpinBox* SpinBox_C1A3 ;
+ GeometryGUI_SpinBox* SpinBox_C1A4 ;
+
+ QLabel* TextLabelC1A1;
+ QLabel* TextLabelC1A2;
+ QLabel* TextLabelC1A3;
+ QLabel* TextLabelC1A4;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+
+ QLabel* TextLabel_Radius1 ;
+ QLabel* TextLabel_Radius2 ;
+ GeometryGUI_SpinBox* SpinBox_Radius1 ;
+ GeometryGUI_SpinBox* SpinBox_Radius2 ;
+
+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_TorusDlgLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+ QGridLayout* GroupC2Layout;
+};
+
+#endif // DIALOGBOX_TORUS_H
--- /dev/null
+// 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_TranslationDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_TranslationDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Config.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 <qvalidator.h>
+#include <qpixmap.h>
+#include <qevent.h>
+
+
+
+//=================================================================================
+// class : GeometryGUI_TranslationDlg()
+// purpose : Constructs a GeometryGUI_TranslationDlg 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_TranslationDlg::GeometryGUI_TranslationDlg( 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_TRANSLATION")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_TranslationDlg" );
+ resize( 303, 219 );
+ setCaption( tr( "GEOM_TRANSLATION_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_TranslationDlgLayout = new QGridLayout( this );
+ GeometryGUI_TranslationDlgLayout->setSpacing( 6 );
+ GeometryGUI_TranslationDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_TRANSLATION" ) );
+ 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_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_TRANSLATION" ) ) ;
+ GroupC1->setMinimumSize( QSize( 0, 0 ) );
+ GroupC1->setFrameShape( QGroupBox::Box );
+ GroupC1->setFrameShadow( QGroupBox::Sunken );
+ GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (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 );
+
+ 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 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+
+ Layout1 = new QHBoxLayout;
+ Layout1->setSpacing( 6 );
+ Layout1->setMargin( 0 );
+
+ TextLabel_DX = new QLabel( GroupC1, "TextLabel_DX" );
+ TextLabel_DX->setText( tr( "GEOM_DX" ) );
+ Layout1->addWidget( TextLabel_DX );
+
+ SpinBox_DX = new GeometryGUI_SpinBox( GroupC1, "SpinBox_DX" );
+ SpinBox_DX->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DX->sizePolicy().hasHeightForWidth() ) );
+ Layout1->addWidget( SpinBox_DX );
+
+ TextLabel_DY = new QLabel( GroupC1, "TextLabel_DY" );
+ TextLabel_DY->setText( tr( "GEOM_DY" ) );
+ Layout1->addWidget( TextLabel_DY );
+
+ SpinBox_DY = new GeometryGUI_SpinBox( GroupC1, "SpinBox_DY" );
+ SpinBox_DY->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DY->sizePolicy().hasHeightForWidth() ) );
+ Layout1->addWidget( SpinBox_DY );
+
+ TextLabel_DZ = new QLabel( GroupC1, "TextLabel_DZ" );
+ TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
+ Layout1->addWidget( TextLabel_DZ );
+
+ SpinBox_DZ = new GeometryGUI_SpinBox( GroupC1, "SpinBox_DZ" );
+ SpinBox_DZ->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, SpinBox_DZ->sizePolicy().hasHeightForWidth() ) );
+ Layout1->addWidget( SpinBox_DZ );
+
+ GroupC1Layout->addMultiCellLayout( Layout1, 1, 1, 0, 2 );
+
+ GeometryGUI_TranslationDlgLayout->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_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+
+//=================================================================================
+// function : ~GeometryGUI_TranslationDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_TranslationDlg::~GeometryGUI_TranslationDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::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_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DX->SetValue( 100.0 ) ;
+ SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DY->SetValue( 100.0 ) ;
+ SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DZ->SetValue( 100.0 ) ;
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myOkBase = false ;
+
+ this->myVec.SetCoord( 100.0, 100.0, 100.0 ) ;
+ mySimulationTopoDs.Nullify() ;
+ myBase.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_ShapeTypeFilter( TopAbs_EDGE, myGeom );
+
+ /* 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( 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( 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 ) ;
+ this->show() ; /* displays Dialog */
+
+ return ;
+}
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_TranslationDlg::ConstructorsClicked(int constructorId)
+{
+ // myGeomGUI->EraseSimulationShape() ;
+ switch (constructorId)
+ {
+ case 0:
+ {
+ break;
+ }
+ case 1:
+ {
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ mySimulationTopoDs.Nullify() ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkBase) {
+ myGeomGUI->MakeTranslationAndDisplay( myGeomShape, myVec ) ;
+ }
+ break ;
+ }
+ case 1 :
+ {
+ break ;
+ }
+ }
+
+ // accept();
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::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_TranslationDlg::SelectionIntoArgument()
+{
+ myEditCurrentArgument->setText("") ;
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Future name of selection */
+ QString aString = "";
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ LineEditC1A1->setText("") ;
+ myOkBase = false ;
+ }
+ return ;
+ }
+
+ /* nbSel == 1 ! */
+ TopoDS_Shape S;
+ Standard_Boolean testResult ;
+ Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
+
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myConstructorId == 0 && myEditCurrentArgument == LineEditC1A1 ) {
+ myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
+ if( !testResult )
+ return ;
+ LineEditC1A1->setText(aString) ;
+ myBase = S ;
+ myOkBase = true ;
+ }
+
+ if( myOkBase ) {
+ MakeTranslationSimulationAndDisplay() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1 ;
+ SelectionIntoArgument() ;
+ }
+ break;
+ }
+ case 1:
+ {
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::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 : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::ValueChangedInSpinBox( double newValue )
+{
+
+ QObject* send = (QObject*)sender() ;
+ Standard_Real Dx, Dy, Dz ;
+
+ if( send == SpinBox_DX ) {
+ Dx = newValue ;
+ Dy = SpinBox_DY->GetValue() ;
+ Dz = SpinBox_DZ->GetValue() ;
+ } else if( send == SpinBox_DY ) {
+ Dx = SpinBox_DX->GetValue() ;
+ Dy = newValue ;
+ Dz = SpinBox_DZ->GetValue() ;
+ } else if( send == SpinBox_DZ ) {
+ Dx = SpinBox_DX->GetValue() ;
+ Dy = SpinBox_DY->GetValue() ;
+ Dz = newValue ;
+ }
+
+ this->myVec.SetCoord(Dx, Dy, Dz) ;
+ if ( myOkBase ) {
+ MakeTranslationSimulationAndDisplay() ;
+ }
+ else {
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::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_TranslationDlg::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_TranslationDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : MakeTranslationSimulationAndDisplay()
+// purpose :
+//=================================================================================
+void GeometryGUI_TranslationDlg::MakeTranslationSimulationAndDisplay()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ gp_Trsf theTransformation ;
+ theTransformation.SetTranslation(this->myVec) ;
+
+ BRepBuilderAPI_Transform myBRepTransformation(this->myBase, theTransformation, Standard_False) ;
+ mySimulationTopoDs = myBRepTransformation.Shape() ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
--- /dev/null
+// 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_TranslationDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_TRANSLATION_H
+#define DIALOGBOX_TRANSLATION_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <gp_Vec.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRepBuilderAPI_Transform.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_TranslationDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_TranslationDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_TranslationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_TranslationDlg();
+
+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 */
+ TopoDS_Shape myBase ;
+ GEOM::GEOM_Shape_var myGeomShape ; /* is myBase */
+ bool myOkBase ;
+ gp_Vec myVec ;
+ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ;
+ void MakeTranslationSimulationAndDisplay() ;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor1;
+ QGroupBox* GroupC1;
+ QLabel* TextLabel_DX;
+ QLabel* TextLabel_DY;
+ QLabel* TextLabel_DZ;
+
+ GeometryGUI_SpinBox* SpinBox_DX ;
+ GeometryGUI_SpinBox* SpinBox_DY ;
+ GeometryGUI_SpinBox* SpinBox_DZ ;
+
+ QLabel* TextLabelC1A1;
+ QPushButton* SelectButtonC1A1;
+ QLineEdit* LineEditC1A1;
+ 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() ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_TranslationDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupC1Layout;
+ QGridLayout* GroupButtonsLayout;
+
+ QHBoxLayout* Layout1 ;
+};
+
+#endif // DIALOGBOX_TRANSLATION_H
--- /dev/null
+// 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_TransparencyDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+
+using namespace std;
+#include "GeometryGUI_TransparencyDlg.h"
+#include "GeometryGUI.h"
+
+#include "QAD_RightFrame.h"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include <qframe.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qapplication.h>
+#include <qgroupbox.h>
+
+#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindowInteractor.h"
+
+//=================================================================================
+// class : GeometryGUI_TransparencyDlg()
+// purpose : Constructs a GeometryGUI_SUBSHAPE which is a child of 'parent', with the
+// name 'name' and widget flags set to 'f'.
+//
+// : WARNING : this dialog is modal !
+//
+//=================================================================================
+GeometryGUI_TransparencyDlg::GeometryGUI_TransparencyDlg( QWidget* parent,
+ const char* name,
+ SALOME_Selection* Sel,
+ const Handle(AIS_InteractiveContext)& ic,
+ bool modal,
+ WFlags fl )
+ : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ if ( !name )
+ setName( "GeometryGUI_TransparencyDlg" );
+ resize( 152, 107 );
+ setCaption( tr( "GEOM_TRANSPARENCY_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_TransparencyDlgLayout = new QGridLayout( this );
+ GeometryGUI_TransparencyDlgLayout->setSpacing( 6 );
+ GeometryGUI_TransparencyDlgLayout->setMargin( 11 );
+
+ /*************************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ buttonOk = new QPushButton( GroupButtons, "buttonOk" );
+ buttonOk->setText( tr( "GEOM_BUT_OK" ) );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 1 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 );
+
+ /*************************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setSpacing( 0 );
+ GroupC1->layout()->setMargin( 0 );
+ QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
+ GroupC1Layout->setAlignment( Qt::AlignTop );
+ GroupC1Layout->setSpacing( 6 );
+ GroupC1Layout->setMargin( 11 );
+
+ TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" );
+ TextLabelOpaque->setText( tr( "GEOM_TRANSPARENCY_OPAQUE" ) );
+ TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) );
+ GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 );
+ GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" );
+ TextLabelTransparent->setText( tr( "GEOM_TRANSPARENCY_TRANSPARENT" ) );
+ TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) );
+ GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 );
+
+ Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" );
+ Slider1->setMinimumSize( 300, 0 );
+ Slider1->setTickmarks( QSlider::Left );
+ GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 );
+ /*************************************************************************/
+
+ GeometryGUI_TransparencyDlgLayout->addWidget( GroupC1, 0, 0 );
+ GeometryGUI_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 );
+
+ /* Initialisations */
+ this->myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ this->myIc = ic ;
+ this->mySel = Sel ;
+
+ /* First call valueChanged() method for initialisation */
+ /* The default value of transparency will change with the selection */
+ this->myFirstInit = true ;
+// Slider1->setMaxValue( 10 );
+// Slider1->setValue( 5 ) ;
+ this->ValueHasChanged( Slider1->value() ) ;
+
+ // signals and slots connections : after ValueHasChanged()
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( Slider1, SIGNAL( valueChanged(int) ), this, SLOT( ValueHasChanged(int) ) );
+
+ /* Move widget on the botton right corner of main widget */
+ int x, y ;
+ myGeomGUI->DefineDlgPosition( this, x, y ) ;
+ this->move( x, y ) ;
+ this->show() ; /* Displays this Dialog */
+}
+
+
+
+
+//=================================================================================
+// function : ~GeometryGUI_TransparencyDlg()
+// purpose :
+//=================================================================================
+GeometryGUI_TransparencyDlg::~GeometryGUI_TransparencyDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=======================================================================
+// function : ClickOnOk()
+// purpose :
+//=======================================================================
+void GeometryGUI_TransparencyDlg::ClickOnOk()
+{
+ accept() ;
+ return ;
+}
+
+
+//=======================================================================
+// function : ClickOnClose()
+// purpose :
+//=======================================================================
+void GeometryGUI_TransparencyDlg::ClickOnClose()
+{
+ accept() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : ValueHasChanged()
+// purpose : Called when value of slider change
+// : or the first time as initilisation
+//=================================================================================
+void GeometryGUI_TransparencyDlg::ValueHasChanged( int newValue )
+{
+
+ if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
+ // VTK
+ // vtkQGLRenderWindowInteractor* myRenderInter= myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
+ VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
+ SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() );
+
+ Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject();
+ if( !FirstIOS.IsNull() ) {
+
+ /* The first time as initialisation */
+ if( this->myFirstInit ) {
+ this->myFirstInit = false ;
+ float transp = ( myRenderInter->GetTransparency(FirstIOS))*10.0 ;
+ this->Slider1->setValue( int(transp) ) ;
+ }
+ }
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ for( ;It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IOS = It.Value();
+ myRenderInter->SetTransparency( IOS, newValue/10.0 );
+ }
+ QApplication::restoreOverrideCursor();
+ }
+
+ else if ( myGeomGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) {
+ // OCC
+ SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() );
+ Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject() ;
+ if( !FirstIOS.IsNull() ) {
+
+ /* The first time as initialisation */
+ if( this->myFirstInit ) {
+ this->myFirstInit = false ;
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(FirstIOS, found);
+ if( !found ) {
+ return ;
+ }
+ float transp = ( int( Shape->Transparency() * 10.0 + 0.001) );
+ this->Slider1->setValue(int(transp) ) ;
+ return ;
+ }
+ }
+
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ for( ;It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+ Standard_Boolean found;
+ Handle(GEOM_AISShape) Shape = myGeomGUI->ConvertIOinGEOMAISShape(IObject, found);
+ if( !found ) {
+ QApplication::restoreOverrideCursor();
+ return ;
+ }
+ this->myIc->SetTransparency( Shape, newValue / 10.0, false );
+ myIc->Redisplay( Shape, Standard_False, Standard_True );
+ }
+ myIc->UpdateCurrentViewer();
+ }
+ QApplication::restoreOverrideCursor();
+ return ;
+}
--- /dev/null
+// 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_TransparencyDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_TRANSPARENCYDLG_H
+#define DIALOGBOX_TRANSPARENCYDLG_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+#include "SALOME_Selection.h"
+#include "SALOME_InteractiveObject.hxx"
+#include "GEOM_InteractiveObject.hxx"
+#include "GEOM_AISShape.hxx"
+
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QFrame;
+class QLabel;
+class QPushButton;
+class QSlider;
+class GeometryGUI;
+
+
+
+//=================================================================================
+// class : GeometryGUI_TransparencyDlg
+// purpose :
+// : WARNING : that is a MODAL dialog.
+//=================================================================================
+class GeometryGUI_TransparencyDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_TransparencyDlg( QWidget* parent = 0,
+ const char* name = 0,
+ SALOME_Selection* Sel = 0,
+ const Handle(AIS_InteractiveContext)& ic = 0,
+ bool modal = TRUE,
+ WFlags fl = 0 );
+
+ ~GeometryGUI_TransparencyDlg();
+
+private :
+
+ GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
+ bool myFirstInit ; /* Inform for the first init */
+ SALOME_Selection* mySel; /* User selection */
+ Handle(AIS_InteractiveContext) myIc ; /* Interactive context */
+
+ QPushButton* buttonOk;
+ QLabel* TextLabelOpaque;
+ QLabel* TextLabelTransparent;
+ QSlider* Slider1;
+
+public slots:
+
+ void ClickOnOk();
+ void ClickOnClose();
+ void ValueHasChanged( int newValue ) ;
+
+protected:
+ QGridLayout* GeometryGUI_TransparencyDlgLayout;
+ QHBoxLayout* Layout1;
+ QHBoxLayout* Layout2;
+};
+
+#endif // DIALOGBOX_TRANSPARENCYDLG_H
+
--- /dev/null
+// 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_VectorDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_VectorDlg.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 <qcheckbox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qtoolbutton.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qvalidator.h>
+#include <qevent.h>
+
+
+
+
+//=================================================================================
+// class : GeometryGUI_VectorDlg()
+// purpose : Constructs a GeometryGUI_VectorDlg 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_VectorDlg::GeometryGUI_VectorDlg( 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_VECTOR_2P")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+ QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_VECTOR_DXYZ")));
+
+ if ( !name )
+ setName( "GeometryGUI_VectorDlg" );
+ resize( 303, 221 );
+ setCaption( tr( "GEOM_VECTOR_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_VectorDlgLayout = new QGridLayout( this );
+ GeometryGUI_VectorDlgLayout->setSpacing( 6 );
+ GeometryGUI_VectorDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupPoints = new QGroupBox( this, "GroupPoints" );
+ GroupPoints->setGeometry( QRect( 10, 10, 280, 90 ) );
+ GroupPoints->setTitle( tr( "GEOM_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_VectorDlgLayout->addWidget( GroupPoints, 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_VectorDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_VECTOR" ) );
+ 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->setChecked( TRUE );
+ Constructor1->setPixmap( image0 );
+ 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, 3 );
+ Constructor2 = new QRadioButton( GroupConstructors, "Constructor2" );
+ Constructor2->setText( tr( "" ) );
+ Constructor2->setPixmap( image2 );
+ Constructor2->setMinimumSize( QSize( 50, 0 ) );
+ GroupConstructorsLayout->addWidget( Constructor2, 0, 2 );
+ QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ GroupConstructorsLayout->addItem( spacer_3, 0, 1 );
+ GeometryGUI_VectorDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ GroupCoordinates = new QGroupBox( this, "GroupCoordinates" );
+ GroupCoordinates->setGeometry( QRect( 10, 70, 280, 80 ) );
+ GroupCoordinates->setTitle( tr( "GEOM_COORDINATES" ) );
+ GroupCoordinates->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupCoordinates->sizePolicy().hasHeightForWidth() ) );
+ GroupCoordinates->setColumnLayout(0, Qt::Vertical );
+ GroupCoordinates->layout()->setSpacing( 0 );
+ GroupCoordinates->layout()->setMargin( 0 );
+ GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() );
+ GroupCoordinatesLayout->setAlignment( Qt::AlignTop );
+ GroupCoordinatesLayout->setSpacing( 6 );
+ GroupCoordinatesLayout->setMargin( 11 );
+
+ TextLabel_DZ = new QLabel( GroupCoordinates, "TextLabel_DZ" );
+ TextLabel_DZ->setText( tr( "GEOM_DZ" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_DZ, 0, 4 );
+ TextLabel_DY = new QLabel( GroupCoordinates, "TextLabel_DY" );
+ TextLabel_DY->setText( tr( "GEOM_DY" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_DY, 0, 2 );
+ TextLabel_DX = new QLabel( GroupCoordinates, "TextLabel_DX" );
+ TextLabel_DX->setText( tr( "GEOM_DX" ) );
+ GroupCoordinatesLayout->addWidget( TextLabel_DX, 0, 0 );
+
+ /* Spin boxes construction */
+ SpinBox_DX = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DX" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_DX, 0, 1 );
+ SpinBox_DY = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DY" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_DY, 0, 3 );
+ SpinBox_DZ = new GeometryGUI_SpinBox( GroupCoordinates, "GeomSpinBox_DZ" ) ;
+ GroupCoordinatesLayout->addWidget( SpinBox_DZ, 0, 5 );
+
+ QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
+ GroupCoordinatesLayout->addItem( spacer2, 1, 3 );
+
+ /* QCheckBox to reverse vector */
+ CheckBoxReverseVector = new QCheckBox( GroupCoordinates, "CheckBoxReverseVector" );
+ CheckBoxReverseVector->setText( tr( "GEOM_REVERSE_VECTOR" ) );
+ GroupCoordinatesLayout->addMultiCellWidget( CheckBoxReverseVector, 1, 1, 1, 5 );
+ /* same position than GroupPoints */
+ GeometryGUI_VectorDlgLayout->addWidget( GroupCoordinates, 1, 0 );
+
+ Init(Sel) ; /* Initialisations */
+
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_VectorDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_VectorDlg::~GeometryGUI_VectorDlg()
+{
+ /* no need to delete child widgets, Qt does it all for us */
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::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_DX->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DX->SetValue( 0.0 ) ;
+ SpinBox_DY->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DY->SetValue( 0.0 ) ;
+ SpinBox_DZ->RangeStepAndValidator( -999.999, 999.999, step, 3 ) ;
+ SpinBox_DZ->SetValue( 200.0 ) ;
+
+ GroupPoints->show();
+ GroupCoordinates->hide() ;
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ CheckBoxReverseVector->setChecked( FALSE );
+
+ 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 in 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 );
+ 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( 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( CheckBoxReverseVector, SIGNAL (stateChanged(int) ), this, SLOT( ReverseVector(int) ) ) ;
+
+ 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 : ReverseVector()
+// purpose : 'state' not used here
+//=================================================================================
+void GeometryGUI_VectorDlg::ReverseVector(int state)
+{
+ if( myConstructorId == 1 ) {
+
+ myDx = -myDx ;
+ myDy = -myDy ;
+ myDz = -myDz ;
+
+ SpinBox_DX->SetValue( myDx ) ;
+ SpinBox_DY->SetValue( myDy ) ;
+ SpinBox_DZ->SetValue( myDz ) ;
+
+ myPoint1.SetCoord(0.0, 0.0, 0.0) ;
+ myPoint2.SetCoord(myDx, myDy, myDz) ;
+
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+ /* In the appropriate constructor */
+ if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
+ mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
+ /* Add arrow in simulation */
+ bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose : Radio button management
+//=================================================================================
+void GeometryGUI_VectorDlg::ConstructorsClicked(int constructorId)
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySelection->ClearFilters() ;
+
+ switch (constructorId)
+ {
+ case 0:
+ {
+ GroupPoints->show();
+ GroupCoordinates->hide() ;
+ myConstructorId = constructorId ;
+ myEditCurrentArgument = LineEditPt1 ;
+ Constructor1->setChecked( TRUE );
+ LineEditPt1->setText(tr("")) ;
+ LineEditPt2->setText(tr("")) ;
+ myOkPoint1 = myOkPoint2 = false ;
+
+ /* filter for next selections */
+ mySelection->AddFilter( myVertexFilter );
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ break;
+ }
+ case 1:
+ {
+ GroupPoints->hide();
+ GroupCoordinates->show();
+ myConstructorId = constructorId ;
+ CheckBoxReverseVector->setChecked( FALSE );
+ myOkPoint1 = myOkPoint2 = false ;
+
+ myEditCurrentArgument = SpinBox_DX ;
+ myPoint1.SetCoord( 0.0, 0.0, 0.0 ) ;
+ myDx = 0.0 ;
+ myDy = 0.0 ;
+ myDz = 200.0 ;
+
+ myPoint2.SetCoord( myDx, myDy, myDz ) ;
+ SpinBox_DX->SetValue( myDx ) ;
+ SpinBox_DY->SetValue( myDy ) ;
+ SpinBox_DZ->SetValue( myDz ) ;
+
+ /* filter for next selections */
+ mySelection->AddFilter( myEdgeFilter );
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+
+ if( myPoint1.Distance(myPoint2) > Precision::Confusion() ) {
+ mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
+ /* Add arrow in simulation */
+ bool noNeedToTest = AddArrowToSimulation(mySimulationTopoDs) ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ break;
+ }
+ }
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::ClickOnApply()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ mySimulationTopoDs.Nullify() ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkPoint1 && myOkPoint2)
+ myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
+ break ;
+ }
+ case 1 :
+ {
+ /* Recup args and call method */
+ myDx = SpinBox_DX->GetValue() ;
+ myDy = SpinBox_DY->GetValue() ;
+ myDz = SpinBox_DZ->GetValue() ;
+ myPoint1.SetCoord(0.0, 0.0, 0.0) ;
+ myPoint2.SetCoord(myDx, myDy, myDz) ;
+ myGeomGUI->MakeVectorAndDisplay( myPoint1, myPoint2 ) ;
+ break ;
+ }
+ }
+
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::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_VectorDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ /* Future name of shape */
+ QString aString = "";
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ if ( myEditCurrentArgument == LineEditPt1 ) {
+ LineEditPt1->setText("") ;
+ myOkPoint1 = false ;
+ }
+ else if ( myEditCurrentArgument == LineEditPt2 ) {
+ LineEditPt2->setText("") ;
+ myOkPoint2 = false ;
+ }
+ return ;
+ }
+
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ /* Constructors treatment */
+ if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt1 && myGeomGUI->VertexToPoint(S, myPoint1) ) {
+ LineEditPt1->setText(aString) ;
+ myOkPoint1 = true ;
+ }
+ else if ( myConstructorId == 0 && myEditCurrentArgument == LineEditPt2 && myGeomGUI->VertexToPoint(S, myPoint2) ) {
+ LineEditPt2->setText(aString) ;
+ myOkPoint2 = true ;
+ }
+ else if( myConstructorId == 1) {
+ gp_Pnt P1, P2 ;
+ /* linear edge selection verified */
+ if( myGeomGUI->LinearEdgeExtremities(S, P1, P2) ) {
+
+ myGeomGUI->GetBipointDxDyDz( P1, P2, myDx, myDy, myDz ) ;
+ SpinBox_DX->SetValue( myDx ) ;
+ SpinBox_DY->SetValue( myDy ) ;
+ SpinBox_DZ->SetValue( myDz ) ;
+
+ myPoint1.SetCoord(0.0, 0.0, 0.0) ;
+ myPoint2.SetCoord(myDx, myDy, myDz) ;
+ }
+ }
+
+ Standard_Real d = myPoint1.Distance(myPoint2) ;
+
+ if( ( myConstructorId == 0 && myOkPoint1 && myOkPoint2 && d > Precision::Confusion() ) ||
+ ( myConstructorId == 1 && d > Precision::Confusion() ) ) {
+ mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
+ /* Add arrow in simulation */
+ bool noNeedToTest = AddArrowToSimulation( mySimulationTopoDs ) ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::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;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ValueChangedInSpinBox()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::ValueChangedInSpinBox( double newValue )
+{
+ if(myConstructorId != 1)
+ return ;
+
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ QObject* send = (QObject*)sender() ;
+ if (send == SpinBox_DX) {
+ myDx = newValue ;
+ } else if( send == SpinBox_DY ) {
+ myDy = newValue ;
+ } else if( send == SpinBox_DZ ) {
+ myDz = newValue ;
+ }
+
+ myPoint1.SetCoord(0.0, 0.0, 0.0) ;
+ myPoint2.SetCoord(myDx, myDy, myDz) ;
+
+ if ( myConstructorId == 1 && myPoint1.Distance(myPoint2) > Precision::Confusion() ) { // mySimulationTopoDs
+ mySimulationTopoDs = BRepBuilderAPI_MakeEdge( myPoint1, myPoint2 ).Shape();
+ /* Create simulation vector with an arrow */
+ this->AddArrowToSimulation(mySimulationTopoDs ) ;
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::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. */
+ QLineEdit* LE = (QLineEdit*)myEditCurrentArgument ;
+ const QString objectUserName = LE->text() ;
+ QWidget* thisWidget = (QWidget*)this ;
+ if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
+ LE->setText( objectUserName ) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+
+ GroupConstructors->setEnabled(false) ;
+ GroupCoordinates->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ GroupPoints->setEnabled(false) ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->EraseSimulationShape() ;
+ mySelection->ClearFilters() ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+
+ GroupConstructors->setEnabled(true) ;
+ GroupCoordinates->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ GroupPoints->setEnabled(true) ;
+
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+}
+
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_VectorDlg::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_VectorDlg::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 ;
+}
--- /dev/null
+// 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_VectorDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_VECTOR_H
+#define DIALOGBOX_VECTOR_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+#include "GeometryGUI_SpinBox.h"
+
+#include <gp_Pnt.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRep_Builder.hxx>
+#include <Precision.hxx>
+
+#include <qvariant.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QButtonGroup;
+class QFrame;
+class QCheckBox;
+class QGroupBox;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QToolButton;
+class QLabel;
+class GeometryGUI;
+
+
+//=================================================================================
+// class : GeometryGUI_VectorDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_VectorDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_VectorDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_VectorDlg();
+
+ bool AddArrowToSimulation( TopoDS_Shape& modifiedShape ) ;
+
+private :
+
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent( QEvent* e);
+ void Init( SALOME_Selection* Sel ) ; /* mouse enter the QWidget */
+
+ 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 ;
+ double myDx ;
+ double myDy ;
+ double myDz ;
+ bool myOkPoint1 ; /* Are true when myPoint is defined */
+ bool myOkPoint2 ;
+ QWidget* myEditCurrentArgument; /* Current LineEdit or Spin box */
+ int myConstructorId ; /* Current constructor id = radio button id */
+ Handle(GEOM_ShapeTypeFilter) myVertexFilter; /* Filter selection */
+ Handle(GEOM_ShapeTypeFilter) myEdgeFilter; /* Filter selection */
+
+ QGroupBox* GroupPoints;
+ QPushButton* SelectButtonPt1;
+ QPushButton* SelectButtonPt2;
+ QLabel* TextLabelPt1;
+ QLabel* TextLabelPt2;
+
+ QButtonGroup* GroupConstructors;
+ QRadioButton* Constructor2;
+ QRadioButton* Constructor1;
+
+ QGroupBox* GroupButtons;
+ QPushButton* buttonApply;
+ QPushButton* buttonOk;
+ QPushButton* buttonCancel;
+
+ QLineEdit* LineEditPt1;
+ QLineEdit* LineEditPt2;
+
+ QGroupBox* GroupCoordinates;
+
+ GeometryGUI_SpinBox* SpinBox_DX ;
+ GeometryGUI_SpinBox* SpinBox_DY ;
+ GeometryGUI_SpinBox* SpinBox_DZ ;
+ QLabel* TextLabel_DZ;
+ QLabel* TextLabel_DX;
+ QLabel* TextLabel_DY;
+
+ QCheckBox* CheckBoxReverseVector;
+
+private slots:
+
+ void ConstructorsClicked(int constructorId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnApply();
+ void SetEditCurrentArgument() ;
+ void SelectionIntoArgument() ;
+ void LineEditReturnPressed() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void ReverseVector(int state) ;
+ void ValueChangedInSpinBox( double newValue ) ;
+
+protected:
+
+ QGridLayout* GeometryGUI_VectorDlgLayout;
+ QGridLayout* GroupPointsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupCoordinatesLayout;
+
+};
+
+#endif // DIALOGBOX_VECTOR_H
--- /dev/null
+// 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_WhatisDlg.cxx
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_WhatisDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "utilities.h"
+
+// Open CASCADE Includes
+//#include <BRepTools_ShapeSet.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Iterator.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_WhatisDlg()
+// purpose : Constructs a GeometryGUI_WhatisDlg 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_WhatisDlg::GeometryGUI_WhatisDlg( 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_WHATIS")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_WhatisDlg" );
+ resize( 303, 275 );
+ setCaption( tr( "GEOM_WHATIS_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_WhatisDlgLayout = new QGridLayout( this );
+ GeometryGUI_WhatisDlgLayout->setSpacing( 6 );
+ GeometryGUI_WhatisDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_WHATIS" ) );
+ 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_WhatisDlgLayout->addWidget( GroupConstructors, 0, 0 );
+
+ /***************************************************************/
+ GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" );
+ GroupConstructor1->setTitle( tr( "GEOM_WHATIS_OBJECT" ) );
+ 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 );
+
+ Text = new QTextView(GroupConstructor1);
+ Text->setTextFormat( Qt::PlainText );
+ GroupConstructor1Layout->addMultiCellWidget( Text, 1, 1, 0, 2 );
+
+ GeometryGUI_WhatisDlgLayout->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_WhatisDlgLayout->addWidget( GroupButtons, 2, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+
+//=================================================================================
+// function : ~GeometryGUI_WhatisDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_WhatisDlg::~GeometryGUI_WhatisDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::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_WhatisDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::ClickOnCancel()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ disconnect( mySelection, 0, this, 0 );
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_WhatisDlg::SelectionIntoArgument()
+{
+ myGeomGUI->EraseSimulationShape() ;
+ mySimulationTopoDs.Nullify() ;
+
+ 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 ;
+ }
+
+ /* Try to display of a cone simulation shape to show direction of a linear edge only in OCC viewer */
+ if( myGeomGUI->CreateArrowForLinearEdge( S, mySimulationTopoDs ) ) {
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ }
+ LineEditC1A1->setText(SelectedName) ;
+ this->CalculateWhatis(S) ;
+
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::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_WhatisDlg::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_WhatisDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ disconnect( mySelection, 0, this, 0 );
+ GroupConstructors->setEnabled(false) ;
+ GroupConstructor1->setEnabled(false) ;
+ myGeomGUI->EraseSimulationShape() ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::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() ) );
+ if( !mySimulationTopoDs.IsNull() )
+ myGeomGUI->DisplaySimulationShape( mySimulationTopoDs ) ;
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : CalculateWhatis()
+// purpose :
+//=================================================================================
+void GeometryGUI_WhatisDlg::CalculateWhatis(const TopoDS_Shape& S)
+{
+
+ if( S.IsNull() )
+ return ;
+
+ TCollection_AsciiString Astr;
+ Astr = Astr + " Number of shapes in " + strdup(SelectedName.latin1()) + ": \n";
+
+ try {
+ // BRepTools_ShapeSet BS;
+ // BS.Add(S);
+ // BS.DumpExtent(Astr);
+
+ int iType, nbTypes [TopAbs_SHAPE];
+ for (iType = 0; iType < TopAbs_SHAPE; ++iType)
+ nbTypes[ iType ] = 0;
+ nbTypes[ S.ShapeType() ]++;
+
+ TopTools_MapOfShape aMapOfShape;
+ aMapOfShape.Add( S );
+ TopTools_ListOfShape aListOfShape;
+ aListOfShape.Append( S );
+
+ TopTools_ListIteratorOfListOfShape itL(aListOfShape);
+ for (; itL.More(); itL.Next())
+ {
+ TopoDS_Iterator it(itL.Value());
+ for (; it.More(); it.Next())
+ {
+ TopoDS_Shape s = it.Value();
+ if (aMapOfShape.Add( s ))
+ {
+ aListOfShape.Append( s );
+ nbTypes[ s.ShapeType() ] ++;
+ }
+ }
+ }
+
+ Astr = Astr + " VERTEX : " + TCollection_AsciiString(nbTypes[ TopAbs_VERTEX ]) + "\n";
+ Astr = Astr + " EDGE : " + TCollection_AsciiString(nbTypes[ TopAbs_EDGE ]) + "\n";
+ Astr = Astr + " WIRE : " + TCollection_AsciiString(nbTypes[ TopAbs_WIRE ]) + "\n";
+ Astr = Astr + " FACE : " + TCollection_AsciiString(nbTypes[ TopAbs_FACE ]) + "\n";
+ Astr = Astr + " SHELL : " + TCollection_AsciiString(nbTypes[ TopAbs_SHELL ]) + "\n";
+ Astr = Astr + " SOLID : " + TCollection_AsciiString(nbTypes[ TopAbs_SOLID ]) + "\n";
+ Astr = Astr + " COMPSOLID : " + TCollection_AsciiString(nbTypes[ TopAbs_COMPSOLID ]) + "\n";
+ Astr = Astr + " COMPOUND : " + TCollection_AsciiString(nbTypes[ TopAbs_COMPOUND ]) + "\n";
+ Astr = Astr + " SHAPE : " + TCollection_AsciiString(aMapOfShape.Extent()) + "\n";
+
+ Text->setText( Astr.ToCString() );
+ }
+ catch(Standard_Failure) {
+ MESSAGE("Catch intercepted in CalculateWhatis()" << endl ) ;
+ }
+ return ;
+}
--- /dev/null
+// 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_WhatisDlg.h
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_WHATIS_H
+#define DIALOGBOX_WHATIS_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_ShapeTypeFilter.hxx"
+
+#include <TopoDS_Shape.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 : DialogBox_PROPERTIES
+// purpose :
+//=================================================================================
+class GeometryGUI_WhatisDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_WhatisDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_WhatisDlg();
+
+private:
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+ void CalculateWhatis(const TopoDS_Shape& S) ;
+
+ 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 */
+
+ 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_WhatisDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupConstructor1Layout;
+ QGridLayout* GroupButtonsLayout;
+};
+
+#endif // DIALOGBOX_WHATIS_H
--- /dev/null
+// 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_WireDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_WireDlg.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_WireDlg()
+// purpose : Constructs a GeometryGUI_WireDlg 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_WireDlg::GeometryGUI_WireDlg( 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_WIRE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_WireDlg" );
+ resize( 303, 185 );
+ setCaption( tr( "GEOM_WIRE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_WireDlgLayout = new QGridLayout( this );
+ GeometryGUI_WireDlgLayout->setSpacing( 6 );
+ GeometryGUI_WireDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_WIRE" ) );
+ 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_WireDlgLayout->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_WireDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_WIRE_CONNECT" ) );
+ 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( image1 );
+ SelectButtonC1A1->setToggleButton( FALSE );
+ GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 );
+ LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
+ GroupC1Layout->addWidget( LineEditC1A1, 0, 2 );
+ GeometryGUI_WireDlgLayout->addWidget( GroupC1, 1, 0 );
+
+ Init(Sel) ; /* Initialisations */
+}
+
+//=================================================================================
+// function : ~GeometryGUI_WireDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_WireDlg::~GeometryGUI_WireDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::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( 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( 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_WireDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::ClickOnApply()
+{
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkListShapes) {
+ myGeomGUI->MakeWireAndDisplay( myListShapes ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::ClickOnCancel()
+{
+ myGeomGUI->ResetState() ;
+ reject() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void GeometryGUI_WireDlg::SelectionIntoArgument()
+{
+ /* All this for first constructor */
+ // if(myEditCurrentArgument == LineEditC1A1 )
+
+ myEditCurrentArgument->setText("") ;
+ myOkListShapes = false;
+ QString aString = ""; /* Future name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if(nbSel < 1)
+ return ;
+
+ myGeomGUI->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes) ;
+ myEditCurrentArgument->setText(aString) ;
+ myOkListShapes = true ;
+ /* no simulation */
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::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_WireDlg::LineEditReturnPressed()
+{
+ return ;
+}
+
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::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_WireDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_WireDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
+
+
--- /dev/null
+// 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_WireDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef DIALOGBOX_WIRE_H
+#define DIALOGBOX_WIRE_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_WireDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_WireDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_WireDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_WireDlg();
+
+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_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_WireDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_WIRE_H
--- /dev/null
+// 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_WorkingPlaneDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+
+using namespace std;
+#include "GeometryGUI_WorkingPlaneDlg.h"
+
+#include "GeometryGUI.h"
+#include "QAD_Application.h"
+#include "QAD_Desktop.h"
+#include "utilities.h"
+
+#include <BRepAdaptor_Surface.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Ax1.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_WorkingPlaneDlg()
+// purpose : Constructs a GeometryGUI_WorkingPlaneDlg 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_WorkingPlaneDlg::GeometryGUI_WorkingPlaneDlg( 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_WPLANE_FACE")));
+ QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
+
+ if ( !name )
+ setName( "GeometryGUI_WorkingPlaneDlg" );
+ resize( 303, 185 );
+ setCaption( tr( "GEOM_WPLANE_TITLE" ) );
+ setSizeGripEnabled( TRUE );
+ GeometryGUI_WorkingPlaneDlgLayout = new QGridLayout( this );
+ GeometryGUI_WorkingPlaneDlgLayout->setSpacing( 6 );
+ GeometryGUI_WorkingPlaneDlgLayout->setMargin( 11 );
+
+ /***************************************************************/
+ GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
+ GroupConstructors->setTitle( tr( "GEOM_WPLANE" ) );
+ 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_WorkingPlaneDlgLayout->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_WorkingPlaneDlgLayout->addWidget( GroupButtons, 2, 0 );
+
+ /***************************************************************/
+ GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setTitle( tr( "GEOM_WPLANE_FACE" ) );
+ 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_SELECTION" ) );
+ 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 );
+ GeometryGUI_WorkingPlaneDlgLayout->addWidget( GroupC1, 1, 0 );
+ /***************************************************************/
+
+ Init(Sel) ; /* Initialisations */
+}
+
+//=================================================================================
+// function : ~GeometryGUI_WorkingPlaneDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+GeometryGUI_WorkingPlaneDlg::~GeometryGUI_WorkingPlaneDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::Init( SALOME_Selection* Sel )
+{
+
+ GroupC1->show();
+ myConstructorId = 0 ;
+ Constructor1->setChecked( TRUE );
+ myEditCurrentArgument = LineEditC1A1 ;
+ mySelection = Sel;
+ this->myOkPlane = false ;
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+ myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
+
+ // TODO : previous selection into argument ?
+
+ Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
+ myGeom = GEOM::GEOM_Gen::_narrow(comp);
+ /* Filter definition */
+ myFaceFilter = new GEOM_FaceFilter( StdSelect_Plane, myGeom );
+ mySelection->AddFilter( myFaceFilter ); /* 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) ), SLOT( ConstructorsClicked(int) ) );
+
+ connect( LineEditC1A1, SIGNAL ( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
+
+ 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_WorkingPlaneDlg::ConstructorsClicked(int constructorId)
+{
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::ClickOnOk()
+{
+ this->ClickOnApply() ;
+ this->ClickOnCancel() ;
+
+ return ;
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::ClickOnApply()
+{
+ mySelection->ClearFilters() ;
+ myGeomGUI->GetDesktop()->putInfo( tr("") ) ;
+ switch(myConstructorId)
+ {
+ case 0 :
+ {
+ if(myOkPlane) {
+ myGeomGUI->MakeWorkingPlane( this->myLoc, this->myDir ) ;
+ }
+ break ;
+ }
+ }
+ // accept();
+ return ;
+}
+
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::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_WorkingPlaneDlg::SelectionIntoArgument()
+{
+ /* All this for first constructor */
+ // if(myEditCurrentArgument == LineEditC1A1 )
+
+ myEditCurrentArgument->setText("") ;
+ QString aString = ""; /* future the name of selection */
+
+ int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
+ if ( nbSel != 1 ) {
+ switch (myConstructorId)
+ {
+ case 0:
+ {
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ myOkPlane = false ;
+ }
+ break ;
+ }
+ }
+ return ;
+ }
+
+ /* nbSel == 1 */
+ TopoDS_Shape S;
+ if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
+ return ;
+
+ if ( myEditCurrentArgument == LineEditC1A1 ) {
+ BRepAdaptor_Surface surf(TopoDS::Face(S));
+ gp_Pln Plane = surf.Plane();
+ myLoc = Plane.Location();
+ myDir = Plane.Axis().Direction();
+
+ LineEditC1A1->setText(aString) ;
+ myOkPlane = true ;
+ }
+
+ /* no simulation */
+ return ;
+}
+
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::SetEditCurrentArgument()
+{
+ QPushButton* send = (QPushButton*)sender();
+ switch (myConstructorId)
+ {
+ case 0: /* default constructor */
+ {
+ if(send == SelectButtonC1A1) {
+ LineEditC1A1->setFocus() ;
+ myEditCurrentArgument = LineEditC1A1;
+ }
+ mySelection->AddFilter(myFaceFilter) ;
+ SelectionIntoArgument() ;
+ break;
+ }
+ }
+ return ;
+}
+
+
+
+//=================================================================================
+// function : LineEditReturnPressed()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::LineEditReturnPressed()
+{
+ QLineEdit* send = (QLineEdit*)sender();
+ if( send == LineEditC1A1 )
+ myEditCurrentArgument = LineEditC1A1 ;
+ 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_WorkingPlaneDlg::DeactivateActiveDialog()
+{
+ if ( GroupConstructors->isEnabled() ) {
+ mySelection->ClearFilters() ;
+ disconnect( mySelection, 0, this, 0 );
+ GroupConstructors->setEnabled(false) ;
+ GroupC1->setEnabled(false) ;
+ GroupButtons->setEnabled(false) ;
+ }
+ return ;
+}
+
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
+ myGeomGUI->EmitSignalDeactivateDialog() ;
+ GroupConstructors->setEnabled(true) ;
+ GroupC1->setEnabled(true) ;
+ GroupButtons->setEnabled(true) ;
+ return ;
+}
+
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::enterEvent(QEvent* e)
+{
+ if ( GroupConstructors->isEnabled() )
+ return ;
+ ActivateThisDialog() ;
+ return ;
+}
+
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void GeometryGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e )
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel() ;
+ return ;
+}
--- /dev/null
+// 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_WorkingPlaneDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+
+#ifndef DIALOGBOX_WORKINGPLANE_H
+#define DIALOGBOX_WORKINGPLANE_H
+
+#include "SALOME_Selection.h"
+#include "GEOM_FaceFilter.hxx"
+
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <gp_Pnt.hxx>
+#include <TopoDS_Shape.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_WorkingPlaneDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_WorkingPlaneDlg : public QDialog
+{
+ Q_OBJECT
+public:
+ GeometryGUI_WorkingPlaneDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~GeometryGUI_WorkingPlaneDlg();
+
+private:
+
+ void Init( SALOME_Selection* Sel ) ;
+ void closeEvent( QCloseEvent* e ) ;
+ void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
+
+ Handle(GEOM_FaceFilter) myFaceFilter; /* filter for selection */
+ GEOM::GEOM_Gen_var myGeom ; /* Current GeomI object */
+ GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
+ SALOME_Selection* mySelection ; /* User shape selection */
+
+ gp_Pnt myLoc;
+ gp_Dir myDir;
+ bool myOkPlane ; /* to check when arguments are 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_WorkingPlaneDlgLayout;
+ QGridLayout* GroupConstructorsLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupC1Layout;
+};
+
+#endif // DIALOGBOX_WORKINGPLANE_H
--- /dev/null
+// 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_aParameterDlg.cxx
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GeometryGUI_aParameterDlg.h"
+#include "GeometryGUI.h"
+#include "QAD_SpinBoxDbl.h"
+#include "QAD_Tools.h"
+
+#include <stdio.h>
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qvalidator.h>
+
+//======================================================================================
+// function : GeometryGUI_aParameterDlg()
+// purpose : Constructs a GeometryGUI_aParametertDlg which is a child of 'parent', with the
+// name 'name' and widget flags set to 'f'
+//
+// avalue1 : is a float or integer used as default value in edit line
+// aTitle1 : is the prompt for aValue1
+// aTitle : is the title for the user in dialog box
+//
+// bottom : the minimal value to be entered
+// top : the maximum value to be entered
+// decimals : number of decimals to be entered
+//
+// The dialog will by default be modeless, unless you set 'modal' to
+// TRUE to construct a modal dialog.
+//
+//======================================================================================
+GeometryGUI_aParameterDlg::GeometryGUI_aParameterDlg( const char *aValue1,
+ const char *aTitle1,
+ QWidget* parent,
+ const char* name,
+ bool modal,
+ WFlags fl,
+ const double bottom,
+ const double top,
+ const int decimals )
+ : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ if ( !name )
+ setName( "MyParameterDialog" );
+ resize( 288, 81 );
+ setCaption( name ); /* appears on the title bar */
+ setSizeGripEnabled( TRUE );
+
+ QGridLayout* topLayout = new QGridLayout( this );
+ topLayout->setSpacing( 6 );
+ topLayout->setMargin( 11 );
+
+ QGroupBox* mainGrp = new QGroupBox( this, "mainGrp" );
+ mainGrp->setColumnLayout(0, Qt::Vertical );
+ mainGrp->layout()->setSpacing( 0 );
+ mainGrp->layout()->setMargin( 0 );
+ QGridLayout* mainGrpLayout = new QGridLayout( mainGrp->layout() );
+ mainGrpLayout->setAlignment( Qt::AlignTop );
+ mainGrpLayout ->setSpacing( 6 );
+ mainGrpLayout->setMargin( 11 );
+ topLayout->addWidget( mainGrp, 0, 0 );
+
+ /* aTitle1 : text prompt on left of edit line */
+ QLabel* TextLabel1 = new QLabel( mainGrp, "TextLabel1" );
+ TextLabel1->setText( tr( aTitle1 ) );
+ mainGrpLayout->addWidget( TextLabel1, 0, 0 );
+
+ mySpinBox = new QAD_SpinBoxDbl( mainGrp, "mySpinBox" );
+ mySpinBox->setPrecision( 12);
+ mySpinBox->setRange( bottom, top );
+ (( QDoubleValidator* )(mySpinBox->validator()))->setRange(bottom, top, decimals);
+ mySpinBox->setValue(QString(aValue1).toDouble());
+ mainGrpLayout->addWidget( mySpinBox, 0, 1 );
+
+ QGroupBox* btnGrp = new QGroupBox( this, "btnGrp" );
+ btnGrp->setColumnLayout(0, Qt::Vertical );
+ btnGrp->layout()->setSpacing( 0 );
+ btnGrp->layout()->setMargin( 0 );
+ QGridLayout* btnGrpLayout = new QGridLayout( btnGrp->layout() );
+ btnGrpLayout->setAlignment( Qt::AlignTop );
+ btnGrpLayout->setSpacing( 6 );
+ btnGrpLayout->setMargin( 11 );
+ topLayout->addWidget( btnGrp, 1, 0 );
+
+ /* Ok button */
+ myButtonOk = new QPushButton( btnGrp, "buttonOk" );
+ myButtonOk->setText( tr("GEOM_BUT_OK") );
+ myButtonOk->setAutoDefault( TRUE );
+ myButtonOk->setDefault( TRUE );
+ btnGrpLayout->addWidget( myButtonOk, 0, 0 );
+
+ btnGrpLayout->addItem( new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
+
+ /* Cancel button */
+ myButtonCancel = new QPushButton( btnGrp, "buttonCancel" );
+ myButtonCancel->setText( tr("GEOM_BUT_CANCEL") );
+ myButtonCancel->setAutoDefault( TRUE );
+ btnGrpLayout->addWidget( myButtonCancel, 0, 2 );
+
+ /* signals and slots connections */
+ connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ /* Retrieve GeomGUI */
+ myGeomGUI = GeometryGUI::GetGeometryGUI() ;
+
+ /* Move widget on the botton right corner of main widget */
+ QAD_Tools::centerWidget(this, parent);
+}
+
+
+//======================================================================================
+// function : ~GeometryGUI_aParameterDlg() destructor
+// purpose : Destroys the object and frees any allocated resources
+//======================================================================================
+GeometryGUI_aParameterDlg::~GeometryGUI_aParameterDlg()
+{ // no need to delete child widgets, Qt does it all for us
+}
+
+//======================================================================================
+// function : GeometryGUI_aParameterDlg::setValue
+// purpose : sets value
+//======================================================================================
+void GeometryGUI_aParameterDlg::setValue( double val )
+{
+ mySpinBox->setValue( val );
+}
+
+//======================================================================================
+// function : GeometryGUI_aParameterDlg::getValue
+// purpose : gets value
+//======================================================================================
+double GeometryGUI_aParameterDlg::getValue()
+{
+ return mySpinBox->value();
+}
+
--- /dev/null
+// 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_aParameterDlg.h
+// Author : Lucien PIGNOLONI
+// Module : GEOM
+// $Header$
+
+#ifndef GeometryGUI_aParameterDLG_H
+#define GeometryGUI_aParameterDLG_H
+
+#include <qdialog.h>
+
+class QPushButton;
+class GeometryGUI;
+class QAD_SpinBoxDbl;
+
+//=================================================================================
+// class : GeometryGUI_aParameterDlg
+// purpose :
+//=================================================================================
+class GeometryGUI_aParameterDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ GeometryGUI_aParameterDlg( const char* aValue1 = "25",
+ const char* aTitle1 = "Value :",
+ QWidget* parent = 0,
+ const char* name = 0,
+ bool modal = FALSE,
+ WFlags fl = 0,
+ const double bottom = -1E6,
+ const double top = +1E6,
+ const int decimals = 6 ) ;
+
+ ~GeometryGUI_aParameterDlg();
+
+ void setValue( double val );
+ double getValue();
+
+private:
+ GeometryGUI* myGeomGUI ; /* Current GeomGUI object */
+
+ QPushButton* myButtonOk;
+ QPushButton* myButtonCancel;
+ QAD_SpinBoxDbl* mySpinBox;
+
+};
+
+#endif // GeometryGUI_aParameterDlg.h
--- /dev/null
+# 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_icons.po
+# Module : GEOM
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2001-06-14 09:11:49 PM CEST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+#Select
+msgid "ICON_SELECT"
+msgstr "select1.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_Geometry"
+msgstr "geometry.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_COMPOUND"
+msgstr "tree_compound.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_COMPSOLID"
+msgstr "tree_compsolid.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_EDGE"
+msgstr "tree_edge.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_FACE"
+msgstr "tree_face.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_SHAPE"
+msgstr "tree_shape.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_SHELL"
+msgstr "tree_shell.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_SOLID"
+msgstr "tree_solid.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_VERTEX"
+msgstr "tree_vertex.png"
+
+#: QAD_ObjectBrowser.cxx:140
+msgid "ICON_OBJBROWSER_WIRE"
+msgstr "tree_wire.png"
+
+#BoxDlg
+msgid "ICON_DLG_BOX_2P"
+msgstr "box2points.png"
+
+#BoxDlg
+msgid "ICON_DLG_BOX_DXYZ"
+msgstr "boxdxyz.png"
+
+#CylinderDlg
+msgid "ICON_DLG_CYLINDER_PV"
+msgstr "cylinderpointvector.png"
+
+#CylinderDlg
+msgid "ICON_DLG_CYLINDER_DXYZ"
+msgstr "cylinderdxyz.png"
+
+#SphereDlg
+msgid "ICON_DLG_SPHERE_P"
+msgstr "spherepoint.png"
+
+#SphereDlg
+msgid "ICON_DLG_SPHERE_DXYZ"
+msgstr "spheredxyz.png"
+
+#torusDlg
+msgid "ICON_DLG_TORUS_PV"
+msgstr "toruspointvector.png"
+
+#ConeDlg
+msgid "ICON_DLG_CONE_PV"
+msgstr "conepointvector.png"
+
+#torusDlg
+msgid "ICON_DLG_TORUS_DXYZ"
+msgstr "torusdxyz.png"
+
+#ConeDlg
+msgid "ICON_DLG_CONE_DXYZ"
+msgstr "conedxyz.png"
+
+#LineDlg
+msgid "ICON_DLG_LINE_2P"
+msgstr "line2points.png"
+
+#LineDlg
+msgid "ICON_DLG_LINE_EDGE"
+msgstr "lineedge.png"
+
+#LineDlg
+msgid "ICON_DLG_LINE_PV"
+msgstr "linepointvector.png"
+
+#CircleDlg
+msgid "ICON_DLG_CIRCLE_PV"
+msgstr "circlepointvector.png"
+
+#VectorDlg
+msgid "ICON_DLG_VECTOR_2P"
+msgstr "vector2points.png"
+
+#vectorDlg
+msgid "ICON_DLG_VECTOR_DXYZ"
+msgstr "vectordxyz.png"
+
+#PlaneDlg
+msgid "ICON_DLG_PLANE_DXYZ"
+msgstr "planedxyz.png"
+
+#PlaneDlg
+msgid "ICON_DLG_PLANE_FACE"
+msgstr "planeface.png"
+
+#PlaneDlg
+msgid "ICON_DLG_PLANE_PV"
+msgstr "planepointvector.png"
+
+#WorkingPlaneDlg
+msgid "ICON_DLG_WPLANE_FACE"
+msgstr "planeworkingface.png"
+
+#PointDlg
+msgid "ICON_DLG_POINT"
+msgstr "point2.png"
+
+#PoinDlg
+msgid "ICON_DLG_POINT_EDGE"
+msgstr "pointonedge.png"
+
+#ArcDlg
+msgid "ICON_DLG_ARC"
+msgstr "arc.png"
+
+#ArchimedeDlg
+msgid "ICON_DLG_ARCHIMEDE"
+msgstr "archimede.png"
+
+#PartitionDlg
+msgid "ICON_DLG_PARTITION"
+msgstr "partition.png"
+
+#PartitionDlg
+msgid "ICON_DLG_PARTITION_KEEP_FACES"
+msgstr "partitionkeep.png"
+
+#CenterMassDlg
+msgid "ICON_DLG_CENTERMASS"
+msgstr "centergravity.png"
+
+#BoundingBoxDlg
+msgid "ICON_DLG_BOUNDING_BOX"
+msgstr "bounding.png"
+
+#CommonDlg
+msgid "ICON_DLG_COMMON"
+msgstr "common.png"
+
+#CompoundDlg
+msgid "ICON_DLG_BUILD_COMPOUND"
+msgstr "build_compound.png"
+
+#CutDlg
+msgid "ICON_DLG_CUT"
+msgstr "cut.png"
+
+#EdgeDlg
+msgid "ICON_DLG_BUILD_EDGE"
+msgstr "build_edge.png"
+
+#FaceDlg
+msgid "ICON_DLG_BUILD_FACE"
+msgstr "build_face.png"
+
+#ShellDlg
+msgid "ICON_DLG_BUILD_SHELL"
+msgstr "build_shell.png"
+
+#WireDlg
+msgid "ICON_DLG_BUILD_WIRE"
+msgstr "build_wire.png"
+
+#FillingDlg
+msgid "ICON_DLG_FILLING"
+msgstr "filling.png"
+
+#FuseDlg
+msgid "ICON_DLG_FUSE"
+msgstr "fuse.png"
+
+#InertiaDlg
+msgid "ICON_DLG_INERTIA"
+msgstr "axisinertia.png"
+
+#ToleranceDlg
+msgid "ICON_DLG_TOLERANCE"
+msgstr "tolerance.png"
+
+#BasicPropertiesDlg
+msgid "ICON_DLG_BASICPROPERTIES"
+msgstr "basicproperties.png"
+
+#WhatisDlg
+msgid "ICON_DLG_WHATIS"
+msgstr "whatis.png"
+
+#MinDistDlg
+msgid "ICON_DLG_MINDIST"
+msgstr "mindist.png"
+
+#MirrorDlg
+msgid "ICON_DLG_MIRROR"
+msgstr "mirrorPlane.png"
+
+#TranslationDlg
+msgid "ICON_DLG_TRANSLATION"
+msgstr "translation.png"
+
+#RotationDlg
+msgid "ICON_DLG_ROTATION"
+msgstr "rotate.png"
+
+#ScaleDlg
+msgid "ICON_DLG_SCALE"
+msgstr "scale.png"
+
+#OrientationDlg
+msgid "ICON_DLG_ORIENTATION"
+msgstr "orientation.png"
+
+#SewingDlg
+msgid "ICON_DLG_SEWING"
+msgstr "sewing.png"
+
+#PipeDlg
+msgid "ICON_DLG_PIPE"
+msgstr "pipe.png"
+
+#PrismDlg
+msgid "ICON_DLG_PRISM"
+msgstr "prism.png"
+
+#RevolutionDlg
+msgid "ICON_DLG_REVOL"
+msgstr "revol.png"
+
+#SectionDlg
+msgid "ICON_DLG_SECTION"
+msgstr "section.png"
+
+#SubShapeDlg
+msgid "ICON_DLG_SUBSHAPE"
+msgstr "subshape.png"
+
+#FilletDlg
+msgid "ICON_DLG_FILLET"
+msgstr "fillet.png"
+
+#ChamferDlg
+msgid "ICON_DLG_CHAMFER"
+msgstr "chamfer.png"
+
+#FilletDlg
+msgid "ICON_DLG_FILLET_ALL"
+msgstr "filletall.png"
+
+#ChamferDlg
+msgid "ICON_DLG_CHAMFER_ALL"
+msgstr "chamferall.png"
+
+#FilletDlg
+msgid "ICON_DLG_FILLET_EDGE"
+msgstr "filletedge.png"
+
+#ChamferDlg
+msgid "ICON_DLG_CHAMFER_EDGE"
+msgstr "chamferedge.png"
+
+#FilletDlg
+msgid "ICON_DLG_FILLET_FACE"
+msgstr "filletface.png"
+
+#ChamferDlg
+msgid "ICON_DLG_CHAMFER_FACE"
+msgstr "chamferface.png"
+
+#ChamferDlg
+msgid "ICON_DLG_CHECKSHAPE"
+msgstr "check.png"
+
+#SupressFaceDlg
+msgid "ICON_DLG_SUPRESS_FACE"
+msgstr "supressface.png"
+
+#SupressHoleDlg
+msgid "ICON_DLG_SUPRESS_HOLE"
+msgstr "supresshole.png"
+
+#SupressHoleDlg
+msgid "ICON_DLG_SUPRESS_HOLE_FACE_SHELL"
+msgstr "supressHolesOnFaceShell.png"
+
+#MultiTranslationDlg
+msgid "ICON_DLG_MULTITRANSLATION_SIMPLE"
+msgstr "multitranslationsimple.png"
+
+#MultiTranslationDlg
+msgid "ICON_DLG_MULTITRANSLATION"
+msgstr "multitranslation.png"
+
+#MultiTranslationDlg
+msgid "ICON_DLG_MULTITRANSLATION_DOUBLE"
+msgstr "multitranslationdouble.png"
+
+#MultiRotationDlg
+msgid "ICON_DLG_MULTIROTATION_SIMPLE"
+msgstr "multirotationsimple.png"
+
+#MultiRotationDlg
+msgid "ICON_DLG_MULTIROTATION"
+msgstr "multirotation.png"
+
+#MultiRotationDlg
+msgid "ICON_DLG_MULTIROTATION_DOUBLE"
+msgstr "multirotationdouble.png"
+
+
+
--- /dev/null
+# 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_msg_en.po
+# Module : GEOM
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+#
+#==============================================================================
+#
+
+#Button Apply
+msgid "GEOM_BUT_APPLY"
+msgstr "&Apply"
+
+#Button Close
+msgid "GEOM_BUT_CLOSE"
+msgstr "&Close"
+
+#Button Cancel
+msgid "GEOM_BUT_CANCEL"
+msgstr "&Cancel"
+
+#Button Ok
+msgid "GEOM_BUT_OK"
+msgstr "&Ok"
+
+#Button Yes
+msgid "GEOM_BUT_YES"
+msgstr "&Yes"
+
+#Button No
+msgid "GEOM_BUT_NO"
+msgstr "&No"
+
+#Button Help
+msgid "GEOM_BUT_HELP"
+msgstr "&Help"
+
+#Button Explode
+msgid "GEOM_BUT_EXPLODE"
+msgstr "&Explode"
+
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:563
+msgid "GEOM_INF_LOADED"
+msgstr "File %1 loaded."
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:3069
+msgid "GEOM_PRP_COMMAND"
+msgstr "No command associated with this id = %1."
+
+#: GeometryGUI.cxx:4977
+msgid "GEOM_PRP_ABORT"
+msgstr "Operation aborted"
+
+#: GeometryGUI.cxx:5058
+msgid "GEOM_PRP_DONE"
+msgstr "Operation done"
+
+#: GeometryGUI.cxx:3717
+msgid "GEOM_PRP_LOADING"
+msgstr "Loading %1 ..."
+
+#: GeometryGUI.cxx:1412
+msgid "GEOM_PRP_NULLSHAPE"
+msgstr "Error, null or inappropriate shape !"
+
+#: GeometryGUI.cxx:5072
+msgid "GEOM_PRP_READY"
+msgstr "Ready"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_SUBSHAPES"
+msgstr "Select Sub Shapes"
+
+msgid "GEOM_CONFIRM"
+msgstr "Confirm operation"
+
+msgid "GEOM_CONFIRM_INFO"
+msgstr "Shape contains %1 sub shapes !"
+
+
+msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER"
+msgstr "Not allowed in VTK viewer"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SHAPE_IN_STUDY"
+msgstr "Main shape must be in the study before"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_EDGE"
+msgstr "Select edges and click on Apply"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_FACE"
+msgstr "Select faces to suppress and click on Ok/Apply"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_FIRST"
+msgstr "Select main shape first"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_MIN_DIST"
+msgstr "Min Distance not computed"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:3698
+msgid "GEOM_MEN_ALL_FILES"
+msgstr "All Files ( * )"
+
+#: GeometryGUI.cxx:4389
+msgid "GEOM_MEN_ANGLE"
+msgstr "Angle :"
+
+#: GeometryGUI.cxx:3941
+msgid "GEOM_MEN_COMPONENT"
+msgstr "Geometry"
+
+#: GeometryGUI.cxx:4389
+msgid "GEOM_MEN_ENTER_ANGLE"
+msgstr "Enter An Angle In Degrees"
+
+#: GeometryGUI.cxx:3758
+msgid "GEOM_MEN_EXPORT"
+msgstr "Export"
+
+#: GeometryGUI.cxx:3648
+msgid "GEOM_MEN_IMPORT"
+msgstr "Import"
+
+#: GeometryGUI.cxx:3761
+msgid "GEOM_MEN_IMPORT_BREP"
+msgstr "BREP Files ( *.brep )"
+
+#: GeometryGUI.cxx:3762
+msgid "GEOM_MEN_IMPORT_IGES"
+msgstr "IGES Files ( *.iges *.igs )"
+
+#: GeometryGUI.cxx:3763
+msgid "GEOM_MEN_IMPORT_STEP"
+msgstr "STEP Files ( *.step *.stp )"
+
+#: GeometryGUI.cxx:2931
+msgid "GEOM_MEN_ISOS"
+msgstr "Select Number Of Isos"
+
+#: GeometryGUI.cxx:4278
+msgid "GEOM_MEN_POPUP_NAME"
+msgstr "%1 Objects"
+
+#: GeometryGUI.cxx:4414
+msgid "GEOM_MEN_SKETCHER_X"
+msgstr "Enter a length to set X"
+
+#: GeometryGUI.cxx:4438
+msgid "GEOM_MEN_SKETCHER_Y"
+msgstr "Enter a length to set Y"
+
+#: GeometryGUI.cxx:2898
+msgid "GEOM_MEN_TRANSPARENCY"
+msgstr "Transparency"
+
+#: GeometryGUI.cxx:4413
+msgid "GEOM_MEN_X"
+msgstr "X :"
+
+#: GeometryGUI.cxx:4437
+msgid "GEOM_MEN_Y"
+msgstr "Y :"
+
+#: GeometryGUI_NbIsosDlg.cxx:36
+msgid "GEOM_MEN_ISOU"
+msgstr "Isos u :"
+
+#: GeometryGUI_NbIsosDlg.cxx:53
+msgid "GEOM_MEN_ISOV"
+msgstr "Isos v :"
+
+#: GeometryGUI_TransparencyDlg.cxx:31
+msgid "GEOM_MEN_TRANSPARENCY_LABEL"
+msgstr "Transparency :"
+
+msgid "GEOM_MEN_STEP_LABEL"
+msgstr "Step :"
+
+
+msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE"
+msgstr "Identical names : select by mouse !"
+
+msgid "GEOM_NAME_INCORRECT"
+msgstr "Object name not found"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:892
+msgid "GEOM_WRN_RADIUS_NULL"
+msgstr "Radius is null"
+
+#: GeometryGUI.cxx:3854
+msgid "GEOM_WRN_WARNING"
+msgstr "Warning"
+
+#: GeometryGUI.cxx:3854
+msgid "GEOM_REALLY_DELETE"
+msgstr "Do you really want to delete object(s) ?"
+
+#
+#==============================================================================
+#
+
+#Object
+msgid "GEOM_OBJECT"
+msgstr "Object"
+
+#Main object
+msgid "GEOM_MAIN_OBJECT"
+msgstr "Main Object"
+
+#Tool object
+msgid "GEOM_TOOL_OBJECT"
+msgstr "Tool Object"
+
+#Base Object
+msgid "GEOM_BASE_OBJECT"
+msgstr "Base Object"
+
+#Path Object
+msgid "GEOM_PATH_OBJECT"
+msgstr "Path Object"
+
+#Objects
+msgid "GEOM_OBJECTS"
+msgstr "Objects"
+
+#Object i
+msgid "GEOM_OBJECT_I"
+msgstr "Object %1"
+
+#Object and result
+msgid "GEOM_OBJECT_RESULT"
+msgstr "Object And Result"
+
+#Point
+msgid "GEOM_POINT"
+msgstr "Point"
+
+#Base point
+msgid "GEOM_BASE_POINT"
+msgstr "Base Point"
+
+#Center Point
+msgid "GEOM_CENTER_POINT"
+msgstr "Center Point"
+
+#Diagonal Points
+msgid "GEOM_DIAGONAL_POINTS"
+msgstr "Diagonal Points"
+
+#Central Point
+msgid "GEOM_CENTRAL_POINT"
+msgstr "Central Point"
+
+#Points
+msgid "GEOM_POINTS"
+msgstr "Points"
+
+#Point i
+msgid "GEOM_POINT_I"
+msgstr "Point %1"
+
+#Arguments
+msgid "GEOM_ARGUMENTS"
+msgstr "Arguments"
+
+#Center
+msgid "GEOM_CENTER"
+msgstr "Center"
+
+#Radius
+msgid "GEOM_RADIUS"
+msgstr "Radius :"
+
+#Radius i
+msgid "GEOM_RADIUS_I"
+msgstr "Radius %1 :"
+
+#Height
+msgid "GEOM_HEIGHT"
+msgstr "Height :"
+
+#Length
+msgid "GEOM_LENGTH"
+msgstr "Length is :"
+
+#Weight
+msgid "GEOM_WEIGHT"
+msgstr "Weight :"
+
+#Coordinates
+msgid "GEOM_COORDINATES"
+msgstr "Coordinates"
+
+#Coor.
+msgid "GEOM_COOR"
+msgstr "Coord. :"
+
+#Reverse
+msgid "GEOM_REVERSE"
+msgstr "Reverse"
+
+#Reverse U
+msgid "GEOM_REVERSE_U"
+msgstr "Reverse U"
+
+#Reverse V
+msgid "GEOM_REVERSE_V"
+msgstr "Reverse V"
+
+#Angle
+msgid "GEOM_ANGLE"
+msgstr "Angle :"
+
+#Axis
+msgid "GEOM_AXIS"
+msgstr "Axis"
+
+#Matrix
+msgid "GEOM_MATRIX"
+msgstr "Matrix :"
+
+#Vector Length
+msgid "GEOM_VECTOR_LENGTH"
+msgstr "Vector Length :"
+
+#Reverse Vector
+msgid "GEOM_REVERSE_VECTOR"
+msgstr "Reverse Vector"
+
+#Plane Mirror
+msgid "GEOM_PLANE_MIRROR"
+msgstr "Plane Mirror"
+
+#Face Selection
+msgid "GEOM_FACE_SELECTION"
+msgstr "Face Selection"
+
+#Base
+msgid "GEOM_BASE"
+msgstr "Base"
+
+#Water Density
+msgid "GEOM_WATER_DENSITY"
+msgstr "Water Density :"
+
+#Meshing Deflection
+msgid "GEOM_MESHING_DEFLECTION"
+msgstr "Meshing Deflect. :"
+
+#Dimensions
+msgid "GEOM_DIMENSIONS"
+msgstr "Dimensions"
+
+#Precision
+msgid "GEOM_PRECISION"
+msgstr "Precision :"
+
+#Selection
+msgid "GEOM_SELECTION"
+msgstr "Selection"
+
+#Nb. Times
+msgid "GEOM_NB_TIMES"
+msgstr "Nb. Times :"
+
+#Nb. Times U
+msgid "GEOM_NB_TIMES_U"
+msgstr "Nb. Times U :"
+
+#Nb. Times V
+msgid "GEOM_NB_TIMES_V"
+msgstr "Nb. Times V :"
+
+#Step
+msgid "GEOM_STEP"
+msgstr "Step :"
+
+#Step V
+msgid "GEOM_STEP_V"
+msgstr "Step V :"
+
+#Step U
+msgid "GEOM_STEP_U"
+msgstr "Step U :"
+
+#
+#==============================================================================
+#
+
+#Partition
+msgid "GEOM_PARTITION"
+msgstr "Partition"
+
+#Tolerance
+msgid "GEOM_TOLERANCE"
+msgstr "Tolerance"
+
+#Orientation
+msgid "GEOM_ORIENTATION"
+msgstr "Orientation"
+
+#Pipe
+msgid "GEOM_PIPE"
+msgstr "Pipe"
+
+#Revolution
+msgid "GEOM_REVOLUTION"
+msgstr "Revolution"
+
+#Rotation
+msgid "GEOM_ROTATION"
+msgstr "Rotation"
+
+#Archimede
+msgid "GEOM_ARCHIMEDE"
+msgstr "Archimede"
+
+#Common
+msgid "GEOM_COMMON"
+msgstr "Common"
+
+#Cut
+msgid "GEOM_CUT"
+msgstr "Cut"
+
+#Distance
+msgid "GEOM_DISTANCE"
+msgstr "Distance"
+
+#Filling
+msgid "GEOM_FILLING"
+msgstr "Filling"
+
+#Fuse
+msgid "GEOM_FUSE"
+msgstr "Fuse"
+
+#Scale
+msgid "GEOM_SCALE"
+msgstr "Scale"
+
+#Section
+msgid "GEOM_SECTION"
+msgstr "Section"
+
+#Sewing
+msgid "GEOM_SEWING"
+msgstr "Sewing"
+
+#Translation
+msgid "GEOM_TRANSLATION"
+msgstr "Translation"
+
+#Working Plane
+msgid "GEOM_WPLANE"
+msgstr "Working Plane"
+
+#Mirror
+msgid "GEOM_MIRROR"
+msgstr "Mirror"
+
+#Prism
+msgid "GEOM_PRISM"
+msgstr "Prism"
+
+#Sub Shapes
+msgid "GEOM_SUB_SHAPE"
+msgstr "Sub Shapes"
+
+#Supress Face
+msgid "GEOM_SUPRESSFACE"
+msgstr "Supress Face"
+
+#Fillet
+msgid "GEOM_FILLET"
+msgstr "Fillet"
+
+#Chamfer
+msgid "GEOM_CHAMFER"
+msgstr "Chamfer"
+
+#Check Shape
+msgid "GEOM_CHECK_SHAPE"
+msgstr "Check Shape"
+
+#Whatis
+msgid "GEOM_WHATIS"
+msgstr "Whatis"
+
+#Bounding Box
+msgid "GEOM_BNDBOX"
+msgstr "Bounding Box"
+
+#Center Of Mass
+msgid "GEOM_CMASS"
+msgstr "Center Of Mass"
+
+#Basic Properties
+msgid "GEOM_PROPERTIES"
+msgstr "Basic Properties"
+
+#Multi-Translation
+msgid "GEOM_MULTITRANSLATION"
+msgstr "Multi-Translation"
+
+#Multi-Rotation
+msgid "GEOM_MULTIROTATION"
+msgstr "Multi-Rotation"
+
+#
+#==============================================================================
+#
+
+#Arc
+msgid "GEOM_ARC"
+msgstr "Arc"
+
+#Box
+msgid "GEOM_BOX"
+msgstr "Box"
+
+#Circle
+msgid "GEOM_CIRCLE"
+msgstr "Circle"
+
+#Compound
+msgid "GEOM_COMPOUND"
+msgstr "Compound"
+
+#CompSolid
+msgid "GEOM_COMPOUNDSOLID"
+msgstr "CompSolid"
+
+#Cone
+msgid "GEOM_CONE"
+msgstr "Cone"
+
+#Cylinder
+msgid "GEOM_CYLINDER"
+msgstr "Cylinder"
+
+#Edge
+msgid "GEOM_EDGE"
+msgstr "Edge"
+
+#Face
+msgid "GEOM_FACE"
+msgstr "Face"
+
+#Faces
+msgid "GEOM_FACES"
+msgstr "Faces"
+
+#Line
+msgid "GEOM_LINE"
+msgstr "Line"
+
+#Plane
+msgid "GEOM_PLANE"
+msgstr "Plane"
+
+#Shape
+msgid "GEOM_SHAPE"
+msgstr "Shape"
+
+#Shell
+msgid "GEOM_SHELL"
+msgstr "Shell"
+
+#Solid
+msgid "GEOM_SOLID"
+msgstr "Solid"
+
+#Sphere
+msgid "GEOM_SPHERE"
+msgstr "Sphere"
+
+#Conical Face
+msgid "GEOM_SURFCONE"
+msgstr "Conical Face"
+
+#Cylindrical Face
+msgid "GEOM_SURFCYLINDER"
+msgstr "Cylindrical Face"
+
+#Spherical Face
+msgid "GEOM_SURFSPHERE"
+msgstr "Spherical Face"
+
+#Toroidal Face
+msgid "GEOM_SURFTORUS"
+msgstr "Toroidal Face"
+
+#Torus
+msgid "GEOM_TORUS"
+msgstr "Torus"
+
+#Vector
+msgid "GEOM_VECTOR"
+msgstr "Vector"
+
+#Vector U
+msgid "GEOM_VECTOR_U"
+msgstr "Vector U"
+
+#Vector V
+msgid "GEOM_VECTOR_V"
+msgstr "Vector V"
+
+#Vertex
+msgid "GEOM_VERTEX"
+msgstr "Vertex"
+
+#Wire
+msgid "GEOM_WIRE"
+msgstr "Wire"
+
+#Parameter
+msgid "GEOM_PARAMETER"
+msgstr "Parameter :"
+
+#
+#==============================================================================
+#
+
+#Min
+msgid "GEOM_MIN"
+msgstr "Min :"
+
+#Max
+msgid "GEOM_MAX"
+msgstr "Max :"
+
+#X
+msgid "GEOM_X"
+msgstr "X :"
+
+#Y
+msgid "GEOM_Y"
+msgstr "Y :"
+
+#Z
+msgid "GEOM_Z"
+msgstr "Z :"
+
+#DX
+msgid "GEOM_DX"
+msgstr "Dx :"
+
+#DY
+msgid "GEOM_DY"
+msgstr "Dy :"
+
+#DZ
+msgid "GEOM_DZ"
+msgstr "Dz :"
+
+#D1
+msgid "GEOM_D1"
+msgstr "D1 :"
+
+#D2
+msgid "GEOM_D2"
+msgstr "D2 :"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx
+msgid "GEOM_STEP_TITLE"
+msgstr "Step value for GUI constructions"
+
+#: GeometryGUI_ArcDlg.cxx:45
+msgid "GEOM_ARC_TITLE"
+msgstr "Arc Construction"
+
+#: GeometryGUI_ArchimedeDlg.cxx:55
+msgid "GEOM_ARCHIMEDE_TITLE"
+msgstr "Archimede Construction"
+
+#: GeometryGUI_BndBoxDlg.cxx:59
+msgid "GEOM_BNDBOX_TITLE"
+msgstr "Bounding Box Informations"
+
+#: GeometryGUI_BndBoxDlg.cxx:82
+msgid "GEOM_BNDBOX_OBJDIM"
+msgstr "Object And Its Dimensions"
+
+#: GeometryGUI_BoxDlg.cxx:50
+msgid "GEOM_BOX_TITLE"
+msgstr "Box Construction"
+
+#: GeometryGUI_BoxDlg.cxx:50
+msgid "GEOM_BOX_OBJ"
+msgstr "Dimensions At Origin"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_TITLE"
+msgstr "Chamfer Construction"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_ALL"
+msgstr "Chamfer On Whole Shape"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_EDGES"
+msgstr "Chamfer On Edges From Shape"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_FACES"
+msgstr "Chamfer On Faces From Shape"
+
+#: GeometryGUI_CircleDlg.cxx:48
+msgid "GEOM_CIRCLE_TITLE"
+msgstr "Circle Construction"
+
+#: GeometryGUI_CenterMassDlg.cxx:77
+msgid "GEOM_CMASS_TITLE"
+msgstr "Center Of Mass Construction"
+
+msgid "GEOM_PLANE_SIZE"
+msgstr "Size of plane :"
+
+#: GeometryGUI_CommonDlg.cxx:47
+msgid "GEOM_COMMON_TITLE"
+msgstr "BOOLEAN : Common Of Two Objects"
+
+#: GeometryGUI_CompoundDlg.cxx:44
+msgid "GEOM_COMPOUND_TITLE"
+msgstr "Create A Compound"
+
+#: GeometryGUI_ConeDlg.cxx:49
+msgid "GEOM_CONE_TITLE"
+msgstr "Cone Construction"
+
+#: GeometryGUI_CutDlg.cxx:48
+msgid "GEOM_CUT_TITLE"
+msgstr "BOOLEAN : Cut Of Two Objects"
+#
+#: GeometryGUI_CylinderDlg.cxx:47
+msgid "GEOM_CYLINDER_TITLE"
+msgstr "Cylinder Construction"
+
+#: GeometryGUI_CheckShape.cxx:60
+msgid "GEOM_CHECK_TITLE"
+msgstr "Check Shape Informations"
+
+#: GeometryGUI_CheckShape.cxx:83
+msgid "GEOM_CHECK_INFOS"
+msgstr "Object And Its Topological Informations"
+
+#: GeometryGUI_DistanceDlg.cxx:57
+msgid "GEOM_MINDIST_TITLE"
+msgstr "Minimun Distance Between Two Objects"
+
+#: GeometryGUI_DistanceDlg.cxx:57
+msgid "GEOM_MINDIST_OBJ"
+msgstr "Objects And Results"
+
+#: GeometryGUI_EdgeDlg.cxx:47
+msgid "GEOM_EDGE_TITLE"
+msgstr "Create An Edge"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_TITLE"
+msgstr "Fillet Construction"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_ALL"
+msgstr "Fillet On Whole Shape"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_EDGES"
+msgstr "Fillet On Edges From Shape"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_FACES"
+msgstr "Fillet On Faces From Shape"
+
+#: GeometryGUI_FaceDlg.cxx:49
+msgid "GEOM_FACE_TITLE"
+msgstr "Create A Face"
+
+#: GeometryGUI_FaceDlg.cxx:78
+msgid "GEOM_FACE_FFW"
+msgstr "Face from a wire"
+
+#: GeometryGUI_FaceDlg.cxx:103
+msgid "GEOM_FACE_OPT"
+msgstr "Try to create a planar face"
+
+#: GeometryGUI_FillingDlg.cxx:53
+msgid "GEOM_FILLING_TITLE"
+msgstr "Filling Surface With Curves"
+
+#: GeometryGUI_FillingDlg.cxx:112
+msgid "GEOM_FILLING_ARG"
+msgstr "Arguments And Parameters"
+
+#: GeometryGUI_FillingDlg.cxx:128
+msgid "GEOM_FILLING_MIN_DEG"
+msgstr "Min deg"
+
+#: GeometryGUI_FillingDlg.cxx:142
+msgid "GEOM_FILLING_MAX_DEG"
+msgstr "Max deg"
+
+#: GeometryGUI_FillingDlg.cxx:150
+msgid "GEOM_FILLING_TOL_2D"
+msgstr "Tol. 2D :"
+
+#: GeometryGUI_FillingDlg.cxx:170
+msgid "GEOM_FILLING_COMPOUND"
+msgstr "Curves Comp."
+
+#: GeometryGUI_FillingDlg.cxx:184
+msgid "GEOM_FILLING_TOL_3D"
+msgstr "Tol. 3D :"
+
+#: GeometryGUI_FillingDlg.cxx:192
+msgid "GEOM_FILLING_NB_ITER"
+msgstr "Nb. Iter :"
+
+#: GeometryGUI_FuseDlg.cxx:48
+msgid "GEOM_FUSE_TITLE"
+msgstr "BOOLEAN : Fuse Two Objects"
+
+#: GeometryGUI_InertiaDlg.cxx:42
+msgid "GEOM_INERTIA_TITLE"
+msgstr "Calculs Of Inertia"
+
+#: GeometryGUI_InertiaDlg.cxx:50
+msgid "GEOM_INERTIA_CONSTR"
+msgstr "Matrix And Moments Of Inertia"
+
+#: GeometryGUI_InertiaDlg.cxx:100
+msgid "GEOM_INERTIA_I"
+msgstr "%1:1 :"
+
+#: GeometryGUI_InertiaDlg.cxx:182
+msgid "GEOM_INERTIA_IXYZ"
+msgstr "IX & IY & IZ :"
+
+#: GeometryGUI_LineDlg.cxx:50
+msgid "GEOM_LINE_TITLE"
+msgstr "Line Construction"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:53
+msgid "GEOM_TOLERANCE_TITLE"
+msgstr "Maximum Tolerance"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:84
+msgid "GEOM_TOLERANCE_CONSTR"
+msgstr "Object And Its Tolerances"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:121
+msgid "GEOM_TOLERANCE_FACE"
+msgstr "Face :"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:138
+msgid "GEOM_TOLERANCE_EDGE"
+msgstr "Edge :"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:155
+msgid "GEOM_TOLERANCE_VERTEX"
+msgstr "Vertex :"
+
+#: GeometryGUI_MirrorDlg.cxx:52
+msgid "GEOM_MIRROR_TITLE"
+msgstr "Mirror An Object"
+
+#: GeometryGUI_OrientationDlg.cxx:46
+msgid "GEOM_ORIENTATION_TITLE"
+msgstr "Change Orientation"
+
+#: GeometryGUI_OrientationDlg.cxx:134
+msgid "GEOM_ORIENTATION_OPT"
+msgstr "Reverse orientation with normal vectors simulation"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_PARTITION_TITLE"
+msgstr "Partition Of Object With Tool"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_KEEP_OBJECT"
+msgstr "Keep Object"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_PARTITION_ORIENTATION"
+msgstr "Change Orientation"
+
+#: GeometryGUI_PipeDlg.cxx:47
+msgid "GEOM_PIPE_TITLE"
+msgstr "Pipe Construction"
+
+#: GeometryGUI_PointDlg.cxx:52
+msgid "GEOM_POINT_TITLE"
+msgstr "Point Construction"
+
+#: GeometryGUI_PlaneDlg.cxx:60
+msgid "GEOM_PLANE_TITLE"
+msgstr "Plane Construction"
+
+#: GeometryGUI_PlaneDlg.cxx:172
+msgid "GEOM_PLANE_PVC"
+msgstr "Point + Coordinate Vector"
+
+#: GeometryGUI_PlaneDlg.cxx:133
+msgid "GEOM_PLANE_PV"
+msgstr "Point + Vector"
+
+#: GeometryGUI_PrismDlg.cxx:54
+msgid "GEOM_PRISM_TITLE"
+msgstr "Prism Construction"
+
+#: GeometryGUI_PrismDlg.cxx:83
+msgid "GEOM_PRISM_BSV"
+msgstr "Base Shape + Vector"
+
+#: GeometryGUI_PropertiesDlg.cxx:56
+msgid "GEOM_PROPERTIES_TITLE"
+msgstr "Basic Properties Informations"
+
+#: GeometryGUI_PropertiesDlg.cxx:78
+msgid "GEOM_PROPERTIES_CONSTR"
+msgstr "Object And Its Properties"
+
+#: GeometryGUI_PropertiesDlg.cxx:114
+msgid "GEOM_PROPERTIES_SURFACE"
+msgstr "Surface is :"
+
+#: GeometryGUI_PropertiesDlg.cxx:120
+msgid "GEOM_PROPERTIES_VOLUME"
+msgstr "Volume is :"
+
+#: GeometryGUI_RevolDlg.cxx:49
+msgid "GEOM_REVOLUTION_TITLE"
+msgstr "Construction By Revolution"
+
+#: GeometryGUI_RotationDlg.cxx:51
+msgid "GEOM_ROTATION_TITLE"
+msgstr "Rotation Of An Object"
+
+#: GeometryGUI_ScaleDlg.cxx:52
+msgid "GEOM_SCALE_TITLE"
+msgstr "Scale An Object"
+
+#: GeometryGUI_ScaleDlg.cxx:117
+msgid "GEOM_SCALE_FACTOR"
+msgstr "Scale Factor :"
+
+#: GeometryGUI_SectionDlg.cxx:50
+msgid "GEOM_SECTION_TITLE"
+msgstr "BOOLEAN : Section Of Two Objects"
+
+#: GeometryGUI_SewingDlg.cxx:48
+msgid "GEOM_SEWING_TITLE"
+msgstr "Sewing Topologies"
+
+#: GeometryGUI_ShellDlg.cxx:53
+msgid "GEOM_SHELL_TITLE"
+msgstr "Shell Construction"
+
+#: GeometryGUI_ShellDlg.cxx:74
+msgid "GEOM_SHELL_LIST"
+msgstr "List Of Connected Faces"
+
+#: GeometryGUI_SphereDlg.cxx:50
+msgid "GEOM_SPHERE_TITLE"
+msgstr "Sphere Construction"
+
+#: GeometryGUI_SphereDlg.cxx:113
+msgid "GEOM_SPHERE_CR"
+msgstr "Center + Radius"
+
+#: GeometryGUI_SphereDlg.cxx:146
+msgid "GEOM_SPHERE_RO"
+msgstr "Radius At Origin"
+
+#: GeometryGUI_SubShapeDlg.cxx:55
+msgid "GEOM_SUBSHAPE_TITLE"
+msgstr "Sub Shapes Selection"
+
+#: GeometryGUI_SubShapeDlg.cxx:131
+msgid "GEOM_SUBSHAPE_TYPE"
+msgstr "Sub Shapes Type :"
+
+#: GeometryGUI_SubShapeDlg.cxx:137
+msgid "GEOM_SUBSHAPE_SELECT"
+msgstr "Select Sub Shapes"
+
+#: GeometryGUI_TorusDlg.cxx:51
+msgid "GEOM_TORUS_TITLE"
+msgstr "Torus Construction"
+
+#: GeometryGUI_SuppressFacesDlg.cxx:103
+msgid "GEOM_SUPRESSFACE_TITLE"
+msgstr "Suppress Faces In An Object"
+
+#: GeometryGUI_SuppressFacesDlg.cxx:164
+msgid "GEOM_SUPRESSFACE_SELECT"
+msgstr "Select Faces To Suppress"
+
+#: GeometryGUI_TranslationDlg.cxx:78
+msgid "GEOM_TRANSLATION_COOR"
+msgstr "Translation With Coordinates"
+
+msgid "GEOM_TRANSPARENCY_TITLE"
+msgstr "Transparency"
+
+msgid "GEOM_TRANSPARENCY_OPAQUE"
+msgstr "Opaque"
+
+msgid "GEOM_TRANSPARENCY_TRANSPARENT"
+msgstr "Transparent"
+
+msgid "GEOM_SUPPRESSHOLE_TITLE"
+msgstr "Suppress holes"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTFACE"
+msgstr "Select the face with hole"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTWIRE"
+msgstr "Select wire on face"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END"
+msgstr "Select end face (if hole traversing)"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END"
+msgstr "Select end wire (if hole traversing)"
+
+msgid "GEOM_SUPPRESSHOLE_FACE_SHELL"
+msgstr "Face or shell"
+
+msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE"
+msgstr "Select hole(s) on the face"
+
+#: GeometryGUI_TranslationDlg.cxx:56
+msgid "GEOM_TRANSLATION_TITLE"
+msgstr "Translation Of An Object"
+
+#: GeometryGUI_VectorDlg.cxx:54
+msgid "GEOM_VECTOR_TITLE"
+msgstr "Vector Construction"
+
+#: GeometryGUI_WhatisDlg.cxx:63
+msgid "GEOM_WHATIS_TITLE"
+msgstr "Whatis Informations"
+
+#: GeometryGUI_WhatisDlg.cxx:86
+msgid "GEOM_WHATIS_OBJECT"
+msgstr "Object And Its Topological Informations"
+
+#: GeometryGUI_WireDlg.cxx:46
+msgid "GEOM_WIRE_TITLE"
+msgstr "Create A Wire"
+
+#: GeometryGUI_WireDlg.cxx:103
+msgid "GEOM_WIRE_CONNECT"
+msgstr "Wire creation from wires/edges connected"
+
+#: GeometryGUI_WorkingPlaneDlg.cxx:50
+msgid "GEOM_WPLANE_TITLE"
+msgstr "Working Plane Selection"
+
+#: GeometryGUI_WorkingPlaneDlg.cxx:107
+msgid "GEOM_WPLANE_FACE"
+msgstr "Plane Or Planar Face"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_TITLE"
+msgstr "Multi-Translation"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_SIMPLE"
+msgstr "Multi Translation Simple"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_DOUBLE"
+msgstr "Multi Translation Double"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_TITLE"
+msgstr "Multi-Rotation"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_SIMPLE"
+msgstr "Multi Rotation Simple"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_DOUBLE"
+msgstr "Multi Rotation Double"
+
+msgid "GEOM_PARAM_POINT"
+msgstr "Parametric point"
+
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:4613
+msgid "GEOM_MEN_WIREFRAME"
+msgstr "Wireframe"
+
+#: GeometryGUI.cxx:4613
+msgid "GEOM_MEN_SHADING"
+msgstr "\nShading"
+
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT"
+msgstr "Reconstruction Limit"
+
+msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT"
+msgstr "Suppress Result"
+
+msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT_INSIDE"
+msgstr "Inside"
+
+msgid "GeometryGUI_PartitionDlg::SUPPRESS_RESULT_OUTSIDE"
+msgstr "Outside"
+
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SHAPE"
+msgstr "Shape"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SOLID"
+msgstr "Solid"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_SHELL"
+msgstr "Shell"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_FACE"
+msgstr "Face"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_WIRE"
+msgstr "Wire"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_EDGE"
+msgstr "Edge"
+msgid "GeometryGUI_PartitionDlg::RECONSTRUCTION_LIMIT_VERTEX"
+msgstr "Vertex"
--- /dev/null
+# 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_msg_fr.po
+# Module : GEOM
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-03-19 09:35:48 AM CET\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+#
+#==============================================================================
+#
+
+#Button Apply
+msgid "GEOM_BUT_APPLY"
+msgstr "&Appliquer"
+
+#Button Close
+msgid "GEOM_BUT_CLOSE"
+msgstr "&Fermer"
+
+#Button Cancel
+msgid "GEOM_BUT_CANCEL"
+msgstr "&Annuler"
+
+#Button Ok
+msgid "GEOM_BUT_OK"
+msgstr "&Ok"
+
+#Button Yes
+msgid "GEOM_BUT_YES"
+msgstr "&Oui"
+
+#Button Help
+msgid "GEOM_BUT_HELP"
+msgstr "&Aide"
+
+
+#Button Explode
+msgid "GEOM_BUT_EXPLODE"
+msgstr "&Exploser"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:563
+msgid "GEOM_INF_LOADED"
+msgstr "Le fichier %1 est chargé."
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:3069
+msgid "GEOM_PRP_COMMAND"
+msgstr "Pas de commande associée à l'id = %1."
+
+#: GeometryGUI.cxx:4977
+msgid "GEOM_PRP_ABORT"
+msgstr "L'opération a echoué"
+
+#: GeometryGUI.cxx:5058
+msgid "GEOM_PRP_DONE"
+msgstr "Opération effectuée"
+
+#: GeometryGUI.cxx:3717
+msgid "GEOM_PRP_LOADING"
+msgstr "Chargement de %1 ..."
+
+#: GeometryGUI.cxx:1412
+msgid "GEOM_PRP_NULLSHAPE"
+msgstr "Erreur, objet inconsistant ou inapproprié !"
+
+#: GeometryGUI.cxx:5072
+msgid "GEOM_PRP_READY"
+msgstr "Prêt..."
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_SUBSHAPES"
+msgstr "Selection de sous objets"
+
+msgid "GEOM_CONFIRM"
+msgstr "Confirmer cette operation"
+
+msgid "GEOM_CONFIRM_INFO"
+msgstr "L'objet contient %1 sous objets"
+
+
+msgid "GEOM_PRP_NOT_FOR_VTK_VIEWER"
+msgstr "Non permis dans viewer VTK"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SHAPE_IN_STUDY"
+msgstr "La shape principale doit etre avant dans l'etude"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_EDGE"
+msgstr "Selectionner les edges et clicker sur Apply"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_FACE"
+msgstr "Select les faces a supprimer et clicker sur Ok/Apply"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_SELECT_FIRST"
+msgstr "Selectionner la shape principale en premier"
+
+#: GeometryGUI.cxx:1690
+msgid "GEOM_PRP_MIN_DIST"
+msgstr "Min Distance non calculer"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:3698
+msgid "GEOM_MEN_ALL_FILES"
+msgstr "Tous fichiers ( * )"
+
+#: GeometryGUI.cxx:4389
+msgid "GEOM_MEN_ANGLE"
+msgstr "Angle :"
+
+#: GeometryGUI.cxx:3941
+msgid "GEOM_MEN_COMPONENT"
+msgstr "Géometrie"
+
+#: GeometryGUI.cxx:4389
+msgid "GEOM_MEN_ENTER_ANGLE"
+msgstr "Saisir un angle en degrés"
+
+#: GeometryGUI.cxx:3758
+msgid "GEOM_MEN_EXPORT"
+msgstr "Exporter"
+
+#: GeometryGUI.cxx:3648
+msgid "GEOM_MEN_IMPORT"
+msgstr "Importer"
+
+#: GeometryGUI.cxx:3761
+msgid "GEOM_MEN_IMPORT_BREP"
+msgstr "Fichiers BREP ( *.brep )"
+
+#: GeometryGUI.cxx:3762
+msgid "GEOM_MEN_IMPORT_IGES"
+msgstr "Fichiers IGES ( *.iges *.igs )"
+
+#: GeometryGUI.cxx:3763
+msgid "GEOM_MEN_IMPORT_STEP"
+msgstr "Fichiers STEP ( *.step *.stp )"
+
+#: GeometryGUI.cxx:2931
+msgid "GEOM_MEN_ISOS"
+msgstr "Choisir un nombre d'isos"
+
+#: GeometryGUI.cxx:4278
+msgid "GEOM_MEN_POPUP_NAME"
+msgstr "%1 Objets"
+
+#: GeometryGUI.cxx:4414
+msgid "GEOM_MEN_SKETCHER_X"
+msgstr "Saisir une longueur pour fixer X"
+
+#: GeometryGUI.cxx:4438
+msgid "GEOM_MEN_SKETCHER_Y"
+msgstr "Saisir une longueur pour fixer Y"
+
+#: GeometryGUI.cxx:2898
+msgid "GEOM_MEN_TRANSPARENCY"
+msgstr "Transparence"
+
+#: GeometryGUI.cxx:4413
+msgid "GEOM_MEN_X"
+msgstr "X :"
+
+#: GeometryGUI.cxx:4437
+msgid "GEOM_MEN_Y"
+msgstr "Y :"
+
+#: GeometryGUI_NbIsosDlg.cxx:36
+msgid "GEOM_MEN_ISOU"
+msgstr "Isos u :"
+
+#: GeometryGUI_NbIsosDlg.cxx:53
+msgid "GEOM_MEN_ISOV"
+msgstr "Isos v :"
+
+#: GeometryGUI_TransparencyDlg.cxx:31
+msgid "GEOM_MEN_TRANSPARENCY_LABEL"
+msgstr "Transparence :"
+
+msgid "GEOM_MEN_STEP_LABEL"
+msgstr "Increment"
+
+msgid "GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE"
+msgstr "Noms identiques : selectionner avec la souris !"
+
+msgid "GEOM_NAME_INCORRECT"
+msgstr "Le nom saisi n'existe pas"
+
+
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:892
+msgid "GEOM_WRN_RADIUS_NULL"
+msgstr "Le rayon est nul"
+
+#: GeometryGUI.cxx:3854
+msgid "GEOM_WRN_WARNING"
+msgstr "Avertissement"
+
+#
+#==============================================================================
+#
+
+#Object
+msgid "GEOM_OBJECT"
+msgstr "Objet"
+
+#Main object
+msgid "GEOM_MAIN_OBJECT"
+msgstr "Objet Principal"
+
+#Tool object
+msgid "GEOM_TOOL_OBJECT"
+msgstr "Objet Outil"
+
+#Base Object
+msgid "GEOM_BASE_OBJECT"
+msgstr "Objet De Base"
+
+#Path Object
+msgid "GEOM_PATH_OBJECT"
+msgstr "Objet Chemin"
+
+#Objects
+msgid "GEOM_OBJECTS"
+msgstr "Objets"
+
+#Object i
+msgid "GEOM_OBJECT_I"
+msgstr "Objet %1"
+
+#Object and result
+msgid "GEOM_OBJECT_RESULT"
+msgstr "Objet Et Résultat"
+
+#Point
+msgid "GEOM_POINT"
+msgstr "Point"
+
+#Base point
+msgid "GEOM_BASE_POINT"
+msgstr "Point De Base"
+
+#Center Point
+msgid "GEOM_CENTER_POINT"
+msgstr "Point Centre"
+
+#Diagonal Points
+msgid "GEOM__DIAGONAL_POINTS"
+msgstr "Points Diagonaux"
+
+#Central Point
+msgid "GEOM_CENTRAL_POINT"
+msgstr "Point Central"
+
+#Points
+msgid "GEOM_POINTS"
+msgstr "Points"
+
+#Point i
+msgid "GEOM_POINT_I"
+msgstr "Point %1"
+
+#Arguments
+msgid "GEOM_ARGUMENTS"
+msgstr "Arguments"
+
+#Center
+msgid "GEOM_CENTER"
+msgstr "Centre"
+
+#Radius
+msgid "GEOM_RADIUS"
+msgstr "Rayon"
+
+#Radius i
+msgid "GEOM_RADIUS_I"
+msgstr "Rayon %1"
+
+#Height
+msgid "GEOM_HEIGHT"
+msgstr "Hauteur"
+
+#Length
+msgid "GEOM_LENGTH"
+msgstr "Longueur :"
+
+#Weight
+msgid "GEOM_WEIGHT"
+msgstr "poids"
+
+#Coordinates
+msgid "GEOM_COORDINATES"
+msgstr "Coordonnées"
+
+#Coor.
+msgid "GEOM_COOR"
+msgstr "Coord. :"
+
+#Reverse
+msgid "GEOM_REVERSE"
+msgstr "Renverser"
+
+#Reverse U
+msgid "GEOM_REVERSE_U"
+msgstr "Renverser U"
+
+#Reverse V
+msgid "GEOM_REVERSE_V"
+msgstr "Reverser V"
+
+#Angle
+msgid "GEOM_ANGLE"
+msgstr "Angle :"
+
+#Axis
+msgid "GEOM_AXIS"
+msgstr "Axe"
+
+#Matrix
+msgid "GEOM_MATRIX"
+msgstr "Matrice :"
+
+#Vector Length
+msgid "GEOM_VECTOR_LENGTH"
+msgstr "Longueur Du Vecteur :"
+
+#Reverse Vector
+msgid "GEOM_REVERSE_VECTOR"
+msgstr "Renverser Le Vecteur"
+
+#Plane Mirror
+msgid "GEOM_PLANE_MIRROR"
+msgstr "Plan Miroir"
+
+#Face Selection
+msgid "GEOM_FACE_SELECTION"
+msgstr "Selection de Face"
+
+#Base
+msgid "GEOM_BASE"
+msgstr "Base"
+
+#Water Density
+msgid "GEOM_WATER_DENSITY"
+msgstr "Densité de l'eau :"
+
+#Meshing Deflection
+msgid "GEOM_MESHING_DEFLECTION"
+msgstr "Déflection Du Maillage :"
+
+#Dimensions
+msgid "GEOM_DIMENSIONS"
+msgstr "Dimensions"
+
+#Precision
+msgid "GEOM_PRECISION"
+msgstr "Précision :"
+
+#Selection
+msgid "GEOM_SELECTION"
+msgstr "Sélection"
+
+#Nb. Times
+msgid "GEOM_NB_TIMES"
+msgstr "Nb. Fois :"
+
+#Nb. Times U
+msgid "GEOM_NB_TIMES_U"
+msgstr "Nb. Fois U :"
+
+#Nb. Times V
+msgid "GEOM_NB_TIMES_V"
+msgstr "Nb. Fois V :"
+
+#Step
+msgid "GEOM_STEP"
+msgstr "Pas :"
+
+#Step V
+msgid "GEOM_STEP_V"
+msgstr "Pas V :"
+
+#Step U
+msgid "GEOM_STEP_U"
+msgstr "Pas U :"
+
+#
+#==============================================================================
+#
+
+#Partition
+msgid "GEOM_PARTITION"
+msgstr "Partition"
+
+#Tolerance
+msgid "GEOM_TOLERANCE"
+msgstr "Tolérance"
+
+#Orientation
+msgid "GEOM_ORIENTATION"
+msgstr "Orientation"
+
+#Pipe
+msgid "GEOM_PIPE"
+msgstr "Pipe"
+
+#Revolution
+msgid "GEOM_REVOLUTION"
+msgstr "Révolution"
+
+#Rotation
+msgid "GEOM_ROTATION"
+msgstr "Rotation"
+
+#Archimede
+msgid "GEOM_ARCHIMEDE"
+msgstr "Archimède"
+
+#Common
+msgid "GEOM_COMMON"
+msgstr "Joindre"
+
+#Cut
+msgid "GEOM_CUT"
+msgstr "Couper"
+
+#Distance
+msgid "GEOM_DISTANCE"
+msgstr "Distance"
+
+#Filling
+msgid "GEOM_FILLING"
+msgstr "Surface Par Courbes"
+
+#Fuse
+msgid "GEOM_FUSE"
+msgstr "Fusionner"
+
+#Scale
+msgid "GEOM_SCALE"
+msgstr "Echelle"
+
+#Section
+msgid "GEOM_SECTION"
+msgstr "Section"
+
+#Sewing
+msgid "GEOM_SEWING"
+msgstr "Coudre"
+
+#Translation
+msgid "GEOM_TRANSLATION"
+msgstr "Translation"
+
+#Working Plane
+msgid "GEOM_WPLANE"
+msgstr "Plan de Travail"
+
+#Mirror
+msgid "GEOM_MIRROR"
+msgstr "Miroir"
+
+#Prism
+msgid "GEOM_PRISM"
+msgstr "Extrusion"
+
+#Sub Shapes
+msgid "GEOM_SUB_SHAPE"
+msgstr "Sous Shapes"
+
+#Supress Face
+msgid "GEOM_SUPRESSFACE"
+msgstr "Supression de Face"
+
+#Fillet
+msgid "GEOM_FILLET"
+msgstr "Conge"
+
+#Chamfer
+msgid "GEOM_CHAMFER"
+msgstr "Chanfrein"
+
+#Check Shape
+msgid "GEOM_CHECK_SHAPE"
+msgstr "Check Shape"
+
+#Whatis
+msgid "GEOM_WHATIS"
+msgstr "Whatis"
+
+#Bounding Box
+msgid "GEOM_BNDBOX"
+msgstr "Boite Anglobante"
+
+#Center Of Mass
+msgid "GEOM_CMASS"
+msgstr "Centre de Masse"
+
+#Basic Properties
+msgid "GEOM_PROPERTIES"
+msgstr "Basiques Proprietes"
+
+#Multi-Translation
+msgid "GEOM_MULTITRANSLATION"
+msgstr "Multi-Translation"
+
+#Multi-Rotation
+msgid "GEOM_MULTIROTATION"
+msgstr "Multi-Rotation"
+
+#
+#==============================================================================
+#
+
+#Arc
+msgid "GEOM_ARC"
+msgstr "Arc"
+
+#Box
+msgid "GEOM_BOX"
+msgstr "Boite"
+
+#Circle
+msgid "GEOM_CIRCLE"
+msgstr "Cercle"
+
+#Compound
+msgid "GEOM_COMPOUND"
+msgstr "Compound"
+
+#CompSolid
+msgid "GEOM_COMPOUNDSOLID"
+msgstr "CompSolid"
+
+#Cone
+msgid "GEOM_CONE"
+msgstr "Cone"
+
+#Cylinder
+msgid "GEOM_CYLINDER"
+msgstr "Cylindre"
+
+#Edge
+msgid "GEOM_EDGE"
+msgstr "Edge"
+
+#Face
+msgid "GEOM_FACE"
+msgstr "Face"
+
+#Faces
+msgid "GEOM_FACES"
+msgstr "Faces"
+
+#Line
+msgid "GEOM_LINE"
+msgstr "Ligne"
+
+#Plane
+msgid "GEOM_PLANE"
+msgstr "Plan"
+
+#Shape
+msgid "GEOM_SHAPE"
+msgstr "Shape"
+
+#Shell
+msgid "GEOM_SHELL"
+msgstr "Shell"
+
+#Solid
+msgid "GEOM_SOLID"
+msgstr "Solide"
+
+#Sphere
+msgid "GEOM_SPHERE"
+msgstr "Sphère"
+
+#Conical Face
+msgid "GEOM_SURFCONE"
+msgstr "Face Conique"
+
+#Cylindrical Face
+msgid "GEOM_SURFCYLINDER"
+msgstr "Face Cylindrique"
+
+#Spherical Face
+msgid "GEOM_SURFSPHERE"
+msgstr "Face Sphèrique"
+
+#Toroidal Face
+msgid "GEOM_SURFTORUS"
+msgstr "Face Toroique"
+
+#Torus
+msgid "GEOM_TORUS"
+msgstr "Tore"
+
+#Vector
+msgid "GEOM_VECTOR"
+msgstr "Vecteur"
+
+#Vector U
+msgid "GEOM_VECTOR_U"
+msgstr "Vecteur U"
+
+#Vector V
+msgid "GEOM_VECTOR_V"
+msgstr "Vecteur V"
+
+#Vertex
+msgid "GEOM_VERTEX"
+msgstr "Vertex"
+
+#Wire
+msgid "GEOM_WIRE"
+msgstr "Wire"
+
+#Parameter
+msgid "GEOM_PARAMETER"
+msgstr "Paramètre :"
+
+
+#
+#==============================================================================
+#
+
+#Min
+msgid "GEOM_MIN"
+msgstr "Min :"
+
+#Max
+msgid "GEOM_MAX"
+msgstr "Max :"
+
+#X
+msgid "GEOM_X"
+msgstr "X :"
+
+#Y
+msgid "GEOM_Y"
+msgstr "Y :"
+
+#Z
+msgid "GEOM_Z"
+msgstr "Z :"
+
+#DX
+msgid "GEOM_DX"
+msgstr "Dx :"
+
+#DY
+msgid "GEOM_DY"
+msgstr "Dy :"
+
+#DZ
+msgid "GEOM_DZ"
+msgstr "Dz :"
+
+#D1
+msgid "GEOM_D1"
+msgstr "D1 :"
+
+#D2
+msgid "GEOM_D2"
+msgstr "D2 :"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx
+msgid "GEOM_STEP_TITLE"
+msgstr "Increment par défaut lors des constructions"
+
+#: GeometryGUI_ArcDlg.cxx:45
+msgid "GEOM_ARC_TITLE"
+msgstr "Construction d'un Arc"
+
+#: GeometryGUI_ArchimedeDlg.cxx:55
+msgid "GEOM_ARCHIMEDE_TITLE"
+msgstr "Construction d'Archimède"
+
+#: GeometryGUI_BndBoxDlg.cxx:59
+msgid "GEOM_BNDBOX_TITLE"
+msgstr "Boite Englobante"
+
+#: GeometryGUI_BndBoxDlg.cxx:82
+msgid "GEOM_BNDBOX_OBJDIM"
+msgstr "Objet and ses dimensions"
+
+#: GeometryGUI_BoxDlg.cxx:50
+msgid "GEOM_BOX_TITLE"
+msgstr "Construction d'une Boite"
+
+#: GeometryGUI_BoxDlg.cxx:50
+msgid "GEOM_BOX_OBJ"
+msgstr "Dimensions A l'Origine"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_TITLE"
+msgstr "Construction d'un Chanfrein"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_ALL"
+msgstr "Chanfrein sur toute la Shape"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_EDGES"
+msgstr "Chanfrein sur Edges de la Shape"
+
+#: GeometryGUI_ChamferDlg.cxx:58
+msgid "GEOM_CHAMFER_FACES"
+msgstr "Chanfrein sur Faces de la Shape"
+
+#: GeometryGUI_CircleDlg.cxx:48
+msgid "GEOM_CIRCLE_TITLE"
+msgstr "Construction d'un Cercle"
+
+#: GeometryGUI_CenterMassDlg.cxx:77
+msgid "GEOM_CMASS_TITLE"
+msgstr "Centre De Gravité"
+
+msgid "GEOM_PLANE_SIZE"
+msgstr "Taille du plan :"
+
+#: GeometryGUI_CommonDlg.cxx:47
+msgid "GEOM_COMMON_TITLE"
+msgstr "BOOLEEN : Jonction De Deux Objets"
+
+#: GeometryGUI_CompoundDlg.cxx:44
+msgid "GEOM_COMPOUND_TITLE"
+msgstr "Création d'un Compound"
+
+#: GeometryGUI_ConeDlg.cxx:49
+msgid "GEOM_CONE_TITLE"
+msgstr "Construction d'un Cone"
+
+#: GeometryGUI_CutDlg.cxx:48
+msgid "GEOM_CUT_TITLE"
+msgstr "BOOLEEN : Couper Deux Objets"
+#
+#: GeometryGUI_CylinderDlg.cxx:47
+msgid "GEOM_CYLINDER_TITLE"
+msgstr "Construction d'un Cylindre"
+
+#: GeometryGUI_CheckShape.cxx:60
+msgid "GEOM_CHECK_TITLE"
+msgstr "Check Shape"
+
+#: GeometryGUI_CheckShape.cxx:83
+msgid "GEOM_CHECK_INFOS"
+msgstr "Objet et ses Informations Topologiques"
+
+#: GeometryGUI_DistanceDlg.cxx:57
+msgid "GEOM_MINDIST_TITLE"
+msgstr "Distance Minimale entre Deux Objets"
+
+#: GeometryGUI_DistanceDlg.cxx:57
+msgid "GEOM_MINDIST_OBJ"
+msgstr "Objets Et Resultats"
+
+#: GeometryGUI_EdgeDlg.cxx:47
+msgid "GEOM_EDGE_TITLE"
+msgstr "Création d'un Edge"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_TITLE"
+msgstr "Construction d'un Congé"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_ALL"
+msgstr "Congé sur toute la Shape"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_EDGES"
+msgstr "Congé sur Edges de la Shape"
+
+#: GeometryGUI_FilletDlg.cxx:58
+msgid "GEOM_FILLET_FACES"
+msgstr "Congé sur Faces de la Shape"
+
+#: GeometryGUI_FaceDlg.cxx:49
+msgid "GEOM_FACE_TITLE"
+msgstr "Création d'une Face"
+
+#: GeometryGUI_FaceDlg.cxx:78
+msgid "GEOM_FACE_FFW"
+msgstr "Face a partir d'un wire"
+
+#: GeometryGUI_FaceDlg.cxx:103
+msgid "GEOM_FACE_OPT"
+msgstr "Création d'une Face plane"
+
+#: GeometryGUI_FillingDlg.cxx:53
+msgid "GEOM_FILLING_TITLE"
+msgstr "Surface Par Courbes"
+
+#: GeometryGUI_FillingDlg.cxx:112
+msgid "GEOM_FILLING_ARG"
+msgstr "Argument Et Parametres"
+
+#: GeometryGUI_FillingDlg.cxx:128
+msgid "GEOM_FILLING_MIN_DEG"
+msgstr "Min. Deg"
+
+#: GeometryGUI_FillingDlg.cxx:142
+msgid "GEOM_FILLING_MAX_DEG"
+msgstr "Max. Deg"
+
+#: GeometryGUI_FillingDlg.cxx:150
+msgid "GEOM_FILLING_TOL_2D"
+msgstr "Tol. 2D"
+
+#: GeometryGUI_FillingDlg.cxx:170
+msgid "GEOM_FILLING_COMPOUND"
+msgstr "Compound de Courbes"
+
+#: GeometryGUI_FillingDlg.cxx:184
+msgid "GEOM_FILLING_TOL_3D"
+msgstr "Tol. 3D"
+
+#: GeometryGUI_FillingDlg.cxx:192
+msgid "GEOM_FILLING_NB_ITER"
+msgstr "Nb. Iter"
+
+#: GeometryGUI_FuseDlg.cxx:48
+msgid "GEOM_FUSE_TITLE"
+msgstr "BOOLEEN : Fusionner deux Objets"
+
+#: GeometryGUI_InertiaDlg.cxx:42
+msgid "GEOM_INERTIA_TITLE"
+msgstr "Calculs d'Inertie"
+
+#: GeometryGUI_InertiaDlg.cxx:50
+msgid "GEOM_INERTIA_CONSTR"
+msgstr "Matrice Et Moments d'Inertie"
+
+#: GeometryGUI_InertiaDlg.cxx:100
+msgid "GEOM_INERTIA_I"
+msgstr "%1:1"
+
+#: GeometryGUI_InertiaDlg.cxx:182
+msgid "GEOM_INERTIA_IXYZ"
+msgstr "IX & IY & IZ"
+
+#: GeometryGUI_LineDlg.cxx:50
+msgid "GEOM_LINE_TITLE"
+msgstr "Construction d'une Ligne"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:53
+msgid "GEOM_TOLERANCE_TITLE"
+msgstr "Tolerance Maximale"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:84
+msgid "GEOM_TOLERANCE_CONSTR"
+msgstr "Object et ses Tolerances"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:121
+msgid "GEOM_TOLERANCE_FACE"
+msgstr "Face :"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:138
+msgid "GEOM_TOLERANCE_EDGE"
+msgstr "Edge :"
+
+#: GeometryGUI_MaxToleranceDlg.cxx:155
+msgid "GEOM_TOLERANCE_VERTEX"
+msgstr "Vertex :"
+
+#: GeometryGUI_MirrorDlg.cxx:52
+msgid "GEOM_MIRROR_TITLE"
+msgstr "Methode Miroir"
+
+#: GeometryGUI_OrientationDlg.cxx:46
+msgid "GEOM_ORIENTATION_TITLE"
+msgstr "Changer l'Orientation"
+
+#: GeometryGUI_OrientationDlg.cxx:134
+msgid "GEOM_ORIENTATION_OPT"
+msgstr "Renverser l'orientation avec une simulation de vecteur normal"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_PARTITION_TITLE"
+msgstr "Partition d'Objects Avec Outils"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_KEEP_OBJECT"
+msgstr "Objet garde"
+
+#: GeometryGUI_PartitionDlg.cxx:45
+msgid "GEOM_PARTITION_ORIENTATION"
+msgstr "Change l'orientation"
+
+#: GeometryGUI_PipeDlg.cxx:47
+msgid "GEOM_PIPE_TITLE"
+msgstr "Construction d'une Pipe"
+
+#: GeometryGUI_PointDlg.cxx:52
+msgid "GEOM_POINT_TITLE"
+msgstr "Construction d'un Point"
+
+#: GeometryGUI_PlaneDlg.cxx:60
+msgid "GEOM_PLANE_TITLE"
+msgstr "Construction d'un Plan"
+
+#: GeometryGUI_PlaneDlg.cxx:172
+msgid "GEOM_PLANE_PVC"
+msgstr "Point + Vecteur Coordonnes"
+
+#: GeometryGUI_PlaneDlg.cxx:133
+msgid "GEOM_PLANE_PV"
+msgstr "Point + Vecteur"
+
+#: GeometryGUI_PrismDlg.cxx:54
+msgid "GEOM_PRISM_TITLE"
+msgstr "Extruder une Shape de base"
+
+#: GeometryGUI_PrismDlg.cxx:83
+msgid "GEOM_PRISM_BSV"
+msgstr "Shape de base + Vecteur"
+
+#: GeometryGUI_PropertiesDlg.cxx:56
+msgid "GEOM_PROPERTIES_TITLE"
+msgstr "Proprietes Basiques"
+
+#: GeometryGUI_PropertiesDlg.cxx:78
+msgid "GEOM_PROPERTIES_CONSTR"
+msgstr "Objet et ses Proprietes"
+
+#: GeometryGUI_PropertiesDlg.cxx:114
+msgid "GEOM_PROPERTIES_SURFACE"
+msgstr "Surface :"
+
+#: GeometryGUI_PropertiesDlg.cxx:120
+msgid "GEOM_PROPERTIES_VOLUME"
+msgstr "Volume :"
+
+#: GeometryGUI_RevolDlg.cxx:49
+msgid "GEOM_REVOLUTION_TITLE"
+msgstr "Construction Par Revolution"
+
+#: GeometryGUI_RotationDlg.cxx:51
+msgid "GEOM_ROTATION_TITLE"
+msgstr "Rotation d'un Objet"
+
+#: GeometryGUI_ScaleDlg.cxx:52
+msgid "GEOM_SCALE_TITLE"
+msgstr "Echelle d'un Objet"
+
+#: GeometryGUI_ScaleDlg.cxx:117
+msgid "GEOM_SCALE_FACTOR"
+msgstr "Facteur d'echelle"
+
+#: GeometryGUI_SectionDlg.cxx:50
+msgid "GEOM_SECTION_TITLE"
+msgstr "BOOLEEN : Section De Deux Objets"
+
+#: GeometryGUI_SewingDlg.cxx:48
+msgid "GEOM_SEWING_TITLE"
+msgstr "Coudre des Topologies"
+
+#: GeometryGUI_ShellDlg.cxx:53
+msgid "GEOM_SHELL_TITLE"
+msgstr "Construction d'une Shell"
+
+#: GeometryGUI_ShellDlg.cxx:74
+msgid "GEOM_SHELL_LIST"
+msgstr "List de Faces Connectees"
+
+#: GeometryGUI_SphereDlg.cxx:50
+msgid "GEOM_SPHERE_TITLE"
+msgstr "Construction d'une Sphere"
+
+#: GeometryGUI_SphereDlg.cxx:113
+msgid "GEOM_SPHERE_CR"
+msgstr "Centre + rayon"
+
+#: GeometryGUI_SphereDlg.cxx:146
+msgid "GEOM_SPHERE_RO"
+msgstr "Rayon a l'origine"
+
+#: GeometryGUI_SubShapeDlg.cxx:55
+msgid "GEOM_SUBSHAPE_TITLE"
+msgstr "Selection de Sous Shapes"
+
+#: GeometryGUI_SubShapeDlg.cxx:131
+msgid "GEOM_SUBSHAPE_TYPE"
+msgstr "Type de Sous Shapes"
+
+#: GeometryGUI_SubShapeDlg.cxx:137
+msgid "GEOM_SUBSHAPE_SELECT"
+msgstr "Selectionner de Sous Shapes"
+
+#: GeometryGUI_TorusDlg.cxx:51
+msgid "GEOM_TORUS_TITLE"
+msgstr "Constructiond'un Tore"
+
+#: GeometryGUI_SuppressFacesDlg.cxx:103
+msgid "GEOM_SUPRESSFACE_TITLE"
+msgstr "Supprimer des Faces dans un Objet"
+
+#: GeometryGUI_SuppressFacesDlg.cxx:164
+msgid "GEOM_SUPRESSFACE_SELECT"
+msgstr "Selectionner les Faces a Supprimer"
+
+#: GeometryGUI_TranslationDlg.cxx:78
+msgid "GEOM_TRANSLATION_COOR"
+msgstr "Translation Avec Coordonnees"
+
+msgid "GEOM_TRANSPARENCY_TITLE"
+msgstr "Transparence"
+
+msgid "GEOM_TRANSPARENCY_OPAQUE"
+msgstr "Opaque"
+
+msgid "GEOM_TRANSPARENCY_TRANSPARENT"
+msgstr "Transparent"
+
+msgid "GEOM_SUPPRESSHOLE_TITLE"
+msgstr "Suppression de trous"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTFACE"
+msgstr "Selection de la face initiale"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTWIRE"
+msgstr "Selection du contour/trou sur la face"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTFACE_END"
+msgstr "Selection de la face terminale (si trou traversant)"
+
+msgid "GEOM_SUPPRESSHOLE_SELECTWIRE_END"
+msgstr "Selection de contour final (si trou traversant)"
+
+msgid "GEOM_SUPPRESSHOLE_FACE_SHELL"
+msgstr "Face ou shell"
+
+msgid "GEOM_SUPPRESSHOLE_SELECT_HOLES_ON_FACE"
+msgstr "Selection de trou(s) sur la face"
+
+#: GeometryGUI_TranslationDlg.cxx:56
+msgid "GEOM_TRANSLATION_TITLE"
+msgstr "Translation d'un Objet"
+
+#: GeometryGUI_VectorDlg.cxx:54
+msgid "GEOM_VECTOR_TITLE"
+msgstr "Construction d'un Vecteur"
+
+#: GeometryGUI_WhatisDlg.cxx:63
+msgid "GEOM_WHATIS_TITLE"
+msgstr "Whatis"
+
+#: GeometryGUI_WhatisDlg.cxx:86
+msgid "GEOM_WHATIS_OBJECT"
+msgstr "Objet et ses Informations Topologiques"
+
+#: GeometryGUI_WireDlg.cxx:46
+msgid "GEOM_WIRE_TITLE"
+msgstr "Creer un Wire"
+
+#: GeometryGUI_WireDlg.cxx:103
+msgid "GEOM_WIRE_CONNECT"
+msgstr "Creation d'un Wire a partir de wires/edges connectes"
+
+#: GeometryGUI_WorkingPlaneDlg.cxx:50
+msgid "GEOM_WPALNE_TITLE"
+msgstr "plan de travail"
+
+#: GeometryGUI_WorkingPlaneDlg.cxx:107
+msgid "GEOM_WPALNE_FACE"
+msgstr "Plan Ou Face plane"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_TITLE"
+msgstr "Multi-Translation"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_SIMPLE"
+msgstr "Multi Translation Simple"
+
+#: GeometryGUI_multiTranslationDlg.cxx:107
+msgid "GEOM_MULTITRANSLATION_DOUBLE"
+msgstr "Multi Translation Double"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_TITLE"
+msgstr "Multi-Rotation"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_SIMPLE"
+msgstr "Multi Rotation Simple"
+
+#: GeometryGUI_multiRotationDlg.cxx:107
+msgid "GEOM_MULTIROTATION_DOUBLE"
+msgstr "Multi Rotation Double"
+
+msgid "GEOM_PARAM_POINT"
+msgstr "Point paramétrique"
+
+#
+#==============================================================================
+#
+
+#: GeometryGUI.cxx:4613
+msgid "GEOM_MEN_WIREFRAME"
+msgstr "Filaire"
+
+#: GeometryGUI.cxx:4613
+msgid "GEOM_MEN_SHADING"
+msgstr "Ombré"
--- /dev/null
+# 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 : Makefile.in
+# Author : Marc Tajchman (CEA)
+# Module : GEOM
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= GeometryGUI_Swig.hxx \
+ GeometryGUI_Swig.i
+
+# ressources files :
+PO_FILES = \
+ GeometryGUI_icons.po \
+ GeometryGUI_msg_en.po \
+ GeometryGUI_msg_fr.po
+
+# Libraries targets
+LIB = libGeometryGUI.la
+LIB_SRC = GeometryGUI.cxx \
+ GeometryGUI_SpinBox.cxx \
+ GeometryGUI_TransparencyDlg.cxx \
+ GeometryGUI_NbIsosDlg.cxx \
+ GeometryGUI_BoxDlg.cxx \
+ GeometryGUI_ArchimedeDlg.cxx \
+ GeometryGUI_PointDlg.cxx \
+ GeometryGUI_VectorDlg.cxx \
+ GeometryGUI_PlaneDlg.cxx \
+ GeometryGUI_PrismDlg.cxx \
+ GeometryGUI_FuseDlg.cxx \
+ GeometryGUI_SectionDlg.cxx \
+ GeometryGUI_CommonDlg.cxx \
+ GeometryGUI_CutDlg.cxx \
+ GeometryGUI_LineDlg.cxx \
+ GeometryGUI_ScaleDlg.cxx \
+ GeometryGUI_MirrorDlg.cxx \
+ GeometryGUI_SphereDlg.cxx \
+ GeometryGUI_CircleDlg.cxx \
+ GeometryGUI_RevolDlg.cxx \
+ GeometryGUI_RotationDlg.cxx \
+ GeometryGUI_TranslationDlg.cxx \
+ GeometryGUI_ArcDlg.cxx \
+ GeometryGUI_PipeDlg.cxx \
+ GeometryGUI_CylinderDlg.cxx \
+ GeometryGUI_ConeDlg.cxx \
+ GeometryGUI_TorusDlg.cxx \
+ GeometryGUI_FillingDlg.cxx \
+ GeometryGUI_SewingDlg.cxx \
+ GeometryGUI_CompoundDlg.cxx \
+ GeometryGUI_EdgeDlg.cxx \
+ GeometryGUI_OrientationDlg.cxx \
+ GeometryGUI_PartitionDlg.cxx \
+ GeometryGUI_SubShapeDlg.cxx \
+ GeometryGUI_aParameterDlg.cxx \
+ GeometryGUI_WireDlg.cxx \
+ GeometryGUI_WorkingPlaneDlg.cxx \
+ GeometryGUI_PropertiesDlg.cxx \
+ GeometryGUI_InertiaDlg.cxx \
+ GeometryGUI_CenterMassDlg.cxx \
+ GeometryGUI_FaceDlg.cxx \
+ GeometryGUI_BndBoxDlg.cxx \
+ GeometryGUI_MaxToleranceDlg.cxx \
+ GeometryGUI_WhatisDlg.cxx \
+ GeometryGUI_DistanceDlg.cxx \
+ GeometryGUI_SuppressFacesDlg.cxx \
+ GeometryGUI_CheckShape.cxx \
+ GeometryGUI_FilletDlg.cxx \
+ GeometryGUI_ChamferDlg.cxx \
+ GeometryGUI_MultiTranslationDlg.cxx \
+ GeometryGUI_MultiRotationDlg.cxx \
+ GeometryGUI_Swig.cxx \
+ GeometryGUI_SuppressHoleDlg.cxx \
+
+LIB_MOC = \
+ GeometryGUI.h \
+ GeometryGUI_SpinBox.h \
+ GeometryGUI_TransparencyDlg.h \
+ GeometryGUI_NbIsosDlg.h \
+ GeometryGUI_BoxDlg.h \
+ GeometryGUI_ArchimedeDlg.h \
+ GeometryGUI_PointDlg.h \
+ GeometryGUI_VectorDlg.h \
+ GeometryGUI_PlaneDlg.h \
+ GeometryGUI_PrismDlg.h \
+ GeometryGUI_FuseDlg.h \
+ GeometryGUI_SectionDlg.h \
+ GeometryGUI_CommonDlg.h \
+ GeometryGUI_CutDlg.h \
+ GeometryGUI_LineDlg.h \
+ GeometryGUI_ScaleDlg.h \
+ GeometryGUI_MirrorDlg.h \
+ GeometryGUI_SphereDlg.h \
+ GeometryGUI_CircleDlg.h \
+ GeometryGUI_RevolDlg.h \
+ GeometryGUI_RotationDlg.h \
+ GeometryGUI_TranslationDlg.h \
+ GeometryGUI_ArcDlg.h \
+ GeometryGUI_PipeDlg.h \
+ GeometryGUI_CylinderDlg.h \
+ GeometryGUI_ConeDlg.h \
+ GeometryGUI_TorusDlg.h \
+ GeometryGUI_FillingDlg.h \
+ GeometryGUI_SewingDlg.h \
+ GeometryGUI_CompoundDlg.h \
+ GeometryGUI_EdgeDlg.h \
+ GeometryGUI_OrientationDlg.h \
+ GeometryGUI_PartitionDlg.h \
+ GeometryGUI_SubShapeDlg.h \
+ GeometryGUI_aParameterDlg.h \
+ GeometryGUI_WireDlg.h \
+ GeometryGUI_WorkingPlaneDlg.h \
+ GeometryGUI_PropertiesDlg.h \
+ GeometryGUI_InertiaDlg.h \
+ GeometryGUI_CenterMassDlg.h \
+ GeometryGUI_FaceDlg.h \
+ GeometryGUI_BndBoxDlg.h \
+ GeometryGUI_MaxToleranceDlg.h \
+ GeometryGUI_WhatisDlg.h \
+ GeometryGUI_DistanceDlg.h \
+ GeometryGUI_SuppressFacesDlg.h \
+ GeometryGUI_CheckShape.h \
+ GeometryGUI_FilletDlg.h \
+ GeometryGUI_ChamferDlg.h \
+ GeometryGUI_MultiTranslationDlg.h \
+ GeometryGUI_MultiRotationDlg.h \
+ GeometryGUI_SuppressHoleDlg.h
+
+LIB_CLIENT_IDL = SALOME_Exception.idl \
+ GEOM_Gen.idl \
+ GEOM_Shape.idl \
+ SALOMEDS.idl \
+ SALOMEDS_Attributes.idl \
+ SALOME_ModuleCatalog.idl \
+ SALOME_Component.idl \
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+
+CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS)
+
+LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lGeometryClient -lGeometryObject -lGeometryFiltersSelection -lGeometrySketcher $(OCC_LIBS)
+
+@CONCLUDE@
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : GEOM_Partition1.py
+# Module : GEOM
+
+#%Make geometry (like CEA script (A1)) using Partition algorithm%
+# appel:
+# import alveole_3D_01_GEOM
+# reload(alveole_3D_01_GEOM)
+
+# -- Rayon de la bariere
+
+barier_height = 7.0
+barier_radius = 5.6 / 2 # Rayon de la bariere
+colis_radius = 1.0 / 2 # Rayon du colis
+colis_step = 2.0 # Distance s\89parant deux colis
+cc_width = 0.11 # Epaisseur du complement de colisage
+
+# --
+
+cc_radius = colis_radius + cc_width
+from math import sqrt
+colis_center = sqrt(2.0)*colis_step/2
+
+# --
+
+import geompy
+geom = geompy.geom
+
+boolean_common = 1
+boolean_cut = 2
+boolean_fuse = 3
+boolean_section = 4
+
+# --
+
+barier = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+ barier_radius,
+ barier_height)
+
+# --
+
+colis = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+ colis_radius,
+ barier_height)
+
+cc = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+ cc_radius,
+ barier_height)
+
+colis_cc = geompy.MakeCompound(
+ [colis._get_Name(), cc._get_Name()])
+
+colis_cc = geompy.MakeTranslation(
+ colis_cc, colis_center, 0.0, 0.0)
+
+colis_cc_multi = geompy.MakeMultiRotation1D(
+ colis_cc,
+ geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)),
+ geom.MakePointStruct(0.,0.,0.),
+ 4)
+
+# --
+
+alveole = geompy.Partition(
+ [colis_cc_multi._get_Name(), barier._get_Name()])
+
+subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] )
+
+## there are 9 subshapes
+
+comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] );
+comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] );
+comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] );
+comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] );
+
+compIORs = []
+compIORs.append( comp1._get_Name() );
+compIORs.append( comp2._get_Name() );
+compIORs.append( comp3._get_Name() );
+compIORs.append( comp4._get_Name() );
+comp = geompy.MakeCompound( compIORs );
+
+alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]);
+
+geompy.addToStudy(alveole, "alveole")
+
+
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : GEOM_Partition2.py
+# Module : GEOM
+
+#%Make geometry (like CEA script (A2)) using Partition algorithm%
+# import callovo_01_GEOM
+# reload(callovo_01_GEOM)
+
+
+# --------------------------------------------
+# Geometrie avec une galerie perpendiculaire
+# --------------------------------------------
+
+import geompy
+geom = geompy.geom
+
+# -- colis
+
+colis_xmin = 05.76
+colis_xmax = 19.83
+colis_radius = 0.3
+
+colis = geompy.MakeCylinder(
+ geom.MakePointStruct(colis_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ colis_radius,
+ colis_xmax-colis_xmin)
+
+# -- bo
+
+bo_xmin = 04.83
+bo_xmax = colis_xmax
+bo_radius = 1.23
+
+bo = geompy.MakeCylinder(
+ geom.MakePointStruct(bo_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ bo_radius,
+ bo_xmax-bo_xmin)
+
+
+# -- rupture alveole
+
+alvRup_xmin = 04.46
+alvRup_xmax = colis_xmax
+alvRup_radius = 1.6
+
+alvRup = geompy.MakeCylinder(
+ geom.MakePointStruct(alvRup_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ alvRup_radius,
+ alvRup_xmax-alvRup_xmin)
+
+
+# bouchon
+
+bouchon_xmin = colis_xmax
+bouchon_xmax = 22.83
+bouchon_radius = alvRup_radius
+
+bouchon = geompy.MakeCylinder(
+ geom.MakePointStruct(bouchon_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ bouchon_radius,
+ bouchon_xmax-bouchon_xmin)
+
+# galerie
+
+galerie_xmax = 25.0
+galerie_radius = 3.0
+box_y = 30.0
+
+galerie = geompy.MakeCylinder(
+ geom.MakePointStruct(galerie_xmax,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ galerie_radius,
+ box_y)
+galerie = geompy.MakeTranslation(galerie, 0, -box_y/2, 0)
+
+# -- box
+
+box = geompy.MakeBox(0., 0., 0., galerie_xmax, box_y, box_y)
+box = geompy.MakeTranslation(box, 0.0, -box_y/2, -box_y/2)
+
+
+# -- rupture galerie
+
+galRup_xmax = galerie_xmax
+galRup_radius = 3.9
+
+galRup = geompy.MakeCylinder(
+ geom.MakePointStruct(galerie_xmax,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ galRup_radius,
+ box_y)
+galRup = geompy.MakeTranslation(galRup, 0, -box_y/2, 0)
+
+# -- endommagement galerie
+
+galEnd_xmax = galerie_xmax
+galEnd_radius = 4.6
+
+galEnd = geompy.MakeCylinder(
+ geom.MakePointStruct(galerie_xmax,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ galEnd_radius,
+ box_y)
+galEnd = geompy.MakeTranslation(galEnd, 0, -box_y/2, 0)
+
+# -- endommagement alveole
+
+alvEnd_xmin = 03.6
+alvEnd_xmax = galerie_xmax
+alvEnd_radius = 2.46
+
+alvEnd = geompy.MakeCylinder(
+ geom.MakePointStruct(alvEnd_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ alvEnd_radius,
+ alvEnd_xmax-alvEnd_xmin)
+
+# remove internal parts of galEnd intersecting alvEnd
+
+galEnd_alvEnd = geompy.Partition(
+ [ alvEnd._get_Name() ] , [], [], [ galEnd._get_Name() ] )
+
+iorL = [ colis._get_Name() ]
+iorL += [ bo._get_Name() ]
+iorL += [ alvRup._get_Name() ]
+#iorL += [ galerie._get_Name() ]
+iorL += [ galRup._get_Name() ]
+iorL += [ galEnd_alvEnd._get_Name() ]
+
+# --
+
+# remove section parts outside bo and inside bouchon
+
+callovo = geompy.Partition(
+ iorL, [], [ box._get_Name() ], [galerie._get_Name(), bouchon._get_Name()] )
+
+
+
+geompy.addToStudy(callovo, "callovo perp. 2")
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : GEOM_Partition3.py
+# Module : GEOM
+
+#%Make geometry (like CEA script (A2)) using Partition algorithm%
+# import callovo_01_GEOM
+# reload(callovo_01_GEOM)
+
+
+import geompy
+geom = geompy.geom
+
+# -- colis
+
+colis_xmin = 05.76
+colis_xmax = 19.83
+colis_radius = 0.3
+
+colis = geompy.MakeCylinder(
+ geom.MakePointStruct(colis_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ colis_radius,
+ colis_xmax-colis_xmin)
+
+iorL = [colis._get_Name()]
+
+# -- bo
+
+bo_xmin = 04.83
+bo_xmax = colis_xmax
+bo_radius = 1.23
+
+bo = geompy.MakeCylinder(
+ geom.MakePointStruct(bo_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ bo_radius,
+ bo_xmax-bo_xmin)
+
+iorL.append(bo._get_Name())
+
+# -- rupture alveole
+
+alvRup_xmin = 04.46
+alvRup_xmax = colis_xmax
+alvRup_radius = 1.6
+
+alvRup = geompy.MakeCylinder(
+ geom.MakePointStruct(alvRup_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ alvRup_radius,
+ alvRup_xmax-alvRup_xmin)
+
+iorL.append(alvRup._get_Name())
+
+# bouchon
+
+bouchon_xmin = colis_xmax
+bouchon_xmax = 22.83
+bouchon_radius = alvRup_radius
+
+bouchon = geompy.MakeCylinder(
+ geom.MakePointStruct(bouchon_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ bouchon_radius,
+ bouchon_xmax-bouchon_xmin)
+
+#iorL.append(bouchon._get_Name())
+
+# -- endommagement alveole
+
+alvEnd_xmin = 03.6
+alvEnd_xmax = 20.66
+alvEnd_radius = 2.46
+
+alvEnd = geompy.MakeCylinder(
+ geom.MakePointStruct(alvEnd_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ alvEnd_radius,
+ alvEnd_xmax-alvEnd_xmin)
+
+iorL.append(alvEnd._get_Name())
+
+# galerie
+
+galerie_xmin = bouchon_xmax
+galerie_xmax = 25.0
+galerie_radius = 2.17
+
+galerie = geompy.MakeCylinder(
+ geom.MakePointStruct(galerie_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ galerie_radius,
+ galerie_xmax-galerie_xmin)
+
+iorL.append(galerie._get_Name())
+
+# -- rupture galerie
+
+galRup_xmin = 22.18
+galRup_xmax = galerie_xmax
+galRup_radius = 2.82
+
+galRup = geompy.MakeCylinder(
+ geom.MakePointStruct(galRup_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ galRup_radius,
+ galRup_xmax-galRup_xmin)
+
+iorL.append(galRup._get_Name())
+
+# -- endom. galerie
+
+galEnd_xmin = alvEnd_xmax
+galEnd_xmax = galerie_xmax
+galEnd_radius = 4.34
+
+galEnd = geompy.MakeCylinder(
+ geom.MakePointStruct(galEnd_xmin,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(1.,0.,0.)),
+ galEnd_radius,
+ galEnd_xmax-galEnd_xmin)
+
+iorL.append(galEnd._get_Name())
+
+# --
+
+box_y = 30.0
+box = geompy.MakeBox(0., 0., 0., galerie_xmax, box_y, box_y)
+box = geompy.MakeTranslation(box, 0.0, -box_y/2, -box_y/2)
+
+iorL.append(box._get_Name())
+
+# --
+
+callovo = geompy.Partition(iorL,[],[], [bouchon._get_Name()])
+geompy.addToStudy(callovo, "callovo 2")
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : GEOM_Partition4.py
+# Module : GEOM
+
+#%Make geometry (like CEA script (A3)) using Partition algorithm%
+# import couplex2_01_GEOM
+# reload(couplex2_01_GEOM)
+
+# Dimensions de alveolus
+# Parall\89pip\88de rectangle de taille alDx, alDy, alDz
+
+alDx = 2.5
+alDy = 20.0
+alDz = 2.5
+alSepx = 18.0
+
+# Dimensions de backfill
+# Parall\89pip\88de rectangle de taille baDx, baDy, baDz
+
+baDx = 27.0
+baDy = 4.8
+baDz = 4.8
+
+# Dimensions de geological medium
+
+gmDx = baDx
+gmDy = 49.6
+gmDz = 100.0
+
+# --
+
+import geompy
+geom = geompy.geom
+
+# -- Construction de backfill
+
+backA = geompy.MakeBox(0.0,0.0,0.0,baDx,baDy,baDz)
+back = geompy.MakeTranslation(backA,-baDx/2,-baDy/2,-baDz/2)
+
+# -- Construction de alveolus
+
+import math
+
+alveA = geompy.MakeBox(0.0,0.0,0.0,alDx,alDy,alDz)
+alveB = geompy.MakeTranslation(alveA,-alDx/2,baDy/2,-alDz/2)
+axis = geompy.geom.MakeAxisStruct(0.0,0.0,0.0,1.0,0.0,0.0)
+alve1 = geompy.MakeRotation(alveB,axis,math.pi)
+alve2 = geompy.MakeTranslation(alveB,+alSepx/2,0.0,0.0)
+alve3 = geompy.MakeTranslation(alveB,-alSepx/2,0.0,0.0)
+IORlist = []
+IORlist.append(alve1._get_Name())
+IORlist.append(alve2._get_Name())
+IORlist.append(alve3._get_Name())
+alve = geompy.MakeCompound(IORlist)
+
+# -- Construction de geological medium
+
+geolA = geompy.MakeBox(0.0,0.0,0.0,gmDx,gmDy,gmDz)
+geol = geompy.MakeTranslation(geolA,-gmDx/2,-gmDy/2,-gmDz/2)
+
+geol = geompy.Partition(
+ [alve._get_Name(), geol._get_Name(), back._get_Name()])
+
+subshapes = geompy.SubShapeAll( geol, geompy.ShapeType["SHAPE"] )
+
+IORlist = []
+IORlist.append(subshapes[0]._get_Name())
+IORlist.append(subshapes[1]._get_Name())
+IORlist.append(subshapes[2]._get_Name())
+alve = geompy.MakeCompound(IORlist)
+
+geol = subshapes[3]
+back = subshapes[4]
+
+# --
+
+geol = geompy.MakeCompound(
+ [geol._get_Name(), back._get_Name(), alve._get_Name()])
+
+geompy.addToStudy(geol,"couplex2 2")
+
+
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : GEOM_Partition5.py
+# Module : GEOM
+
+#%Make geometry (like CEA script (A4)) using Partition algorithm%
+# import gallery_01_GEOM
+# reload(gallery_01_GEOM)
+
+# -- Import geompy pour piloter GEOM par script
+
+import geompy
+geom = geompy.geom
+
+# -- Dimensions de la boite enti\88re
+
+LX, LY, LZ = 300.0, 150.0, 150.0
+
+# -- D\89finition du plan de sym\89trie (O,Ox,Oz)
+
+symPlane = geompy.MakePlane (
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ 10.0 )
+
+# -- bo
+
+bo = geompy.MakeBox(0.0,0.0,0.0,LX,LY,LZ)
+bo = geompy.MakeTranslation(bo,0.0,-LY/2,-LZ/2)
+
+# -- Galerie principale
+
+gal_diam = 80.0
+gal_lony = LY
+gal_x = LX-20.0-gal_diam/2
+gal = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ gal_diam/2,gal_lony)
+gal = geompy.MakeTranslation(gal,gal_x,-gal_lony/2,0.0)
+
+# -- Galerie perpendiculaire
+# -- Dimensions de la galerie perpendiculaire
+# -- La longueur est compt\89e \80 partir du centre
+# -- de la galerie principale
+
+gpe_long, gpe_diam = 200.0, 60.0
+gpe_x = gal_x
+gpe = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(-1.,0.,0.)),
+ gpe_diam/2,gpe_long)
+gpe = geompy.MakeTranslation(gpe,gpe_x,0,0)
+
+# -- Dimensions d'une alveole
+# -- Construction d'une alv\89ole
+
+alv_long, alv_diam = 60.0, 18.0
+alv01 = geompy.MakeCylinder(
+ geom.MakePointStruct(0.,0.,0.),
+ geom.MakeDirection(geom.MakePointStruct(0.,1.,0.)),
+ alv_diam/2,alv_long)
+alv02 = geompy.MakeMirrorByPlane(alv01,symPlane)
+alv0 = geompy.MakeCompound( [ alv01._get_Name(), alv02._get_Name() ] )
+
+# -- Construction des alv\89oles
+
+alv_del, alv_sep = 40.0, 35.0
+alv1 = geompy.MakeTranslation (
+ alv0,gal_x-gal_diam/2-alv_sep,0.0,0.0 )
+alv2 = geompy.MakeTranslation (
+ alv1,-alv_del,0.0,0.0 )
+alv3 = geompy.MakeTranslation (
+ alv2,-alv_del,0.0,0.0 )
+alv = geompy.MakeCompound( [ alv1._get_Name(), alv2._get_Name(), alv3._get_Name() ] )
+
+# -- Remplissage de la BO
+
+gallery = geompy.Partition(
+ [ alv._get_Name(), bo._get_Name() ], [], [], [ gal._get_Name(), gpe._get_Name() ])
+
+subshapes = geompy.SubShapeAll( gallery, geompy.ShapeType["SHAPE"] )
+
+alvIORs = []
+alvIORs.append( subshapes[0]._get_Name() )
+alvIORs.append( subshapes[1]._get_Name() )
+alvIORs.append( subshapes[2]._get_Name() )
+alvIORs.append( subshapes[3]._get_Name() )
+alvIORs.append( subshapes[4]._get_Name() )
+alvIORs.append( subshapes[5]._get_Name() )
+alvcomp = geompy.MakeCompound( alvIORs )
+
+boIOR = subshapes[6]._get_Name()
+galIOR = subshapes[7]._get_Name()
+gpeIOR = subshapes[8]._get_Name()
+
+gallery = geompy.MakeCompound( [ boIOR, alvcomp._get_Name(), gpeIOR, galIOR ] )
+
+geompy.addToStudy(gallery,"Gallery 2")
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_example.py
+# Author : Paul RASCLE, EDF
+# Module : GEOM
+# $Header$
+
+import salome
+import geompy
+
+ind = 0
+boxlist = []
+while ind < 5:
+ x1 = 10. * ind
+ y1 = 0.
+ z1 = 0.
+ x2 = 10. * (ind+1)
+ y2 = 20. * (ind+1)
+ z2 = 30. * (ind+1)
+ print x1, y1, z1, x2, y2, z2
+ name = "box%d"%(ind)
+ box = geompy.MakeBox(x1, y1, z1, x2, y2, z2)
+ id_box = geompy.addToStudy(box, name)
+ boxlist.append(box)
+ ind = ind +1
+
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_example2.py
+# Author : Paul RASCLE, EDF
+# Module : GEOM
+# $Header$
+
+import salome
+import geompy
+import math
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+
+point0 = geom.MakePointStruct(0.,0.,0.)
+pointz1 = geom.MakePointStruct(0.,0.,1.)
+dirz = geom.MakeDirection(pointz1)
+
+torus1 = geompy.MakeTorus(point0,dirz,150.,25.)
+id_torus1 = geompy.addToStudy(torus1,"torus1")
+
+torus2 = geom.MakeCopy(torus1)
+torus2 = geom.MakeTranslation(torus2,0.,0.,100.)
+id_torus2 = geompy.addToStudy(torus2,"torus2")
+
+cylz1 = geompy.MakeCylinder(point0,dirz,25.,100.)
+
+ind = 0
+cyllist = []
+while ind < 6:
+ acyl = geom.MakeCopy(cylz1)
+ x = 150. * math.cos(ind * math.pi/3.)
+ y = 150. * math.sin(ind * math.pi/3.)
+ z = 0.
+ name = "cyl%d"%(ind)
+ acyl = geompy.MakeTranslation(acyl,x,y,z)
+ id_acyl = geompy.addToStudy(acyl,name)
+ cyllist.append(acyl)
+ ind = ind +1
+
+
+
+
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_example3.py
+# Author : Paul RASCLE, EDF
+# Module : GEOM
+# $Header$
+
+import salome
+import geompy
+import math
+from time import sleep
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+
+gg = salome.ImportComponentGUI("Geometry")
+
+point0 = geom.MakePointStruct(0.,0.,0.)
+pointz1 = geom.MakePointStruct(0.,0.,1.)
+dirz = geom.MakeDirection(pointz1)
+
+torus1 = geompy.MakeTorus(point0,dirz,150.,25.)
+id_torus1 = geompy.addToStudy(torus1,"torus1")
+gg.createAndDisplayGO(id_torus1)
+
+torus2 = geom.MakeCopy(torus1)
+torus2 = geom.MakeTranslation(torus2,0.,0.,100.)
+id_torus2 = geompy.addToStudy(torus2,"torus2")
+gg.createAndDisplayGO(id_torus2)
+
+cylz1 = geompy.MakeCylinder(point0,dirz,25.,100.)
+
+ind = 0
+shapeList = []
+idList = []
+while ind < 6:
+ acyl = geom.MakeCopy(cylz1)
+ x = 150. * math.cos(ind * math.pi/3.)
+ y = 150. * math.sin(ind * math.pi/3.)
+ z = 0.
+ name = "cyl%d"%(ind)
+ acyl = geompy.MakeTranslation(acyl,x,y,z)
+ id_acyl = geompy.addToStudy(acyl,name)
+ gg.createAndDisplayGO(id_acyl)
+ shapeList.append(acyl)
+ idList.append(id_acyl)
+ ind = ind +1
+
+shapeList.append(torus1)
+shapeList.append(torus2)
+idList.append(id_torus1)
+idList.append(id_torus2)
+
+iorStringList = []
+for shape in shapeList:
+ iorStringList.append(shape._get_Name())
+
+cage = geompy.MakeCompound(iorStringList)
+id_cage = geompy.addToStudy(cage,"cage")
+gg.createAndDisplayGO(id_cage)
+
+from salome import sg
+sleep(1)
+sg.EraseAll()
+for id in idList:
+ sg.DisplayOnly(id)
+ sleep(1)
+sg.EraseAll()
+for id in idList:
+ sg.Display(id)
+ sleep(1)
+for id in idList:
+ sg.Erase(id)
+ sleep(1)
+
+#sg.Display(id_cage)
+sg.Display(id_torus1)
+sg.Display(id_torus2)
+sg.Display(id_acyl)
+
+gg.setTransparency(id_torus1,0.5)
+
+gg.setDisplayMode(id_torus1,1)
+gg.setDisplayMode(id_torus2,1)
+gg.setDisplayMode(id_acyl,1)
+#gg.setDisplayMode(id_cage,1)
+
+gg.setColor(id_torus1,0,0,255)
+gg.setColor(id_torus2,255,0,0)
+gg.setColor(id_acyl,0,255,0)
+#gg.setColor(id_cage,255,255,0)
\ No newline at end of file
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_example4.py
+# Module : GEOM
+
+import SMESH
+import smeshpy
+import salome
+from salome import sg
+import math
+#import SMESH_BasicHypothesis_idl
+
+import geompy
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+from geompy import gg
+
+smeshgui = salome.ImportComponentGUI("SMESH")
+smeshgui.Init(salome.myStudyId);
+
+ShapeTypeCompSolid = 1
+ShapeTypeSolid = 2
+ShapeTypeShell = 3
+ShapeTypeFace = 4
+ShapeTypeWire = 5
+ShapeTypeEdge = 6
+ShapeTypeVertex = 7
+
+pi=math.pi
+
+# ---------------------------------------------
+xa=math.sin(pi/12)
+ya=0
+za=math.cos(pi/12)
+
+xb=0
+yb=math.sin(pi/18)
+zb=math.cos(pi/18)
+
+xc=math.cos(-pi/18)
+yc=0
+zc=math.sin(-pi/18)
+
+rc1=150
+hc1=300
+rc2=150
+rc3=150
+rc4=300
+# ---------------------------------------------
+point_0 = geom.MakePointStruct(0, 0, 0)
+point_z = geom.MakePointStruct(0, 0, 1)
+
+point_a = geom.MakePointStruct(xa, ya, za)
+point_b = geom.MakePointStruct(xb, yb, zb)
+point_c = geom.MakePointStruct(xc, yc, zc)
+
+dir_z = geom.MakeDirection(point_z)
+axe_z = geom.MakeAxisStruct(0, 0, 0, 0, 0, 1)
+
+dir_a = geom.MakeDirection(point_a)
+axe_a = geom.MakeAxisStruct(0, 0, 0, xa, ya, za)
+
+dir_b = geom.MakeDirection(point_b)
+axe_b = geom.MakeAxisStruct(0, 0, 0, xb, yb, zb)
+
+dir_c = geom.MakeDirection(point_c)
+axe_c = geom.MakeAxisStruct(0, 0, 0, xc, yc, zc)
+
+cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1)
+
+hc2=2*hc1
+cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2)
+cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1)
+
+hc3=2*hc1
+cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3)
+cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1)
+
+hc4=2*hc1
+cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4)
+cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2)
+cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0)
+cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4)
+
+inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common
+
+blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut
+blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2)
+
+blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common
+
+idblob = geompy.addToStudy(blob,"blob")
+#idc = geompy.addToStudy(cyl_c,"cyl_c")
+#idd = geompy.addToStudy(cyl_d,"cyl_d")
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_moteur.py
+# Author : Damien COQUERET, Open CASCADE
+# Module : GEOM
+# $Header$
+
+import salome
+import geompy
+import math
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+
+#Variables modifiables
+PosX = 0 #Position du cylindre dans l'espace
+PosY = 0 #Il est oriente suivant Z
+PosZ = 0
+NbBranches = 7 #>2
+HauteurT = 70 #Hauteur total du stator
+
+#Varaibles
+Angle1 = 2 * math.pi / NbBranches
+Angle2 = Angle1 / 2
+HauteurR = HauteurT / 3
+Ep = HauteurT / 10
+DExtExt = HauteurT * 6 / 7
+DExtInt = DExtExt - Ep
+DIntExt = DExtExt / 3
+DIntInt = DExtExt / 4
+EpRot = DIntExt * math.sin(Angle2)
+Pos1C = PosX + DIntExt * math.cos(Angle2)
+Pos1S = PosY + DIntExt * math.sin(Angle2)
+PosCour = PosZ + HauteurT * 4 / 7
+PosRot = PosZ + 0.9 * HauteurT
+
+#Points
+P0 = geom.MakePointStruct(0, 0, 1)
+P1 = geom.MakePointStruct(PosX, PosY, PosZ)
+P2 = geom.MakePointStruct(PosX, PosY, PosZ + Ep)
+P3 = geom.MakePointStruct(PosX, PosY, PosCour)
+P4 = geom.MakePointStruct(PosX, PosY, PosCour + Ep)
+P5 = geom.MakePointStruct(PosX, PosY, PosRot)
+P6 = geom.MakePointStruct(Pos1C, Pos1S, PosZ)
+P7 = geom.MakePointStruct(PosX + DExtExt, Pos1S, PosZ)
+P8 = geom.MakePointStruct(Pos1C, Pos1S, PosZ + HauteurT)
+
+#Vecteurs
+V1 = geom.MakeDirection(P0)
+V2 = geom.MakeAxisStruct(PosX, PosY, PosZ, 0, 0, 1)
+V3 = geom.MakeAxisStruct(Pos1C, Pos1S, PosZ, 0, 0, 1)
+
+#Cylindre central
+C0 = geompy.MakeCylinder(P1, V1, DIntInt, PosCour + Ep - PosZ)
+C01 = geompy.MakeCylinder(P1, V1, DIntExt, PosCour + Ep - PosZ)
+Cylindre = geompy.MakeBoolean(C01, C0, 2)
+#Id_Cyl = geompy.addToStudy(Cylindre, "Cylindre")
+
+#Camemberts de coupe
+B1 = geompy.MakeVector(P6, P7)
+B2 = geompy.MakePrism(B1, P6, P8)
+S0 = geompy.MakeRevolution(B2, V3, Angle1)
+CoupeList = []
+CoupeList.append(S0)
+Ind = 1
+while Ind < NbBranches :
+ S = geompy.MakeRotation(S0, V2, Ind * Angle1)
+ CoupeList.append(S)
+ Ind = Ind + 1
+IorCoupeList = []
+for CoupeShape in CoupeList :
+ IorCoupeList.append(CoupeShape._get_Name())
+Coupe1 = geompy.MakeCompound(IorCoupeList)
+#Id_Coupe1 = geompy.addToStudy(Coupe1, "Coupe1")
+
+#Couronne1
+C1 = geompy.MakeCylinder(P1, V1, DExtExt, HauteurT)
+C2 = geompy.MakeCylinder(P2, V1, DExtInt, HauteurT)
+C3 = geompy.MakeBoolean(C1, C2, 2)
+C31 = geompy.MakeBoolean(C3, C0, 2)
+Couronne1 = geompy.MakeBoolean(C31, Coupe1, 2)
+#Id_Couronne1 = geompy.addToStudy(Couronne1, "Couronne1")
+
+#Couronne2
+C4 = geompy.MakeCylinder(P3, V1, DExtExt, PosZ + HauteurT - PosCour)
+C5 = geompy.MakeCylinder(P4, V1, DExtInt, HauteurT)
+Coupe2 = geompy.MakeRotation(Coupe1, V2, Angle2)
+C6 = geompy.MakeBoolean(C4, C5, 2)
+C61 = geompy.MakeBoolean(C6, C0, 2)
+Couronne2 = geompy.MakeBoolean(C61, Coupe2, 2)
+#Id_Couronne2 = geompy.addToStudy(Couronne2, "Couronne2")
+
+#Rotor1
+C9 = geompy.MakeCylinder(P5, V1, DIntExt, HauteurR)
+C10 = geompy.MakeCylinder(P5, V1, DIntExt / 4, 2 * HauteurR)
+Rotor1List = []
+Rotor1List.append(C9)
+Rotor1List.append(C10)
+IorRotor1List = []
+for Rotor1Shape in Rotor1List :
+ IorRotor1List.append(Rotor1Shape._get_Name())
+Rotor1 = geompy.MakeCompound(IorRotor1List)
+Id_Rotor1 = geompy.addToStudy(Rotor1, "Rotor1")
+
+#Rotor2
+D0 = geompy.MakeBox(2 * Pos1C - PosX, -Pos1S + 2 * PosY, PosRot, 2 * Pos1C + EpRot - PosX, Pos1S, PosRot + EpRot / 2)
+Rotor2List = []
+Rotor2List.append(D0)
+Ind = 1
+while Ind < NbBranches :
+ R = geompy.MakeRotation(D0, V2, Ind * Angle1)
+ Rotor2List.append(R)
+ Ind = Ind + 1
+IorRotor2List = []
+for Rotor2Shape in Rotor2List :
+ IorRotor2List.append(Rotor2Shape._get_Name())
+Rotor2 = geompy.MakeCompound(IorRotor2List)
+Id_Rotor2 = geompy.addToStudy(Rotor2, "Rotor2")
+
+#Rotor3
+Rotor3 = geompy.MakeRotation(Rotor2, V2, Angle2)
+Id_Rotor3 = geompy.addToStudy(Rotor3, "Rotor3")
+
+#Stator
+StatorList = []
+StatorList.append(Cylindre)
+StatorList.append(Couronne1)
+StatorList.append(Couronne2)
+IorStatorList = []
+for StatorShape in StatorList :
+ IorStatorList.append(StatorShape._get_Name())
+Stator = geompy.MakeCompound(IorStatorList)
+Id_Stator = geompy.addToStudy(Stator, "Stator")
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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_usinggeom.py
+# Author : Damien COQUERET, Open CASCADE
+# Module : GEOM
+# $Header$
+
+import salome
+import geompy
+import math
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+myBuilder = salome.myStudy.NewBuilder()
+
+from geompy import gg
+
+#Create base Variables
+nbtimes1 = 5 #Short
+nbtimes2 = 5
+mindeg = 2
+maxdeg = 5
+nbiter = 5
+ShapeTypeFace = 4
+ShapeTypeEdge = 6
+WantPlanarFace = 1 #True
+
+radius = 10. #Double
+radius1 = 100.
+radius2 = 200.
+height = 200.
+d1 = 10.
+d2 = 10.
+step1 = 250.
+step2 = 250.
+angle = 45.
+angle1 = angle * math.pi / 180
+angle2 = 2 * angle1
+factor = 2.
+tol3d = 0.0001
+tol2d = 0.0001
+weight = 1000000.
+waterdensity = 1.
+meshingdeflection = 0.01
+trimsize = 1000.
+precision = 0.00001
+
+#Create base points
+p0 = geom.MakePointStruct(0., 0., 0.) #(Double, Double, Double)->PointStruct
+px = geom.MakePointStruct(100., 0., 0.)
+py = geom.MakePointStruct(0., 100., 0.)
+pz = geom.MakePointStruct(0., 0., 100.)
+pxyz = geom.MakePointStruct(100., 100., 100.)
+
+#Create base directions
+vx = geom.MakeDirection(px) #(PointStruct)->DirStruct
+vy = geom.MakeDirection(py)
+vz = geom.MakeDirection(pz)
+vxyz = geom.MakeDirection(pxyz)
+ax = geom.MakeAxisStruct(0., 0., 0., 100., 0., 0.) #(Double, Double, Double, Double, Double, Double)->AxisStruct
+axy = geom.MakeAxisStruct(100., 0., 0., -100., 100., 0.)
+ay = geom.MakeAxisStruct(0., 0., 0., 0., 100., 0.)
+az = geom.MakeAxisStruct(0., 0., 0., 0., 0., 100.)
+
+#Create base geometry 2D
+Vertex = geom.MakeVertex(100., 50., 200.) #(Double, Double, Double)->GEOM_Shape_ptr
+Vector = geom.MakeVector(px, py) #(PointStruct, PointStruct)->GEOM_Shape_ptr
+Line = geom.MakeLine(p0, vxyz) #(PointStruct, DirStruct)->GEOM_Shape_ptr
+Arc = geom.MakeArc(py, pz, px) #(PointStruct, PointStruct, PointStruct)->GEOM_Shape_ptr
+Circle = geom.MakeCircle(p0, vz, radius1) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr
+Plane = geom.MakePlane(pz, vxyz, trimsize) #(PointStruct, DirStruct, Double)->GEOM_Shape_ptr
+
+#Create base geometry 3D
+Box = geompy.MakeBox(0., 0., 0., 200., 200., 200.) #(Double, Double, Double)->GEOM_Shape_ptr
+Cylinder = geompy.MakeCylinder(p0, vz, radius1, height) #(Double, Double, Double)->GEOM_Shape_ptr
+Sphere = geompy.MakeSphere(0., 0., 0., radius1) #(Double, Double, Double)->GEOM_Shape_ptr
+Cone = geompy.MakeCone(p0, vz, radius2, radius, height) #(PointStruct)->DirStruct
+Torus = geompy.MakeTorus(p0, vz, radius2, radius) #(Double, Double, Double)->GEOM_Shape_ptr
+
+#Boolean (Common, Cut, Fuse, Section)
+Common = geompy.MakeBoolean(Box, Sphere, 1) #(GEOM_Shape_ptr, GEOM_Shape_ptr, Short)->GEOM_Shape_ptr
+Cut = geompy.MakeBoolean(Box, Sphere, 2)
+Fuse = geompy.MakeBoolean(Box, Sphere, 3)
+Section = geompy.MakeBoolean(Box, Sphere, 4)
+
+#IORList for Wire
+ShapeListWire = []
+IORListWire = []
+ShapeListWire.append(Vector)
+ShapeListWire.append(Arc)
+for Shape in ShapeListWire :
+ IORListWire.append(Shape._get_Name())
+
+#IORList for Compound
+ShapeListCompound = []
+IORListCompound = []
+i = 0
+while i <= 3 :
+ S = geompy.MakeTranslation(Arc, i * 100., i * 100., i * 100.)
+ ShapeListCompound.append(S)
+ i = i + 1
+for Shape in ShapeListCompound :
+ IORListCompound.append(Shape._get_Name())
+
+#Create base objects
+Edge = geompy.MakeEdge(p0, pxyz) #(PointStruct, PointStruct)->GEOM_Shape_ptr
+Wire = geompy.MakeWire(IORListWire) #(ListOfIOR)->GEOM_Shape_ptr
+Face = geompy.MakeFace(Wire, WantPlanarFace) #(GEOM_Shape_ptr, Boolean)->GEOM_Shape_ptr
+Compound = geompy.MakeCompound(IORListCompound) #(ListOfIOR)->GEOM_Shape_ptr
+
+#IORList for Sewing
+ShapeListSewing = []
+IORListSewing = []
+ShapeListSewing.append(Face)
+S = geompy.MakeRotation(Face, axy, angle1)
+ShapeListSewing.append(S)
+for Shape in ShapeListSewing :
+ IORListSewing.append(Shape._get_Name())
+
+#Create advanced objects
+Copy = geompy.MakeCopy(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
+Prism = geompy.MakePrism(Face, p0, pz) #(GEOM_Shape_ptr, PointStruct, PointStruct)->GEOM_Shape_ptr
+#Revolution = geompy.MakeRevolution(Face, az, angle2) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr
+Filling = geompy.MakeFilling(Compound, mindeg, maxdeg, tol3d, tol2d, nbiter) #(GEOM_Shape_ptr, Short, Short, Double, Double, Short)->GEOM_Shape_ptr
+Pipe = geompy.MakePipe(Edge, Wire) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr
+Sewing = geompy.MakeSewing(IORListSewing, precision) #(ListOfIOR, Double)->GEOM_Shape_ptr
+
+#IDList for Fillet/Chamfer
+IDlist = []
+i = 1
+while i <= 3 :
+ IDlist.append(i)
+ i = i + 1
+
+#Transform objects
+Translation = geompy.MakeTranslation(Box, 300., 300., 300.) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr
+Rotation = geompy.MakeRotation(Box, az, angle1) #(GEOM_Shape_ptr, AxisStruct, Double)->GEOM_Shape_ptr
+Scale = geompy.MakeScaleTransform(Box, p0, factor) #(GEOM_Shape_ptr, PointStruct, Double)->GEOM_Shape_ptr
+Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(GEOM_Shape_ptr, GEOM_Shape_ptr)->GEOM_Shape_ptr
+Orientation = geompy.OrientationChange(Box) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
+Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr
+Chamfer = geompy.MakeChamfer(Prism, d1, d2, ShapeTypeEdge, IDlist) #(GEOM_Shape_ptr, Double, Double, Short, ListOfSubShapeID)->GEOM_Shape_ptr
+
+#Create Patterns
+MultiTrans1D = geompy.MakeMultiTranslation1D(Fillet, vz, step1, nbtimes1) #(GEOM_Shape_ptr, DirStruct, Double, Short)->GEOM_Shape_ptr
+MultiTrans2D = geompy.MakeMultiTranslation2D(Fillet, vz, step1, nbtimes1, vy, step2, nbtimes2) #(GEOM_Shape_ptr, DirStruct, Double, Short, DirStruct, Double, Short)->GEOM_Shape_ptr
+#!!!!Angle In Degree!!!!
+MultiRot1D = geompy.MakeMultiRotation1D(Chamfer, vx, px, nbtimes1) #(GEOM_Shape_ptr, DirStruct, PointStruct, Short)->GEOM_Shape_ptr
+MultiRot2D = geompy.MakeMultiRotation2D(Chamfer, vx, px, angle, nbtimes1, step1, nbtimes2) #(GEOM_Shape_ptr, DirStruct, PointStruct, Double, Short, Double, Short)->GEOM_Shape_ptr
+
+#IDList for Partition
+ShapeListPartition1 = []
+ShapeListPartition1.append(Box)
+IORListPartition1 = []
+for Shape in ShapeListPartition1 :
+ IORListPartition1.append(Shape._get_Name())
+ShapeListPartition2 = []
+ShapeListPartition2.append(Plane)
+IORListPartition2 = []
+for Shape in ShapeListPartition2 :
+ IORListPartition2.append(Shape._get_Name())
+
+#IDList for SubShape
+IDlistSubShape = []
+IDlistSubShape.append(3)
+
+#Create Informations objects
+CDG = geompy.MakeCDG(Prism) #(GEOM_Shape_ptr)->GEOM_Shape_ptr
+Archimede = geompy.Archimede(Box, weight, waterdensity, meshingdeflection) #(GEOM_Shape_ptr, Double, Double, Double)->GEOM_Shape_ptr
+CheckShape = geompy.CheckShape(Prism) #(GEOM_Shape_ptr)->Boolean
+
+#Partition objects
+Partition = geompy.Partition(IORListPartition1, IORListPartition2) #(ListOfIOR, ListOfIOR)->GEOM_Shape_ptr
+
+#Add In Study
+id_Vertex = geompy.addToStudy(Vertex, "Vertex")
+id_Vector = geompy.addToStudy(Vector, "Vector")
+id_Line = geompy.addToStudy(Line, "Line")
+id_Arc = geompy.addToStudy(Arc, "Arc")
+id_Circle = geompy.addToStudy(Circle, "Circle")
+id_Plane = geompy.addToStudy(Plane, "Plane")
+
+id_Box = geompy.addToStudy(Box, "Box")
+id_Cylinder = geompy.addToStudy(Cylinder, "Cylinder")
+id_Sphere = geompy.addToStudy(Sphere, "Sphere")
+id_Cone = geompy.addToStudy(Cone, "Cone")
+id_Torus = geompy.addToStudy(Torus, "Torus")
+
+id_Edge = geompy.addToStudy(Edge, "Edge")
+id_Wire = geompy.addToStudy(Wire, "Wire")
+id_Face = geompy.addToStudy(Face, "Face")
+id_Compound = geompy.addToStudy(Compound, "Compound")
+
+id_Common = geompy.addToStudy(Common, "Common")
+id_Cut = geompy.addToStudy(Cut, "Cut")
+id_Fuse = geompy.addToStudy(Fuse, "Fuse")
+id_Section = geompy.addToStudy(Section, "Section")
+
+id_Copy = geompy.addToStudy(Copy, "Copy")
+id_Prism = geompy.addToStudy(Prism, "Prism")
+#id_Revolution = geompy.addToStudy(Revolution, "Revolution")
+id_Filling = geompy.addToStudy(Filling, "Filling")
+id_Pipe = geompy.addToStudy(Pipe, "Pipe")
+id_Sewing = geompy.addToStudy(Sewing, "Sewing")
+
+Id_Translation = geompy.addToStudy(Translation, "Translation")
+Id_Rotation = geompy.addToStudy(Rotation, "Rotation")
+Id_Scale = geompy.addToStudy(Scale, "Scale")
+Id_Mirror = geompy.addToStudy(Mirror, "Mirror")
+Id_Orientation = geompy.addToStudy(Orientation, "Orientation")
+Id_Fillet = geompy.addToStudy(Fillet, "Fillet")
+Id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer")
+
+Id_MultiTrans1D = geompy.addToStudy(MultiTrans1D, "MultiTrans1D")
+Id_MultiTrans2D = geompy.addToStudy(MultiTrans2D, "MultiTrans2D")
+Id_MultiRot1D = geompy.addToStudy(MultiRot1D, "MultiRot1D")
+Id_MultiRot2D = geompy.addToStudy(MultiRot2D, "MultiRot2D")
+
+Id_Partition = geompy.addToStudy(Partition, "Partition")
+Id_CDG = geompy.addToStudy(CDG, "CDG")
+Id_Archimede = geompy.addToStudy(Archimede, "Archimede")
+
+#Decompose objects
+SubShape = geompy.SubShape(Box, ShapeTypeFace, IDlistSubShape) #(GEOM_Shape_ptr, Short, ListOfSubShapeID)->GEOM_Shape_ptr
+name = geompy.SubShapeName( SubShape._get_Name(), Box._get_Name() )
+Id_SubShape = geompy.addToStudyInFather(Box, SubShape, name)
+
+SubShapeAllList = []
+SubShapeAllList = geompy.SubShapeAll(SubShape, ShapeTypeEdge) #(GEOM_Shape_ptr, Short)->ListOfGeomShapes
+for Shape in SubShapeAllList :
+ name = geompy.SubShapeName( Shape._get_Name(), Box._get_Name() )
+ Id_SubShapeAll = geompy.addToStudyInFather(SubShape, Shape, name)
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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, Paul RASCLE
+# Module : GEOM
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# Libraries targets
+
+LIB = libGeometry_Swigcmodule.la
+LIB_SRC =
+
+SWIG_DEF = libGeometry_Swig.i
+EXPORT_PYSCRIPTS = libGeometry_Swig.py geompy.py batchmode_geompy.py \
+ GEOM_example.py \
+ GEOM_example2.py \
+ GEOM_example3.py \
+ GEOM_example4.py \
+ GEOM_moteur.py \
+ GEOM_usinggeom.py \
+ GEOM_Partition1.py \
+ GEOM_Partition2.py \
+ GEOM_Partition3.py \
+ GEOM_Partition4.py \
+ GEOM_Partition5.py
+
+LIB_CLIENT_IDL = SALOMEDS.idl \
+ SALOMEDS_Attributes.idl \
+ SALOME_Exception.idl \
+ GEOM_Gen.idl \
+ GEOM_Shape.idl \
+ SALOME_Component.idl
+
+CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H
+LIBS+= $(PYTHON_LIBS)
+LDFLAGS+= -lGeometryGUI
+
+@CONCLUDE@
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# Copyright (C) 2003 CEA/DEN, EDF R&D
+#
+#
+#
+# File : geompy.py
+# Author : Paul RASCLE, EDF
+# Module : GEOM
+# $Header$
+
+from batchmode_salome import *
+
+#--------------------------------------------------------------------------
+
+geom = lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+geom.GetCurrentStudy(myStudyId)
+myBuilder = myStudy.NewBuilder()
+
+father = myStudy.FindComponent("GEOM")
+if father is None:
+ father = myBuilder.NewComponent("GEOM")
+ A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
+ FName = A1._narrow(SALOMEDS.AttributeName)
+ FName.SetValue("Geometry")
+ A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" );
+ myBuilder.DefineComponentInstance(father,geom)
+
+
+# -----------------------------------------------------------------------------
+# add To Study
+# -----------------------------------------------------------------------------
+
+def SubShapeName(aSubId, aMainId):
+# index = gg.getIndexTopology(aSubId, aMainId)
+# print index
+# name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
+ name = "Shape"
+ print name
+ return name
+
+def addArguments(aShape):
+ ListIOR = []
+ ListIOR = geom.GetReferencedObjects(aShape)
+
+ if aShape._get_StudyShapeId()!="":
+ father = IDToSObject(aShape._get_StudyShapeId())
+
+ myBuilder.NewCommand()
+ if len(ListIOR) > 0:
+ Arg = myBuilder.NewObject(father)
+ A1 = myBuilder.FindOrCreateAttribute(Arg, "AttributeName");
+ ArgName = A1._narrow(SALOMEDS.AttributeName)
+ ArgName.SetValue("Arguments")
+ A2 = myBuilder.FindOrCreateAttribute(Arg, "AttributeSelectable");
+ SelAttr = A2._narrow(SALOMEDS.AttributeSelectable);
+ SelAttr.SetSelectable(0);
+
+ OneObject = 0
+ for anIOR in ListIOR:
+ Shape = orb.string_to_object(anIOR)
+ if Shape is not None:
+ if Shape._get_StudyShapeId()!="":
+ Obj = IDToSObject(Shape._get_StudyShapeId())
+ if Obj is not None:
+ Obj1 = myBuilder.NewObject(Arg)
+ myBuilder.Addreference(Obj1,Obj)
+ OneObject = 1
+
+ if OneObject == 0:
+ myBuilder.RemoveObject(Arg)
+
+ myBuilder.CommitCommand()
+ return 1
+
+def addToStudy(aShape, aName):
+ try:
+ myBuilder.NewCommand()
+ newObj = myBuilder.NewObject(father)
+ ior = orb.object_to_string(aShape)
+ A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
+ ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
+ ObjIOR.SetValue(ior)
+ A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
+ ObjName = A2._narrow(SALOMEDS.AttributeName)
+ ObjName.SetValue(aName)
+ id = newObj.GetID()
+ aShape._set_StudyShapeId(id)
+ myBuilder.CommitCommand()
+
+ addArguments( aShape )
+
+ except:
+ return None
+ return id
+
+def addToStudyInFather(aFather, aShape, aName):
+ myBuilder.NewCommand()
+ newObj = myBuilder.NewObject( IDToSObject(aFather._get_StudyShapeId()) )
+ ior = orb.object_to_string(aShape)
+ A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
+ ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
+ ObjIOR.SetValue(ior)
+ A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
+ ObjName = A2._narrow(SALOMEDS.AttributeName)
+ ObjName.SetValue(aName)
+ id = newObj.GetID()
+ aShape._set_StudyShapeId(id)
+ myBuilder.CommitCommand()
+ addArguments( aShape )
+ return id
+
+# -----------------------------------------------------------------------------
+# Create Geometry 2D
+# -----------------------------------------------------------------------------
+
+def MakeVertex(x,y,z):
+ anObj = geom.MakeVertex(x,y,z)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeVector(p1,p2):
+ anObj = geom.MakeVector(p1,p2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeLine(p1,d1):
+ anObj = geom.MakeLine(p1,d1)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeArc(p1,p2,p3):
+ anObj = geom.MakeArc(p1,p2,p3)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCircle(p1,d1,radius):
+ anObj = geom.MakeCircle(p1,d1,radius)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePlane(p1,d1,trimsize):
+ anObj = geom.MakePlane(p1,d1,trimsize)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create Geometry 3D
+# -----------------------------------------------------------------------------
+
+def MakeBox(x1,y1,z1,x2,y2,z2):
+ anObj = geom.MakeBox(x1,y1,z1,x2,y2,z2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCylinder(p1,d1,radius,height):
+ anObj = geom.MakeCylinder(p1,d1,radius,height)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeSphere(x,y,z,radius):
+ anObj = geom.MakeSphere(x,y,z,radius)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCone(p1,d1,radius1,radius2,height):
+ anObj = geom.MakeCone(p1,d1,radius1,radius2,height)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeTorus(p1,d1,major_radius,minor_radius):
+ anObj = geom.MakeTorus(p1,d1,major_radius,minor_radius)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create base objects
+# -----------------------------------------------------------------------------
+
+def MakeEdge(p1,p2):
+ anObj = geom.MakeEdge(p1,p2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeWire(ListShape):
+ anObj = geom.MakeWire(ListShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFace(aShapeWire,WantPlanarFace):
+ anObj = geom.MakeFace(aShapeWire,WantPlanarFace)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCompound(ListShape):
+ anObj = geom.MakeCompound(ListShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create advanced objects
+# -----------------------------------------------------------------------------
+
+def MakeCopy(aShape):
+ anObj = geom.MakeCopy(aShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePrism(baseShape,p1,p2):
+ anObj = geom.MakePrism(baseShape,p1,p2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeRevolution(aShape,axis,angle):
+ anObj = geom.MakeRevolution(aShape,axis,angle)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter):
+ anObj = geom.MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePipe(pathShape,baseShape):
+ anObj = geom.MakePipe(pathShape,baseShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeSewing(ListShape,precision):
+ anObj = geom.MakeSewing(ListShape,precision)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Boolean (Common, Cut, Fuse, Section)
+# -----------------------------------------------------------------------------
+
+def MakeBoolean(shape1,shape2,operation):
+ anObj = geom.MakeBoolean(shape1,shape2,operation)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Transform objects
+# -----------------------------------------------------------------------------
+
+def MakeTranslation(aShape,x,y,z):
+ anObj = geom.MakeTranslation(aShape,x,y,z)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeRotation(aShape,axis,angle):
+ anObj = geom.MakeRotation(aShape,axis,angle)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeScaleTransform(aShape,theCenterofScale,factor):
+ anObj = geom.MakeScaleTransform(aShape,theCenterofScale,factor)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMirrorByPlane(aShape,aPlane):
+ anObj = geom.MakeMirrorByPlane(aShape,aPlane)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def OrientationChange(aShape):
+ anObj = geom.OrientationChange(aShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFillet(aShape,radius,ShapeType,ListShape):
+ anObj = geom.MakeFillet(aShape,radius,ShapeType,ListShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeChamfer(aShape,d1,d2,ShapeType,ListShape):
+ anObj = geom.MakeChamfer(aShape,d1,d2,ShapeType,ListShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Decompose objects
+# -----------------------------------------------------------------------------
+
+def SubShape(aShape,type,ListOfId):
+ anObj = geom.SubShape(aShape,type, ListOfId)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SubShapeAll(aShape,type):
+ ListObj = geom.SubShapeAll(aShape,type)
+ for anObj in ListObj :
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return ListObj
+
+def SubShapeSorted(aShape,type,ListOfId):
+ anObj = geom.SubShapeSorted(aShape,type, ListOfId)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SubShapeAllSorted(aShape,type):
+ ListObj = geom.SubShapeAllSorted(aShape,type)
+ for anObj in ListObj :
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return ListObj
+
+# -- enumeration ShapeType as a dictionary --
+ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
+
+def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"]):
+ anObj = geom.Partition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit);
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SuppressFaces(aShape,ListOfId):
+ anObj = geom.SuppressFaces(aShape,ListOfId)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace):
+ anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Patterns
+# -----------------------------------------------------------------------------
+
+def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
+ anObj = geom.MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
+ anObj = geom.MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
+ anObj = geom.MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
+ anObj = geom.MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Import objects
+# -----------------------------------------------------------------------------
+
+def ImportBREP(filename):
+ anObj = geom.ImportBREP(filename)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def ImportIGES(filename):
+ anObj = geom.ImportIGES(filename)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def ImportSTEP(filename):
+ anObj = geom.ImportSTEP(filename)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Export objects
+# -----------------------------------------------------------------------------
+def ExportBREP(filename,aShape):
+ geom.ExportBREP(filename,aShape)
+
+def ExportIGES(filename,aShape):
+ geom.ExportIGES(filename,aShape)
+
+def ExportSTEP(filename,aShape):
+ geom.ExportSTEP(filename,aShape)
+
+# -----------------------------------------------------------------------------
+# Information objects
+# -----------------------------------------------------------------------------
+
+def MakeCDG(aShape):
+ anObj = geom.MakeCDG(aShape)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
+ anObj = geom.Archimede(aShape,weight,WaterDensity,MeshingDeflection)
+ ior = orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def CheckShape(aShape):
+ Status = geom.CheckShape(aShape)
+ return Status
--- /dev/null
+# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+#
+# 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 : geompy.py
+# Author : Paul RASCLE, EDF
+# Module : GEOM
+# $Header$
+
+import salome
+import SALOMEDS
+#import SALOMEDS_Attributes_idl
+
+#NRI : BugID 1682 : from libSALOME_Swig import *
+
+geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry")
+geom.GetCurrentStudy(salome.myStudyId)
+myBuilder = salome.myStudy.NewBuilder()
+
+gg = salome.ImportComponentGUI("Geometry")
+
+father = salome.myStudy.FindComponent("GEOM")
+if father is None:
+ father = myBuilder.NewComponent("GEOM")
+ A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
+ FName = A1._narrow(SALOMEDS.AttributeName)
+ FName.SetValue("Geometry")
+ A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
+ aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" );
+ myBuilder.DefineComponentInstance(father,geom)
+
+
+# -----------------------------------------------------------------------------
+# add To Study
+# -----------------------------------------------------------------------------
+
+def SubShapeName(aSubId, aMainId):
+ index = gg.getIndexTopology(aSubId, aMainId)
+ name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
+ return name
+
+def addArguments(aShape):
+ ListIOR = []
+ ListIOR = geom.GetReferencedObjects(aShape)
+
+ if aShape._get_StudyShapeId()!="":
+ father = salome.IDToSObject(aShape._get_StudyShapeId())
+
+ myBuilder.NewCommand()
+ if len(ListIOR) > 0:
+ Arg = myBuilder.NewObject(father)
+ A1 = myBuilder.FindOrCreateAttribute(Arg, "AttributeName");
+ ArgName = A1._narrow(SALOMEDS.AttributeName)
+ ArgName.SetValue("Arguments")
+ A2 = myBuilder.FindOrCreateAttribute(Arg, "AttributeSelectable");
+ SelAttr = A2._narrow(SALOMEDS.AttributeSelectable);
+ SelAttr.SetSelectable(0);
+
+ OneObject = 0
+ for anIOR in ListIOR:
+ Shape = salome.orb.string_to_object(anIOR)
+ if Shape is not None:
+ if Shape._get_StudyShapeId()!="":
+ Obj = salome.IDToSObject(Shape._get_StudyShapeId())
+ if Obj is not None:
+ Obj1 = myBuilder.NewObject(Arg)
+ myBuilder.Addreference(Obj1,Obj)
+ OneObject = 1
+
+ if OneObject == 0:
+ myBuilder.RemoveObject(Arg)
+
+ myBuilder.CommitCommand()
+ return 1
+
+def addToStudy(aShape, aName):
+ myBuilder.NewCommand()
+ newObj = myBuilder.NewObject(father)
+ ior = salome.orb.object_to_string(aShape)
+ A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
+ ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
+ ObjIOR.SetValue(ior)
+ A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
+ ObjName = A2._narrow(SALOMEDS.AttributeName)
+ ObjName.SetValue(aName)
+ A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap");
+ ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap)
+ anIcon = gg.getShapeTypeIcon(ior);
+ ObjPixmap.SetPixMap(anIcon)
+ id = newObj.GetID()
+ aShape._set_StudyShapeId(id)
+ myBuilder.CommitCommand()
+
+ addArguments( aShape )
+
+#NRI : BugID 1682 : sg = SALOMEGUI_Swig()
+#NRI : BugID 1682 : sg.updateObjBrowser(0)
+ salome.sg.updateObjBrowser(0)
+ return id
+
+def addToStudyInFather(aFather, aShape, aName):
+
+#NRI : BugID 1682 : sg = SALOMEGUI_Swig()
+ myBuilder.NewCommand()
+ newObj = myBuilder.NewObject( salome.IDToSObject(aFather._get_StudyShapeId()) )
+ ior = salome.orb.object_to_string(aShape)
+ A1 = myBuilder.FindOrCreateAttribute(newObj, "AttributeIOR");
+ ObjIOR = A1._narrow(SALOMEDS.AttributeIOR)
+ ObjIOR.SetValue(ior)
+ A2 = myBuilder.FindOrCreateAttribute(newObj, "AttributeName");
+ ObjName = A2._narrow(SALOMEDS.AttributeName)
+ ObjName.SetValue(aName)
+ A3 = myBuilder.FindOrCreateAttribute(newObj, "AttributePixMap");
+ ObjPixmap = A3._narrow(SALOMEDS.AttributePixMap)
+ anIcon = gg.getShapeTypeIcon(ior);
+ ObjPixmap.SetPixMap(anIcon)
+ id = newObj.GetID()
+ aShape._set_StudyShapeId(id)
+ myBuilder.CommitCommand()
+
+ addArguments( aShape )
+
+#NRI : BugID 1682 : sg.updateObjBrowser(0)
+ salome.sg.updateObjBrowser(0)
+ return id
+
+# -----------------------------------------------------------------------------
+# Create Geometry 2D
+# -----------------------------------------------------------------------------
+
+def MakeVertex(x,y,z):
+ anObj = geom.MakeVertex(x,y,z)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeVector(p1,p2):
+ anObj = geom.MakeVector(p1,p2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeLine(p1,d1):
+ anObj = geom.MakeLine(p1,d1)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeArc(p1,p2,p3):
+ anObj = geom.MakeArc(p1,p2,p3)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCircle(p1,d1,radius):
+ anObj = geom.MakeCircle(p1,d1,radius)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePlane(p1,d1,trimsize):
+ anObj = geom.MakePlane(p1,d1,trimsize)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create Geometry 3D
+# -----------------------------------------------------------------------------
+
+def MakeBox(x1,y1,z1,x2,y2,z2):
+ anObj = geom.MakeBox(x1,y1,z1,x2,y2,z2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCylinder(p1,d1,radius,height):
+ anObj = geom.MakeCylinder(p1,d1,radius,height)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeSphere(x,y,z,radius):
+ anObj = geom.MakeSphere(x,y,z,radius)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCone(p1,d1,radius1,radius2,height):
+ anObj = geom.MakeCone(p1,d1,radius1,radius2,height)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeTorus(p1,d1,major_radius,minor_radius):
+ anObj = geom.MakeTorus(p1,d1,major_radius,minor_radius)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create base objects
+# -----------------------------------------------------------------------------
+
+def MakeEdge(p1,p2):
+ anObj = geom.MakeEdge(p1,p2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeWire(ListShape):
+ anObj = geom.MakeWire(ListShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFace(aShapeWire,WantPlanarFace):
+ anObj = geom.MakeFace(aShapeWire,WantPlanarFace)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeCompound(ListShape):
+ anObj = geom.MakeCompound(ListShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Create advanced objects
+# -----------------------------------------------------------------------------
+
+def MakeCopy(aShape):
+ anObj = geom.MakeCopy(aShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePrism(baseShape,p1,p2):
+ anObj = geom.MakePrism(baseShape,p1,p2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeRevolution(aShape,axis,angle):
+ anObj = geom.MakeRevolution(aShape,axis,angle)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter):
+ anObj = geom.MakeFilling(aShape,mindeg,maxdeg,tol3d,tol2d,nbiter)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakePipe(pathShape,baseShape):
+ anObj = geom.MakePipe(pathShape,baseShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeSewing(ListShape,precision):
+ anObj = geom.MakeSewing(ListShape,precision)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Boolean (Common, Cut, Fuse, Section)
+# -----------------------------------------------------------------------------
+
+def MakeBoolean(shape1,shape2,operation):
+ anObj = geom.MakeBoolean(shape1,shape2,operation)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Transform objects
+# -----------------------------------------------------------------------------
+
+def MakeTranslation(aShape,x,y,z):
+ anObj = geom.MakeTranslation(aShape,x,y,z)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeRotation(aShape,axis,angle):
+ anObj = geom.MakeRotation(aShape,axis,angle)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeScaleTransform(aShape,theCenterofScale,factor):
+ anObj = geom.MakeScaleTransform(aShape,theCenterofScale,factor)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMirrorByPlane(aShape,aPlane):
+ anObj = geom.MakeMirrorByPlane(aShape,aPlane)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def OrientationChange(aShape):
+ anObj = geom.OrientationChange(aShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeFillet(aShape,radius,ShapeType,ListShape):
+ anObj = geom.MakeFillet(aShape,radius,ShapeType,ListShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeChamfer(aShape,d1,d2,ShapeType,ListShape):
+ anObj = geom.MakeChamfer(aShape,d1,d2,ShapeType,ListShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Decompose objects
+# -----------------------------------------------------------------------------
+
+def SubShape(aShape,type,ListOfId):
+ anObj = geom.SubShape(aShape,type, ListOfId)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SubShapeAll(aShape,type):
+ ListObj = geom.SubShapeAll(aShape,type)
+ for anObj in ListObj :
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return ListObj
+
+def SubShapeSorted(aShape,type,ListOfId):
+ anObj = geom.SubShapeSorted(aShape,type, ListOfId)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SubShapeAllSorted(aShape,type):
+ ListObj = geom.SubShapeAllSorted(aShape,type)
+ for anObj in ListObj :
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return ListObj
+
+# -- enumeration ShapeType as a dictionary --
+ShapeType = {"COMPOUND":0, "COMPSOLID":1, "SOLID":2, "SHELL":3, "FACE":4, "WIRE":5, "EDGE":6, "VERTEX":7, "SHAPE":8}
+
+def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], Limit=ShapeType["SHAPE"]):
+ anObj = geom.Partition(ListShapes, ListTools, ListKeepInside, ListRemoveInside, Limit);
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SuppressFaces(aShape,ListOfId):
+ anObj = geom.SuppressFaces(aShape,ListOfId)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace):
+ anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Patterns
+# -----------------------------------------------------------------------------
+
+def MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes):
+ anObj = geom.MakeMultiTranslation1D(aShape,aDir,aStep,aNbTimes)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2):
+ anObj = geom.MakeMultiTranslation2D(aShape,d1,step1,nbtimes1,d2,step2,nbtimes2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes):
+ anObj = geom.MakeMultiRotation1D(aShape,aDir,aPoint,aNbTimes)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2):
+ anObj = geom.MakeMultiRotation2D(aShape,aDir,aPoint,anAngle,nbtimes1,aStep,nbtimes2)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Import objects
+# -----------------------------------------------------------------------------
+
+def ImportBREP(filename):
+ anObj = geom.ImportBREP(filename)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def ImportIGES(filename):
+ anObj = geom.ImportIGES(filename)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def ImportSTEP(filename):
+ anObj = geom.ImportSTEP(filename)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+# -----------------------------------------------------------------------------
+# Export objects
+# -----------------------------------------------------------------------------
+def ExportBREP(filename,aShape):
+ geom.ExportBREP(filename,aShape)
+
+def ExportIGES(filename,aShape):
+ geom.ExportIGES(filename,aShape)
+
+def ExportSTEP(filename,aShape):
+ geom.ExportSTEP(filename,aShape)
+
+# -----------------------------------------------------------------------------
+# Information objects
+# -----------------------------------------------------------------------------
+
+def MakeCDG(aShape):
+ anObj = geom.MakeCDG(aShape)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def Archimede(aShape,weight,WaterDensity,MeshingDeflection):
+ anObj = geom.Archimede(aShape,weight,WaterDensity,MeshingDeflection)
+ ior = salome.orb.object_to_string(anObj)
+ anObj._set_Name(ior)
+ return anObj
+
+def CheckShape(aShape):
+ Status = geom.CheckShape(aShape)
+ return Status
--- /dev/null
+// GEOM GEOM_SWIG : binding of C++ omplementaion with Python
+//
+// 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 : libGeometry_Swig.i
+// Author : Nicolas REJNERI, Paul RASCLE
+// Module : GEOM
+// $Header$
+
+%module libGeometry_Swig
+
+%include "GeometryGUI_Swig.i"
+
-# -* Makefile *-
+# 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
#
-# Author : Patrick GOLDBRONN (CEA)
-# Date : 28/06/2001
-# $Header$
#
+#
+# File : Makefile.in
+# Author : Patrick GOLDBRONN (CEA)
+# Module : GEOM
+# $Header$
-# source path
top_srcdir=@top_srcdir@
-top_builddir=.
+top_builddir=../..
srcdir=@srcdir@
-VPATH=.:@srcdir@:@top_srcdir@/bin:@top_srcdir@/resources:./bin:@top_srcdir@/idl
+VPATH=.:@srcdir@
@COMMENCE@
-SUBDIRS = idl src
-
-RESOURCES_FILES = \
-Geometry_en.xml \
-Geometry_fr.xml \
-arc.png \
-archimede.png \
-axisinertia.png \
-basicproperties.png \
-bounding.png \
-box.png \
-box2points.png \
-boxdxyz.png \
-build_compound.png \
-build_edge.png \
-build_face.png \
-build_shell.png \
-build_solid.png \
-build_wire.png \
-centergravity.png \
-chamfer.png \
-chamferall.png \
-chamferedge.png \
-chamferface.png \
-check.png \
-circle.png \
-circlepointvector.png \
-common.png \
-cone.png \
-conedxyz.png \
-conepointvector.png \
-cut.png \
-cylinder.png \
-cylinderdxyz.png \
-cylinderpointvector.png \
-delete.png \
-display.png \
-displayall.png \
-erase.png \
-eraseall.png \
-fillet.png \
-filletall.png \
-filletedge.png \
-filletface.png \
-filling.png \
-fuse.png \
-geometry.png \
-line.png \
-line2points.png \
-lineedge.png \
-linepointvector.png \
-mindist.png \
-mirrorPlane.png \
-ModuleGeom.png \
-multirotation.png \
-multirotationdouble.png \
-multirotationsimple.png \
-multitranslation.png \
-multitranslationdouble.png \
-multitranslationsimple.png \
-orientation.png \
-partition.png \
-partitionkeep.png \
-pipe.png \
-plane.png \
-planeWorking.png \
-planedxyz.png \
-planeface.png \
-planepointvector.png \
-planeworkingface.png \
-point2.png \
-pointonedge.png \
-prism.png \
-revol.png \
-rotate.png \
-scale.png \
-section.png \
-select1.png \
-sewing.png \
-shading.png \
-sketch.png \
-sphere.png \
-spheredxyz.png \
-spherepoint.png \
-subshape.png \
-supressHolesOnFaceShell.png \
-supressface.png \
-supresshole.png \
-tolerance.png \
-torus.png \
-torusdxyz.png \
-toruspointvector.png \
-translation.png \
-tree_compound.png \
-tree_compsolid.png \
-tree_edge.png \
-tree_face.png \
-tree_shape.png \
-tree_shell.png \
-tree_solid.png \
-tree_vertex.png \
-tree_wire.png \
-vector.png \
-vector2points.png \
-vectordxyz.png \
-whatis.png
-
-# copy header files in common directory
-ifeq ($(HAVE_SSTREAM),yes)
- include_list=include/salome/SALOMEconfig.h
-else
- include_list=include/salome/SALOMEconfig.h include/salome/sstream
-endif
-
-inc: idl $(include_list)
-
-include/salome/SALOMEconfig.h: salome_adm/unix/SALOMEconfig.h
- -$(RM) $@
- $(LN_S) ../../$< $@
-
-include/salome/sstream: salome_adm/unix/sstream
- -$(RM) $@
- $(LN_S) ../../$< $@
-
-depend: depend_idl
-
-depend_idl:
- (cd idl ; $(MAKE) $@) || exit 1
-
-# doc is already build : if you want to had documents, go manually to doc and run 'make doc'
-#doc:
-# (cd doc && $(MAKE) $@) || exit 1
-
-install-end:
-# finish libtool install
-# @$(LT) --mode=finish $(libdir)
-
-install-include: $(include_list)
- $(INSTALL) -d $(includedir)
- @for f in X $(include_list); do \
- if test $$f != X; then \
- ($(INSTALL_DATA) $$f $(includedir)/. || exit 1); \
- fi; \
- done
-
-# install script in $(bindir) :
-install-bin: $(BIN_SCRIPT)
- $(INSTALL) -d $(bindir)
- if test $(BIN_SCRIPT)X != X; then \
- $(INSTALL_PROGRAM) $^ $(bindir); \
- fi
-
-uninstall: uninstall-idl
-
-uninstall-idl:
- $(RM) $(idldir)/*.idl
-
-distclean: distclean-other
-
-distclean-other:
- -$(RM) salome_adm/unix/*~ salome_adm/unix/*% salome_adm/unix/*.bak salome_adm/unix/*.new salome_adm/unix/*.old
- -$(RM) salome_adm/unix/make_*
- -$(RM) salome_adm/unix/depend salome_adm/unix/SALOMEconfig.h
- -$(RM) config.cache config.log config.status
+SUBDIRS = OBJECT SKETCHER ARCHIMEDE PARTITION GEOMDS GEOM GEOMClient GEOMFiltersSelection GEOMGUI GEOM_SWIG
@MODULE@
-
-install: install-bin install-include install-end
-
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AISShape.cxx
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+/*!
+ \class GEOM_AISShape GEOM_AISShape.hxx
+ \brief ....
+*/
+
+#include "GEOM_AISShape.ixx"
+#include "SALOME_InteractiveObject.hxx"
+
+#include "utilities.h"
+
+// Open CASCADE Includes
+#include <AIS_Drawer.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <StdSelect_DisplayMode.hxx>
+#include <StdPrs_WFShape.hxx>
+#include <StdPrs_ShadedShape.hxx>
+
+#include <Graphic3d_AspectFillArea3d.hxx>
+
+GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
+ const Standard_CString aName): SALOME_AISShape(shape)
+{
+ myIO = NULL;
+ myName = new char [strlen(aName)+1];
+ strcpy( myName, aName);
+
+ myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
+}
+
+void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
+ myIO = io;
+}
+
+Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
+ return myIO;
+}
+
+Standard_Boolean GEOM_AISShape::hasIO(){
+ return !( myIO == NULL ) ;
+}
+
+void GEOM_AISShape::setName(const Standard_CString aName)
+{
+ myName = new char [strlen(aName)+1];
+ strcpy( myName, aName);
+
+ if ( hasIO() )
+ myIO->setName(aName);
+}
+
+Standard_CString GEOM_AISShape::getName(){
+ return myName;
+}
+
+void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+ const Handle(Prs3d_Presentation)& aPrs,
+ const Standard_Integer aMode)
+{
+ if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
+
+ StdSelect_DisplayMode d = (StdSelect_DisplayMode) aMode;
+
+ switch (d) {
+ case StdSelect_DM_Wireframe:
+ {
+ StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
+ break;
+ }
+ case StdSelect_DM_Shading:
+ {
+ myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
+ myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(Graphic3d_NOM_BRASS);
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
+
+ Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
+ FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
+ myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
+
+ //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
+ // P->SetPrimitivesAspect(a4bis);
+ // G->SetGroupPrimitivesAspect(a4bis);
+ //a4bis->SetInteriorColor(myShadingColor);
+ myDrawer->ShadingAspect()->SetColor(myShadingColor);
+
+ StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
+ break;
+ }
+ }
+ // aPrs->ReCompute(); // for hidden line recomputation if necessary...
+}
+
+void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
+{
+ if(aValue<0.0 || aValue>1.0) return;
+
+ if(aValue<=0.05)
+ {
+ UnsetTransparency();
+ return;
+ }
+
+ Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
+ FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
+ myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
+ myTransparency = aValue;
+}
+
+void GEOM_AISShape::SetShadingColor(const Quantity_Color &aCol)
+{
+ myShadingColor = aCol;
+}
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AISShape.hxx
+// Module : GEOM
+
+#ifndef _GEOM_AISShape_HeaderFile
+#define _GEOM_AISShape_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Handle_GEOM_AISShape_HeaderFile
+#include "Handle_GEOM_AISShape.hxx"
+#endif
+
+#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
+#include "Handle_SALOME_InteractiveObject.hxx"
+#endif
+#ifndef _Standard_CString_HeaderFile
+#include <Standard_CString.hxx>
+#endif
+#ifndef _SALOME_AISShape_HeaderFile
+#include "SALOME_AISShape.hxx"
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_PrsMgr_PresentationManager3d_HeaderFile
+#include <Handle_PrsMgr_PresentationManager3d.hxx>
+#endif
+#ifndef _Handle_Prs3d_Presentation_HeaderFile
+#include <Handle_Prs3d_Presentation.hxx>
+#endif
+
+class PrsMgr_PresentationManager3d;
+class Prs3d_Presentation;
+class SALOME_InteractiveObject;
+class TopoDS_Shape;
+
+
+class GEOM_AISShape : public SALOME_AISShape {
+
+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_AISShape(const TopoDS_Shape& shape, const Standard_CString aName);
+Standard_EXPORT Standard_Boolean hasIO() ;
+Standard_EXPORT void setIO(const Handle(SALOME_InteractiveObject)& name) ;
+Standard_EXPORT void setName(const Standard_CString aName) ;
+Standard_EXPORT Standard_CString getName() ;
+Standard_EXPORT Handle_SALOME_InteractiveObject getIO() ;
+Standard_EXPORT ~GEOM_AISShape();
+
+Standard_EXPORT void SetTransparency(const Standard_Real aValue);
+Standard_EXPORT void SetShadingColor(const Quantity_Color &aCol);
+
+Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer aMode = 0) ;
+
+ // Type management
+ //
+ Standard_EXPORT friend Handle_Standard_Type& GEOM_AISShape_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
+ //
+ Handle_SALOME_InteractiveObject myIO;
+ Standard_CString myName;
+ Quantity_Color myShadingColor;
+};
+
+
+
+
+
+// other inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AISShape.ixx
+// Module : GEOM
+
+#include "GEOM_AISShape.jxx"
+
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#endif
+
+GEOM_AISShape::~GEOM_AISShape() {}
+
+
+
+Standard_EXPORT Handle_Standard_Type& GEOM_AISShape_Type_()
+{
+
+ static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_AISShape);
+ if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_AISShape);
+ static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_Shape);
+ if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_Shape);
+ static Handle_Standard_Type aType3 = STANDARD_TYPE(AIS_InteractiveObject);
+ if ( aType3.IsNull()) aType3 = STANDARD_TYPE(AIS_InteractiveObject);
+ static Handle_Standard_Type aType4 = STANDARD_TYPE(SelectMgr_SelectableObject);
+ if ( aType4.IsNull()) aType4 = STANDARD_TYPE(SelectMgr_SelectableObject);
+ static Handle_Standard_Type aType5 = STANDARD_TYPE(PrsMgr_PresentableObject);
+ if ( aType5.IsNull()) aType5 = STANDARD_TYPE(PrsMgr_PresentableObject);
+ static Handle_Standard_Type aType6 = STANDARD_TYPE(MMgt_TShared);
+ if ( aType6.IsNull()) aType6 = STANDARD_TYPE(MMgt_TShared);
+ static Handle_Standard_Type aType7 = STANDARD_TYPE(Standard_Transient);
+ if ( aType7.IsNull()) aType7 = STANDARD_TYPE(Standard_Transient);
+
+
+ static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,aType7,NULL};
+ static Handle_Standard_Type _aType = new Standard_Type("GEOM_AISShape",
+ sizeof(GEOM_AISShape),
+ 1,
+ (Standard_Address)_Ancestors,
+ (Standard_Address)NULL);
+
+ return _aType;
+}
+
+
+// DownCast method
+// allow safe downcasting
+//
+const Handle(GEOM_AISShape) Handle(GEOM_AISShape)::DownCast(const Handle(Standard_Transient)& AnObject)
+{
+ Handle(GEOM_AISShape) _anOtherObject;
+
+ if (!AnObject.IsNull()) {
+ if (AnObject->IsKind(STANDARD_TYPE(GEOM_AISShape))) {
+ _anOtherObject = Handle(GEOM_AISShape)((Handle(GEOM_AISShape)&)AnObject);
+ }
+ }
+
+ return _anOtherObject ;
+}
+const Handle(Standard_Type)& GEOM_AISShape::DynamicType() const
+{
+ return STANDARD_TYPE(GEOM_AISShape) ;
+}
+Standard_Boolean GEOM_AISShape::IsKind(const Handle(Standard_Type)& AType) const
+{
+ return (STANDARD_TYPE(GEOM_AISShape) == AType || SALOME_AISShape::IsKind(AType));
+}
+Handle_GEOM_AISShape::~Handle_GEOM_AISShape() {}
+
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AISShape.jxx
+// Module : GEOM
+
+#ifndef _GEOM_InteractiveObject_HeaderFile
+#include "GEOM_InteractiveObject.hxx"
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _GEOM_AISShape_HeaderFile
+#include "GEOM_AISShape.hxx"
+#endif
+#ifndef _PrsMgr_PresentationManager3d_HeaderFile
+#include <PrsMgr_PresentationManager3d.hxx>
+#endif
+#ifndef _Prs3d_Presentation_HeaderFile
+#include <Prs3d_Presentation.hxx>
+#endif
\ No newline at end of file
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_Actor.cxx
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+using namespace std;
+/*!
+ \class GEOM_Actor GEOM_Actor.h
+ \brief This class allows to display an OpenCASCADE CAD model in a VTK viewer.
+*/
+
+#include "GEOM_Actor.h"
+
+// OpenCASCADE Includes
+#include "GEOM_OCCReader.h"
+#include <BRep_Tool.hxx>
+
+//-------------------------------------------------------------
+// Main methods
+//-------------------------------------------------------------
+
+
+GEOM_Actor* GEOM_Actor::New()
+{
+ // First try to create the object from the vtkObjectFactory
+ vtkObject* ret = vtkObjectFactory::CreateInstance("GEOM_Actor");
+ if(ret)
+ {
+ return (GEOM_Actor*)ret;
+ }
+ // If the factory was unable to create the object, then create it here.
+ return new GEOM_Actor;
+}
+
+
+GEOM_Actor::GEOM_Actor()
+{
+ this->Device = vtkActor::New();
+
+ this->WireframeMapper = NULL;
+ this->ShadingMapper = NULL;
+
+ this->ShadingProperty = NULL;
+ this->WireframeProperty = NULL;
+
+ this->deflection = 0;
+ myDisplayMode = 0;
+
+ this->myIO = NULL;
+ this->myName = "";
+
+ this->HighlightProperty = NULL;
+ this->ishighlighted = false;
+
+ this->subshape = false;
+}
+
+GEOM_Actor::~GEOM_Actor()
+{
+ if (WireframeMapper != NULL)
+ WireframeMapper->Delete();
+ if (ShadingMapper != NULL)
+ ShadingMapper->Delete();
+ if (ShadingProperty != NULL)
+ ShadingProperty->Delete();
+ if (WireframeProperty != NULL)
+ WireframeProperty->Delete();
+ if (HighlightProperty != NULL)
+ HighlightProperty->Delete();
+}
+
+
+void GEOM_Actor::ShallowCopy(vtkProp *prop)
+{
+ GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
+ if ( f != NULL )
+ {
+ this->setInputShape(f->getTopo(),f->getDeflection(),f->getDisplayMode());
+ this->setName( f->getName() );
+ if ( f->hasIO() )
+ this->setIO( f->getIO() );
+ this->ShadingMapper = NULL;
+ this->WireframeMapper = NULL;
+ } else {
+ this->myIO = NULL;
+ this->myName = "";
+ this->ShadingMapper = NULL;
+ this->WireframeMapper = NULL;
+ }
+
+ // Now do superclass
+ this->SALOME_Actor::ShallowCopy(prop);
+}
+
+//-------------------------------------------------------------
+// Set parameters
+//-------------------------------------------------------------
+
+
+void GEOM_Actor::setDisplayMode(int thenewmode) {
+ myDisplayMode = thenewmode;
+ if ( thenewmode >=1 ) {
+ if ((myShape.ShapeType() == TopAbs_WIRE) ||
+ (myShape.ShapeType() == TopAbs_EDGE) ||
+ (myShape.ShapeType() == TopAbs_VERTEX)) {
+ if ( !subshape )
+ CreateWireframeMapper();
+ else
+ return;
+ } else
+ CreateShadingMapper();
+ } else
+ CreateWireframeMapper();
+}
+
+void GEOM_Actor::setDeflection(double adef) {
+ deflection = adef;
+}
+
+void GEOM_Actor::setInputShape(const TopoDS_Shape& aShape,double adef,int imode) {
+ myShape = aShape;
+ deflection = adef;
+ setDisplayMode(imode);
+}
+
+//-------------------------------------------------------------
+// Get parameters
+//-------------------------------------------------------------
+
+const TopoDS_Shape& GEOM_Actor::getTopo() {
+ return myShape;
+}
+
+double GEOM_Actor::getDeflection() {
+ return deflection;
+}
+
+void GEOM_Actor::SetWireframeProperty(vtkProperty* Prop) {
+ this->WireframeProperty = Prop;
+}
+
+void GEOM_Actor::SetShadingProperty(vtkProperty* Prop) {
+ this->ShadingProperty = Prop;
+}
+
+
+//-------------------------------------------------------------
+// Mapper creating function
+//-------------------------------------------------------------
+void GEOM_Actor::CreateMapper(int theMode) {
+ if(myShape.ShapeType() == TopAbs_VERTEX) {
+ gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(myShape));
+ this->SetPosition(aPnt.X(),aPnt.Y(),aPnt.Z());
+ }
+ GEOM_OCCReader* aread = GEOM_OCCReader::New();
+ aread->setTopo(myShape);
+ aread->setDisplayMode(theMode);
+ aread->GetOutput()->ReleaseDataFlagOn();
+
+ vtkPolyDataMapper* aMapper = vtkPolyDataMapper::New();
+ if (theMode == 0) {
+ aMapper->SetInput(aread->GetOutput());
+ } else {
+ vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
+ normals->SetInput(aread->GetOutput());
+ aMapper->SetInput(normals->GetOutput());
+ }
+ aread->Delete();
+ this->SetMapper(theMode == 0? WireframeMapper = aMapper : ShadingMapper = aMapper);
+}
+
+void GEOM_Actor::CreateShadingMapper() {
+ CreateMapper(1);
+}
+
+
+void GEOM_Actor::CreateWireframeMapper() {
+ CreateMapper(0);
+}
+
+//-------------------------------------------------------------
+// Render function
+//-------------------------------------------------------------
+
+void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper)
+{
+ /* render the property */
+ if (!this->Property) {
+ // force creation of a property
+ this->GetProperty();
+ this->Property->SetInterpolation(1);
+ this->Property->SetRepresentationToSurface();
+ this->Property->SetAmbient(0.3);
+ this->Property->SetAmbientColor(0.88,0.86,0.2);
+ this->Property->SetDiffuseColor(0.99,0.7,0.21);
+ this->Property->SetSpecularColor(0.99,0.98,0.83);
+ }
+
+ if(!ishighlighted) {
+ if(myDisplayMode >= 1) {
+ // SHADING
+ this->Property = ShadingProperty;
+ }
+ else {
+ this->Property = WireframeProperty;
+ }
+
+ if ( ispreselected )
+ this->Property = PreviewProperty;
+ }
+
+ this->Property->Render(this, ren);
+ if (this->BackfaceProperty) {
+ this->BackfaceProperty->BackfaceRender(this, ren);
+ this->Device->SetBackfaceProperty(this->BackfaceProperty);
+ }
+ this->Device->SetProperty(this->Property);
+ // Store information on time it takes to render.
+ // We might want to estimate time from the number of polygons in mapper.
+ if(myDisplayMode >= 1) {
+ if((myShape.ShapeType() == TopAbs_WIRE) ||
+ (myShape.ShapeType() == TopAbs_EDGE) ||
+ (myShape.ShapeType() == TopAbs_VERTEX)) {
+ if ( !subshape ) {
+ if(WireframeMapper==NULL) CreateWireframeMapper();
+ } else
+ return;
+ }
+ else {
+ if(ShadingMapper==NULL) CreateShadingMapper();
+ }
+ }
+ else {
+ if(WireframeMapper==NULL) CreateWireframeMapper();
+ }
+ if(myShape.ShapeType() == TopAbs_VERTEX) {
+ if(ren){
+ //The parameter determine size of vertex actor relate to diagonal of RendererWindow
+ static float delta = 0.01;
+ float X1 = -1, Y1 = -1, Z1 = 0;
+ ren->ViewToWorld(X1,Y1,Z1);
+ float X2 = +1, Y2 = +1, Z2 = 0;
+ ren->ViewToWorld(X2,Y2,Z2);
+ Z2 = sqrt((X2-X1)*(X2-X1) + (Y2-Y1)*(Y2-Y1) + (Z2-Z1)*(Z2-Z1));
+ this->SetScale(Z2*delta);
+ }
+ vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
+ this->GetMatrix(ren->GetActiveCamera(), aMatrix);
+ this->Device->SetUserMatrix(aMatrix);
+ this->Device->Render(ren,this->Mapper);
+ aMatrix->Delete();
+ } else
+ this->Device->Render(ren, this->Mapper);
+ this->EstimatedRenderTime = WireframeMapper->GetTimeToDraw();
+}
+
+// SubShape
+void GEOM_Actor::SubShapeOn()
+{
+ subshape = true;
+}
+void GEOM_Actor::SubShapeOff()
+{
+ subshape = false;
+}
+
+//-------------------------------------------------------------
+// Opacity methods
+//-------------------------------------------------------------
+
+void GEOM_Actor::SetOpacity(float opa)
+{
+ //HighlightProperty->SetOpacity(opa);
+ SALOME_Actor::SetOpacity(opa);
+ ShadingProperty->SetOpacity(opa);
+}
+
+float GEOM_Actor::GetOpacity() {
+ return ShadingProperty->GetOpacity();
+}
+
+//-------------------------------------------------------------
+// Color methods
+//-------------------------------------------------------------
+void GEOM_Actor::SetColor(float r,float g,float b) {
+ ShadingProperty->SetColor(r,g,b);
+}
+
+void GEOM_Actor::GetColor(float& r,float& g,float& b) {
+ float color[3];
+ ShadingProperty->GetColor(color);
+ r = color[0];
+ g = color[1];
+ b = color[2];
+}
+
+//-------------------------------------------------------------
+// Highlight methods
+//-------------------------------------------------------------
+
+void GEOM_Actor::highlight(Standard_Boolean highlight) {
+
+ if(highlight && !ishighlighted) {
+ ishighlighted=true;
+ // build highlight property is necessary
+ if(HighlightProperty==NULL) {
+ HighlightProperty = vtkProperty::New();
+ HighlightProperty->SetAmbient(0.5);
+ HighlightProperty->SetDiffuse(0.3);
+ HighlightProperty->SetSpecular(0.2);
+ HighlightProperty->SetRepresentationToSurface();
+ HighlightProperty->SetAmbientColor(1, 1, 1);
+ HighlightProperty->SetDiffuseColor(1, 1, 1);
+ HighlightProperty->SetSpecularColor(0.5, 0.5, 0.5);
+ }
+
+ this->Property = HighlightProperty;
+
+ }
+ else if (!highlight) {
+ if(ishighlighted) {
+ ishighlighted=false;
+ if(myDisplayMode==1) {
+ //unhilight in shading
+ this->Property = ShadingProperty;
+ }
+ else {
+ //unhilight in wireframe
+ this->Property = WireframeProperty;
+ }
+ }
+ }
+}
+
+bool GEOM_Actor::hasHighlight()
+{
+ return true;
+}
+
+void GEOM_Actor::SetHighlightProperty(vtkProperty* Prop) {
+ this->HighlightProperty = Prop;
+}
+
+
+void GEOM_Actor::ReleaseGraphicsResources(vtkWindow *renWin)
+{
+ vtkActor::ReleaseGraphicsResources(renWin);
+
+ // broadcast the message down to the individual LOD mappers
+
+ if(WireframeMapper) this->WireframeMapper->ReleaseGraphicsResources(renWin);
+ if(ShadingMapper) this->ShadingMapper->ReleaseGraphicsResources(renWin);
+}
+
+
+// Copy the follower's composite 4x4 matrix into the matrix provided.
+void GEOM_Actor::GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result)
+{
+ double *pos, *vup;
+ double Rx[3], Ry[3], Rz[3], p1[3];
+ vtkMatrix4x4 *matrix = vtkMatrix4x4::New();
+ int i;
+ double distance;
+
+ this->GetOrientation();
+ this->Transform->Push();
+ this->Transform->PostMultiply();
+ this->Transform->Identity();
+
+ // apply user defined matrix last if there is one
+ if (this->UserMatrix)
+ {
+ this->Transform->Concatenate(this->UserMatrix);
+ }
+
+ this->Transform->Translate(-this->Origin[0],
+ -this->Origin[1],
+ -this->Origin[2]);
+ // scale
+ this->Transform->Scale(this->Scale[0],
+ this->Scale[1],
+ this->Scale[2]);
+
+ // rotate
+ this->Transform->RotateY(this->Orientation[1]);
+ this->Transform->RotateX(this->Orientation[0]);
+ this->Transform->RotateZ(this->Orientation[2]);
+
+ if (theCam)
+ {
+ // do the rotation
+ // first rotate y
+ pos = theCam->GetPosition();
+ vup = theCam->GetViewUp();
+
+ if (theCam->GetParallelProjection())
+ {
+ theCam->GetDirectionOfProjection(Rz);
+ }
+ else
+ {
+ distance = sqrt(
+ (pos[0] - this->Position[0])*(pos[0] - this->Position[0]) +
+ (pos[1] - this->Position[1])*(pos[1] - this->Position[1]) +
+ (pos[2] - this->Position[2])*(pos[2] - this->Position[2]));
+ for (i = 0; i < 3; i++)
+ {
+ Rz[i] = (pos[i] - this->Position[i])/distance;
+ }
+ }
+
+ vtkMath::Cross(vup,Rz,Rx);
+ vtkMath::Normalize(Rx);
+ vtkMath::Cross(Rz,Rx,Ry);
+
+ matrix->Element[0][0] = Rx[0];
+ matrix->Element[1][0] = Rx[1];
+ matrix->Element[2][0] = Rx[2];
+ matrix->Element[0][1] = Ry[0];
+ matrix->Element[1][1] = Ry[1];
+ matrix->Element[2][1] = Ry[2];
+ matrix->Element[0][2] = Rz[0];
+ matrix->Element[1][2] = Rz[1];
+ matrix->Element[2][2] = Rz[2];
+
+ this->Transform->Concatenate(matrix);
+ }
+
+ // translate to projection reference point PRP
+ // this is the camera's position blasted through
+ // the current matrix
+ p1[0] = this->Origin[0] + this->Position[0];
+ p1[1] = this->Origin[1] + this->Position[1];
+ p1[2] = this->Origin[2] + this->Position[2];
+
+ this->Transform->Translate(p1[0],p1[1],p1[2]);
+ this->Transform->GetMatrix(result);
+
+ matrix->Delete();
+ this->Transform->Pop();
+}
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_Actor.h
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+#ifndef GEOM_ACTOR_H
+#define GEOM_ACTOR_H
+
+#include "SALOME_Actor.h"
+
+//OpenCASCADE
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+
+
+class TopoDS_Shape;
+
+#ifdef _WIN_32
+#define VTKOCC_EXPORT __declspec (dllexport)
+#else
+#define VTKOCC_EXPORT
+#endif
+class VTKOCC_EXPORT GEOM_Actor : public SALOME_Actor {
+
+
+ public:
+ vtkTypeMacro(GEOM_Actor,SALOME_Actor);
+
+ static GEOM_Actor* New();
+
+ // Description:
+ // This causes the actor to be rendered. It, in turn, will render the actor's
+ // property and then mapper.
+ virtual void Render(vtkRenderer *, vtkMapper *);
+
+ // Description:
+ // Release any graphics resources that are being consumed by this actor.
+ // The parameter window could be used to determine which graphic
+ // resources to release.
+ void ReleaseGraphicsResources(vtkWindow *);
+
+ const TopoDS_Shape& getTopo();
+ void setInputShape(const TopoDS_Shape& ashape,double adef1,int imode);
+
+ double getDeflection();
+ void setDeflection(double adefl);
+
+ // SubShape
+ void SubShapeOn();
+ void SubShapeOff();
+
+ // Display Mode
+ void setDisplayMode(int);
+
+ // Highlight
+ void highlight(Standard_Boolean highlight);
+ bool hasHighlight();
+
+ void ShallowCopy(vtkProp *prop);
+
+ // Properties
+ void SetHighlightProperty(vtkProperty* Prop);
+ void SetWireframeProperty(vtkProperty* Prop);
+ void SetShadingProperty(vtkProperty* Prop);
+
+ // Opacity
+ void SetOpacity(float opa);
+ float GetOpacity();
+
+ // Color
+ void SetColor(float r,float g,float b);
+ void GetColor(float& r,float& g,float& b);
+
+ protected:
+
+ GEOM_Actor();
+ ~GEOM_Actor();
+ GEOM_Actor(const GEOM_Actor&) {};
+ void operator=(const GEOM_Actor&) {};
+
+ void CreateWireframeMapper();
+ void CreateShadingMapper();
+ void CreateMapper(int theMode);
+ void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
+
+
+ private:
+
+ bool subshape;
+
+ TopoDS_Shape myShape;
+ double deflection;
+
+ vtkMapper* ShadingMapper;
+ vtkMapper* WireframeMapper;
+
+ vtkProperty* ShadingProperty;
+ vtkProperty* WireframeProperty;
+ vtkProperty* HighlightProperty;
+
+};
+#endif //GEOM_ACTOR_H
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AssemblyBuilder.cxx
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+using namespace std;
+/*!
+ \class GEOM_AssemblyBuilder GEOM_AssemblyBuilder.h
+ \brief ....
+*/
+
+#include "GEOM_AssemblyBuilder.h"
+#include "GEOM_Actor.h"
+#include "utilities.h"
+
+// Open CASCADE Includes
+#include <TopExp_Explorer.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <Poly_Triangulation.hxx>
+#include <BRepBndLib.hxx>
+#include <BRep_Tool.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+
+// SALOME
+
+#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
+#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
+
+
+
+
+
+void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
+ vtkProperty* FaceProp,
+ vtkProperty* EdgeFProp,
+ vtkProperty* EdgeSProp,
+ vtkProperty* EdgeIProp,
+ vtkProperty* VertexProp,
+ vtkProperty* IsoPVProp,
+ vtkProperty* EdgePVProp,
+ vtkProperty* VertexPVProp)
+{
+ // Shading like default OCC material
+ FaceProp->SetRepresentationToSurface();
+ FaceProp->SetInterpolation(1);
+ FaceProp->SetAmbient(1.0);
+ FaceProp->SetDiffuse(1.0);
+ FaceProp->SetSpecular(0.4);
+ FaceProp->SetAmbientColor(0.329412, 0.223529, 0.027451);
+ FaceProp->SetDiffuseColor(0.780392, 0.568627, 0.113725);
+ FaceProp->SetSpecularColor(0.992157, 0.941176, 0.807843);
+
+ // Wireframe for iso
+ IsoProp->SetRepresentationToWireframe();
+ IsoProp->SetAmbientColor(0.5, 0.5, 0.5);
+ IsoProp->SetDiffuseColor(0.5, 0.5, 0.5);
+ IsoProp->SetSpecularColor(0.5, 0.5, 0.5);
+
+ // Wireframe for iso
+ IsoPVProp->SetRepresentationToWireframe();
+ IsoPVProp->SetAmbientColor(0, 1, 1);
+ IsoPVProp->SetDiffuseColor(0, 1, 1);
+ IsoPVProp->SetSpecularColor(0, 1, 1);
+
+ // Wireframe for shared edge
+ EdgeSProp->SetRepresentationToWireframe();
+ EdgeSProp->SetAmbientColor(1, 1, 0);
+ EdgeSProp->SetDiffuseColor(1, 1, 0);
+ EdgeSProp->SetSpecularColor(1, 1, 0);
+
+ // Wireframe for free edge
+ EdgeFProp->SetRepresentationToWireframe();
+ EdgeFProp->SetAmbientColor(0, 1, 0);
+ EdgeFProp->SetDiffuseColor(0, 1, 0);
+ EdgeFProp->SetSpecularColor(0, 1, 0);
+
+ // Wireframe for isolated edge
+ EdgeIProp->SetRepresentationToWireframe();
+ EdgeIProp->SetAmbientColor(1, 0, 0);
+ EdgeIProp->SetDiffuseColor(1, 0, 0);
+ EdgeIProp->SetSpecularColor(1, 0, 0);
+
+ // Wireframe for Preview edge
+ EdgePVProp->SetRepresentationToWireframe();
+ EdgePVProp->SetAmbientColor(0, 1, 1);
+ EdgePVProp->SetDiffuseColor(0, 1, 1);
+ EdgePVProp->SetSpecularColor(0, 1, 1);
+
+ // Wireframe for vertex
+ VertexProp->SetRepresentationToWireframe();
+ VertexProp->SetAmbientColor(1, 1, 0);
+ VertexProp->SetDiffuseColor(1, 1, 0);
+ VertexProp->SetSpecularColor(1, 1, 0);
+
+ // Wireframe for vertex
+ VertexPVProp->SetRepresentationToWireframe();
+ VertexPVProp->SetAmbientColor(0, 1, 1);
+ VertexPVProp->SetDiffuseColor(0, 1, 1);
+ VertexPVProp->SetSpecularColor(0, 1, 1);
+}
+
+
+void GEOM_AssemblyBuilder::MeshShape(const TopoDS_Shape myShape,
+ Standard_Real deflection,
+ Standard_Boolean forced)
+{
+ // Mesh the shape if necessary
+ Standard_Boolean alreadymesh = Standard_True;
+ TopExp_Explorer ex;
+ TopLoc_Location aLoc;
+
+ for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
+ const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
+ Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
+ if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
+ }
+
+ if(!alreadymesh || forced) {
+ if(deflection<=0) {
+ // Compute default deflection
+ Bnd_Box B;
+ BRepBndLib::Add(myShape, B);
+ Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
+ B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
+ deflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin) * 0.001 *4;
+ }
+ BRepMesh_IncrementalMesh MESH(myShape,deflection);
+ }
+}
+
+
+
+vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
+ Standard_Real deflection,
+ Standard_Integer mode,
+ Standard_Boolean forced) {
+
+ vtkActorCollection* AISActors = vtkActorCollection::New();
+
+ if(myShape.ShapeType() == TopAbs_COMPOUND) {
+ TopoDS_Iterator anItr(myShape);
+ for(; anItr.More(); anItr.Next()) {
+ vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
+ theActors->InitTraversal();
+ vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
+ while(!(anActor==NULL)) {
+ AISActors->AddItem(anActor);
+ anActor = (vtkActor*)theActors->GetNextActor();
+ }
+ }
+ }
+ // Create graphics properties
+
+ vtkProperty* IsoProp = vtkProperty::New();
+ vtkProperty* FaceProp = vtkProperty::New();
+ vtkProperty* EdgeFProp = vtkProperty::New();
+ vtkProperty* EdgeSProp = vtkProperty::New();
+ vtkProperty* EdgeIProp = vtkProperty::New();
+ vtkProperty* VertexProp = vtkProperty::New();
+
+ vtkProperty* IsoPVProp = vtkProperty::New();
+ vtkProperty* EdgePVProp = vtkProperty::New();
+ vtkProperty* VertexPVProp = vtkProperty::New();
+
+ InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
+
+ MeshShape(myShape,deflection,forced);
+
+ if ( myShape.ShapeType() <= 4 && myShape.ShapeType() != TopAbs_COMPOUND) {
+
+ // FACE Actor
+ // look if edges are free or shared
+ TopTools_IndexedDataMapOfShapeListOfShape edgemap;
+ TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
+
+ TopExp_Explorer ex;
+
+ for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
+
+ GEOM_Actor* FaceActor = GEOM_Actor::New();
+ FaceActor->SetShadingProperty(FaceProp);
+ FaceActor->SetWireframeProperty(IsoProp);
+
+ FaceActor->SetPreviewProperty(IsoPVProp);
+
+ FaceActor->setInputShape(ex.Current(),deflection,mode);
+
+ AISActors->AddItem(FaceActor);
+
+ TopExp_Explorer ex2;
+ for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
+ const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
+
+ if (BRep_Tool::Degenerated(aEdge)) {
+ continue;
+ }
+
+ // compute the number of faces
+ Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
+ GEOM_Actor* EdgeActor = GEOM_Actor::New();
+ EdgeActor->SubShapeOn();
+ EdgeActor->setInputShape(ex2.Current(),deflection,mode);
+ switch (nbf) {
+
+ case 0 : // isolated edge
+ {
+ EdgeActor->SetShadingProperty(EdgeIProp);
+ EdgeActor->SetWireframeProperty(EdgeIProp);
+ }
+ break;
+
+ case 1 :// edge in only one face
+ {
+ EdgeActor->SetShadingProperty(EdgeFProp);
+ EdgeActor->SetWireframeProperty(EdgeFProp);
+ }
+ break;
+
+ default : // edge shared by at least two faces
+ {
+ EdgeActor->SetShadingProperty(EdgeSProp);
+ EdgeActor->SetWireframeProperty(EdgeSProp);
+ }
+ }
+ EdgeActor->SetPreviewProperty(EdgePVProp);
+ AISActors->AddItem(EdgeActor);
+ }
+ }
+ } else if ( myShape.ShapeType() == TopAbs_WIRE ) { // WIRE Actor
+ TopExp_Explorer ex;
+ for (ex.Init(myShape, TopAbs_EDGE); ex.More(); ex.Next()) {
+ const TopoDS_Edge& aEdge = TopoDS::Edge(ex.Current());
+
+ if (BRep_Tool::Degenerated(aEdge)) {
+ continue;
+ }
+
+ GEOM_Actor* EdgeActor = GEOM_Actor::New();
+ EdgeActor->setInputShape(ex.Current(),deflection,mode);
+ EdgeActor->SetShadingProperty(EdgeIProp);
+ EdgeActor->SetWireframeProperty(EdgeIProp);
+ EdgeActor->SetPreviewProperty(EdgePVProp);
+
+ AISActors->AddItem(EdgeActor);
+ }
+ } else if ( myShape.ShapeType() == TopAbs_EDGE ) { // EDGE Actor
+ GEOM_Actor* EdgeActor = GEOM_Actor::New();
+ EdgeActor->setInputShape(myShape,deflection,mode);
+ EdgeActor->SetShadingProperty(EdgeIProp);
+ EdgeActor->SetWireframeProperty(EdgeIProp);
+ EdgeActor->SetPreviewProperty(EdgePVProp);
+
+ AISActors->AddItem(EdgeActor);
+ } else if ( myShape.ShapeType() == TopAbs_VERTEX ) { // VERTEX Actor
+ GEOM_Actor* VertexActor = GEOM_Actor::New();
+ VertexActor->setInputShape(myShape,deflection,mode);
+ VertexActor->SetShadingProperty(VertexProp);
+ VertexActor->SetWireframeProperty(VertexProp);
+ VertexActor->SetPreviewProperty(VertexPVProp);
+
+ AISActors->AddItem(VertexActor);
+
+ }
+
+ return AISActors;
+
+}
+
+
+
+//-------------------------------------------------------------
+// BUILD ASSEMBLY
+//-------------------------------------------------------------
+vtkAssembly* GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
+ Standard_Real deflection,
+ Standard_Integer mode,
+ Standard_Boolean forced)
+{
+ // Create a new vtkAssembly
+
+ vtkAssembly* myVTKShape = vtkAssembly::New();
+
+
+ // Create graphics properties
+
+ vtkProperty* IsoProp = vtkProperty::New();
+ vtkProperty* FaceProp = vtkProperty::New();
+ vtkProperty* EdgeFProp = vtkProperty::New();
+ vtkProperty* EdgeSProp = vtkProperty::New();
+ vtkProperty* EdgeIProp = vtkProperty::New();
+ vtkProperty* VertexProp = vtkProperty::New();
+ vtkProperty* EdgePVProp = vtkProperty::New();
+ vtkProperty* VertexPVProp = vtkProperty::New();
+ vtkProperty* IsoPVProp = vtkProperty::New();
+
+ InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
+
+ MeshShape(myShape,deflection,forced);
+
+
+ // FACE Actor
+
+ // look if edges are free or shared
+ TopTools_IndexedDataMapOfShapeListOfShape edgemap;
+ TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
+
+ TopExp_Explorer ex;
+
+ for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
+ //const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
+
+ GEOM_Actor* FaceActor = GEOM_Actor::New();
+ FaceActor->SetShadingProperty(FaceProp);
+ FaceActor->SetWireframeProperty(IsoProp);
+
+ vtkAssembly* myFaceAssembly = vtkAssembly::New();
+
+
+ FaceActor->setInputShape(ex.Current(),deflection,mode);
+ myFaceAssembly->AddPart(FaceActor);
+
+ TopExp_Explorer ex2;
+ for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
+ const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
+
+ if (BRep_Tool::Degenerated(aEdge)) {
+ continue;
+ }
+
+
+ // compute the number of faces
+ Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
+ GEOM_Actor* EdgeActor = GEOM_Actor::New();
+ switch (nbf) {
+
+ case 0 : // isolated edge
+ {
+ EdgeActor->SetShadingProperty(EdgeIProp);
+ EdgeActor->SetWireframeProperty(EdgeIProp);
+ }
+ break;
+
+ case 1 :// edge in only one face
+ {
+ EdgeActor->SetShadingProperty(EdgeFProp);
+ EdgeActor->SetWireframeProperty(EdgeFProp);
+ }
+ break;
+
+ default : // edge shared by at least two faces
+ {
+ EdgeActor->SetShadingProperty(EdgeSProp);
+ EdgeActor->SetWireframeProperty(EdgeSProp);
+ }
+ }
+
+ EdgeActor->setInputShape(ex2.Current(),deflection,mode);
+ myFaceAssembly->AddPart(EdgeActor);
+ }
+ myVTKShape->AddPart(myFaceAssembly);
+ }
+
+ return myVTKShape;
+
+}
+
+//-------------------------------------------------------------
+// CHANGE SPECIFIC DISPLAY MODE
+//-------------------------------------------------------------
+void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkAssembly* aOCCAssembly)
+{
+}
+
+void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkActorCollection* aOCCAssembly)
+{
+}
+
+//-------------------------------------------------------------
+// DISPLAY/ERASE
+//-------------------------------------------------------------
+
+void GEOM_AssemblyBuilder::DisplayErase(vtkAssembly* mySALOMEAssembly)
+{
+}
+
+
+void GEOM_AssemblyBuilder::DisplayErase(vtkActorCollection* mySALOMEActors)
+{
+}
+
+
+
+
+
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AssemblyBuilder.h
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+#include <vtkAssembly.h>
+#include <vtkPropAssembly.h>
+#include <vtkActorCollection.h>
+
+// Open CASCADE Inlcudes
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+class GEOM_AssemblyBuilder {
+
+ private:
+
+ static void InitProperties(vtkProperty* IsoProp,
+ vtkProperty* FaceProp,
+ vtkProperty* EdgeFProp,
+ vtkProperty* EdgeSProp,
+ vtkProperty* EdgeIProp,
+ vtkProperty* VertexProp,
+ vtkProperty* IsoPVProp,
+ vtkProperty* EdgePVProp,
+ vtkProperty* VertePVProp);
+
+ static void MeshShape(const TopoDS_Shape myShape,
+ Standard_Real deflection,
+ Standard_Boolean forced);
+
+
+ public:
+
+
+ //------------------------------------------------------------------
+ // WARNING! Poor graphic performance :-( use BuildActors instead
+ //------------------------------------------------------------------
+
+ static vtkAssembly* BuildAssembly(const TopoDS_Shape& myShape,
+ Standard_Real deflection,
+ Standard_Integer amode,
+ Standard_Boolean forced);
+
+ //------------------------------------------------------------------
+ // Good performance
+ //------------------------------------------------------------------
+
+ static vtkActorCollection* BuildActors(const TopoDS_Shape& myShape,
+ Standard_Real deflection,
+ Standard_Integer amode,
+ Standard_Boolean forced);
+
+
+ //------------------------------------------------------------------
+ // Change mode - Not implemented !!
+ //------------------------------------------------------------------
+
+ static void SwitchDisplayMode(vtkAssembly* mySALOMEAssembly);
+ static void SwitchDisplayMode(vtkActorCollection* mySALOMEActors);
+
+ //------------------------------------------------------------------
+ // Erase/Display - Not implemented !!
+ //------------------------------------------------------------------
+
+ static void DisplayErase(vtkAssembly* mySALOMEAssembly);
+ static void DisplayErase(vtkActorCollection* mySALOMEActors);
+
+
+};
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_InteractiveObject.cxx
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+using namespace std;
+/*!
+ \class GEOM_InteractiveObject GEOM_InteractiveObject.hxx
+ \brief ....
+*/
+
+#include "GEOM_InteractiveObject.ixx"
+
+GEOM_InteractiveObject::GEOM_InteractiveObject()
+ : SALOME_InteractiveObject()
+{
+ myIOR = "";
+ myFatherIOR = "";
+}
+
+GEOM_InteractiveObject::GEOM_InteractiveObject(const Standard_CString anIOR,
+ const Standard_CString aFatherIOR,
+ const Standard_CString aComponentDataType,
+ const Standard_CString anEntry)
+ : SALOME_InteractiveObject(anEntry,aComponentDataType)
+{
+ myIOR = new char [strlen(anIOR)+1];
+ strcpy( myIOR, anIOR);
+ myFatherIOR = new char [strlen(aFatherIOR)+1];
+ strcpy( myFatherIOR, aFatherIOR);
+}
+
+Standard_CString GEOM_InteractiveObject::getIOR(){
+ return myIOR;
+}
+Standard_CString GEOM_InteractiveObject::getFatherIOR(){
+ return myFatherIOR;
+}
+
+Standard_Boolean GEOM_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){
+ if ( anIO->hasEntry() && this->hasEntry() ) {
+ if ( strcmp(myEntry, anIO->getEntry() ) == 0 )
+ return Standard_True;
+ }
+
+ if ( anIO->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) {
+ Handle(GEOM_InteractiveObject) theIO = Handle(GEOM_InteractiveObject)::DownCast( anIO );
+ if ( strcmp(myIOR, theIO->getIOR() ) == 0 )
+ return Standard_True;
+ }
+
+ return Standard_False;
+}
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_InteractiveObject.hxx
+// Module : GEOM
+
+#ifndef _GEOM_InteractiveObject_HeaderFile
+#define _GEOM_InteractiveObject_HeaderFile
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Handle_GEOM_InteractiveObject_HeaderFile
+#include "Handle_GEOM_InteractiveObject.hxx"
+#endif
+
+#ifndef _Standard_CString_HeaderFile
+#include <Standard_CString.hxx>
+#endif
+#ifndef _SALOME_InteractiveObject_HeaderFile
+#include "SALOME_InteractiveObject.hxx"
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
+#include "Handle_SALOME_InteractiveObject.hxx"
+#endif
+class SALOME_InteractiveObject;
+
+
+class GEOM_InteractiveObject : public SALOME_InteractiveObject {
+
+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_InteractiveObject();
+Standard_EXPORT GEOM_InteractiveObject(const Standard_CString anIOR,
+ const Standard_CString aFatherIOR,
+ const Standard_CString aComponentDataType,
+ const Standard_CString anEntry = "");
+Standard_EXPORT void setIOR(const Standard_CString anEntry) ;
+Standard_EXPORT Standard_CString getIOR() ;
+Standard_EXPORT void setFatherIOR(const Standard_CString anEntry) ;
+Standard_EXPORT Standard_CString getFatherIOR() ;
+Standard_EXPORT virtual Standard_Boolean isSame(const Handle(SALOME_InteractiveObject)& anIO) ;
+Standard_EXPORT ~GEOM_InteractiveObject();
+
+
+
+
+ // Type management
+ //
+ Standard_EXPORT friend Handle_Standard_Type& GEOM_InteractiveObject_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_CString myIOR;
+Standard_CString myFatherIOR;
+
+
+};
+
+
+
+
+
+// other inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_InteractiveObject.ixx
+// Module : GEOM
+
+#include "GEOM_InteractiveObject.jxx"
+
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#endif
+
+GEOM_InteractiveObject::~GEOM_InteractiveObject() {}
+
+
+
+Standard_EXPORT Handle_Standard_Type& GEOM_InteractiveObject_Type_()
+{
+
+ static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_InteractiveObject);
+ if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_InteractiveObject);
+ 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_InteractiveObject",
+ sizeof(GEOM_InteractiveObject),
+ 1,
+ (Standard_Address)_Ancestors,
+ (Standard_Address)NULL);
+
+ return _aType;
+}
+
+
+// DownCast method
+// allow safe downcasting
+//
+const Handle(GEOM_InteractiveObject) Handle(GEOM_InteractiveObject)::DownCast(const Handle(Standard_Transient)& AnObject)
+{
+ Handle(GEOM_InteractiveObject) _anOtherObject;
+
+ if (!AnObject.IsNull()) {
+ if (AnObject->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) {
+ _anOtherObject = Handle(GEOM_InteractiveObject)((Handle(GEOM_InteractiveObject)&)AnObject);
+ }
+ }
+
+ return _anOtherObject ;
+}
+const Handle(Standard_Type)& GEOM_InteractiveObject::DynamicType() const
+{
+ return STANDARD_TYPE(GEOM_InteractiveObject) ;
+}
+Standard_Boolean GEOM_InteractiveObject::IsKind(const Handle(Standard_Type)& AType) const
+{
+ return (STANDARD_TYPE(GEOM_InteractiveObject) == AType || SALOME_InteractiveObject::IsKind(AType));
+}
+Handle_GEOM_InteractiveObject::~Handle_GEOM_InteractiveObject() {}
+
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_InteractiveObject.jxx
+// Module : GEOM
+
+#ifndef _SALOME_InteractiveObject_HeaderFile
+#include "SALOME_InteractiveObject.hxx"
+#endif
+#ifndef _GEOM_InteractiveObject_HeaderFile
+#include "GEOM_InteractiveObject.hxx"
+#endif
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_OCCReader.h
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GEOM_OCCReader.h"
+
+// SALOME Includes
+#include "utilities.h"
+
+// VTK Includes
+#include "VTKViewer_Common.h"
+#include <vtkMergePoints.h>
+
+// OpenCASCADE Includes
+#include <BRepAdaptor_Surface.hxx>
+#include <TopExp_Explorer.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Poly_Polygon3D.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepBndLib.hxx>
+#include <TopoDS.hxx>
+#include <TopAbs.hxx>
+#include <Precision.hxx>
+#include <BRepTools.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dHatch_Intersector.hxx>
+#include <Geom2dHatch_Hatcher.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <HatchGen_Domain.hxx>
+#include <GeomAbs_IsoType.hxx>
+#include <Precision.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Pnt2d.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <Adaptor3d_HCurve.hxx>
+
+
+#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
+#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
+
+// Constante for iso building
+static Standard_Real IntersectorConfusion = 1.e-10 ; // -8 ;
+static Standard_Real IntersectorTangency = 1.e-10 ; // -8 ;
+static Standard_Real HatcherConfusion2d = 1.e-8 ;
+static Standard_Real HatcherConfusion3d = 1.e-8 ;
+
+static Standard_Integer lastVTKpoint = 0;
+static Standard_Integer PlotCount = 0;
+static Standard_Real IsoRatio = 1.001;
+static Standard_Integer MaxPlotCount = 5;
+
+//=======================================================================
+// Function : New
+// Purpose :
+//=======================================================================
+
+GEOM_OCCReader* GEOM_OCCReader::New()
+{
+ vtkObject* ret = vtkObjectFactory::CreateInstance("GEOM_OCCReader");
+ if(ret) {
+ return (GEOM_OCCReader*)ret;
+ }
+ return new GEOM_OCCReader;
+}
+
+//=======================================================================
+// Function : GEOM_OCCReader
+// Purpose :
+//=======================================================================
+
+GEOM_OCCReader::GEOM_OCCReader()
+{
+ //this->myShape = NULL;
+ this->amode = 0;
+ this->forced = Standard_False;
+ this->discretiso = 15;
+ this->nbisos = 1;
+}
+//=======================================================================
+// Function : ~GEOM_OCCReader
+// Purpose :
+//=======================================================================
+
+GEOM_OCCReader::~GEOM_OCCReader()
+{
+}
+
+
+//=======================================================================
+// Function : Execute
+// Purpose :
+//=======================================================================
+
+
+void GEOM_OCCReader::Execute() {
+
+ vtkPolyData* output = this->GetOutput();
+ vtkPoints* Pts = NULL;
+ vtkCellArray* Cells = NULL;
+ TopLoc_Location aLoc;
+
+ // Allocation
+ Pts = vtkPoints::New();
+ Cells = vtkCellArray::New();
+
+ //Compute number of triangles and points
+ Standard_Integer nbpoly=0,nbpts=0;
+
+ if(amode==1) {
+ //for shading
+
+ if(myShape.ShapeType() == TopAbs_FACE) {
+ // whole FACE
+ const TopoDS_Face& aFace = TopoDS::Face(myShape);
+ Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
+ if(aPoly.IsNull()) {
+ Pts->Delete();
+ Cells->Delete();
+ return;
+ }
+
+ nbpts = aPoly->NbNodes();
+ nbpoly = aPoly->NbTriangles();
+
+ Pts->SetNumberOfPoints(nbpts);
+ Cells->Allocate(Cells->EstimateSize(nbpoly,3));
+ }
+ else {
+ Cells->Delete();
+ Pts->Delete();
+ return;
+ }
+ }
+
+ // Start computation
+ if(amode == 0) {
+ ComputeWireframe(Pts,Cells);
+ output->SetPoints(Pts);
+ output->SetLines(Cells);
+ output->Squeeze();
+ }
+ else {
+ if(myShape.ShapeType() == TopAbs_FACE) {
+ ComputeShading(Pts,Cells);
+
+ output->SetPoints(Pts);
+ output->SetPolys(Cells);
+ output->Squeeze();
+ }
+ }
+ Pts->Delete();
+ Cells->Delete();
+
+}
+
+//=======================================================================
+// Function : ComputeWireframe
+// Purpose : Compute the shape in CAD wireframe mode
+//=======================================================================
+
+void GEOM_OCCReader::ComputeWireframe(vtkPoints* Pts,vtkCellArray* Cells){
+
+ // Check the type of the shape:
+ if(myShape.ShapeType() == TopAbs_FACE) {
+ // Face
+ TransferFaceWData(TopoDS::Face(myShape),Pts,Cells);
+ } else if(myShape.ShapeType() == TopAbs_EDGE) {
+ // Edge
+ TransferEdgeWData(TopoDS::Edge(myShape),Pts,Cells);
+ } else {
+ if(myShape.ShapeType() == TopAbs_VERTEX) {
+ // Vertex
+ TransferVertexWData(TopoDS::Vertex(myShape),Pts,Cells);
+ }
+ }
+}
+
+//=======================================================================
+// Function : TransferFaceWData
+// Purpose : Transfert wireframe data for FACE
+//=======================================================================
+
+void GEOM_OCCReader::TransferFaceWData(const TopoDS_Face& aFace,
+ vtkPoints* Pts,
+ vtkCellArray* Cells)
+{
+ TopoDS_Face aCopyFace = aFace;
+ aCopyFace.Orientation (TopAbs_FORWARD);
+ createISO(aCopyFace,Precision::Infinite(),1,Pts,Cells);
+}
+
+//=======================================================================
+// Function : createISO
+// Purpose : Create ISO for Face Wireframe representation
+//=======================================================================
+
+void GEOM_OCCReader::createISO (const TopoDS_Face& TopologicalFace,
+ const Standard_Real Infinite,
+ const Standard_Integer NbIsos,
+ vtkPoints* Pts,
+ vtkCellArray* Cell)
+{
+ Geom2dHatch_Hatcher aHatcher (Geom2dHatch_Intersector (IntersectorConfusion,
+ IntersectorTangency),
+ HatcherConfusion2d,
+ HatcherConfusion3d,
+ Standard_True,
+ Standard_False);
+
+ Standard_Real myInfinite,myUMin,myUMax,myVMin,myVMax;
+ //myInfinite = Precision::Infinite();
+ myInfinite = 1e38; // VTK uses float numbers - Precision::Infinite() is double and can not be accepted.
+
+ Standard_Integer myNbDom;
+ TColStd_Array1OfReal myUPrm(1, NbIsos),myVPrm(1, NbIsos);
+ TColStd_Array1OfInteger myUInd(1, NbIsos),myVInd(1, NbIsos);
+
+ myUInd.Init(0);
+ myVInd.Init(0);
+
+ //-----------------------------------------------------------------------
+ // If the Min Max bounds are infinite, there are bounded to Infinite
+ // value.
+ //-----------------------------------------------------------------------
+
+ BRepTools::UVBounds (TopologicalFace, myUMin, myUMax, myVMin, myVMax) ;
+ Standard_Boolean InfiniteUMin = Precision::IsNegativeInfinite (myUMin) ;
+ Standard_Boolean InfiniteUMax = Precision::IsPositiveInfinite (myUMax) ;
+ Standard_Boolean InfiniteVMin = Precision::IsNegativeInfinite (myVMin) ;
+ Standard_Boolean InfiniteVMax = Precision::IsPositiveInfinite (myVMax) ;
+ if (InfiniteUMin && InfiniteUMax) {
+ myUMin = - myInfinite ;
+ myUMax = myInfinite ;
+ } else if (InfiniteUMin) {
+ myUMin = myUMax - myInfinite ;
+ } else if (InfiniteUMax) {
+ myUMax = myUMin + myInfinite ;
+ }
+ if (InfiniteVMin && InfiniteVMax) {
+ myVMin = - myInfinite ;
+ myVMax = myInfinite ;
+ } else if (InfiniteVMin) {
+ myVMin = myVMax - myInfinite ;
+ } else if (InfiniteVMax) {
+ myVMax = myVMin + myInfinite ;
+ }
+
+ //-----------------------------------------------------------------------
+ // Retreiving the edges and loading them into the hatcher.
+ //-----------------------------------------------------------------------
+
+ TopExp_Explorer ExpEdges ;
+ for (ExpEdges.Init (TopologicalFace, TopAbs_EDGE) ; ExpEdges.More() ; ExpEdges.Next()) {
+ const TopoDS_Edge& TopologicalEdge = TopoDS::Edge (ExpEdges.Current()) ;
+ Standard_Real U1, U2 ;
+ const Handle(Geom2d_Curve) PCurve = BRep_Tool::CurveOnSurface (TopologicalEdge, TopologicalFace, U1, U2) ;
+
+ if ( PCurve.IsNull() ) {
+ return;
+ }
+
+ if ( U1==U2) {
+ return;
+ }
+
+ //-- Test if a TrimmedCurve is necessary
+ if( Abs(PCurve->FirstParameter()-U1)<= Precision::PConfusion()
+ && Abs(PCurve->LastParameter()-U2)<= Precision::PConfusion()) {
+ aHatcher.AddElement (PCurve, TopologicalEdge.Orientation()) ;
+ }
+ else {
+ if (!PCurve->IsPeriodic()) {
+ Handle (Geom2d_TrimmedCurve) TrimPCurve =Handle(Geom2d_TrimmedCurve)::DownCast(PCurve);
+ if (!TrimPCurve.IsNull()) {
+ if (TrimPCurve->BasisCurve()->FirstParameter()-U1 > Precision::PConfusion() ||
+ U2-TrimPCurve->BasisCurve()->LastParameter() > Precision::PConfusion()) {
+ aHatcher.AddElement (PCurve, TopologicalEdge.Orientation()) ;
+ return;
+ }
+ }
+ else {
+ if (PCurve->FirstParameter()-U1 > Precision::PConfusion()){
+ U1=PCurve->FirstParameter();
+ }
+ if (U2-PCurve->LastParameter() > Precision::PConfusion()){
+ U2=PCurve->LastParameter();
+ }
+ }
+ }
+ Handle (Geom2d_TrimmedCurve) TrimPCurve = new Geom2d_TrimmedCurve (PCurve, U1, U2) ;
+ aHatcher.AddElement (TrimPCurve, TopologicalEdge.Orientation()) ;
+ }
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Loading and trimming the hatchings.
+ //-----------------------------------------------------------------------
+
+ Standard_Integer IIso ;
+ Standard_Real DeltaU = Abs (myUMax - myUMin) ;
+ Standard_Real DeltaV = Abs (myVMax - myVMin) ;
+ Standard_Real confusion = Min (DeltaU, DeltaV) * HatcherConfusion3d ;
+ aHatcher.Confusion3d (confusion) ;
+
+ Standard_Real StepU = DeltaU / (Standard_Real) NbIsos ;
+ if (StepU > confusion) {
+ Standard_Real UPrm = myUMin + StepU / 2. ;
+ gp_Dir2d Dir (0., 1.) ;
+ for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
+ myUPrm(IIso) = UPrm ;
+ gp_Pnt2d Ori (UPrm, 0.) ;
+ Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
+ myUInd(IIso) = aHatcher.AddHatching (HCur) ;
+ UPrm += StepU ;
+ }
+ }
+
+ Standard_Real StepV = DeltaV / (Standard_Real) NbIsos ;
+ if (StepV > confusion) {
+ Standard_Real VPrm = myVMin + StepV / 2. ;
+ gp_Dir2d Dir (1., 0.) ;
+ for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
+ myVPrm(IIso) = VPrm ;
+ gp_Pnt2d Ori (0., VPrm) ;
+ Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
+ myVInd(IIso) = aHatcher.AddHatching (HCur) ;
+ VPrm += StepV ;
+ }
+ }
+
+ //-----------------------------------------------------------------------
+ // Computation.
+ //-----------------------------------------------------------------------
+
+ aHatcher.Trim() ;
+
+ myNbDom = 0 ;
+ for (IIso = 1 ; IIso <= NbIsos ; IIso++) {
+ Standard_Integer Index ;
+
+ Index = myUInd(IIso) ;
+ if (Index != 0) {
+ if (aHatcher.TrimDone (Index) && !aHatcher.TrimFailed (Index)) {
+ aHatcher.ComputeDomains (Index);
+ if (aHatcher.IsDone (Index)) myNbDom = myNbDom + aHatcher.NbDomains (Index) ;
+ }
+ }
+
+ Index = myVInd(IIso) ;
+ if (Index != 0) {
+ if (aHatcher.TrimDone (Index) && !aHatcher.TrimFailed (Index)) {
+ aHatcher.ComputeDomains (Index);
+ if (aHatcher.IsDone (Index)) myNbDom = myNbDom + aHatcher.NbDomains (Index) ;
+ }
+ }
+ }
+
+ //-----------------------------------------------------------------------
+ // Push iso lines in vtk kernel
+ //-----------------------------------------------------------------------
+
+
+ Standard_Integer pt_start_idx = 0;
+
+ for (Standard_Integer UIso = myUPrm.Lower() ; UIso <= myUPrm.Upper() ; UIso++) {
+ Standard_Integer UInd = myUInd.Value (UIso) ;
+ if (UInd != 0) {
+ Standard_Real UPrm = myUPrm.Value (UIso) ;
+ if (!aHatcher.IsDone (UInd)) {
+ MESSAGE("DBRep_IsoBuilder:: U iso of parameter: "<<UPrm)
+ switch (aHatcher.Status (UInd)) {
+ case HatchGen_NoProblem : MESSAGE("No Problem") ; break ;
+ case HatchGen_TrimFailure : MESSAGE("Trim Failure") ; break ;
+ case HatchGen_TransitionFailure : MESSAGE("Transition Failure") ; break ;
+ case HatchGen_IncoherentParity : MESSAGE("Incoherent Parity") ; break ;
+ case HatchGen_IncompatibleStates : MESSAGE("Incompatible States") ; break ;
+ }
+ } else {
+ Standard_Integer NbDom = aHatcher.NbDomains (UInd) ;
+ for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++) {
+ const HatchGen_Domain& Dom = aHatcher.Domain (UInd, IDom) ;
+ Standard_Real V1 = Dom.HasFirstPoint() ? Dom.FirstPoint().Parameter() : myVMin - myInfinite ;
+ Standard_Real V2 = Dom.HasSecondPoint() ? Dom.SecondPoint().Parameter() : myVMax + myInfinite ;
+ DrawIso(GeomAbs_IsoU, UPrm, V1, V2, Pts, Cell,pt_start_idx);
+ }
+ }
+ }
+ }
+
+ for (Standard_Integer VIso = myVPrm.Lower() ; VIso <= myVPrm.Upper() ; VIso++) {
+ Standard_Integer VInd = myVInd.Value (VIso) ;
+ if (VInd != 0) {
+ Standard_Real VPrm = myVPrm.Value (VIso) ;
+ if (!aHatcher.IsDone (VInd)) {
+ MESSAGE("DBRep_IsoBuilder:: V iso of parameter: "<<VPrm)
+ switch (aHatcher.Status (VInd)) {
+ case HatchGen_NoProblem : MESSAGE("No Problem") ; break ;
+ case HatchGen_TrimFailure : MESSAGE("Trim Failure") ; break ;
+ case HatchGen_TransitionFailure : MESSAGE("Transition Failure") ; break ;
+ case HatchGen_IncoherentParity : MESSAGE("Incoherent Parity") ; break ;
+ case HatchGen_IncompatibleStates : MESSAGE("Incompatible States") ; break ;
+ }
+ } else {
+ Standard_Integer NbDom = aHatcher.NbDomains (VInd) ;
+ for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++) {
+ const HatchGen_Domain& Dom = aHatcher.Domain (VInd, IDom) ;
+ Standard_Real U1 = Dom.HasFirstPoint() ? Dom.FirstPoint().Parameter() : myVMin - myInfinite ;
+ Standard_Real U2 = Dom.HasSecondPoint() ? Dom.SecondPoint().Parameter() : myVMax + myInfinite ;
+ DrawIso(GeomAbs_IsoV, VPrm, U1, U2, Pts, Cell,pt_start_idx) ;
+ }
+ }
+ }
+ }
+
+}
+
+//=======================================================================
+// Function : MoveTo
+// Purpose : Init VTK ISO PLOT
+//=======================================================================
+void GEOM_OCCReader::MoveTo(gp_Pnt P,
+ vtkPoints* Pts)
+{
+ float coord[3];
+
+ coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
+ lastVTKpoint = Pts->InsertNextPoint(coord);
+
+}
+
+//=======================================================================
+// Function : DrawTo
+// Purpose : Plot point in VTK
+//=======================================================================
+void GEOM_OCCReader::DrawTo(gp_Pnt P,
+ vtkPoints* Pts,
+ vtkCellArray* Cells)
+{
+ float coord[3];
+ coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
+ Standard_Integer NewVTKpoint = Pts->InsertNextPoint(coord);
+
+ int pts[2];
+ pts[0] = lastVTKpoint;
+ pts[1] = NewVTKpoint;
+
+ Cells->InsertNextCell(2,pts);
+
+ lastVTKpoint = NewVTKpoint;
+}
+
+
+//=======================================================================
+// Function : DrawIso
+// Purpose : Draw an iso on vtk
+//=======================================================================
+void GEOM_OCCReader::DrawIso(GeomAbs_IsoType T,
+ Standard_Real Par,
+ Standard_Real T1,
+ Standard_Real T2,
+ vtkPoints* Pts,
+ vtkCellArray* Cells,
+ Standard_Integer& startidx)
+{
+
+ Standard_Boolean halt = Standard_False;
+ Standard_Integer j,myDiscret = discretiso;
+ Standard_Real U1,U2,V1,V2,stepU=0.,stepV=0.;
+ gp_Pnt P;
+ TopLoc_Location l;
+
+ const Handle(Geom_Surface)& S = BRep_Tool::Surface(TopoDS::Face(myShape),l);
+ if (!S.IsNull()) {
+ BRepAdaptor_Surface S(TopoDS::Face(myShape),Standard_False);
+
+ GeomAbs_SurfaceType SurfType = S.GetType();
+
+ GeomAbs_CurveType CurvType = GeomAbs_OtherCurve;
+
+ Standard_Integer Intrv, nbIntv;
+ Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN);
+ Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN);
+ TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1);
+
+
+ if (T == GeomAbs_IsoU) {
+ S.VIntervals(TI, GeomAbs_CN);
+ V1 = Max(T1, TI(1));
+ V2 = Min(T2, TI(2));
+ U1 = Par;
+ U2 = Par;
+ stepU = 0;
+ nbIntv = nbVIntv;
+ }
+ else {
+ S.UIntervals(TI, GeomAbs_CN);
+ U1 = Max(T1, TI(1));
+ U2 = Min(T2, TI(2));
+ V1 = Par;
+ V2 = Par;
+ stepV = 0;
+ nbIntv = nbUIntv;
+ }
+
+ S.D0(U1,V1,P);
+ MoveTo(P,Pts);
+
+ for (Intrv = 1; Intrv <= nbIntv; Intrv++) {
+
+ if (TI(Intrv) <= T1 && TI(Intrv + 1) <= T1)
+ continue;
+ if (TI(Intrv) >= T2 && TI(Intrv + 1) >= T2)
+ continue;
+ if (T == GeomAbs_IsoU) {
+ V1 = Max(T1, TI(Intrv));
+ V2 = Min(T2, TI(Intrv + 1));
+ stepV = (V2 - V1) / myDiscret;
+ }
+ else {
+ U1 = Max(T1, TI(Intrv));
+ U2 = Min(T2, TI(Intrv + 1));
+ stepU = (U2 - U1) / myDiscret;
+ }
+
+ switch (SurfType) {
+ //-------------GeomAbs_Plane---------------
+ case GeomAbs_Plane :
+ break;
+ //----GeomAbs_Cylinder GeomAbs_Cone------
+ case GeomAbs_Cylinder :
+ case GeomAbs_Cone :
+ if (T == GeomAbs_IsoV) {
+ for (j = 1; j < myDiscret; j++) {
+ U1 += stepU;
+ V1 += stepV;
+ S.D0(U1,V1,P);
+ DrawTo(P,Pts,Cells);
+ }
+ }
+ break;
+ //---GeomAbs_Sphere GeomAbs_Torus--------
+ //GeomAbs_BezierSurface GeomAbs_BezierSurface
+ case GeomAbs_Sphere :
+ case GeomAbs_Torus :
+ case GeomAbs_OffsetSurface :
+ case GeomAbs_OtherSurface :
+ for (j = 1; j < myDiscret; j++) {
+ U1 += stepU;
+ V1 += stepV;
+ S.D0(U1,V1,P);
+ DrawTo(P,Pts,Cells);
+ }
+ break;
+ //-------------GeomAbs_BSplineSurface------
+ case GeomAbs_BezierSurface :
+ case GeomAbs_BSplineSurface :
+ for (j = 1; j <= myDiscret/2; j++) {
+
+ PlotCount = 0;
+
+ PlotIso ( S, T, U1, V1, (T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt, Pts, Cells);
+ U1 += stepU*2.;
+ V1 += stepV*2.;
+ }
+ break;
+ //-------------GeomAbs_SurfaceOfExtrusion--
+ //-------------GeomAbs_SurfaceOfRevolution-
+ case GeomAbs_SurfaceOfExtrusion :
+ case GeomAbs_SurfaceOfRevolution :
+ if ((T == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) ||
+ (T == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) {
+ if (SurfType == GeomAbs_SurfaceOfExtrusion) break;
+ for (j = 1; j < myDiscret; j++) {
+ U1 += stepU;
+ V1 += stepV;
+ S.D0(U1,V1,P);
+ DrawTo(P,Pts,Cells);
+ }
+ } else {
+ CurvType = (S.BasisCurve())->GetType();
+ switch (CurvType) {
+ case GeomAbs_Line :
+ break;
+ case GeomAbs_Circle :
+ case GeomAbs_Ellipse :
+ for (j = 1; j < myDiscret; j++) {
+ U1 += stepU;
+ V1 += stepV;
+ S.D0(U1,V1,P);
+ DrawTo(P,Pts,Cells);
+ }
+ break;
+ case GeomAbs_Parabola :
+ case GeomAbs_Hyperbola :
+ case GeomAbs_BezierCurve :
+ case GeomAbs_BSplineCurve :
+ case GeomAbs_OtherCurve :
+ for (j = 1; j <= myDiscret/2; j++) {
+
+ PlotCount = 0;
+
+ PlotIso ( S, T, U1, V1,(T == GeomAbs_IsoV) ? stepU*2. : stepV*2., halt, Pts, Cells);
+ U1 += stepU*2.;
+ V1 += stepV*2.;
+ }
+ break;
+ }
+ }
+ }
+ }
+ S.D0(U2,V2,P);
+ DrawTo(P,Pts,Cells);
+ }
+}
+
+//=======================================================================
+// Function : PlotIso
+// Purpose : Plot iso for other surface
+//=======================================================================
+
+void GEOM_OCCReader::PlotIso (BRepAdaptor_Surface& S,
+ GeomAbs_IsoType T,
+ Standard_Real& U,
+ Standard_Real& V,
+ Standard_Real Step,
+ Standard_Boolean& halt,
+ vtkPoints* Pts,
+ vtkCellArray* Cells)
+{
+
+ ++PlotCount;
+
+ gp_Pnt Pl, Pr, Pm;
+
+ if (T == GeomAbs_IsoU) {
+ S.D0(U, V, Pl);
+ S.D0(U, V + Step/2., Pm);
+ S.D0(U, V + Step, Pr);
+ } else {
+ S.D0(U, V, Pl);
+ S.D0(U + Step/2., V, Pm);
+ S.D0(U + Step, V, Pr);
+ }
+
+ if (PlotCount > MaxPlotCount) {
+ DrawTo(Pr,Pts,Cells);
+ return;
+ }
+
+ if (Pm.Distance(Pl) + Pm.Distance(Pr) <= IsoRatio*Pl.Distance(Pr)) {
+ DrawTo(Pr,Pts,Cells);
+ } else
+ if (T == GeomAbs_IsoU) {
+ PlotIso ( S, T, U, V, Step/2, halt, Pts, Cells);
+ Standard_Real aLocalV = V + Step/2 ;
+ PlotIso ( S, T, U, aLocalV , Step/2, halt, Pts, Cells);
+ } else {
+ PlotIso ( S, T, U, V, Step/2, halt, Pts, Cells);
+ Standard_Real aLocalU = U + Step/2 ;
+ PlotIso ( S, T, aLocalU , V, Step/2, halt, Pts, Cells);
+ }
+}
+
+//=======================================================================
+// Function : TransferEdgeWData
+// Purpose : Transfert wireframe data for EDGE
+//=======================================================================
+
+void GEOM_OCCReader::TransferEdgeWData(const TopoDS_Edge& aEdge,
+ vtkPoints* Pts,
+ vtkCellArray* Cells) {
+
+
+ Handle(Poly_PolygonOnTriangulation) aEdgePoly;
+ Standard_Integer i = 1;
+ Handle(Poly_Triangulation) T;
+ TopLoc_Location aEdgeLoc;
+ BRep_Tool::PolygonOnTriangulation(aEdge, aEdgePoly, T, aEdgeLoc, i);
+
+ Handle(Poly_Polygon3D) P;
+ if(aEdgePoly.IsNull()) {
+ P = BRep_Tool::Polygon3D(aEdge, aEdgeLoc);
+ }
+
+ if(P.IsNull() && aEdgePoly.IsNull())
+ return;
+
+ // Location edges
+ //---------------
+
+ gp_Trsf edgeTransf;
+ Standard_Boolean isidtrsf = true;
+ if(!aEdgeLoc.IsIdentity()) {
+ isidtrsf = false;
+ edgeTransf = aEdgeLoc.Transformation();
+ }
+
+ Standard_Integer nbnodes;
+ if (aEdgePoly.IsNull()) {
+ nbnodes = P->NbNodes();
+ const TColgp_Array1OfPnt& theNodesP = P->Nodes();
+
+ float coord[3];
+ int pts[2];
+
+ for(int j=1;j<nbnodes;j++) {
+ gp_Pnt pt1 = theNodesP(j);
+ gp_Pnt pt2 = theNodesP(j+1);
+
+ if(!isidtrsf) {
+ // apply edge transformation
+ pt1.Transform(edgeTransf);
+ pt2.Transform(edgeTransf);
+ }
+
+ // insert pt1
+ coord[0] = pt1.X(); coord[1] = pt1.Y(); coord[2] = pt1.Z();
+ pts[0] = Pts->InsertNextPoint(coord);
+
+ // insert pt2
+ coord[0] = pt2.X(); coord[1] = pt2.Y(); coord[2] = pt2.Z();
+ pts[1] = Pts->InsertNextPoint(coord);
+
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+ }
+ } else {
+ nbnodes = aEdgePoly->NbNodes();
+ const TColStd_Array1OfInteger& Nodesidx = aEdgePoly->Nodes();
+ const TColgp_Array1OfPnt& theNodesPoly = T->Nodes();
+
+ float coord[3];
+ int pts[2];
+
+ for(int j=1;j<nbnodes;j++) {
+ Standard_Integer id1 = Nodesidx(j);
+ Standard_Integer id2 = Nodesidx(j+1);
+
+ gp_Pnt pt1 = theNodesPoly(id1);
+ gp_Pnt pt2 = theNodesPoly(id2);
+
+ if(!isidtrsf) {
+ // apply edge transformation
+ pt1.Transform(edgeTransf);
+ pt2.Transform(edgeTransf);
+ }
+
+ // insert pt1
+ coord[0] = pt1.X(); coord[1] = pt1.Y(); coord[2] = pt1.Z();
+ pts[0] = Pts->InsertNextPoint(coord);
+
+ // insert pt2
+ coord[0] = pt2.X(); coord[1] = pt2.Y(); coord[2] = pt2.Z();
+ pts[1] = Pts->InsertNextPoint(coord);
+
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+ }
+ }
+}
+
+/* Standard_Integer nbnodes = aEdgePoly->NbNodes();
+ const TColStd_Array1OfInteger& Nodesidx = aEdgePoly->Nodes();
+ const TColgp_Array1OfPnt& theNodes = T->Nodes();
+
+ float coord[3];
+ int pts[2];
+
+
+ // PUSH NODES
+ for(i=1;i<=nbnodes;i++) {
+ Standard_Integer id = Nodesidx(i);
+ gp_Pnt pt = theNodes(id);
+
+ float coord[3];
+ if(!isidtrsf) pt.Transform(edgeTransf);
+
+ coord[0] = pt.X(); coord[1] = pt.Y(); coord[2] = pt.Z();
+
+ Pts->SetPoint(id-1,coord);
+
+ }
+
+ // PUSH EDGES
+ for(i=1;i<nbnodes;i++) {
+
+ Standard_Integer id1 = Nodesidx(i);
+ Standard_Integer id2 = Nodesidx(i+1);
+
+ int pts[2];
+ pts[0] = id1-1; pts[1] = id2-1;
+
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+ }
+
+
+ }*/
+
+//=======================================================================
+// Function : TransferVertexWData
+// Purpose : Transfert wireframe data for VERTEX
+//=======================================================================
+
+void GEOM_OCCReader::TransferVertexWData(const TopoDS_Vertex& aVertex,
+ vtkPoints* Pts,
+ vtkCellArray* Cells) {
+#define ZERO_COORD coord[0] = 0.0; coord[1] = 0.0; coord[2] = 0.0
+
+ gp_Pnt P = BRep_Tool::Pnt( aVertex );
+ float delta = 1, coord[3];
+ int pts[2];
+ // insert pt
+ ZERO_COORD; coord[0] = +delta;
+ pts[0] = Pts->InsertNextPoint(coord);
+ coord[0] = -delta;
+ pts[1] = Pts->InsertNextPoint(coord);
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+
+ ZERO_COORD; coord[1] = +delta;
+ pts[0] = Pts->InsertNextPoint(coord);
+ coord[1] = -delta;
+ pts[1] = Pts->InsertNextPoint(coord);
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+
+ ZERO_COORD; coord[2] = +delta;
+ pts[0] = Pts->InsertNextPoint(coord);
+ coord[2] = -delta;
+ pts[1] = Pts->InsertNextPoint(coord);
+ // insert line (pt1,pt2)
+ Cells->InsertNextCell(2,pts);
+
+#undef ZERO_COORD
+}
+
+//=======================================================================
+// Function : TransferEdgeSData(
+// Purpose : Transfert shading data for EDGE
+//=======================================================================
+
+void GEOM_OCCReader::TransferEdgeSData(const TopoDS_Edge& aFace,
+ vtkPoints* Pts,
+ vtkCellArray* Cells)
+{
+}
+
+
+//=======================================================================
+// Function : TransferFaceSData
+// Purpose : Transfert shading data for FACE
+//=======================================================================
+void GEOM_OCCReader::TransferFaceSData(const TopoDS_Face& aFace,
+ vtkPoints* Pts,
+ vtkCellArray* Cells) {
+
+ TopLoc_Location aLoc;
+ Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
+ if(aPoly.IsNull()) return;
+ else {
+
+ gp_Trsf myTransf;
+ Standard_Boolean identity = true;
+ if(!aLoc.IsIdentity()) {
+ identity = false;
+ myTransf = aLoc.Transformation();
+ }
+
+ Standard_Integer nbNodesInFace = aPoly->NbNodes();
+ Standard_Integer nbTriInFace = aPoly->NbTriangles();
+
+ const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
+ const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
+
+ Standard_Integer i;
+ for(i=1;i<=nbNodesInFace;i++) {
+ gp_Pnt P = Nodes(i);
+ float coord[3];
+ if(!identity) P.Transform(myTransf);
+ coord[0] = P.X(); coord[1] = P.Y(); coord[2] = P.Z();
+ Pts->SetPoint(i-1,coord);
+ }
+
+ for(i=1;i<=nbTriInFace;i++) {
+ // Get the triangle
+
+ Standard_Integer N1,N2,N3;
+ Triangles(i).Get(N1,N2,N3);
+
+ int pts[3];
+ pts[0] = N1-1; pts[1] = N2-1; pts[2] = N3-1;
+ Cells->InsertNextCell(3,pts);
+
+ }
+ }
+}
+
+//=======================================================================
+// Function : ComputeShading
+// Purpose : Compute the shape in shading mode
+//=======================================================================
+void GEOM_OCCReader::ComputeShading(vtkPoints* Pts,vtkCellArray* Cells){
+
+ // Check the type of the shape:
+ if(myShape.ShapeType() == TopAbs_FACE) {
+ // Face
+ TransferFaceSData(TopoDS::Face(myShape),Pts,Cells);
+ }
+ else {
+ if(myShape.ShapeType() == TopAbs_EDGE) {
+ // Edge
+ TransferEdgeSData(TopoDS::Edge(myShape),Pts,Cells);
+ }
+ else {
+ }
+
+ }
+
+}
+
+//=======================================================================
+// Function :
+// Purpose : Set parameters
+//=======================================================================
+void GEOM_OCCReader::setDisplayMode(int thenewmode) {
+ amode = thenewmode;
+}
+
+void GEOM_OCCReader::setTopo(const TopoDS_Shape& aShape) {
+ myShape = aShape;
+}
+
+void GEOM_OCCReader::setForceUpdate(Standard_Boolean bol) {
+ forced = bol;
+}
+
+//=======================================================================
+// Function :
+// Purpose : Get parameters
+//=======================================================================
+const TopoDS_Shape& GEOM_OCCReader::getTopo() {
+ return myShape;
+}
+
+int GEOM_OCCReader::getDisplayMode() {
+ return amode;
+}
+
+
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_OCCReader.h
+// Author : Christophe ATTANASIO
+// Module : GEOM
+// $Header$
+
+/*!
+ \class GEOM_OCCReader GEOM_OCCReader.h
+ \brief This class allow to display a OpenCASCADE CAD model in a VTK viewer.
+*/
+
+#ifndef GEOM_OCCREADER_H
+#define GEOM_OCCREADER_H
+
+// VTK
+#include "VTKViewer_Common.h"
+
+// OpenCASCADE
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <Poly_Polygon3D.hxx>
+#include <Poly_PolygonOnTriangulation.hxx>
+#include <GeomAbs_IsoType.hxx>
+#include <BRepAdaptor_Surface.hxx>
+
+#ifdef _WIN_32
+#define VTKOCC_EXPORT __declspec (dllexport)
+#else
+#define VTKOCC_EXPORT
+#endif
+class VTKOCC_EXPORT GEOM_OCCReader : public vtkPolyDataSource {
+
+ // methods
+
+ public:
+
+ static GEOM_OCCReader* New();
+
+ const TopoDS_Shape& getTopo();
+
+ void setTopo(const TopoDS_Shape& ashape);
+
+ int getDisplayMode();
+ void setDisplayMode(int);
+
+ void setForceUpdate(Standard_Boolean bol);
+
+ protected:
+
+ GEOM_OCCReader();
+ ~GEOM_OCCReader();
+ void Execute();
+
+ void ComputeShading(vtkPoints* Pts,vtkCellArray* Cells);
+ void ComputeWireframe(vtkPoints* Pts,vtkCellArray* Cells);
+
+ void TransferFaceSData(const TopoDS_Face& aFace,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void TransferFaceWData(const TopoDS_Face& aFace,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void TransferEdgeSData(const TopoDS_Edge& aEdge,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void TransferEdgeWData(const TopoDS_Edge& aEdge,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void TransferVertexWData(const TopoDS_Vertex& aVertex,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void createISO(const TopoDS_Face &,
+ double, int,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void DrawIso(GeomAbs_IsoType aType,
+ Standard_Real PParm,
+ Standard_Real p1,
+ Standard_Real p2,
+ vtkPoints* Pts,
+ vtkCellArray* Cells,
+ Standard_Integer& startidx);
+
+ void MoveTo(gp_Pnt P,
+ vtkPoints* Pts);
+
+ void DrawTo(gp_Pnt P,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ void PlotIso(BRepAdaptor_Surface& S,
+ GeomAbs_IsoType T,
+ Standard_Real& U,
+ Standard_Real& V,
+ Standard_Real Step,
+ Standard_Boolean& halt,
+ vtkPoints* Pts,
+ vtkCellArray* Cells);
+
+ // fields
+
+ private:
+
+ Standard_Boolean forced;
+ int discretiso;
+ int amode;
+ int nbisos;
+ TopoDS_Shape myShape;
+
+};
+
+#endif //GEOM_OCCREADER_H
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_AISShape.hxx
+// Module : GEOM
+
+#ifndef _Handle_GEOM_AISShape_HeaderFile
+#define _Handle_GEOM_AISShape_HeaderFile
+
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Handle_SALOME_AISShape_HeaderFile
+#include "Handle_SALOME_AISShape.hxx"
+#endif
+
+class Standard_Transient;
+class Handle_Standard_Type;
+class Handle(SALOME_AISShape);
+class GEOM_AISShape;
+Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_AISShape);
+
+class Handle(GEOM_AISShape) : public Handle(SALOME_AISShape) {
+ 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_AISShape)():Handle(SALOME_AISShape)() {}
+ Handle(GEOM_AISShape)(const Handle(GEOM_AISShape)& aHandle) : Handle(SALOME_AISShape)(aHandle)
+ {
+ }
+
+ Handle(GEOM_AISShape)(const GEOM_AISShape* anItem) : Handle(SALOME_AISShape)((SALOME_AISShape *)anItem)
+ {
+ }
+
+ Handle(GEOM_AISShape)& operator=(const Handle(GEOM_AISShape)& aHandle)
+ {
+ Assign(aHandle.Access());
+ return *this;
+ }
+
+ Handle(GEOM_AISShape)& operator=(const GEOM_AISShape* anItem)
+ {
+ Assign((Standard_Transient *)anItem);
+ return *this;
+ }
+
+ GEOM_AISShape* operator->()
+ {
+ return (GEOM_AISShape *)ControlAccess();
+ }
+
+ GEOM_AISShape* operator->() const
+ {
+ return (GEOM_AISShape *)ControlAccess();
+ }
+
+ Standard_EXPORT ~Handle(GEOM_AISShape)();
+
+ Standard_EXPORT static const Handle(GEOM_AISShape) DownCast(const Handle(Standard_Transient)& AnObject);
+};
+#endif
--- /dev/null
+// GEOM OBJECT : interactive object for Geometry entities visualization
+//
+// 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_InteractiveObject.hxx
+// Module : GEOM
+
+#ifndef _Handle_GEOM_InteractiveObject_HeaderFile
+#define _Handle_GEOM_InteractiveObject_HeaderFile
+
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
+#include "Handle_SALOME_InteractiveObject.hxx"
+#endif
+
+class Standard_Transient;
+class Handle_Standard_Type;
+class Handle(SALOME_InteractiveObject);
+class GEOM_InteractiveObject;
+Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOM_InteractiveObject);
+
+class Handle(GEOM_InteractiveObject) : public Handle(SALOME_InteractiveObject) {
+ 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_InteractiveObject)():Handle(SALOME_InteractiveObject)() {}
+ Handle(GEOM_InteractiveObject)(const Handle(GEOM_InteractiveObject)& aHandle) : Handle(SALOME_InteractiveObject)(aHandle)
+ {
+ }
+
+ Handle(GEOM_InteractiveObject)(const GEOM_InteractiveObject* anItem) : Handle(SALOME_InteractiveObject)((SALOME_InteractiveObject *)anItem)
+ {
+ }
+
+ Handle(GEOM_InteractiveObject)& operator=(const Handle(GEOM_InteractiveObject)& aHandle)
+ {
+ Assign(aHandle.Access());
+ return *this;
+ }
+
+ Handle(GEOM_InteractiveObject)& operator=(const GEOM_InteractiveObject* anItem)
+ {
+ Assign((Standard_Transient *)anItem);
+ return *this;
+ }
+
+ GEOM_InteractiveObject* operator->()
+ {
+ return (GEOM_InteractiveObject *)ControlAccess();
+ }
+
+ GEOM_InteractiveObject* operator->() const
+ {
+ return (GEOM_InteractiveObject *)ControlAccess();
+ }
+
+ Standard_EXPORT ~Handle(GEOM_InteractiveObject)();
+
+ Standard_EXPORT static const Handle(GEOM_InteractiveObject) DownCast(const Handle(Standard_Transient)& AnObject);
+};
+#endif
--- /dev/null
+# GEOM OBJECT : interactive object for Geometry entities visualization
+#
+# 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
+# Module : GEOM
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+EXPORT_HEADERS = GEOM_Actor.h \
+ GEOM_AssemblyBuilder.h \
+ GEOM_AISShape.hxx \
+ Handle_GEOM_AISShape.hxx \
+ GEOM_InteractiveObject.hxx \
+ Handle_GEOM_InteractiveObject.hxx
+
+
+# Libraries targets
+
+LIB = libGeometryObject.la
+LIB_SRC = GEOM_Actor.cxx \
+ GEOM_OCCReader.cxx \
+ GEOM_AssemblyBuilder.cxx \
+ GEOM_AISShape.cxx \
+ GEOM_InteractiveObject.cxx
+
+LIB_CLIENT_IDL =
+
+# Executables targets
+BIN =
+BIN_SRC =
+
+CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES)
+LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject
+
+%_moc.cxx: %.h
+ $(MOC) $< -o $@
+
+
+@CONCLUDE@
--- /dev/null
+# GEOM PARTITION : partition algorithm
+#
+# 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 : Marc Tajchman (CEA)
+# Module : GEOM
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+
+@COMMENCE@
+
+# Libraries targets
+LIB = libGeometryPartition.la
+LIB_SRC = Partition_Inter2d.cxx \
+ Partition_Inter3d.cxx \
+ Partition_Loop2d.cxx \
+ Partition_Loop3d.cxx \
+ Partition_Spliter.cxx
+
+LIB_CLIENT_IDL =
+LIB_SERVER_IDL =
+
+# header files
+EXPORT_HEADERS = Partition_Spliter.hxx \
+ Partition_Inter3d.hxx
+
+# idl files
+EXPORT_IDLS=
+
+
+CPPFLAGS += $(OCC_INCLUDES)
+CXXFLAGS += $(OCC_CXXFLAGS)
+LDFLAGS += $(OCC_LIBS)
+
+%_moc.cxx: %.h
+ $(MOC) $< -o $@
+
+@CONCLUDE@
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- 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 : Partition.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+package Partition
+
+uses
+ TopoDS,
+ TopTools,
+ TopAbs,
+ BRepAlgo,
+ BRep,
+ gp
+is
+ class Spliter;
+ class Inter3d;
+ class Inter2d;
+ class Loop2d;
+ class Loop3d;
+
+end Partition;
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- 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 : Partition_Inter2d.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+class Inter2d from Partition
+
+ ---Purpose: Computes the intersections between edges on a face
+ -- stores result is SD as AsDes from BRepAlgo.
+
+uses
+ AsDes from BRepAlgo,
+ Edge from TopoDS,
+ Face from TopoDS,
+ Vertex from TopoDS,
+ MapOfShape from TopTools,
+ Real from Standard,
+ ListOfShape from TopTools
+
+is
+ CompletPart2d(myclass ; AsDes : mutable AsDes from BRepAlgo;
+ F : Face from TopoDS;
+ NewEdges : MapOfShape from TopTools);
+
+ ---Purpose: Computes the intersections between the edges stored
+ -- is AsDes as descendants of <F> . Intersections is computed
+ -- between two edges if one of them is bound in NewEdges.
+
+
+ FindEndVertex(myclass; VertList : ListOfShape from TopTools;
+ f,l : Real from Standard;
+ E : Edge from TopoDS;
+ First : out Boolean from Standard;
+ DU : out Real from Standard)
+ returns Vertex from TopoDS;
+ ---Purpose: Returns a vertex from <VertList> having parameter on
+ -- <E> most close to <f> or <l>. <First> is True if
+ -- found vertex is closer to <f>. <DU> returns parameter
+ -- difference.
+
+ AddVonE(myclass; V : Vertex from TopoDS;
+ E1,E2 : Edge from TopoDS;
+ AsDes : mutable AsDes from BRepAlgo)
+ returns Vertex from TopoDS;
+ ---Purpose: Put V in AsDes as intersection of E1 and E2.
+ -- Check that vertex equal to V already exists on one
+ -- of edges, in such a case, V is not added but
+ -- existing vertex is updated to be on E1 and E2 and
+ -- is returned insead of V.
+
+end Inter2d;
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter2d.cxx
+// Author : Benedicte MARTIN
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "Partition_Inter2d.ixx"
+
+#include "utilities.h"
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRepAlgo_AsDes.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <BRepAdaptor_Curve.hxx>
+
+#include <gp_Pnt.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopOpeBRep_EdgesIntersector.hxx>
+#include <TopOpeBRep_Point2d.hxx>
+#include <TopOpeBRepDS_Transition.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+#include <stdio.h>
+#include <Precision.hxx>
+
+#ifdef DEB
+static Standard_Boolean TestEdges = 0;
+static Standard_Integer NbF2d = 0;
+static Standard_Integer NbE2d = 0;
+#endif
+
+//=======================================================================
+//function : StorePart2d
+//purpose :
+//=======================================================================
+
+// static void StorePart2d (const TopoDS_Edge& E1,
+// const TopoDS_Edge& E2,
+// TopTools_ListOfShape& LV1,
+// TopTools_ListOfShape& LV2,
+// Handle(BRepAlgo_AsDes) AsDes,
+// Standard_Real Tol)
+TopoDS_Vertex Partition_Inter2d::AddVonE(const TopoDS_Vertex& theV,
+ const TopoDS_Edge& E1,
+ const TopoDS_Edge& E2,
+ const Handle(BRepAlgo_AsDes)& AsDes)
+
+{
+ //-------------------------------------------------------------
+ // test if the points of intersection already exist. If not,
+ // add as descendants of the edges.
+ // nb: theses points are only vertices of intersection.
+ //-------------------------------------------------------------
+ const TopTools_ListOfShape& VOnE1 = AsDes->Descendant(E1);
+ const TopTools_ListOfShape& VOnE2 = AsDes->Descendant(E2);
+ TopTools_ListOfShape NewVOnE1;
+ TopTools_ListOfShape NewVOnE2;
+ gp_Pnt P1,P2;
+ TopoDS_Vertex V1,V2;
+ TopTools_ListIteratorOfListOfShape it, itLV1, itLV2;
+ BRep_Builder B;
+ TopAbs_Orientation O1,O2;
+ Standard_Real U1,U2;
+ Standard_Real Tol,Tol1,Tol2;
+ Standard_Boolean OnE1,OnE2;
+
+// for (itLV1.Initialize(LV1),itLV2.Initialize(LV2);
+// itLV1.More();
+// itLV1.Next() ,itLV2.Next()) {
+
+ TopoDS_Vertex V = theV;
+// TopoDS_Vertex V = TopoDS::Vertex(itLV1.Value());
+
+ U1 = BRep_Tool::Parameter(V,E1);
+ U2 = BRep_Tool::Parameter(V,E2);
+ O1 = V.Orientation();
+ O2 = O1;///itLV2.Value().Orientation();
+ P1 = BRep_Tool::Pnt(V);
+ Tol = BRep_Tool::Tolerance( V );
+ OnE1 = OnE2 = Standard_False;
+
+ //-----------------------------------------------------------------
+ // Search if the point of intersection is a vertex of E1.
+ //-----------------------------------------------------------------
+ for (it.Initialize(VOnE1); it.More(); it.Next()) {
+ const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() );
+ if (V.IsSame( CV )) {
+ V1 = V;
+ OnE1 = Standard_True;
+ break;
+ }
+ P2 = BRep_Tool::Pnt( CV );
+ Tol1 = 1.1*(Tol + BRep_Tool::Tolerance( CV ));
+ if (P1.SquareDistance(P2) <= Tol1*Tol1) {
+ V = CV;
+ V1 = V;
+ OnE1 = Standard_True;
+ break;
+ }
+ }
+ if (OnE1) {
+ //-----------------------------------------------------------------
+ // Search if the vertex found is still on E2.
+ //-----------------------------------------------------------------
+ for (it.Initialize(VOnE2); it.More(); it.Next()) {
+ if (V.IsSame( it.Value() )) {
+ OnE2 = Standard_True;
+ V2 = V;
+ break;
+ }
+ }
+ }
+ if (!OnE2) {
+ for (it.Initialize(VOnE2); it.More(); it.Next()) {
+ //-----------------------------------------------------------------
+ // Search if the point of intersection is a vertex of E2.
+ //-----------------------------------------------------------------
+ const TopoDS_Vertex& CV = TopoDS::Vertex( it.Value() );
+ P2 = BRep_Tool::Pnt( CV );
+ Tol2 = 1.1*(Tol + BRep_Tool::Tolerance( CV ));
+ if (P1.SquareDistance(P2) <= Tol2*Tol2) {
+ V = CV;
+ V2 = V;
+ OnE2 = Standard_True;
+ break;
+ }
+ }
+ }
+ if (OnE1 && OnE2) {
+ if (!V1.IsSame(V2)) {
+ Standard_Real UV2;
+ TopoDS_Edge EWE2;
+ TopoDS_Vertex VI;
+ const TopTools_ListOfShape& EdgeWithV2 = AsDes->Ascendant(V2);
+
+ for (it.Initialize(EdgeWithV2); it.More(); it.Next()) {
+ EWE2 = TopoDS::Edge(it.Value());
+ VI = V2;
+ VI.Orientation(TopAbs_INTERNAL);
+ UV2 = BRep_Tool::Parameter(VI,EWE2);
+ VI = V1;
+ VI.Orientation(TopAbs_INTERNAL);
+ B.UpdateVertex(VI,UV2,EWE2, Max(Tol1,Tol2));
+ }
+ AsDes->Replace(V2,V1);
+ }
+ }
+ // add existing vertices instead of new ones
+ if (!OnE1) {
+ if (OnE2) {
+ V.Orientation(TopAbs_INTERNAL);
+ B.UpdateVertex(V,U1,E1, Tol2);
+ }
+ V.Orientation(O1);
+ NewVOnE1.Prepend(V);
+ }
+ if (!OnE2) {
+ if (OnE1) {
+ V.Orientation(TopAbs_INTERNAL);
+ B.UpdateVertex(V,U2,E2, Tol1);
+ }
+ V.Orientation(O2);
+ NewVOnE2.Prepend(V);
+ }
+// }
+
+ if (!NewVOnE1.IsEmpty()) AsDes->Add(E1,NewVOnE1);
+ if (!NewVOnE2.IsEmpty()) AsDes->Add(E2,NewVOnE2);
+
+ return V;
+}
+
+//=======================================================================
+//function : FindEndVertex
+//purpose : Returns a vertex from <VertList> having parameter on
+// <E> closest to <f> or <l>. <isFirst> is True if
+// found vertex is closer to <f>. <DU> returns parameter
+// difference.
+//=======================================================================
+
+TopoDS_Vertex Partition_Inter2d::FindEndVertex(const TopTools_ListOfShape& LV,
+ const Standard_Real f,
+ const Standard_Real l,
+ const TopoDS_Edge& E,
+ Standard_Boolean& isFirst,
+ Standard_Real& minDU)
+{
+ TopoDS_Vertex endV;
+ Standard_Real U, endU, min;
+ minDU = 1.e10;
+
+ TopTools_ListIteratorOfListOfShape it;
+ it.Initialize(LV);
+ for (; it.More(); it.Next()) {
+ const TopoDS_Vertex& v = TopoDS::Vertex(it.Value());
+ U = BRep_Tool::Parameter(v, E);
+ min = Min( Abs(U-f), Abs(U-l) );
+ if (min < minDU) {
+ endV = v;
+ endU = U;
+ minDU = min;
+ }
+ }
+ if (Abs(endU-f) < Abs(endU-l))
+ isFirst = Standard_True;
+ else
+ isFirst = Standard_False;
+
+ return endV;
+}
+
+//=======================================================================
+//function : treatClosed
+//purpose : add second vertex to closed edge. Vertex is one of <LV1>
+//=======================================================================
+
+static void treatClosed (const TopoDS_Edge& E1,
+ const Standard_Real f,
+ const Standard_Real l,
+ TopTools_ListOfShape& LV1,
+ TopTools_ListOfShape& /*LV2*/)
+{
+ Standard_Boolean isFirst=0;
+ Standard_Real minDU = 1.e10;
+ TopoDS_Vertex endV;
+ endV = Partition_Inter2d::FindEndVertex(LV1, f,l, E1, isFirst,minDU);
+
+ if (minDU > Precision::PConfusion())
+ return; // not end point
+
+ Standard_Real newU;
+ if (isFirst)
+ newU = f + (l - f);
+ else
+ newU = l - (l - f);
+
+ // update end parameter
+ BRep_Builder B;
+ endV.Orientation(TopAbs_INTERNAL);
+ B.UpdateVertex(endV,newU,E1,BRep_Tool::Tolerance(endV));
+}
+
+//=======================================================================
+//function : EdgesPartition
+//purpose :
+//=======================================================================
+
+static void EdgesPartition(const TopoDS_Face& F,
+ const TopoDS_Edge& E1,
+ const TopoDS_Edge& E2,
+ const Handle(BRepAlgo_AsDes)& AsDes,
+ const TopTools_MapOfShape& NewEdges,
+ const Standard_Boolean WithOri)
+{
+
+ Standard_Real f[3],l[3];
+ Standard_Real MilTol2;
+ Standard_Real Tol = Max (BRep_Tool::Tolerance(E1),
+ BRep_Tool::Tolerance(E2));
+ MilTol2 = Tol * Tol * 10;
+
+ BRep_Tool::Range(E1, f[1], l[1]);
+ BRep_Tool::Range(E2, f[2], l[2]);
+
+ BRepAdaptor_Curve CE1(E1,F);
+ BRepAdaptor_Curve CE2(E2,F);
+
+ TopoDS_Edge EI[3]; EI[1] = E1; EI[2] = E2;
+ TopTools_ListOfShape LV1; // new vertices at intersections on E1
+ TopTools_ListOfShape LV2; // ... on E2
+ BRep_Builder B;
+
+ // if E1 and E2 are results of intersection of F and two connex faces then
+ // no need to intersect edges, they can contact by vertices only
+ // (encounted an exception in TopOpeBRep_EdgesIntersector in such a case)
+ Standard_Boolean intersect = Standard_True;
+ TopTools_IndexedMapOfShape ME;
+ TopExp::MapShapes(F, TopAbs_EDGE, ME);
+ if (!ME.Contains(E1) && ! ME.Contains(E2)) { // if E1 and E2 are new on F
+ TopoDS_Shape F1, F2;
+ const TopTools_ListOfShape& LF1 = AsDes->Ascendant( E1 );
+ F1 = F.IsSame( LF1.First() ) ? LF1.Last() : LF1.First();
+ const TopTools_ListOfShape& LF2 = AsDes->Ascendant( E2 );
+ F2 = F.IsSame( LF2.First() ) ? LF2.Last() : LF2.First();
+ if (!F.IsSame(F2) && !F.IsSame(F1) ) {
+ TopExp_Explorer exp(F2, TopAbs_EDGE);
+ TopExp::MapShapes(F1, TopAbs_EDGE, ME);
+ for (; exp.More(); exp.Next()) {
+ if (ME.Contains( exp.Current())) {
+ intersect = Standard_False;
+ break;
+ }
+ }
+ }
+ }
+
+ if (intersect) {
+ //------------------------------------------------------
+ // compute the points of Intersection in 2D
+ //-----------------------------------------------------
+ // i.e. fill LV1 and LV2
+ TopOpeBRep_EdgesIntersector EInter;
+ EInter.SetFaces(F,F);
+ Standard_Real TolDub = 1.e-7;
+ EInter.ForceTolerances(TolDub,TolDub);
+ Standard_Boolean reducesegments = Standard_False;
+ EInter.Perform (E1,E2,reducesegments);
+
+ Standard_Boolean rejectreducedsegmentpoints = Standard_False;
+ EInter.InitPoint(rejectreducedsegmentpoints);
+ for (;EInter.MorePoint();EInter.NextPoint()) {
+ const TopOpeBRep_Point2d& P2D = EInter.Point();
+ const gp_Pnt& P = P2D.Value();
+ TopoDS_Vertex V = BRepLib_MakeVertex(P);
+
+ //-------------------------
+ // control the point found.
+ //-------------------------
+ gp_Pnt P1 = CE1.Value(P2D.Parameter(1));
+ gp_Pnt P2 = CE2.Value(P2D.Parameter(2));
+ Standard_Real sqd1 = P1.SquareDistance(P);
+ Standard_Real sqd2 = P2.SquareDistance(P);
+ if (sqd1 > MilTol2 || sqd2 > MilTol2 ) {
+ //MESSAGE ( "Inter2d : Solution rejected, dist: " << sqrt(Max(sqd1,sqd2)) )
+#ifdef DEB
+ if (TestEdges) {
+ MESSAGE ( " edges : E2d_"<<NbE2d-2<<" E2d_"<<NbE2d-1 ); }
+#endif
+ continue;
+ }
+
+ // add a new vertex to the both edges
+ Standard_Real toler = 1.5 * Max (Tol, sqrt(Max(sqd1,sqd2)) );
+ Standard_Integer i;
+ for (i = 1; i <= 2; i++) {
+ Standard_Real U = P2D.Parameter(i);
+#ifdef DEB
+ if (U < f[i]-Tol || U > l[i]+Tol) {
+ MESSAGE ( "out" );
+ }
+#endif
+ V.Orientation(TopAbs_INTERNAL);
+ B.UpdateVertex( V,U,EI[i], toler);
+ TopAbs_Orientation OO = TopAbs_REVERSED;
+ if (WithOri) {
+ if (P2D.IsVertex(i))
+ OO = P2D.Vertex(i).Orientation();
+ else if (P2D.Transition(i).Before() == TopAbs_OUT) {
+ OO = TopAbs_FORWARD;
+ }
+ V.Orientation(OO);
+ if (i == 1) LV1.Append(V);
+ else LV2.Append(V);
+ }
+ }
+ }
+ } // if (intersect)
+
+ //----------------------------------
+ // Test the extremities of the edges.
+ //----------------------------------
+ // add to LV* vertices for vertex-vertex closeness
+ Standard_Real U1,U2;
+ Standard_Real TolConf2, TolConf;
+ TopoDS_Vertex V1[2],V2[2];
+ TopExp::Vertices(E1,V1[0],V1[1]);
+ TopExp::Vertices(E2,V2[0],V2[1]);
+
+ Standard_Integer i,j,k;
+ for (j = 0; j < 2; j++) {
+ if (V1[j].IsNull()) continue;
+ for ( k = 0; k < 2; k++) {
+ if (V2[k].IsNull()) continue;
+ gp_Pnt P1 = BRep_Tool::Pnt(V1[j]);
+ gp_Pnt P2 = BRep_Tool::Pnt(V2[k]);
+ TolConf = BRep_Tool::Tolerance(V1[j]) + BRep_Tool::Tolerance(V2[k]);
+ TolConf = Max (Tol, TolConf);
+ TolConf2 = TolConf * TolConf;
+ if (!intersect)
+ TolConf2 *= 100;
+ Standard_Real SqDist = P1.SquareDistance(P2);
+
+ if (SqDist <= TolConf2) {
+ TopoDS_Vertex V = BRepLib_MakeVertex(P1);
+ V.Orientation(TopAbs_INTERNAL);
+ U1 = (j == 0) ? f[1] : l[1];
+ U2 = (k == 0) ? f[2] : l[2];
+ B.UpdateVertex(V,U1,E1,TolConf);
+ B.UpdateVertex(V,U2,E2,TolConf);
+ LV1.Prepend(V.Oriented(V1[j].Orientation()));
+ LV2.Prepend(V.Oriented(V2[k].Orientation()));
+ }
+ }
+ }
+
+ Standard_Boolean AffichPurge = Standard_False;
+
+ if ( LV1.IsEmpty()) return;
+
+ //----------------------------------
+ // Purge of all the vertices.
+ //----------------------------------
+ // remove one of close vertices
+ TopTools_ListIteratorOfListOfShape it1LV1,it1LV2,it2LV1;
+ gp_Pnt P1,P2;
+ Standard_Boolean Purge = Standard_True;
+
+ while (Purge) {
+ i = 1;
+ Purge = Standard_False;
+ for (it1LV1.Initialize(LV1),it1LV2.Initialize(LV2);
+ it1LV1.More(); it1LV1.Next(),it1LV2.Next()) {
+ j = 1;
+ it2LV1.Initialize(LV1);
+ while (j < i) {
+ const TopoDS_Vertex& VE1 = TopoDS::Vertex(it1LV1.Value());
+ const TopoDS_Vertex& VE2 = TopoDS::Vertex(it2LV1.Value());
+ Standard_Real Tol1 = BRep_Tool::Tolerance( VE1 );
+ Standard_Real Tol2 = BRep_Tool::Tolerance( VE2 );
+ P1 = BRep_Tool::Pnt( VE1 );
+ P2 = BRep_Tool::Pnt( VE2 );
+ if (P1.IsEqual(P2, Tol1 + Tol2)) {
+ LV1.Remove(it1LV1);
+ LV2.Remove(it1LV2);
+ if (AffichPurge) {
+ MESSAGE ("Vertices confused purged in EdgeInter.")
+ }
+ Purge = Standard_True;
+ break;
+ }
+ j++;
+ it2LV1.Next();
+ }
+ if (Purge) break;
+ i++;
+ }
+ }
+
+ // care of new closed edges, they always intersect with seam at end
+ if (V1[0].IsSame( V1[1] ) && NewEdges.Contains(E1) )
+ treatClosed (E1,f[1],l[1],LV1,LV2);
+ if (V2[0].IsSame( V2[1] ) && NewEdges.Contains(E2) )
+ treatClosed (E2,f[2],l[2],LV2,LV1);
+
+ //---------------------------------
+ // Stocking vertex .
+ //---------------------------------
+
+ //StorePart2d (E1,E2,LV1,LV2,AsDes,Tol);
+ for ( it1LV1.Initialize( LV1 ); it1LV1.More(); it1LV1.Next())
+ Partition_Inter2d::AddVonE ( TopoDS::Vertex( it1LV1.Value()), E1,E2,AsDes);
+}
+
+//=======================================================================
+//function : CompletPart2d
+//purpose : Computes the intersections between the edges stored
+// is AsDes as descendants of <F> . Intersections is computed
+// between two edges if one of them is bound in NewEdges.
+//=======================================================================
+
+void Partition_Inter2d::CompletPart2d (const Handle(BRepAlgo_AsDes)& AsDes,
+ const TopoDS_Face& F,
+ const TopTools_MapOfShape& NewEdges)
+{
+
+#ifdef DEB
+ NbF2d++;
+ NbE2d = 0;
+#endif
+
+ //Do not intersect the edges of a face
+ TopTools_IndexedMapOfShape EdgesOfFace;
+ TopExp::MapShapes( F, TopAbs_EDGE , EdgesOfFace);
+
+ //-------------------------------------------------------------------
+ // compute the intersection2D on the faces touched by the intersection3D
+ //-------------------------------------------------------------------
+ TopTools_ListIteratorOfListOfShape it1LE ;
+ TopTools_ListIteratorOfListOfShape it2LE ;
+
+ //-----------------------------------------------
+ // Intersection edge-edge.
+ //-----------------------------------------------
+ const TopTools_ListOfShape& LE = AsDes->Descendant(F);
+ TopoDS_Vertex V1,V2;
+ Standard_Integer j, i = 1;
+
+ TopoDS_Face FF = F;
+ FF.Orientation(TopAbs_FORWARD);
+
+ for ( it1LE.Initialize(LE) ; it1LE.More(); it1LE.Next()) {
+ const TopoDS_Edge& E1 = TopoDS::Edge(it1LE.Value());
+ j = 1;
+ it2LE.Initialize(LE);
+
+ while (j < i && it2LE.More()) {
+ const TopoDS_Edge& E2 = TopoDS::Edge(it2LE.Value());
+ //----------------------------------------------------------
+ // Intersections of the new edges obtained by intersection
+ // between them and with the restrictions edges
+ //----------------------------------------------------------
+ if ( (!EdgesOfFace.Contains(E1) || !EdgesOfFace.Contains(E2)) &&
+ (NewEdges.Contains(E1) || NewEdges.Contains(E2)) ) {
+ EdgesPartition(FF,E1,E2,AsDes,NewEdges,Standard_True);
+ }
+ it2LE.Next();
+ j++;
+ }
+ i++;
+ }
+}
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter2d.hxx
+// Module : GEOM
+
+#ifndef _Partition_Inter2d_HeaderFile
+#define _Partition_Inter2d_HeaderFile
+
+#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
+#include <Handle_BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+class BRepAlgo_AsDes;
+class TopoDS_Face;
+class TopTools_MapOfShape;
+class TopoDS_Vertex;
+class TopTools_ListOfShape;
+class TopoDS_Edge;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Inter2d {
+
+public:
+
+ void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+ // Methods PUBLIC
+ //
+Standard_EXPORT static void CompletPart2d(const Handle(BRepAlgo_AsDes)& AsDes,const TopoDS_Face& F,const TopTools_MapOfShape& NewEdges) ;
+Standard_EXPORT static TopoDS_Vertex FindEndVertex(const TopTools_ListOfShape& VertList,const Standard_Real f,const Standard_Real l,const TopoDS_Edge& E,Standard_Boolean& First,Standard_Real& DU) ;
+Standard_EXPORT static TopoDS_Vertex AddVonE(const TopoDS_Vertex& V,const TopoDS_Edge& E1,const TopoDS_Edge& E2,const Handle(BRepAlgo_AsDes)& AsDes) ;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+
+
+ // Fields PRIVATE
+ //
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter2d.ixx
+// Module : GEOM
+
+#include "Partition_Inter2d.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter2d.jxx
+// Module : GEOM
+
+#ifndef _BRepAlgo_AsDes_HeaderFile
+#include <BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopTools_MapOfShape_HeaderFile
+#include <TopTools_MapOfShape.hxx>
+#endif
+#ifndef _TopoDS_Vertex_HeaderFile
+#include <TopoDS_Vertex.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _Partition_Inter2d_HeaderFile
+#include "Partition_Inter2d.hxx"
+#endif
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- 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 : Partition_Inter3d.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+class Inter3d from Partition
+
+ ---Purpose: Computes the intersection face face in a set of faces
+ -- Store the result in a SD as AsDes.
+
+uses
+ Edge from TopoDS,
+ Vertex from TopoDS,
+ DataMapOfShapeShape from TopTools,
+ MapOfShape from TopTools,
+ Boolean from Standard,
+ AsDes from BRepAlgo,
+ Image from BRepAlgo,
+ Shape from TopoDS,
+ Face from TopoDS,
+ ListOfShape from TopTools,
+ Real from Standard,
+ State from TopAbs,
+ DataMapOfShapeListOfShape from TopTools
+
+is
+ Create returns Inter3d from Partition;
+
+ Create(AsDes : mutable AsDes from BRepAlgo);
+
+ CompletPart3d (me : in out; SetOfFaces1 : ListOfShape from TopTools;
+ FaceShapeMap: DataMapOfShapeShape from TopTools)
+ is static;
+
+ FacesPartition (me : in out; F1, F2 : Face from TopoDS)
+ is static;
+
+ ----------------------------
+ ---Category: Result Querying
+ ----------------------------
+
+ IsDone(me ; F1,F2 : Face from TopoDS)
+ returns Boolean from Standard is static;
+ ---Purpose: return True if F1-F2 pair has been processed
+
+ TouchedFaces(me : in out) returns MapOfShape from TopTools
+ ---C++: return &
+ is static;
+ ---Purpose: return map of
+
+ AsDes(me) returns AsDes from BRepAlgo
+ is static;
+
+ NewEdges(me : in out) returns MapOfShape from TopTools
+ ---C++: return &
+ is static;
+
+ -------------------------------
+ ---Category: Same domain shapes
+ -------------------------------
+
+ HasSameDomainF(me; F : Shape from TopoDS)
+ returns Boolean from Standard;
+ ---Purpose: Return true if F has same domain faces
+
+ IsSameDomainF(me; F1, F2 : Shape from TopoDS)
+ returns Boolean from Standard;
+ ---Purpose: Return true if F1 and F2 are same domain faces
+
+ SameDomain(me; F : Face from TopoDS)
+ returns ListOfShape from TopTools;
+ ---C++: return const &
+ ---Purpose: Return same domain faces of F
+
+ ReplaceSameDomainV (me; V : Vertex from TopoDS;
+ E : Edge from TopoDS)
+ returns Vertex from TopoDS;
+ ---Purpose: return same domain vertex of V if it was replaced
+ -- and make this vertex to be on E too, else return V
+
+ --------------------------
+ ---Category: Section edges
+ --------------------------
+
+ SectionEdgesAD (me) returns AsDes from BRepAlgo
+ is static;
+
+ IsSectionEdge (me; E : Edge from TopoDS)
+ returns Boolean from Standard;
+ ---Purpose: return True if E is an edge of an initial face and
+ -- E intersects aother face
+
+ HasSectionEdge (me; F : Face from TopoDS)
+ returns Boolean from Standard;
+ ---Purpose: return True if F is intersected by an edge of
+ -- other face
+
+ IsSplitOn (me; NewE, OldE : Edge from TopoDS;
+ F : Face from TopoDS)
+ returns Boolean from Standard;
+ ---Purpose: return True if NewE is split of OldE on F;
+ -- no check if NewE is split of OldE :)
+
+ SectionEdgeFaces (me; SecE : Edge from TopoDS)
+ returns ListOfShape from TopTools;
+ ---C++: return const&
+ ---Purpose: return faces cut by section edge
+
+ --------------------
+ ---Category: Private
+ --------------------
+
+ Inter3D (me: in out; F1, F2 : Face from TopoDS;
+ LInt : in out ListOfShape from TopTools)
+ is static private;
+
+ StorePart3d(me : in out; F1,F2 : Face from TopoDS;
+ LInt1 : ListOfShape from TopTools)
+ is static private;
+
+ SetDone(me : in out; F1,F2 : Face from TopoDS)
+ is static private;
+
+ Affiche (me; SetOfFaces : ListOfShape from TopTools)
+ is static private;
+
+fields
+
+ myAsDes : AsDes from BRepAlgo;
+ myDone : DataMapOfShapeListOfShape from TopTools;
+ myTouched : MapOfShape from TopTools;
+ myNewEdges : MapOfShape from TopTools;
+
+ -- section edges: existing edges that are intersection lines,
+ -- may be partially.
+ -- Store as
+ -- FACE -> SECTION EDGES, SECTION EDGE -> OTHER SECTION EDGE
+ mySectionEdgesAD : AsDes from BRepAlgo;
+
+ -- same domain shapes
+ -- faces
+ mySameDomainFM : DataMapOfShapeListOfShape from TopTools;
+ -- vertex -> vertex replacement
+ mySameDomainVM : DataMapOfShapeShape from TopTools;
+
+end Inter3d;
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter3d.cxx
+// Author : Benedicte MARTIN
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "Partition_Inter3d.ixx"
+#include "Partition_Inter2d.hxx"
+#include "utilities.h"
+
+#include <BRepOffset_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAlgo_AsDes.hxx>
+#include <BRepAlgo_Image.hxx>
+#include <BRepLib.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopOpeBRepTool_BoxSort.hxx>
+
+#ifdef DEB
+#include <DBRep.hxx>
+#endif
+
+#include <stdio.h>
+#include <TopOpeBRepDS_HDataStructure.hxx>
+#include <TopOpeBRep_DSFiller.hxx>
+#include <TopOpeBRepTool_GeomTool.hxx>
+#include <TopOpeBRepTool_OutCurveType.hxx>
+#include <TopOpeBRepDS_BuildTool.hxx>
+#include <TopOpeBRepBuild_Builder.hxx>
+#include <TopOpeBRepDS_CurveExplorer.hxx>
+#include <Geom2d_Curve.hxx>
+#include <TopOpeBRepDS_PointIterator.hxx>
+#include <TopOpeBRepDS_Transition.hxx>
+#include <Geom_Curve.hxx>
+#include <TopOpeBRepTool_CurveTool.hxx>
+#include <TopOpeBRepDS_Interference.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <BRepLib_MakeVertex.hxx>
+#include <Precision.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <BRepTools.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+//=======================================================================
+//function : Partition_Inter3d
+//purpose :
+//=======================================================================
+
+Partition_Inter3d::Partition_Inter3d()
+{
+}
+//=======================================================================
+//function : Partition_Inter3d
+//purpose :
+//=======================================================================
+
+Partition_Inter3d::Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes)
+ :myAsDes(AsDes)
+{
+ mySectionEdgesAD = new BRepAlgo_AsDes;
+}
+
+//=======================================================================
+//function : CompletPart3d
+//purpose : FaceShapeMap is just to know the shape a face belongs to
+//=======================================================================
+
+void Partition_Inter3d::CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,
+ const TopTools_DataMapOfShapeShape& FaceShapeMap)
+{
+ if (myAsDes.IsNull())
+ myAsDes = new BRepAlgo_AsDes;
+
+ TopTools_ListIteratorOfListOfShape it;
+
+ //---------------------------------------------------------------
+ // Construction of bounding boxes.
+ //---------------------------------------------------------------
+
+ BRep_Builder B;
+ TopoDS_Compound CompOS;
+ B.MakeCompound(CompOS);
+ for (it.Initialize(SetOfFaces1); it.More(); it.Next())
+ B.Add(CompOS, it.Value());
+
+ TopOpeBRepTool_BoxSort BOS;
+ BOS.AddBoxesMakeCOB(CompOS,TopAbs_FACE);
+
+ for (it.Initialize(SetOfFaces1); it.More(); it.Next()) {
+ TopoDS_Face F1 = TopoDS::Face(it.Value());
+
+ // avoid intersecting faces of one shape
+ TopoDS_Shape S1;
+ if (FaceShapeMap.IsBound(F1)) S1 = FaceShapeMap.Find(F1);
+ // avoid intersecting faces sharing vertices, suppose they belong to
+ // shapes sharing same faces
+ TopTools_IndexedMapOfShape VM;
+ TopExp::MapShapes( F1, TopAbs_VERTEX, VM);
+
+ TColStd_ListIteratorOfListOfInteger itLI = BOS.Compare(F1);
+ for (; itLI.More(); itLI.Next()) {
+ TopoDS_Face F2 = TopoDS::Face(BOS.TouchedShape(itLI));
+ if (F1.IsSame(F2) || IsDone(F1,F2))
+ continue;
+
+ TopoDS_Shape S2;
+ if (FaceShapeMap.IsBound(F2)) S2 = FaceShapeMap.Find(F2);
+ if (!S1.IsNull() && S1.IsSame(S2))
+ continue; // descendants of one shape
+
+ TopExp_Explorer expV (F2, TopAbs_VERTEX);
+ for ( ; expV.More(); expV.Next())
+ if (VM.Contains( expV.Current() ))
+ break;
+ if (expV.More())
+ continue; // faces have a common edge
+
+ F1.Orientation(TopAbs_FORWARD);
+ F2.Orientation(TopAbs_FORWARD);
+ FacesPartition(F1,F2);
+ }
+
+ // mark as modified a face which has at least one new edge
+ if (!myAsDes->HasDescendant( F1 ))
+ continue;
+ TopTools_ListIteratorOfListOfShape itE (myAsDes->Descendant( F1 ));
+ for ( ; itE.More(); itE.Next()) {
+ if (myNewEdges.Contains( itE.Value())) {
+ myTouched.Add( F1 );
+ break;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : PutInBounds
+//purpose :
+//=======================================================================
+
+static void PutInBounds (const TopoDS_Face& F,
+ const TopoDS_Edge& E,
+ Handle(Geom2d_Curve)& C2d)
+{
+ Standard_Real umin,umax,vmin,vmax;
+ Standard_Real f,l;
+ BRep_Tool::Range(E,f,l);
+
+ TopLoc_Location L; // Recup S avec la location pour eviter la copie.
+ Handle (Geom_Surface) S = BRep_Tool::Surface(F,L);
+
+ if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
+ S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface();
+ }
+ //---------------
+ // Recadre en U.
+ //---------------
+ if (!S->IsUPeriodic() && !S->IsVPeriodic()) return;
+
+ BRepTools::UVBounds(F,umin,umax,vmin,vmax);
+
+ if (S->IsUPeriodic()) {
+ Standard_Real period = S->UPeriod();
+ Standard_Real eps = period*1.e-6;
+ gp_Pnt2d Pf = C2d->Value(f);
+ gp_Pnt2d Pl = C2d->Value(l);
+ gp_Pnt2d Pm = C2d->Value(0.34*f + 0.66*l);
+ Standard_Real minC = Min(Pf.X(),Pl.X()); minC = Min(minC,Pm.X());
+ Standard_Real maxC = Max(Pf.X(),Pl.X()); maxC = Max(maxC,Pm.X());
+ Standard_Real du = 0.;
+ if (minC< umin - eps) {
+ du = (int((umin - minC)/period) + 1)*period;
+ }
+ if (minC > umax + eps) {
+ du = -(int((minC - umax)/period) + 1)*period;
+ }
+ if (du != 0) {
+ gp_Vec2d T1(du,0.);
+ C2d->Translate(T1);
+ minC += du; maxC += du;
+ }
+ // Ajuste au mieux la courbe dans le domaine.
+ if (maxC > umax +100*eps) {
+ Standard_Real d1 = maxC - umax;
+ Standard_Real d2 = umin - minC + period;
+ if (d2 < d1) du =-period;
+ if ( du != 0.) {
+ gp_Vec2d T2(du,0.);
+ C2d->Translate(T2);
+ }
+ }
+ }
+ //------------------
+ // Recadre en V.
+ //------------------
+ if (S->IsVPeriodic()) {
+ Standard_Real period = S->VPeriod();
+ Standard_Real eps = period*1.e-6;
+ gp_Pnt2d Pf = C2d->Value(f);
+ gp_Pnt2d Pl = C2d->Value(l);
+ gp_Pnt2d Pm = C2d->Value(0.34*f + 0.66*l);
+ Standard_Real minC = Min(Pf.Y(),Pl.Y()); minC = Min(minC,Pm.Y());
+ Standard_Real maxC = Max(Pf.Y(),Pl.Y()); maxC = Max(maxC,Pm.Y());
+ Standard_Real dv = 0.;
+ if (minC< vmin - eps) {
+ dv = (int((vmin - minC)/period) + 1)*period;
+ }
+ if (minC > vmax + eps) {
+ dv = -(int((minC - vmax)/period) + 1)*period;
+ }
+ if (dv != 0) {
+ gp_Vec2d T1(0.,dv);
+ C2d->Translate(T1);
+ minC += dv; maxC += dv;
+ }
+ // Ajuste au mieux la courbe dans le domaine.
+ if (maxC > vmax +100*eps) {
+ Standard_Real d1 = maxC - vmax;
+ Standard_Real d2 = vmin - minC + period;
+ if (d2 < d1) dv =-period;
+ if ( dv != 0.) {
+ gp_Vec2d T2(0.,dv);
+ C2d->Translate(T2);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : Inter3D
+//purpose :
+//=======================================================================
+
+void Partition_Inter3d::Inter3D(const TopoDS_Face& F1,
+ const TopoDS_Face& F2,
+ TopTools_ListOfShape& L)
+{
+ BRep_Builder B;
+
+ // fill the data Structure
+ Handle(TopOpeBRepDS_HDataStructure) DatStr = new TopOpeBRepDS_HDataStructure();
+ TopOpeBRep_DSFiller DSFiller;
+ DSFiller.Insert(F1,F2,DatStr);
+
+ // define the GeomTool used by the DSFiller :
+ // compute BSpline of degree 1 on intersection curves.
+ Standard_Real tol3dAPPROX = 1e-7;
+ Standard_Real tol2dAPPROX = 1e-7;
+ TopOpeBRepTool_GeomTool GT2 (TopOpeBRepTool_APPROX);
+ GT2.SetTolerances(tol3dAPPROX,tol2dAPPROX);
+ TopOpeBRepDS_BuildTool BT(GT2);
+
+ // Perform Section
+ TopOpeBRepBuild_Builder TopB(BT);
+ TopB.Perform(DatStr);
+
+ // ===============
+ // Store new edges
+ // ===============
+
+ L.Clear();
+ TopOpeBRepDS_CurveExplorer cex(DatStr->DS());
+ for (; cex.More(); cex.Next()) {
+ const TopOpeBRepDS_Curve& CDS = cex.Curve();
+ Standard_Integer ic = cex.Index();
+ Handle(Geom2d_Curve) pc1 = CDS.Curve1();
+ Handle(Geom2d_Curve) pc2 = CDS.Curve2();
+
+ TopTools_ListIteratorOfListOfShape itLE = TopB.NewEdges(ic);
+ while (itLE.More()) {
+ TopoDS_Edge E = TopoDS::Edge(itLE.Value());
+
+// Standard_Real f,l;
+// BRep_Tool::Range(E,f,l);
+ PutInBounds (F1,E,pc1);
+ PutInBounds (F2,E,pc2);
+
+ B.UpdateEdge (E,pc1,F1,0.);
+ B.UpdateEdge (E,pc2,F2,0.);
+
+ L.Append (E);
+
+ itLE.Next();
+ if (itLE.More()) {
+ pc1 = Handle(Geom2d_Curve)::DownCast(pc1->Copy());
+ pc2 = Handle(Geom2d_Curve)::DownCast(pc2->Copy());
+ }
+ }
+ }
+
+ // ===================================================
+ // Store section edges, same domain faces and verives
+ // ===================================================
+
+ TopTools_ListOfShape empty, LSP, LSE;
+
+ if ( DatStr->HasSameDomain( F1 )) { // same domain faces
+ if (!mySameDomainFM.IsBound(F1))
+ mySameDomainFM.Bind(F1,empty);
+ if (!mySameDomainFM.IsBound(F2))
+ mySameDomainFM.Bind(F2,empty);
+ mySameDomainFM(F1).Append(F2);
+ mySameDomainFM(F2).Append(F1);
+ }
+
+ const TopOpeBRepDS_DataStructure& DS = DatStr->DS();
+ Standard_Integer j,i,nes = DS.NbSectionEdges();
+ if (!nes) return;
+
+
+ TopoDS_Vertex V, sdeV1, sdeV2;
+ TopTools_MapOfShape MV;
+
+ // put vertices on section edges
+ for (i=1;i<=nes;i++) {
+
+ TopoDS_Edge se, sde, oe; // section, same domain, other edge
+ se = DS.SectionEdge(i);
+ if (! TopB.IsSplit(se,TopAbs_ON))
+ continue;
+
+ if (DatStr->HasSameDomain(se)) {
+ sde = TopoDS::Edge( DatStr->SameDomain(se).Value() );
+ TopExp::Vertices( sde, sdeV1, sdeV2);
+ }
+
+ TColStd_MapOfInteger MIV;
+ TopOpeBRepDS_PointIterator itP (DS.ShapeInterferences( se ));
+ itP.SupportKind( TopOpeBRepDS_EDGE );
+ for (; itP.More(); itP.Next()) {
+ oe = TopoDS::Edge( DS.Shape( itP.Support()));
+ if (itP.IsVertex()) {
+ if ( !MIV.Add( itP.Current() ))
+ continue;
+ V = TopoDS::Vertex( DS.Shape( itP.Current()));
+ if ( !sde.IsNull() && (V.IsSame(sdeV1) || V.IsSame(sdeV2)) )
+ oe = sde;
+ V = ReplaceSameDomainV( V , oe );
+ V.Orientation( TopAbs_INTERNAL);
+ B.UpdateVertex( V, itP.Parameter(), se, 0.);
+ }
+ else {
+ const TopOpeBRepDS_Point& DSP = DS.Point( itP.Current());
+ V = BRepLib_MakeVertex( DSP.Point() );
+ V.Orientation( TopAbs_INTERNAL);
+ B.UpdateVertex( V, itP.Parameter(), se, DSP.Tolerance());
+ // make V be on the other edge
+ TopOpeBRepDS_PointIterator itOP (DS.ShapeInterferences( oe ));
+ for (; itOP.More(); itOP.Next()) {
+ const TopOpeBRepDS_Point& ODSP = DS.Point( itOP.Current());
+ if ( DSP.IsEqual (ODSP)) {
+ B.UpdateVertex( V, itOP.Parameter(), TopoDS::Edge(oe), ODSP.Tolerance());
+ break;
+ }
+ }
+ }
+ TopoDS_Vertex addedV = Partition_Inter2d::AddVonE( V,se,oe,myAsDes);
+ if (!addedV.IsSame( V ))
+ mySameDomainVM.Bind (V, addedV);
+ MV.Add( addedV );
+ }
+ }
+
+ TopB.SplitSectionEdges();
+
+ TopTools_DataMapOfShapeShape SEM; // map split - section edge
+ TopTools_IndexedMapOfShape ME[2];
+ TopExp::MapShapes( F1, TopAbs_EDGE, ME[1]);
+ TopExp::MapShapes( F2, TopAbs_EDGE, ME[0]);
+
+ // add section edge to the face it intersects and find
+ // splits ON that do not have same domain pair
+
+ for (i=1;i<=nes;i++) {
+
+ const TopoDS_Edge& se = DS.SectionEdge(i);
+ if (! TopB.IsSplit(se,TopAbs_ON))
+ continue;
+
+ Standard_Integer ancRank = DS.AncestorRank(se);
+ if (ME[ancRank-1].Contains( se ))
+ continue; // se is an edge of face it intersects
+
+ const TopoDS_Face& F = (ancRank == 1) ? F2 : F1;
+
+ // add se to face but dont add twice
+ TopTools_ListIteratorOfListOfShape itE;
+ if (myAsDes->HasDescendant( F )) {
+ for (itE.Initialize( (myAsDes->Descendant( F )) ); itE.More(); itE.Next())
+ if (se.IsSame( itE.Value() ))
+ break;
+ }
+ if (!itE.More()) {
+ myAsDes->Add( F, se );
+ Standard_Real tol, f,l, umin=1e100, umax=-1e100;
+ Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( se, F, f,l);
+ if (pc.IsNull()) {
+ TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
+ for ( ;it.More();it.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge ( it.Value());
+ BRep_Tool::Range(E, f, l);
+ umin = Min( umin, f);
+ umax = Max( umax, l);
+ }
+ Handle(Geom_Curve) C3d = BRep_Tool::Curve( se, f, l);
+ if (umin < umax) // sometimes umin == umax for closed edge
+ C3d = new Geom_TrimmedCurve( C3d, umin, umax);
+ pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol);
+ if (pc.IsNull()) {
+ MESSAGE (" CANT BUILD PCURVE ");
+ }
+ B.UpdateEdge( se, pc, F, tol);
+ }
+ }
+
+ // to detect splits that do not have same domain pair
+ TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
+ for ( ;it.More();it.Next()) {
+ const TopoDS_Edge& S = TopoDS::Edge ( it.Value());
+ if (SEM.IsBound( S ))
+ SEM.UnBind( S );
+ else
+ SEM.Bind( S, se);
+ }
+ }
+
+ // store vertices of ON splits and bind section edges to faces
+ for (i=1;i<=nes;i++) {
+
+ const TopoDS_Edge& se = DS.SectionEdge(i);
+ if (! TopB.IsSplit(se,TopAbs_ON))
+ continue;
+
+ Standard_Integer ancRank = DS.AncestorRank(se);
+ if (ME[ancRank-1].Contains( se ))
+ continue; // se is an edge of face it intersects
+
+ TopoDS_Face F = (ancRank == 1) ? F2 : F1;
+
+ // add vertices of splits
+ Standard_Boolean added = Standard_False;
+ TopTools_ListIteratorOfListOfShape it( TopB.Splits(se,TopAbs_ON) );
+ for ( ;it.More();it.Next()) {
+ const TopoDS_Edge& S = TopoDS::Edge ( it.Value());
+ if (!SEM.IsBound( S ))
+ continue;
+
+ added = Standard_True;
+ mySectionEdgesAD->Add( F, se );
+
+ TopoDS_Vertex VS[2];
+ TopExp::Vertices (S, VS[0], VS[1]);
+ for (j=0; j<2; ++j) {
+ if (mySameDomainVM.IsBound( VS[j] ))
+ VS[j] = TopoDS::Vertex( mySameDomainVM( VS[j] ));
+ if ( !MV.Contains( VS[j] )) {
+ // find equal vertex on se - point interference
+ gp_Pnt P1 = BRep_Tool::Pnt( VS[j] );
+ TopTools_ListIteratorOfListOfShape itV( myAsDes->Descendant(se) );
+ for (; itV.More(); itV.Next()) {
+ V = TopoDS::Vertex( itV.Value() );
+ gp_Pnt P2 = BRep_Tool::Pnt( V );
+ if (P1.IsEqual( P2, Precision::Confusion())) {
+ mySameDomainVM.Bind (VS[j], V);
+ VS[j] = V;
+ break;
+ }
+ }
+ if (!itV.More()) // no interferences with edges
+ myAsDes->Add( se, VS[j]);
+ }
+ mySectionEdgesAD->Add( F, VS[j]);
+ }
+ mySectionEdgesAD->Add( F, S );
+ }
+ if (!added)
+ mySectionEdgesAD->Add( F, se );
+
+ myNewEdges.Add( se );
+ }
+}
+
+//=======================================================================
+//function : FacesPartition
+//purpose :
+//=======================================================================
+
+void Partition_Inter3d::FacesPartition(const TopoDS_Face& F1,
+ const TopoDS_Face& F2)
+ //(const TopTools_DataMapOfShapeListOfShape& /*SetOfFaces2*/)
+{
+ TopTools_ListOfShape LInt;
+
+ Inter3D (F1,F2,LInt);
+
+ StorePart3d (F1,F2,LInt);
+}
+
+//=======================================================================
+//function : SetDone
+//purpose :
+//=======================================================================
+
+void Partition_Inter3d::SetDone(const TopoDS_Face& F1,
+ const TopoDS_Face& F2)
+{
+ if (!myDone.IsBound(F1)) {
+ TopTools_ListOfShape empty;
+ myDone.Bind(F1,empty);
+ }
+ myDone(F1).Append(F2);
+ if (!myDone.IsBound(F2)) {
+ TopTools_ListOfShape empty;
+ myDone.Bind(F2,empty);
+ }
+ myDone(F2).Append(F1);
+}
+
+//=======================================================================
+//function : IsDone
+//purpose :
+//=======================================================================
+
+Standard_Boolean Partition_Inter3d::IsDone(const TopoDS_Face& F1,
+ const TopoDS_Face& F2)
+
+ const
+{
+ if (myDone.IsBound(F1)) {
+ TopTools_ListIteratorOfListOfShape it (myDone(F1));
+ for (; it.More(); it.Next()) {
+ if (it.Value().IsSame(F2)) return Standard_True;
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : StorePart3d
+//purpose :
+//=======================================================================
+
+void Partition_Inter3d::StorePart3d(const TopoDS_Face& F1,
+ const TopoDS_Face& F2,
+ const TopTools_ListOfShape& LInt)
+{
+
+ if (!LInt.IsEmpty()) {
+ myAsDes->Add( F1,LInt);
+ myAsDes->Add( F2,LInt);
+
+ TopTools_ListIteratorOfListOfShape it(LInt);
+ for (; it.More(); it.Next()) {
+
+ TopoDS_Edge E = TopoDS::Edge(it.Value());
+
+ BRep_Builder B;
+ B.SameParameter(E,Standard_False);
+ BRepLib::SameParameter(E,1.0e-7);
+
+ myNewEdges.Add(E);
+ }
+ }
+ SetDone(F1,F2);
+}
+
+//=======================================================================
+//function : TouchedFaces
+//purpose :
+//=======================================================================
+
+TopTools_MapOfShape& Partition_Inter3d::TouchedFaces()
+{
+ return myTouched;
+}
+
+//=======================================================================
+//function : AsDes
+//purpose :
+//=======================================================================
+
+Handle(BRepAlgo_AsDes) Partition_Inter3d::AsDes() const
+{
+ return myAsDes;
+}
+
+//=======================================================================
+//function : NewEdges
+//purpose :
+//=======================================================================
+
+TopTools_MapOfShape& Partition_Inter3d::NewEdges()
+{
+ return myNewEdges;
+}
+
+//=======================================================================
+//function : Affiche
+//purpose :
+//=======================================================================
+
+void Partition_Inter3d::Affiche(const TopTools_ListOfShape& SetOfFaces) const
+{
+#ifdef DEB
+ char PSection[1024];
+ char *section=PSection;
+ Standard_Integer i = 0;
+ Standard_Real j=1;
+ TopTools_ListOfShape aList;
+ TopTools_ListIteratorOfListOfShape it;
+ for (it.Initialize(SetOfFaces); it.More(); it.Next()) {
+ const TopoDS_Shape& OS = it.Value();
+ aList=myAsDes->Descendant(OS);
+ MESSAGE ( " the number of items stored in the list " << j << " : " << aList.Extent() )
+ j++;
+ TopTools_ListIteratorOfListOfShape itaList;
+ for (itaList.Initialize(aList); itaList.More(); itaList.Next()) {
+ const TopoDS_Shape& SS = itaList.Value();
+ i++;
+ sprintf(PSection,"section_%d",i);
+ DBRep::Set(section,SS);
+ }
+ }
+#endif
+}
+
+//=======================================================================
+//function : SameDomain
+//purpose :
+//=======================================================================
+
+const TopTools_ListOfShape& Partition_Inter3d::SameDomain(const TopoDS_Face& F) const
+{
+ if (mySameDomainFM.IsBound( F ))
+ return mySameDomainFM (F);
+
+ static TopTools_ListOfShape empty;
+ return empty;
+}
+
+//=======================================================================
+//function : HasSameDomainF
+//purpose : Return true if F has same domain faces
+//=======================================================================
+
+Standard_Boolean Partition_Inter3d::HasSameDomainF(const TopoDS_Shape& F) const
+{
+ return mySameDomainFM.IsBound( F );
+}
+
+//=======================================================================
+//function : IsSameDomain
+//purpose : Return true if F1 and F2 are same domain faces
+//=======================================================================
+
+Standard_Boolean Partition_Inter3d::IsSameDomainF(const TopoDS_Shape& F1,
+ const TopoDS_Shape& F2) const
+{
+ if (mySameDomainFM.IsBound( F1 )) {
+ TopTools_ListIteratorOfListOfShape it (mySameDomainFM( F1 ));
+ for (; it.More(); it.Next())
+ if (F2.IsSame( it.Value()))
+ return Standard_True;
+ }
+ return F1.IsSame( F2 );
+}
+
+//=======================================================================
+//function : ReplaceSameDomainV
+//purpose : return same domain vertex of V if it was replaced
+// and make this vertex to be on E too, else return V
+//=======================================================================
+
+TopoDS_Vertex Partition_Inter3d::ReplaceSameDomainV(const TopoDS_Vertex& V,
+ const TopoDS_Edge& E) const
+{
+ TopoDS_Vertex SDV = V;
+ if (mySameDomainVM.IsBound( V )) {
+
+ TopoDS_Vertex V1,V2;
+ TopExp::Vertices(E,V1,V2);
+ Standard_Boolean isClosed = V1.IsSame( V2 ) && V.IsSame(V1);
+
+ SDV = TopoDS::Vertex( mySameDomainVM(V) );
+ Standard_Real tol = BRep_Tool::Tolerance( V );
+ BRep_Builder B;
+ SDV.Orientation( V.Orientation());
+
+ if (isClosed) {
+ Standard_Real f, l;
+ BRep_Tool::Range (E, f, l);
+ Standard_Boolean isFirst = IsEqual( BRep_Tool::Parameter(V,E), f );
+ B.UpdateVertex(SDV, (isFirst ? f : l), E, tol);
+ SDV.Reverse();
+ B.UpdateVertex(SDV, (isFirst ? l : f), E, tol);
+ }
+ else
+ B.UpdateVertex (SDV, BRep_Tool::Parameter(V,E), E, tol);
+
+ }
+ return SDV;
+}
+
+//=======================================================================
+//function : SectionEdgesAD
+//purpose :
+//=======================================================================
+
+Handle(BRepAlgo_AsDes) Partition_Inter3d::SectionEdgesAD() const
+{
+ return mySectionEdgesAD;
+}
+
+//=======================================================================
+//function : IsSectionEdge
+//purpose : return True if E is an edge of a face and it
+// intersects an other face
+//=======================================================================
+
+Standard_Boolean
+ Partition_Inter3d::IsSectionEdge(const TopoDS_Edge& E) const
+{
+ return mySectionEdgesAD->HasAscendant(E);
+}
+
+//=======================================================================
+//function : HasSectionEdge
+//purpose : return True if an edge of F intersects an other
+// face or F is intersected by edge of an other face
+//=======================================================================
+
+Standard_Boolean
+ Partition_Inter3d::HasSectionEdge(const TopoDS_Face& F) const
+{
+ return mySectionEdgesAD->HasDescendant(F);
+}
+
+//=======================================================================
+//function : IsSplitOn
+//purpose : return True if NewE is split of OldE on F
+//=======================================================================
+
+Standard_Boolean
+ Partition_Inter3d::IsSplitOn(const TopoDS_Edge& NewE,
+ const TopoDS_Edge& OldE,
+ const TopoDS_Face& F) const
+{
+ if (! mySectionEdgesAD->HasDescendant(F))
+ return Standard_False;
+
+ TopTools_ListIteratorOfListOfShape itE ( mySectionEdgesAD->Descendant(F) );
+ for ( ; itE.More(); itE.Next()) {
+ if ( itE.Value().ShapeType() != TopAbs_EDGE ||
+ ! OldE.IsSame ( itE.Value() ))
+ continue;
+ // an edge encountered, its vertices and a split come next
+ itE.Next();
+ if (!itE.More()) break;
+ const TopoDS_Shape& V3 = itE.Value();
+ if (V3.ShapeType() != TopAbs_VERTEX) continue;
+ itE.Next();
+ if (!itE.More()) break;
+ const TopoDS_Shape& V4 = itE.Value();
+ if (V4.ShapeType() != TopAbs_VERTEX) continue;
+
+ TopoDS_Vertex V1, V2;
+ TopExp::Vertices( OldE, V1, V2);
+
+ if ( V1.IsSame(V2) &&
+ (V1.IsSame(V3) || V1.IsSame(V4)) ) {
+ // closed old edge; use the split for the test
+ itE.Next();
+ if (!itE.More()) break;
+ const TopoDS_Edge& split = TopoDS::Edge( itE.Value() );
+ // check distance at middle point of NewE
+ Standard_Real f1,l1, f2,l2;
+ Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface( split, F ,f1,l1);
+ if (!PC1.IsNull()) {
+ Handle(Geom2d_Curve) PC2 = BRep_Tool::CurveOnSurface(NewE, F ,f2,l2);
+ gp_Pnt2d P = PC2->Value( 0.5*(f2+l2) );
+ Geom2dAPI_ProjectPointOnCurve proj (P, PC1, f1, l1);
+ if (proj.NbPoints() &&
+ proj.LowerDistance() <= Precision::Confusion())
+ return Standard_True;
+ }
+ else {
+ Handle(Geom_Curve) C1 = BRep_Tool::Curve( split ,f1,l1);
+ Handle(Geom_Curve) C2 = BRep_Tool::Curve( NewE ,f2,l2);
+ gp_Pnt P = C2->Value( 0.5*(f2+l2) );
+ GeomAPI_ProjectPointOnCurve proj (P, C1, f1, l1);
+ if (proj.NbPoints() &&
+ proj.LowerDistance() <= Precision::Confusion())
+ return Standard_True;
+ }
+ }
+ else {
+ Standard_Real u3 = BRep_Tool::Parameter( TopoDS::Vertex(V3), OldE);
+ Standard_Real u4 = BRep_Tool::Parameter( TopoDS::Vertex(V4), OldE);
+
+ Standard_Real f,l, u;
+ BRep_Tool::Range( NewE, f,l);
+ u = 0.5*(f+l);
+ f = Min(u3,u4);
+ l = Max(u3,u4);
+
+ if (u <= l && u >= f)
+ return Standard_True;
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : SectionEdgeFaces
+//purpose : return faces cut by section edge
+//=======================================================================
+
+const TopTools_ListOfShape&
+ Partition_Inter3d::SectionEdgeFaces(const TopoDS_Edge& SecE) const
+{
+ return mySectionEdgesAD->Ascendant( SecE );
+}
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter3d.hxx
+// Module : GEOM
+
+#ifndef _Partition_Inter3d_HeaderFile
+#define _Partition_Inter3d_HeaderFile
+
+#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
+#include <Handle_BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#endif
+#ifndef _TopTools_MapOfShape_HeaderFile
+#include <TopTools_MapOfShape.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
+#include <TopTools_DataMapOfShapeShape.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+class BRepAlgo_AsDes;
+class TopTools_ListOfShape;
+class TopTools_DataMapOfShapeShape;
+class TopoDS_Face;
+class TopTools_MapOfShape;
+class TopoDS_Shape;
+class TopoDS_Vertex;
+class TopoDS_Edge;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Inter3d {
+
+public:
+
+ void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+ // Methods PUBLIC
+ //
+Standard_EXPORT Partition_Inter3d();
+Standard_EXPORT Partition_Inter3d(const Handle(BRepAlgo_AsDes)& AsDes);
+Standard_EXPORT void CompletPart3d(const TopTools_ListOfShape& SetOfFaces1,const TopTools_DataMapOfShapeShape& FaceShapeMap) ;
+Standard_EXPORT void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
+Standard_EXPORT Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const;
+Standard_EXPORT TopTools_MapOfShape& TouchedFaces() ;
+Standard_EXPORT Handle_BRepAlgo_AsDes AsDes() const;
+Standard_EXPORT TopTools_MapOfShape& NewEdges() ;
+Standard_EXPORT Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const;
+Standard_EXPORT Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const;
+Standard_EXPORT const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const;
+Standard_EXPORT TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const;
+Standard_EXPORT Handle_BRepAlgo_AsDes SectionEdgesAD() const;
+Standard_EXPORT Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const;
+Standard_EXPORT Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const;
+Standard_EXPORT Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const;
+Standard_EXPORT const TopTools_ListOfShape& SectionEdgeFaces(const TopoDS_Edge& SecE) const;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+Standard_EXPORT void Inter3D(const TopoDS_Face& F1,const TopoDS_Face& F2,TopTools_ListOfShape& LInt) ;
+Standard_EXPORT void StorePart3d(const TopoDS_Face& F1,const TopoDS_Face& F2,const TopTools_ListOfShape& LInt1) ;
+Standard_EXPORT void SetDone(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
+Standard_EXPORT void Affiche(const TopTools_ListOfShape& SetOfFaces) const;
+
+
+ // Fields PRIVATE
+ //
+Handle_BRepAlgo_AsDes myAsDes;
+TopTools_DataMapOfShapeListOfShape myDone;
+TopTools_MapOfShape myTouched;
+TopTools_MapOfShape myNewEdges;
+Handle_BRepAlgo_AsDes mySectionEdgesAD;
+TopTools_DataMapOfShapeListOfShape mySameDomainFM;
+TopTools_DataMapOfShapeShape mySameDomainVM;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter3d.ixx
+// Module : GEOM
+
+#include "Partition_Inter3d.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Inter3d.jxx
+// Module : GEOM
+
+#ifndef _BRepAlgo_AsDes_HeaderFile
+#include <BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
+#include <TopTools_DataMapOfShapeShape.hxx>
+#endif
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopTools_MapOfShape_HeaderFile
+#include <TopTools_MapOfShape.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _TopoDS_Vertex_HeaderFile
+#include <TopoDS_Vertex.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _Partition_Inter3d_HeaderFile
+#include "Partition_Inter3d.hxx"
+#endif
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- 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 : Partition_Loop.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+class Loop from Partition
+
+ ---Purpose: Builds the loops from a set of edges on a face.
+
+uses
+
+ Face from TopoDS,
+ Edge from TopoDS,
+ ListOfShape from TopTools,
+ DataMapOfShapeListOfShape from TopTools
+
+is
+
+ Create;
+
+ Init (me : in out; F : Face from TopoDS)
+ ---Purpose: Init with <F> the set of edges must have
+ -- pcurves on <F>.
+ is static;
+
+ AddEdge (me : in out; E : in out Edge from TopoDS;
+ LV : ListOfShape from TopTools)
+ ---Purpose: Add E with <LV>. <E> will be copied and trim
+ -- by vertices in <LV>.
+ is static;
+
+ AddConstEdge (me : in out; E : Edge from TopoDS)
+ ---Purpose: Add <E> as const edge, E can be in the result.
+ is static;
+
+ Perform(me : in out)
+ ---Purpose: Make loops.
+ is static;
+
+ NewWires (me)
+ ---Purpose: Returns the list of wires performed.
+ -- can be an empty list.
+ ---C++: return const &
+ returns ListOfShape from TopTools;
+
+ WiresToFaces (me : in out)
+ ---Purpose: Build faces from the wires result.
+ is static;
+
+ NewFaces (me)
+ ---Purpose: Returns the list of faces.
+ ---Warning: The method <WiresToFaces> as to be called before.
+ -- can be an empty list.
+ ---C++: return const &
+ returns ListOfShape from TopTools;
+
+
+fields
+
+ myFace : Face from TopoDS;
+ myConstEdges : ListOfShape from TopTools;
+ myNewWires : ListOfShape from TopTools;
+ myNewFaces : ListOfShape from TopTools;
+
+end Loop;
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Loop.cxx
+// Author : Benedicte MARTIN
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include <stdio.h>
+
+#include "Partition_Loop.ixx"
+
+#include "utilities.h"
+
+#include <BRep_Builder.hxx>
+#include <BRepAlgo_FaceRestrictor.hxx>
+#include <BRep_Tool.hxx>
+
+#include <Geom2d_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfOrientedShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <Precision.hxx>
+#include <BRep_TVertex.hxx>
+#include <BRep_TEdge.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+static char* name = new char[100];
+static int nbe = 0;
+
+//=======================================================================
+//function : Partition_Loop
+//purpose :
+//=======================================================================
+Partition_Loop::Partition_Loop()
+{
+}
+
+//=======================================================================
+//function : Init
+//purpose :
+//=======================================================================
+void Partition_Loop::Init(const TopoDS_Face& F)
+{
+ myConstEdges.Clear();
+ myNewWires .Clear();
+ myNewFaces .Clear();
+ myFace = F;
+}
+
+//=======================================================================
+//function : AddConstEdge
+//purpose :
+//=======================================================================
+void Partition_Loop::AddConstEdge (const TopoDS_Edge& E)
+{
+ myConstEdges.Append(E);
+}
+
+
+//=======================================================================
+//function : FindDelta
+//purpose :
+//=======================================================================
+static Standard_Real FindDelta(TopTools_ListOfShape& LE,
+ const TopoDS_Face& F)
+{
+ Standard_Real dist, f, l;
+ Standard_Real d = Precision::Infinite();
+ TopTools_ListIteratorOfListOfShape itl;
+
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(E,F,f,l);
+ gp_Pnt2d p = C->Value(f);
+ gp_Pnt2d pp = C->Value(l);
+ Standard_Real d1 = p.Distance(pp);
+ if (d1<d) { d=d1;}
+ }
+ dist = d ;
+ return dist;
+}
+
+//=======================================================================
+//function : SelectEdge
+//purpose : Find the edge <NE> connected <CE> by the vertex <CV> in the list <LE>.
+// <NE> Is erased of the list. If <CE> is too in the list <LE>
+// with the same orientation, it's erased of the list
+//=======================================================================
+static Standard_Boolean SelectEdge(const TopoDS_Face& F,
+ const TopoDS_Edge& CE,
+ const TopoDS_Vertex& CV,
+ TopoDS_Edge& NE,
+ TopTools_ListOfShape& LE)
+{
+ TopTools_ListIteratorOfListOfShape itl;
+ NE.Nullify();
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ if (itl.Value().IsEqual(CE)) {
+ LE.Remove(itl);
+ break;
+ }
+ }
+
+ if (LE.Extent() > 1) {
+ //--------------------------------------------------------------
+ // Several possible edges.
+ // - Test the edges differents of CE
+ //--------------------------------------------------------------
+ Standard_Real cf, cl, f, l;
+ TopoDS_Face FForward = F;
+ Handle(Geom2d_Curve) Cc, C;
+ FForward.Orientation(TopAbs_FORWARD);
+
+ Cc = BRep_Tool::CurveOnSurface(CE,FForward,cf,cl);
+ Standard_Real dist,distmin = 100*BRep_Tool::Tolerance(CV);
+ Standard_Real uc,u;
+ if (CE.Orientation () == TopAbs_FORWARD) uc = cl;
+ else uc = cf;
+
+ gp_Pnt2d P2,PV = Cc->Value(uc);
+
+ Standard_Real delta = FindDelta(LE,FForward);
+
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ if (!E.IsSame(CE)) {
+ C = BRep_Tool::CurveOnSurface(E,FForward,f,l);
+ if (E.Orientation () == TopAbs_FORWARD) u = f;
+ else u = l;
+ P2 = C->Value(u);
+ dist = PV.Distance(P2);
+ if (dist <= distmin){
+ distmin = dist;
+ }
+
+ }
+ }
+
+ Standard_Real anglemax = - PI;
+ TopoDS_Edge SelectedEdge;
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ if (!E.IsSame(CE)) {
+ C = BRep_Tool::CurveOnSurface(E,FForward,f,l);
+ if (E.Orientation () == TopAbs_FORWARD) u = f;
+ else u = l;
+ P2 = C->Value(u);
+ dist = PV.Distance(P2);
+ if (dist <= distmin + (1./3)*delta){
+ gp_Pnt2d PC, P;
+ gp_Vec2d CTg1, CTg2, Tg1, Tg2;
+ Cc->D2(uc, PC, CTg1, CTg2);
+ C->D2(u, P, Tg1, Tg2);
+
+ Standard_Real angle;
+
+ if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_FORWARD) {
+ angle = CTg1.Angle(Tg1.Reversed());
+ }
+ else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_REVERSED) {
+ angle = (CTg1.Reversed()).Angle(Tg1);
+ }
+ else if (CE.Orientation () == TopAbs_REVERSED && E.Orientation () == TopAbs_REVERSED) {
+ angle = CTg1.Angle(Tg1);
+ }
+ else if (CE.Orientation () == TopAbs_FORWARD && E.Orientation () == TopAbs_FORWARD) {
+ angle = (CTg1.Reversed()).Angle(Tg1.Reversed());
+ }
+ if (angle >= anglemax) {
+ anglemax = angle ;
+ SelectedEdge = E;
+ }
+ }
+ }
+ }
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ if (E.IsEqual(SelectedEdge)) {
+ NE = TopoDS::Edge(E);
+ LE.Remove(itl);
+ break;
+ }
+ }
+ }
+ else if (LE.Extent() == 1) {
+ NE = TopoDS::Edge(LE.First());
+ LE.RemoveFirst();
+ }
+ else {
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : SamePnt2d
+//purpose :
+//=======================================================================
+static Standard_Boolean SamePnt2d(TopoDS_Vertex V,
+ TopoDS_Edge& E1,
+ TopoDS_Edge& E2,
+ TopoDS_Face& F)
+{
+ Standard_Real f1,f2,l1,l2;
+ gp_Pnt2d P1,P2;
+ TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD);
+ TopoDS_Face FF = TopoDS::Face(aLocalF);
+ Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1);
+ Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2);
+ if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1);
+ else P1 = C1->Value(l1);
+
+ if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2);
+ else P2 = C2->Value(f2);
+ Standard_Real Tol = 100*BRep_Tool::Tolerance(V);
+ Standard_Real Dist = P1.Distance(P2);
+ return Dist < Tol;
+}
+
+//=======================================================================
+//function : PurgeNewEdges
+//purpose :
+//=======================================================================
+static void PurgeNewEdges(TopTools_ListOfShape& ConstEdges,
+ const TopTools_MapOfOrientedShape& UsedEdges)
+{
+ TopTools_ListIteratorOfListOfShape it(ConstEdges);
+ while ( it.More()) {
+ const TopoDS_Shape& NE = it.Value();
+ if (!UsedEdges.Contains(NE)) {
+ ConstEdges.Remove(it);
+ }
+ else {
+ it.Next();
+ }
+ }
+}
+
+//=======================================================================
+//function : StoreInMVE
+//purpose :
+//=======================================================================
+static void StoreInMVE (const TopoDS_Face& F,
+ TopoDS_Edge& E,
+ TopTools_DataMapOfShapeListOfShape& MVE )
+
+{
+ TopoDS_Vertex V1, V2;
+ TopTools_ListOfShape Empty;
+
+ TopExp::Vertices(E,V1,V2);
+ if (!MVE.IsBound(V1)) {
+ MVE.Bind(V1,Empty);
+ }
+ MVE(V1).Append(E);
+
+ if (!MVE.IsBound(V2)) {
+ MVE.Bind(V2,Empty);
+ }
+ MVE(V2).Append(E);
+}
+
+//=======================================================================
+//function : Perform
+//purpose :
+//=======================================================================
+void Partition_Loop::Perform()
+{
+
+ TopTools_DataMapOfShapeListOfShape MVE;
+ TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit, Mapit1;
+ TopTools_ListIteratorOfListOfShape itl;
+ TopoDS_Vertex V1,V2;
+
+ //-----------------------------------
+ // Construction map vertex => edges
+ //-----------------------------------
+ for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) {
+ TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ StoreInMVE(myFace,E,MVE);
+ }
+
+ //----------------------------------------------
+ // Construction of all the wires and of all the new faces.
+ //----------------------------------------------
+ TopTools_MapOfOrientedShape UsedEdges;
+
+ while (!MVE.IsEmpty()) {
+ TopoDS_Vertex VF,CV;
+ TopoDS_Edge CE,NE,EF;
+ TopoDS_Wire NW;
+ BRep_Builder B;
+ Standard_Boolean End= Standard_False;
+
+ B.MakeWire(NW);
+ //--------------------------------
+ // EF first edge.
+ //--------------------------------
+ Mapit.Initialize(MVE);
+ EF = CE = TopoDS::Edge(Mapit.Value().First());
+
+ TopExp::Vertices(CE,V1,V2);
+ //--------------------------------
+ // VF first vertex
+ //--------------------------------
+ if (CE.Orientation() == TopAbs_FORWARD) {
+ CV = VF = V1;
+ }
+ else {
+ CV = VF = V2;
+ }
+ if (!MVE.IsBound(CV)) continue;
+ for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
+ if (itl.Value().IsEqual(CE)) {
+ MVE(CV).Remove(itl);
+ break;
+ }
+ }
+
+ int i = 0;
+ while (!End) {
+ //-------------------------------
+ // Construction of a wire.
+ //-------------------------------
+ TopExp::Vertices(CE,V1,V2);
+ if (!CV.IsSame(V1)) CV = V1; else CV = V2;
+ B.Add (NW,CE);
+ UsedEdges.Add(CE);
+
+ //--------------
+ // stop test
+ //--------------
+ if (!MVE.IsBound(CV) || MVE(CV).IsEmpty() || CV.IsSame(VF) ) {
+ if (CV.IsSame(VF)) {
+ if (MVE(CV).Extent() == 1 ) MVE.UnBind(CV);
+ else {
+ for ( itl.Initialize(MVE(CV)); itl.More(); itl.Next()) {
+ if (itl.Value().IsEqual(CE)) {
+ MVE(CV).Remove(itl);
+ break;
+ }
+ }
+ }
+ }
+ End=Standard_True;
+ }
+
+ //--------------
+ // select edge
+ //--------------
+ else {
+ Standard_Boolean find = SelectEdge(myFace,CE,CV,NE,MVE(CV));
+ if (find) {
+ CE=NE;
+ if (MVE(CV).IsEmpty()) MVE.UnBind(CV);
+ if (CE.IsNull() ) {
+ MESSAGE ( " CE is NULL !!! " )
+ End=Standard_True;
+ }
+ }
+ else {
+ MESSAGE ( " edge doesn't exist " )
+ End=Standard_True;
+ }
+ }
+ }
+
+ //-----------------------------
+ // Test if the wire is closed
+ //-----------------------------
+ if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) {
+ }
+ else{
+ MESSAGE ( "wire not closed" )
+ }
+ myNewWires.Append (NW);
+ }
+
+ PurgeNewEdges(myConstEdges,UsedEdges);
+
+}
+
+
+//=======================================================================
+//function : NewWires
+//purpose :
+//=======================================================================
+const TopTools_ListOfShape& Partition_Loop::NewWires() const
+{
+ return myNewWires;
+}
+
+//=======================================================================
+//function : NewFaces
+//purpose :
+//=======================================================================
+const TopTools_ListOfShape& Partition_Loop::NewFaces() const
+{
+ return myNewFaces;
+}
+
+//=======================================================================
+//function : WiresToFaces
+//purpose :
+//=======================================================================
+void Partition_Loop::WiresToFaces()
+{
+ if (!myNewWires.IsEmpty()) {
+ BRepAlgo_FaceRestrictor FR;
+
+ TopAbs_Orientation OriF = myFace.Orientation();
+ TopoDS_Shape aLocalS = myFace.Oriented(TopAbs_FORWARD);
+
+ FR.Init (TopoDS::Face(aLocalS),Standard_False);
+ TopTools_ListIteratorOfListOfShape it(myNewWires);
+ for (; it.More(); it.Next()) {
+ FR.Add(TopoDS::Wire(it.Value()));
+ }
+
+ FR.Perform();
+
+ if (FR.IsDone()) {
+ for (; FR.More(); FR.Next()) {
+ myNewFaces.Append(FR.Current().Oriented(OriF));
+ }
+ }
+ }
+}
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Loop.hxx
+// Module : GEOM
+
+#ifndef _Partition_Loop_HeaderFile
+#define _Partition_Loop_HeaderFile
+
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#endif
+class TopoDS_Face;
+class TopoDS_Edge;
+class TopTools_ListOfShape;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Loop {
+
+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 Partition_Loop();
+Standard_EXPORT void Init(const TopoDS_Face& F) ;
+Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ;
+Standard_EXPORT void Perform() ;
+Standard_EXPORT const TopTools_ListOfShape& NewWires() const;
+Standard_EXPORT void WiresToFaces() ;
+Standard_EXPORT const TopTools_ListOfShape& NewFaces() const;
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+
+
+ // Fields PRIVATE
+ //
+TopoDS_Face myFace;
+TopTools_ListOfShape myConstEdges;
+TopTools_ListOfShape myNewWires;
+TopTools_ListOfShape myNewFaces;
+
+
+};
+
+
+
+
+
+// other inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Loop.ixx
+// Module : GEOM
+
+#include "Partition_Loop.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Loop.jxx
+// Module : GEOM
+
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
+#include <TopTools_DataMapOfShapeShape.hxx>
+#endif
+#ifndef _Partition_Loop_HeaderFile
+#include "Partition_Loop.hxx"
+#endif
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- Copyright (C) 2003 CEA/DEN, EDF R&D
+--
+--
+--
+-- File : Partition_Loop2d.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+class Loop2d from Partition
+
+ ---Purpose: Builds the loops from a set of edges on a face.
+ -- It works in supposition that all constant edges
+ -- are split edges of an initialization face and all
+ -- section edges are new on the face
+
+uses
+
+ Orientation from TopAbs,
+ Boolean from Standard,
+ Face from TopoDS,
+ Image from BRepAlgo,
+ Face from TopoDS,
+ Edge from TopoDS,
+ ListOfShape from TopTools,
+ DataMapOfShapeListOfShape from TopTools,
+ MapOfShape from TopTools
+is
+
+ Create;
+
+ Init (me : in out; F : Face from TopoDS)
+ ---Purpose: Init with <F> the set of edges must have
+ -- pcurves on <F>.
+ is static;
+
+ AddConstEdge (me : in out; E : Edge from TopoDS)
+ ---Purpose: Add <E> as unique edge in the result.
+ is static;
+
+ AddSectionEdge (me : in out; E : Edge from TopoDS)
+ ---Purpose: Add <E> as double edge in the result.
+ is static;
+
+ Perform(me : in out)
+ ---Purpose: Make loops.
+ is static;
+
+ NewWires (me)
+ ---Purpose: Returns the list of wires performed.
+ -- can be an empty list.
+ ---C++: return const &
+ returns ListOfShape from TopTools;
+
+ WiresToFaces (me : in out; EdgeImage : Image from BRepAlgo)
+ ---Purpose: Build faces from the wires result.
+ -- <EdgeImage> serves to find original edge by new
+ -- one.
+ is static;
+
+ NewFaces (me)
+ ---Purpose: Returns the list of faces.
+ ---Warning: The method <WiresToFaces> as to be called before.
+ -- can be an empty list.
+ ---C++: return const &
+ returns ListOfShape from TopTools;
+
+
+fields
+
+ myFace : Face from TopoDS;
+ myFaceOri : Orientation from TopAbs;
+ myConstEdges : ListOfShape from TopTools;
+ myNewWires : ListOfShape from TopTools;
+ myNewFaces : ListOfShape from TopTools;
+
+ -- internal wires do not contain constant edges
+ myInternalWL : ListOfShape from TopTools;
+
+ mySectionEdges : MapOfShape from TopTools;
+
+end Loop2d;
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop2d.cxx
+// Author : Benedicte MARTIN
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "Partition_Loop2d.ixx"
+
+#include "utilities.h"
+#include <stdio.h>
+
+#include <BRepAdaptor_Curve2d.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAlgo_AsDes.hxx>
+#include <BRepOffset_DataMapOfShapeReal.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom2dInt_GInter.hxx>
+#include <Geom2d_Curve.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <Precision.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_SequenceOfReal.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfOrientedShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+
+//=======================================================================
+//function : Partition_Loop2d
+//purpose :
+//=======================================================================
+
+Partition_Loop2d::Partition_Loop2d()
+{
+}
+
+//=======================================================================
+//function : Init
+//purpose : Init with <F> the set of edges must have
+// pcurves on <F>.
+//=======================================================================
+
+void Partition_Loop2d::Init(const TopoDS_Face& F)
+{
+ myConstEdges.Clear();
+ myNewWires .Clear();
+ myNewFaces .Clear();
+ myFace = F;
+ myFaceOri = myFace.Orientation();
+ myFace.Orientation( TopAbs_FORWARD );
+}
+
+//=======================================================================
+//function : AddConstEdge
+//purpose : Add <E> as unique edge in the result.
+//=======================================================================
+
+void Partition_Loop2d::AddConstEdge (const TopoDS_Edge& E)
+{
+#ifdef DEB
+ Standard_Real f,l;
+ Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( E, myFace, f,l);
+ if (pc.IsNull()) {
+ INFOS( "AddConstEdge(): EDGE W/O PCURVE on FACE");
+ } else
+#endif
+ {
+ myConstEdges.Append(E);
+ }
+}
+
+void Partition_Loop2d::AddSectionEdge (const TopoDS_Edge& E)
+{
+#ifdef DEB
+ Standard_Real f,l;
+ Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( E, myFace, f,l);
+ if (pc.IsNull())
+ pc = BRep_Tool::CurveOnSurface( E, myFace, f,l);
+ gp_Vec2d Tg1;
+ gp_Pnt2d PC;
+ pc->D1(0.5*(f+l), PC, Tg1);
+ if (Tg1.Magnitude() <= gp::Resolution()) {
+ MESSAGE ("");
+ }
+ if (pc.IsNull()) {
+ INFOS( "AddConstEdge(): EDGE W/O PCURVE on FACE");
+ } else
+#endif
+ {
+ myConstEdges.Append(E);
+ myConstEdges.Append(E.Reversed());
+ mySectionEdges.Add( E );
+ }
+}
+
+//=======================================================================
+//function : SelectEdge
+//purpose : Find the edge <NE> connected <CE> by the vertex <CV> in the list <LE>.
+// <NE> Is erased of the list. If <CE> is too in the list <LE>
+// with the same orientation, it's erased of the list
+//=======================================================================
+
+static Standard_Boolean SelectEdge(const BRepAdaptor_Surface& Surf,
+ const TopoDS_Edge& CE,
+ const TopoDS_Vertex& CV,
+ TopoDS_Edge& NE,
+ const TopTools_ListOfShape& LE)
+{
+ NE.Nullify();
+
+ if (LE.Extent() > 1) {
+ //--------------------------------------------------------------
+ // Several possible edges.
+ // - Test the edges differents of CE
+ //--------------------------------------------------------------
+ TopoDS_Face FForward = Surf.Face();
+
+ Standard_Real cf, cl, f, l;
+ Handle(Geom2d_Curve) Cc, C;
+ Cc = BRep_Tool::CurveOnSurface(CE,FForward,cf,cl);
+
+// Standard_Real tolV, tol2d2;
+ Standard_Real tolV = BRep_Tool::Tolerance(CV);
+// tol2d2 = Max ( Surf.UResolution(tolV) , Surf.VResolution(tolV) );
+// tol2d2 = 2 * Max ( tol2d2, Precision::PConfusion() );
+// tol2d2 *= tol2d2;
+
+ Standard_Real uc,u, du = Precision::PConfusion();
+ if (CE.Orientation () == TopAbs_FORWARD) uc = cl + du;
+ else uc = cf - du;
+
+ gp_Vec2d CTg1, Tg1;
+ gp_Pnt2d PC, P;
+ gp_Pnt P3d;
+
+ Cc->D1(uc, PC, CTg1);
+ if (CE.Orientation () == TopAbs_REVERSED) CTg1.Reverse();
+
+ Standard_Real anglemin = 3 * PI;
+// Standard_Real sqdist, sqdistmin = 1.0e50;
+
+ TopTools_ListIteratorOfListOfShape itl;
+ for ( itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ if (E.IsSame(CE))
+ continue;
+ if (! CV.IsSame( TopExp::FirstVertex( E, Standard_True )))
+ continue;
+
+ C = BRep_Tool::CurveOnSurface(E,FForward,f,l);
+ if (E.Orientation () == TopAbs_FORWARD) u = f + du;
+ else u = l - du;
+
+ C->D1(u, P, Tg1);
+// if (P.SquareDistance(PC); > tol2d2)
+// continue;
+
+ if (E.Orientation () == TopAbs_REVERSED) Tg1.Reverse();
+
+ Standard_Real angle = Tg1.Angle(CTg1);
+
+ if (angle <= anglemin) {
+ anglemin = angle ;
+ NE = E;
+#ifdef DEB
+// sqdist = P.SquareDistance(PC);
+// if (sqdist < sqdistmin)
+// sqdistmin = sqdist;
+ P3d = Surf.Value (PC.X(), PC.Y());
+#endif
+ }
+ }
+#ifdef DEB
+ if (!NE.IsNull() && P3d.Distance( BRep_Tool::Pnt(CV)) > tolV) {
+ MESSAGE( "DISTANCE MORE THAN VERTEX TOL (" << tolV << ")" );
+ cout << "point p " << P3d.X() << " " << P3d.Y() << " " << P3d.Z() << endl;
+ }
+#endif
+ }
+ else if (LE.Extent() == 1) {
+ NE = TopoDS::Edge(LE.First());
+ }
+ else {
+ return Standard_False;
+ }
+ return !NE.IsNull();
+}
+
+//=======================================================================
+//function : SamePnt2d
+//purpose :
+//=======================================================================
+
+static Standard_Boolean SamePnt2d(const TopoDS_Vertex& V1,
+ const TopoDS_Edge& E1,
+ const TopoDS_Vertex& V2,
+ const TopoDS_Edge& E2,
+ const TopoDS_Face& F)
+{
+ Standard_Real f1,f2,l1,l2;
+ Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,F,f1,l1);
+ Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,F,f2,l2);
+
+ gp_Pnt2d P1 = C1->Value( BRep_Tool::Parameter(V1,E1));
+ gp_Pnt2d P2 = C2->Value( BRep_Tool::Parameter(V2,E2));
+
+ Standard_Real Tol = 100 * BRep_Tool::Tolerance(V1);
+ Standard_Real Dist = P1.Distance(P2);
+ return Dist < Tol;
+}
+
+
+//=======================================================================
+//function : StoreInMVE
+//purpose :
+//=======================================================================
+
+static void StoreInMVE (const TopoDS_Face& /*F*/,
+ TopoDS_Edge& E,
+ TopTools_DataMapOfShapeListOfShape& MVE )
+
+{
+ TopoDS_Vertex V1, V2;
+ TopTools_ListOfShape Empty;
+
+ TopExp::Vertices(E,V1,V2);
+ if (!MVE.IsBound(V1)) {
+ MVE.Bind(V1,Empty);
+ }
+ MVE(V1).Append(E);
+
+ if (!MVE.IsBound(V2)) {
+ MVE.Bind(V2,Empty);
+ }
+ MVE(V2).Append(E);
+}
+
+//=======================================================================
+//function : RemoveFromMVE
+//purpose :
+//=======================================================================
+
+static void RemoveFromMVE(const TopoDS_Edge& E,
+ TopTools_DataMapOfShapeListOfShape& MVE)
+{
+ TopTools_ListIteratorOfListOfShape itl;
+ TopoDS_Vertex V1,V2;
+ TopExp::Vertices (E,V1,V2);
+ if (MVE.IsBound(V1))
+ for ( itl.Initialize(MVE(V1)); itl.More(); itl.Next()) {
+ if (itl.Value().IsEqual(E)) {
+ MVE(V1).Remove(itl);
+ break;
+ }
+ }
+ if (MVE.IsBound(V2))
+ for ( itl.Initialize(MVE(V2)); itl.More(); itl.Next()) {
+ if (itl.Value().IsEqual(E)) {
+ MVE(V2).Remove(itl);
+ break;
+ }
+ }
+}
+//=======================================================================
+//function : addConnected
+//purpose : add to <EM> all edges reachable from <E>
+//=======================================================================
+
+static void addConnected(const TopoDS_Shape& E,
+ TopTools_MapOfShape& EM,
+ TopTools_MapOfShape& VM,
+ const TopTools_DataMapOfShapeListOfShape& MVE)
+{
+ // Loop on vertices of E
+ TopoDS_Iterator itV ( E );
+ for ( ; itV.More(); itV.Next()) {
+
+ if ( ! VM.Add ( itV.Value() )) continue;
+
+ // Loop on edges sharing V
+ TopTools_ListIteratorOfListOfShape itE( MVE( itV.Value() ) );
+ for (; itE.More(); itE.Next()) {
+ if ( EM.Add( itE.Value() ))
+ addConnected ( itE.Value(), EM, VM, MVE );
+ }
+ }
+}
+//=======================================================================
+//function : canPassToOld
+//purpose :
+//=======================================================================
+
+static Standard_Boolean canPassToOld (const TopoDS_Shape& V,
+ TopTools_MapOfShape& UsedShapesMap,
+ const TopTools_DataMapOfShapeListOfShape& MVE,
+ const TopTools_MapOfShape& SectionEdgesMap)
+{
+ TopTools_ListIteratorOfListOfShape itE( MVE(V) );
+ // Loop on edges sharing V
+ for (; itE.More(); itE.Next()) {
+ if ( !UsedShapesMap.Add( itE.Value() ))
+ continue; // already checked
+
+ if ( !SectionEdgesMap.Contains( itE.Value() ))
+ return Standard_True; // WE PASSED
+
+ TopoDS_Iterator itV( itE.Value() );
+ // Loop on vertices of an edge
+ for (; itV.More(); itV.Next()) {
+ if ( !UsedShapesMap.Add( itV.Value() ))
+ continue; // already checked
+ else
+ return canPassToOld( itV.Value(), UsedShapesMap, MVE, SectionEdgesMap);
+ }
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : MakeDegenAndSelect
+//purpose : Find parameter of intersection of <CE> with <DE> and
+// select an edge with its parameter closest to found one.
+// Return new degenerated edge trimming <DE> by found parameters
+//=======================================================================
+
+static TopoDS_Edge MakeDegenAndSelect(const TopoDS_Edge& CE,
+ const TopoDS_Vertex& CV,
+ TopoDS_Edge& NE,
+ TopTools_SequenceOfShape& EdgesSeq,
+ TColStd_SequenceOfReal& USeq,
+ const TopoDS_Edge& DE)
+{
+ if (EdgesSeq.Length() < 3) {
+ if (CE == EdgesSeq.First())
+ NE = TopoDS::Edge( EdgesSeq.Last() );
+ else
+ NE = TopoDS::Edge( EdgesSeq.First() );
+ return DE;
+ }
+
+ // find parameter on DE where it intersects CE
+
+ Standard_Real U1;
+ Standard_Integer i, nb = EdgesSeq.Length();
+ for (i=1; i<= nb; ++i) {
+ if (CE == EdgesSeq(i)) {
+ U1 = USeq(i);
+ break;
+ }
+ }
+
+ // select NE with param closest to U1 thus finding U2 for a new degen edge
+
+ Standard_Real U2, dU, dUmin = 1.e100;
+ Standard_Boolean isReversed = ( DE.Orientation() == TopAbs_REVERSED );
+ for (i=1; i<= nb; ++i) {
+ dU = USeq(i) - U1;
+ if (isReversed ? (dU > 0) : (dU < 0))
+ continue;
+ dU = Abs( dU );
+ if ( dU > dUmin || IsEqual( dU, 0.))
+ continue;
+ const TopoDS_Edge& E = TopoDS::Edge ( EdgesSeq(i) );
+ if ( ! CV.IsSame( TopExp::FirstVertex( E , Standard_True )))
+ continue;
+ NE = E;
+ dUmin = dU + Epsilon(dU);
+ U2 = USeq(i);
+ }
+
+ // make a new degenerated edge
+ TopoDS_Edge NewDegen = TopoDS::Edge ( DE.EmptyCopied() );
+
+ Standard_Real Tol = BRep_Tool::Tolerance( CV );
+ TopoDS_Vertex V = CV;
+
+ BRep_Builder B;
+ V.Orientation( NewDegen.Orientation() );
+ B.UpdateVertex( V, U1, NewDegen, Tol);
+ B.Add ( NewDegen , V );
+
+ V.Reverse();
+ B.UpdateVertex( V, U2, NewDegen, Tol);
+ B.Add ( NewDegen , V );
+
+ return NewDegen;
+}
+
+//=======================================================================
+//function : prepareDegen
+//purpose : Intersect <DegEdge> with edges bound to its vertex in <MVE>
+// and store intersection parameter on <DegEdge> in
+// <USeq> as well as the edges them-self in <EdgesSeq>.
+// Bind <DegEdgeIndex> to vertex of <DegEdge> in <MVDEI>
+//=======================================================================
+
+static void prepareDegen (const TopoDS_Edge& DegEdge,
+ const TopoDS_Face& F,
+ const TopTools_DataMapOfShapeListOfShape& MVE,
+ TopTools_SequenceOfShape& EdgesSeq,
+ TColStd_SequenceOfReal& USeq,
+ TopTools_DataMapOfShapeInteger& MVDEI,
+ const Standard_Integer DegEdgeIndex)
+{
+ const TopoDS_Vertex& V = TopExp::FirstVertex ( DegEdge );
+ MVDEI.Bind ( V, DegEdgeIndex );
+
+ const TopTools_ListOfShape& EdgesList = MVE ( V );
+ // if only 2 edges come to degenerated one, no pb in selection and
+ // no need to intersect them, just simulate asked data
+ Standard_Boolean doIntersect = ( EdgesList.Extent() > 2 );
+
+ BRepAdaptor_Curve2d DC, C;
+ Geom2dInt_GInter InterCC;
+ Standard_Real Tol = Precision::PConfusion();
+ if ( doIntersect )
+ DC.Initialize( DegEdge, F );
+
+ // avoid intersecting twice the same edge
+ BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
+
+ Standard_Real U, f, l;
+ BRep_Tool::Range (DegEdge, f, l);
+
+ TopTools_ListIteratorOfListOfShape itE (EdgesList);
+ for (; itE.More(); itE.Next()) {
+
+ const TopoDS_Edge& E = TopoDS::Edge ( itE.Value() );
+
+ if ( !doIntersect) {
+ U = 0.; // it won't be used
+ }
+ else if ( BRep_Tool::IsClosed( E, F )) {
+ // seam edge: select U among f and l
+ Standard_Boolean first = Standard_True;
+ if ( V.IsSame ( TopExp::FirstVertex( E, Standard_True ) ))
+ first = Standard_False;
+ if ( DegEdge.Orientation() == TopAbs_REVERSED )
+ first = !first;
+ U = first ? f : l;
+ }
+ else if ( EUMap.IsBound( E ) ) {
+ // same edge already bound
+ U = EUMap( E );
+ }
+ else {
+ // intersect 2d curves
+ C.Initialize( E, F );
+ InterCC.Perform ( DC, C , Tol, Tol );
+ if (! InterCC.IsDone() || InterCC.NbPoints() == 0) {
+ MESSAGE ( "NO 2d INTERSECTION ON DEGENERATED EDGE" );
+ continue;
+ }
+ // hope there is only one point of intersection
+ U = InterCC.Point( 1 ).ParamOnFirst();
+ }
+ USeq.Append ( U );
+ EdgesSeq.Append ( E );
+ }
+}
+//=======================================================================
+//function : Perform
+//purpose : Make loops.
+//=======================================================================
+
+void Partition_Loop2d::Perform()
+{
+
+ Standard_Integer NbConstEdges = myConstEdges.Extent();
+ TopTools_DataMapOfShapeListOfShape MVE(NbConstEdges) , MVE2(NbConstEdges);
+ TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit;
+ TopTools_ListIteratorOfListOfShape itl;
+ TopoDS_Vertex V1,V2;
+ BRepAdaptor_Surface Surface ( myFace, Standard_False );
+
+ // degenerated edges and parameters of their 2d intersection with other edges
+ TopoDS_Edge DE [2];
+ TopTools_SequenceOfShape SEID [2]; // seq of edges intersecting degenerated
+ TColStd_SequenceOfReal SeqU [2]; // n-th U corresponds to n-th edge in SEID
+ TopTools_DataMapOfShapeInteger MVDEI(2); // map vertex - degenerated edge index
+ Standard_Integer iDeg = 0; // index of degenerated edge [0,1]
+
+ //---------------------------------------------------------
+ // Construction map vertex => edges, find degenerated edges
+ //---------------------------------------------------------
+ for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) {
+ TopoDS_Edge& E = TopoDS::Edge(itl.Value());
+ if ( BRep_Tool::Degenerated( E )) {
+ if (DE[0].IsNull()) DE[0] = E;
+ else DE[1] = E;
+ }
+ else
+ StoreInMVE(myFace,E,MVE);
+ }
+
+ // fill data for degenerated edges
+ if ( ! DE[0].IsNull() )
+ prepareDegen ( DE[0], myFace, MVE, SEID[0], SeqU[0], MVDEI, 0);
+ if ( ! DE[1].IsNull() )
+ prepareDegen ( DE[1], myFace, MVE, SEID[1], SeqU[1], MVDEI, 1);
+
+
+ // to detect internal wires
+ Standard_Boolean isInternCW = 0;
+ MVE2 = MVE;
+
+
+ //------------------------------
+ // Construction of all the wires
+ //------------------------------
+ // first, we collect wire edges in WEL list looking for same edges that
+ // will be then removed possibly exploding a wire into parts;
+ // second, build wire(s)
+
+ while (!MVE.IsEmpty()) {
+
+ TopoDS_Vertex VF,CV;
+ TopoDS_Edge CE,NE,EF;
+ TopoDS_Wire NW;
+ BRep_Builder B;
+ Standard_Boolean End = Standard_False;
+ TopTools_ListOfShape WEL;
+
+ Mapit.Initialize(MVE);
+ if (Mapit.Value().IsEmpty()) {
+ MVE.UnBind(Mapit.Key());
+ continue;
+ }
+
+ // EF first edge.
+ EF = CE = TopoDS::Edge(Mapit.Value().First());
+ // VF first vertex
+ VF = TopExp::FirstVertex( CE, Standard_True);
+
+ isInternCW = Standard_True;
+
+ TopTools_MapOfShape addedEM (NbConstEdges); // map of edges added to WEL
+ TopTools_MapOfShape doubleEM (NbConstEdges); // edges encountered twice in WEL
+
+ //-------------------------------
+ // Construction of a wire.
+ //-------------------------------
+ while (!End) {
+
+ // only a seam is allowed twice in a wire, the others should be removed
+ if (addedEM.Add ( CE ) || BRep_Tool::IsClosed( CE, myFace ) )
+ WEL.Append( CE );
+ else {
+ doubleEM.Add( CE );
+ RemoveFromMVE (CE,MVE2);
+ TopoDS_Edge CERev = CE;
+ CERev.Reverse();
+ RemoveFromMVE (CERev,MVE2);
+ }
+
+ RemoveFromMVE (CE,MVE);
+
+ CV = TopExp::LastVertex( CE, Standard_True);
+
+ if (isInternCW && !mySectionEdges.Contains(CE))
+ // wire is internal if all edges are section ones
+ isInternCW = Standard_False;
+
+ if (MVDEI.IsBound( CV )) { // CE comes to the degeneration
+ iDeg = MVDEI( CV );
+ TopoDS_Edge NewDegen;
+ NewDegen = MakeDegenAndSelect( CE, CV, NE, SEID[iDeg], SeqU[iDeg], DE[iDeg]);
+ WEL.Append( NewDegen );
+ CE = NE;
+ End = CV.IsSame( VF );
+ continue;
+ }
+
+ //--------------
+ // stop test
+ //--------------
+ if (MVE(CV).IsEmpty()) {
+ End=Standard_True;
+ MVE.UnBind(CV);
+ }
+ else if (CV.IsSame(VF) && SamePnt2d(CV,CE, VF,EF, myFace) ) {
+ End = Standard_True;
+ }
+ else {
+ //----------------------------
+ // select new current edge
+ //----------------------------
+ if (! SelectEdge (Surface,CE,CV,NE,MVE(CV))) {
+ MESSAGE ( " NOT CLOSED WIRE " );
+ End=Standard_True;
+ }
+ else
+ CE = NE;
+ }
+ } // while ( !End )
+
+
+ // WEL is built, built wire(s)
+
+
+ itl.Initialize( WEL );
+ if ( doubleEM.IsEmpty()) { // no double edges
+ B.MakeWire( NW );
+ for (; itl.More(); itl.Next())
+ B.Add ( NW, itl.Value());
+ if (isInternCW) myInternalWL.Append(NW);
+ else myNewWires.Append (NW);
+ }
+
+ else {
+ // remove double and degenerated edges from WEL
+ while (itl.More()) {
+ const TopoDS_Edge& E = TopoDS::Edge ( itl.Value() );
+ if ( doubleEM.Contains( E ) || BRep_Tool::Degenerated( E ))
+ WEL.Remove( itl );
+ else
+ itl.Next();
+ }
+ if ( WEL.IsEmpty())
+ continue;
+ // remove double edges from SEID and SeqU
+ Standard_Integer i,j;
+ for (j=0; j<2; ++j) {
+ for (i=1; i<=SEID[j].Length(); ++i) {
+ if (doubleEM.Contains( SEID[j].Value(i))) {
+ SEID[j].Remove( i );
+ SeqU[j].Remove( i-- );
+ }
+ }
+ }
+ // removal of doulbe edges can explode a wire into parts,
+ // make new wires of them.
+ // A Loop like previous one but without 2d check
+ while ( !WEL.IsEmpty() ) {
+ CE = TopoDS::Edge( WEL.First() );
+ WEL.RemoveFirst();
+ B.MakeWire( NW );
+ VF = TopExp::FirstVertex ( EF, Standard_True);
+
+ End = Standard_False;
+ while ( !End) {
+ B.Add( NW, CE );
+ CV = TopExp::LastVertex ( CE, Standard_True);
+
+ if (MVDEI.IsBound( CV )) { // CE comes to the degeneration
+ iDeg = MVDEI( CV );
+ TopoDS_Edge NewDegen;
+ NewDegen = MakeDegenAndSelect( CE, CV, NE, SEID[iDeg], SeqU[iDeg], DE[iDeg]);
+ B.Add( NW, NewDegen );
+ End = CV.IsSame( VF );
+ CE = NE;
+ if (!NE.IsNull()) { // remove NE from WEL
+ for (itl.Initialize( WEL ); itl.More(); itl.Next())
+ if ( NE == itl.Value()) {
+ WEL.Remove( itl );
+ break;
+ }
+ }
+ } // end degeneration
+
+ else {
+ if (CV.IsSame( VF )) {
+ End = Standard_True;
+ continue;
+ }
+ // edges in WEL most often are well ordered
+ // so try to iterate until the End
+ Standard_Boolean add = Standard_False;
+ itl.Initialize(WEL);
+ while ( itl.More() && !End) {
+ NE = TopoDS::Edge( itl.Value() );
+ if ( CV.IsSame( TopExp::FirstVertex( NE, Standard_True ))) {
+ WEL.Remove( itl );
+ if (add)
+ B.Add( NW, CE );
+ CE = NE;
+ add = Standard_True;
+ CV = TopExp::LastVertex( CE, Standard_True);
+ if (MVDEI.IsBound( CV ) || CV.IsSame( VF ))
+ break;
+ }
+ else
+ itl.Next();
+ }
+ if (!add)
+ End = Standard_True;
+ }
+ } // !End
+
+ myInternalWL.Append( NW );
+ }
+ } // end building new wire(s) from WEL
+
+ } // end Loop on MVE
+
+ // all wires are built
+
+
+ // ============================================================
+ // select really internal wires i.e. those from which we can`t
+ // pass to an old (not section) edge
+ // ============================================================
+
+ Standard_Integer nbIW = myInternalWL.Extent();
+ if ( nbIW == 1 ) {
+ TopTools_MapOfShape UsedShapes( 2*NbConstEdges );
+ TopExp_Explorer expV (myInternalWL.First(), TopAbs_VERTEX);
+ if (canPassToOld (expV.Current(), UsedShapes, MVE2, mySectionEdges))
+ myNewWires.Append ( myInternalWL );
+ }
+ else if ( nbIW > 1 ) {
+ TopTools_MapOfShape outerEM (NbConstEdges); // edges connected to non-section ones
+ TopTools_MapOfShape visitedVM (NbConstEdges);
+ for ( itl.Initialize( myConstEdges ); itl.More(); itl.Next()) {
+ if ( ! mySectionEdges.Contains( itl.Value() ))
+ addConnected (itl.Value(), outerEM, visitedVM, MVE2);
+ }
+ // if an edge of a wire is in <outerEM>, the wire is not internal
+ TopExp_Explorer expIWE;
+ TopTools_ListIteratorOfListOfShape itIW ( myInternalWL );
+ while (itIW.More()) {
+ expIWE.Init ( itIW.Value() , TopAbs_EDGE );
+ if ( outerEM.Contains( expIWE.Current() )) {
+ myNewWires.Append ( itIW.Value() );
+ myInternalWL.Remove( itIW ); // == itIW.Next()
+ }
+ else
+ itIW.Next();
+ }
+ }
+}
+//=======================================================================
+//function : isHole
+//purpose :
+//=======================================================================
+
+static Standard_Boolean isHole (const TopoDS_Wire& W,
+ const TopoDS_Face& F)
+{
+ BRep_Builder B;
+ TopoDS_Shape newFace = F.EmptyCopied();
+ B.Add(newFace,W.Oriented(TopAbs_FORWARD));
+ BRepTopAdaptor_FClass2d classif (TopoDS::Face(newFace),
+ Precision::PConfusion());
+ return (classif.PerformInfinitePoint() == TopAbs_IN);
+}
+
+//=======================================================================
+//function : IsInside
+//purpose : check if W1 is inside W2. Suppose W2 is not a hole !!!!
+//=======================================================================
+
+static Standard_Boolean isInside(const TopoDS_Face& F,
+ const TopoDS_Wire& W1,
+ const TopoDS_Wire& W2)
+{
+ // make a face with wire W2
+ BRep_Builder B;
+ TopoDS_Shape aLocalShape = F.EmptyCopied();
+ TopoDS_Face newFace = TopoDS::Face(aLocalShape);
+ B.Add(newFace,W2);
+
+ // get any 2d point of W1
+ TopExp_Explorer exp(W1,TopAbs_EDGE);
+ const TopoDS_Edge& edg = TopoDS::Edge(exp.Current());
+ Standard_Real f,l;
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(edg,F,f,l);
+ gp_Pnt2d pt2d(C2d->Value(f));
+
+ BRepTopAdaptor_FClass2d classif(newFace,Precision::PConfusion());
+ return (classif.Perform(pt2d) == TopAbs_IN);
+}
+
+//=======================================================================
+//function : NewWires
+//purpose : Returns the list of wires performed.
+// can be an empty list.
+//=======================================================================
+
+const TopTools_ListOfShape& Partition_Loop2d::NewWires() const
+{
+ return myNewWires;
+}
+
+//=======================================================================
+//function : NewFaces
+//purpose : Returns the list of faces.
+//Warning : The method <WiresToFaces> as to be called before.
+// can be an empty list.
+//=======================================================================
+
+const TopTools_ListOfShape& Partition_Loop2d::NewFaces() const
+{
+ return myNewFaces;
+}
+
+//=======================================================================
+//function : findEqual
+//purpose : move wires form <WL> to <EqWL> pairs of wires build of the same edges
+//=======================================================================
+
+static void findEqual (TopTools_ListOfShape& WL,
+ TopTools_DataMapOfShapeShape& EqWM,
+ const TopoDS_Face& F)
+{
+ TopTools_ListIteratorOfListOfShape it1, it2;
+ Standard_Integer i,j;
+ TColStd_MapOfInteger IndMap;
+ for (it1.Initialize(WL), i=1; it1.More(); it1.Next(), i++) {
+
+ if (IndMap.Contains(i)) continue;
+ const TopoDS_Wire& Wire1 = TopoDS::Wire( it1.Value());
+
+ for (it2.Initialize(WL), j=1; it2.More(); it2.Next(), j++) {
+
+ if (j <= i || IndMap.Contains(j)) continue;
+
+ TopTools_IndexedMapOfShape EdgesMap;
+ TopExp::MapShapes (Wire1, TopAbs_EDGE, EdgesMap);
+
+ const TopoDS_Shape& Wire2 = it2.Value();
+ TopoDS_Iterator itE ( Wire2);
+ for (; itE.More(); itE.Next()) {
+ if ( !EdgesMap.Contains( itE.Value()) )
+ break;
+ }
+ if (!itE.More()) { // all edges are same
+ if (isHole( Wire1, F)) {
+ EqWM.Bind ( Wire1, Wire2 );
+ }
+ else {
+ EqWM.Bind ( Wire2, Wire1 );
+ }
+ IndMap.Add(i);
+ IndMap.Add(j);
+ break;
+ }
+ }
+ }
+ // clear WL
+ it1.Initialize(WL);
+ i=1;
+ while (it1.More()) {
+ if (IndMap.Contains(i))
+ WL.Remove(it1); // next node becomes current and with Next() we would miss it
+ else
+ it1.Next();
+ i++;
+ }
+}
+
+//=======================================================================
+//function : classify
+//purpose : bind to a wire a list of internal wires
+//=======================================================================
+
+static void classify(const TopTools_DataMapOfShapeShape& EqWM,
+ BRepAlgo_AsDes& OuterInner,
+ const TopoDS_Face& F)
+{
+ TopTools_DataMapIteratorOfDataMapOfShapeShape it1, it2;
+
+ for (it1.Initialize(EqWM); it1.More(); it1.Next()) {
+ for (it2.Initialize(EqWM); it2.More(); it2.Next()) {
+ if (it1.Value().IsSame( it2.Value() )) continue;
+ const TopoDS_Wire& Wire1 = TopoDS::Wire( it1.Value() );
+ const TopoDS_Wire& Wire2 = TopoDS::Wire( it2.Value() );
+ if (isInside(F, Wire1, Wire2))
+ OuterInner.Add (Wire2, Wire1);
+ else if (isInside(F, Wire2, Wire1))
+ OuterInner.Add (Wire1, Wire2);
+ }
+ }
+}
+//=======================================================================
+//function : WiresToFaces
+//purpose : Build faces from the wires result.
+// <EdgeImage> serves to find original edge by new
+// one. <Section> contains edges resulting from face
+// intersections
+//=======================================================================
+
+//#define USE_BREPFEAT_SPLITSHAPE
+
+#ifdef USE_BREPFEAT_SPLITSHAPE
+
+# include <BRepFeat_SplitShape.hxx>
+void Partition_Loop2d::WiresToFaces(const BRepAlgo_Image& EdgeImage)
+#else
+
+# include <BRepAlgo_FaceRestrictor.hxx>
+void Partition_Loop2d::WiresToFaces(const BRepAlgo_Image& )
+#endif
+{
+ Standard_Integer nbW = myNewWires.Extent() + myInternalWL.Extent();
+ if (nbW==0)
+ return;
+
+#ifndef USE_BREPFEAT_SPLITSHAPE
+
+ // ============================================================
+ // use BRepAlgo_FaceRestrictor to make faces
+ // ============================================================
+
+ BRepAlgo_FaceRestrictor FR;
+ FR.Init (myFace,Standard_False);
+
+ // FaceRestrictor is instable in rather simple cases
+ // (ex. a single face of bellecoque.brep splited by 10 planes:
+ // sometimes 1-2 faces are missing ).
+ // So we use it as less as possible: no holes -> make faces by hands
+
+
+ // are there holes in myFace ?
+ Standard_Boolean hasOldHoles = Standard_False;
+ TopoDS_Iterator itOldW (myFace);
+ if ( itOldW.More()) {
+ const TopoDS_Wire& FirstOldWire = TopoDS::Wire( itOldW.Value() );
+ itOldW.Next();
+ hasOldHoles = itOldW.More() || isHole( FirstOldWire, myFace);
+ }
+ if (myInternalWL.IsEmpty() && !hasOldHoles) {
+ // each wire bounds one face
+ BRep_Builder B;
+ TopTools_ListIteratorOfListOfShape itNW (myNewWires);
+ for (; itNW.More(); itNW.Next()) {
+ TopoDS_Face NF = TopoDS::Face ( myFace.EmptyCopied() );
+ B.Add ( NF, itNW.Value() );
+ NF.Orientation( myFaceOri);
+ myNewFaces.Append ( NF );
+ }
+ return;
+ }
+
+ // FaceRestrictor can't classify wires build on all the same edges
+ // and gives incorrect result in such cases (ex. a plane cut into 2 parts by cylinder)
+ // We must make faces of equal wires separately. One of equal wires makes a
+ // hole in a face and should come together with outer wires of face.
+ // The other of a wires pair bounds a face that may have holes in turn.
+
+ // Find equal wires among internal wires
+ TopTools_DataMapOfShapeShape EqWM; // key is a hole part of a pair of equal wires
+ findEqual (myInternalWL, EqWM, myFace);
+
+ if (!EqWM.IsEmpty()) { // there are equal wires
+
+ if (hasOldHoles)
+ myInternalWL.Append( myNewWires ); // an old wire can be inside an equal wire
+
+ // classify equal wire pairs
+ BRepAlgo_AsDes OuterInner;
+ classify (EqWM,OuterInner,myFace);
+
+ // make face of most internal of equal wires and its inner wires
+ while ( !EqWM.IsEmpty()) {
+
+ TopTools_ListOfShape prevHolesL; // list of hole-part of previous most internal equal wires
+
+ // find most internal wires among pairs (key - hole, value - outer part)
+ TopTools_DataMapIteratorOfDataMapOfShapeShape it(EqWM);
+ for ( ; it.More(); it.Next()) {
+
+ TopoDS_Wire outerW = TopoDS::Wire ( it.Value() );
+ if ( OuterInner.HasDescendant( outerW ) && // has internal
+ ! OuterInner.Descendant( outerW ).IsEmpty() )
+ continue;
+
+ FR.Add( outerW );
+
+ // add internal wires that are inside of outerW
+ TopTools_ListIteratorOfListOfShape itIW (myInternalWL);
+ while ( itIW.More()) {
+ TopoDS_Wire IW = TopoDS::Wire ( itIW.Value() );
+ if ( isInside (myFace, IW, outerW)) {
+ FR.Add (IW);
+ myInternalWL.Remove( itIW ); // == itIW.Next() !!!
+ }
+ else
+ itIW.Next();
+ }
+
+ // the hole-part of current pair of equal wires will be in the next new face
+ prevHolesL.Append ( it.Key() );
+
+ } // Loop on map of equal pairs searching for innermost wires
+
+ // make faces
+ FR.Perform();
+ if (FR.IsDone()) {
+ for (; FR.More(); FR.Next())
+ myNewFaces.Append(FR.Current());
+ }
+
+ FR.Clear();
+
+ // add hole-parts to FaceRestrictor,
+ // remove themfrom the EqWM,
+ // remove found wires as internal of resting classified wires
+ Standard_Boolean clearOuterInner = ( prevHolesL.Extent() < EqWM.Extent() );
+ TopTools_ListIteratorOfListOfShape itPrev (prevHolesL);
+ for (; itPrev.More(); itPrev.Next()) {
+ TopoDS_Wire& Hole = TopoDS::Wire ( itPrev.Value() );
+ FR.Add ( Hole );
+ if (clearOuterInner) {
+ const TopoDS_Wire& outerW = TopoDS::Wire ( EqWM.Find( Hole ) );
+ // Loop on wires including outerW
+ TopTools_ListIteratorOfListOfShape itO( OuterInner.Ascendant( outerW ));
+ for (; itO.More(); itO.Next()) {
+ TopTools_ListOfShape& innerL = OuterInner.ChangeDescendant( itO.Value() );
+ TopTools_ListIteratorOfListOfShape itI (innerL);
+ // Loop on internal wires of current including wire
+ for (; itI.More(); itI.Next())
+ if ( outerW.IsSame( itI.Value() )) {
+ innerL.Remove( itI ); break;
+ }
+ }
+ }
+ EqWM.UnBind ( Hole );
+ }
+
+ } // while (!EqWM.IsEmpty)
+
+ } // !EqWM.IsEmpty()
+
+ myNewWires.Append ( myInternalWL );
+
+ TopTools_ListIteratorOfListOfShape itW (myNewWires);
+ for (; itW.More(); itW.Next()) {
+ TopoDS_Wire& W = TopoDS::Wire ( itW.Value() );
+ FR.Add(W);
+ }
+ FR.Perform();
+ for (; FR.IsDone() && FR.More(); FR.Next())
+ myNewFaces.Append(FR.Current());
+
+
+
+#else // ifndef USE_BREPFEAT_SPLITSHAPE
+
+ // ============================================================
+ // use BRepFeat_SplitShape to make faces
+ // ============================================================
+
+ BRepFeat_SplitShape Split(myFace);
+ TopTools_MapOfShape AddedSectionEdgesMap;
+
+ myNewWires.Append(myInternalWL);
+
+ TopTools_ListIteratorOfListOfShape it(myNewWires);
+ for (; it.More(); it.Next()) {
+ TopoDS_Iterator itE(it.Value());
+ for (; itE.More(); itE.Next()) {
+ const TopoDS_Edge& newE = TopoDS::Edge( itE.Value() );
+ if (AddedSectionEdgesMap.Add(newE)) {
+ if (mySectionEdges.Contains(newE))
+ Split.Add(newE,F); // new edge on face
+ else {
+ const TopoDS_Edge& oldE = TopoDS::Edge( EdgeImage.ImageFrom(newE) );
+ Split.Add(newE, oldE); // splited edge
+ }
+ }
+ }
+ }
+ Split.Build();
+
+ if (Split.IsDone())
+ myNewFaces = Split.Modified(F);
+
+#endif // ifndef USE_BREPFEAT_SPLITSHAPE
+
+
+
+#ifdef DEB
+ Standard_Integer nbF = myNewFaces.Extent();
+ if (nbW != nbF)
+ cout << "WiresToFaces(): " << nbW << " wires --> " << myNewFaces.Extent() << " faces "
+ << endl;
+#endif
+
+ TopTools_ListIteratorOfListOfShape itNF (myNewFaces);
+ for (; itNF.More(); itNF.Next())
+ itNF.Value().Orientation( myFaceOri );
+}
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop2d.hxx
+// Module : GEOM
+
+#ifndef _Partition_Loop2d_HeaderFile
+#define _Partition_Loop2d_HeaderFile
+
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopAbs_Orientation_HeaderFile
+#include <TopAbs_Orientation.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_MapOfShape_HeaderFile
+#include <TopTools_MapOfShape.hxx>
+#endif
+class TopoDS_Face;
+class TopoDS_Edge;
+class TopTools_ListOfShape;
+class BRepAlgo_Image;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Loop2d {
+
+public:
+
+ void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+ // Methods PUBLIC
+ //
+Standard_EXPORT Partition_Loop2d();
+Standard_EXPORT void Init(const TopoDS_Face& F) ;
+Standard_EXPORT void AddConstEdge(const TopoDS_Edge& E) ;
+Standard_EXPORT void AddSectionEdge(const TopoDS_Edge& E) ;
+Standard_EXPORT void Perform() ;
+Standard_EXPORT const TopTools_ListOfShape& NewWires() const;
+Standard_EXPORT void WiresToFaces(const BRepAlgo_Image& EdgeImage) ;
+Standard_EXPORT const TopTools_ListOfShape& NewFaces() const;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+
+
+ // Fields PRIVATE
+ //
+TopoDS_Face myFace;
+TopAbs_Orientation myFaceOri;
+TopTools_ListOfShape myConstEdges;
+TopTools_ListOfShape myNewWires;
+TopTools_ListOfShape myNewFaces;
+TopTools_ListOfShape myInternalWL;
+TopTools_MapOfShape mySectionEdges;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop2d.ixx
+// Module : GEOM
+
+#include "Partition_Loop2d.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop2d.jxx
+// Module : GEOM
+
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _BRepAlgo_Image_HeaderFile
+#include <BRepAlgo_Image.hxx>
+#endif
+#ifndef _Partition_Loop2d_HeaderFile
+#include "Partition_Loop2d.hxx"
+#endif
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- Copyright (C) 2003 CEA/DEN, EDF R&D
+--
+--
+--
+-- File : Partition_Loop3d.cdl
+-- Module : GEOM
+
+class Loop3d from Partition
+
+ ---Purpose: Builds the shells from a set of faces.
+ -- Provides methods for comparing faces mutual
+ -- location.
+
+uses
+ Vec from gp,
+ MapOfOrientedShape from TopTools,
+ IndexedDataMapOfShapeListOfShape from TopTools,
+ Face from TopoDS,
+ Edge from TopoDS,
+ ListOfShape from TopTools,
+ Shape from TopoDS
+
+is
+
+ Create;
+
+ AddConstFaces (me : in out; S : Shape from TopoDS)
+ ---Purpose: Add faces of <S> as unique faces in the result.
+ is static;
+
+ AddSectionFaces (me : in out; S : Shape from TopoDS)
+ ---Purpose: Add faces of <S> as double faces in the result.
+ is static;
+
+ MakeShells (me : in out; AvoidFacesMap : MapOfOrientedShape from TopTools)
+ returns ListOfShape from TopTools is static;
+ ---Purpose: Make and return shells.
+ -- <AvoidFacesMap> can contain faces that must not be
+ -- added to result shells.
+ ---C++: return const &
+
+
+ ---Category: class methods
+
+ IsInside (myclass; E : Edge from TopoDS;
+ F1, F2 : Face from TopoDS;
+ CountDot : Boolean from Standard;
+ Dot : in out Real from Standard;
+ GoodOri : in out Boolean from Standard)
+ returns Boolean from Standard;
+ ---Purpose: check if <F2> is inside <F1> by edge <E>.
+ -- if <CountDot>, compute <Dot>: scalar production of
+ -- normalized vectors pointing inside faces, and
+ -- check if faces are oriented well for sewing
+
+ Normal (myclass; E : Edge from TopoDS;
+ F : Face from TopoDS) returns Vec from gp;
+
+
+fields
+
+ myNewShells : ListOfShape from TopTools; -- result
+
+ myFaces : ListOfShape from TopTools;
+ myEFMap : IndexedDataMapOfShapeListOfShape from TopTools;
+
+end Loop3d;
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop3d.cxx
+// Module : GEOM
+
+using namespace std;
+#include "Partition_Loop3d.ixx"
+
+#include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
+#include <BRep_Builder.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <Geom2d_Curve.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Surface.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <gp_Dir2d.hxx>
+#include <Geom_Curve.hxx>
+
+//=======================================================================
+//function : Partition_Loop3d
+//purpose :
+//=======================================================================
+
+Partition_Loop3d::Partition_Loop3d()
+{
+}
+
+//=======================================================================
+//function : AddConstFaces
+//purpose : Add faces of <S> as unique faces in the result.
+//=======================================================================
+
+void Partition_Loop3d::AddConstFaces(const TopoDS_Shape& S)
+{
+ TopExp_Explorer FaceExp(S, TopAbs_FACE);
+ for (; FaceExp.More(); FaceExp.Next())
+ myFaces.Append( FaceExp.Current() );
+
+ TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, myEFMap);
+}
+
+//=======================================================================
+//function : AddSectionFaces
+//purpose : Add faces of <S> as double faces in the result.
+//=======================================================================
+
+void Partition_Loop3d::AddSectionFaces(const TopoDS_Shape& S)
+{
+ AddConstFaces( S );
+ AddConstFaces( S.Reversed() );
+}
+
+//=======================================================================
+//function : MakeShells
+//purpose : Make and return shells.
+// <AvoidFacesMap> can contain faces that must not be
+// added to result shells.
+//=======================================================================
+
+const TopTools_ListOfShape&
+ Partition_Loop3d::MakeShells (const TopTools_MapOfOrientedShape& AvoidFacesMap)
+{
+ myNewShells.Clear();
+
+ BRep_Builder Builder;
+ TopTools_MapOfShape CheckedEdgesMap;
+ TopTools_MapOfOrientedShape AddedFacesMap;
+
+ TopTools_ListIteratorOfListOfShape itF (myFaces);
+ for (; itF.More(); itF.Next())
+ {
+ const TopoDS_Shape& FF = itF.Value();
+ if (AvoidFacesMap.Contains( FF ) ||
+ ! AddedFacesMap.Add( FF ) )
+ continue;
+
+ // make a new shell
+ TopoDS_Shell Shell;
+ Builder.MakeShell(Shell);
+ Builder.Add(Shell,FF);
+
+ // clear the maps from shapes added to previous Shell
+ TopTools_MapIteratorOfMapOfShape itEM (CheckedEdgesMap);
+ for (; itEM.More(); itEM.Next()) {
+ TopTools_ListOfShape& FL = myEFMap.ChangeFromKey( itEM.Key());
+ TopTools_ListIteratorOfListOfShape it (FL);
+ while ( it.More()) {
+ if (AddedFacesMap.Contains( it.Value()))
+ FL.Remove( it );
+ else
+ it.Next();
+ }
+ }
+ CheckedEdgesMap.Clear();
+
+
+ // loop on faces added to Shell; add their neighbor faces to Shell and so on
+ TopoDS_Iterator itAddedF (Shell);
+ for (; itAddedF.More(); itAddedF.Next())
+ {
+ const TopoDS_Face& F = TopoDS::Face (itAddedF.Value());
+
+ // loop on edges of F; find a good neighbor face of F by E
+ TopExp_Explorer EdgeExp(F, TopAbs_EDGE);
+ for (; EdgeExp.More(); EdgeExp.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge( EdgeExp.Current());
+ if (! CheckedEdgesMap.Add( E ))
+ continue;
+
+ // candidate faces list
+ const TopTools_ListOfShape& FL = myEFMap.ChangeFromKey(E);
+ if (FL.IsEmpty())
+ continue;
+ // select one of neighbors
+ TopoDS_Face SelF;
+ if (FL.Extent() == 2) {
+ if (! F.IsSame( FL.First() ))
+ SelF = TopoDS::Face( FL.First() );
+ else if (!F.IsSame( FL.Last() ))
+ SelF = TopoDS::Face( FL.Last() );
+ }
+ else {
+ // check if a face already added to Shell shares E
+ TopTools_ListIteratorOfListOfShape it (FL);
+ Standard_Boolean found = Standard_False;
+ for (; !found && it.More(); it.Next())
+ if (F != it.Value())
+ found = AddedFacesMap.Contains( it.Value() );
+ if (found)
+ continue;
+ // select basing on geometrical check
+ Standard_Boolean GoodOri, inside;
+ Standard_Real dot, MaxDot = -100;
+ TopTools_ListOfShape TangFL; // tangent faces
+ for ( it.Initialize( FL ) ; it.More(); it.Next()) {
+ const TopoDS_Face& NeighborF = TopoDS::Face( it.Value());
+ if (NeighborF.IsSame( F ))
+ continue;
+ inside = Partition_Loop3d::IsInside( E, F, NeighborF, 1, dot, GoodOri);
+ if (!GoodOri)
+ continue;
+ if (!inside)
+ dot = -dot - 3;
+ if (dot < MaxDot)
+ continue;
+ if ( IsEqual( dot, MaxDot))
+ TangFL.Append(SelF);
+ else
+ TangFL.Clear();
+ MaxDot = dot;
+ SelF = NeighborF;
+ }
+ if (!TangFL.IsEmpty()) {
+ for (it.Initialize( TangFL ); it.More(); it.Next()) {
+ const TopoDS_Face& NeighborF = TopoDS::Face( it.Value());
+ if (Partition_Loop3d:: IsInside( E, SelF , NeighborF, 0, dot, GoodOri))
+ SelF = NeighborF;
+ }
+ }
+ }
+ if (!SelF.IsNull() &&
+ AddedFacesMap.Add( SelF ) &&
+ !AvoidFacesMap.Contains( SelF ))
+ Builder.Add( Shell, SelF);
+
+ } // loop on edges of F
+
+ } // loop on the faces added to Shell
+
+ // Shell is complete
+ myNewShells.Append( Shell );
+
+ } // loop on myFaces
+
+
+ // prepare to the next call
+ myFaces.Clear();
+ myEFMap.Clear();
+
+ return myNewShells;
+}
+
+
+
+//=======================================================================
+//function : Normal
+//purpose :
+//=======================================================================
+
+gp_Vec Partition_Loop3d::Normal(const TopoDS_Edge& E,
+ const TopoDS_Face& F)
+{
+ gp_Vec Norm, V1, V2;
+ Standard_Real First, Last;
+ gp_Pnt Ps;
+
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last);
+ Handle(Geom_Surface) Sf = BRep_Tool::Surface(F);
+
+ gp_Pnt2d p = C2d->Value( 0.5*(First+Last) );
+ Sf->D1(p.X(), p.Y(), Ps, V1, V2);
+ Norm = V1.Crossed(V2);
+
+ if (F.Orientation() == TopAbs_REVERSED )
+ Norm.Reverse();
+
+ return Norm;
+}
+
+//=======================================================================
+//function : NextNormal
+//purpose : find normal to F at point a little inside F near the middle of E
+//warning : E must be properly oriented in F.
+//=======================================================================
+
+static gp_Vec NextNormal(const TopoDS_Edge& E,
+ const TopoDS_Face& F)
+{
+ Standard_Real First, Last;
+
+ Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface (E, F, First, Last);
+ Handle(Geom_Surface) Sf = BRep_Tool::Surface(F);
+
+ gp_Pnt2d p;
+ gp_Vec2d v;
+ C2d->D1( 0.5*(First+Last), p, v);
+ if (E.Orientation() != F.Orientation())
+ v.Reverse();
+ gp_Dir2d dir( -v.Y(), v.X() ); // dir inside F
+
+ Standard_Real duv = 1e-6; // this is not Ok and may give incorrect result if
+ // resolutionUV of compared faces is very different. To have a good result,
+ //it is necessary to get normal to faces at points equidistant from E in 3D
+
+ p.SetX( p.X() + dir.X()*duv );
+ p.SetY( p.Y() + dir.Y()*duv );
+
+ gp_Pnt Ps;
+ gp_Vec Norm, V1, V2, VV1, VV2;
+ Sf->D1( p.X(), p.Y(), Ps, V1, V2);
+ Norm = V1.Crossed(V2);
+
+ if (F.Orientation() == TopAbs_REVERSED )
+ Norm.Reverse();
+
+ return Norm;
+}
+
+
+//=======================================================================
+//function : FindEinF
+//purpose : find E in F
+//=======================================================================
+
+static TopoDS_Edge FindEinF(const TopoDS_Edge& E,
+ const TopoDS_Face& F)
+{
+ TopExp_Explorer expl (F, TopAbs_EDGE);
+ for (; expl.More(); expl.Next())
+ if( E.IsSame( expl.Current() ))
+ return TopoDS::Edge(expl.Current());
+ TopoDS_Edge nullE;
+ return nullE;
+}
+
+//=======================================================================
+//function : IsInside
+//purpose : check if <F2> is inside <F1> by edge <E>.
+// if <CountDot>, compute <Dot>: scalar production of
+// normalized vectors pointing inside faces, and
+// check if faces are oriented well for sewing
+//=======================================================================
+
+Standard_Boolean Partition_Loop3d::IsInside(const TopoDS_Edge& E,
+ const TopoDS_Face& F1,
+ const TopoDS_Face& F2,
+ const Standard_Boolean CountDot,
+ Standard_Real& Dot,
+ Standard_Boolean& GoodOri)
+{
+ Standard_Real f, l;
+ gp_Pnt P;
+ gp_Vec Vc1, Vc2, Vin1, Vin2, Nf1, Nf2;
+ Handle(Geom_Curve) Curve = BRep_Tool::Curve(E,f,l);
+ Curve->D1( 0.5*(f + l), P, Vc2);
+ TopoDS_Edge E1, E2 = FindEinF (E, F2);
+ if (E2.Orientation() == TopAbs_REVERSED ) Vc2.Reverse();
+
+ Nf1 = Normal(E,F1);
+ Nf2 = Normal(E,F2);
+
+ Standard_Real sin =
+ Nf1.CrossSquareMagnitude(Nf2) / Nf1.SquareMagnitude() / Nf2.SquareMagnitude();
+ Standard_Boolean tangent = sin < 0.001;
+
+ Standard_Boolean inside = 0;
+ if (tangent) {
+ E1 = FindEinF (E, F1);
+ gp_Vec NNf1 = NextNormal(E1,F1);
+ gp_Vec NNf2 = NextNormal(E2,F2);
+ Vin2 = NNf2.Crossed(Vc2);
+ inside = Vin2 * NNf1 < 0;
+ }
+ else {
+ Vin2 = Nf2.Crossed(Vc2);
+ inside = Vin2 * Nf1 < 0;
+ }
+
+ if (!CountDot) return inside;
+
+ if (tangent)
+ Vin2 = Nf2.Crossed(Vc2);
+ else
+ E1 = FindEinF (E, F1);
+
+ Vc1 = Vc2;
+ if (E1.Orientation() != E2.Orientation())
+ Vc1.Reverse();
+ Vin1 = Nf1.Crossed(Vc1);
+
+ if (tangent) {
+ Standard_Real N1N2 = Nf1 * Nf2;
+ GoodOri = (Vin2 * Vin1 < 0) ? N1N2 > 0 : N1N2 < 0;
+ }
+ else {
+ Standard_Real V1N2 = Vin1 * Nf2;
+ GoodOri = ( inside ? V1N2 <= 0 : V1N2 >= 0);
+ }
+
+ Vin1.Normalize();
+ Vin2.Normalize();
+
+ Dot = Vin2 * Vin1;
+
+ return inside;
+}
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop3d.hxx
+// Module : GEOM
+
+#ifndef _Partition_Loop3d_HeaderFile
+#define _Partition_Loop3d_HeaderFile
+
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+class TopoDS_Shape;
+class TopTools_ListOfShape;
+class TopTools_MapOfOrientedShape;
+class TopoDS_Edge;
+class TopoDS_Face;
+class gp_Vec;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Loop3d {
+
+public:
+
+ void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+ // Methods PUBLIC
+ //
+Standard_EXPORT Partition_Loop3d();
+Standard_EXPORT void AddConstFaces(const TopoDS_Shape& S) ;
+Standard_EXPORT void AddSectionFaces(const TopoDS_Shape& S) ;
+Standard_EXPORT const TopTools_ListOfShape& MakeShells(const TopTools_MapOfOrientedShape& AvoidFacesMap) ;
+Standard_EXPORT static Standard_Boolean IsInside(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const Standard_Boolean CountDot,Standard_Real& Dot,Standard_Boolean& GoodOri) ;
+Standard_EXPORT static gp_Vec Normal(const TopoDS_Edge& E,const TopoDS_Face& F) ;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+
+
+ // Fields PRIVATE
+ //
+TopTools_ListOfShape myNewShells;
+TopTools_ListOfShape myFaces;
+TopTools_IndexedDataMapOfShapeListOfShape myEFMap;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop3d.ixx
+// Module : GEOM
+
+#include "Partition_Loop3d.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : Partition_Loop3d.jxx
+// Module : GEOM
+
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_MapOfOrientedShape_HeaderFile
+#include <TopTools_MapOfOrientedShape.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _gp_Vec_HeaderFile
+#include <gp_Vec.hxx>
+#endif
+#ifndef _Partition_Loop3d_HeaderFile
+#include "Partition_Loop3d.hxx"
+#endif
--- /dev/null
+-- GEOM PARTITION : partition algorithm
+--
+-- 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 : Partition_Spliter.cdl
+-- Author : Benedicte MARTIN
+-- Module : GEOM
+
+class Spliter from Partition
+
+ ---Purpose: Split solids, shells and faces into parts of the
+ -- same topology if reconstruction level is not
+ -- limited.
+
+uses
+ Inter3d from Partition,
+ Loop2d from Partition,
+ Builder from BRep,
+ ShapeEnum from TopAbs,
+ Compound from TopoDS,
+ Face from TopoDS,
+ Edge from TopoDS,
+ Shape from TopoDS,
+ MapOfOrientedShape from TopTools,
+ IndexedMapOfShape from TopTools,
+ DataMapOfShapeShape from TopTools,
+ ListOfShape from TopTools,
+ MapOfShape from TopTools,
+ AsDes from BRepAlgo,
+ Image from BRepAlgo
+
+is
+ Create returns Spliter from Partition;
+ ---Purpose: constructor
+
+ AddShape ( me : in out; S : Shape from TopoDS);
+ ---Purpose: add object Shape to be splitted.
+ -- If S is a COMPOUND or COMPSOLID, it will be
+ -- exploded in order to get more simple object
+ -- shapes.
+ -- Object shapes that are vertices, edges or wires
+ -- won't be splitted and won't be in a result.
+
+ AddTool ( me : in out; S : Shape from TopoDS);
+ ---Purpose: add cutting tool
+
+ Compute (me : in out; Limit : ShapeEnum from TopAbs
+ = TopAbs_SHAPE);
+ ---Purpose: produce a result which is a compound of parts of
+ -- object shapes. A part can be either a vertex,
+ -- edge, wire, face, shell or solid.
+ -- By default, a part is of the same topology as an
+ -- object shape, else <Limit> restricts parts
+ -- reconstruction.
+ -- If <Limit> == TopAbs_VERTEX, only new vertices are
+ -- returned in the result
+
+ KeepShapesInside (me : in out; S : Shape from TopoDS);
+ ---Purpose: remove shapes that are outside of S from result.
+ -- S should be an object shape.
+ ---Warning: call it after Compute()
+
+ RemoveShapesInside (me : in out; S : Shape from TopoDS);
+ ---Purpose: remove shapes that are inside S from result.
+ -- S should be an object shape.
+ ---Warning: call it after Compute()
+
+ Shape ( me ) returns Shape from TopoDS;
+ ---Purpose: return resulting compound
+
+ Clear ( me : in out);
+ ---Purpose: clear fields
+
+
+ ---Category: private methods
+
+
+ MakeShells (me: in out; S : Shape from TopoDS;
+ NS: in out ListOfShape from TopTools) is private;
+ ---Purpose: split S into shells
+
+ MakeFaces (me: in out; S : Shape from TopoDS)
+ returns Shape from TopoDS is private;
+ ---Purpose: split faces of S, return compound of new faces
+
+ MakeEdges (me;
+ E : Edge from TopoDS;
+ VOnE : ListOfShape from TopTools;
+ NE : in out ListOfShape from TopTools)
+ is private;
+ ---Purpose: cut E by vertices VOnE, return list of new edges
+ -- NE
+
+ FindFacesInside (me: in out; S : Shape from TopoDS;
+ CheckClosed : Boolean = Standard_False;
+ All : Boolean = Standard_False)
+ returns Shape from TopoDS is private;
+ ---Purpose: return compound of faces of other shapes that are
+ -- inside <S>. <S> must have image in myImageShape.
+ -- <CheckClosed> makes avoid faces that do not form a
+ -- closed shell
+ -- <All> makes return already added faces
+
+ CheckTool ( me: in out; S : Shape from TopoDS)
+ returns Boolean from Standard is private;
+ ---Purpose: Return True if <S> is a tool shape. Prepare tool
+ -- faces of <S> for the search of internal faces.
+
+ MergeEqualEdges (me: in out; LE : ListOfShape from TopTools) is private;
+ ---Purpose: among LE, find equal edges, choose ones to keep
+ -- and make them have pcurves on all faces they are
+ -- shared by
+ -- <LE> contains edge splits
+
+fields
+
+ myDoneStep : ShapeEnum from TopAbs; -- reconstructed topology
+ myShape : Compound from TopoDS; -- result
+ myBuilder : Builder from BRep;
+
+ myListShapes : ListOfShape from TopTools; -- object shapes
+ myMapFaces : MapOfShape from TopTools; -- object faces
+ myMapTools : MapOfShape from TopTools; -- tool faces
+ myFaceShapeMap : DataMapOfShapeShape from TopTools; -- to find a shape by face
+
+ myNewSection : MapOfShape from TopTools; -- new secton edges
+
+ myAsDes : AsDes from BRepAlgo;
+ myImagesFaces : Image from BRepAlgo;
+ myImagesEdges : Image from BRepAlgo;
+ myImageShape : Image from BRepAlgo;
+
+ -- contains info of same domain shapes and section edges
+ myInter3d : Inter3d from Partition;
+
+ -- avoid rebuilding twice commont part of solids
+ myAddedFacesMap: MapOfOrientedShape from TopTools;
+
+ -- equal splits
+ myEqualEdges : MapOfShape from TopTools;
+
+ -- shape and its internal faces
+ myInternalFaces: DataMapOfShapeShape from TopTools;
+ myIntNotClFaces: DataMapOfShapeShape from TopTools;-- internal but not closed
+
+end Spliter;
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Spliter.cxx
+// Author : Benedicte MARTIN
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "Partition_Spliter.ixx"
+#include "Partition_Inter2d.hxx"
+#include "Partition_Inter3d.hxx"
+#include "Partition_Loop2d.hxx"
+#include "Partition_Loop3d.hxx"
+
+#include "utilities.h"
+
+#include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
+#include <Precision.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepLib.hxx>
+#include <BRepBndLib.hxx>
+
+#include <stdio.h>
+#include <Extrema_ExtPC.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <TopOpeBRepTool_CurveTool.hxx>
+
+#ifdef DEB
+#define DRAW 0
+#endif
+
+#ifdef DRAW
+#include <DBRep.hxx>
+Standard_IMPORT Standard_Boolean AffichInter3d ;
+Standard_IMPORT Standard_Boolean AffichInter2d ;
+Standard_IMPORT Standard_Boolean AffichVertex;
+Standard_IMPORT Standard_Boolean AffichFace;
+Standard_IMPORT Standard_Boolean AffichWire;
+Standard_IMPORT Standard_Boolean SelectFace;
+
+static char* names = new char[100];
+
+#endif
+
+//=======================================================================
+//function : Partition_Spliter
+//purpose : constructor
+//=======================================================================
+
+Partition_Spliter::Partition_Spliter()
+{
+ myAsDes = new BRepAlgo_AsDes;
+ Clear();
+}
+
+//=======================================================================
+//function : AddTool
+//purpose : add cutting tool that will _NOT_ be in result
+//=======================================================================
+
+void Partition_Spliter::AddTool(const TopoDS_Shape& S)
+{
+ for (TopExp_Explorer exp(S,TopAbs_FACE); exp.More(); exp.Next())
+ myMapTools.Add(exp.Current());
+}
+
+//=======================================================================
+//function : AddShape
+//purpose : add object Shape to be splited
+//=======================================================================
+
+void Partition_Spliter::AddShape(const TopoDS_Shape& S)
+{
+ if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid
+ TopoDS_Iterator it (S);
+ for (; it.More(); it.Next())
+ AddShape( it.Value());
+ return;
+ }
+
+ TopExp_Explorer exp(S,TopAbs_FACE);
+ if (!exp.More()) { // do not split edges and vertices
+ //myBuilder.Add( myShape, S );
+ return;
+ }
+
+ myListShapes.Append(S);
+
+ for (; exp.More(); exp.Next()) {
+ myFaceShapeMap.Bind( exp.Current(), S );
+ myMapFaces.Add(exp.Current());
+ myImagesFaces.SetRoot(exp.Current());
+ }
+}
+
+//=======================================================================
+//function : Shape
+//purpose : return resulting compound
+//=======================================================================
+
+TopoDS_Shape Partition_Spliter::Shape() const
+{
+ return myShape;
+}
+
+//=======================================================================
+//function : Clear
+//purpose : clear fields
+//=======================================================================
+
+void Partition_Spliter::Clear()
+{
+ myDoneStep = TopAbs_SHAPE;
+
+ myListShapes.Clear();
+ myMapFaces.Clear();
+ myMapTools.Clear();
+ myFaceShapeMap.Clear();
+
+ myNewSection.Clear();
+
+ myAsDes->Clear();
+ myImagesFaces.Clear();
+ myImagesEdges.Clear();
+ myImageShape.Clear();
+
+ myInter3d = Partition_Inter3d(myAsDes);
+
+ myAddedFacesMap.Clear();
+
+ myInternalFaces.Clear();
+}
+
+//=======================================================================
+//function : Compute
+//purpose : produce a result
+//=======================================================================
+
+void Partition_Spliter::Compute(const TopAbs_ShapeEnum Limit)
+{
+ if ((Limit != TopAbs_SHAPE && myDoneStep == Limit) ||
+ (Limit == TopAbs_SHAPE && myDoneStep == TopAbs_SOLID))
+ return;
+
+ myBuilder.MakeCompound( myShape );
+
+ TopTools_MapIteratorOfMapOfShape it;
+ TopTools_ListIteratorOfListOfShape itl;
+ TopExp_Explorer exp;
+
+ if (myDoneStep > TopAbs_VERTEX) {
+
+ TopTools_ListOfShape aListFaces;
+ aListFaces = myImagesFaces.Roots();
+ for (it.Initialize(myMapTools); it.More(); it.Next())
+ aListFaces.Append(it.Key());
+
+ //-----------------------------------------------
+ // Intersection between faces
+ //-----------------------------------------------
+ // result is in myAsDes as a map Face - list of new edges;
+ // special care is done for section edges, same domain faces and vertices:
+ // data about them is inside myInter3d
+
+ myInter3d.CompletPart3d(aListFaces, myFaceShapeMap);
+
+ TopTools_MapOfShape& Modif = myInter3d.TouchedFaces();
+ TopTools_MapOfShape& NewEdges = myInter3d.NewEdges();
+ Handle(BRepAlgo_AsDes) SectionEdgesAD = myInter3d.SectionEdgesAD();
+
+#ifdef DRAW
+ if (AffichInter3d) {
+ Standard_Integer i=0;
+ for (it.Initialize(NewEdges); it.More(); it.Next(), i++) {
+ sprintf(names,"e_%d",i);
+ cout << "donly " << names << endl;
+ DBRep::Set(names,it.Key());
+ }
+ }
+#endif
+ //if (Modif.IsEmpty()) return;
+
+ // -----------------------------------------------
+ // store tools intersecting solids as object shapes,
+ // they must split into faces too
+ // -----------------------------------------------
+
+ // build edge - face map for tool faces
+ TopTools_IndexedDataMapOfShapeListOfShape EFM;
+ for (it.Initialize(myMapTools); it.More(); it.Next())
+ TopExp::MapShapesAndAncestors( it.Key(), TopAbs_EDGE, TopAbs_FACE, EFM);
+
+ TopTools_MapOfShape checkedEdgeMap;
+ for (itl.Initialize( myListShapes ); itl.More(); itl.Next()) {
+ TopExp_Explorer expSo (itl.Value(), TopAbs_SOLID);
+ for (; expSo.More(); expSo.Next()) {
+
+ TopTools_ListOfShape checkFL; // faces to check
+ for ( exp.Init( expSo.Current(), TopAbs_FACE); exp.More(); exp.Next())
+ checkFL.Append ( exp.Current());
+
+ // iterate a list while appending new items
+ TopTools_ListIteratorOfListOfShape itF, itCF;
+ for (itCF.Initialize (checkFL) ; itCF.More(); itCF.Next()) {
+ const TopoDS_Shape& F = itCF.Value();
+ if ( myAsDes->HasDescendant( F )) {
+ // new edges on face to check
+ const TopTools_ListOfShape& NEL = myAsDes->Descendant( F );
+ TopTools_ListIteratorOfListOfShape itE (NEL);
+ for (; itE.More(); itE.Next()) {
+ if (checkedEdgeMap.Add( itE.Value() )) {
+ // intersected faces originating an edge
+ itF.Initialize (myAsDes->Ascendant( itE.Value() ));
+ for (; itF.More(); itF.Next()) {
+ if (!myMapFaces.Contains( itF.Value())) {
+ AddShape( itF.Value() );
+ checkFL.Append( itF.Value() );
+ }
+ }
+ // faces having section edges on F
+ if (EFM.Contains( itE.Value()))
+ itF.Initialize ( EFM.FindFromKey (itE.Value()));
+ for (; itF.More(); itF.Next()) {
+ if (!myMapFaces.Contains( itF.Value())) {
+ AddShape( itF.Value() );
+ checkFL.Append( itF.Value() );
+ }
+ }
+ }
+ }
+ }
+ // find faces cut by edges of F
+ TopExp_Explorer expE(F, TopAbs_EDGE);
+ for (; expE.More();expE.Next()) {
+ if ( SectionEdgesAD->HasAscendant( expE.Current() )
+ && checkedEdgeMap.Add( expE.Current() )) {
+ itF.Initialize( SectionEdgesAD->Ascendant( expE.Current()) );
+ for (; itF.More(); itF.Next()) {
+ if (!myMapFaces.Contains( itF.Value())) {
+ AddShape( itF.Value() );
+ checkFL.Append( itF.Value() );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------
+ // Intersection of edges
+ //-----------------------------------------------
+
+ // add existing vertices to edges of object faces in myAsDes
+ TopTools_MapOfShape DoneEM;
+ for ( it.Initialize(myMapFaces); it.More(); it.Next()) {
+ const TopoDS_Shape& F = it.Key();
+ TopoDS_Face FForward = TopoDS::Face(F.Oriented(TopAbs_FORWARD));
+ for (exp.Init(FForward,TopAbs_EDGE); exp.More(); exp.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge( exp.Current() );
+ myAsDes->Add(FForward,E);
+ if (DoneEM.Add(E)) {
+ TopoDS_Iterator itV(E);
+ for (; itV.More(); itV.Next()) {
+ const TopoDS_Vertex& V = TopoDS::Vertex( itV.Value());
+ myAsDes->Add(E, myInter3d.ReplaceSameDomainV( V, E ));
+ }
+ }
+ }
+ }
+
+ // intersect edges that are descendants of a face in myAsDes
+ for ( it.Initialize(Modif); it.More(); it.Next()) {
+ const TopoDS_Face& F = TopoDS::Face(it.Key());
+ Partition_Inter2d::CompletPart2d (myAsDes, F, NewEdges);
+ }
+ // now myAsDes contains also new vertices made at edge intersection as
+ // descendant of edges both new and old
+
+ myDoneStep = TopAbs_VERTEX;
+
+ } // if (myDoneStep > TopAbs_VERTEX)
+
+ if (Limit == TopAbs_VERTEX) {
+ // add new vertices to myShape
+ for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) {
+ if (! myAsDes->HasDescendant( it.Key() ))
+ continue;
+ itl.Initialize( myAsDes->Descendant( it.Key() ));
+ for (; itl.More(); itl.Next())
+ myBuilder.Add ( myShape, itl.Value() );
+ }
+ return;
+ }
+
+ if (myDoneStep > TopAbs_EDGE) {
+
+ //-----------------------------------------------
+ // Reconstruction of all the edges.
+ //-----------------------------------------------
+
+ // Add to myAsDes end vertices of new edges and cut new edges
+ int j=1;
+ TopTools_MapOfShape& NewEdges = myInter3d.NewEdges();
+ TopTools_ListOfShape LSE; // all edge splits
+ for ( it.Initialize(NewEdges); it.More(); it.Next()) {
+
+ TopoDS_Vertex V1,V2;
+ TopoDS_Edge EE = TopoDS::Edge(it.Key());
+
+ TopTools_ListOfShape aListV, aListF;
+ aListV = myAsDes->Descendant(EE); // intersection vertices
+ aListF = myAsDes->Ascendant(EE); // intersected faces
+
+ if (aListV.IsEmpty())
+ continue; // new edge does not intersect any other edge
+
+ // one face is Tool, the other is Shape:
+ if ( (myMapTools.Contains(aListF.First()) && myMapFaces.Contains(aListF.Last()) ) ||
+ ( myMapFaces.Contains(aListF.First()) && myMapTools.Contains(aListF.Last()) ) )
+ {
+ TopExp::Vertices(EE,V1,V2);
+ Standard_Real Tol = Max (BRep_Tool::Tolerance( V1 ),
+ BRep_Tool::Tolerance( V2 ));
+
+ gp_Pnt P1 = BRep_Tool::Pnt(V1);
+ gp_Pnt P2 = BRep_Tool::Pnt(V2);
+ Standard_Boolean AddV1 = Standard_True;
+ Standard_Boolean AddV2 = Standard_True;
+
+ // add only if there is no intersection at end vertex
+ for (itl.Initialize(aListV); itl.More(); itl.Next()) {
+ const TopoDS_Vertex& Ve = TopoDS::Vertex(itl.Value()) ;
+ Standard_Real Tol2 = Max ( Tol, BRep_Tool::Tolerance( Ve ));
+ Tol2 *= Tol2;
+ gp_Pnt P = BRep_Tool::Pnt(Ve);
+ if (AddV1 && P.SquareDistance(P1) <= Tol2)
+ AddV1 = Standard_False;
+
+ if (AddV2 && P.SquareDistance(P2) <= Tol2)
+ AddV2 = Standard_False;
+ }
+
+ if (AddV1) {
+ aListV.Append(V1);
+ myAsDes->Add(EE,V1);
+ }
+
+ if (AddV2) {
+ aListV.Append(V2);
+ myAsDes->Add(EE,V2);
+ }
+ }
+#ifdef DRAW
+ if (AffichVertex) {
+ for(itl.Initialize(aListV);itl.More();itl.Next(), j++) {
+ sprintf(names,"v_%d",j);
+ cout << "donly " << names << endl;
+ DBRep::Set(names,itl.Value());
+ }
+ }
+#endif
+
+ Standard_Integer NbV=aListV.Extent() ;
+ if (NbV>1 || (NbV==1 && V1.IsSame(V2)) ) {
+ // cut new edges
+ TopTools_ListOfShape LNE;
+ MakeEdges (EE,aListV, LNE);
+ myImagesEdges.Bind(EE,LNE);
+ LSE.Append( LNE );
+ }
+ }
+
+ // cut old edges
+ for ( it.Initialize(myMapFaces); it.More(); it.Next()) {
+ for (exp.Init( it.Key(), TopAbs_EDGE); exp.More(); exp.Next()) {
+ const TopoDS_Edge& EE = TopoDS::Edge( exp.Current() );
+ if ( myImagesEdges.HasImage( EE ))
+ continue;
+ TopTools_ListOfShape LNE;
+ const TopTools_ListOfShape& aListVV = myAsDes->Descendant(EE);
+ MakeEdges (EE, aListVV, LNE);
+ myImagesEdges.Bind(EE,LNE);
+ LSE.Append( LNE );
+ }
+ }
+
+ MergeEqualEdges( LSE );
+
+ myDoneStep = TopAbs_EDGE;
+
+ } // if (myDoneStep > TopAbs_EDGE)
+
+ if (Limit == TopAbs_EDGE) {
+ // add splits of old edges
+ TopTools_ListIteratorOfListOfShape itNE;
+ for (itl.Initialize( myListShapes );itl.More();itl.Next()) {
+ for ( exp.Init( itl.Value(), TopAbs_EDGE ); exp.More(); exp.Next()) {
+ itNE.Initialize( myImagesEdges.Image( exp.Current() ));
+ for ( ; itNE.More(); itNE.Next())
+ myBuilder.Add ( myShape, itNE.Value() );
+ }
+ }
+ // add splits of new edges
+ for ( it.Initialize( myInter3d.NewEdges() ); it.More(); it.Next()) {
+ itNE.Initialize( myImagesEdges.Image( it.Key() ));
+ for (; itNE.More(); itNE.Next())
+ myBuilder.Add ( myShape, itNE.Value() );
+ }
+ return;
+ }
+
+ // make faces interfering by section edges share the same splits
+ //ProcessSectionEdges( SectionEdgesAD );
+
+
+ //-----------------------------------------------
+ // split faces
+ //-----------------------------------------------
+
+ if (myDoneStep > TopAbs_FACE) {
+
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ TopoDS_Shape FacesComp = MakeFaces ( itl.Value());
+ // there is a cunning here: myImagesFaces keeps faces made by Loop2d
+ // but some of them may be replaced with splits of same domain face
+ // and myImageShape keeps ultimate result
+ myImageShape.Bind( itl.Value(), FacesComp );
+ }
+
+ myDoneStep = TopAbs_FACE;
+ }
+
+ if (Limit == TopAbs_WIRE ||
+ Limit == TopAbs_FACE) {
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ if ( myMapTools.Contains( itl.Value() ))
+ continue; // no result needed for a tool face
+ const TopoDS_Shape& FacesComp = myImageShape.Image( itl.Value() ).First();
+ for ( exp.Init( FacesComp, Limit); exp.More(); exp.Next())
+ myBuilder.Add ( myShape, exp.Current());
+ }
+ return;
+ }
+
+
+ //-----------------------------------------------
+ // split solids
+ //-----------------------------------------------
+
+ // solids must remains closed, so process them first
+ Standard_Boolean makeSolids = (Limit == TopAbs_SHAPE ||
+ Limit < TopAbs_SHELL);
+
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ if (itl.Value().ShapeType() == TopAbs_SOLID) {
+ TopTools_ListOfShape NSL;
+ MakeShells (itl.Value() , NSL);
+ TopTools_ListIteratorOfListOfShape itS(NSL);
+ for ( ; itS.More(); itS.Next())
+ if (makeSolids) {
+ // make a solid from a shell
+ TopoDS_Solid Solid;
+ myBuilder.MakeSolid( Solid );
+ myBuilder.Add (Solid, itS.Value());
+ myBuilder.Add (myShape, Solid);
+ }
+ else
+ myBuilder.Add (myShape, itS.Value());
+ }
+ }
+
+ //-----------------------------------------------
+ // split shells
+ //-----------------------------------------------
+
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ if (itl.Value().ShapeType() == TopAbs_SHELL) {
+ TopTools_ListOfShape NSL;
+ MakeShells (itl.Value() , NSL);
+ TopTools_ListIteratorOfListOfShape itS(NSL);
+ for ( ; itS.More(); itS.Next())
+ myBuilder.Add (myShape, itS.Value());
+ }
+ }
+
+ //-----------------------------------------------
+ // add split faces
+ //-----------------------------------------------
+
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ const TopoDS_Shape& S = itl.Value();
+ if (S.ShapeType() != TopAbs_FACE ||
+ myMapTools.Contains( S ))
+ continue;
+ TopoDS_Iterator itS( myImageShape.Image(S).First() );
+ for (; itS.More(); itS.Next())
+ if (! myAddedFacesMap.Contains( itS.Value() ))
+ myBuilder.Add (myShape, itS.Value());
+ }
+
+ myDoneStep = makeSolids ? TopAbs_SOLID : TopAbs_SHELL;
+
+}
+
+
+//=======================================================================
+//function : Tri
+//purpose :
+//=======================================================================
+
+static void Tri(const TopoDS_Edge& E,
+ TopTools_SequenceOfShape& Seq)
+{
+ Standard_Boolean Invert = Standard_True;
+ Standard_Integer NbPoints = Seq.Length();
+ Standard_Real U1,U2;
+ TopoDS_Vertex V1,V2;
+
+ while (Invert) {
+ Invert = Standard_False;
+ for ( Standard_Integer i = 1; i < Seq.Length(); i++) {
+
+ V1 = TopoDS::Vertex(Seq.Value(i));
+ V2 = TopoDS::Vertex(Seq.Value(i+1));
+
+ V1.Orientation(TopAbs_INTERNAL);
+ V2.Orientation(TopAbs_INTERNAL);
+
+ U1 = BRep_Tool::Parameter(V1,E);
+ U2 = BRep_Tool::Parameter(V2,E);
+
+ if (IsEqual(U1,U2)) {
+ Seq.Remove(i);
+ i--;
+ continue;
+ }
+ if (U2 < U1) {
+ Seq.Exchange(i,i+1);
+ Invert = Standard_True;
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : MakeEdges
+//purpose : cut E by vertices VOnE, return list of new edges NE
+//=======================================================================
+
+void Partition_Spliter::MakeEdges (const TopoDS_Edge& E,
+ const TopTools_ListOfShape& VOnE,
+ TopTools_ListOfShape& NE ) const
+{
+ TopoDS_Edge WE = E;
+ WE.Orientation(TopAbs_FORWARD);
+
+ TopTools_ListIteratorOfListOfShape itv(VOnE);
+ TopTools_SequenceOfShape SV;
+
+ Standard_Real U1,U2, f, l;
+ TopoDS_Vertex V1,V2,VF,VL;
+
+ BRep_Tool::Range(WE,f,l);
+ TopExp::Vertices(WE,VF,VL);
+
+ if (VOnE.Extent() < 3) { // do not rebuild not cut edge
+ if (( VF.IsSame( VOnE.First() ) && VL.IsSame( VOnE.Last() )) ||
+ VL.IsSame( VOnE.First() ) && VF.IsSame( VOnE.Last() ) ) {
+ NE.Append( E );
+ return;
+ }
+ }
+
+ for (; itv.More(); itv.Next())
+ SV.Append(itv.Value());
+
+ Tri( WE, SV);
+
+ Standard_Integer iVer, NbVer = SV.Length();
+
+
+ //----------------------------------------------------------------
+ // Construction of the new edges .
+ //----------------------------------------------------------------
+
+ if (VF.IsSame(VL)) { // closed edge
+ if (NbVer==1)
+ SV.Append( SV.First() );
+ else if (!SV.First().IsSame(SV.Last())) {
+ Standard_Boolean isFirst=0;
+ Standard_Real minDU = 1.e10;
+ TopoDS_Vertex endV = Partition_Inter2d::FindEndVertex(VOnE, f,l, E, isFirst,minDU);
+ if (endV.IsSame(SV.First()))
+ SV.Append(endV);
+ else if (endV.IsSame(SV.Last()))
+ SV.Prepend(endV);
+ else
+ MESSAGE ("END VERTEX IS IN SEQUNCE MIDDLE");
+ }
+ NbVer = SV.Length();
+ }
+
+ for (iVer=1; iVer < NbVer; iVer++) {
+ V1 = TopoDS::Vertex(SV(iVer));
+ V2 = TopoDS::Vertex(SV(iVer+1));
+
+ TopoDS_Shape NewEdge = WE.EmptyCopied();
+ V1.Orientation(TopAbs_FORWARD);
+ myBuilder.Add (NewEdge,V1);
+ V2.Orientation(TopAbs_REVERSED);
+ myBuilder.Add (NewEdge,V2);
+
+ if (iVer==1)
+ U1 = f;
+ else {
+ V1.Orientation(TopAbs_INTERNAL);
+ U1=BRep_Tool::Parameter(V1,WE);
+ }
+ if (iVer+1 == NbVer)
+ U2 = l;
+ else {
+ V2.Orientation(TopAbs_INTERNAL);
+ U2=BRep_Tool::Parameter(V2,WE);
+ }
+ if (Abs(U1-U2) <= Precision::PConfusion()) {
+ MESSAGE( "MakeEdges(), EQUAL PARAMETERS OF DIFFERENT VERTICES");
+ continue;
+ }
+ TopoDS_Edge EE=TopoDS::Edge(NewEdge);
+ myBuilder.Range (EE,U1,U2);
+
+ TopoDS_Edge NEdge = TopoDS::Edge(NewEdge);
+ myBuilder.SameParameter(NEdge,Standard_False);
+
+ Standard_Real tol = 1.0e-2;
+ Standard_Boolean flag = BRep_Tool::SameParameter(NEdge);
+ if (!flag) {
+ BRepLib::SameParameter(NEdge,tol);
+ }
+ NE.Append(NEdge.Oriented(E.Orientation()));
+ }
+}
+
+//=======================================================================
+//function : FindFacesInside
+//purpose : return compound of faces of other shapes that are
+// inside <theShape>.
+// <theShape> is an object shape.
+// <CheckClosed> makes avoid faces that do not form a
+// closed shell
+// <All> makes return already added faces
+//=======================================================================
+
+TopoDS_Shape Partition_Spliter::FindFacesInside(const TopoDS_Shape& theShape,
+ const Standard_Boolean CheckClosed,
+ const Standard_Boolean All)
+{
+ TopExp_Explorer expl;
+ if (myInternalFaces.IsBound( theShape ))
+ {
+ TopoDS_Shape aIntFComp = myInternalFaces.Find ( theShape );
+ TopoDS_Shape aIntRemFComp = myIntNotClFaces.Find ( theShape );
+
+ expl.Init( aIntRemFComp, TopAbs_FACE);
+ if (CheckClosed || !expl.More())
+ return aIntFComp;
+
+ TopoDS_Compound C;
+ myBuilder.MakeCompound( C );
+ // add removed faces
+ for (; expl.More(); expl.Next())
+ myBuilder.Add( C, expl.Current() );
+ // add good internal faces
+ for (expl.Init( aIntFComp, TopAbs_FACE); expl.More(); expl.Next())
+ myBuilder.Add( C, expl.Current() );
+ return C;
+ }
+
+ // compound of split faces of theShape
+ const TopoDS_Shape& CSF = myImageShape.Image(theShape).First();
+
+ TopTools_MapOfShape MSE, MFP;
+ TopTools_DataMapOfShapeListOfShape DMSEFP;
+ TopTools_MapIteratorOfMapOfShape itm;
+ TopTools_ListOfShape EmptyL;
+
+ // MSE filling: map of new section edges of CSF
+ for (expl.Init(CSF,TopAbs_EDGE); expl.More(); expl.Next()) {
+ TopoDS_Shape resE = expl.Current() ;
+ if (myNewSection.Contains( resE )) // only new edges
+ MSE.Add(resE);
+ }
+
+ // DMEF: map edge of CSF - faces of CSF
+ TopTools_IndexedDataMapOfShapeListOfShape DMEF;
+ TopExp::MapShapesAndAncestors(CSF, TopAbs_EDGE, TopAbs_FACE, DMEF);
+
+ // Fill
+ // 1. MFP - a map of faces to process: map of resulting faces except
+ // those of theShape; we`ll add to C those of them which are inside CSF
+ // 2. DMSEFP - edge of MSE => faces of MFP
+ TopTools_ListIteratorOfListOfShape itl;
+ for (itl.Initialize(myListShapes);itl.More();itl.Next()) {
+ const TopoDS_Shape& aShape = itl.Value();
+ if ( theShape.IsSame( aShape )) continue;
+ // fill maps
+ // iterate on split faces of aShape
+ TopoDS_Iterator itF ( myImageShape.Image(aShape).First() );
+ for ( ; itF.More(); itF.Next()) {
+ const TopoDS_Shape& sf = itF.Value();
+ MFP.Add(sf);
+ // iterate on edges of split faces of aShape,
+ // add to DMSEFP edges that are new
+ for (expl.Init( sf, TopAbs_EDGE ); expl.More(); expl.Next()) {
+ TopoDS_Shape se = expl.Current();
+ if ( MSE.Contains(se)) {// section edge
+ if (!DMSEFP.IsBound(se))
+ DMSEFP.Bind(se,EmptyL);
+ DMSEFP(se).Append(sf);
+ }
+ }
+ }
+ }
+
+ // find faces inside theShape
+
+ Standard_Boolean skipAlreadyAdded = Standard_False;
+ Standard_Boolean GoodOri, inside;
+ Standard_Real dot;
+ TopTools_ListOfShape KeepFaces;
+ TopTools_DataMapIteratorOfDataMapOfShapeListOfShape Mapit;
+
+ // iterate on section edges, check faces of other shapes
+ // sharing section edges and put internal faces to KeepFaces
+ for (Mapit.Initialize(DMSEFP); Mapit.More() ; Mapit.Next() ) {
+ // a new edge of theShape
+ const TopoDS_Edge& E = TopoDS::Edge (Mapit.Key());
+ // an original edge of which E is a split
+ const TopoDS_Edge& OrigE = TopoDS::Edge ( myImagesEdges.Root( E ));
+ // is OrigE itself splits a face
+ Standard_Boolean isSectionE = myInter3d.IsSectionEdge ( OrigE );
+
+ // split faces of other shapes sharing E
+ TopTools_ListOfShape& LSF = DMSEFP.ChangeFind(E);
+ itl.Initialize( LSF );
+ while (itl.More()) {
+ // a split faces of other shape
+ TopoDS_Face aFace1 = TopoDS::Face(itl.Value());
+ // remove aFace1 form DMSEFP and MFP
+ LSF.Remove( itl ); // == itl.Next();
+ if (!MFP.Remove( aFace1 ))
+ continue; // was not is MFP ( i.e already checked)
+ // check if aFace1 was already added to 2 shells
+ if (!All &&
+ myAddedFacesMap.Contains( aFace1 ) &&
+ myAddedFacesMap.Contains( aFace1.Reversed() )) {
+ skipAlreadyAdded = Standard_True;
+ continue;
+ }
+
+ // find another face which originates from the same face as aFace1:
+ // usually aFace2 is internal if aFace1 is not and vice versa
+
+ const TopoDS_Shape& anOrigFace = myImagesFaces.Root(aFace1);
+ TopoDS_Shape aFace2;
+ if ( !isSectionE ) {
+ while (itl.More()) {
+ aFace2 = itl.Value();
+ if (!MFP.Contains( aFace2 )) {
+ LSF.Remove( itl );
+ continue;
+ }
+ if (anOrigFace.IsSame( myImagesFaces.Root( aFace2 )))
+ break;
+ itl.Next();
+ }
+ if (itl.More()) { // aFace2 found, remove it from maps
+ LSF.Remove( itl );
+ MFP.Remove(aFace2);
+ }
+ else
+ aFace2.Nullify();
+ itl.Initialize( LSF );
+ }
+
+ // check that anOrigFace is not same domain with CSF faces it intersects
+
+ const TopTools_ListOfShape& FL = DMEF.FindFromKey(E); //faces of CSF sharing E
+ const TopoDS_Shape& origF1 = myImagesFaces.Root(FL.First());
+ const TopoDS_Shape& origF2 = myImagesFaces.Root(FL.Last());
+ Standard_Boolean sameDom1 = anOrigFace.IsSame( origF1 );
+ Standard_Boolean sameDom2 = anOrigFace.IsSame( origF2 );
+ if (!(sameDom1 || sameDom2) && myInter3d.HasSameDomainF( anOrigFace )) {
+ sameDom1 = myInter3d.IsSameDomainF( anOrigFace, origF1);
+ if (origF1 == origF2)
+ sameDom2 = sameDom1;
+ else
+ myInter3d.IsSameDomainF( anOrigFace, origF2);
+ }
+ if (sameDom1 && sameDom2)
+ continue;
+ if ((sameDom1 || sameDom2)) {
+ inside = Partition_Loop3d::IsInside (E,
+ TopoDS::Face(FL.First()),
+ TopoDS::Face(FL.Last()),
+ 1, dot, GoodOri);
+ if (inside || (dot + Precision::Angular() >= 1.0))
+ continue; // E is convex between origF1 and origF2 or they are tangent
+ }
+
+
+ // keep one of found faces
+
+ //face of CSF sharing E
+ const TopoDS_Shape& aShapeFace = sameDom1 ? FL.Last() : FL.First();
+ // analyse aFace1 state
+ inside = Partition_Loop3d::IsInside (E, TopoDS::Face(aShapeFace), aFace1,
+ 1, dot, GoodOri);
+ // store internal face
+ if (inside)
+ KeepFaces.Append(aFace1);
+ else if (!aFace2.IsNull())
+ {
+ if (dot + Precision::Angular() >= 1.0)
+ {
+ // aFace2 state is not clear, it will be analysed alone,
+ // put it back to the maps
+ MFP.Add( aFace2 );
+ LSF.Append( aFace2 );
+ }
+ else
+ KeepFaces.Append(aFace2);
+ }
+ }
+ }
+
+ // add not distributed faces connected with KeepFaces
+
+ // ultimate list of internal faces
+ TopTools_ListOfShape KeptFaces;
+
+ // add to MFP not split tool faces as well, they may be connected with
+ // tool faces interfering with theShape
+ for ( itm.Initialize(myMapTools); itm.More(); itm.Next() ) {
+ const TopoDS_Shape& aToolFace = itm.Key();
+ if (!myImageShape.HasImage(aToolFace))
+ MFP.Add (aToolFace);
+ }
+
+ if (MFP.IsEmpty())
+ KeptFaces.Append (KeepFaces);
+
+ while (!KeepFaces.IsEmpty())
+ {
+ // KeepEdges : map of edges of faces kept last time
+ TopTools_IndexedMapOfShape KeepEdges;
+ for ( itl.Initialize(KeepFaces); itl.More(); itl.Next() ) {
+ TopExp::MapShapes( itl.Value(), TopAbs_EDGE, KeepEdges);
+ KeptFaces.Append( itl.Value() );
+ }
+
+ KeepFaces.Clear();
+
+ // keep faces connected with already kept faces by KeepEdges
+ for ( itm.Initialize(MFP); itm.More(); itm.Next() ) {
+ const TopoDS_Shape& FP = itm.Key();
+ for (expl.Init(FP,TopAbs_EDGE); expl.More(); expl.Next()) {
+ const TopoDS_Shape& se = expl.Current();
+ if (!MSE.Contains(se) && KeepEdges.Contains(se) ) {
+ KeepFaces.Append(FP);
+ MFP.Remove(FP);
+ break;
+ }
+ }
+ }
+ }
+
+ // check if kept faces form a shell without free edges
+
+ DMEF.Clear(); // edge - kept faces
+ MFP.Clear(); // wrong faces
+ if (CheckClosed) {
+ for (itl.Initialize(KeptFaces); itl.More(); itl.Next() )
+ TopExp::MapShapesAndAncestors(itl.Value(), TopAbs_EDGE, TopAbs_FACE, DMEF);
+
+ Standard_Integer i, nb = DMEF.Extent();
+ Standard_Boolean isClosed = Standard_False;
+ while (!isClosed) {
+ isClosed = Standard_True;
+ for (i=1; isClosed && i<=nb; ++i) {
+ const TopoDS_Shape& E = DMEF.FindKey( i );
+ if (! MSE.Contains( E ))
+ isClosed = ( DMEF(i).Extent() != 1 );
+ }
+ if (!isClosed) {
+ const TopoDS_Shape& F = DMEF.FindFromIndex( i-1 ).First(); // bad face
+ MFP.Add( F );
+ // remove bad face from DMEF
+ for (expl.Init( F, TopAbs_EDGE); expl.More(); expl.Next()) {
+ const TopoDS_Shape& E = expl.Current();
+ TopTools_ListOfShape& FL = DMEF.ChangeFromKey( E );
+ for (itl.Initialize( FL ); itl.More(); itl.Next() ) {
+ if ( F.IsSame( itl.Value() )) {
+ FL.Remove( itl );
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // a result compound
+ TopoDS_Compound C;
+ // compound of removed internal faces
+ TopoDS_Compound CNotCl;
+
+ myBuilder.MakeCompound(C);
+ myBuilder.MakeCompound(CNotCl);
+
+ // add to compounds
+ for (itl.Initialize(KeptFaces); itl.More(); itl.Next() )
+ {
+ TopoDS_Shape & aIntFace = itl.Value();
+ if (! MFP.Contains( aIntFace ))
+ myBuilder.Add( C, aIntFace);
+ else
+ myBuilder.Add( CNotCl, aIntFace);
+ }
+
+ if (!skipAlreadyAdded && CheckClosed)
+ {
+ myInternalFaces.Bind( theShape, C );
+ myIntNotClFaces.Bind( theShape, CNotCl );
+ }
+
+ return C;
+}
+
+//=======================================================================
+//function : MakeShell
+//purpose : split S into compound of shells
+//=======================================================================
+
+void Partition_Spliter::MakeShells(const TopoDS_Shape& S,
+ TopTools_ListOfShape& NS)
+{
+ // check if S is closed shape
+ Standard_Boolean isClosed = Standard_True;
+
+ TopTools_IndexedDataMapOfShapeListOfShape MEF;
+ Standard_Integer i;
+ if (S.ShapeType() != TopAbs_SOLID) {
+ TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF);
+ for (i=1; isClosed && i<=MEF.Extent(); ++i)
+ isClosed = ( MEF(i).Extent() != 1 );
+ }
+ Partition_Loop3d ShellMaker;
+ // get compound of split faces of S
+ const TopoDS_Shape& FacesComp = myImageShape.Image(S).First();
+ ShellMaker.AddConstFaces( FacesComp );
+ // split faces inside S
+ if (isClosed) {
+ TopoDS_Shape InternalFacesComp = FindFacesInside(S, Standard_True);
+ ShellMaker.AddSectionFaces( InternalFacesComp );
+// } else { // a shell may become closed
+// ShellMaker.AddConstFaces( InternalFacesComp );
+ }
+
+ NS = ShellMaker.MakeShells( myAddedFacesMap );
+
+ // 1. Add faces added to new shell to myAddedFacesMap:
+ // avoid rebuilding twice commont part of 2 solids.
+ // 2. Check shell closeness (DEBUG)
+ TopTools_ListIteratorOfListOfShape itS(NS);
+ while ( itS.More()) {
+#ifdef DEB
+ Standard_Boolean checkCloseness = Standard_True;
+#endif
+ TopExp_Explorer expF (itS.Value(), TopAbs_FACE);
+ for (; expF.More(); expF.Next()) {
+
+ myAddedFacesMap.Add (expF.Current());
+
+#ifdef DEB
+ if (checkCloseness &&
+ ! myInter3d.HasSameDomainF( myImagesFaces.Root(expF.Current()) ))
+ checkCloseness = Standard_False;
+#endif
+ }
+
+#ifdef DEB
+ if (checkCloseness) {
+ // if S is closed, a new shell must be closed too;
+ if (isClosed) {
+ // check that a new shell is closed
+ MEF.Clear();
+ TopExp::MapShapesAndAncestors(itS.Value(), TopAbs_EDGE, TopAbs_FACE, MEF);
+ for (i=1; isClosed && i<=MEF.Extent(); ++i)
+ isClosed = ( MEF(i).Extent() != 1 );
+ if (!isClosed) { // remove not closed shell
+ MESSAGE (" NOT CLOSED SHELL " );
+ //NS.Remove( itS );
+ itS.Next();
+ continue;
+ }
+ }
+ }
+#endif
+ itS.Next();
+ } // loop on new shells
+}
+
+//=======================================================================
+//function : findEqual
+//purpose : compare edges form EL1 against edges from EL2,
+// Result is in EMM binding edge form EL1 to list of equal edges
+// Edges are considered equall only if they have same vertices
+// <addSame>==True makes consider same edges as equal
+// Put in <AllEqMap> all equal edges
+//=======================================================================
+
+static void findEqual (const TopTools_ListOfShape& EL1,
+ const TopTools_ListOfShape& EL2,
+ const Standard_Boolean addSame,
+ TopTools_DataMapOfShapeListOfShape& EEM,
+ TopTools_MapOfShape& AllEqMap)
+{
+ // map vertices to edges for EL2
+ TopTools_DataMapOfShapeListOfShape VEM;
+ TopTools_ListIteratorOfListOfShape itE1, itE2(EL2);
+ TopoDS_Iterator itV;
+ TopTools_ListOfShape emptyL;
+ for (; itE2.More(); itE2.Next()) {
+ for (itV.Initialize( itE2.Value() ); itV.More(); itV.Next()) {
+ const TopoDS_Shape& V = itV.Value();
+ if (! VEM.IsBound( V ) )
+ VEM.Bind( V, emptyL);
+ VEM( V ).Append( itE2.Value());
+ }
+ }
+
+ gp_Vec D1, D2;
+ gp_Pnt P;
+ Standard_Real f,l,u,tol;
+ Handle(Geom_Curve) C1, C2;
+ Extrema_ExtPC Extrema;
+ TopoDS_Vertex V1, V2, V3, V4;
+
+ AllEqMap.Clear();
+
+ for (itE1.Initialize(EL1); itE1.More(); itE1.Next()) {
+ const TopoDS_Edge& E1 = TopoDS::Edge( itE1.Value());
+ if (BRep_Tool::Degenerated( E1 ) || AllEqMap.Contains (E1))
+ continue;
+ TopExp::Vertices( E1, V1, V2 );
+
+ if (VEM.IsBound(V1))
+ itE2.Initialize( VEM(V1) );
+ for (; itE2.More(); itE2.Next()) {
+ const TopoDS_Edge& E2 = TopoDS::Edge( itE2.Value());
+ if (BRep_Tool::Degenerated( E2 ))
+ continue;
+
+ if (E1.IsSame(E2)) {
+ if (!addSame)
+ continue;
+ }
+ else {
+ TopExp::Vertices( E2, V3, V4);
+ if (!V2.IsSame(V4) && !V2.IsSame(V3))
+ continue;
+ // E1 and E2 have same vertices
+ // check D1 at end points.
+ C2 = BRep_Tool::Curve( E2, f,l);
+ C1 = BRep_Tool::Curve( E1, f,l);
+ u = BRep_Tool::Parameter(V1,E1);
+ C1->D1(u, P, D1);
+ u = BRep_Tool::Parameter(V1.IsSame(V3) ? V3 : V4, E2);
+ C2->D1(u, P, D2);
+ D1.Normalize(); D2.Normalize();
+ if (Abs(D1*D2) + Precision::Angular() < 1.0)
+ continue;
+ if (! V1.IsSame(V2)) {
+ u = BRep_Tool::Parameter(V2,E1);
+ C1->D1(u, P, D1);
+ u = BRep_Tool::Parameter(V2.IsSame(V3) ? V3 : V4, E2);
+ C2->D1(u, P, D2);
+ D1.Normalize(); D2.Normalize();
+ if (Abs(D1*D2) + Precision::Angular() < 1.0)
+ continue;
+ }
+ // check distance at a couple of internal points
+ tol = Max(BRep_Tool::Tolerance(E1),
+ BRep_Tool::Tolerance(E2));
+ GeomAdaptor_Curve AC1(C1);
+ Extrema.Initialize(AC1,f,l);
+ Standard_Boolean ok = Standard_True, hasMin = Standard_False;
+ BRep_Tool::Range( E2, f, l);
+ Standard_Integer i=1, nbi=3;
+ for (; i<nbi && ok; ++i) {
+ Extrema.Perform( C2->Value( f+(l-f)*i/nbi ));
+ Standard_Integer j=1, nbj=Extrema.NbExt();
+ for (; j<=nbj && ok; ++j) {
+ if (Extrema.IsMin(j)) {
+ hasMin = Standard_True;
+ ok = Extrema.Value(j) <= tol;
+ }
+ }
+ }
+ if ( !hasMin || !ok)
+ continue;
+ }
+ // bind E2 to E1 in EEM
+ if (!EEM.IsBound(E1)) {
+ EEM.Bind (E1, emptyL);
+ AllEqMap.Add (E1);
+ }
+ EEM(E1).Append(E2);
+ AllEqMap.Add (E2);
+ }
+ }
+}
+
+//=======================================================================
+//function : MakeFaces
+//purpose : split faces of S, return compound of new faces
+//=======================================================================
+
+TopoDS_Shape Partition_Spliter::MakeFaces (const TopoDS_Shape& S)
+{
+ TopoDS_Compound C;
+ myBuilder.MakeCompound(C);
+
+ TopTools_ListIteratorOfListOfShape itl, itNE;
+
+ TopExp_Explorer exp(S,TopAbs_FACE);
+ for (; exp.More(); exp.Next()) {
+
+ const TopoDS_Face& F = TopoDS::Face(exp.Current());
+
+ TopTools_ListOfShape LNF;
+
+ if (myImagesFaces.HasImage( F )) {
+ myImagesFaces.LastImage( F, LNF );
+ TopAbs_Orientation oriF = F.Orientation();
+ for ( itl.Initialize( LNF ); itl.More(); itl.Next())
+ itl.Value().Orientation( oriF );
+ }
+ else {
+
+ Partition_Loop2d loops;
+ loops.Init(F);
+
+ TopTools_IndexedMapOfShape EM;
+ TopExp::MapShapes( F, TopAbs_EDGE, EM);
+
+ TopTools_MapOfShape AddedEqualM;
+ Standard_Boolean needRebuild = Standard_False;
+
+ // add splits to loops
+
+ // LE: old edges + new not splitted edges
+ const TopTools_ListOfShape& LE = myAsDes->Descendant(F);
+ for (itl.Initialize(LE); itl.More(); itl.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge( itl.Value() );
+
+ Standard_Boolean isSectionE = myInter3d.IsSectionEdge(E);
+ Standard_Boolean isNewE = !EM.Contains( E );
+
+ // LSE: list of split edges
+ TopTools_ListOfShape LSE;
+ myImagesEdges.LastImage(E,LSE); // splits of E or E itself
+
+ for (itNE.Initialize(LSE); itNE.More(); itNE.Next()) {
+
+ TopoDS_Edge NE = TopoDS::Edge( itNE.Value() );
+ Standard_Boolean isSameE = NE.IsSame ( E );
+
+ if ( isNewE || isSectionE || !isSameE) {
+ if (AddedEqualM.Contains( NE ))
+ continue;
+
+ if (isNewE) {
+ if (isSectionE) {
+ if ( ! myInter3d.IsSplitOn( NE, E, F) )
+ continue;
+ }
+ else {
+ TopoDS_Vertex V1,V2;
+ TopExp::Vertices(NE,V1,V2);
+ const TopTools_ListOfShape& EL1 = myAsDes->Ascendant(V1);
+ const TopTools_ListOfShape& EL2 = myAsDes->Ascendant(V2);
+ if ( EL1.Extent() < 2 && EL2.Extent() < 2 )
+ continue;
+ }
+ }
+ else {
+ NE.Orientation( E.Orientation());
+ if (!isSameE) {
+ // orient NE because it may be a split of other edge
+ Standard_Real f,l,u;
+ Handle(Geom_Curve) C3d = BRep_Tool::Curve( E,f,l );
+ Handle(Geom_Curve) NC3d = BRep_Tool::Curve( NE,f,l);
+ if ( C3d != NC3d) {
+ gp_Vec D1, ND1; gp_Pnt P;
+ TopoDS_Vertex V = TopExp::FirstVertex(NE);
+ u = BRep_Tool::Parameter(V,NE);
+ NC3d->D1 (u, P, ND1);
+ u = BRep_Tool::Parameter(V,E);
+ C3d ->D1 (u, P, D1);
+ if (ND1.Dot(D1) < 0)
+ NE.Reverse();
+ }
+ }
+ }
+ if (myEqualEdges.Contains( NE ) && !AddedEqualM.Add( NE ))
+ continue;
+
+ needRebuild = Standard_True;
+ }
+
+ if (isNewE || isSectionE)
+ myNewSection.Add( NE );
+
+ if (isNewE)
+ loops.AddSectionEdge(NE);
+ else
+ loops.AddConstEdge(NE);
+ }
+ }
+
+ //-------------------
+ // Build the faces.
+ //-------------------
+
+ if (needRebuild) {
+
+ loops.Perform();
+ loops.WiresToFaces(myImagesEdges);
+
+ LNF = loops.NewFaces();
+
+ myImagesFaces.Bind(F,LNF);
+
+ // replace the result faces that have already been built
+ // during same domain faces reconstruction
+ if (myInter3d.HasSameDomainF( F )) {
+ // build map edge to same domain faces
+ TopTools_IndexedDataMapOfShapeListOfShape EFM;
+ TopTools_MapOfShape SDFM; // avoid doubling
+ itl.Initialize( myInter3d.SameDomain( F ));
+ for (; itl.More(); itl.Next()) {
+ if ( !myImagesFaces.HasImage( itl.Value() ))
+ continue;
+ TopTools_ListIteratorOfListOfShape itNF;
+ itNF.Initialize (myImagesFaces.Image( itl.Value() ));
+ for ( ; itNF.More(); itNF.Next()) {
+ TopoDS_Shape SDF = itNF.Value();
+ if (myImagesFaces.HasImage( SDF )) // already replaced
+ SDF = myImagesFaces.Image( SDF ).First();
+ if (SDFM.Add (SDF))
+ TopExp::MapShapesAndAncestors(SDF, TopAbs_EDGE, TopAbs_FACE, EFM);
+ }
+ }
+ // do replace
+ TopTools_ListOfShape LOF;
+ if ( !EFM.IsEmpty() )
+ itl.Initialize( LNF );
+ while (itl.More()) {
+ const TopoDS_Shape& NF = itl.Value();
+ TopExp_Explorer expE ( NF, TopAbs_EDGE );
+ const TopoDS_Edge& E = TopoDS::Edge (expE.Current());
+ if (EFM.Contains( E )) {
+ const TopTools_ListOfShape& SDFL = EFM.FindFromKey( E );
+ TopoDS_Shape SDF = SDFL.First();
+ Standard_Boolean GoodOri;
+ Standard_Real dot;
+ Partition_Loop3d::IsInside (E, TopoDS::Face(NF), TopoDS::Face(SDF),
+ 1, dot, GoodOri);
+ if (dot < 0) {
+ if (SDFL.Extent() == 1) {
+ itl.Next();
+ continue;
+ }
+ else
+ SDF = SDFL.Last();
+ }
+ gp_Vec V1 = Partition_Loop3d::Normal( E, TopoDS::Face( NF ));
+ gp_Vec V2 = Partition_Loop3d::Normal( E, TopoDS::Face( SDF ));
+ if (V1*V2 < 0)
+ SDF.Reverse();
+
+ if (!myImagesFaces.HasImage( NF ))
+ myImagesFaces.Bind( NF, SDF );
+
+ LOF.Prepend ( SDF );
+ LNF.Remove (itl);
+ }
+ else
+ itl.Next();
+ }
+
+ LNF.Append (LOF);
+ }
+ } // if (needRebuild)
+
+ else {
+ LNF.Append( F );
+ myImagesFaces.Bind(F,LNF);
+ }
+ } // if (myImagesFaces.HasImage( F ))
+
+ for (itl.Initialize(LNF); itl.More(); itl.Next())
+ myBuilder.Add ( C, itl.Value());
+ } // loop on faces of S
+
+ return C;
+}
+
+//=======================================================================
+//function : MergeEqualEdges
+//purpose : find equal edges, choose ones to keep and make
+// them have pcurves on all faces they are shared by
+//=======================================================================
+
+void Partition_Spliter::MergeEqualEdges (const TopTools_ListOfShape& LSE)
+{
+ // find equal edges
+ // map: edge - equal edges
+ TopTools_DataMapOfShapeListOfShape EEM( LSE.Extent() );
+ findEqual (LSE, LSE, 0, EEM, myEqualEdges);
+
+ TopTools_ListOfShape EEL; // list of equal edges
+ TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itM (EEM);
+ for ( ; itM.More(); itM.Next()) {
+ EEL = itM.Value();
+ EEL.Append( itM.Key() );
+ // choose an edge to keep, section edges have priority
+ TopoDS_Edge EKeep;
+ TopTools_ListIteratorOfListOfShape itEE (EEL);
+ for (; itEE.More(); itEE.Next()) {
+ EKeep = TopoDS::Edge( itEE.Value() );
+ const TopoDS_Edge& EKeepOrig = TopoDS::Edge( myImagesEdges.Root( EKeep ));
+ if (myInter3d.IsSectionEdge( EKeepOrig ))
+ break;
+ }
+
+ Standard_Real f,l, tol;
+ for (itEE.Initialize (EEL); itEE.More(); itEE.Next()) {
+ const TopoDS_Edge& E = TopoDS::Edge( itEE.Value() );
+ if ( E.IsSame( EKeep ))
+ continue;
+ const TopoDS_Edge& EReplOrig = TopoDS::Edge( myImagesEdges.Root( E ));
+ TopTools_ListOfShape FL;
+ if (myInter3d.IsSectionEdge( EReplOrig ))
+ FL = myInter3d.SectionEdgeFaces ( EReplOrig );
+ else
+ FL = myAsDes->Ascendant( EReplOrig );
+
+ TopTools_ListIteratorOfListOfShape itF (FL);
+ for ( ; itF.More(); itF.Next()) {
+ const TopoDS_Face& F = TopoDS::Face( itF.Value());
+ // build pcurves
+ Handle(Geom2d_Curve) pc = BRep_Tool::CurveOnSurface( EKeep, F, f,l);
+ if (pc.IsNull()) {
+ Handle(Geom_Curve) C3d = BRep_Tool::Curve( EKeep, f, l);
+ C3d = new Geom_TrimmedCurve( C3d, f,l);
+ pc = TopOpeBRepTool_CurveTool::MakePCurveOnFace (F,C3d,tol);
+ if (pc.IsNull()) {
+ MESSAGE (" CANT BUILD PCURVE ");
+ }
+ myBuilder.UpdateEdge( EKeep, pc, F, tol);
+ }
+ }
+ // replace edges in faces
+ if (!myImagesEdges.HasImage( E ))
+ myImagesEdges.Bind( E, EKeep );
+ }
+ }
+}
+
+//=======================================================================
+//function : KeepShapesInside
+//purpose : remove shapes that are outside of S from resul
+//=======================================================================
+
+void Partition_Spliter::KeepShapesInside (const TopoDS_Shape& S)
+{
+ TopoDS_Iterator it;
+ if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid
+ for (it.Initialize( S ); it.More(); it.Next())
+ KeepShapesInside( it.Value());
+ return;
+ }
+
+ Standard_Boolean isTool = Standard_False;
+ if (!myImageShape.HasImage( S )) {
+ isTool = CheckTool( S );
+ if (!isTool) return;
+ }
+
+ // build map of internal faces
+ TopTools_IndexedMapOfShape MIF;
+
+ // if S is not a tool, make sure that split faces of S are in MIF
+ if (!isTool)
+ TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF);
+
+ TopoDS_Shape InsFacesComp = FindFacesInside( S, Standard_False, Standard_True);
+ TopExp::MapShapes( InsFacesComp, TopAbs_FACE, MIF );
+
+
+ TopoDS_Compound C;
+ myBuilder.MakeCompound(C);
+
+ // leave in the result only those shapes having a face in MIF
+ for (it.Initialize( myShape ); it.More(); it.Next()) {
+
+ TopExp_Explorer expResF( it.Value(), TopAbs_FACE );
+ for (; expResF.More(); expResF.Next()) {
+ if ( MIF.Contains( expResF.Current())) {
+ myBuilder.Add( C, it.Value() );
+ break;
+ }
+ }
+ }
+
+ myShape = C;
+}
+
+//=======================================================================
+//function : RemoveShapesInside
+//purpose : remove shapes that are inside S from resul
+//=======================================================================
+
+void Partition_Spliter::RemoveShapesInside (const TopoDS_Shape& S)
+{
+ TopoDS_Iterator it;
+ if (S.ShapeType() < TopAbs_SOLID) { // compound or compsolid
+ for (it.Initialize( S ); it.More(); it.Next())
+ RemoveShapesInside( it.Value());
+ return;
+ }
+ Standard_Boolean isTool = Standard_False;
+ if (!myImageShape.HasImage( S )) {
+ isTool = CheckTool( S );
+ if (!isTool) return;
+ }
+
+ TopoDS_Shape InsFacesComp = FindFacesInside( S, Standard_False, Standard_True);
+ TopTools_IndexedMapOfShape MIF; // map of internal faces
+ TopExp::MapShapes( InsFacesComp, TopAbs_FACE, MIF);
+
+ if (MIF.IsEmpty()) return;
+
+ // add to MIF split faces of S
+ if (myImageShape.HasImage(S))
+ TopExp::MapShapes( myImageShape.Image(S).First(), TopAbs_FACE, MIF);
+
+ // leave in the result only those shapes not having all face in MIF
+
+ TopoDS_Compound C;
+ myBuilder.MakeCompound(C);
+
+ // RMF : faces of removed shapes that encounter once
+ TopTools_MapOfShape RFM;
+
+ for (it.Initialize( myShape ); it.More(); it.Next()) {
+
+ TopExp_Explorer expResF( it.Value(), TopAbs_FACE );
+ for (; expResF.More(); expResF.Next())
+ if (!MIF.Contains( expResF.Current()))
+ break;
+
+ if (expResF.More())
+ // add shape to result
+ myBuilder.Add( C, it.Value() );
+ else
+ // add faces of a removed shape to RFM
+ for (expResF.ReInit(); expResF.More(); expResF.Next()) {
+ const TopoDS_Shape& F = expResF.Current();
+ if ( ! RFM.Remove ( F ))
+ RFM.Add( F );
+ }
+ }
+
+ if (!isTool) {
+
+ // rebuild S, it must remain in the result
+
+ Standard_Boolean isClosed = Standard_False;
+ switch (S.ShapeType()) {
+ case TopAbs_SOLID :
+ isClosed = Standard_True; break;
+ case TopAbs_SHELL: {
+ TopTools_IndexedDataMapOfShapeListOfShape MEF;
+ TopExp::MapShapesAndAncestors(S, TopAbs_EDGE, TopAbs_FACE, MEF);
+ Standard_Integer i;
+ for (i=1; isClosed && i<=MEF.Extent(); ++i)
+ isClosed = ( MEF(i).Extent() != 1 );
+ break;
+ }
+ default:
+ isClosed = Standard_False;
+ }
+ if (isClosed) {
+
+ // add to a new shape external faces of removed shapes, ie those in RFM
+
+ TopoDS_Shell Shell;
+ myBuilder.MakeShell( Shell );
+
+ // exclude redundant internal face with edges encounterd only once
+ TopTools_IndexedDataMapOfShapeListOfShape MEF;
+ TopTools_MapIteratorOfMapOfShape itF (RFM);
+ for ( ; itF.More(); itF.Next())
+ TopExp::MapShapesAndAncestors(itF.Key(), TopAbs_EDGE, TopAbs_FACE, MEF);
+
+ // add only faces forming a closed shell
+ for (itF.Reset() ; itF.More(); itF.Next())
+ {
+ TopExp_Explorer expE (itF.Key(), TopAbs_EDGE);
+ for (; expE.More(); expE.Next())
+ if (MEF.FindFromKey(expE.Current()).Extent() == 1)
+ break;
+ if (!expE.More())
+ myBuilder.Add( Shell, itF.Key());
+ }
+
+ if (S.ShapeType() == TopAbs_SOLID) {
+ TopoDS_Solid Solid;
+ myBuilder.MakeSolid( Solid );
+ myBuilder.Add (Solid, Shell);
+ myBuilder.Add (C, Solid);
+ }
+ else
+ myBuilder.Add (C, Shell);
+ }
+ else {
+ if (myImageShape.HasImage( S )) {
+ for (it.Initialize( myImageShape.Image(S).First()); it.More(); it.Next())
+ myBuilder.Add (C, it.Value());
+ }
+ }
+ }
+
+ myShape = C;
+}
+
+//=======================================================================
+//function : CheckTool
+//purpose : Return True if <S> is a tool shape. Prepare tool
+// faces of <S> for the search of internal faces.
+//=======================================================================
+
+Standard_Boolean Partition_Spliter::CheckTool(const TopoDS_Shape& S)
+{
+ // suppose S has not an image
+
+ Standard_Boolean isTool = Standard_False;
+ TopoDS_Compound C;
+ myBuilder.MakeCompound( C );
+
+ TopExp_Explorer expF( S, TopAbs_FACE);
+ for (; expF.More(); expF.Next()) {
+
+ const TopoDS_Face& F = TopoDS::Face( expF.Current() );
+ if (myMapTools.Contains( F ))
+ isTool = Standard_True;
+ else
+ continue;
+
+ if (myImagesFaces.HasImage( F )) {
+ // F has been reconstructed
+ TopAbs_Orientation Fori = F.Orientation();
+ TopTools_ListOfShape LNF;
+ myImagesFaces.LastImage( F, LNF);
+ TopTools_ListIteratorOfListOfShape itF (LNF);
+ for ( ; itF.More(); itF.Next())
+ myBuilder.Add( C, itF.Value().Oriented(Fori) );
+ continue;
+ }
+
+ Standard_Boolean hasSectionE = myInter3d.HasSectionEdge( F );
+ Standard_Boolean hasNewE = myAsDes->HasDescendant( F );
+ if (!hasSectionE && !hasNewE)
+ continue; // F intersects nothing
+
+ // make an image for F
+
+ TopoDS_Face NF = F;
+ NF.Orientation(TopAbs_FORWARD);
+ NF = TopoDS::Face( NF.EmptyCopied() ); // make a copy
+ TopoDS_Wire NW;
+ myBuilder.MakeWire( NW );
+
+ // add edges, as less as possible
+ TopTools_ListOfShape NEL;
+ TopTools_ListIteratorOfListOfShape itNE;
+ if (hasSectionE) {
+ // add section edges
+ TopExp_Explorer expE;
+ for ( ; expE.More(); expE.Next()) {
+ if (! myImagesEdges.HasImage( expE.Current() ))
+ continue;
+ myImagesEdges.LastImage( expE.Current(), NEL );
+ for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next())
+ myBuilder.Add ( NW, itNE.Value());
+ }
+ }
+ if (hasNewE) {
+ // add new adges
+ NEL = myAsDes->Descendant( F );
+ for ( itNE.Initialize( NEL ); itNE.More(); itNE.Next()) {
+ TopTools_ListOfShape SEL; // splits
+ myImagesEdges.LastImage( itNE.Value(), SEL );
+ TopTools_ListIteratorOfListOfShape itSE (SEL);
+ for ( ; itSE.More(); itSE.Next())
+ myBuilder.Add ( NW, itSE.Value());
+ }
+ }
+ myBuilder.Add( NF, NW );
+ myBuilder.Add (C, NF);
+
+ NF.Orientation( F.Orientation() ); // NF is most probably invalid
+ myImagesFaces.Bind (F, NF);
+ }
+ if (isTool)
+ myImageShape.Bind (S, C);
+
+ return isTool;
+}
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Spliter.hxx
+// Module : GEOM
+
+
+#ifndef _Partition_Spliter_HeaderFile
+#define _Partition_Spliter_HeaderFile
+
+#ifndef _TopAbs_ShapeEnum_HeaderFile
+#include <TopAbs_ShapeEnum.hxx>
+#endif
+#ifndef _TopoDS_Compound_HeaderFile
+#include <TopoDS_Compound.hxx>
+#endif
+#ifndef _BRep_Builder_HeaderFile
+#include <BRep_Builder.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopTools_MapOfShape_HeaderFile
+#include <TopTools_MapOfShape.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeShape_HeaderFile
+#include <TopTools_DataMapOfShapeShape.hxx>
+#endif
+#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
+#include <Handle_BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _BRepAlgo_Image_HeaderFile
+#include <BRepAlgo_Image.hxx>
+#endif
+#ifndef _Partition_Inter3d_HeaderFile
+#include "Partition_Inter3d.hxx"
+#endif
+#ifndef _TopTools_MapOfOrientedShape_HeaderFile
+#include <TopTools_MapOfOrientedShape.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+class BRepAlgo_AsDes;
+class TopoDS_Shape;
+class TopTools_ListOfShape;
+class TopoDS_Edge;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class Partition_Spliter {
+
+public:
+
+ void* operator new(size_t,void* anAddress)
+ {
+ return anAddress;
+ }
+ void* operator new(size_t size)
+ {
+ return Standard::Allocate(size);
+ }
+ void operator delete(void *anAddress)
+ {
+ if (anAddress) Standard::Free((Standard_Address&)anAddress);
+ }
+ // Methods PUBLIC
+ //
+Standard_EXPORT Partition_Spliter();
+Standard_EXPORT void AddShape(const TopoDS_Shape& S) ;
+Standard_EXPORT void AddTool(const TopoDS_Shape& S) ;
+Standard_EXPORT void Compute(const TopAbs_ShapeEnum Limit = TopAbs_SHAPE) ;
+Standard_EXPORT void KeepShapesInside(const TopoDS_Shape& S) ;
+Standard_EXPORT void RemoveShapesInside(const TopoDS_Shape& S) ;
+Standard_EXPORT TopoDS_Shape Shape() const;
+Standard_EXPORT void Clear() ;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+Standard_EXPORT void MakeShells(const TopoDS_Shape& S,TopTools_ListOfShape& NS) ;
+Standard_EXPORT TopoDS_Shape MakeFaces(const TopoDS_Shape& S) ;
+Standard_EXPORT void MakeEdges(const TopoDS_Edge& E,const TopTools_ListOfShape& VOnE,TopTools_ListOfShape& NE) const;
+Standard_EXPORT TopoDS_Shape FindFacesInside(const TopoDS_Shape& S,const Standard_Boolean CheckClosed = Standard_False,const Standard_Boolean All = Standard_False) ;
+Standard_EXPORT Standard_Boolean CheckTool(const TopoDS_Shape& S) ;
+Standard_EXPORT void MergeEqualEdges(const TopTools_ListOfShape& LE) ;
+
+
+ // Fields PRIVATE
+ //
+TopAbs_ShapeEnum myDoneStep;
+TopoDS_Compound myShape;
+BRep_Builder myBuilder;
+TopTools_ListOfShape myListShapes;
+TopTools_MapOfShape myMapFaces;
+TopTools_MapOfShape myMapTools;
+TopTools_DataMapOfShapeShape myFaceShapeMap;
+TopTools_MapOfShape myNewSection;
+Handle_BRepAlgo_AsDes myAsDes;
+BRepAlgo_Image myImagesFaces;
+BRepAlgo_Image myImagesEdges;
+BRepAlgo_Image myImageShape;
+Partition_Inter3d myInter3d;
+TopTools_MapOfOrientedShape myAddedFacesMap;
+TopTools_MapOfShape myEqualEdges;
+TopTools_DataMapOfShapeShape myInternalFaces;
+TopTools_DataMapOfShapeShape myIntNotClFaces;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Spliter.ixx
+// Module : GEOM
+
+#include "Partition_Spliter.jxx"
+
+
+
+
--- /dev/null
+// GEOM PARTITION : partition algorithm
+//
+// 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 : Partition_Spliter.jxx
+// Module : GEOM
+
+#ifndef _BRepAlgo_AsDes_HeaderFile
+#include <BRepAlgo_AsDes.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _TopTools_ListOfShape_HeaderFile
+#include <TopTools_ListOfShape.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _Partition_Spliter_HeaderFile
+#include "Partition_Spliter.hxx"
+#endif
--- /dev/null
+// GEOM SKETCHER : basic sketcher
+//
+// 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_Sketcher.cxx
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+using namespace std;
+#include "GEOM_Sketcher.h"
+#include "utilities.h"
+
+#include <qstring.h>
+
+#include <Geom_Axis1Placement.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBuilderAPI_MakeEdge2d.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Circ2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <IntAna_IntConicQuad.hxx>
+#include <BRepLib.hxx>
+#include <TopExp.hxx>
+#include <ProjLib.hxx>
+#include <Precision.hxx>
+#include <ElSLib.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <GccAna_Pnt2dBisec.hxx>
+#include <GeomAPI.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_Circle.hxx>
+#include <gce_MakeCirc2d.hxx>
+#include <GccAna_Circ2d2TanRad.hxx>
+#include <GccAna_Circ2d2TanOn.hxx>
+#include <GccEnt.hxx>
+#include <GccEnt_QualifiedLin.hxx>
+#include <GccEnt_QualifiedCirc.hxx>
+#include <GccAna_Lin2dTanPer.hxx>
+#include <GccAna_Lin2dTanObl.hxx>
+#include <gce_MakeLin2d.hxx>
+#include <GCE2d_MakeArcOfCircle.hxx>
+#include <Precision.hxx>
+#include <ElCLib.hxx>
+#include <AIS_Point.hxx>
+#include <TColgp_HArray1OfPnt2d.hxx>
+#include <Geom2dAPI_Interpolate.hxx>
+#include <TColgp_Array1OfVec2d.hxx>
+#include <TColStd_HArray1OfBoolean.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <DsgPrs_ArrowSide.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+
+#include <AIS_Drawer.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Graphic3d_NameOfFont.hxx>
+
+#include <TopoDS_Wire.hxx>
+
+/*!
+ \class GEOM_Sketcher GEOM_Sketcher.h
+ \brief ...
+*/
+
+Standard_Real resol = 1.0;
+
+/*!
+ Constructor.
+*/
+Sketch::Sketch()
+{
+
+}
+
+/*!
+ Destructor.
+*/
+Sketch::~Sketch()
+{
+
+}
+
+
+/*!
+ Constructor.
+
+ \param V3d_Viewer
+*/
+Sketch::Sketch(const Handle(V3d_Viewer)& aViewer) :
+myInteractiveContext(new AIS_InteractiveContext(aViewer)),
+myAxisColor(Quantity_Color(Quantity_NOC_YELLOW)),
+myCurrentColor(Quantity_Color(Quantity_NOC_GREEN)),
+myWireColor(Quantity_Color(Quantity_NOC_RED))
+{
+ Init();
+}
+
+/*!
+ Constructor.
+
+ \param V3d_Viewer
+ \param Quantity_Color
+ \param Quantity_Color
+ \param Quantity_Color
+*/
+Sketch::Sketch(const Handle(V3d_Viewer)& aViewer,
+ const Quantity_Color& anAxisColor,
+ const Quantity_Color& aCurrentColor,
+ const Quantity_Color& aWireColor):
+myInteractiveContext(new AIS_InteractiveContext(aViewer)),
+myAxisColor(anAxisColor),
+myCurrentColor(aCurrentColor),
+myWireColor(aWireColor)
+{
+ Init();
+}
+
+/*!
+ Build the current edge in a graphic mode.
+ The first signature with view coordinates is used to connect to the move event from the user interface.
+ The second signature is used when the current point is known by 2d real coordinates.
+
+ \param Xp
+ \param Yp
+ \param V3d_View
+*/
+void Sketch::MakeCurrentEdge(const Standard_Integer Xp ,
+ const Standard_Integer Yp ,
+ const Handle(V3d_View)& aView )
+{
+ /* 3d coordinates of the picked point */
+ Standard_Real Xv,Yv,Zv;
+ aView->Convert(Xp,Yp,Xv,Yv,Zv);
+ /* computation of real 2d coordinates in plane of sketch */
+ Standard_Real Vx,Vy,Vz;
+ aView->Proj(Vx,Vy,Vz);
+ gp_Dir D(Vx,Vy,Vz);
+ gp_Pnt P(Xv,Yv,Zv);
+ gp_Lin L(P,D);
+ Standard_Real X,Y;
+ gp_Pnt Sol;
+ IntAna_IntConicQuad Int(L,myPlane->Pln(),Precision::Angular());
+ if (Int.IsDone()) {
+ if (!Int.IsParallel()) {
+ if (Int.NbPoints() > 0 ) {
+ Sol = Int.Point(1);
+ ElSLib::Parameters(myPlane->Pln(),Sol,X,Y);
+ }
+ }
+ }
+ MakeCurrentEdge(X,Y);
+}
+
+/*!
+ Build the current edge in a graphic mode.
+ The first signature with view coordinates is used to connect to the move event from the user interface.
+ The second signature is used when the current point is known by 2d real coordinates.
+
+ \param X
+ \param Y
+*/
+void Sketch::MakeCurrentEdge(const Standard_Real X, const Standard_Real Y)
+{
+ /* Create the current edge depending on the active mode */
+ switch (myCurrentStatus) {
+ case BEGIN_SKETCH:
+ myCurrentEdge = BRepBuilderAPI_MakeVertex(ElCLib::To3d(myPlane->Pln().Position().Ax2(),gp_Pnt2d(X,Y)));
+ break;
+ case SEGMENT:
+ MakeCurrentSegment(X,Y);
+ break;
+ case ARC_CHORD:
+ MakeCurrentSegment(X,Y);
+ break;
+ case ARC_CHORD_END:
+ MakeCurrentArc(X,Y);
+ break;
+ }
+ DisplayCurrentEdge();
+}
+
+/*!
+ Build the current edge in a graphic mode.
+ Function to connect to the input event from the user interface.
+*/
+void Sketch::ValidateEdge()
+{
+ gp_Pnt pt;
+ gp_Pnt2d pt2d;
+ switch (myCurrentStatus) {
+ case BEGIN_SKETCH:
+ {
+ myFirstPointSketch = TopoDS::Vertex(myCurrentEdge);
+ myPresentableWire = new AIS_Shape(myFirstPointSketch);
+ myPresentableWire->SetColor(myWireColor.Name());
+ myInteractiveContext->Display(myPresentableWire);
+ pt = BRep_Tool::Pnt(myFirstPointSketch);
+ pt2d = ProjLib::Project(myPlane->Pln(),pt);
+ myLastX = pt2d.X();
+ myLastY = pt2d.Y();
+ myCurrentStatus = SEGMENT;
+ break;
+ }
+ case SEGMENT:
+ {
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last);
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,myLengthDimension->Value());
+ if (myTransitionStatus == ANGLE ||
+ myTransitionStatus == LENGTH_FIXED ||
+ myTransitionStatus == X_FIXED ||
+ myTransitionStatus == Y_FIXED)
+ myTransitionStatus = NOCONSTRAINT;
+ AddEdgeToWire();
+ break;
+ }
+ case ARC_CHORD:
+ {
+ myInteractiveContext->CloseLocalContext();
+ myInteractiveContext->OpenLocalContext();
+ gp_Pnt2d p1 (myLastX,myLastY);
+ pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myCurrentEdge)));
+ gp_Pnt2d p2 = ProjLib::Project(myPlane->Pln(),pt);
+ GccAna_Pnt2dBisec ComputeMediatrice(p1,p2);
+ if (ComputeMediatrice.HasSolution()) {
+ myMediatrice = new Geom2d_Line(ComputeMediatrice.ThisSolution());
+ Handle(Geom_Curve) aMediatrice3d = GeomAPI::To3d(myMediatrice,myPlane->Pln());
+ myPresentableMediatrice = new AIS_Axis(Handle(Geom_Line)::DownCast(aMediatrice3d));
+ myInteractiveContext->Display(myPresentableMediatrice);
+ }
+ TopoDS_Edge e = BRepBuilderAPI_MakeEdge2d(gce_MakeCirc2d(gp_Pnt2d(0.,0),1.));
+ BRepLib::BuildCurve3d(e);
+ myLengthDimension->SetText(TCollection_ExtendedString());
+ myInteractiveContext->Redisplay(myLengthDimension,Standard_False);
+ if (myEdgesNumber == 0)
+ myPreviousEdge = TopoDS::Edge(myCurrentEdge);
+ pt2d = ProjLib::Project(myPlane->Pln(),pt);
+ myLastX = pt2d.X();
+ myLastY = pt2d.Y();
+ myTransitionStatus = NOCONSTRAINT;
+ myCurrentStatus = ARC_CHORD_END;
+ break;
+ }
+ case ARC_CHORD_END:
+ myCurrentStatus = ARC_CHORD;
+ AddEdgeToWire();
+ break;
+ }
+}
+
+/*!
+ Add edge to current wire on an edge validation .
+*/
+void Sketch::AddEdgeToWire()
+{
+ myPreviousEdge = TopoDS::Edge(myCurrentEdge);
+ BRepLib::BuildCurve3d(myPreviousEdge);
+ myCurrentWire.Add(TopoDS::Edge(myPreviousEdge));
+ myEdgesNumber++;
+ myPresentableWire->Set( myCurrentWire.Wire() );
+ myInteractiveContext->Redisplay(myPresentableWire);
+ myConstructionMode.Append(myCurrentStatus);
+ myConstraintMode.Append(myTransitionStatus);
+ myInteractiveContext->CloseLocalContext();
+ gp_Pnt pt;
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD )
+ pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge)));
+ else
+ pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge)));
+ gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt);
+ myLastX = pt2d.X();
+ myLastY = pt2d.Y();
+}
+
+/*!
+ Set the numeric dimension for the current edge and validate creation.
+
+ \param aValue
+ \return Standard_Boolean
+*/
+Standard_Boolean Sketch::SetDimension(Standard_Real& aValue)
+{
+ fitInResol(aValue);
+ if (myCurrentStatus == SEGMENT ||
+ myCurrentStatus == ARC_CHORD){
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C =
+ BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last);
+ myCurrentEdge =
+ BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,aValue);
+ DisplayCurrentEdge();
+ if (myTransitionStatus == NOCONSTRAINT) {
+ mySegmentLength = aValue;
+ myTransitionStatus = LENGTH_FIXED;
+ }
+ else
+ ValidateEdge();
+ return Standard_True;
+ }
+
+ else if( myCurrentStatus == ARC_CHORD_END){
+ if (myTransitionStatus == TANGENT) return Standard_False;
+ gp_Pnt2d p;
+ if (myEdgesNumber > 0) {
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
+ else
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
+ }
+ else
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch));
+ GccAna_Circ2d2TanRad aSol(p, gp_Pnt2d(myLastX,myLastY),aValue,Precision::Confusion());
+ Standard_Real dist = RealLast();
+ if (aSol.NbSolutions() > 0) {
+ gp_Circ2d CirSol;
+ gp_Pnt2d pc = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopoDS::Vertex(myCenterCircle->Shape())));
+ for (Standard_Integer i =1; i<= aSol.NbSolutions(); i++) {
+ if (pc.Distance(aSol.ThisSolution(i).Location()) < dist)
+ CirSol = aSol.ThisSolution(i);
+ }
+ if (myCurrentEdge.Orientation() == TopAbs_FORWARD)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),p,gp_Pnt2d(myLastX,myLastY));
+ else {
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),gp_Pnt2d(myLastX,myLastY),p);
+ myCurrentEdge.Reverse();
+ }
+ DisplayCurrentEdge();
+ ValidateEdge();
+ return Standard_True;
+ }
+ }
+
+ return Standard_False;
+}
+
+/*!
+ Set the numeric dimension for the current edge and validate creation.
+
+ \param deltaX
+ \param deltaY
+*/
+void Sketch::SetDimension(Standard_Real& deltaX, Standard_Real& deltaY)
+{
+ fitInResol(deltaX);
+ fitInResol(deltaY);
+ Standard_Real X = myLastX + deltaX;
+ Standard_Real Y = myLastY + deltaY;
+ MakeCurrentEdge(X,Y);
+ ValidateEdge();
+}
+
+/*!
+ Set the numeric value of the X coordinate of current point giving a deltaX relative to previous point.
+
+ \param deltaX
+*/
+void Sketch::SetXDimension(Standard_Real& deltaX)
+{
+ fitInResol(deltaX);
+ Standard_Real X = myLastX + deltaX;
+ Standard_Real Y = myLastY;
+ if ( deltaX == 0. )
+ Y = Y + 100.0 * Precision::Confusion();
+
+ if (myTransitionStatus == NOCONSTRAINT) {
+ MakeCurrentEdge(X,Y);
+ myTransitionStatus = X_FIXED;
+ mySegmentX = X;
+ }
+ else if (myTransitionStatus == Y_FIXED) {
+ myTransitionStatus = NOCONSTRAINT;
+ MakeCurrentEdge(X,mySegmentY);
+ ValidateEdge();
+ }
+ else if (myTransitionStatus == ANGLE) {
+ myTransitionStatus = NOCONSTRAINT;
+ Standard_Real angle;
+ if (0 <= mySegmentAngle && mySegmentAngle<= PI )
+ angle = PI - mySegmentAngle;
+ else
+ angle = mySegmentAngle - PI;
+ Y = X*Tan(angle);
+ MakeCurrentEdge(X,Y);
+ ValidateEdge();
+ }
+ else
+ myTransitionStatus = NOCONSTRAINT;
+}
+
+/*!
+ Set the numeric value of the Y coordinate of current point giving a deltaY relative to previous point.
+
+ \param deltaY
+*/
+void Sketch::SetYDimension(Standard_Real& deltaY)
+{
+ fitInResol(deltaY);
+ Standard_Real X = myLastX;
+ Standard_Real Y = myLastY + deltaY;
+
+ if ( deltaY == 0. )
+ X = X + 100.0 * Precision::Confusion();
+
+ if (myTransitionStatus == NOCONSTRAINT) {
+ MakeCurrentEdge(X,Y);
+ myTransitionStatus = Y_FIXED;
+ mySegmentY = Y;
+ }
+ else if (myTransitionStatus == X_FIXED) {
+ myTransitionStatus = NOCONSTRAINT;
+ MakeCurrentEdge(mySegmentX,Y);
+ ValidateEdge();
+ }
+ else if (myTransitionStatus == ANGLE) {
+ myTransitionStatus = NOCONSTRAINT;
+ Standard_Real angle;
+ if (0 <= mySegmentAngle && mySegmentAngle<= PI )
+ angle = PI - mySegmentAngle;
+ else
+ angle = mySegmentAngle - PI;
+ X = Y/Tan(angle);
+ MakeCurrentEdge(X,Y);
+ ValidateEdge();
+ }
+ else
+ myTransitionStatus = NOCONSTRAINT;
+}
+
+/*!
+ Set the numeric value of angle between 2 segments.
+
+ \param aValue
+*/
+void Sketch::SetSegmentAngle(Standard_Real& aValue)
+{
+ if (myEdgesNumber > 0) {
+ Standard_Real First,Last;
+ TopLoc_Location L;
+ Standard_Real angle;
+ if (0 <= aValue && aValue<= PI )
+ angle = PI - aValue;
+ else
+ angle = aValue - PI;
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
+ if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
+
+ GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle);
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),0.,myLengthDimension->Value());
+ }
+ if (myTransitionStatus == LENGTH_FIXED) {
+ ValidateEdge();
+ }
+ else if (myTransitionStatus == X_FIXED) {
+ Standard_Real length = mySegmentX/Cos(angle);
+ SetDimension(length);
+ ValidateEdge();
+ }
+ else if (myTransitionStatus == Y_FIXED) {
+ Standard_Real length = mySegmentY/Sin(angle);
+ SetDimension(length);
+ ValidateEdge();
+ }
+ else {
+ mySegmentAngle = aValue;
+ myTransitionStatus = ANGLE;
+ }
+ }
+}
+
+/*!
+ Get the angle value between 2 segments.
+
+ \return Standard_Real
+*/
+Standard_Real Sketch::GetSegmentAngle()
+{
+ return mySegmentAngle;
+}
+
+/*!
+ Close automatically an open sketch.
+
+ \return TopoDS_Wire. Return null shape if not possible.
+*/
+TopoDS_Wire Sketch::Close()
+{
+ myCurrentStatus = END_SKETCH;
+ myInteractiveContext->CloseAllContexts();
+ myInteractiveContext->EraseAll(Standard_False);
+ if (myEdgesNumber >= 2) {
+ BRepTools_WireExplorer Ex(myCurrentWire.Wire());
+ TopoDS_Vertex V1;
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ V1 = TopExp::LastVertex(myPreviousEdge);
+ else
+ V1 = TopExp::FirstVertex(myPreviousEdge);
+ myCurrentWire.Add(BRepBuilderAPI_MakeEdge(V1,myFirstPointSketch).Edge());
+ myEdgesNumber++;
+ return myCurrentWire.Wire();
+ }
+ else
+ return TopoDS_Wire();
+}
+
+
+
+/*!
+ Clear sketch presentation.
+*/
+void Sketch::Clear()
+{
+ myCurrentStatus = END_SKETCH;
+ myInteractiveContext->CloseAllContexts();
+ myInteractiveContext->EraseAll(Standard_False);
+}
+
+/*!
+ Terminate sketch without closing.
+
+ \return TopoDS_Wire. Return null shape if not possible.
+*/
+TopoDS_Wire Sketch::End()
+{
+ myCurrentStatus = END_SKETCH;
+ myInteractiveContext->CloseAllContexts();
+ myInteractiveContext->EraseAll(Standard_False);
+ if (myCurrentWire.IsDone()) {
+ return myCurrentWire.Wire();
+ }
+ else
+ return TopoDS_Wire();
+}
+
+
+/*!
+ Delete current edge.
+*/
+Standard_Boolean Sketch::Delete()
+{
+ myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
+
+ if (myCurrentStatus == BEGIN_SKETCH) {
+ myCurrentStatus = END_SKETCH;
+ myInteractiveContext->CloseAllContexts();
+ myInteractiveContext->EraseAll(Standard_False);
+ return true;
+ }
+ else if(myCurrentStatus == SEGMENT ||
+ myCurrentStatus == ARC_CHORD ) {
+ RemoveLastEdge();
+ }
+ else if(myCurrentStatus == ARC_CHORD_END) {
+ myCurrentStatus = ARC_CHORD;
+ myInteractiveContext->CloseAllContexts();
+ }
+ gp_Pnt pt;
+ if (myEdgesNumber == 0) {
+ //myInteractiveContext->EraseAll(Standard_False);
+ ChangeMode(BEGIN_SKETCH); // DCQ
+ pt = BRep_Tool::Pnt(myFirstPointSketch);
+ }
+ else {
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD )
+ pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge)));
+ else
+ pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge)));
+ }
+ gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt);
+ myLastX = pt2d.X();
+ myLastY = pt2d.Y();
+
+ return false;
+}
+
+/*!
+ Set a specific plane for sketch.
+
+ \param GeomyPlane
+*/
+void Sketch::SetPlane(const Handle(Geom_Plane)& aPlane)
+{
+ myPlane = aPlane;
+}
+
+/*!
+ Set display parameters.
+
+ \param aColor
+*/
+void Sketch::SetWireColor(const Quantity_Color& aColor)
+{
+ myWireColor = aColor;
+}
+
+/*!
+ Set display parameters.
+
+ \param aColor
+*/
+void Sketch::SetCurrentColor(const Quantity_Color& aColor)
+{
+ myCurrentColor = aColor;
+}
+
+/*!
+ Set display parameters.
+
+ \param aColor
+*/
+void Sketch::SetAxisColor(const Quantity_Color& aColor)
+{
+ myAxisColor = aColor;
+}
+
+
+/*!
+ Change mode of construction line.
+
+ \param aMode : SEGMENT, ARC_CHORD.
+*/
+void Sketch::ChangeMode(const SketchStatus aMode)
+{
+ gp_Pnt2d p;
+ if (myEdgesNumber > 0) {
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
+ else
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
+ myLastX = p.X();
+ myLastY = p.Y();
+ myInteractiveContext->CloseLocalContext(myInteractiveContext->IndexOfCurrentLocal());
+ }
+ if (!myCurrentStatus == BEGIN_SKETCH)
+ myCurrentStatus = aMode; /* change the mode only when the sketch is not in state BEGIN_SKETCH, i.d. fist point has been fixed */
+
+}
+
+/*!
+ Set transition constraint between consecutive edges.
+
+ \param aStatus : NOCONSTRAINT, TANGENT, PERPENDICULAR, ANGLE, LENGTH_FIXED, X_FIXED, Y_FIXED.
+*/
+void Sketch::SetTransitionStatus(const TransitionStatus aStatus)
+{
+ myTransitionStatus = aStatus;
+}
+
+/*!
+ Set or unset the display of dimensions.
+
+ \param atype
+ \param OnOff
+*/
+void Sketch::SetParameterVisibility(const TypeOfParameter atype, const Standard_Boolean OnOff)
+{
+ switch (atype) {
+ case ANGLE_PARAMETER:
+ myIsAngleDimensionVisible = OnOff;
+ if (!myIsAngleDimensionVisible && !myAngleDimension.IsNull())
+ myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False);
+ //else DCQ
+ // DisplayCurrentEdge();
+ break;
+ case LENGTH_PARAMETER:
+ myIsLengthDimensionVisible = OnOff;
+ if (!myIsLengthDimensionVisible&& !myLengthDimension.IsNull())
+ myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False);
+ //else DCQ
+ // DisplayCurrentEdge();
+ break;
+ case RADIUS_PARAMETER:
+ myIsRadiusDimensionVisible = OnOff;
+ if (!myIsRadiusDimensionVisible&& !myRadiusDimension.IsNull()){
+ myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False);
+ myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False);
+ }
+ //else DCQ
+ // DisplayCurrentEdge();
+ break;
+ case XVALUE_PARAMETER:
+ myIsXDimensionVisible = OnOff;
+ if (!myIsXDimensionVisible&& !myXDimension.IsNull())
+ myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
+ break;
+ case YVALUE_PARAMETER:
+ myIsYDimensionVisible = OnOff;
+ if (!myIsYDimensionVisible&& !myYDimension.IsNull())
+ myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
+ break;
+ }
+}
+
+/*!
+ Hilight parameters.
+
+ \param atype
+ \param acolor
+*/
+void Sketch::HiligthWithColor(const TypeOfParameter atype, const Quantity_NameOfColor acolor)
+{
+ switch (atype) {
+ case ANGLE_PARAMETER:
+ myInteractiveContext->HilightWithColor(myAngleDimension, acolor);
+ break;
+ case LENGTH_PARAMETER:
+ myInteractiveContext->HilightWithColor(myLengthDimension, acolor);
+ break;
+ case RADIUS_PARAMETER:
+ myInteractiveContext->HilightWithColor(myRadiusDimension, acolor);
+ break;
+ case XVALUE_PARAMETER:
+ myInteractiveContext->HilightWithColor(myXDimension, acolor);
+ break;
+ case YVALUE_PARAMETER:
+ myInteractiveContext->HilightWithColor(myYDimension, acolor);
+ break;
+ }
+}
+
+
+/*!
+ Unhilight parameters.
+
+ \param atype
+*/
+void Sketch::Unhiligth(const TypeOfParameter atype)
+{
+ switch (atype) {
+ case ANGLE_PARAMETER:
+ myInteractiveContext->Unhilight(myAngleDimension);
+ break;
+ case LENGTH_PARAMETER:
+ myInteractiveContext->Unhilight(myLengthDimension);
+ break;
+ case RADIUS_PARAMETER:
+ myInteractiveContext->Unhilight(myRadiusDimension);
+ break;
+ case XVALUE_PARAMETER:
+ myInteractiveContext->Unhilight(myXDimension);
+ break;
+ case YVALUE_PARAMETER:
+ myInteractiveContext->Unhilight(myYDimension);
+ break;
+ }
+}
+
+/*!
+ Check if the edition of a type of parameter is relevant depending on sketch current status.
+
+ \param atype
+ \return Standard_Boolean
+*/
+Standard_Boolean Sketch::IsValidCurrentParameter(const TypeOfParameter atype)
+{
+ switch (atype) {
+ case ANGLE_PARAMETER:
+ if (myCurrentStatus != SEGMENT && myCurrentStatus != ARC_CHORD)
+ return Standard_False;
+ else if (myTransitionStatus == TANGENT || myTransitionStatus == PERPENDICULAR)
+ return Standard_False;
+ else if (myEdgesNumber < 1)
+ return Standard_False;
+ else {
+ TopLoc_Location L;
+ Standard_Real First,Last;
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
+ if (!PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line)))
+ return Standard_False;
+ }
+ break;
+ case LENGTH_PARAMETER:
+ if (myCurrentStatus != SEGMENT &&
+ myCurrentStatus != ARC_CHORD /*&&
+ myCurrentStatus != CURVE_POINTS*/
+ )
+ return Standard_False;
+ else if (myTransitionStatus == LENGTH_FIXED)
+ return Standard_False;
+ break;
+ case RADIUS_PARAMETER:
+ if (myCurrentStatus != ARC_CHORD_END)
+ return Standard_False;
+ break;
+ case XVALUE_PARAMETER:
+ if (myCurrentStatus != SEGMENT &&
+ myCurrentStatus != ARC_CHORD /*&&
+ myCurrentStatus != CURVE_POINTS*/
+ )
+ return Standard_False;
+ else if (myTransitionStatus == X_FIXED)
+ return Standard_False;
+ break;
+ case YVALUE_PARAMETER:
+ if (myCurrentStatus != SEGMENT &&
+ myCurrentStatus != ARC_CHORD /*&&
+ myCurrentStatus != CURVE_POINTS*/
+ )
+ return Standard_False;
+ else if (myTransitionStatus == Y_FIXED)
+ return Standard_False;
+ break;
+ }
+ return Standard_True;
+}
+
+/*!
+ Set a parameter value.
+
+ \param atype
+ \param aValue
+*/
+void Sketch::SetParameterValue(const TypeOfParameter atype, Standard_Real aValue)
+{
+ switch (atype) {
+ case ANGLE_PARAMETER:
+ SetSegmentAngle(aValue);
+ break;
+ case LENGTH_PARAMETER:
+ SetDimension(aValue);
+ break;
+ case RADIUS_PARAMETER:
+ SetDimension(aValue);
+ break;
+ case XVALUE_PARAMETER:
+ SetXDimension(aValue);
+ break;
+ case YVALUE_PARAMETER:
+ SetYDimension(aValue);
+ break;
+ }
+}
+
+/*!
+ Initialisation of sketch parameters or options.
+*/
+void Sketch::Init()
+{
+ myPlane = new Geom_Plane (0.,0.,1.,0.);
+ CreateConstraints();
+ BRepLib::Plane(myPlane);
+ myEdgesNumber = 0;
+ myCurrentStatus = BEGIN_SKETCH;
+ /* In order to update the visulisation of current objects by using Redisplay method from InteractiveContext */
+ myCurrentEdge = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));
+ myPresentableEdge = new AIS_Shape(myCurrentEdge);
+ myPresentableEdge->SetColor(myCurrentColor.Name());
+ myInteractiveContext->Display(myPresentableEdge);
+ myTransitionStatus = NOCONSTRAINT;
+ /* Init for display objects */
+ TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));
+ TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10.,0.,0.));
+ myLengthDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString());
+ myXDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE,
+ AIS_TOD_Horizontal);
+ myYDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE,
+ AIS_TOD_Vertical);
+ myRadiusDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString());
+ myCenterCircle = new AIS_Shape(V1);
+ myIsLengthDimensionVisible = Standard_False;
+ myIsXDimensionVisible = Standard_False;
+ myIsYDimensionVisible = Standard_False;
+ myIsRadiusDimensionVisible = Standard_False;
+}
+
+/*!
+ Build the current segment.
+
+ \param X
+ \param Y
+*/
+void Sketch::MakeCurrentSegment(Standard_Real X, Standard_Real Y)
+{
+ if (myTransitionStatus == NOCONSTRAINT)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y));
+ else if (myTransitionStatus == X_FIXED)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(mySegmentX,Y));
+ else if (myTransitionStatus == Y_FIXED)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(X,mySegmentY));
+ else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) {
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
+ gp_Pnt2d p1;
+ gp_Vec2d Vt;
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ C->D1(last,p1,Vt);
+ else
+ C->D1(first,p1,Vt);
+ gp_Lin2d aline(p1,Vt);
+ Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(aline));
+ if (proj.NbPoints() > 0)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1));
+ }
+ else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) {
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
+ gp_Pnt2d p1;
+ gp_Lin2d perpen;
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ C->D0(last,p1);
+ else
+ C->D0(first,p1);
+ if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d());
+ perpen = aSol.ThisSolution(1);
+ }
+ else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
+ GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d());
+ perpen = aSol.ThisSolution(1);
+ }
+ Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(perpen));
+ if (proj.NbPoints() > 0)
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1));
+ }
+ else if (myTransitionStatus == ANGLE && myEdgesNumber > 0) {
+ Standard_Real First,Last;
+ TopLoc_Location L;
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
+ if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
+ Standard_Real angle;
+ if (0 <= mySegmentAngle && mySegmentAngle<= PI )
+ angle = PI - mySegmentAngle;
+ else
+ angle = mySegmentAngle - PI;
+ GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle);
+ Standard_Real dist = RealLast();
+ gp_Pnt2d pt(X,Y),ptproj;
+ for (Standard_Integer i =1; i<=aSol.NbSolutions(); i++) {
+ Geom2dAPI_ProjectPointOnCurve proj(pt,new Geom2d_Line(aSol.ThisSolution(i)));
+ if (pt.Distance(proj.Point(1)) < dist) {
+ dist = pt.Distance(proj.Point(1));
+ ptproj = proj.Point(1);
+ }
+ }
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),ptproj);
+ }
+ }
+ else if (myTransitionStatus == LENGTH_FIXED && myEdgesNumber > 0) {
+ Standard_Real First,Last;
+ TopLoc_Location L;
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
+ if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
+ gp_Lin2d aline = gce_MakeLin2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y));
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aline,0.,mySegmentLength);
+ }
+ }
+}
+
+/*!
+ Build the current arc.
+
+ \param X
+ \param Y
+*/
+void Sketch::MakeCurrentArc(Standard_Real X, Standard_Real Y)
+{
+ gp_Circ2d CircSol;
+ Standard_Boolean OK(Standard_False);
+
+ if (myTransitionStatus == NOCONSTRAINT) {
+ GccAna_Circ2d2TanOn aSol(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y),myMediatrice->Lin2d(),Precision::Confusion());
+ if (aSol.NbSolutions() > 0){
+ CircSol = aSol.ThisSolution(1);
+ OK = Standard_True;
+ }
+ }
+ /* Tangency with previous edge */
+ else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) {
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
+ if (C->IsKind(STANDARD_TYPE(Geom2d_Line))){
+ GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Line)::DownCast(C)->Lin2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
+ if (aSol.NbSolutions() > 0){
+ CircSol = aSol.ThisSolution(1);
+ OK = Standard_True;
+ }
+ }
+ else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
+ GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Circle)::DownCast(C)->Circ2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
+ if (aSol.NbSolutions() > 0){
+ CircSol = aSol.ThisSolution(1);
+ OK = Standard_True;
+ }
+ }
+ else if(C->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) {
+ gp_Pnt2d pc;
+ gp_Vec2d Vt;
+ C->D1(last,pc,Vt);
+ gp_Lin2d alin2d(pc,gp_Dir2d(Vt));
+ GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(alin2d), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
+ if (aSol.NbSolutions() > 0){
+ CircSol = aSol.ThisSolution(1);
+ OK = Standard_True;
+ }
+ }
+ }
+ /* Tangency with the perpendicular to the previous edge */
+ else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) {
+ Standard_Real first,last;
+ TopLoc_Location L;
+ Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
+ gp_Pnt2d p1;
+ gp_Lin2d perpen;
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ C->D0(last,p1);
+ else
+ C->D0(first,p1);
+ if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d());
+ perpen = aSol.ThisSolution(1);
+ }
+ else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
+ GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d());
+ perpen = aSol.ThisSolution(1);
+ }
+ GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(perpen), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
+ if (aSol.NbSolutions() > 0){
+ CircSol = aSol.ThisSolution(1);
+ OK = Standard_True;
+ }
+ }
+
+ gp_Pnt2d p;
+ if (myEdgesNumber > 0) {
+ if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
+ else
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
+ }
+ else
+ p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch));
+ if (OK){
+ gp_Vec2d V1(p,gp_Pnt2d(X,Y));
+ gp_Vec2d V2(p,gp_Pnt2d(myLastX,myLastY));
+ if (V1.Angle(V2) > 0 )
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,p,gp_Pnt2d(myLastX,myLastY));
+ else {
+ myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,gp_Pnt2d(myLastX,myLastY),p);
+ myCurrentEdge.Reverse();
+ }
+ }
+ else {
+ myCurrentStatus = ARC_CHORD;
+ myLastX = p.X();
+ myLastY = p.Y();
+ myInteractiveContext->CloseLocalContext();
+ }
+
+}
+
+/*!
+ Display the current edge under construction with it's dimension.
+*/
+void Sketch::DisplayCurrentEdge()
+{
+ myPresentableEdge->Set(myCurrentEdge);
+ myInteractiveContext->Redisplay(myPresentableEdge);
+ if (myCurrentStatus == SEGMENT ||
+ myCurrentStatus == ARC_CHORD ) {
+ /* Length dimension */
+ TopoDS_Vertex V1 = TopExp::FirstVertex(TopoDS::Edge(myCurrentEdge));
+ TopoDS_Vertex V2 = TopExp::LastVertex(TopoDS::Edge(myCurrentEdge));
+ DisplayLengthDimension(V1,V2);
+ /* Angular dimension */
+ DisplayAngleDimension();
+ DisplayXDimension(V1,V2);
+ DisplayYDimension(V1,V2);
+ }
+ else if (myCurrentStatus == ARC_CHORD_END )
+ DisplayRadiusDimension();
+ else {
+ TopoDS_Vertex V1 = TopoDS::Vertex(myCurrentEdge);
+ TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));
+ DisplayXDimension(V1,V2);
+ DisplayYDimension(V1,V2);
+ }
+
+}
+
+/*!
+ Display the current length dimension.
+
+ \param V1
+ \param V2
+*/
+void Sketch::DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
+{
+ gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
+ gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
+ Standard_Real length = p1.Distance(p2);
+ if (length <= Precision::Confusion()) return;
+ myLengthDimension->SetFirstShape(V1);
+ myLengthDimension->SetSecondShape(V2);
+ fitInResol(length);
+ myLengthDimension->SetValue(length);
+ QString S;
+ S.sprintf("%.1f",length);
+ myLengthDimension->SetText(TCollection_ExtendedString(strdup(S)));
+ if (myIsLengthDimensionVisible) {
+ if (myInteractiveContext->IsDisplayed(myLengthDimension))
+ myInteractiveContext->Redisplay(myLengthDimension);
+ else
+ myInteractiveContext->Display(myLengthDimension);
+ }
+}
+
+/*!
+ Display the current X dimension.
+
+ \param V1
+ \param V2
+*/
+void Sketch::DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
+{
+ if (myTransitionStatus != X_FIXED) {
+ gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
+ gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
+
+ gp_Lin aline(p1,myPlane->Pln().XAxis().Direction());
+ GeomAPI_ProjectPointOnCurve proj(p2,new Geom_Line(aline));
+
+ gp_Pnt pb = p1;
+
+ if (proj.NbPoints() > 0) {
+ Standard_Real length = p1.Distance(proj.Point(1));
+ if (length <= Precision::Confusion()) return;
+ myXDimension->SetFirstShape(V1);
+ myXDimension->SetSecondShape(V2);
+ fitInResol(length);
+ myXDimension->SetValue(length);
+ QString S;
+ S.sprintf("%.1f",length);
+ myXDimension->SetText(TCollection_ExtendedString(strdup(S)));
+ // myXDimension->SetPosition(proj.Point(1));
+ pb.BaryCenter(5,proj.Point(1),5);
+ myXDimension->SetPosition(pb);
+ if (myIsXDimensionVisible) {
+ if (myInteractiveContext->IsDisplayed(myXDimension))
+ myInteractiveContext->Redisplay(myXDimension);
+ else
+ myInteractiveContext->Display(myXDimension);
+ }
+ }
+ } else
+ myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
+}
+
+/*!
+ Display the current Y dimension.
+
+ \param V1
+ \param V2
+*/
+void Sketch::DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
+{
+ if (myTransitionStatus != Y_FIXED) {
+
+ gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
+ gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
+ gp_Lin aline(p2 /*p1*/, myPlane->Pln().YAxis().Direction());
+ gp_Pnt pb = p2 /*p1*/;
+ GeomAPI_ProjectPointOnCurve proj(p1 /*p2*/,new Geom_Line(aline));
+ if (proj.NbPoints() > 0) {
+ Standard_Real length = /*p1*/ p2.Distance(proj.Point(1));
+ if (length <= Precision::Confusion()) return;
+ myYDimension->SetFirstShape(V1);
+ myYDimension->SetSecondShape(V2);
+ fitInResol(length);
+ myYDimension->SetValue(length);
+ QString S;
+ S.sprintf("%.1f",length);
+ myYDimension->SetText(TCollection_ExtendedString(strdup(S)));
+ pb.BaryCenter(5,proj.Point(1),5);
+ myYDimension->SetPosition(pb);
+ // myYDimension->SetPosition(p2);
+ if (myIsYDimensionVisible) {
+ if (myInteractiveContext->IsDisplayed(myYDimension))
+ myInteractiveContext->Redisplay(myYDimension);
+ else
+ myInteractiveContext->Display(myYDimension);
+ }
+ }
+ } else
+ myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
+}
+
+/*!
+ Display the current angle dimension.
+*/
+void Sketch::DisplayAngleDimension()
+{
+ if (!myIsAngleDimensionVisible)
+ return;
+ if (myEdgesNumber > 0) {
+ Standard_Real First,Last;
+ TopLoc_Location L;
+ Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
+ Handle (Geom2d_Curve) CurrentCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,First,Last);
+ if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) && CurrentCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
+ Standard_Real angle = Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d().Angle(Handle(Geom2d_Line)::DownCast(CurrentCurve)->Lin2d());
+ gp_Pnt2d apos;
+ if (0 <= angle && angle<= PI)
+ angle = PI - angle;
+ else
+ angle = PI + angle;
+ CurrentCurve->D0((First+Last)/5.,apos);
+ gp_Pnt apos3d = ElCLib::To3d(myPlane->Pln().Position().Ax2(),apos);
+ Standard_Real angtext = angle*180./PI;
+ mySegmentAngle = angle;
+ BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge));
+ fitInResol(angtext);
+
+ QString S;
+ S.sprintf("%.1f",angtext);
+ if (myInteractiveContext->IndexOfCurrentLocal() == 0) {
+ myInteractiveContext->OpenLocalContext();
+ myAngleDimension = new AIS_AngleDimension(myPreviousEdge,TopoDS::Edge(myCurrentEdge),myPlane,angle,
+ TCollection_ExtendedString(strdup(S)));
+ myInteractiveContext->Display(myAngleDimension);
+ }
+ else {
+ myAngleDimension->SetSecondShape(myCurrentEdge);
+ myAngleDimension->SetValue(angle);
+ myAngleDimension->SetPosition(apos3d);
+ myAngleDimension->SetText(TCollection_ExtendedString(strdup(S)));
+ myInteractiveContext->Redisplay(myAngleDimension);
+ }
+ }
+ }
+}
+
+/*!
+ Display the current radius dimension.
+*/
+void Sketch::DisplayRadiusDimension()
+{
+ if (! myIsRadiusDimensionVisible)
+ return;
+ BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge));
+ Standard_Real First,Last;
+ Handle (Geom_Circle) C = Handle (Geom_Circle)::DownCast(BRep_Tool::Curve(TopoDS::Edge(myCurrentEdge),First,Last));
+ if (!C.IsNull()) {
+ Standard_Real R = C->Radius();
+ TopoDS_Shape V1 = BRepBuilderAPI_MakeVertex(C->Location());
+ gp_Pnt MidlePoint ;
+ C->D0((First+Last)/2.,MidlePoint);
+ TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(MidlePoint);
+ myRadiusDimension->SetFirstShape(V1);
+ myRadiusDimension->SetSecondShape(V2);
+ myRadiusDimension->SetValue(R);
+ fitInResol(R);
+ QString S;
+ S.sprintf("%.1f",R);
+ myRadiusDimension->SetText(TCollection_ExtendedString(strdup(S)));
+ if (myInteractiveContext->IsDisplayed(myRadiusDimension))
+ myInteractiveContext->Redisplay(myRadiusDimension);
+ else
+ myInteractiveContext->Display(myRadiusDimension);
+ myCenterCircle->Set(V1);
+ if (myInteractiveContext->IsDisplayed(myCenterCircle))
+ myInteractiveContext->Redisplay(myCenterCircle);
+ else
+ myInteractiveContext->Display(myCenterCircle);
+ }
+}
+
+/*!
+ Remove last edge from the current wire.
+*/
+void Sketch::RemoveLastEdge()
+{
+ if (myEdgesNumber == 0) {
+ myCurrentStatus = END_SKETCH;
+ myInteractiveContext->CloseAllContexts();
+ myInteractiveContext->EraseAll(Standard_False);
+ return;
+ }
+ else {
+ BRepTools_WireExplorer Ex;
+ BRepBuilderAPI_MakeWire MW;
+ Standard_Integer index = 1;
+ myCurrentEdge = myPreviousEdge;
+ for (Ex.Init(myCurrentWire.Wire());Ex.More();Ex.Next()){
+ if (index <= myEdgesNumber-1) {
+ MW.Add(Ex.Current());
+ myPreviousEdge = Ex.Current();
+ index++;
+ }
+ }
+ myCurrentWire = MW;
+ myCurrentStatus = (SketchStatus)myConstructionMode(myEdgesNumber);
+ myTransitionStatus = (TransitionStatus)myConstraintMode(myEdgesNumber);
+ myEdgesNumber--;
+ myConstructionMode.Remove(index);
+ myConstraintMode.Remove(index);
+ if (myEdgesNumber == 0)
+ myPresentableWire->Set(myFirstPointSketch);
+ else
+ myPresentableWire->Set(myCurrentWire.Wire());
+ myInteractiveContext->Redisplay(myPresentableWire);
+ myInteractiveContext->CloseLocalContext();
+ myPresentableEdge->Set(myCurrentEdge);
+ myInteractiveContext->Redisplay(myPresentableEdge);
+ }
+}
+
+/*!
+ Create initial constraints.
+*/
+void Sketch::CreateConstraints()
+{
+ Handle(Geom_Axis1Placement) xAxis = new Geom_Axis1Placement(myPlane->Pln().XAxis());
+ Handle(Geom_Axis1Placement) yAxis = new Geom_Axis1Placement(myPlane->Pln().YAxis());
+ myHAxis = new AIS_Axis(xAxis);
+ myVAxis = new AIS_Axis(yAxis);
+ myAngularAxis = myVAxis;
+ myHAxis->SetColor(myAxisColor.Name());
+ myVAxis->SetColor(myAxisColor.Name());
+ myAngularAxis->SetColor(myAxisColor.Name());
+}
+
+/*!
+ fitInResol.
+
+ \param toFit
+ \param minIsResol
+*/
+void Sketch::fitInResol(Standard_Real &toFit, Standard_Boolean minIsResol)
+{
+ Standard_Real sign = (toFit < 0) ? -1. : +1.;
+ Standard_Real value = toFit + sign * resol/2.0; /* why "+ resol/2.0" ? because if resol = 0.5, 3.3 is rounded to 3.5 */
+ int nTimesResol = int(value/resol);
+ if ((nTimesResol == 0) && (minIsResol)) nTimesResol = 1;
+ toFit = nTimesResol*resol;
+}
+
+SketchStatus Sketch::GetCurrentStatus()
+{
+ return myCurrentStatus;
+}
+
+Standard_Integer Sketch::GetmyEdgesNumber()
+{
+ return myEdgesNumber;
+}
+
+
+
--- /dev/null
+// GEOM SKETCHER : basic sketcher
+//
+// 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_Sketcher.h
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+#include "GEOM_SketcherStatus.h"
+
+#include <V3d_Viewer.hxx>
+#include <V3d_View.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <Geom_Plane.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_Axis.hxx>
+#include <TopoDS_Edge.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_RadiusDimension.hxx>
+#include <AIS_AngleDimension.hxx>
+#include <Geom2d_Line.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
+#include <TColgp_SequenceOfPnt2d.hxx>
+#include <gp_Vec2d.hxx>
+
+class Sketch
+{
+public:
+ Sketch();
+ ~Sketch();
+ Sketch(const Handle(V3d_Viewer)& aViewer);
+ Sketch(const Handle(V3d_Viewer)& aViewer,
+ const Quantity_Color& anAxisColor,
+ const Quantity_Color& aCurrentColor,
+ const Quantity_Color& aWireColor);
+
+ static void fitInResol(Standard_Real &toFit,
+ Standard_Boolean minIsResol = Standard_False);
+
+ void MakeCurrentEdge(const Standard_Integer Xp ,
+ const Standard_Integer Yp ,
+ const Handle(V3d_View)& aView );
+
+ void MakeCurrentEdge(const Standard_Real X, const Standard_Real Y);
+
+ Standard_Boolean SetDimension(Standard_Real& aValue);
+ void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
+
+ void SetXDimension(Standard_Real& deltaX);
+ void SetYDimension(Standard_Real& deltaY);
+
+ void SetSegmentAngle(Standard_Real& aValue);
+ Standard_Real GetSegmentAngle();
+
+ void ValidateEdge();
+
+ TopoDS_Wire Close();
+ TopoDS_Wire End();
+
+ void Clear();
+
+ Standard_Boolean Delete();
+
+ void SetPlane(const Handle(Geom_Plane)& aPlane);
+
+ void SetWireColor(const Quantity_Color& aColor);
+ void SetCurrentColor(const Quantity_Color& aColor);
+ void SetAxisColor(const Quantity_Color& aColor);
+
+ void SetParameterVisibility(const TypeOfParameter atype,
+ const Standard_Boolean OnOff);
+
+ void HiligthWithColor(const TypeOfParameter atype,
+ const Quantity_NameOfColor acolor);
+ void Unhiligth(const TypeOfParameter atype);
+
+ Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
+
+ void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
+
+ void ChangeMode(const SketchStatus aMode);
+
+ void SetTransitionStatus(const TransitionStatus aStatus);
+
+ SketchStatus GetCurrentStatus();
+ Standard_Integer GetmyEdgesNumber();
+
+private :
+
+ void Init();
+
+ void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
+
+ void MakeCurrentArc(Standard_Real X, Standard_Real Y);
+
+ void DisplayCurrentEdge();
+
+ void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
+ void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
+ void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
+ void DisplayAngleDimension();
+ void DisplayRadiusDimension();
+
+ void AddEdgeToWire();
+
+ void RemoveLastEdge();
+
+ void CreateConstraints();
+
+private:
+ // Current status of construction
+ SketchStatus myCurrentStatus;
+ // Transition status between arcs and segments
+ TransitionStatus myTransitionStatus;
+ // Current wire
+ BRepBuilderAPI_MakeWire myCurrentWire;
+ // Current presentable wire
+ Handle_AIS_Shape myPresentableWire;
+ // Number of edges into the current wire
+ Standard_Integer myEdgesNumber;
+ // Store for each edge how it has been built i.d the value of myCurrentStatus
+ TColStd_SequenceOfInteger myConstructionMode;
+ // Store for each edge how it has been built i.d the value of myTransitionStatus
+ TColStd_SequenceOfInteger myConstraintMode;
+ // Current edge
+ TopoDS_Shape myCurrentEdge;
+ // Previous edge
+ TopoDS_Edge myPreviousEdge;
+ // List of points to interpolate when computing a curve by interpolation
+ TColgp_SequenceOfPnt2d myPointsToInterpolate;
+ // Tangent vector at beginning of curve
+ gp_Vec2d myTangentVector;
+ // Tangent flag at beginning og curve
+ Standard_Boolean myTangentFlag;
+
+ // Origin of sketch
+ TopoDS_Vertex myFirstPointSketch;
+ // Last x coordinate of end point of previous edge or picked point
+ Standard_Real myLastX;
+ // Last y coordinate of end point of previous edge or picked point
+ Standard_Real myLastY;
+ // angle between 2 segments when an ANGLE TransitionStatus is set.
+ Standard_Real mySegmentAngle;
+ // Length of segment when the length of the segment is fixed before the angle
+ Standard_Real mySegmentLength;
+ // Value of X fixed coordinate
+ Standard_Real mySegmentX;
+ // Value of Y fixed Coordinate
+ Standard_Real mySegmentY;
+ Handle_AIS_Shape myPresentableEdge; // Current presentable edge
+ Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
+ Handle_AIS_LengthDimension myXDimension; // For display of current X segment dimension
+ Handle_AIS_LengthDimension myYDimension; // For display of current Y segment dimension
+ Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
+ Handle_AIS_AngleDimension myAngleDimension; // For display of current angle dimension
+ Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
+ Standard_Boolean myIsXDimensionVisible; // Visibility flag for X Dimension
+ Standard_Boolean myIsYDimensionVisible; // Visibility flag for Y Dimension
+ Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
+ Standard_Boolean myIsAngleDimensionVisible; // Visibility flag for AngleDimension
+ Handle_AIS_Axis myPresentableMediatrice; // Chord mediatrice of current circle as a presentable object
+ Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
+ Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
+
+ Handle_AIS_Axis myHAxis; // Horizontal axis
+ Handle_AIS_Axis myVAxis; // Vertical axis
+ Handle_AIS_Axis myAngularAxis; // Axis making a predefined angle with the previous edge
+
+ Quantity_Color myWireColor; // Color of wire and of build edges
+ Quantity_Color myCurrentColor; // Color of edge under construction
+ Quantity_Color myAxisColor; // Color for axis
+ Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
+
+ Handle_Geom_Plane myPlane; // Plane of sketch
+
+ BRepBuilderAPI_MakeWire myPasteWire;
+ Standard_Integer myPasteEdgesNumber;
+ TColStd_SequenceOfInteger myPasteConstructionMode;
+ TColStd_SequenceOfInteger myPasteConstraintMode;
+};
--- /dev/null
+// GEOM SKETCHER : basic sketcher
+//
+// 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_SketcherStatus.h
+// Author : Nicolas REJNERI
+// Module : GEOM
+// $Header$
+
+enum TransitionStatus {
+ NOCONSTRAINT, // no constraint between consecutive edges
+ TANGENT, // arc and segment are tangent
+ PERPENDICULAR,// arc is tangent to the perpendicular to the segment
+ ANGLE, // Angular constraint between 2 segments
+ LENGTH_FIXED, // Length of segment has been fixed
+ X_FIXED, // X coordinate for segment has been fixed
+ Y_FIXED // Y coordinate for segment has been fixed
+ };
+
+enum TypeOfParameter {
+ ANGLE_PARAMETER,
+ LENGTH_PARAMETER,
+ RADIUS_PARAMETER,
+ XVALUE_PARAMETER,
+ YVALUE_PARAMETER
+ };
+
+enum SketchStatus {
+ BEGIN_SKETCH, // Begin sketch; no edges created yet
+ SEGMENT, // Current mode for creation is segment
+ ARC_CHORD, // Current mode for creation is arc by chord
+ ARC_CHORD_END,// Chord validated, waiting for radius or center
+ END_SKETCH // End sketch
+};
--- /dev/null
+# GEOM SKETCHER : basic sketcher
+#
+# 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 = libGeometrySketcher.la
+LIB_SRC = GEOM_Sketcher.cxx
+LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
+
+# header files
+EXPORT_HEADERS= GEOM_Sketcher.h \
+ GEOM_SketcherStatus.h
+
+# 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@
+