DCQ : Add Position Functions.

This commit is contained in:
dcq 2004-02-27 13:02:11 +00:00
parent 749f61ead9
commit dfa458fe08
17 changed files with 753 additions and 26 deletions

View File

@ -91,6 +91,10 @@ planepointvector.png \
planeworkingface.png \ planeworkingface.png \
point2.png \ point2.png \
pointonedge.png \ pointonedge.png \
position.png \
positionface.png \
positionpoint.png \
positionvect.png \
prism.png \ prism.png \
revol.png \ revol.png \
rotate.png \ rotate.png \

View File

@ -120,6 +120,11 @@ module GEOM
GEOM_Shape MakeRotation(in GEOM_Shape shape, GEOM_Shape MakeRotation(in GEOM_Shape shape,
in AxisStruct axis, in AxisStruct axis,
in double angle) raises (SALOME::SALOME_Exception) ; in double angle) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakePosition(in GEOM_Shape shape1,
in GEOM_Shape shape2,
in GEOM_Shape::ListOfSubShapeID ListOfID1,
in GEOM_Shape::ListOfSubShapeID ListOfID2,
in short typeofshape) raises (SALOME::SALOME_Exception) ;
GEOM_Shape MakeScaleTransform(in GEOM_Shape shape, GEOM_Shape MakeScaleTransform(in GEOM_Shape shape,
in PointStruct theCenterofScale, in PointStruct theCenterofScale,
in double factor) raises (SALOME::SALOME_Exception) ; in double factor) raises (SALOME::SALOME_Exception) ;

View File

@ -112,11 +112,12 @@
<submenu label-id="Transformation" item-id="502" pos-id="2"> <submenu label-id="Transformation" item-id="502" pos-id="2">
<popup-item item-id="5021" pos-id="" label-id="Translation" icon-id="translation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5021" pos-id="" label-id="Translation" icon-id="translation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="5022" pos-id="" label-id="Rotation" icon-id="rotate.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5022" pos-id="" label-id="Rotation" icon-id="rotate.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="5023" pos-id="" label-id="Mirror by plane" icon-id="mirrorPlane.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5023" pos-id="" label-id="Position" icon-id="position.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="5024" pos-id="" label-id="Scale transform" icon-id="scale.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5024" pos-id="" label-id="Mirror by plane" icon-id="mirrorPlane.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="5025" pos-id="" label-id="Scale transform" icon-id="scale.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<separator pos-id=""/> <separator pos-id=""/>
<popup-item item-id="5025" pos-id="" label-id="Multi-Translation" icon-id="multitranslation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5026" pos-id="" label-id="Multi-Translation" icon-id="multitranslation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="5026" pos-id="" label-id="Multi-Rotation" icon-id="multirotation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="5027" pos-id="" label-id="Multi-Rotation" icon-id="multirotation.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu> </submenu>
<endsubmenu /> <endsubmenu />
<popup-item item-id="503" pos-id="" label-id="Partition" icon-id="partition.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="503" pos-id="" label-id="Partition" icon-id="partition.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
@ -139,7 +140,7 @@
<!-- ************************** Kinematic (menubar) ************************************ --> <!-- ************************** Kinematic (menubar) ************************************ -->
<menu-item label-id="Kinematic" item-id="61" pos-id="6"> <menu-item label-id="Kinematic" item-id="61" pos-id="6">
<popup-item item-id="611" pos-id="" label-id="Add Assembly" icon-id="assembly.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="611" pos-id="" label-id="Add Assembly" icon-id="assembly.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<submenu label-id="Add Contact" item-id="612" icon-id="contact.png" pos-id=""> <submenu label-id="Add Contact" item-id="612" icon-id="" pos-id="">
<popup-item item-id="61201" pos-id="" label-id="Embedding" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="61201" pos-id="" label-id="Embedding" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="61202" pos-id="" label-id="Pivot" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="61202" pos-id="" label-id="Pivot" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="61203" pos-id="" label-id="Slide" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="61203" pos-id="" label-id="Slide" icon-id="" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
@ -252,11 +253,12 @@
<toolbar label-id="Transformation"> <toolbar label-id="Transformation">
<toolbutton-item item-id="5021" label-id="Translation" icon-id="translation.png" tooltip-id="Translate a shape"accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5021" label-id="Translation" icon-id="translation.png" tooltip-id="Translate a shape"accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="5022" label-id="Rotation" icon-id="rotate.png" tooltip-id="Rotate a shape" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5022" label-id="Rotation" icon-id="rotate.png" tooltip-id="Rotate a shape" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="5023" label-id="Mirror by plane" icon-id="mirrorPlane.png" tooltip-id="Mirror a shape" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5023" label-id="Position" icon-id="position.png" tooltip-id="Position a shape" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="5024" label-id="Scale transform" icon-id="scale.png" tooltip-id="Scale a shape" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5024" label-id="Mirror by plane" icon-id="mirrorPlane.png" tooltip-id="Mirror a shape" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="5025" label-id="Scale transform" icon-id="scale.png" tooltip-id="Scale a shape" accel-id="" toggle-id="" execute-action=""/>
<separatorTB/> <separatorTB/>
<toolbutton-item item-id="5025" label-id="Multi-Translation" icon-id="multitranslation.png" tooltip-id="Multi-translate a shape" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5026" label-id="Multi-Translation" icon-id="multitranslation.png" tooltip-id="Multi-translate a shape" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="5026" label-id="Multi-Rotation" icon-id="multirotation.png" tooltip-id="Multi-rotate a shape" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="5027" label-id="Multi-Rotation" icon-id="multirotation.png" tooltip-id="Multi-rotate a shape" accel-id="" toggle-id="" execute-action=""/>
</toolbar> </toolbar>

