1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MeasureGUI_PointDlg.cxx
25 // Author : Lucien PIGNOLONI
29 #include "MeasureGUI_PointDlg.h"
32 #include "utilities.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "SalomeApp_SelectionMgr.h"
37 #include <TColStd_MapOfInteger.hxx>
38 #include <TopAbs_ShapeEnum.hxx>
39 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Vertex.hxx>
42 #include <BRep_Tool.hxx>
44 #include <TopAbs_ShapeEnum.hxx>
45 #include <TopTools_IndexedMapOfShape.hxx>
46 #include <TColStd_IndexedMapOfInteger.hxx>
49 #include <qlineedit.h>
52 #include <qpushbutton.h>
53 #include <qgroupbox.h>
54 #include <qbuttongroup.h>
55 #include <qradiobutton.h>
56 #include <qapplication.h>
58 //=================================================================================
59 // class : MeasureGUI_PointDlg()
60 // purpose : Constructs a MeasureGUI_PointDlg which is a child of 'parent'
62 //=================================================================================
63 MeasureGUI_PointDlg::MeasureGUI_PointDlg( GeometryGUI* GUI, QWidget* parent )
64 : MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_PointDlg" )
66 QPixmap iconPnt( SUIT_Session::session()->resourceMgr()->loadPixmap(
67 "GEOM",tr( "ICON_DLG_POINT" ) ) );
69 QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap(
70 "GEOM",tr( "ICON_SELECT" ) ) );
72 setCaption( tr( "CAPTION" ) );
74 GroupConstructors->setTitle( tr( "CAPTION" ) );
75 RadioButton1->setPixmap( iconPnt );
77 QGroupBox* aGrp = new QGroupBox( 2, Qt::Horizontal, tr( "COORDINATES" ), this );
79 new QLabel( tr( "POINT" ), aGrp );
80 QFrame* aFrame = new QFrame( aGrp );
81 mySelBtn = new QPushButton( aFrame );
82 mySelBtn->setPixmap( iconSelect );
83 mySelEdit = new QLineEdit( aFrame );
84 QHBoxLayout* aLay = new QHBoxLayout( aFrame, 0, 10 );
85 aLay->addWidget( mySelBtn );
86 aLay->addWidget( mySelEdit );
88 new QLabel( tr( "X" ), aGrp );
89 myX = new QLineEdit( aGrp );
90 new QLabel( tr( "Y" ), aGrp );
91 myY = new QLineEdit( aGrp );
92 new QLabel( tr( "Z" ), aGrp );
93 myZ = new QLineEdit( aGrp );
95 mySelEdit->setReadOnly( true );
96 myX->setReadOnly( true );
97 myY->setReadOnly( true );
98 myZ->setReadOnly( true );
100 Layout1->addWidget( aGrp, 1, 0 );
106 //=================================================================================
107 // function : ~MeasureGUI_PointDlg()
108 // purpose : Destroys the object and frees any allocated resources
109 //======================myX->setReadOnly( true );===========================================================
110 MeasureGUI_PointDlg::~MeasureGUI_PointDlg()
115 //=================================================================================
118 //=================================================================================
119 void MeasureGUI_PointDlg::Init()
121 QSize aSize( size() );
122 resize( (int)(aSize.width() *0.75 ), aSize.height() );
123 MeasureGUI_Skeleton::Init();
126 //=================================================================================
127 // function : activateSelection
129 //=================================================================================
130 void MeasureGUI_PointDlg::activateSelection()
132 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
135 //=================================================================================
136 // function : SelectionIntoArgument
138 //=================================================================================
139 void MeasureGUI_PointDlg::SelectionIntoArgument()
143 myObj = GEOM::GEOM_Object::_nil();
144 mySelEdit->setText( "" );
149 Standard_Boolean testResult = Standard_False;
150 GEOM::GEOM_Object_var aSelectedObject =
151 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
153 if( !testResult || aSelectedObject->_is_nil() )
156 myObj = aSelectedObject;
158 TColStd_IndexedMapOfInteger anIndexes;
159 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
160 selectionMgr()->GetIndexes( firstIObject(), anIndexes );
163 if ( anIndexes.Extent() > 1 || !GEOMBase::GetShape( myObj, aShape ) || aShape.IsNull() )
166 TopoDS_Vertex aPoint;
167 QString aName = GEOMBase::GetName( myObj );
168 if ( anIndexes.Extent() == 0 )
170 if ( aShape.ShapeType() == TopAbs_VERTEX )
171 aPoint = TopoDS::Vertex( aShape );
175 int i = anIndexes( 1 );
177 TopTools_IndexedMapOfShape aShapes;
178 TopExp::MapShapes( aShape, aShapes );
180 if ( aShape != aShapes( i ) )
181 aName += QString( ":%1" ).arg( i );
183 aPoint = TopoDS::Vertex( aShapes( i ) );
186 if ( !aPoint.IsNull() )
188 gp_Pnt aPnt = BRep_Tool::Pnt( aPoint );
189 mySelEdit->setText( aName );
190 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
191 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
192 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
197 myObj = GEOM::GEOM_Object::_nil();
198 mySelEdit->setText( "" );