geom/src/BasicGUI/BasicGUI_PointDlg.cxx

577 lines
20 KiB
C++
Raw Normal View History

2007-10-15 10:41:03 +00:00
// GEOM GEOMGUI : GUI for Geometry component
2004-01-07 15:46:21 +00:00
//
2007-10-15 10:41:03 +00:00
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2004-01-07 15:46:21 +00:00
//
2007-10-15 10:41:03 +00:00
// 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.
2004-01-07 15:46:21 +00:00
//
2007-10-15 10:41:03 +00:00
// 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.
2004-01-07 15:46:21 +00:00
//
2007-10-15 10:41:03 +00:00
// 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
2004-01-07 15:46:21 +00:00
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-01-07 15:46:21 +00:00
//
2007-10-15 10:41:03 +00:00
// File : BasicGUI_PointDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
2004-01-07 15:46:21 +00:00
//
#include "BasicGUI_PointDlg.h"
2007-10-15 10:41:03 +00:00
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
2004-01-07 15:46:21 +00:00
2007-10-15 10:41:03 +00:00
#include <GeometryGUI.h>
#include <GEOMBase.h>
2007-07-09 07:39:05 +00:00
2007-10-15 10:41:03 +00:00
#include <GEOM_DlgRef.h>
2004-12-01 10:39:14 +00:00
2007-10-15 10:41:03 +00:00
#include <GEOMImpl_Types.hxx>
2007-07-09 07:39:05 +00:00
#include <QApplication>
#include <QLabel>
2004-12-01 10:39:14 +00:00
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS.hxx>
2004-01-07 15:46:21 +00:00
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
2004-12-01 10:39:14 +00:00
2004-01-07 15:46:21 +00:00
//=================================================================================
// class : BasicGUI_PointDlg()
// purpose : Constructs a BasicGUI_PointDlg 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.
//=================================================================================
2007-10-15 10:41:03 +00:00
BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
2007-10-15 14:16:21 +00:00
bool modal, Qt::WindowFlags fl )
2007-10-16 14:15:43 +00:00
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
2004-01-07 15:46:21 +00:00
{
2007-10-15 10:41:03 +00:00
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_EDGE" ) ) );
QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_REF" ) ) );
2004-01-07 15:46:21 +00:00
2007-10-15 10:41:03 +00:00
setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
2004-01-07 15:46:21 +00:00
/***************************************************************/
2007-10-15 10:41:03 +00:00
mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
mainFrame()->RadioButton1->setIcon( image0 );
mainFrame()->RadioButton2->setIcon( image3 );
mainFrame()->RadioButton3->setIcon( image1 );
GroupXYZ = new DlgRef_3Spin( centralWidget() );
GroupXYZ->GroupBox1->setTitle( tr( "GEOM_COORDINATES" ) );
GroupXYZ->TextLabel1->setText( tr( "GEOM_X" ) );
GroupXYZ->TextLabel2->setText( tr( "GEOM_Y" ) );
GroupXYZ->TextLabel3->setText( tr( "GEOM_Z" ) );
GroupOnCurve = new DlgRef_1Sel1Spin( centralWidget() );
GroupOnCurve->GroupBox1->setTitle( tr( "GEOM_PARAM_POINT" ) );
GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
GroupOnCurve->PushButton1->setIcon( image2 );
GroupRefPoint = new DlgRef_1Sel3Spin( centralWidget() );
GroupRefPoint->GroupBox1->setTitle( tr( "GEOM_REF_POINT" ) );
GroupRefPoint->TextLabel1->setText( tr( "GEOM_POINT" ) );
GroupRefPoint->PushButton1->setIcon( image2 );
GroupRefPoint->TextLabel2->setText( tr( "GEOM_DX" ) );
GroupRefPoint->TextLabel3->setText( tr( "GEOM_DY" ) );
GroupRefPoint->TextLabel4->setText( tr( "GEOM_DZ" ) );
myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES" ), centralWidget() );
2007-07-09 07:39:05 +00:00
QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
2004-12-01 10:39:14 +00:00
myX = new QLineEdit( myCoordGrp );
2007-07-09 07:39:05 +00:00
myCoordGrpLayout->addWidget( myX, 0, 1 );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
2004-12-01 10:39:14 +00:00
myY = new QLineEdit( myCoordGrp );
2007-07-09 07:39:05 +00:00
myCoordGrpLayout->addWidget( myY, 1, 1 );
myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
2004-12-01 10:39:14 +00:00
myZ = new QLineEdit( myCoordGrp );
2007-07-09 07:39:05 +00:00
myCoordGrpLayout->addWidget( myZ, 2, 1 );
2004-12-01 10:39:14 +00:00
2007-10-15 10:41:03 +00:00
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupXYZ );
layout->addWidget( GroupOnCurve );
layout->addWidget( GroupRefPoint );
layout->addWidget( myCoordGrp );
2004-12-01 10:39:14 +00:00
myX->setReadOnly( true );
myY->setReadOnly( true );
myZ->setReadOnly( true );
myX->setEnabled( false );
myY->setEnabled( false );
myZ->setEnabled( false );
QPalette aPal = myX->palette();
2007-07-09 07:39:05 +00:00
aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
2004-12-01 10:39:14 +00:00
myX->setPalette( aPal );
myY->setPalette( aPal );
myZ->setPalette( aPal );
2007-10-15 10:41:03 +00:00
setHelpFileName( "point.htm" );
2004-12-01 10:39:14 +00:00
Init();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
2004-01-07 15:46:21 +00:00
// function : ~BasicGUI_PointDlg()
// purpose : Destructor
//=================================================================================
2004-01-07 15:46:21 +00:00
BasicGUI_PointDlg::~BasicGUI_PointDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
2004-12-01 10:39:14 +00:00
void BasicGUI_PointDlg::Init()
2004-01-07 15:46:21 +00:00
{
2004-12-01 10:39:14 +00:00
GroupOnCurve->LineEdit1->setReadOnly( true );
GroupRefPoint->LineEdit1->setReadOnly( true );
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
myEdge = GEOM::GEOM_Object::_nil();
myRefPoint = GEOM::GEOM_Object::_nil();
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
myEditCurrentArgument = 0;
2004-01-07 15:46:21 +00:00
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
2007-10-15 10:41:03 +00:00
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
2004-01-07 15:46:21 +00:00
/* min, max, step and decimals for spin boxes */
2007-10-15 10:41:03 +00:00
initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 );
initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 );
initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 );
GroupXYZ->SpinBox_DX->setValue( 0.0 );
GroupXYZ->SpinBox_DY->setValue( 0.0 );
GroupXYZ->SpinBox_DZ->setValue( 0.0 );
initSpinBox( GroupRefPoint->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 );
initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 3 );
initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 3 );
GroupRefPoint->SpinBox_DX->setValue( 0.0 );
GroupRefPoint->SpinBox_DY->setValue( 0.0 );
GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
2004-12-01 10:39:14 +00:00
step = 0.1;
2007-10-15 10:41:03 +00:00
initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 3 );
GroupOnCurve->SpinBox_DX->setValue( 0.5 );
2004-12-01 10:39:14 +00:00
2004-01-07 15:46:21 +00:00
/* signals and slots connections */
2007-10-15 10:41:03 +00:00
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( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupXYZ->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupXYZ->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupXYZ->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupRefPoint->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupRefPoint->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( GroupRefPoint->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
// VSR: TODO ->>
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupOnCurve->SpinBox_DX, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupXYZ->SpinBox_DX, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupXYZ->SpinBox_DY, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupXYZ->SpinBox_DZ, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupRefPoint->SpinBox_DX, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupRefPoint->SpinBox_DY, SLOT( SetStep( double ) ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), GroupRefPoint->SpinBox_DZ, SLOT( SetStep( double ) ) );
// <<-
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
2007-10-15 10:41:03 +00:00
initName( tr( "GEOM_VERTEX" ) );
2004-12-01 10:39:14 +00:00
ConstructorsClicked( 0 );
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
2004-12-01 10:39:14 +00:00
{
2007-10-15 10:41:03 +00:00
switch ( constructorId ) {
2004-12-01 10:39:14 +00:00
case 0:
{
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
GroupRefPoint->hide();
GroupOnCurve->hide();
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
myCoordGrp->hide();
2007-10-15 10:41:03 +00:00
GroupXYZ->show();
2004-12-01 10:39:14 +00:00
break;
}
case 1:
2004-01-07 15:46:21 +00:00
{
2004-12-01 10:39:14 +00:00
myEditCurrentArgument = GroupRefPoint->LineEdit1;
2007-10-15 10:41:03 +00:00
myEditCurrentArgument->setText( "" );
2004-12-01 10:39:14 +00:00
myRefPoint = GEOM::GEOM_Object::_nil();
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
globalSelection( GEOM_POINT );
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
GroupXYZ->hide();
GroupOnCurve->hide();
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
GroupRefPoint->show();
myCoordGrp->show();
break;
2004-01-07 15:46:21 +00:00
}
2004-12-01 10:39:14 +00:00
case 2:
{
myEditCurrentArgument = GroupOnCurve->LineEdit1;
2007-10-15 10:41:03 +00:00
myEditCurrentArgument->setText( "" );
2004-12-01 10:39:14 +00:00
myEdge = GEOM::GEOM_Object::_nil();
globalSelection( GEOM_EDGE );
GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->show();
myCoordGrp->show();
break;
}
}
myX->setText( "" );
myY->setText( "" );
myZ->setText( "" );
qApp->processEvents();
updateGeometry();
resize( minimumSize() );
SelectionIntoArgument();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::ClickOnOk()
{
2005-06-03 10:39:10 +00:00
if ( onAccept() )
2004-12-01 10:39:14 +00:00
ClickOnCancel();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
2004-12-01 10:39:14 +00:00
bool BasicGUI_PointDlg::ClickOnApply()
2004-01-07 15:46:21 +00:00
{
2004-12-01 10:39:14 +00:00
if ( !onAccept() )
return false;
2004-12-01 10:39:14 +00:00
initName();
ConstructorsClicked( getConstructorId() );
return true;
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed (for constructors not using local context)
//=================================================================================
void BasicGUI_PointDlg::SelectionIntoArgument()
{
const int id = getConstructorId();
2004-12-01 10:39:14 +00:00
2007-10-15 10:41:03 +00:00
if ( ( id == 1 || id == 2 ) && myEditCurrentArgument != 0 ) {
myEditCurrentArgument->setText( "" );
myX->setText( "" );
myY->setText( "" );
myZ->setText( "" );
myRefPoint = myEdge = GEOM::GEOM_Object::_nil();
}
2007-10-15 10:41:03 +00:00
if ( IObjectCount() == 1 ) {
Standard_Boolean aRes = Standard_False;
Handle(SALOME_InteractiveObject) anIO = firstIObject();
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
2007-10-15 10:41:03 +00:00
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
if ( id == 0 ) {
// get CORBA reference to data object
2007-10-15 10:41:03 +00:00
TopoDS_Shape aShape = myGeomGUI->GetShapeReader().GetShape( myGeomGUI->GetGeomGen(), aSelectedObject );
if ( aShape.IsNull() )
return;
2007-10-15 10:41:03 +00:00
if ( aShape.ShapeType() != TopAbs_VERTEX ) {
TColStd_IndexedMapOfInteger aMap;
LightApp_Application* anApp =
(LightApp_Application*)(SUIT_Session::session()->activeApplication());
anApp->selectionMgr()->GetIndexes( anIO, aMap );
2007-10-15 10:41:03 +00:00
if ( aMap.Extent() == 1 ) {
int anIndex = aMap( 1 );
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes( aShape, aShapes );
aShape = aShapes.FindKey( anIndex );
2007-10-15 10:41:03 +00:00
if ( aShape.IsNull() || aShape.ShapeType() != TopAbs_VERTEX )
return;
}
else
return;
}
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
2007-10-15 10:41:03 +00:00
GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
}
2007-10-15 10:41:03 +00:00
else if ( id == 1 ) {
myRefPoint = aSelectedObject;
GroupRefPoint->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
}
2007-10-15 10:41:03 +00:00
else if ( id == 2 ) {
myEdge = aSelectedObject;
GroupOnCurve->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
}
}
}
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
displayPreview();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
2004-12-01 10:39:14 +00:00
if ( send == GroupRefPoint->LineEdit1 || send == GroupOnCurve->LineEdit1 )
{
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
}
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
2007-10-15 10:41:03 +00:00
if ( send == GroupRefPoint->PushButton1 ) {
2004-12-01 10:39:14 +00:00
GroupRefPoint->LineEdit1->setFocus();
myEditCurrentArgument = GroupRefPoint->LineEdit1;
globalSelection( GEOM_POINT );
}
2007-10-15 10:41:03 +00:00
else if ( send == GroupOnCurve->PushButton1 ) {
2004-12-01 10:39:14 +00:00
GroupOnCurve->LineEdit1->setFocus();
myEditCurrentArgument = GroupOnCurve->LineEdit1;
2004-12-01 10:39:14 +00:00
globalSelection( GEOM_EDGE );
2004-01-07 15:46:21 +00:00
}
}
//=================================================================================
// function : enterEvent()
// purpose : to reactivate this dialog box when mouse enter onto the window
//=================================================================================
2007-10-15 10:41:03 +00:00
void BasicGUI_PointDlg::enterEvent( QEvent* )
2004-01-07 15:46:21 +00:00
{
2007-10-15 10:41:03 +00:00
if ( !mainFrame()->GroupConstructors->isEnabled() )
2004-12-01 10:39:14 +00:00
ActivateThisDialog();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::ActivateThisDialog( )
{
GEOMBase_Skeleton::ActivateThisDialog();
// myGeomGUI->SetState( 0 );
2004-12-01 10:39:14 +00:00
ConstructorsClicked( getConstructorId() );
2004-01-07 15:46:21 +00:00
}
//=================================================================================
// function : DeactivateActiveDialog()
// purpose : public slot to deactivate if active
//=================================================================================
void BasicGUI_PointDlg::DeactivateActiveDialog()
{
// myGeomGUI->SetState( -1 );
2004-01-07 15:46:21 +00:00
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
{
2004-12-01 10:39:14 +00:00
displayPreview();
2004-01-07 15:46:21 +00:00
}
//=================================================================================
2004-12-01 10:39:14 +00:00
// funcion : getParameter()
// purpose :
//=================================================================================
2004-12-01 10:39:14 +00:00
double BasicGUI_PointDlg::getParameter() const
{
2007-10-15 10:41:03 +00:00
return GroupOnCurve->SpinBox_DX->value();
2004-12-01 10:39:14 +00:00
}
2004-01-07 15:46:21 +00:00
//=================================================================================
2004-12-01 10:39:14 +00:00
// function : OnPointSelected
// purpose :
2004-01-07 15:46:21 +00:00
//=================================================================================
2004-12-01 10:39:14 +00:00
void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
2004-01-07 15:46:21 +00:00
{
2007-10-15 10:41:03 +00:00
if ( getConstructorId() == 0 ) {
GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
displayPreview();
}
2004-01-07 15:46:21 +00:00
}
2004-12-01 10:39:14 +00:00
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
{
return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
2004-12-01 10:39:14 +00:00
}
2004-01-07 15:46:21 +00:00
2004-12-01 10:39:14 +00:00
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool BasicGUI_PointDlg::isValid( QString& msg )
2004-01-07 15:46:21 +00:00
{
const int id = getConstructorId();
if ( id == 0 )
return true;
else if ( id == 1 )
return !myRefPoint->_is_nil();
else if ( id == 2 )
return !myEdge->_is_nil();
return false;
2004-12-01 10:39:14 +00:00
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool BasicGUI_PointDlg::execute( ObjectList& objects )
{
bool res = false;
GEOM::GEOM_Object_var anObj;
2007-10-15 10:41:03 +00:00
switch ( getConstructorId() ) {
2004-12-01 10:39:14 +00:00
case 0 :
2007-10-15 10:41:03 +00:00
{
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
double z = GroupXYZ->SpinBox_DZ->value();
2004-12-01 10:39:14 +00:00
2007-10-15 10:41:03 +00:00
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
res = true;
break;
}
2004-12-01 10:39:14 +00:00
case 1 :
2007-10-15 10:41:03 +00:00
{
double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value();
double dz = GroupRefPoint->SpinBox_DZ->value();
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointWithReference( myRefPoint, dx, dy, dz );
res = true;
break;
}
2004-12-01 10:39:14 +00:00
case 2 :
anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
MakePointOnCurve( myEdge, getParameter() );
2004-12-01 10:39:14 +00:00
res = true;
break;
2004-01-07 15:46:21 +00:00
}
2007-10-15 10:41:03 +00:00
if ( getConstructorId() == 1 || getConstructorId() == 2 ) {
2005-06-03 10:39:10 +00:00
TopoDS_Shape aShape;
2007-10-15 10:41:03 +00:00
if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
2005-06-03 10:39:10 +00:00
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
myX->setText( QString( "%1" ).arg( aPnt.X() ) );
myY->setText( QString( "%1" ).arg( aPnt.Y() ) );
myZ->setText( QString( "%1" ).arg( aPnt.Z() ) );
}
2007-10-15 10:41:03 +00:00
else {
2005-06-03 10:39:10 +00:00
myX->setText( "" );
myY->setText( "" );
myZ->setText( "" );
2004-12-01 10:39:14 +00:00
}
2005-06-03 10:39:10 +00:00
}
2007-10-15 10:41:03 +00:00
if ( !anObj->_is_nil() ) {
2004-12-01 10:39:14 +00:00
objects.push_back( anObj._retn() );
2005-06-03 10:39:10 +00:00
}
2007-10-15 10:41:03 +00:00
2004-12-01 10:39:14 +00:00
return res;
}
//=================================================================================
// function : closeEvent
// purpose :
//=================================================================================
void BasicGUI_PointDlg::closeEvent( QCloseEvent* e )
{
GEOMBase_Skeleton::closeEvent( e );
2004-01-07 15:46:21 +00:00
}