BIN
resources/position.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

BIN
resources/positionface.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

BIN
resources/positionpoint.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

BIN
resources/positionvect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

View File

@ -46,6 +46,7 @@ using namespace std;
#include <gp_Elips.hxx> #include <gp_Elips.hxx>
#include <Geom_Plane.hxx> #include <Geom_Plane.hxx>
#include <Geom_Line.hxx> #include <Geom_Line.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_BezierCurve.hxx> #include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx> #include <Geom_BSplineCurve.hxx>
#include <GeomFill_Line.hxx> #include <GeomFill_Line.hxx>
@ -64,6 +65,7 @@ using namespace std;
#include <BRepAlgoAPI.hxx> #include <BRepAlgoAPI.hxx>
#endif #endif
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepBuilderAPI_Copy.hxx> #include <BRepBuilderAPI_Copy.hxx>
#include <BRepAlgoAPI_Common.hxx> #include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx> #include <BRepAlgoAPI_Cut.hxx>
@ -4420,6 +4422,121 @@ GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeRotation( GEOM::GEOM_Shape_ptr myShape,
} }
//=================================================================================
// function : MakePosition()
// purpose :
//=================================================================================
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakePosition(GEOM::GEOM_Shape_ptr shape1,
GEOM::GEOM_Shape_ptr shape2,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID1,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID2,
const CORBA::Short typeofshape)
throw (SALOME::SALOME_Exception)
{
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds;
TopoDS_Shape aShape1 = GetTopoShape(shape1);
TopoDS_Shape aShape2 = GetTopoShape(shape2);
if(aShape1.IsNull() || aShape2.IsNull()) {
THROW_SALOME_CORBA_EXCEPTION("MakePosition aborted : null shape during operation", SALOME::BAD_PARAM);
}
try {
gp_Trsf theTransformation;
TopoDS_Shape S1, S2;
GetShapeFromIndex(aShape1, (TopAbs_ShapeEnum)typeofshape, ListOfID1[0], S1);
GetShapeFromIndex(aShape2, (TopAbs_ShapeEnum)typeofshape, ListOfID2[0], S2);
if(S1.ShapeType() == TopAbs_VERTEX && S2.ShapeType() == TopAbs_VERTEX) {
gp_Pnt Pt1 = BRep_Tool::Pnt(TopoDS::Vertex(S1));
gp_Pnt Pt2 = BRep_Tool::Pnt(TopoDS::Vertex(S2));
gp_Vec theVector(Pt1, Pt2);
theTransformation.SetTranslation(theVector);
}
else if(S1.ShapeType() == TopAbs_EDGE && S2.ShapeType() == TopAbs_EDGE) {
Standard_Real f, l;
gp_Pnt Pt1, Pt2;
gp_Vec V1, V2;
Handle(Geom_Curve) C = BRep_Tool::Curve(TopoDS::Edge(S1), f, l);
C->D1(f, Pt1, V1);
C = BRep_Tool::Curve(TopoDS::Edge(S2), f, l);
C->D1(f, Pt2, V2);
gp_Vec theVector(Pt1, Pt2);
theTransformation.SetTranslation(theVector);
if(!V1.IsParallel(V2, Precision::Angular())) {
gp_Vec VN = V1.Crossed(V2);
double Angle = V1.Angle(V2);
gp_Dir D(VN.X(), VN.Y(), VN.Z());
gp_Ax1 AX(Pt1, D);
gp_Trsf TheRot;
TheRot.SetRotation(AX, Angle);
theTransformation = theTransformation * TheRot;
}
}
else if(S1.ShapeType() == TopAbs_FACE && S2.ShapeType() == TopAbs_FACE) {
TopoDS_Edge E1, E2;
Standard_Real f, l;
gp_Pnt P1, P2;
gp_Vec D1, D2, N1, N2, V1, V2;
TopExp_Explorer Exp1(S1, TopAbs_EDGE);
TopExp_Explorer Exp2(S2, TopAbs_EDGE);
for(; Exp1.More(); Exp1.Next()) {
E1 = TopoDS::Edge(Exp1.Current());
if(!BRep_Tool::Degenerated(E1))
break;
}
for(; Exp2.More(); Exp2.Next()) {
E2 = TopoDS::Edge(Exp2.Current());
if(!BRep_Tool::Degenerated(E2))
break;
}
Handle(Geom_Curve) C = BRep_Tool::Curve(E1, f, l);
C->D1(f, P1, D1);
Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E1, TopoDS::Face(S1), f, l);
gp_Pnt2d P2d = C2->Value(f);
Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(S1));
S->D1(P2d.X(), P2d.Y(), P1, V1, V2);
N1 = V1^V2;
C = BRep_Tool::Curve(E2, f, l);
C->D1(f, P2, D2);
C2 = BRep_Tool::CurveOnSurface(E2, TopoDS::Face(S2), f, l);
P2d = C2->Value(f);
S = BRep_Tool::Surface(TopoDS::Face(S2));
S->D1(P2d.X(), P2d.Y(), P2, V1, V2);
N2 = V1^V2;
gp_Ax3 Ax1(P1, N1, D1);
gp_Ax3 Ax2(P2, N2, D2);
theTransformation.SetDisplacement(Ax1, Ax2);
}
BRepBuilderAPI_Transform myBRepTransformation(aShape1, theTransformation, Standard_False);
tds = myBRepTransformation.Shape();
}
catch(Standard_Failure) {
THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakePosition", SALOME::BAD_PARAM);
}
if(!tds.IsNull()) {
result = CreateObject(tds);
InsertInLabelOneArgument(aShape1, shape1, tds, result, myCurrentOCAFDoc);
}
return result;
}
//================================================================================= //=================================================================================
// function : MakeScaleTransform() // function : MakeScaleTransform()
// purpose : Make a shape multipling another by a scale factor // purpose : Make a shape multipling another by a scale factor

