0016757: EDF 546 GEOM : Add Face and Disc in geom primitives

This commit is contained in:
dmv 2008-08-04 11:10:28 +00:00
parent 89737a2aea
commit 04a3a47a3c
36 changed files with 2509 additions and 6 deletions

View File

@ -821,6 +821,42 @@ module GEOM
*/
GEOM_Object MakeBoxTwoPnt (in GEOM_Object thePnt1, in GEOM_Object thePnt2);
/*!
* Create a face specified dimensions along OX-OY coordinate axes,
* with edges parallel to the coordinate axes.
* Center of the face will be at point (0, 0, 0).
* \param theH length of Face edge, parallel to OX axis.
* \param theW lenght of Face edge, patallel to OY axis.
* \return New GEOM_Object, containing the created face.
*/
GEOM_Object MakeFaceHW (in double theH, in double theW);
/*!
* Create a face by another plane and two specified sizes,
* vertical (H) and horisontal (W).
* \param theFace defines plane.
* \param theH vertical size (height).
* \param theW horisontal size (width).
* \return New GEOM_Object, containing the created face.
*/
GEOM_Object MakeFacePlaneHW (in GEOM_Object theFace, in double theH, in double theW);
/*!
* Create a Disk (circular face) with given center, normal vector and radius.
* \param thePnt disk center.
* \param theVec Vector, normal to the plane of the disk.
* \param theR Disk radius.
* \return New GEOM_Object, containing the created disk.
*/
GEOM_Object MakeDiskPntVecR (in GEOM_Object thePnt,
in GEOM_Object theVec,
in double theR);
/*!
* Create a disk (circular face), passing through three given points
* \param thePnt1, thePnt2, thePnt3 Points, defining the disk.
* \return New GEOM_Object, containing the created disk.
*/
GEOM_Object MakeDiskThreePnt (in GEOM_Object thePnt1,
in GEOM_Object thePnt2,
in GEOM_Object thePnt3);
/*!
* Create a cylinder with given radius and height at
* the origin of coordinate system. Axis of the cylinder

View File

@ -126,6 +126,17 @@ module GEOM
in double theDZ) ;
GEOM_Object MakeBoxTwoPnt (in GEOM_Object thePnt1,
in GEOM_Object thePnt2) ;
GEOM_Object MakeFaceHW (in double theH,
in double theW) ;
GEOM_Object MakeFacePlaneHW (in GEOM_Object theFace,
in double theH,
in double theW) ;
GEOM_Object MakeDiskPntVecR (in GEOM_Object thePnt,
in GEOM_Object theVec,
in double theR) ;
GEOM_Object MakeDiskThreePnt (in GEOM_Object thePnt1,
in GEOM_Object thePnt2,
in GEOM_Object thePnt3) ;
GEOM_Object MakeCylinderPntVecRH (in GEOM_Object thePnt,
in GEOM_Object theAxis,
in double theRadius,

View File

@ -52,6 +52,8 @@
<popup-item item-id="4023" pos-id="" label-id="Sphere" icon-id="sphere.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4024" pos-id="" label-id="Torus" icon-id="torus.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4025" pos-id="" label-id="Cone" icon-id="cone.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4026" pos-id="" label-id="Face" icon-id="face.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4027" pos-id="" label-id="Face" icon-id="disk.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu>
<endsubmenu />
<submenu label-id="Generation" item-id="403" pos-id="3">
@ -229,6 +231,8 @@
<toolbutton-item item-id="4023" label-id="Sphere" icon-id="sphere.png" tooltip-id="Sphere" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4024" label-id="Torus" icon-id="torus.png" tooltip-id="Torus" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4025" label-id="Cone" icon-id="cone.png" tooltip-id="Cone" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4026" label-id="Face" icon-id="face.png" tooltip-id="Face" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4027" label-id="Disk" icon-id="disk.png" tooltip-id="Disk" accel-id="" toggle-id="" execute-action=""/>
</toolbar>
<toolbar label-id="Ope. Boolean">

View File

@ -58,6 +58,8 @@
<popup-item item-id="4023" pos-id="" label-id="Sphère" icon-id="sphere.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4024" pos-id="" label-id="Tore" icon-id="torus.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4025" pos-id="" label-id="Cone" icon-id="cone.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4026" pos-id="" label-id="Face" icon-id="face.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4027" pos-id="" label-id="Face" icon-id="disk.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu>
<endsubmenu />
<submenu label-id="Generation" item-id="403" pos-id="3">
@ -203,6 +205,8 @@
<toolbutton-item item-id="4023" label-id="Sphère" icon-id="sphere.png" tooltip-id="Construction d'une sphère" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4024" label-id="Tore" icon-id="torus.png" tooltip-id="Construction d'un tore" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4025" label-id="Cone" icon-id="cone.png" tooltip-id="Cone" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4026" label-id="Face" icon-id="face.png" tooltip-id="Face" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4027" label-id="Disk" icon-id="disk.png" tooltip-id="Disk" accel-id="" toggle-id="" execute-action=""/>
</toolbar>
<toolbar label-id="Opé. Booléennes">

View File

@ -72,11 +72,16 @@ cylinder.png \
cylinderdxyz.png \
cylinderpointvector.png \
delete.png \
disk.png \
disk3points.png \
disk_pntvecr.png \
display.png \
displayonly.png \
displayall.png \
erase.png \
eraseall.png \
face_hw.png \
face_planehw.png \
fillet.png \
filletall.png \
filletedge.png \

BIN
resources/disk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

BIN
resources/disk3points.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

BIN
resources/disk_pntvecr.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

BIN
resources/face_hw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

BIN
resources/face_planehw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

View File

@ -62,6 +62,18 @@
<source>ICON_DLG_BUILD_COMPOUND</source>
<translation>build_compound.png</translation>
</message>
<message>
<source>ICON_DLG_DISK</source>
<translation>disk.png</translation>
</message>
<message>
<source>ICON_DLG_DISK_PNT_VEC_R</source>
<translation>disk_pntvecr.png</translation>
</message>
<message>
<source>ICON_DLG_DISK_THREE_POINTS</source>
<translation>disk3points.png</translation>
</message>
<message>
<source>ICON_DLG_BUILD_EDGE</source>
<translation>build_edge.png</translation>
@ -70,6 +82,14 @@
<source>ICON_DLG_BUILD_FACE</source>
<translation>build_face.png</translation>
</message>
<message>
<source>ICON_DLG_FACE_HW</source>
<translation>face_hw.png</translation>
</message>
<message>
<source>ICON_DLG_FACE_PLANE_HW</source>
<translation>face_planehw.png</translation>
</message>
<message>
<source>ICON_DLG_BUILD_SHELL</source>
<translation>build_shell.png</translation>
@ -642,6 +662,10 @@
<source>ICO_DELETE</source>
<translation>delete.png</translation>
</message>
<message>
<source>ICO_DISK</source>
<translation>disk.png</translation>
</message>
<message>
<source>ICO_DISPLAY</source>
<translation>display.png</translation>

View File

@ -416,6 +416,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_DIAGONAL_POINTS</source>
<translation>Diagonal Points</translation>
</message>
<message>
<source>GEOM_DISK</source>
<translation>Disk</translation>
</message>
<message>
<source>GEOM_DIMENSIONS</source>
<translation>Dimensions</translation>
@ -1748,6 +1752,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_WEIGHT</source>
<translation>Weight :</translation>
</message>
<message>
<source>GEOM_WIDTH</source>
<translation>Width :</translation>
</message>
<message>
<source>GEOM_WHATIS</source>
<translation>Whatis</translation>
@ -1972,6 +1980,10 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_DISPLAY</source>
<translation>Show</translation>
</message>
<message>
<source>MEN_DISK</source>
<translation>Disk</translation>
</message>
<message>
<source>MEN_DISPLAY_ALL</source>
<translation>Show all</translation>
@ -2516,6 +2528,10 @@ Please, select face, shell or solid and try again</translation>
<source>STB_DELETE</source>
<translation>Delete object</translation>
</message>
<message>
<source>STB_DISK</source>
<translation>Create a disk</translation>
</message>
<message>
<source>STB_DISPLAY</source>
<translation>Show object(s)</translation>
@ -2566,7 +2582,7 @@ Please, select face, shell or solid and try again</translation>
</message>
<message>
<source>STB_FACE</source>
<translation>Build a face from wires and/or edges</translation>
<translation>Build a face</translation>
</message>
<message>
<source>STB_FACE_SEL_ONLY</source>
@ -2988,6 +3004,10 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_DELETE</source>
<translation>Delete object</translation>
</message>
<message>
<source>TOP_DISK</source>
<translation>Build a Disk</translation>
</message>
<message>
<source>TOP_DISPLAY</source>
<translation>Show</translation>

View File

@ -403,7 +403,9 @@ void GeometryGUI::OnGUIEvent( int id )
id == 4022 || // MENU PRIMITIVE - CYLINDER
id == 4023 || // MENU PRIMITIVE - SPHERE
id == 4024 || // MENU PRIMITIVE - TORUS
id == 4025 ) { // MENU PRIMITIVE - CONE
id == 4025 || // MENU PRIMITIVE - CONE
id == 4026 || // MENU PRIMITIVE - FACE
id == 4027 ) { // MENU PRIMITIVE - DISK
#ifndef WNT
library = getLibrary( "libPrimitiveGUI.so" );
#else
@ -759,6 +761,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( 4023, "SPHERE" );
createGeomAction( 4024, "TORUS" );
createGeomAction( 4025, "CONE" );
createGeomAction( 4026, "FACE" );
createGeomAction( 4027, "DISK" );
createGeomAction( 4031, "EXTRUSION" );
createGeomAction( 4032, "REVOLUTION" );
@ -899,6 +903,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( 4023, primId, -1 );
createMenu( 4024, primId, -1 );
createMenu( 4025, primId, -1 );
createMenu( 4026, primId, -1 );
createMenu( 4027, primId, -1 );
int genId = createMenu( tr( "MEN_GENERATION" ), newEntId, -1 );
createMenu( 4031, genId, -1 );
@ -1053,6 +1059,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( 4023, primTbId );
createTool( 4024, primTbId );
createTool( 4025, primTbId );
createTool( 4026, primTbId );
createTool( 4027, primTbId );
int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
createTool( 5011, boolTbId );

View File

@ -0,0 +1,185 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
#include <GEOMImpl_DiskDriver.hxx>
#include <GEOMImpl_IDisk.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <GC_MakeCircle.hxx>
#include <Geom_Circle.hxx>
#include <Standard_ConstructionError.hxx>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Circ.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& GEOMImpl_DiskDriver::GetID()
{
static Standard_GUID aDiskDriver("C1FEEF9D-1C6D-41ce-9507-F10D75430CE1");
return aDiskDriver;
}
//=======================================================================
//function : GEOMImpl_DiskDriver
//purpose :
//=======================================================================
GEOMImpl_DiskDriver::GEOMImpl_DiskDriver()
{
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_DiskDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IDisk aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == DISK_PNT_VEC_R) {
Handle(GEOM_Function) aRefPoint = aCI.GetCenter();
Handle(GEOM_Function) aRefVector = aCI.GetVector();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapePnt.ShapeType() == TopAbs_VERTEX &&
aShapeVec.ShapeType() == TopAbs_EDGE) {
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anE, V1, V2, Standard_True);
if (!V1.IsNull() && !V2.IsNull()) {
gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
gp_Ax2 anAxes (aP, aV);
gp_Circ aCirc (anAxes, aCI.GetRadius());
TopoDS_Shape aCircle = BRepBuilderAPI_MakeEdge(aCirc).Edge();
BRepBuilderAPI_MakeWire MW;
MW.Add(TopoDS::Edge(aCircle));
BRepBuilderAPI_MakeFace MF (MW, Standard_False);
aShape = MF.Shape();
}
}
}
else if (aType == DISK_THREE_PNT) {
Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1();
Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2();
Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3();
TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue();
TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue();
TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue();
if (aShapePnt1.ShapeType() == TopAbs_VERTEX &&
aShapePnt2.ShapeType() == TopAbs_VERTEX &&
aShapePnt3.ShapeType() == TopAbs_VERTEX) {
gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1));
gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2));
gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3));
if (aP1.Distance(aP2) < gp::Resolution() ||
aP1.Distance(aP3) < gp::Resolution() ||
aP2.Distance(aP3) < gp::Resolution())
Standard_ConstructionError::Raise("Disk creation aborted: coincident points given");
if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular()))
Standard_ConstructionError::Raise("Disk creation aborted: points lay on one line");
Handle(Geom_Circle) aCirc = GC_MakeCircle(aP1, aP2, aP3).Value();
TopoDS_Shape aCircle = BRepBuilderAPI_MakeEdge(aCirc).Edge();
BRepBuilderAPI_MakeWire MW;
MW.Add(TopoDS::Edge(aCircle));
BRepBuilderAPI_MakeFace MF (MW, Standard_False);
aShape = MF.Shape();
}
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
//=======================================================================
//function : GEOMImpl_DiskDriver_Type_
//purpose :
//=======================================================================
Standard_EXPORT Handle_Standard_Type& GEOMImpl_DiskDriver_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
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("GEOMImpl_DiskDriver",
sizeof(GEOMImpl_DiskDriver),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
//=======================================================================
//function : DownCast
//purpose :
//=======================================================================
const Handle(GEOMImpl_DiskDriver) Handle(GEOMImpl_DiskDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMImpl_DiskDriver) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_DiskDriver))) {
_anOtherObject = Handle(GEOMImpl_DiskDriver)((Handle(GEOMImpl_DiskDriver)&)AnObject);
}
}
return _anOtherObject ;
}

View File

@ -0,0 +1,158 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMImpl_DiskDriver.ixx
// Module : GEOMImpl
#ifndef _GEOMImpl_DiskDriver_HeaderFile
#define _GEOMImpl_DiskDriver_HeaderFile
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
#include <TColStd_SequenceOfExtendedString.hxx>
#endif
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
#endif
#ifndef _Handle_TFunction_Driver_HeaderFile
#include <Handle_TFunction_Driver.hxx>
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(TFunction_Driver);
class GEOMImpl_DiskDriver;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_DiskDriver);
class Handle(GEOMImpl_DiskDriver) : public Handle(TFunction_Driver) {
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);
}
Handle(GEOMImpl_DiskDriver)():Handle(TFunction_Driver)() {}
Handle(GEOMImpl_DiskDriver)(const Handle(GEOMImpl_DiskDriver)& aHandle) : Handle(TFunction_Driver)(aHandle)
{
}
Handle(GEOMImpl_DiskDriver)(const GEOMImpl_DiskDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem)
{
}
Handle(GEOMImpl_DiskDriver)& operator=(const Handle(GEOMImpl_DiskDriver)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOMImpl_DiskDriver)& operator=(const GEOMImpl_DiskDriver* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOMImpl_DiskDriver* operator->()
{
return (GEOMImpl_DiskDriver *)ControlAccess();
}
GEOMImpl_DiskDriver* operator->() const
{
return (GEOMImpl_DiskDriver *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOMImpl_DiskDriver)() {};
Standard_EXPORT static const Handle(GEOMImpl_DiskDriver) DownCast(const Handle(Standard_Transient)& AnObject);
};
#ifndef _TFunction_Driver_HeaderFile
#include <TFunction_Driver.hxx>
#endif
#ifndef _TFunction_Logbook_HeaderFile
#include <TFunction_Logbook.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
class TColStd_SequenceOfExtendedString;
class GEOMImpl_DiskDriver : public TFunction_Driver {
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 GEOMImpl_DiskDriver();
Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const;
Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; }
Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT ~GEOMImpl_DiskDriver() {};
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_DiskDriver_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_DiskDriver) ; }
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_DiskDriver) == AType || TFunction_Driver::IsKind(AType)); }
};
#endif

View File

@ -0,0 +1,148 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx>
#include <GEOMImpl_FaceDriver.hxx>
#include <GEOMImpl_IFace.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <GEOMImpl_IMeasureOperations.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <StdFail_NotDone.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& GEOMImpl_FaceDriver::GetID()
{
static Standard_GUID aFaceDriver("F7953CC1-FF8B-4628-BF5E-9D3510DE4629");
return aFaceDriver;
}
//=======================================================================
//function : GEOMImpl_FaceDriver
//purpose :
//=======================================================================
GEOMImpl_FaceDriver::GEOMImpl_FaceDriver()
{
}
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_FaceDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IFace aFI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == FACE_PLANE_H_W) {
Handle(GEOM_Function) aRefPlane = aFI.GetRef1();
TopoDS_Shape aShapePlane = aRefPlane->GetValue();
double aH = aFI.GetH() / 2.0;
double aW = aFI.GetW() / 2.0;
gp_Ax3 anAx = GEOMImpl_IMeasureOperations::GetPosition(aShapePlane);
gp_Pln aPln (anAx);
aShape = BRepBuilderAPI_MakeFace(aPln, -aH, +aH, -aW, +aW).Shape();
}
else if (aType == FACE_H_W) {
double aH = aFI.GetH() / 2.0;
double aW = aFI.GetW() / 2.0;
TopoDS_Vertex V1, V2;
gp_Pnt aP = gp::Origin();
gp_Vec aV = gp::DZ();
gp_Pln aPlane (aP, aV);
aShape = BRepBuilderAPI_MakeFace(aPlane, -aH, +aH, -aW, +aW).Shape();
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
//=======================================================================
//function : GEOMImpl_FaceDriver_Type_
//purpose :
//=======================================================================
Standard_EXPORT Handle_Standard_Type& GEOMImpl_FaceDriver_Type_()
{
static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
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("GEOMImpl_FaceDriver",
sizeof(GEOMImpl_FaceDriver),
1,
(Standard_Address)_Ancestors,
(Standard_Address)NULL);
return _aType;
}
//=======================================================================
//function : DownCast
//purpose :
//=======================================================================
const Handle(GEOMImpl_FaceDriver) Handle(GEOMImpl_FaceDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
{
Handle(GEOMImpl_FaceDriver) _anOtherObject;
if (!AnObject.IsNull()) {
if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_FaceDriver))) {
_anOtherObject = Handle(GEOMImpl_FaceDriver)((Handle(GEOMImpl_FaceDriver)&)AnObject);
}
}
return _anOtherObject ;
}

View File

@ -0,0 +1,158 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMImpl_FaceDriver.ixx
// Module : GEOMImpl
#ifndef _GEOMImpl_FaceDriver_HeaderFile
#define _GEOMImpl_FaceDriver_HeaderFile
#ifndef _TColStd_SequenceOfExtendedString_HeaderFile
#include <TColStd_SequenceOfExtendedString.hxx>
#endif
#ifndef _Standard_TypeMismatch_HeaderFile
#include <Standard_TypeMismatch.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_GUID_HeaderFile
#include <Standard_GUID.hxx>
#endif
#ifndef _Handle_TFunction_Driver_HeaderFile
#include <Handle_TFunction_Driver.hxx>
#endif
class Standard_Transient;
class Handle_Standard_Type;
class Handle(TFunction_Driver);
class GEOMImpl_FaceDriver;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_FaceDriver);
class Handle(GEOMImpl_FaceDriver) : public Handle(TFunction_Driver) {
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);
}
Handle(GEOMImpl_FaceDriver)():Handle(TFunction_Driver)() {}
Handle(GEOMImpl_FaceDriver)(const Handle(GEOMImpl_FaceDriver)& aHandle) : Handle(TFunction_Driver)(aHandle)
{
}
Handle(GEOMImpl_FaceDriver)(const GEOMImpl_FaceDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem)
{
}
Handle(GEOMImpl_FaceDriver)& operator=(const Handle(GEOMImpl_FaceDriver)& aHandle)
{
Assign(aHandle.Access());
return *this;
}
Handle(GEOMImpl_FaceDriver)& operator=(const GEOMImpl_FaceDriver* anItem)
{
Assign((Standard_Transient *)anItem);
return *this;
}
GEOMImpl_FaceDriver* operator->()
{
return (GEOMImpl_FaceDriver *)ControlAccess();
}
GEOMImpl_FaceDriver* operator->() const
{
return (GEOMImpl_FaceDriver *)ControlAccess();
}
Standard_EXPORT ~Handle(GEOMImpl_FaceDriver)() {};
Standard_EXPORT static const Handle(GEOMImpl_FaceDriver) DownCast(const Handle(Standard_Transient)& AnObject);
};
#ifndef _TFunction_Driver_HeaderFile
#include <TFunction_Driver.hxx>
#endif
#ifndef _TFunction_Logbook_HeaderFile
#include <TFunction_Logbook.hxx>
#endif
#ifndef _Standard_CString_HeaderFile
#include <Standard_CString.hxx>
#endif
class TColStd_SequenceOfExtendedString;
class GEOMImpl_FaceDriver : public TFunction_Driver {
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 GEOMImpl_FaceDriver();
Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const;
Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {}
Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; }
Standard_EXPORT static const Standard_GUID& GetID();
Standard_EXPORT ~GEOMImpl_FaceDriver() {};
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_FaceDriver_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_FaceDriver) ; }
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_FaceDriver) == AType || TFunction_Driver::IsKind(AType)); }
};
#endif

View File

@ -44,6 +44,8 @@
#include <GEOMImpl_SplineDriver.hxx>
#include <GEOMImpl_SketcherDriver.hxx>
#include <GEOMImpl_BoxDriver.hxx>
#include <GEOMImpl_FaceDriver.hxx>
#include <GEOMImpl_DiskDriver.hxx>
#include <GEOMImpl_ConeDriver.hxx>
#include <GEOMImpl_CylinderDriver.hxx>
#include <GEOMImpl_PrismDriver.hxx>
@ -101,6 +103,8 @@ GEOMImpl_Gen::GEOMImpl_Gen()
// 3D Primitives
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_BoxDriver::GetID(), new GEOMImpl_BoxDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FaceDriver::GetID(), new GEOMImpl_FaceDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_DiskDriver::GetID(), new GEOMImpl_DiskDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConeDriver::GetID(), new GEOMImpl_ConeDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_CylinderDriver::GetID(), new GEOMImpl_CylinderDriver());
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PrismDriver::GetID(), new GEOMImpl_PrismDriver());

View File

@ -36,6 +36,8 @@
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_BoxDriver.hxx>
#include <GEOMImpl_FaceDriver.hxx>
#include <GEOMImpl_DiskDriver.hxx>
#include <GEOMImpl_CylinderDriver.hxx>
#include <GEOMImpl_ConeDriver.hxx>
#include <GEOMImpl_SphereDriver.hxx>
@ -48,6 +50,8 @@
#include <GEOMImpl_ThruSectionsDriver.hxx>
#include <GEOMImpl_IBox.hxx>
#include <GEOMImpl_IFace.hxx>
#include <GEOMImpl_IDisk.hxx>
#include <GEOMImpl_ICylinder.hxx>
#include <GEOMImpl_ICone.hxx>
#include <GEOMImpl_ISphere.hxx>
@ -192,6 +196,230 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec
return aBox;
}
//=============================================================================
/*!
* MakeFaceHW
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW)
{
SetErrorCode(KO);
if (theH == 0 || theW == 0) return NULL;
//Add a new Face object
Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
//Add a new Box function for creation a box relatively to two points
Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
GEOMImpl_IFace aFI (aFunction);
aFI.SetH(theH);
aFI.SetW(theW);
//Compute the Face
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Face driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
<< theH << ", " << theW << ")";
SetErrorCode(OK);
return aFace;
}
//=============================================================================
/*!
* MakeFacePlaneHW
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFacePlaneHW (Handle(GEOM_Object) theFace,
double theH, double theW)
{
SetErrorCode(KO);
if (theFace.IsNull()) return NULL;
//Add a new Face object
Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
//Add a new Box function for creation a box relatively to two points
Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_PLANE_H_W);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
GEOMImpl_IFace aFI (aFunction);
Handle(GEOM_Function) aRefFunction1 = theFace->GetLastFunction();
if (aRefFunction1.IsNull())
return aFace;
aFI.SetRef1(aRefFunction1);
aFI.SetH(theH);
aFI.SetW(theW);
//Compute the Face
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Face driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFacePlaneHW("
<< theFace << ", " << theH << ", " << theW << ")";
SetErrorCode(OK);
return aFace;
}
//=============================================================================
/*!
* MakeDiskPntVecR
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
(Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
{
SetErrorCode(KO);
if (thePnt.IsNull() || theVec.IsNull()) return NULL;
//Add a new Disk object
Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
//Add a new Disk function for creation a disk relatively to point and vector
Handle(GEOM_Function) aFunction =
aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
GEOMImpl_IDisk aCI (aFunction);
Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
aCI.SetCenter(aRefPnt);
aCI.SetVector(aRefVec);
aCI.SetRadius(theR);
//Compute the Disk value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Disk driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
<< thePnt << ", " << theVec << ", " << theR << ")";
SetErrorCode(OK);
return aDisk;
}
//=============================================================================
/*!
* MakeDiskThreePnt
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2,
Handle(GEOM_Object) thePnt3)
{
SetErrorCode(KO);
if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
//Add a new Disk object
Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
//Add a new Disk function for creation a disk relatively to three points
Handle(GEOM_Function) aFunction =
aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
GEOMImpl_IDisk aCI (aFunction);
Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
aCI.SetPoint1(aRefPnt1);
aCI.SetPoint2(aRefPnt2);
aCI.SetPoint3(aRefPnt3);
//Compute the Disk value
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Disk driver failed");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
<< thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
SetErrorCode(OK);
return aDisk;
}
//=============================================================================
/*!

View File

@ -36,7 +36,15 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakeBoxDXDYDZ (double theDX, double theDY, double theDZ);
Standard_EXPORT Handle(GEOM_Object) MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2);
Standard_EXPORT Handle(GEOM_Object) MakeFaceHW (double theH, double theW);
Standard_EXPORT Handle(GEOM_Object) MakeFacePlaneHW (Handle(GEOM_Object) theFace,
double theH, double theW);
Standard_EXPORT Handle(GEOM_Object) MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) thePnt2,
Handle(GEOM_Object) thePnt3);
Standard_EXPORT Handle(GEOM_Object) MakeDiskPntVecR (Handle(GEOM_Object) thePnt1,
Handle(GEOM_Object) theVec,
double theR);
Standard_EXPORT Handle(GEOM_Object) MakeCylinderRH (double theR, double theH);
Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
Handle(GEOM_Object) theVec,

60
src/GEOMImpl/GEOMImpl_IDisk.hxx Executable file
View File

@ -0,0 +1,60 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//NOTE: This is an intreface to a function for the Disk creation.
#include "GEOM_Function.hxx"
#define DISK_ARG_P1 1
#define DISK_ARG_P2 2
#define DISK_ARG_P3 3
#define DISK_ARG_CC 4
#define DISK_ARG_VV 5
#define DISK_ARG_RR 6
class GEOMImpl_IDisk
{
public:
GEOMImpl_IDisk(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetPoint1(Handle(GEOM_Function) theP) { _func->SetReference(DISK_ARG_P1, theP); }
void SetPoint2(Handle(GEOM_Function) theP) { _func->SetReference(DISK_ARG_P2, theP); }
void SetPoint3(Handle(GEOM_Function) theP) { _func->SetReference(DISK_ARG_P3, theP); }
void SetCenter(Handle(GEOM_Function) theP) { _func->SetReference(DISK_ARG_CC, theP); }
void SetVector(Handle(GEOM_Function) theV) { _func->SetReference(DISK_ARG_VV, theV); }
void SetRadius(double theR) { _func->SetReal(DISK_ARG_RR, theR); }
Handle(GEOM_Function) GetPoint1() { return _func->GetReference(DISK_ARG_P1); }
Handle(GEOM_Function) GetPoint2() { return _func->GetReference(DISK_ARG_P2); }
Handle(GEOM_Function) GetPoint3() { return _func->GetReference(DISK_ARG_P3); }
Handle(GEOM_Function) GetCenter() { return _func->GetReference(DISK_ARG_CC); }
Handle(GEOM_Function) GetVector() { return _func->GetReference(DISK_ARG_VV); }
double GetRadius() { return _func->GetReal(DISK_ARG_RR); }
private:
Handle(GEOM_Function) _func;
};

57
src/GEOMImpl/GEOMImpl_IFace.hxx Executable file
View File

@ -0,0 +1,57 @@
// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//NOTE: This is an intreface to a function for the Face creation.
#include "GEOM_Function.hxx"
#define FACE_ARG_REF1 1
#define FACE_ARG_REF2 2
#define FACE_ARG_REF3 3
#define FACE_ARG_PLANE 4
#define FACE_ARG_H 5
#define FACE_ARG_W 6
class GEOMImpl_IFace
{
public:
GEOMImpl_IFace(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetRef1(Handle(GEOM_Function) theRefPoint1) { _func->SetReference(FACE_ARG_REF1, theRefPoint1); }
Handle(GEOM_Function) GetRef1() { return _func->GetReference(FACE_ARG_REF1); }
void SetRef2(Handle(GEOM_Function) theRefPoint2) { _func->SetReference(FACE_ARG_REF2, theRefPoint2); }
Handle(GEOM_Function) GetRef2() { return _func->GetReference(FACE_ARG_REF2); }
void SetRef3(Handle(GEOM_Function) theRefVec) { _func->SetReference(FACE_ARG_REF3, theRefVec); }
Handle(GEOM_Function) GetRef3() { return _func->GetReference(FACE_ARG_REF3); }
void SetH(double theH) { _func->SetReal(FACE_ARG_H, theH); }
void SetW(double theW) { _func->SetReal(FACE_ARG_W, theW); }
double GetH() { return _func->GetReal(FACE_ARG_H); }
double GetW() { return _func->GetReal(FACE_ARG_W); }
private:
Handle(GEOM_Function) _func;
};

View File

@ -158,6 +158,12 @@
#define BOX_DX_DY_DZ 1
#define BOX_TWO_PNT 2
#define FACE_PLANE_H_W 1
#define FACE_H_W 2
#define DISK_PNT_VEC_R 1
#define DISK_THREE_PNT 2
#define CYLINDER_R_H 1
#define CYLINDER_PNT_VEC_R_H 2

View File

@ -75,6 +75,8 @@ dist_libGEOMimpl_la_SOURCES = \
GEOMImpl_ScaleDriver.cxx \
GEOMImpl_PositionDriver.cxx \
GEOMImpl_BoxDriver.cxx \
GEOMImpl_FaceDriver.cxx \
GEOMImpl_DiskDriver.cxx \
GEOMImpl_ConeDriver.cxx \
GEOMImpl_CylinderDriver.cxx \
GEOMImpl_SphereDriver.cxx \

View File

@ -103,6 +103,131 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeBoxTwoPnt
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeFaceHW
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFaceHW (CORBA::Double theH,
CORBA::Double theW)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
if (theH == 0 || theW == 0)
return aGEOMObject._retn();
//Create the Face
Handle(GEOM_Object) anObject = GetOperations()->MakeFaceHW(theH, theW);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeFacePlaneHW
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFacePlaneHW
(GEOM::GEOM_Object_ptr theFace,
CORBA::Double theH,
CORBA::Double theW)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
if (theFace == NULL || theH == 0 || theW == 0)
return aGEOMObject._retn();
//Get the reference points
Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject
(theFace->GetStudyID(), theFace->GetEntry());
if (aFace.IsNull())
return aGEOMObject._retn();
//Create the Face
Handle(GEOM_Object) anObject = GetOperations()->MakeFacePlaneHW(aFace, theH, theW);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeDiskPntVecR
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskPntVecR
(GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
CORBA::Double theR)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
//Get the reference points
Handle(GEOM_Object) aPnt = GetOperations()->GetEngine()->GetObject
(thePnt->GetStudyID(), thePnt->GetEntry());
Handle(GEOM_Object) aVec = GetOperations()->GetEngine()->GetObject
(theVec->GetStudyID(), theVec->GetEntry());
if (aPnt.IsNull() || aVec.IsNull()) return aGEOMObject._retn();
// Make Disk
Handle(GEOM_Object) anObject =
GetOperations()->MakeDiskPntVecR(aPnt, aVec, theR);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeDiskThreePnt
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDiskThreePnt
(GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
if (thePnt1 == NULL || thePnt2 == NULL || thePnt3 == NULL) return aGEOMObject._retn();
//Get the reference points
Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
(thePnt1->GetStudyID(), thePnt1->GetEntry());
Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
(thePnt2->GetStudyID(), thePnt2->GetEntry());
Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
(thePnt3->GetStudyID(), thePnt3->GetEntry());
if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
// Make Disk
Handle(GEOM_Object) anObject =
GetOperations()->MakeDiskThreePnt(aPnt1, aPnt2, aPnt3);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* MakeCylinderRH

View File

@ -47,6 +47,21 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i :
GEOM::GEOM_Object_ptr MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2);
GEOM::GEOM_Object_ptr MakeFaceHW (CORBA::Double theH,
CORBA::Double theW);
GEOM::GEOM_Object_ptr MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace,
CORBA::Double theH,
CORBA::Double theW);
GEOM::GEOM_Object_ptr MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter,
GEOM::GEOM_Object_ptr theVector,
double theR);
GEOM::GEOM_Object_ptr MakeDiskThreePnt (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3);
GEOM::GEOM_Object_ptr MakeCylinderRH (CORBA::Double theR,
CORBA::Double theH);

View File

@ -771,6 +771,65 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt
return anObj;
}
//=============================================================================
// MakeFaceHW:
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceHW (CORBA::Double theH,
CORBA::Double theW)
{
beginService( " GEOM_Superv_i::MakeFaceHW" );
MESSAGE("GEOM_Superv_i::MakeFaceHW");
get3DPrimOp();
GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceHW(theH, theW);
endService( " GEOM_Superv_i::MakeFaceHW" );
return anObj;
}
//=============================================================================
// MakeFaceTwoPlaneHW:
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace,
CORBA::Double theH,
CORBA::Double theW)
{
beginService( " GEOM_Superv_i::MakeFacePlaneHW" );
MESSAGE("GEOM_Superv_i::MakeFacePlaneHW");
get3DPrimOp();
GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFacePlaneHW(theFace, theH, theW);
endService( " GEOM_Superv_i::MakeFacePlaneHW" );
return anObj;
}
//=============================================================================
// MakeDiskPntVecR:
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter,
GEOM::GEOM_Object_ptr theVector,
CORBA::Double theR)
{
beginService( " GEOM_Superv_i::MakeDiskPntVecR" );
MESSAGE("GEOM_Superv_i::MakeDiskPntVecR");
get3DPrimOp();
GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeDiskPntVecR(theCenter, theVector, theR);
endService( " GEOM_Superv_i::MakeDiskPntVecR" );
return anObj;
}
//=============================================================================
// MakeDiskThreePnt:
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskThreePnt (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3)
{
beginService( " GEOM_Superv_i::MakeDiskThreePnt" );
MESSAGE("GEOM_Superv_i::MakeDiskThreePnt");
get3DPrimOp();
GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeDiskThreePnt(thePnt1, thePnt2, thePnt3);
endService( " GEOM_Superv_i::MakeDiskThreePnt" );
return anObj;
}
//=============================================================================
// MakeCylinderPntVecRH:
//=============================================================================

View File

@ -187,6 +187,17 @@ public:
CORBA::Double theDZ);
GEOM::GEOM_Object_ptr MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2);
GEOM::GEOM_Object_ptr MakeFaceHW (CORBA::Double theH,
CORBA::Double theW);
GEOM::GEOM_Object_ptr MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace,
CORBA::Double theH,
CORBA::Double theW);
GEOM::GEOM_Object_ptr MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter,
GEOM::GEOM_Object_ptr theVector,
CORBA::Double theR);
GEOM::GEOM_Object_ptr MakeDiskThreePnt (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2,
GEOM::GEOM_Object_ptr thePnt3);
GEOM::GEOM_Object_ptr MakeCylinderPntVecRH (GEOM::GEOM_Object_ptr thePnt,
GEOM::GEOM_Object_ptr theAxis,
CORBA::Double theRadius,

View File

@ -138,6 +138,10 @@ def TestAll (geompy, math):
Face1 = geompy.MakeFaceWires([Wire, Sketcher],
WantPlanarFace) #(List of GEOM_Object_ptr, Boolean)->GEOM_Object_ptr
Face2 = geompy.MakeFace(Sketcher, WantPlanarFace)
Face3 = geompy.MakeFaceHW (100., 200.) #(2 Doubles)->GEOM_Object_ptr
Face4 = geompy.MakeFacePlaneHW (Face, 200., 200.)#(1 GEOM_Object_ptr, 2 Doubles)->GEOM_Object_ptr
Disk = geompy.MakeDiskPntVecR (p0, vz, radius) #(2 GEOM_Object_ptr, 1 Double)->GEOM_Object_ptr
Disk2 = geompy.MakeDiskThreePnt(p0, p200, pz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
Shell = geompy.MakeShell([Face, Face1]) #(List of GEOM_Object_ptr)->GEOM_Object_ptr
Prism1 = geompy.MakePrism(Face2, p0, pxyz) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
@ -324,6 +328,10 @@ def TestAll (geompy, math):
id_Face = geompy.addToStudy(Face, "Face")
id_Face1 = geompy.addToStudy(Face1, "Face from two wires")
id_Face2 = geompy.addToStudy(Face2, "Face from Sketcher")
id_Face3 = geompy.addToStudy(Face3, "Face Height Width")
id_Face4 = geompy.addToStudy(Face4, "Face Plane_HW")
id_Disk = geompy.addToStudy(Disk, "Disk PntVecR")
id_Disk2 = geompy.addToStudy(Disk2, "Disk Three Points")
id_Shell = geompy.addToStudy(Shell, "Shell")
id_p_on_face = geompy.addToStudy(p_on_face, "Vertex on Face (0.1, 0.8)")

View File

@ -680,6 +680,57 @@ class geompyDC(GEOM._objref_GEOM_Gen):
RaiseIfFailed("MakeBoxTwoPnt", self.PrimOp)
return anObj
## Create a face with specified dimensions along OX-OY coordinate axes,
# with edges, parallel to this coordinate axes.
# @param theH length of Face edge, parallel to OX axis.
# @param theW length of Face edge, parallel to OY axis.
# @return New GEOM_Object, containing the created face.
#
# @ref tui_creation_face "Example"
def MakeFaceHW(self,theH, theW):
# Example: see GEOM_TestAll.py
anObj = self.PrimOp.MakeFaceHW(theH, theW)
RaiseIfFailed("MakeFaceHW", self.PrimOp)
return anObj
## Create a face from another plane and two sizes,
# vertical size and horisontal size.
# @param thePlane Plane in that axis will be create new face.
# @param theH Height (vertical size).
# @param theW Width (horisontal size).
# @return New GEOM_Object, containing the created face.
#
# @ref tui_creation_face "Example"
def MakeFacePlaneHW(self, theFace, theH, theW):
# Example: see GEOM_TestAll.py
anObj = self.PrimOp.MakeFacePlaneHW(theFace, theH, theW)
RaiseIfFailed("MakeFacePlaneHW", self.PrimOp)
return anObj
## Create a disk with given center, normal vector and radius.
# @param thePnt Disk center.
# @param theVec Vector, normal to the plane of the disk.
# @param theR Disk radius.
# @return New GEOM_Object, containing the created disk.
#
# @ref tui_creation_disk "Example"
def MakeDiskPntVecR(self,thePnt, theVec, theR):
# Example: see GEOM_TestAll.py
anObj = self.PrimOp.MakeDiskPntVecR(thePnt, theVec, theR)
RaiseIfFailed("MakeDiskPntVecR", self.PrimOp)
return anObj
## Create a disk, passing through three given points
# @param thePnt1,thePnt2,thePnt3 Points, defining the disk.
# @return New GEOM_Object, containing the created disk.
#
# @ref tui_creation_disk "Example"
def MakeDiskThreePnt(self,thePnt1, thePnt2, thePnt3):
# Example: see GEOM_TestAll.py
anObj = self.PrimOp.MakeDiskThreePnt(thePnt1, thePnt2, thePnt3)
RaiseIfFailed("MakeDiskThreePnt", self.PrimOp)
return anObj
## Create a cylinder with given base point, axis, radius and height.
# @param thePnt Central point of cylinder base.
# @param theAxis Cylinder axis.

View File

@ -37,20 +37,26 @@ dist_libPrimitiveGUI_la_SOURCES = \
PrimitiveGUI_CylinderDlg.h \
PrimitiveGUI_SphereDlg.h \
PrimitiveGUI_TorusDlg.h \
PrimitiveGUI_FaceDlg.h \
PrimitiveGUI_DiskDlg.h \
\
PrimitiveGUI.cxx \
PrimitiveGUI_BoxDlg.cxx \
PrimitiveGUI_CylinderDlg.cxx \
PrimitiveGUI_SphereDlg.cxx \
PrimitiveGUI_TorusDlg.cxx \
PrimitiveGUI_ConeDlg.cxx
PrimitiveGUI_ConeDlg.cxx \
PrimitiveGUI_FaceDlg.cxx \
PrimitiveGUI_DiskDlg.cxx
MOC_FILES = \
PrimitiveGUI_BoxDlg_moc.cxx \
PrimitiveGUI_CylinderDlg_moc.cxx \
PrimitiveGUI_SphereDlg_moc.cxx \
PrimitiveGUI_TorusDlg_moc.cxx \
PrimitiveGUI_ConeDlg_moc.cxx
PrimitiveGUI_ConeDlg_moc.cxx \
PrimitiveGUI_FaceDlg_moc.cxx \
PrimitiveGUI_DiskDlg_moc.cxx
nodist_libPrimitiveGUI_la_SOURCES = \
$(MOC_FILES)

View File

@ -35,6 +35,8 @@
#include "PrimitiveGUI_SphereDlg.h" // Method SPHERE
#include "PrimitiveGUI_TorusDlg.h" // Method TORUS
#include "PrimitiveGUI_ConeDlg.h" // Method CONE
#include "PrimitiveGUI_FaceDlg.h" // Method FACE
#include "PrimitiveGUI_DiskDlg.h" // Method DISK
//=======================================================================
// function : PrimitiveGUI()
@ -81,6 +83,12 @@ bool PrimitiveGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
case 4025: // CONE
aDlg = new PrimitiveGUI_ConeDlg( getGeometryGUI(), parent);
break;
case 4026: // FACE
aDlg = new PrimitiveGUI_FaceDlg( getGeometryGUI(), parent);
break;
case 4027: // DISK
aDlg = new PrimitiveGUI_DiskDlg( getGeometryGUI(), parent);
break;
default:
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break;

View File

@ -0,0 +1,510 @@
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : PrimitiveGUI_DiskDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
//
#include "PrimitiveGUI_DiskDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
//=================================================================================
// class : PrimitiveGUI_DiskDlg()
// purpose : Constructs a PrimitiveGUI_DiskDlg 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.
//=================================================================================
PrimitiveGUI_DiskDlg::PrimitiveGUI_DiskDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_PNT_VEC_R" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_DISK_THREE_POINTS" ) ) );
setWindowTitle( tr( "GEOM_DISK_TITLE" ) );
/***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_DISK" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image2 );
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
GroupPntVecR->PushButton1->setIcon( image1 );
GroupPntVecR->PushButton2->setIcon( image1 );
GroupPntVecR->LineEdit1->setReadOnly( true );
GroupPntVecR->LineEdit2->setReadOnly( true );
Group3Pnts = new DlgRef_3Sel( centralWidget() );
Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
Group3Pnts->PushButton1->setIcon( image1 );
Group3Pnts->PushButton2->setIcon( image1 );
Group3Pnts->PushButton3->setIcon( image1 );
Group3Pnts->LineEdit1->setReadOnly( true );
Group3Pnts->LineEdit2->setReadOnly( true );
Group3Pnts->LineEdit3->setReadOnly( true );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPntVecR );
layout->addWidget( Group3Pnts );
/***************************************************************/
setHelpFileName( "create_disk_page.html" );
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_DiskDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
PrimitiveGUI_DiskDlg::~PrimitiveGUI_DiskDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPntVecR->LineEdit1;
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
/* min, max, step and decimals for spin boxes & initial values */
initSpinBox( GroupPntVecR->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPntVecR->SpinBox_DX->setValue( 100 );
/* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPntVecR->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntVecR->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( Group3Pnts->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( Group3Pnts->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_DISK" ) );
ConstructorsClicked( 0 );
}
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
void PrimitiveGUI_DiskDlg::SetDoubleSpinBoxStep( double step )
{
GroupPntVecR->SpinBox_DX->setSingleStep(step);
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void PrimitiveGUI_DiskDlg::ConstructorsClicked( int constructorId )
{
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
switch ( constructorId ) {
case 0:
{
Group3Pnts->hide();
GroupPntVecR->show();
myEditCurrentArgument = GroupPntVecR->LineEdit1;
GroupPntVecR->LineEdit1->setText( "" );
GroupPntVecR->LineEdit2->setText( "" );
break;
}
case 1:
{
GroupPntVecR->hide();
Group3Pnts->show();
myEditCurrentArgument = Group3Pnts->LineEdit1;
Group3Pnts->LineEdit1->setText( "" );
Group3Pnts->LineEdit2->setText( "" );
Group3Pnts->LineEdit3->setText( "" );
break;
}
}
qApp->processEvents();
updateGeometry();
resize( minimumSize() );
myEditCurrentArgument->setFocus();
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::ClickOnOk()
{
if ( ClickOnApply() )
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool PrimitiveGUI_DiskDlg::ClickOnApply()
{
if ( !onAccept() )
return false;
initName();
ConstructorsClicked( getConstructorId() );
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void PrimitiveGUI_DiskDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aList;
aSelMgr->selectedObjects( aList );
if ( aList.Extent() != 1 ) {
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
return;
}
// nbSel == 1
Handle(SALOME_InteractiveObject) anIO = aList.First();
Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
QString aName = GEOMBase::GetName( aSelectedObject );
// If selected Vertex or Edge on the some Shape Get selection Subshape
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
aNeedType = TopAbs_EDGE;
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes(anIO, aMap);
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap(1);
if ( aNeedType == TopAbs_EDGE )
aName += QString( ":edge_%1" ).arg( anIndex );
else
aName += QString( ":vertex_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else {
aSelectedObject = aFindedObject; // get Object from study
}
}
else { // Global Selection
if ( aShape.ShapeType() != aNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject;
else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject;
else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject;
}
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if ( send == GroupPntVecR->PushButton1 ) myEditCurrentArgument = GroupPntVecR->LineEdit1;
else if ( send == GroupPntVecR->PushButton2 ) myEditCurrentArgument = GroupPntVecR->LineEdit2;
else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1;
else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2;
else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3;
myEditCurrentArgument->setFocus();
if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else {
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
SelectionIntoArgument();
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPntVecR->LineEdit1 ||
send == GroupPntVecR->LineEdit2 ||
send == Group3Pnts->LineEdit1 ||
send == Group3Pnts->LineEdit2 ||
send == Group3Pnts->LineEdit3 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::enterEvent( QEvent* )
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_DiskDlg::DeactivateActiveDialog()
{
// myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void PrimitiveGUI_DiskDlg::ValueChangedInSpinBox()
{
displayPreview();
}
//=================================================================================
// function : getRadius()
// purpose :
//=================================================================================
double PrimitiveGUI_DiskDlg::getRadius() const
{
double r = 0.;
switch ( getConstructorId() ) {
case 0:
r = GroupPntVecR->SpinBox_DX->value(); break;
}
return r;
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr PrimitiveGUI_DiskDlg::createOperation()
{
return myGeomGUI->GetGeomGen()->GetI3DPrimOperations( getStudyId() );
}
//=================================================================================
// function : isEqual
// purpose : it may also be needed to check for min distance between gp_Pnt-s...
//=================================================================================
static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
{
return thePnt1->_is_equivalent( thePnt2 );
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_DiskDlg::isValid( QString& msg )
{
const int id = getConstructorId();
if ( id == 0 )
return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
else if ( id == 1 )
return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
!isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
return false;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool PrimitiveGUI_DiskDlg::execute( ObjectList& objects )
{
bool res = false;
GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) {
case 0 :
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskPntVecR( myPoint, myDir, getRadius() );
res = true;
break;
case 1 :
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeDiskThreePnt( myPoint1, myPoint2, myPoint3 );
res = true;
break;
}
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
else {
MESSAGE( "Execute Object is NULL!" );
}
return res;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void PrimitiveGUI_DiskDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
case 0:
objMap[GroupPntVecR->LineEdit1->text()] = myPoint;
objMap[GroupPntVecR->LineEdit2->text()] = myDir;
break;
case 1:
objMap[Group3Pnts->LineEdit1->text()] = myPoint1;
objMap[Group3Pnts->LineEdit2->text()] = myPoint2;
objMap[Group3Pnts->LineEdit3->text()] = myPoint3;
break;
}
addSubshapesToFather( objMap );
}

View File

@ -0,0 +1,81 @@
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : PrimitiveGUI_DiskDlg.h
// Author : Dmitry Matveitchev, OCN
//
#ifndef BASICGUI_DISKDLG_H
#define BASICGUI_DISKDLG_H
#include <GEOMBase_Skeleton.h>
class DlgRef_3Sel;
class DlgRef_2Sel1Spin;
//=================================================================================
// class : PrimitiveGUI_DiskDlg
// purpose :
//=================================================================================
class PrimitiveGUI_DiskDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
PrimitiveGUI_DiskDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
~PrimitiveGUI_DiskDlg();
protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
virtual void addSubshapesToStudy();
private:
void Init();
void enterEvent( QEvent* );
double getRadius() const;
private:
GEOM::GEOM_Object_var myPoint, myDir, myPoint1, myPoint2, myPoint3;
DlgRef_2Sel1Spin* GroupPntVecR;
DlgRef_3Sel* Group3Pnts;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void SelectionIntoArgument();
void ConstructorsClicked( int );
void LineEditReturnPressed();
void SetEditCurrentArgument();
void ValueChangedInSpinBox();
void SetDoubleSpinBoxStep( double );
};
#endif // BASICGUI_DISKDLG_H

View File

@ -0,0 +1,422 @@
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : PrimitiveGUI_FaceDlg.cxx
// Author : Dmitry Matveitchev, OCN.
//
#include "PrimitiveGUI_FaceDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx>
//=================================================================================
// class : PrimitiveGUI_FaceDlg()
// purpose : Constructs a PrimitiveGUI_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.
//=================================================================================
PrimitiveGUI_FaceDlg::PrimitiveGUI_FaceDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_PLANE_HW" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_FACE_HW" ) ) );
setWindowTitle( tr( "GEOM_FACE_TITLE" ) );
/***************************************************************/
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_FACE" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image2 );
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
GroupPlane = new DlgRef_1Sel2Spin( centralWidget() );
GroupPlane->GroupBox1->setTitle( tr( "GEOM_FACES" ) );
GroupPlane->TextLabel1->setText( tr( "GEOM_FACE" ) );
GroupPlane->TextLabel2->setText( tr( "GEOM_HEIGHT" ) );
GroupPlane->TextLabel3->setText( tr( "GEOM_WIDTH" ) );
GroupPlane->PushButton1->setIcon( image1 );
GroupPlane->LineEdit1->setReadOnly( true );
GroupDimensions = new DlgRef_2Spin( centralWidget() );
GroupDimensions->GroupBox1->setTitle( tr( "GEOM_BOX_OBJ" ) );
GroupDimensions->TextLabel1->setText( tr( "GEOM_HEIGHT" ) );
GroupDimensions->TextLabel2->setText( tr( "GEOM_WIDTH" ) );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPlane );
layout->addWidget( GroupDimensions );
/***************************************************************/
setHelpFileName( "create_face_page.html" );
Init();
}
//=================================================================================
// function : ~PrimitiveGUI_FaceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
PrimitiveGUI_FaceDlg::~PrimitiveGUI_FaceDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPlane->LineEdit1;
myFace = GEOM::GEOM_Object::_nil();
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
double aDefaultSize = 100.0;
/* min, max, step and decimals for spin boxes */
initSpinBox( GroupPlane->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPlane->SpinBox_DX->setValue( aDefaultSize );
initSpinBox( GroupPlane->SpinBox_DY, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupPlane->SpinBox_DY->setValue( aDefaultSize );
initSpinBox( GroupDimensions->SpinBox_DX, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupDimensions->SpinBox_DX->setValue( aDefaultSize );
initSpinBox( GroupDimensions->SpinBox_DY, 0.001, COORD_MAX, aStep, 3 ); // VSR:TODO : DBL_DIGITS_DISPLAY
GroupDimensions->SpinBox_DY->setValue( aDefaultSize );
/* signals and slots connections */
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
connect( GroupPlane->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupPlane->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupPlane->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupPlane->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupDimensions->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_FACE" ) );
ConstructorsClicked( 0 );
}
//=================================================================================
// function : SetDoubleSpinBoxStep()
// purpose : Double spin box management
//=================================================================================
void PrimitiveGUI_FaceDlg::SetDoubleSpinBoxStep( double step )
{
GroupPlane->SpinBox_DX->setSingleStep(step);
GroupPlane->SpinBox_DY->setSingleStep(step);
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::ValueChangedInSpinBox( double newValue )
{
displayPreview();
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::ClickOnOk()
{
if ( ClickOnApply() )
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool PrimitiveGUI_FaceDlg::ClickOnApply()
{
if ( !onAccept() )
return false;
initName();
myEditCurrentArgument->setText( "" );
ConstructorsClicked( getConstructorId() );
return true;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void PrimitiveGUI_FaceDlg::ConstructorsClicked( int constructorId )
{
switch ( constructorId ) {
case 0:
{
globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
myEditCurrentArgument = GroupPlane->LineEdit1;
myEditCurrentArgument->setText("");
myFace = GEOM::GEOM_Object::_nil();
GroupDimensions->hide();
GroupPlane->show();
break;
}
case 1:
{
globalSelection(); // close local contexts, if any
GroupPlane->hide();
GroupDimensions->show();
break;
}
}
qApp->processEvents();
updateGeometry();
resize( minimumSize() );
SelectionIntoArgument();
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void PrimitiveGUI_FaceDlg::SelectionIntoArgument()
{
if (getConstructorId() != 0) {
displayPreview();
return;
}
myEditCurrentArgument->setText( "" );
if ( IObjectCount() != 1 ) {
if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myFace = GEOM::GEOM_Object::_nil();
return;
}
// nbSel == 1
Standard_Boolean aRes = Standard_False;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
QString aName = GEOMBase::GetName( aSelectedObject );
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
TColStd_IndexedMapOfInteger aMap;
aSelMgr->GetIndexes( firstIObject(), aMap );
if ( aMap.Extent() == 1 ) { // Local Selection
int anIndex = aMap( 1 );
aName += QString( ":face_%1" ).arg( anIndex );
//Find SubShape Object in Father
GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( aSelectedObject, aName );
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
}
else
aSelectedObject = aFindedObject; // get Object from study
}
else { // Global Selection
if ( aShape.ShapeType() != TopAbs_FACE ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
}
}
}
myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == GroupPlane->LineEdit1 ) myFace = aSelectedObject;
}
displayPreview();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
globalSelection(); // close previous local contexts
if ( send == GroupPlane->PushButton1 ) {
myEditCurrentArgument = GroupPlane->LineEdit1;
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
}
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if ( send == GroupPlane->LineEdit1 ) myEditCurrentArgument = GroupPlane->LineEdit1;
else return;
GEOMBase_Skeleton::LineEditReturnPressed();
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void PrimitiveGUI_FaceDlg::DeactivateActiveDialog()
{
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void PrimitiveGUI_FaceDlg::enterEvent( QEvent* )
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr PrimitiveGUI_FaceDlg::createOperation()
{
return myGeomGUI->GetGeomGen()->GetI3DPrimOperations( getStudyId() );
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool PrimitiveGUI_FaceDlg::isValid( QString& msg )
{
const int id = getConstructorId();
if ( id == 0 )
return !myFace->_is_nil();
else if ( id == 1 )
return true;
return false;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool PrimitiveGUI_FaceDlg::execute( ObjectList& objects )
{
bool res = false;
GEOM::GEOM_Object_var anObj;
switch ( getConstructorId() ) {
case 0 :
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFacePlaneHW( myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value() );
res = true;
break;
case 1 :
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeFaceHW( GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value() );
res = true;
break;
}
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
return res;
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void PrimitiveGUI_FaceDlg::addSubshapesToStudy()
{
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
case 0 :
objMap[GroupPlane->LineEdit1->text()] = myFace;
break;
}
addSubshapesToFather( objMap );
}

View File

@ -0,0 +1,81 @@
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : BasicGUI_FaceDlg.h
// Author : Dmitry Matveithev, OCN.
//
#ifndef BASICGUI_FACEDLG_H
#define BASICGUI_FACEDLG_H
#include <GEOMBase_Skeleton.h>
class DlgRef_2Spin;
class DlgRef_1Sel2Spin;
//=================================================================================
// class : PrimitiveGUI_FaceDlg
// purpose :
//=================================================================================
class PrimitiveGUI_FaceDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
PrimitiveGUI_FaceDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
~PrimitiveGUI_FaceDlg();
protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
virtual void addSubshapesToStudy();
private:
void Init();
void enterEvent( QEvent* );
private:
GEOM::GEOM_Object_var myPoint1;
GEOM::GEOM_Object_var myPoint2;
GEOM::GEOM_Object_var myVector;
GEOM::GEOM_Object_var myFace;
DlgRef_2Spin* GroupDimensions;
DlgRef_1Sel2Spin* GroupPlane;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void DeactivateActiveDialog();
void ConstructorsClicked( int );
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ValueChangedInSpinBox( double );
void SetDoubleSpinBoxStep( double );
};
#endif // BASICGUI_FACEDLG_H