From 0862244ac6a7629a8de53d35e3f4ee795155553a Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 12 Oct 2007 09:06:21 +0000 Subject: [PATCH] NPAL16559: EDF507: Implementation of a more advanced system of measurement. --- Makefile.in | 1 + idl/GEOM_Gen.idl | 6 + resources/angle.png | Bin 0 -> 252 bytes src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx | 97 ++++- src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx | 6 +- src/GEOM_I/GEOM_IMeasureOperations_i.cc | 30 +- src/GEOM_I/GEOM_IMeasureOperations_i.hh | 6 +- src/GEOM_SWIG/GEOM_TestMeasures.py | 24 ++ src/GEOM_SWIG/geompy.py | 23 ++ src/MeasureGUI/Makefile.in | 4 + src/MeasureGUI/MeasureGUI.cxx | 2 + .../MeasureGUI_2Sel1LineEdit_QTD.cxx | 93 +++-- src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.h | 50 +-- .../MeasureGUI_2Sel4LineEdit_QTD.cxx | 131 +++++++ src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.h | 60 ++++ src/MeasureGUI/MeasureGUI_AngleDlg.cxx | 330 ++++++++++++++++++ src/MeasureGUI/MeasureGUI_AngleDlg.h | 71 ++++ src/MeasureGUI/MeasureGUI_DistanceDlg.cxx | 23 +- src/MeasureGUI/MeasureGUI_DistanceDlg.h | 6 +- .../UIFiles/MeasureGUI_2Sel1LineEdit_QTD.ui | 95 ++--- .../UIFiles/MeasureGUI_2Sel4LineEdit_QTD.ui | 219 ++++++++++++ src/MeasureGUI/UIFiles/ui_to_cxx | 3 + 22 files changed, 1112 insertions(+), 168 deletions(-) create mode 100644 resources/angle.png create mode 100644 src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.cxx create mode 100644 src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.h create mode 100644 src/MeasureGUI/MeasureGUI_AngleDlg.cxx create mode 100644 src/MeasureGUI/MeasureGUI_AngleDlg.h create mode 100644 src/MeasureGUI/UIFiles/MeasureGUI_2Sel4LineEdit_QTD.ui diff --git a/Makefile.in b/Makefile.in index 84b64d931..e5697da5c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -95,6 +95,7 @@ line2points.png \ lineedge.png \ linepointvector.png \ mindist.png \ +angle.png \ mirrorPoint.png \ mirrorAxe.png \ mirrorPlane.png \ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 874ce239b..edc35ef21 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2370,6 +2370,12 @@ module GEOM out double X1, out double Y1, out double Z1, out double X2, out double Y2, out double Z2); + /*! + * Get angle between the given lines or linear edges. + * \param theShape1,theShape2 Shapes to find angle between. Lines or linear edges. + * \return Value of the angle between the given shapes. + */ + double GetAngle (in GEOM_Object theShape1, in GEOM_Object theShape2); /*! * Get point coordinates diff --git a/resources/angle.png b/resources/angle.png new file mode 100644 index 0000000000000000000000000000000000000000..9ec01ae67210a449c8f3de704cd6991345c274ce GIT binary patch literal 252 zcmVu zu?>ST5Jlf17oLVCP?li_s_c+0PU_C5os#w3)FlAzwY6GlwANIoDufHxWkgqQ>J2>f1LHJejEOpXHxvQ7Fo3S_n5P+Y z_ka-?fLd2uU=R}p#$+2F09`;#uvdG7fBzr;A@Bh#EJ*na=LpmQ0000 #include @@ -81,15 +82,17 @@ #include #include #include +#include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= /*! - * constructor: + * Constructor */ //============================================================================= GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations (GEOM_Engine* theEngine, int theDocID) @@ -100,7 +103,7 @@ GEOMImpl_IMeasureOperations::GEOMImpl_IMeasureOperations (GEOM_Engine* theEngine //============================================================================= /*! - * destructor + * Destructor */ //============================================================================= GEOMImpl_IMeasureOperations::~GEOMImpl_IMeasureOperations() @@ -1291,23 +1294,24 @@ Standard_Real GEOMImpl_IMeasureOperations::GetMinDistance } //======================================================================= -//function : PointCoordinates -//purpose : Get coordinates of point +/*! + * Get coordinates of point + */ //======================================================================= -void GEOMImpl_IMeasureOperations::PointCoordinates( Handle(GEOM_Object) theShape, - Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ ) +void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape, + Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) { - SetErrorCode( KO ); + SetErrorCode(KO); - if ( theShape.IsNull() ) + if (theShape.IsNull()) return; Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); - if ( aRefShape.IsNull() ) + if (aRefShape.IsNull()) return; TopoDS_Shape aShape = aRefShape->GetValue(); - if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX ) + if (aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX) { SetErrorCode( "Shape must be a vertex" ); return; @@ -1321,15 +1325,84 @@ void GEOMImpl_IMeasureOperations::PointCoordinates( Handle(GEOM_Object) theShape theX = aPnt.X(); theY = aPnt.Y(); theZ = aPnt.Z(); - SetErrorCode( OK ); + + SetErrorCode(OK); } - catch ( Standard_Failure ) + catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); SetErrorCode( aFail->GetMessageString() ); } } +//======================================================================= +/*! + * Compute angle (in degrees) between two lines + */ +//======================================================================= +Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine1, + Handle(GEOM_Object) theLine2) +{ + SetErrorCode(KO); + + Standard_Real anAngle = -1.0; + + if (theLine1.IsNull() || theLine2.IsNull()) + return anAngle; + + Handle(GEOM_Function) aRefLine1 = theLine1->GetLastFunction(); + Handle(GEOM_Function) aRefLine2 = theLine2->GetLastFunction(); + if (aRefLine1.IsNull() || aRefLine2.IsNull()) + return anAngle; + + TopoDS_Shape aLine1 = aRefLine1->GetValue(); + TopoDS_Shape aLine2 = aRefLine2->GetValue(); + if (aLine1.IsNull() || aLine2.IsNull() || + aLine1.ShapeType() != TopAbs_EDGE || + aLine2.ShapeType() != TopAbs_EDGE) + { + SetErrorCode("Two edges must be given"); + return anAngle; + } + + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + TopoDS_Edge E1 = TopoDS::Edge(aLine1); + TopoDS_Edge E2 = TopoDS::Edge(aLine2); + + double fp,lp; + Handle(Geom_Curve) C1 = BRep_Tool::Curve(E1,fp,lp); + Handle(Geom_Curve) C2 = BRep_Tool::Curve(E2,fp,lp); + + if (!C1->IsKind(STANDARD_TYPE(Geom_Line)) || + !C2->IsKind(STANDARD_TYPE(Geom_Line))) + { + SetErrorCode("The edges must be linear"); + return anAngle; + } + + Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(C1); + Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(C2); + + gp_Lin aLin1 = L1->Lin(); + gp_Lin aLin2 = L2->Lin(); + + anAngle = aLin1.Angle(aLin2); + anAngle /= PI180; // convert radians into degrees + + SetErrorCode(OK); + } + catch (Standard_Failure) + { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + } + + return anAngle; +} + //======================================================================= //function : StructuralDump //purpose : Structural (data exchange) style of output. diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx index b889d3872..2c221f3f3 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx @@ -122,8 +122,10 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations { Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1, Standard_Real& X2, Standard_Real& Y2, Standard_Real& Z2); - Standard_EXPORT void PointCoordinates(Handle(GEOM_Object) theShape, - Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ ); + Standard_EXPORT void PointCoordinates (Handle(GEOM_Object) theShape, + Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ); + + Standard_EXPORT Standard_Real GetAngle (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2); public: Standard_EXPORT static gp_Ax3 GetPosition (const TopoDS_Shape& theShape); diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 6167bf0e1..7be304056 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -17,6 +17,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include #include "GEOM_IMeasureOperations_i.hh" @@ -392,8 +393,8 @@ CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance * PointCoordinates */ //============================================================================= -void GEOM_IMeasureOperations_i::PointCoordinates( - GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z ) +void GEOM_IMeasureOperations_i::PointCoordinates (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z) { //Set a not done flag @@ -412,3 +413,28 @@ void GEOM_IMeasureOperations_i::PointCoordinates( // Get shape parameters GetOperations()->PointCoordinates( aShape, X, Y, Z ); } + +//============================================================================= +/*! + * GetAngle + */ +//============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + if (theShape1 == NULL || theShape2 == NULL) return -1.0; + + //Get the reference shapes + Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject + (theShape1->GetStudyID(), theShape1->GetEntry()); + Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject + (theShape2->GetStudyID(), theShape2->GetEntry()); + + if (aShape1.IsNull() || aShape2.IsNull()) return -1.0; + + // Get the angle + return GetOperations()->GetAngle(aShape1, aShape2); +} diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.hh b/src/GEOM_I/GEOM_IMeasureOperations_i.hh index 177644189..702162edc 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.hh +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.hh @@ -84,9 +84,11 @@ class GEOM_IMeasureOperations_i : CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1, CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2); + void PointCoordinates (GEOM::GEOM_Object_ptr theShape, + CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z); - void PointCoordinates( GEOM::GEOM_Object_ptr theShape, - CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z ); + CORBA::Double GetAngle (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2); ::GEOMImpl_IMeasureOperations* GetOperations() { return (::GEOMImpl_IMeasureOperations*)GetImpl(); } diff --git a/src/GEOM_SWIG/GEOM_TestMeasures.py b/src/GEOM_SWIG/GEOM_TestMeasures.py index c18c30648..1ca3cbccd 100644 --- a/src/GEOM_SWIG/GEOM_TestMeasures.py +++ b/src/GEOM_SWIG/GEOM_TestMeasures.py @@ -120,6 +120,30 @@ def TestMeasureOperations (geompy, math): print "\nMinimal distance between Box and Cube = ", MinDist + MinDistComps = geompy.MinDistanceComponents(box, cube) + print "\nMinimal distance between Box and Cube = ", MinDistComps[0] + print "Its components are (", MinDistComps[1], ", ", MinDistComps[2], ", ", MinDistComps[3], ")" + + ####### Angle ####### + + OX = geompy.MakeVectorDXDYDZ(10, 0,0) + OXY = geompy.MakeVectorDXDYDZ(10,10,0) + + # in one plane + Angle = geompy.GetAngle(OX, OXY) + + print "\nAngle between OX and OXY = ", Angle + if math.fabs(Angle - 45.0) > 1e-05: + print " Error: returned angle is", Angle, "while must be 45.0" + + # not in one plane + OXY_shift = geompy.MakeTranslation(OXY,10,-10,20) + Angle = geompy.GetAngle(OX, OXY_shift) + + print "Angle between OX and OXY_shift = ", Angle + if math.fabs(Angle - 45.0) > 1e-05: + print " Error: returned angle is", Angle, "while must be 45.0" + ####### Position (LCS) ####### Pos = geompy.GetPosition(box) diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 61228920c..ba1cb7c27 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -2040,6 +2040,29 @@ def MinDistance(theShape1, theShape2): print "MinDistance : ", MeasuOp.GetErrorCode() return aTuple[0] +## Get minimal distance between the given shapes. +# @param theShape1,theShape2 Shapes to find minimal distance between. +# @return Value of the minimal distance between the given shapes. +# +# Example: see GEOM_TestMeasures.py +def MinDistanceComponents(theShape1, theShape2): + aTuple = MeasuOp.GetMinDistance(theShape1, theShape2) + if MeasuOp.IsDone() == 0: + print "MinDistanceComponents : ", MeasuOp.GetErrorCode() + aRes = [aTuple[0], aTuple[4] - aTuple[1], aTuple[5] - aTuple[2], aTuple[6] - aTuple[3]] + return aRes + +## Get angle between the given shapes. +# @param theShape1,theShape2 Lines or linear edges to find angle between. +# @return Value of the angle between the given shapes. +# +# Example: see GEOM_TestMeasures.py +def GetAngle(theShape1, theShape2): + anAngle = MeasuOp.GetAngle(theShape1, theShape2) + if MeasuOp.IsDone() == 0: + print "GetAngle : ", MeasuOp.GetErrorCode() + return anAngle + ## Get min and max tolerances of sub-shapes of theShape # @param theShape Shape, to get tolerances of. # @return [FaceMin,FaceMax, EdgeMin,EdgeMax, VertMin,VertMax] diff --git a/src/MeasureGUI/Makefile.in b/src/MeasureGUI/Makefile.in index 7c3f45974..8391f494e 100644 --- a/src/MeasureGUI/Makefile.in +++ b/src/MeasureGUI/Makefile.in @@ -47,12 +47,14 @@ LIB_SRC = MeasureGUI.cxx \ MeasureGUI_1Sel12LineEdit_QTD.cxx \ MeasureGUI_1Sel1TextView_QTD.cxx \ MeasureGUI_2Sel1LineEdit_QTD.cxx \ + MeasureGUI_2Sel4LineEdit_QTD.cxx \ MeasureGUI_Skeleton.cxx \ MeasureGUI_PropertiesDlg.cxx \ MeasureGUI_CenterMassDlg.cxx \ MeasureGUI_InertiaDlg.cxx \ MeasureGUI_BndBoxDlg.cxx \ MeasureGUI_DistanceDlg.cxx \ + MeasureGUI_AngleDlg.cxx \ MeasureGUI_MaxToleranceDlg.cxx \ MeasureGUI_WhatisDlg.cxx \ MeasureGUI_CheckShapeDlg.cxx \ @@ -66,12 +68,14 @@ LIB_MOC = \ MeasureGUI_1Sel12LineEdit_QTD.h \ MeasureGUI_1Sel1TextView_QTD.h \ MeasureGUI_2Sel1LineEdit_QTD.h \ + MeasureGUI_2Sel4LineEdit_QTD.h \ MeasureGUI_Skeleton.h \ MeasureGUI_PropertiesDlg.h \ MeasureGUI_CenterMassDlg.h \ MeasureGUI_InertiaDlg.h \ MeasureGUI_BndBoxDlg.h \ MeasureGUI_DistanceDlg.h \ + MeasureGUI_AngleDlg.h \ MeasureGUI_MaxToleranceDlg.h \ MeasureGUI_WhatisDlg.h \ MeasureGUI_CheckShapeDlg.h \ diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index 2b2186d91..b872ced4c 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -38,6 +38,7 @@ #include "MeasureGUI_InertiaDlg.h" // Method INERTIA #include "MeasureGUI_BndBoxDlg.h" // Method BNDBOX #include "MeasureGUI_DistanceDlg.h" // Method DISTANCE +#include "MeasureGUI_AngleDlg.h" // Method ANGLE #include "MeasureGUI_MaxToleranceDlg.h" // Method MAXTOLERANCE #include "MeasureGUI_WhatisDlg.h" // Method WHATIS #include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE @@ -79,6 +80,7 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 703 : new MeasureGUI_InertiaDlg (getGeometryGUI(), parent); break; // INERTIA case 7041: new MeasureGUI_BndBoxDlg (getGeometryGUI(), parent); break; // BOUNDING BOX case 7042: new MeasureGUI_DistanceDlg (getGeometryGUI(), parent); break; // MIN DISTANCE + case 7043: new MeasureGUI_AngleDlg (getGeometryGUI(), parent); break; // ANGLE case 705 : new MeasureGUI_MaxToleranceDlg(getGeometryGUI(), parent); break; // MAXTOLERANCE case 706 : new MeasureGUI_WhatisDlg (getGeometryGUI(), parent); break; // WHATIS case 707 : new MeasureGUI_CheckShapeDlg (getGeometryGUI(), parent); break; // CHECKSHAPE diff --git a/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.cxx b/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.cxx index 5010e26b8..ad4fba90b 100644 --- a/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.cxx +++ b/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.cxx @@ -1,57 +1,36 @@ -// 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 -// /**************************************************************************** ** Form implementation generated from reading ui file 'MeasureGUI_2Sel1LineEdit_QTD.ui' ** -** Created: mar oct 28 16:11:14 2003 -** by: The User Interface Compiler (uic) +** Created: Tue Oct 9 14:45:59 2007 +** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ + #include "MeasureGUI_2Sel1LineEdit_QTD.h" #include +#include #include #include #include -#include #include #include #include -/* - * Constructs a MeasureGUI_2Sel1LineEdit_QTD which is a child of 'parent', with the +/* + * Constructs a MeasureGUI_2Sel1LineEdit_QTD as a child of 'parent', with the * name 'name' and widget flags set to 'f'. */ -MeasureGUI_2Sel1LineEdit_QTD::MeasureGUI_2Sel1LineEdit_QTD( QWidget* parent, const char* name, WFlags fl ) +MeasureGUI_2Sel1LineEdit_QTD::MeasureGUI_2Sel1LineEdit_QTD( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { if ( !name ) setName( "MeasureGUI_2Sel1LineEdit_QTD" ); - resize( 129, 115 ); - setCaption( trUtf8( "MeasureGUI_2Sel1LineEdit_QTD" ) ); MeasureGUI_2Sel1LineEdit_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "MeasureGUI_2Sel1LineEdit_QTDLayout"); GroupBox1 = new QGroupBox( this, "GroupBox1" ); GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, GroupBox1->sizePolicy().hasHeightForWidth() ) ); - GroupBox1->setTitle( trUtf8( "" ) ); GroupBox1->setColumnLayout(0, Qt::Vertical ); GroupBox1->layout()->setSpacing( 6 ); GroupBox1->layout()->setMargin( 11 ); @@ -59,38 +38,14 @@ MeasureGUI_2Sel1LineEdit_QTD::MeasureGUI_2Sel1LineEdit_QTD( QWidget* parent, co GroupBox1Layout->setAlignment( Qt::AlignTop ); Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); - QSpacerItem* spacer = new QSpacerItem( 0, 60, QSizePolicy::Minimum, QSizePolicy::Expanding ); - Layout1->addItem( spacer, 3, 2 ); - - TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); - TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); - TextLabel3->setText( trUtf8( "TL3" ) ); - - Layout1->addWidget( TextLabel3, 2, 0 ); - - LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); - - Layout1->addMultiCellWidget( LineEdit3, 2, 2, 1, 2 ); - - LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); - - Layout1->addWidget( LineEdit2, 1, 2 ); - - TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); - TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); - TextLabel2->setText( trUtf8( "TL2" ) ); - - Layout1->addWidget( TextLabel2, 1, 0 ); TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); - TextLabel1->setText( trUtf8( "TL1" ) ); Layout1->addWidget( TextLabel1, 0, 0 ); PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); - PushButton1->setText( trUtf8( "" ) ); Layout1->addWidget( PushButton1, 0, 1 ); @@ -98,18 +53,40 @@ MeasureGUI_2Sel1LineEdit_QTD::MeasureGUI_2Sel1LineEdit_QTD( QWidget* parent, co Layout1->addWidget( LineEdit1, 0, 2 ); + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); - PushButton2->setText( trUtf8( "" ) ); Layout1->addWidget( PushButton2, 1, 1 ); + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); + + Layout1->addMultiCellWidget( LineEdit3, 2, 2, 1, 2 ); + Spacer8 = new QSpacerItem( 0, 60, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( Spacer8, 3, 2 ); + GroupBox1Layout->addLayout( Layout1, 0, 0 ); MeasureGUI_2Sel1LineEdit_QTDLayout->addWidget( GroupBox1, 0, 0 ); + languageChange(); + resize( QSize(129, 115).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); } -/* +/* * Destroys the object and frees any allocated resources */ MeasureGUI_2Sel1LineEdit_QTD::~MeasureGUI_2Sel1LineEdit_QTD() @@ -117,3 +94,11 @@ MeasureGUI_2Sel1LineEdit_QTD::~MeasureGUI_2Sel1LineEdit_QTD() // no need to delete child widgets, Qt does it all for us } +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void MeasureGUI_2Sel1LineEdit_QTD::languageChange() +{ +} + diff --git a/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.h b/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.h index b77968ec3..aeeb6775f 100644 --- a/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.h +++ b/src/MeasureGUI/MeasureGUI_2Sel1LineEdit_QTD.h @@ -1,45 +1,29 @@ -// 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 -// /**************************************************************************** ** Form interface generated from reading ui file 'MeasureGUI_2Sel1LineEdit_QTD.ui' ** -** Created: mar oct 28 16:11:14 2003 -** by: The User Interface Compiler (uic) +** Created: Tue Oct 9 14:45:55 2007 +** by: The User Interface Compiler ($Id$) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ + #ifndef MEASUREGUI_2SEL1LINEEDIT_QTD_H #define MEASUREGUI_2SEL1LINEEDIT_QTD_H #include #include -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QSpacerItem; class QGroupBox; class QLabel; -class QLineEdit; class QPushButton; +class QLineEdit; class MeasureGUI_2Sel1LineEdit_QTD : public QWidget -{ +{ Q_OBJECT public: @@ -47,20 +31,24 @@ public: ~MeasureGUI_2Sel1LineEdit_QTD(); QGroupBox* GroupBox1; - QLabel* TextLabel3; - QLineEdit* LineEdit3; - QLineEdit* LineEdit2; - QLabel* TextLabel2; QLabel* TextLabel1; QPushButton* PushButton1; QLineEdit* LineEdit1; + QLabel* TextLabel2; QPushButton* PushButton2; - + QLineEdit* LineEdit2; + QLabel* TextLabel3; + QLineEdit* LineEdit3; protected: QGridLayout* MeasureGUI_2Sel1LineEdit_QTDLayout; QGridLayout* GroupBox1Layout; QGridLayout* Layout1; + QSpacerItem* Spacer8; + +protected slots: + virtual void languageChange(); + }; #endif // MEASUREGUI_2SEL1LINEEDIT_QTD_H diff --git a/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.cxx b/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.cxx new file mode 100644 index 000000000..3c5563c72 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.cxx @@ -0,0 +1,131 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'MeasureGUI_2Sel4LineEdit_QTD.ui' +** +** Created: Tue Oct 9 14:32:18 2007 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "MeasureGUI_2Sel4LineEdit_QTD.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a MeasureGUI_2Sel4LineEdit_QTD as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +MeasureGUI_2Sel4LineEdit_QTD::MeasureGUI_2Sel4LineEdit_QTD( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + if ( !name ) + setName( "MeasureGUI_2Sel4LineEdit_QTD" ); + MeasureGUI_2Sel4LineEdit_QTDLayout = new QGridLayout( this, 1, 1, 0, 6, "MeasureGUI_2Sel4LineEdit_QTDLayout"); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, 0, 0, GroupBox1->sizePolicy().hasHeightForWidth() ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 6 ); + GroupBox1->layout()->setMargin( 11 ); + GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + + Layout1 = new QGridLayout( 0, 1, 1, 0, 6, "Layout1"); + + TextLabel1 = new QLabel( GroupBox1, "TextLabel1" ); + TextLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel1, 0, 0 ); + + PushButton1 = new QPushButton( GroupBox1, "PushButton1" ); + PushButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton1->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( PushButton1, 0, 1 ); + + LineEdit1 = new QLineEdit( GroupBox1, "LineEdit1" ); + + Layout1->addWidget( LineEdit1, 0, 2 ); + + TextLabel2 = new QLabel( GroupBox1, "TextLabel2" ); + TextLabel2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel2, 1, 0 ); + + PushButton2 = new QPushButton( GroupBox1, "PushButton2" ); + PushButton2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, PushButton2->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( PushButton2, 1, 1 ); + + LineEdit2 = new QLineEdit( GroupBox1, "LineEdit2" ); + + Layout1->addWidget( LineEdit2, 1, 2 ); + + TextLabel3 = new QLabel( GroupBox1, "TextLabel3" ); + TextLabel3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel3->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel3, 2, 0 ); + + LineEdit3 = new QLineEdit( GroupBox1, "LineEdit3" ); + + Layout1->addMultiCellWidget( LineEdit3, 2, 2, 1, 2 ); + + TextLabel4 = new QLabel( GroupBox1, "TextLabel4" ); + TextLabel4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel4->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel4, 3, 0 ); + + LineEdit4 = new QLineEdit( GroupBox1, "LineEdit4" ); + + Layout1->addMultiCellWidget( LineEdit4, 3, 3, 1, 2 ); + + TextLabel5 = new QLabel( GroupBox1, "TextLabel5" ); + TextLabel5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel5->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel5, 4, 0 ); + + LineEdit5 = new QLineEdit( GroupBox1, "LineEdit5" ); + + Layout1->addMultiCellWidget( LineEdit5, 4, 4, 1, 2 ); + + TextLabel6 = new QLabel( GroupBox1, "TextLabel6" ); + TextLabel6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, TextLabel6->sizePolicy().hasHeightForWidth() ) ); + + Layout1->addWidget( TextLabel6, 5, 0 ); + + LineEdit6 = new QLineEdit( GroupBox1, "LineEdit6" ); + + Layout1->addMultiCellWidget( LineEdit6, 5, 5, 1, 2 ); + Spacer8 = new QSpacerItem( 0, 60, QSizePolicy::Minimum, QSizePolicy::Expanding ); + Layout1->addItem( Spacer8, 6, 2 ); + + GroupBox1Layout->addLayout( Layout1, 0, 0 ); + + MeasureGUI_2Sel4LineEdit_QTDLayout->addWidget( GroupBox1, 0, 0 ); + languageChange(); + resize( QSize(129, 163).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); +} + +/* + * Destroys the object and frees any allocated resources + */ +MeasureGUI_2Sel4LineEdit_QTD::~MeasureGUI_2Sel4LineEdit_QTD() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void MeasureGUI_2Sel4LineEdit_QTD::languageChange() +{ +} + diff --git a/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.h b/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.h new file mode 100644 index 000000000..605c71d62 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_2Sel4LineEdit_QTD.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'MeasureGUI_2Sel4LineEdit_QTD.ui' +** +** Created: Tue Oct 9 14:31:27 2007 +** by: The User Interface Compiler ($Id$) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#ifndef MEASUREGUI_2SEL4LINEEDIT_QTD_H +#define MEASUREGUI_2SEL4LINEEDIT_QTD_H + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QSpacerItem; +class QGroupBox; +class QLabel; +class QPushButton; +class QLineEdit; + +class MeasureGUI_2Sel4LineEdit_QTD : public QWidget +{ + Q_OBJECT + +public: + MeasureGUI_2Sel4LineEdit_QTD( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~MeasureGUI_2Sel4LineEdit_QTD(); + + QGroupBox* GroupBox1; + QLabel* TextLabel1; + QPushButton* PushButton1; + QLineEdit* LineEdit1; + QLabel* TextLabel2; + QPushButton* PushButton2; + QLineEdit* LineEdit2; + QLabel* TextLabel3; + QLineEdit* LineEdit3; + QLabel* TextLabel4; + QLineEdit* LineEdit4; + QLabel* TextLabel5; + QLineEdit* LineEdit5; + QLabel* TextLabel6; + QLineEdit* LineEdit6; + +protected: + QGridLayout* MeasureGUI_2Sel4LineEdit_QTDLayout; + QGridLayout* GroupBox1Layout; + QGridLayout* Layout1; + QSpacerItem* Spacer8; + +protected slots: + virtual void languageChange(); + +}; + +#endif // MEASUREGUI_2SEL4LINEEDIT_QTD_H diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx new file mode 100644 index 000000000..468d6788c --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx @@ -0,0 +1,330 @@ +// 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 : MeasureGUI_AngleDlg.cxx +// Author : Julia DOROVSKIKH +// Module : GEOM +// $Header$ + +#include "MeasureGUI_AngleDlg.h" + +#include "MeasureGUI_2Sel1LineEdit_QTD.h" + +#include "GEOMBase.h" +#include "GEOM_Displayer.h" +#include "DlgRef_SpinBox.h" + +#include "SUIT_Session.h" +#include "SUIT_ViewWindow.h" +#include "SOCC_Prs.h" +#include "SOCC_ViewModel.h" +#include "SalomeApp_Tools.h" + +// OCCT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include + +#include "GEOMImpl_Types.hxx" + +#include "utilities.h" + +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//================================================================================= +// class : MeasureGUI_AngleDlg() +// purpose : Constructs a MeasureGUI_AngleDlg 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. +//================================================================================= +MeasureGUI_AngleDlg::MeasureGUI_AngleDlg (GeometryGUI* GUI, QWidget* parent) + : MeasureGUI_Skeleton(GUI, parent, "MeasureGUI_AngleDlg") +{ + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_ANGLE"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setCaption(tr("GEOM_MEASURE_ANGLE_TITLE")); + + // Widgets + + GroupConstructors->setTitle(tr("GEOM_MEASURE_ANGLE_ANGLE")); + RadioButton1->setPixmap(image0); + + myGrp = new MeasureGUI_2Sel1LineEdit_QTD(this, "myGrp"); + myGrp->GroupBox1->setTitle(tr("GEOM_MEASURE_ANGLE_OBJ")); + myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1")); + myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2")); + myGrp->TextLabel3->setText(tr("GEOM_MEASURE_ANGLE_IS")); + myGrp->LineEdit3->setReadOnly(TRUE); + myGrp->PushButton1->setPixmap(image1); + myGrp->PushButton2->setPixmap(image1); + myGrp->LineEdit1->setReadOnly(true); + myGrp->LineEdit2->setReadOnly(true); + + Layout1->addWidget(myGrp, 1, 0); + + // Help page reference + myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#Angle"; + + // Initialisation + Init(); +} + +//================================================================================= +// function : ~MeasureGUI_AngleDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_AngleDlg::~MeasureGUI_AngleDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_AngleDlg::Init() +{ + mySelBtn = myGrp->PushButton1; + mySelEdit = myGrp->LineEdit1; + mySelBtn2 = myGrp->PushButton2; + mySelEdit2 = myGrp->LineEdit2; + + myEditCurrentArgument = mySelEdit; + + connect(mySelEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + globalSelection(GEOM_LINE); + MeasureGUI_Skeleton::Init(); +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void MeasureGUI_AngleDlg::SelectionIntoArgument() +{ + Standard_Boolean testResult = Standard_False; + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult); + + if (!testResult) + aSelectedObject = GEOM::GEOM_Object::_nil(); + + if (myEditCurrentArgument == mySelEdit) + myObj = aSelectedObject; + else + myObj2 = aSelectedObject; + + processObject(); +} + +//================================================================================= +// function : processObject() +// purpose : Fill dialogs fields in accordance with myObj and myObj2 +//================================================================================= +void MeasureGUI_AngleDlg::processObject() +{ + myGrp->LineEdit1->setText(!myObj->_is_nil() ? GEOMBase::GetName(myObj ) : ""); + myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : ""); + + double anAngle = 0.; + if (getParameters(anAngle)) + { + myGrp->LineEdit3->setText(DlgRef_SpinBox::PrintDoubleValue(anAngle)); + redisplayPreview(); + } + else + { + myGrp->LineEdit3->setText(""); + erasePreview(); + } +} + +//================================================================================= +// function : getParameters() +// purpose : Get angle between objects +//================================================================================= +bool MeasureGUI_AngleDlg::getParameters (double& theAngle) +{ + QString msg; + if (isValid(msg)) { + try { + theAngle = GEOM::GEOM_IMeasureOperations::_narrow(getOperation())->GetAngle(myObj, myObj2); + } + catch(const SALOME::SALOME_Exception& e) { + SalomeApp_Tools::QtCatchCorbaException(e); + return false; + } + + return getOperation()->IsDone(); + } + + return false; +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_AngleDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == mySelBtn) { + mySelEdit->setFocus(); + myEditCurrentArgument = mySelEdit; + } + else { + mySelEdit2->setFocus(); + myEditCurrentArgument = mySelEdit2; + } + + globalSelection(GEOM_LINE); + SelectionIntoArgument(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_AngleDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + + if (send == mySelEdit) + myEditCurrentArgument = mySelEdit; + else + myEditCurrentArgument = mySelEdit2; + + if (GEOMBase::SelectionByNameInDialogs(this, mySelEdit->text(), selectedIO())) + mySelEdit->setText(mySelEdit->text()); +} + +//================================================================================= +// function : buildPrs() +// purpose : +//================================================================================= +SALOME_Prs* MeasureGUI_AngleDlg::buildPrs() +{ + double anAngle = 0.; + + SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + + if (myObj->_is_nil() || myObj2->_is_nil() || !getParameters(anAngle) || + vw->getViewManager()->getType() != OCCViewer_Viewer::Type()) + return 0; + + if (anAngle > Precision::Angular()) + { + try + { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + TopoDS_Shape S1, S2; + if (GEOMBase::GetShape(myObj , S1, TopAbs_EDGE) && + GEOMBase::GetShape(myObj2, S2, TopAbs_EDGE)) + { + TopoDS_Edge anEdge1 = TopoDS::Edge(S1); + TopoDS_Edge anEdge2 = TopoDS::Edge(S2); + + // Build a plane for angle dimension presentation {P11, P12, P3} + TopoDS_Vertex V11, V12, V21, V22; + TopExp::Vertices(anEdge1, V11, V12); + TopExp::Vertices(anEdge2, V21, V22); + + gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1)); + gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex (anEdge1)); + + gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2)); + gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex (anEdge2)); + + // *P3 + // \ + // \ + // *P22 + // / + // / + // P11 / P12 + // *-----/----------* + // \ / + // \ / + // *P21 + gp_Pnt aP3 (aP22.XYZ() + aP11.XYZ() - aP21.XYZ()); + + gce_MakePln gce_MP (aP11, aP12, aP3); + Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value()); + + // Build the angle dimension presentation + QString aLabel; + aLabel.sprintf("%.1f", anAngle); + + Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension + (anEdge1, anEdge2, aPlane, anAngle * PI180, + TCollection_ExtendedString((Standard_CString)aLabel.latin1())); + + SOCC_Prs* aPrs = + dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); + + if (aPrs) + aPrs->AddObject(anIO); + + return aPrs; + } + } + catch(Standard_Failure) + { + } + } + + return 0; +} + +//================================================================================= +// function : isValid() +// purpose : +//================================================================================= +bool MeasureGUI_AngleDlg::isValid(QString& msg) +{ + return MeasureGUI_Skeleton::isValid(msg) && !myObj2->_is_nil(); +} diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.h b/src/MeasureGUI/MeasureGUI_AngleDlg.h new file mode 100644 index 000000000..0ef32abc4 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.h @@ -0,0 +1,71 @@ +// 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 : MeasureGUI_AngleDlg.h +// Author : Julia DOROVSKIKH +// Module : GEOM + +#ifndef DIALOGBOX_ANGLE_H +#define DIALOGBOX_ANGLE_H + +#include "GEOM_MeasureGUI.hxx" + +#include "MeasureGUI_Skeleton.h" + +class MeasureGUI_2Sel1LineEdit_QTD; + +//================================================================================= +// class : MeasureGUI_AngleDlg +// purpose : +//================================================================================= +class GEOM_MEASUREGUI_EXPORT MeasureGUI_AngleDlg : public MeasureGUI_Skeleton +{ + Q_OBJECT + +public: + MeasureGUI_AngleDlg (GeometryGUI* GUI, QWidget* parent); + ~MeasureGUI_AngleDlg(); + +protected: + // redefined from GEOMBase_Helper and MeasureGUI_Skeleton + virtual void processObject(); + virtual SALOME_Prs* buildPrs(); + virtual void SelectionIntoArgument(); + virtual void LineEditReturnPressed(); + virtual void SetEditCurrentArgument(); + virtual bool isValid (QString& msg); + +private: + void Init(); + bool getParameters (double& theAngle); + +private: + QLineEdit* myEditCurrentArgument; + QLineEdit* mySelEdit2; + QPushButton* mySelBtn2; + MeasureGUI_2Sel1LineEdit_QTD* myGrp; + + GEOM::GEOM_Object_var myObj2; +}; + +#endif // DIALOGBOX_ANGLE_H diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx index 163b19653..93c37b837 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -27,7 +27,7 @@ // $Header$ #include "MeasureGUI_DistanceDlg.h" -#include "MeasureGUI_2Sel1LineEdit_QTD.h" +#include "MeasureGUI_2Sel4LineEdit_QTD.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" #include "DlgRef_SpinBox.h" @@ -78,12 +78,18 @@ MeasureGUI_DistanceDlg::MeasureGUI_DistanceDlg( GeometryGUI* GUI, QWidget* paren GroupConstructors->setTitle( tr( "GEOM_DISTANCE" ) ); RadioButton1->setPixmap( image0 ); - myGrp = new MeasureGUI_2Sel1LineEdit_QTD( this, "myGrp" ); + myGrp = new MeasureGUI_2Sel4LineEdit_QTD( this, "myGrp" ); myGrp->GroupBox1->setTitle( tr( "GEOM_MINDIST_OBJ" ) ); myGrp->TextLabel1->setText( tr( "GEOM_OBJECT_I" ).arg( "1" ) ); myGrp->TextLabel2->setText( tr( "GEOM_OBJECT_I" ).arg( "2" ) ); myGrp->TextLabel3->setText( tr( "GEOM_LENGTH" ) ); + myGrp->TextLabel4->setText( tr( "GEOM_DX" ) ); + myGrp->TextLabel5->setText( tr( "GEOM_DY" ) ); + myGrp->TextLabel6->setText( tr( "GEOM_DZ" ) ); myGrp->LineEdit3->setReadOnly( TRUE ); + myGrp->LineEdit4->setReadOnly( TRUE ); + myGrp->LineEdit5->setReadOnly( TRUE ); + myGrp->LineEdit6->setReadOnly( TRUE ); myGrp->PushButton1->setPixmap( image1 ); myGrp->PushButton2->setPixmap( image1 ); myGrp->LineEdit1->setReadOnly( true ); @@ -152,7 +158,7 @@ void MeasureGUI_DistanceDlg::SelectionIntoArgument() //================================================================================= // function : processObject() -// purpose : Fill dialogs fileds in accordance with myObj and myObj2 +// purpose : Fill dialogs fields in accordance with myObj and myObj2 //================================================================================= void MeasureGUI_DistanceDlg::processObject() { @@ -161,14 +167,23 @@ void MeasureGUI_DistanceDlg::processObject() gp_Pnt aPnt1, aPnt2; double aDist = 0.; - if ( getParameters( aDist, aPnt1, aPnt2 ) ) + if (getParameters(aDist, aPnt1, aPnt2)) { myGrp->LineEdit3->setText( DlgRef_SpinBox::PrintDoubleValue( aDist ) ); + + gp_XYZ aVec = aPnt2.XYZ() - aPnt1.XYZ(); + myGrp->LineEdit4->setText( DlgRef_SpinBox::PrintDoubleValue( aVec.X() ) ); + myGrp->LineEdit5->setText( DlgRef_SpinBox::PrintDoubleValue( aVec.Y() ) ); + myGrp->LineEdit6->setText( DlgRef_SpinBox::PrintDoubleValue( aVec.Z() ) ); + redisplayPreview(); } else { myGrp->LineEdit3->setText( "" ); + myGrp->LineEdit4->setText( "" ); + myGrp->LineEdit5->setText( "" ); + myGrp->LineEdit6->setText( "" ); erasePreview(); } } diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.h b/src/MeasureGUI/MeasureGUI_DistanceDlg.h index cd4702a3a..795b63558 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.h +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.h @@ -17,7 +17,7 @@ // License along with 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -31,7 +31,7 @@ #include "MeasureGUI_Skeleton.h" -class MeasureGUI_2Sel1LineEdit_QTD; +class MeasureGUI_2Sel4LineEdit_QTD; class gp_Pnt; #if defined WNT && defined MEASUREGUI_EXPORTS @@ -74,7 +74,7 @@ private: QLineEdit* mySelEdit2; QPushButton* mySelBtn2; - MeasureGUI_2Sel1LineEdit_QTD* myGrp; + MeasureGUI_2Sel4LineEdit_QTD* myGrp; GEOM::GEOM_Object_var myObj2; }; diff --git a/src/MeasureGUI/UIFiles/MeasureGUI_2Sel1LineEdit_QTD.ui b/src/MeasureGUI/UIFiles/MeasureGUI_2Sel1LineEdit_QTD.ui index e68cca900..0cb627406 100644 --- a/src/MeasureGUI/UIFiles/MeasureGUI_2Sel1LineEdit_QTD.ui +++ b/src/MeasureGUI/UIFiles/MeasureGUI_2Sel1LineEdit_QTD.ui @@ -12,9 +12,6 @@ 115 - - MeasureGUI_2Sel1LineEdit_QTD - unnamed @@ -37,9 +34,6 @@ 0 - - - unnamed @@ -64,26 +58,9 @@ 6 - - - Spacer8 - - - Vertical - - - Expanding - - - - 0 - 60 - - - - + - TextLabel3 + TextLabel1 @@ -93,23 +70,10 @@ 0 - - TL3 - - - - - LineEdit3 - - - - - LineEdit2 - - + - TextLabel2 + PushButton1 @@ -119,13 +83,15 @@ 0 - - TL2 + + + + LineEdit1 - + - TextLabel1 + TextLabel2 @@ -135,13 +101,10 @@ 0 - - TL1 - - + - PushButton1 + PushButton2 @@ -151,18 +114,15 @@ 0 - - - - + - LineEdit1 + LineEdit2 - + - PushButton2 + TextLabel3 @@ -172,10 +132,29 @@ 0 - - + + + + LineEdit3 + + + Spacer8 + + + Vertical + + + Expanding + + + + 0 + 60 + + + diff --git a/src/MeasureGUI/UIFiles/MeasureGUI_2Sel4LineEdit_QTD.ui b/src/MeasureGUI/UIFiles/MeasureGUI_2Sel4LineEdit_QTD.ui new file mode 100644 index 000000000..8fb9b3184 --- /dev/null +++ b/src/MeasureGUI/UIFiles/MeasureGUI_2Sel4LineEdit_QTD.ui @@ -0,0 +1,219 @@ + +MeasureGUI_2Sel4LineEdit_QTD + + + MeasureGUI_2Sel4LineEdit_QTD + + + + 0 + 0 + 129 + 163 + + + + + unnamed + + + 0 + + + 6 + + + + GroupBox1 + + + + 7 + 7 + 0 + 0 + + + + + unnamed + + + 11 + + + 6 + + + + Layout1 + + + + unnamed + + + 0 + + + 6 + + + + TextLabel1 + + + + 0 + 0 + 0 + 0 + + + + + + PushButton1 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit1 + + + + + TextLabel2 + + + + 0 + 0 + 0 + 0 + + + + + + PushButton2 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit2 + + + + + TextLabel3 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit3 + + + + + TextLabel4 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit4 + + + + + TextLabel5 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit5 + + + + + TextLabel6 + + + + 0 + 0 + 0 + 0 + + + + + + LineEdit6 + + + + + Spacer8 + + + Vertical + + + Expanding + + + + 0 + 60 + + + + + + + + + + + diff --git a/src/MeasureGUI/UIFiles/ui_to_cxx b/src/MeasureGUI/UIFiles/ui_to_cxx index 6ffec252b..eea9301e5 100755 --- a/src/MeasureGUI/UIFiles/ui_to_cxx +++ b/src/MeasureGUI/UIFiles/ui_to_cxx @@ -34,5 +34,8 @@ uic -o MeasureGUI_1Sel12LineEdit_QTD.cxx -impl MeasureGUI_1Sel12LineEdit_QTD.h M uic -o MeasureGUI_2Sel1LineEdit_QTD.h MeasureGUI_2Sel1LineEdit_QTD.ui uic -o MeasureGUI_2Sel1LineEdit_QTD.cxx -impl MeasureGUI_2Sel1LineEdit_QTD.h MeasureGUI_2Sel1LineEdit_QTD.ui +uic -o MeasureGUI_2Sel4LineEdit_QTD.h MeasureGUI_2Sel4LineEdit_QTD.ui +uic -o MeasureGUI_2Sel4LineEdit_QTD.cxx -impl MeasureGUI_2Sel4LineEdit_QTD.h MeasureGUI_2Sel4LineEdit_QTD.ui + #uic -o MeasureGUI_1Sel1TextView_QTD.h MeasureGUI_1Sel1TextView_QTD.ui #uic -o MeasureGUI_1Sel1TextView_QTD.cxx -impl MeasureGUI_1Sel1TextView_QTD.h MeasureGUI_1Sel1TextView_QTD.ui -- 2.39.2