View File

@ -401,21 +401,28 @@ class GEOM_Gen_i: public POA_GEOM::GEOM_Gen,
//---------------------------------------------------------------------// //---------------------------------------------------------------------//
// Transformations Operations // // Transformations Operations //
//---------------------------------------------------------------------// //---------------------------------------------------------------------//
// Copy // Copy
GEOM::GEOM_Shape_ptr MakeCopy( GEOM::GEOM_Shape_ptr shape) GEOM::GEOM_Shape_ptr MakeCopy(GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
// Translation // Translation
GEOM::GEOM_Shape_ptr MakeTranslation( GEOM::GEOM_Shape_ptr shape, GEOM::GEOM_Shape_ptr MakeTranslation(GEOM::GEOM_Shape_ptr shape,
CORBA::Double x, CORBA::Double x,
CORBA::Double y, CORBA::Double y,
CORBA::Double z) CORBA::Double z)
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
// Rotation // Rotation
GEOM::GEOM_Shape_ptr MakeRotation( GEOM::GEOM_Shape_ptr shape, GEOM::GEOM_Shape_ptr MakeRotation(GEOM::GEOM_Shape_ptr shape,
const GEOM::AxisStruct& axis, const GEOM::AxisStruct& axis,
CORBA::Double angle) CORBA::Double angle)
throw (SALOME::SALOME_Exception) ; throw (SALOME::SALOME_Exception) ;
// Position
GEOM::GEOM_Shape_ptr MakePosition(GEOM::GEOM_Shape_ptr shape1,
GEOM::GEOM_Shape_ptr shape2,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID1,
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID2,
const CORBA::Short typeofshape)
throw (SALOME::SALOME_Exception) ;
// Create a shape using a scale factor // Create a shape using a scale factor
GEOM::GEOM_Shape_ptr MakeScaleTransform(GEOM::GEOM_Shape_ptr shape, GEOM::GEOM_Shape_ptr MakeScaleTransform(GEOM::GEOM_Shape_ptr shape,
const GEOM::PointStruct& theCenterOfScale, const GEOM::PointStruct& theCenterOfScale,

View File

@ -382,5 +382,18 @@ msgstr "bezier.png"
msgid "ICON_DLG_INTERPOL" msgid "ICON_DLG_INTERPOL"
msgstr "interpol.png" msgstr "interpol.png"
#PositionDlg
msgid "ICON_DLG_POSITION"
msgstr "position.png"
#PositionDlg
msgid "ICON_DLG_POS_POINT"
msgstr "positionpoint.png"
#PositionDlg
msgid "ICON_DLG_POS_VECT"
msgstr "positionvect.png"
#PositionDlg
msgid "ICON_DLG_POS_FACE"
msgstr "positionface.png"

View File

@ -1371,3 +1371,18 @@ msgstr "Nb. Sequences"
msgid "GEOM_IS_IN_LOOP" msgid "GEOM_IS_IN_LOOP"
msgstr "In Loop" msgstr "In Loop"
msgid "GEOM_POSITION"
msgstr "Position"
msgid "GEOM_POSITION_TITLE"
msgstr "Position Of An Object"
msgid "GEOM_POS_VERTEX"
msgstr "Position by Points"
msgid "GEOM_POS_EDGE"
msgstr "Position by Edges"
msgid "GEOM_POS_FACE"
msgstr "Position by Faces"

View File

@ -222,10 +222,11 @@ bool GeometryGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
} }
else if(theCommandID == 5021 || // MENU TRANSFORMATION - TRANSLATION else if(theCommandID == 5021 || // MENU TRANSFORMATION - TRANSLATION
theCommandID == 5022 || // MENU TRANSFORMATION - ROTATION theCommandID == 5022 || // MENU TRANSFORMATION - ROTATION
theCommandID == 5023 || // MENU TRANSFORMATION - MIRROR theCommandID == 5023 || // MENU TRANSFORMATION - POSITION
theCommandID == 5024 || // MENU TRANSFORMATION - SCALE theCommandID == 5024 || // MENU TRANSFORMATION - MIRROR
theCommandID == 5025 || // MENU TRANSFORMATION - MULTI-TRANSLATION theCommandID == 5025 || // MENU TRANSFORMATION - SCALE
theCommandID == 5026) { // MENU TRANSFORMATION - MULTI-ROTATION theCommandID == 5026 || // MENU TRANSFORMATION - MULTI-TRANSLATION
theCommandID == 5027) { // MENU TRANSFORMATION - MULTI-ROTATION
if(!GeomGUI->LoadLibrary("libTransformationGUI.so")) if(!GeomGUI->LoadLibrary("libTransformationGUI.so"))
return false; return false;
} }

