2004-12-01 15:39:14 +05:00
|
|
|
// 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 : MeasureGUI_PointDlg.cxx
|
|
|
|
// Author : Lucien PIGNOLONI
|
|
|
|
// Module : GEOM
|
|
|
|
// $Header$
|
|
|
|
|
|
|
|
#include "MeasureGUI_PointDlg.h"
|
|
|
|
#include "GEOMBase.h"
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SalomeApp_Application.h"
|
|
|
|
#include "SalomeApp_SelectionMgr.h"
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TopAbs_ShapeEnum.hxx>
|
|
|
|
#include <TopoDS_Shape.hxx>
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <TopoDS_Vertex.hxx>
|
|
|
|
#include <BRep_Tool.hxx>
|
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TopAbs_ShapeEnum.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
|
|
|
#include <gp_Pnt.hxx>
|
|
|
|
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qapplication.h>
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : MeasureGUI_PointDlg()
|
|
|
|
// purpose : Constructs a MeasureGUI_PointDlg which is a child of 'parent'
|
|
|
|
//
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
MeasureGUI_PointDlg::MeasureGUI_PointDlg( GeometryGUI* GUI, QWidget* parent )
|
|
|
|
: MeasureGUI_Skeleton( GUI, parent, "MeasureGUI_PointDlg" )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
QPixmap iconPnt( SUIT_Session::session()->resourceMgr()->loadPixmap(
|
2004-12-01 15:39:14 +05:00
|
|
|
"GEOM",tr( "ICON_DLG_POINT" ) ) );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap(
|
2004-12-01 15:39:14 +05:00
|
|
|
"GEOM",tr( "ICON_SELECT" ) ) );
|
|
|
|
|
|
|
|
setCaption( tr( "CAPTION" ) );
|
|
|
|
|
|
|
|
GroupConstructors->setTitle( tr( "CAPTION" ) );
|
|
|
|
RadioButton1->setPixmap( iconPnt );
|
|
|
|
|
|
|
|
QGroupBox* aGrp = new QGroupBox( 2, Qt::Horizontal, tr( "COORDINATES" ), this );
|
|
|
|
|
|
|
|
new QLabel( tr( "POINT" ), aGrp );
|
|
|
|
QFrame* aFrame = new QFrame( aGrp );
|
|
|
|
mySelBtn = new QPushButton( aFrame );
|
|
|
|
mySelBtn->setPixmap( iconSelect );
|
|
|
|
mySelEdit = new QLineEdit( aFrame );
|
|
|
|
QHBoxLayout* aLay = new QHBoxLayout( aFrame, 0, 10 );
|
|
|
|
aLay->addWidget( mySelBtn );
|
|
|
|
aLay->addWidget( mySelEdit );
|
|
|
|
|
|
|
|
new QLabel( tr( "X" ), aGrp );
|
|
|
|
myX = new QLineEdit( aGrp );
|
|
|
|
new QLabel( tr( "Y" ), aGrp );
|
|
|
|
myY = new QLineEdit( aGrp );
|
|
|
|
new QLabel( tr( "Z" ), aGrp );
|
|
|
|
myZ = new QLineEdit( aGrp );
|
|
|
|
|
|
|
|
mySelEdit->setReadOnly( true );
|
|
|
|
myX->setReadOnly( true );
|
|
|
|
myY->setReadOnly( true );
|
|
|
|
myZ->setReadOnly( true );
|
|
|
|
|
|
|
|
Layout1->addWidget( aGrp, 1, 0 );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
Init();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ~MeasureGUI_PointDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//======================myX->setReadOnly( true );===========================================================
|
|
|
|
MeasureGUI_PointDlg::~MeasureGUI_PointDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void MeasureGUI_PointDlg::Init()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
QSize aSize( size() );
|
|
|
|
resize( (int)(aSize.width() *0.75 ), aSize.height() );
|
2005-06-02 13:17:09 +06:00
|
|
|
MeasureGUI_Skeleton::Init();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : activateSelection
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_PointDlg::activateSelection()
|
|
|
|
{
|
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SelectionIntoArgument
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void MeasureGUI_PointDlg::SelectionIntoArgument()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
myObj = GEOM::GEOM_Object::_nil();
|
|
|
|
mySelEdit->setText( "" );
|
|
|
|
myX->setText( "" );
|
|
|
|
myY->setText( "" );
|
|
|
|
myZ->setText( "" );
|
|
|
|
|
|
|
|
Standard_Boolean testResult = Standard_False;
|
|
|
|
GEOM::GEOM_Object_var aSelectedObject =
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
if( !testResult || aSelectedObject->_is_nil() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
myObj = aSelectedObject;
|
|
|
|
|
|
|
|
TColStd_IndexedMapOfInteger anIndexes;
|
2005-06-02 13:17:09 +06:00
|
|
|
((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->
|
|
|
|
selectionMgr()->GetIndexes( firstIObject(), anIndexes );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
TopoDS_Shape aShape;
|
|
|
|
if ( anIndexes.Extent() > 1 || !GEOMBase::GetShape( myObj, aShape ) || aShape.IsNull() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
TopoDS_Vertex aPoint;
|
|
|
|
QString aName = GEOMBase::GetName( myObj );
|
|
|
|
if ( anIndexes.Extent() == 0 )
|
|
|
|
{
|
|
|
|
if ( aShape.ShapeType() == TopAbs_VERTEX )
|
|
|
|
aPoint = TopoDS::Vertex( aShape );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int i = anIndexes( 1 );
|
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape aShapes;
|
|
|
|
TopExp::MapShapes( aShape, aShapes );
|
|
|
|
|
|
|
|
if ( aShape != aShapes( i ) )
|
|
|
|
aName += QString( ":%1" ).arg( i );
|
|
|
|
|
|
|
|
aPoint = TopoDS::Vertex( aShapes( i ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !aPoint.IsNull() )
|
|
|
|
{
|
|
|
|
gp_Pnt aPnt = BRep_Tool::Pnt( aPoint );
|
|
|
|
mySelEdit->setText( aName );
|
|
|
|
myX->setText( QString( "%1" ).arg( aPnt.X() ) );
|
|
|
|
myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
|
|
|
|
myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( ... )
|
|
|
|
{
|
|
|
|
myObj = GEOM::GEOM_Object::_nil();
|
|
|
|
mySelEdit->setText( "" );
|
|
|
|
myX->setText( "" );
|
|
|
|
myY->setText( "" );
|
|
|
|
myZ->setText( "" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|