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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 "LightApp_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 );
102 myHelpFileName = "files/salome2_sp3_measuregui_functions.htm#PointCoord";
108 //=================================================================================
109 // function : ~MeasureGUI_PointDlg()
110 // purpose : Destroys the object and frees any allocated resources
111 //======================myX->setReadOnly( true );===========================================================
112 MeasureGUI_PointDlg::~MeasureGUI_PointDlg()
117 //=================================================================================
120 //=================================================================================
121 void MeasureGUI_PointDlg::Init()
123 QSize aSize( size() );
124 resize( (int)(aSize.width() *0.75 ), aSize.height() );
125 MeasureGUI_Skeleton::Init();
128 //=================================================================================
129 // function : activateSelection
131 //=================================================================================
132 void MeasureGUI_PointDlg::activateSelection()
134 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
137 //=================================================================================
138 // function : SelectionIntoArgument
140 //=================================================================================
141 void MeasureGUI_PointDlg::SelectionIntoArgument()
145 myObj = GEOM::GEOM_Object::_nil();
146 mySelEdit->setText( "" );
151 Standard_Boolean testResult = Standard_False;
152 GEOM::GEOM_Object_var aSelectedObject =
153 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
155 if( !testResult || aSelectedObject->_is_nil() )
158 myObj = aSelectedObject;
160 TColStd_IndexedMapOfInteger anIndexes;
161 ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
162 selectionMgr()->GetIndexes( firstIObject(), anIndexes );
165 if ( anIndexes.Extent() > 1 || !GEOMBase::GetShape( myObj, aShape ) || aShape.IsNull() )
168 TopoDS_Vertex aPoint;
169 QString aName = GEOMBase::GetName( myObj );
170 if ( anIndexes.Extent() == 0 )
172 if ( aShape.ShapeType() == TopAbs_VERTEX )
173 aPoint = TopoDS::Vertex( aShape );
177 int i = anIndexes( 1 );
179 TopTools_IndexedMapOfShape aShapes;
180 TopExp::MapShapes( aShape, aShapes );
182 if ( aShape != aShapes( i ) )
183 aName += QString( ":%1" ).arg( i );
185 aPoint = TopoDS::Vertex( aShapes( i ) );
188 if ( !aPoint.IsNull() )
190 gp_Pnt aPnt = BRep_Tool::Pnt( aPoint );
191 mySelEdit->setText( aName );
192 myX->setText( QString( "%1" ).arg( aPnt.X() ) );
193 myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
194 myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
199 myObj = GEOM::GEOM_Object::_nil();
200 mySelEdit->setText( "" );