View File

@ -45,6 +45,7 @@ LIB_SRC = TransformationGUI.cxx \
TransformationGUI_MultiRotationDlg.cxx \ TransformationGUI_MultiRotationDlg.cxx \
TransformationGUI_TranslationDlg.cxx \ TransformationGUI_TranslationDlg.cxx \
TransformationGUI_RotationDlg.cxx \ TransformationGUI_RotationDlg.cxx \
TransformationGUI_PositionDlg.cxx \
TransformationGUI_MirrorDlg.cxx \ TransformationGUI_MirrorDlg.cxx \
TransformationGUI_ScaleDlg.cxx TransformationGUI_ScaleDlg.cxx
@ -54,6 +55,7 @@ LIB_MOC = \
TransformationGUI_MultiRotationDlg.h \ TransformationGUI_MultiRotationDlg.h \
TransformationGUI_TranslationDlg.h \ TransformationGUI_TranslationDlg.h \
TransformationGUI_RotationDlg.h \ TransformationGUI_RotationDlg.h \
TransformationGUI_PositionDlg.h \
TransformationGUI_MirrorDlg.h \ TransformationGUI_MirrorDlg.h \
TransformationGUI_ScaleDlg.h TransformationGUI_ScaleDlg.h
@ -66,6 +68,6 @@ LIB_SERVER_IDL =
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS += -lGEOMFiltersSelection -lGEOMBase LDFLAGS += -lGEOMFiltersSelection -lDisplayGUI
@CONCLUDE@ @CONCLUDE@

View File

@ -29,12 +29,16 @@
using namespace std; using namespace std;
#include "TransformationGUI.h" #include "TransformationGUI.h"
#include "BRepAdaptor_Curve.hxx"
#include "QAD_RightFrame.h"
#include "OCCViewer_Viewer3d.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION #include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
#include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION #include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
#include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION #include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
#include "TransformationGUI_RotationDlg.h" // Method ROTATION #include "TransformationGUI_RotationDlg.h" // Method ROTATION
#include "TransformationGUI_PositionDlg.h" // Method POSITION
#include "TransformationGUI_MirrorDlg.h" // Method MIRROR #include "TransformationGUI_MirrorDlg.h" // Method MIRROR
#include "TransformationGUI_ScaleDlg.h" // Method SCALE #include "TransformationGUI_ScaleDlg.h" // Method SCALE
@ -73,31 +77,41 @@ bool TransformationGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
switch (theCommandID) switch (theCommandID)
{ {
case 5021: // TRANSLATION case 5021: // TRANSLATION
{ {
TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", myTransformationGUI, Sel); TransformationGUI_TranslationDlg *aDlg = new TransformationGUI_TranslationDlg(parent, "", myTransformationGUI, Sel);
break; break;
} }
case 5022: // ROTATION case 5022: // ROTATION
{ {
TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", myTransformationGUI, Sel); TransformationGUI_RotationDlg *aDlg = new TransformationGUI_RotationDlg(parent, "", myTransformationGUI, Sel);
break; break;
} }
case 5023: // MIRROR case 5023: // POSITION
{ {
Handle(AIS_InteractiveContext) ic;
if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
ic = v3d->getAISContext();
}
TransformationGUI_PositionDlg *aDlg = new TransformationGUI_PositionDlg(parent, "", myTransformationGUI, Sel, ic);
break;
}
case 5024: // MIRROR
{
TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", myTransformationGUI, Sel); TransformationGUI_MirrorDlg *aDlg = new TransformationGUI_MirrorDlg(parent, "", myTransformationGUI, Sel);
break; break;
} }
case 5024: // SCALE case 5025: // SCALE
{ {
TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", myTransformationGUI, Sel ); TransformationGUI_ScaleDlg *aDlg = new TransformationGUI_ScaleDlg(parent, "", myTransformationGUI, Sel );
break; break;
} }
case 5025: // MULTI TRANSLATION case 5026: // MULTI TRANSLATION
{ {
TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", myTransformationGUI, Sel); TransformationGUI_MultiTranslationDlg *aDlg = new TransformationGUI_MultiTranslationDlg(parent, "", myTransformationGUI, Sel);
break; break;
} }
case 5026: // MULTI ROTATION case 5027: // MULTI ROTATION
{ {
TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", myTransformationGUI, Sel); TransformationGUI_MultiRotationDlg *aDlg = new TransformationGUI_MultiRotationDlg(parent, "", myTransformationGUI, Sel);
break; break;
@ -148,7 +162,7 @@ void TransformationGUI::MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const
GEOM::GEOM_Shape_var result = myGeom->MakeRotation(Shape, axis, angle); GEOM::GEOM_Shape_var result = myGeom->MakeRotation(Shape, axis, angle);
if(result->_is_nil()) { if(result->_is_nil()) {
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT")); QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
return ; return;
} }
result->NameType(Shape->NameType()); result->NameType(Shape->NameType());
if(myGeomBase->Display(result)) if(myGeomBase->Display(result))
@ -161,6 +175,48 @@ void TransformationGUI::MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const
} }
//=======================================================================================
// function : MakePositionAndDisplay()
// purpose :
//=======================================================================================
void TransformationGUI::MakePositionAndDisplay(GEOM::GEOM_Shape_ptr ShapePtr1,
GEOM::GEOM_Shape_ptr ShapePtr2,
const TopoDS_Shape& Shape1,
const TopoDS_Shape& Shape2,
const TopoDS_Shape& SubShape1,
const TopoDS_Shape& SubShape2)
{
try {
GEOM::GEOM_Shape_var result;
if(SubShape1.ShapeType() == SubShape2.ShapeType()) {
GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID1 = new GEOM::GEOM_Shape::ListOfSubShapeID;
GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID2 = new GEOM::GEOM_Shape::ListOfSubShapeID;
ListOfID1->length(1);
ListOfID2->length(1);
ListOfID1[0] = myGeomBase->GetIndex(SubShape1, Shape1, SubShape1.ShapeType());
ListOfID2[0] = myGeomBase->GetIndex(SubShape2, Shape2, SubShape2.ShapeType());
result = myGeom->MakePosition(ShapePtr1, ShapePtr2, ListOfID1, ListOfID2, SubShape1.ShapeType());
}
if(result->_is_nil()) {
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_ABORT"));
return;
}
result->NameType(ShapePtr1->NameType());
if(myGeomBase->Display(result))
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
}
catch(const SALOME::SALOME_Exception& S_ex) {
QtCatchCorbaException(S_ex);
}
return;
}
//===================================================================================== //=====================================================================================
// function : MakeMirrorAndDisplay() // function : MakeMirrorAndDisplay()
// purpose : // purpose :

View File

@ -49,6 +49,10 @@ public :
void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V); void MakeTranslationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Vec V);
void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc, void MakeRotationAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt loc,
const gp_Dir dir, const Standard_Real angle); const gp_Dir dir, const Standard_Real angle);
void MakePositionAndDisplay(GEOM::GEOM_Shape_ptr ShapePtr1,
GEOM::GEOM_Shape_ptr ShapePtr2,
const TopoDS_Shape& Shape1, const TopoDS_Shape& Shape2,
const TopoDS_Shape& SubShape1, const TopoDS_Shape& SubShape2);
void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2); void MakeMirrorAndDisplay(GEOM::GEOM_Shape_ptr Shape1, GEOM::GEOM_Shape_ptr Shape2);
void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint, void MakeScaleAndDisplay(GEOM::GEOM_Shape_ptr Shape, const gp_Pnt centralPoint,
const Standard_Real factor); const Standard_Real factor);

View File

@ -0,0 +1,410 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : TransformationGUI_PositionDlg.cxx
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
using namespace std;
#include "TransformationGUI_PositionDlg.h"
#include "DisplayGUI.h"
#include <AIS_InteractiveContext.hxx>
//=================================================================================
// class : TransformationGUI_PositionDlg()
// purpose : Constructs a TransformationGUI_PositionDlg 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.
//=================================================================================
TransformationGUI_PositionDlg::TransformationGUI_PositionDlg(QWidget* parent, const char* name, TransformationGUI* theTransformationGUI, SALOME_Selection* Sel, Handle(AIS_InteractiveContext) ic, bool modal, WFlags fl)
:GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POS_POINT")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POS_VECT")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POS_FACE")));
QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
setCaption(tr("GEOM_POSITION_TITLE"));
/***************************************************************/
GroupConstructors->setTitle(tr("GEOM_POSITION"));
RadioButton1->setPixmap(image0);
RadioButton2->setPixmap(image1);
RadioButton3->setPixmap(image2);
Group1 = new DlgRef_2Sel_QTD(this, "Group1");
Group1->GroupBox1->setTitle(tr("GEOM_POS_VERTEX"));
Group1->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
Group1->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
Group1->PushButton1->setPixmap(image3);
Group1->PushButton2->setPixmap(image3);
Layout1->addWidget(Group1, 1, 0);
/***************************************************************/
/* Initialisations */
myTransformationGUI = theTransformationGUI;
Init(ic);
}
//=================================================================================
// function : ~TransformationGUI_PositionDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg()
{
// no need to delete child widgets, Qt does it all for us
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::Init(Handle (AIS_InteractiveContext) ic)
{
/* init variables */
myConstructorId = 0;
myShapeType = 7;
myEditCurrentArgument = Group1->LineEdit1;
myOkBase1 = myOkBase2 = myOkObj1 = myOkObj2 = false;
myIC = ic;
myLocalContextId = -1;
myUseLocalContext = false;
/* signals and slots connections */
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
connect(Group1->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group1->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(Group1->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(Group1->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
/* displays Dialog */
Group1->show();
this->show();
return;
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void TransformationGUI_PositionDlg::ConstructorsClicked(int constructorId)
{
resize(0, 0);
myConstructorId = constructorId;
disconnect(mySelection, 0, this, 0);
myOkBase1 = myOkBase2 = myOkObj1 = myOkObj2 = false;
myEditCurrentArgument = Group1->LineEdit1;
Group1->LineEdit1->setText("");
Group1->LineEdit2->setText("");
if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) {
myIC->CloseLocalContext(myLocalContextId);
DisplayGUI* myDisplayGUI = new DisplayGUI();
myDisplayGUI->OnDisplayAll(true);
myUseLocalContext = false;
}
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
if(constructorId == 0) {
Group1->GroupBox1->setTitle(tr("GEOM_POS_VERTEX"));
myShapeType = 7; //Vertex
}
else if(constructorId == 1) {
Group1->GroupBox1->setTitle(tr("GEOM_POS_EDGE"));
myShapeType = 6; //Edge
}
else if(constructorId == 2) {
Group1->GroupBox1->setTitle(tr("GEOM_POS_FACE"));
myShapeType = 4; //Face
}
return;
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ClickOnOk()
{
this->ClickOnApply();
this->ClickOnCancel();
return;
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ClickOnApply()
{
QAD_Application::getDesktop()->putInfo(tr(""));
if(myEditCurrentArgument == Group1->LineEdit2 && myUseLocalContext) {
if(myOkBase2) {
myIC->InitSelected();
if(myIC->NbSelected() == 1) {
myIC->InitSelected();
myIC->MoreSelected();
myObj2 = myIC->SelectedShape();
myOkObj2 = true;
}
}
}
else if(myEditCurrentArgument == Group1->LineEdit1 && myUseLocalContext) {
if(myOkBase1) {
myIC->InitSelected();
if(myIC->NbSelected() == 1) {
myIC->InitSelected();
myIC->MoreSelected();
myObj1 = myIC->SelectedShape();
myOkObj1 = true;
}
}
}
if(myOkBase1 && myOkBase2 && myOkObj1 && myOkObj2)
myTransformationGUI->MakePositionAndDisplay(myGeomShape1, myGeomShape2, myShape1, myShape2, myObj1, myObj2);
this->ResetStateOfDialog();
return;
}
//=================================================================================
// function : ClickOnCancel()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ClickOnCancel()
{
this->ResetStateOfDialog();
GEOMBase_Skeleton::ClickOnCancel();
return;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void TransformationGUI_PositionDlg::SelectionIntoArgument()
{
if(myEditCurrentArgument == Group1->LineEdit1 && myUseLocalContext) {
if(myOkBase2) {
myIC->InitSelected();
if(myIC->NbSelected() == 1) {
myIC->InitSelected();
myIC->MoreSelected();
myObj2 = myIC->SelectedShape();
myOkObj2 = true;
}
}
}
else if(myEditCurrentArgument == Group1->LineEdit2 && myUseLocalContext) {
if(myOkBase1) {
myIC->InitSelected();
if(myIC->NbSelected() == 1) {
myIC->InitSelected();
myIC->MoreSelected();
myObj1 = myIC->SelectedShape();
myOkObj1 = true;
}
}
}
this->ResetStateOfDialog();
myEditCurrentArgument->setText("");
QString aString = ""; /* name of selection */
int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
if(nbSel != 1)
return;
// nbSel == 1
TopoDS_Shape S;
Standard_Boolean testResult;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject();
if(!myGeomBase->GetTopoFromSelection(mySelection, S))
return;
if(myEditCurrentArgument == Group1->LineEdit1) {
myShape1 = S;
myGeomShape1 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
if(!testResult)
return;
myEditCurrentArgument->setText(aString);
myOkBase1 = true;
}
else if(myEditCurrentArgument == Group1->LineEdit2) {
myShape2 = S;
myGeomShape2 = myGeomBase->ConvertIOinGEOMShape(IO, testResult);
if(!testResult)
return;
myEditCurrentArgument->setText(aString);
myOkBase2 = true;
}
/* local context is defined into the method */
DisplayGUI* myDisplayGUI = new DisplayGUI();
myDisplayGUI->PrepareSubShapeSelection(myShapeType, myLocalContextId);
myUseLocalContext = true;
return;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if(send == Group1->PushButton1) {
Group1->LineEdit1->setFocus();
myEditCurrentArgument = Group1->LineEdit1;
myOkBase1 = false;
myOkObj1 = false;
}
else if(send == Group1->PushButton2) {
Group1->LineEdit2->setFocus();
myEditCurrentArgument = Group1->LineEdit2;
myOkBase2 = false;
myOkObj2 = false;
}
mySelection->ClearIObjects();
this->SelectionIntoArgument();
return;
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
if(send == Group1->LineEdit1)
myEditCurrentArgument = Group1->LineEdit1;
else if (send == Group1->LineEdit2)
myEditCurrentArgument = Group1->LineEdit2;
else
return;
GEOMBase_Skeleton::LineEditReturnPressed();
return;
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::DeactivateActiveDialog()
{
this->ResetStateOfDialog();
GEOMBase_Skeleton::DeactivateActiveDialog();
return;
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
Group1->LineEdit1->setFocus();
myEditCurrentArgument = Group1->LineEdit1;
return;
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::enterEvent(QEvent* e)
{
if (GroupConstructors->isEnabled())
return;
this->ActivateThisDialog();
return;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::closeEvent(QCloseEvent* e)
{
/* same than click on cancel button */
this->ClickOnCancel();
return;
}
//=================================================================================
// function : ResetStateOfDialog()
// purpose :
//=================================================================================
void TransformationGUI_PositionDlg::ResetStateOfDialog()
{
/* Close its local contact if opened */
if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC && myUseLocalContext) {
myIC->CloseLocalContext(myLocalContextId);
myUseLocalContext = false;
DisplayGUI* myDisplayGUI = new DisplayGUI();
myDisplayGUI->OnDisplayAll();
}
return;
}

View File

@ -0,0 +1,91 @@
// GEOM GEOMGUI : GUI for Geometry component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : TransformationGUI_PositionDlg.h
// Author : Lucien PIGNOLONI
// Module : GEOM
// $Header$
#ifndef DIALOGBOX_POSITION_H
#define DIALOGBOX_POSITION_H
#include "GEOMBase_Skeleton.h"
#include "DlgRef_2Sel_QTD.h"
#include "TransformationGUI.h"
//=================================================================================
// class : TransformationGUI_PositionDlg
// purpose :
//=================================================================================
class TransformationGUI_PositionDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
TransformationGUI_PositionDlg(QWidget* parent = 0, const char* name = 0, TransformationGUI* theTransformationGUI = 0, SALOME_Selection* Sel = 0, Handle(AIS_InteractiveContext) ic = 0, bool modal = FALSE, WFlags fl = 0);
~TransformationGUI_PositionDlg();
private :
void Init(Handle(AIS_InteractiveContext) ic);
void enterEvent(QEvent* e);
void closeEvent(QCloseEvent* e);
void ResetStateOfDialog();
TransformationGUI* myTransformationGUI;
int myConstructorId; /* Current constructor id = radio button id */
/* Interactive and local context management see also : bool myUseLocalContext() */
Handle(AIS_InteractiveContext) myIC; /* Interactive context */
Standard_Integer myLocalContextId; /* identify a local context used by this method */
bool myUseLocalContext; /* true when this method as opened a local context */
TopoDS_Shape myShape1;
TopoDS_Shape myShape2;
TopoDS_Shape myObj1;
TopoDS_Shape myObj2;
int myShapeType;
GEOM::GEOM_Shape_var myGeomShape1;
GEOM::GEOM_Shape_var myGeomShape2;
bool myOkBase1;
bool myOkBase2;
bool myOkObj1;
bool myOkObj2;
DlgRef_2Sel_QTD* Group1;
private slots:
void ClickOnOk();
void ClickOnApply();
void ClickOnCancel();
void ActivateThisDialog();
void DeactivateActiveDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked(int constructorId);
};
#endif // DIALOGBOX_POSITION_H