2009-02-13 17:16:39 +05:00
|
|
|
// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2008-03-07 12:45:34 +05:00
|
|
|
// 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
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2009-02-13 17:16:39 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
// File : BasicGUI_MarkerDlg.cxx
|
|
|
|
// Author : Sergey LITONIN, Open CASCADE S.A.S. (sergey.litonin@opencascade.com)
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
|
|
|
#include "BasicGUI_MarkerDlg.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <DlgRef.h>
|
|
|
|
#include <GeometryGUI.h>
|
|
|
|
#include <GEOMBase.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <LightApp_SelectionMgr.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <QLabel>
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// OCCT Includes
|
|
|
|
#include <BRep_Tool.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TopAbs.hxx>
|
|
|
|
#include <TopoDS.hxx>
|
|
|
|
#include <TopoDS_Vertex.hxx>
|
|
|
|
#include <TopoDS_Face.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <Geom_Plane.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <TColStd_IndexedMapOfInteger.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <gp_Pnt.hxx>
|
|
|
|
#include <gp_Pln.hxx>
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// class : BasicGUI_MarkerDlg()
|
|
|
|
// purpose : Constructor
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
BasicGUI_MarkerDlg::BasicGUI_MarkerDlg( GeometryGUI* theGeometryGUI, QWidget* theParent )
|
2009-02-13 17:16:39 +05:00
|
|
|
: GEOMBase_Skeleton( theGeometryGUI, theParent, false,
|
|
|
|
Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
QPixmap iconCS1 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER" ) ) );
|
|
|
|
QPixmap iconCS2 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER2" ) ) );
|
|
|
|
QPixmap iconCS3 ( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_MARKER3" ) ) );
|
|
|
|
QPixmap iconSelect( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
setWindowTitle( tr( "CAPTION" ) );
|
|
|
|
|
|
|
|
mainFrame()->GroupConstructors->setTitle( tr( "LOCALCS" ) );
|
|
|
|
mainFrame()->RadioButton1->setIcon( iconCS1 );
|
|
|
|
mainFrame()->RadioButton2->setIcon( iconCS2 );
|
|
|
|
mainFrame()->RadioButton3->setIcon( iconCS3 );
|
|
|
|
|
|
|
|
Group1 = new DlgRef_1Sel( centralWidget() );
|
|
|
|
|
|
|
|
Group1->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
|
|
|
|
Group1->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
|
|
|
|
Group1->PushButton1->setIcon( iconSelect );
|
|
|
|
Group1->PushButton1->setDown( true );
|
|
|
|
|
|
|
|
Group2 = new DlgRef_3Sel( centralWidget() );
|
|
|
|
|
|
|
|
Group2->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
|
|
|
|
Group2->TextLabel1->setText( tr( "GEOM_POINT" ) );
|
|
|
|
Group2->TextLabel2->setText( tr( "XDIR" ) );
|
|
|
|
Group2->TextLabel3->setText( tr( "YDIR" ) );
|
|
|
|
Group2->PushButton1->setIcon( iconSelect );
|
|
|
|
Group2->PushButton2->setIcon( iconSelect );
|
|
|
|
Group2->PushButton3->setIcon( iconSelect );
|
|
|
|
Group2->PushButton1->setDown( true );
|
|
|
|
|
|
|
|
aMainGrp = new QFrame( centralWidget() );
|
|
|
|
aMainGrp->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
|
|
|
|
aMainGrp->setContentsMargins( 0, 0, 0, 0 );
|
|
|
|
QHBoxLayout* aMainGrpLayout = new QHBoxLayout( aMainGrp );
|
|
|
|
aMainGrpLayout->setMargin( 0 );
|
|
|
|
|
|
|
|
QGroupBox* anOriGrp = new QGroupBox( tr( "ORIGIN" ), aMainGrp );
|
|
|
|
QVBoxLayout* anOriGrpLayout = new QVBoxLayout( anOriGrp );
|
|
|
|
|
|
|
|
anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), anOriGrp ) );
|
|
|
|
myData[ X ] = new SalomeApp_DoubleSpinBox( anOriGrp );
|
|
|
|
anOriGrpLayout->addWidget( myData[ X ] );
|
|
|
|
anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), anOriGrp ) );
|
|
|
|
myData[ Y ] = new SalomeApp_DoubleSpinBox( anOriGrp );
|
|
|
|
anOriGrpLayout->addWidget( myData[ Y ] );
|
|
|
|
anOriGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), anOriGrp ) );
|
|
|
|
myData[ Z ] = new SalomeApp_DoubleSpinBox( anOriGrp );
|
|
|
|
anOriGrpLayout->addWidget( myData[ Z ] );
|
|
|
|
|
|
|
|
aMainGrpLayout->addWidget( anOriGrp );
|
|
|
|
|
|
|
|
QGroupBox* aXAxisGrp = new QGroupBox( tr( "XDIR" ), aMainGrp );
|
|
|
|
QVBoxLayout* aXAxisGrpLayout = new QVBoxLayout( aXAxisGrp );
|
|
|
|
|
|
|
|
aXAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), aXAxisGrp ) );
|
|
|
|
myData[ DX1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
|
|
|
|
aXAxisGrpLayout->addWidget( myData[ DX1 ] );
|
|
|
|
aXAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), aXAxisGrp ) );
|
|
|
|
myData[ DY1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
|
|
|
|
aXAxisGrpLayout->addWidget( myData[ DY1 ] );
|
|
|
|
aXAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), aXAxisGrp ) );
|
|
|
|
myData[ DZ1 ] = new SalomeApp_DoubleSpinBox( aXAxisGrp );
|
|
|
|
aXAxisGrpLayout->addWidget( myData[ DZ1 ] );
|
|
|
|
|
|
|
|
aMainGrpLayout->addWidget( aXAxisGrp );
|
|
|
|
|
|
|
|
QGroupBox* anYAxisGrp = new QGroupBox( tr( "YDIR" ), aMainGrp );
|
|
|
|
QVBoxLayout* anYAxisGrpLayout = new QVBoxLayout( anYAxisGrp );
|
|
|
|
|
|
|
|
anYAxisGrpLayout->addWidget( new QLabel( tr( "DX" ), anYAxisGrp ) );
|
|
|
|
myData[ DX2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
|
|
|
|
anYAxisGrpLayout->addWidget( myData[ DX2 ] );
|
|
|
|
anYAxisGrpLayout->addWidget( new QLabel( tr( "DY" ), anYAxisGrp ) );
|
|
|
|
myData[ DY2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
|
|
|
|
anYAxisGrpLayout->addWidget( myData[ DY2 ] );
|
|
|
|
anYAxisGrpLayout->addWidget( new QLabel( tr( "DZ" ), anYAxisGrp ) );
|
|
|
|
myData[ DZ2 ] = new SalomeApp_DoubleSpinBox( anYAxisGrp );
|
|
|
|
anYAxisGrpLayout->addWidget( myData[ DZ2 ] );
|
|
|
|
|
|
|
|
aMainGrpLayout->addWidget( anYAxisGrp );
|
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
|
|
|
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
|
|
|
layout->addWidget( aMainGrp );
|
|
|
|
layout->addWidget( Group1 );
|
|
|
|
layout->addWidget( Group2 );
|
|
|
|
|
|
|
|
setHelpFileName( "create_lcs_page.html" );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
Init();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : ~BasicGUI_MarkerDlg()
|
|
|
|
// purpose : Destroys the object and frees any allocated resources
|
|
|
|
//=================================================================================
|
|
|
|
BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : Init()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void BasicGUI_MarkerDlg::Init()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
myBlockPreview = false;
|
|
|
|
myConstructorId = -1;
|
|
|
|
myEditCurrentArgument = Group1->LineEdit1;
|
|
|
|
Group1->LineEdit1->setReadOnly( true );
|
|
|
|
Group2->LineEdit1->setReadOnly( true );
|
|
|
|
Group2->LineEdit2->setReadOnly( true );
|
|
|
|
Group2->LineEdit3->setReadOnly( true );
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->LineEdit1->setEnabled( true );
|
|
|
|
Group2->LineEdit2->setEnabled( false );
|
|
|
|
Group2->LineEdit3->setEnabled( false );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( Group1->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
connect( Group2->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
connect( Group2->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
|
|
|
connect( Group2->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( Group1->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
|
|
|
connect( Group2->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
|
|
|
connect( Group2->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
|
|
|
connect( Group2->LineEdit3, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( onDeactivate() ) );
|
|
|
|
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
|
|
|
|
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
|
|
|
|
|
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(),
|
2005-06-02 13:17:09 +06:00
|
|
|
SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
initName( tr( "LCS_NAME" ) );
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
2009-02-13 17:16:39 +05:00
|
|
|
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter ) {
|
|
|
|
initSpinBox( anIter.value(), COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
|
|
|
|
connect( anIter.value(), SIGNAL( valueChanged( double ) ),
|
2004-12-01 15:39:14 +05:00
|
|
|
this, SLOT( onValueChanged( double ) ) );
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
myBlockPreview = true;
|
|
|
|
for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
|
2009-02-13 17:16:39 +05:00
|
|
|
anIter.value()->setValue( 0 );
|
|
|
|
myData[ DX1 ]->setValue( 1 );
|
|
|
|
myData[ DY2 ]->setValue( 1 );
|
2004-12-01 15:39:14 +05:00
|
|
|
myBlockPreview = false;
|
|
|
|
|
|
|
|
ConstructorsClicked( 0 );
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
//@
|
|
|
|
/*
|
2004-12-01 15:39:14 +05:00
|
|
|
QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
|
|
|
|
getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
|
|
|
|
|
|
|
|
VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
|
|
|
|
if ( aVTKFrame )
|
|
|
|
{
|
|
|
|
aVTKFrame->AdjustTrihedrons( true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
|
|
|
|
if ( aOCCFrame )
|
|
|
|
aOCCFrame->AdjustTrihedrons( true );
|
2005-06-02 13:17:09 +06:00
|
|
|
*/
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : ConstructorsClicked()
|
|
|
|
// purpose : Radio button management
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myConstructorId == constructorId && myConstructorId == 0 ) {
|
2008-03-07 12:45:34 +05:00
|
|
|
globalSelection(); // close local contexts, if any
|
2004-12-01 15:39:14 +05:00
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
|
|
|
activate( GEOM_MARKER );
|
|
|
|
displayPreview();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
myConstructorId = constructorId;
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
switch ( constructorId ) {
|
2008-03-07 12:45:34 +05:00
|
|
|
case 0:
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
Group1->hide();
|
|
|
|
Group2->hide();
|
|
|
|
aMainGrp->show();
|
2008-03-07 12:45:34 +05:00
|
|
|
globalSelection(); // close local contexts, if any
|
2004-12-01 15:39:14 +05:00
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
|
|
|
activate( GEOM_MARKER );
|
|
|
|
break;
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
aMainGrp->hide();
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->hide();
|
2008-03-07 12:45:34 +05:00
|
|
|
Group1->show();
|
2009-02-13 17:16:39 +05:00
|
|
|
Group1->PushButton1->setDown( true );
|
2008-03-07 12:45:34 +05:00
|
|
|
globalSelection( GEOM_ALLGEOM );
|
|
|
|
myEditCurrentArgument = Group1->LineEdit1;
|
2009-02-13 17:16:39 +05:00
|
|
|
Group1->LineEdit1->setText( "" );
|
2008-03-07 12:45:34 +05:00
|
|
|
break;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
aMainGrp->hide();
|
2009-02-13 17:16:39 +05:00
|
|
|
Group1->hide();
|
2008-03-07 12:45:34 +05:00
|
|
|
Group2->show();
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->PushButton1->setDown( true );
|
|
|
|
Group2->PushButton2->setDown( false );
|
|
|
|
Group2->PushButton3->setDown( false );
|
2008-03-07 12:45:34 +05:00
|
|
|
globalSelection(); // close local contexts, if any
|
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
|
|
|
myEditCurrentArgument = Group2->LineEdit1;
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->LineEdit1->setText( "" );
|
|
|
|
Group2->LineEdit2->setText( "" );
|
|
|
|
Group2->LineEdit3->setText( "" );
|
|
|
|
Group2->LineEdit1->setEnabled( true );
|
|
|
|
Group2->LineEdit2->setEnabled( false );
|
|
|
|
Group2->LineEdit3->setEnabled( false );
|
2008-03-07 12:45:34 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
qApp->processEvents();
|
|
|
|
updateGeometry();
|
|
|
|
resize( minimumSizeHint() );
|
|
|
|
|
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
|
|
|
this, SLOT( onSelectionDone() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
onSelectionDone();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onOk()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onOk()
|
|
|
|
{
|
|
|
|
if ( onApply() )
|
2009-02-13 17:16:39 +05:00
|
|
|
ClickOnCancel();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onApply()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool BasicGUI_MarkerDlg::onApply()
|
|
|
|
{
|
|
|
|
if ( !onAccept() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
initName();
|
|
|
|
ConstructorsClicked( getConstructorId() );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectionDone0()
|
|
|
|
// purpose : Reaction on selection when first method of creation is current one
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onSelectionDone0()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
|
|
|
|
|
|
|
if (aSelList.Extent() == 1) {
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean aRes = Standard_False;
|
2009-02-13 17:16:39 +05:00
|
|
|
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
if ( aRes && !aSelectedObj->_is_nil() ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
TopoDS_Shape aShape;
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
|
2008-03-07 12:45:34 +05:00
|
|
|
// Existing LCS selected
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( aSelectedObj->GetType() == GEOM_MARKER && aShape.ShapeType() == TopAbs_FACE ) {
|
|
|
|
TopoDS_Face aFace = TopoDS::Face( aShape );
|
|
|
|
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast( BRep_Tool::Surface( aFace ) );
|
|
|
|
|
|
|
|
if ( !aPlane.IsNull() ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
gp_Ax3 anAx3 = aPlane->Pln().Position();
|
|
|
|
gp_Pnt aLoc = anAx3.Location();
|
|
|
|
gp_Dir aXDir = anAx3.XDirection();
|
|
|
|
gp_Dir aYDir = anAx3.YDirection();
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
myData[ X ]->setValue( aLoc.X() );
|
|
|
|
myData[ Y ]->setValue( aLoc.Y() );
|
|
|
|
myData[ Z ]->setValue( aLoc.Z() );
|
|
|
|
|
|
|
|
myData[ DX1 ]->setValue( aXDir.X() );
|
|
|
|
myData[ DY1 ]->setValue( aXDir.Y() );
|
|
|
|
myData[ DZ1 ]->setValue( aXDir.Z() );
|
|
|
|
|
|
|
|
myData[ DX2 ]->setValue( aYDir.X() );
|
|
|
|
myData[ DY2 ]->setValue( aYDir.Y() );
|
|
|
|
myData[ DZ2 ]->setValue( aYDir.Z() );
|
2008-03-07 12:45:34 +05:00
|
|
|
aSelMgr->clearSelected();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else {
|
2005-06-02 13:17:09 +06:00
|
|
|
TColStd_IndexedMapOfInteger aMap;
|
2009-02-13 17:16:39 +05:00
|
|
|
aSelMgr->GetIndexes( anIO, aMap );
|
|
|
|
if ( aMap.Extent() == 1 ) { // Local Selection
|
|
|
|
int anIndex = aMap( 1 );
|
2005-06-02 13:17:09 +06:00
|
|
|
TopTools_IndexedMapOfShape aShapes;
|
2009-02-13 17:16:39 +05:00
|
|
|
TopExp::MapShapes( aShape, aShapes );
|
|
|
|
aShape = aShapes.FindKey( anIndex );
|
2008-03-07 12:45:34 +05:00
|
|
|
aSelMgr->clearSelected(); // ???
|
2005-06-02 13:17:09 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
|
|
|
|
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
|
|
|
|
myData[ X ]->setValue( aPnt.X() );
|
|
|
|
myData[ Y ]->setValue( aPnt.Y() );
|
|
|
|
myData[ Z ]->setValue( aPnt.Z() );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=================================================================================
|
|
|
|
// function : onSelectionDone()
|
|
|
|
// purpose : Called when selection as changed or other case
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onSelectionDone()
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( getConstructorId() == 0 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
onSelectionDone0();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument->setText( "" );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
|
|
|
SALOME_ListIO aSelList;
|
|
|
|
aSelMgr->selectedObjects(aSelList);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if (aSelList.Extent() == 1) {
|
|
|
|
Standard_Boolean aRes = Standard_False;
|
|
|
|
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
|
|
|
|
GEOM::GEOM_Object_var aSelectedObj = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !CORBA::is_nil( aSelectedObj ) && aRes ) {
|
|
|
|
QString aName = GEOMBase::GetName( aSelectedObj );
|
|
|
|
|
|
|
|
if ( getConstructorId() == 1 ) { // by shape position
|
2008-03-07 12:45:34 +05:00
|
|
|
// Get shape's position
|
2009-02-13 17:16:39 +05:00
|
|
|
CORBA::Double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz, Yx, Yy, Yz;
|
2008-03-07 12:45:34 +05:00
|
|
|
Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
|
|
|
|
Zz = Xx = Yy = 1.;
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
|
2009-02-13 17:16:39 +05:00
|
|
|
myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
|
|
|
|
aMeasureOp->GetPosition( aSelectedObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz );
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Calculate Y direction
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( aMeasureOp->IsDone() ) {
|
|
|
|
gp_Pnt aPnt ( Ox, Oy, Oz );
|
|
|
|
gp_Dir aDirN ( Zx, Zy, Zz );
|
|
|
|
gp_Dir aDirX ( Xx, Xy, Xz );
|
|
|
|
gp_Ax3 anAx3 ( aPnt, aDirN, aDirX );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
gp_Dir aDirY = anAx3.YDirection();
|
|
|
|
aDirY.Coord(Yx,Yy,Yz);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
// Set values
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ X ]->setValue( Ox );
|
|
|
|
myData[ Y ]->setValue( Oy );
|
|
|
|
myData[ Z ]->setValue( Oz );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX1 ]->setValue( Xx );
|
|
|
|
myData[ DY1 ]->setValue( Xy );
|
|
|
|
myData[ DZ1 ]->setValue( Xz );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX2 ]->setValue( Yx );
|
|
|
|
myData[ DY2 ]->setValue( Yy );
|
|
|
|
myData[ DZ2 ]->setValue( Yz );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myEditCurrentArgument->setText( aName );
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( getConstructorId() == 2 ) { // by point and two vectors
|
2008-03-07 12:45:34 +05:00
|
|
|
TopoDS_Shape aShape;
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) ) {
|
2008-03-07 12:45:34 +05:00
|
|
|
TopAbs_ShapeEnum aNeedType = TopAbs_EDGE;
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myEditCurrentArgument == Group2->LineEdit1 )
|
2008-03-07 12:45:34 +05:00
|
|
|
aNeedType = TopAbs_VERTEX;
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
TColStd_IndexedMapOfInteger aMap;
|
2009-02-13 17:16:39 +05:00
|
|
|
aSelMgr->GetIndexes( anIO, aMap );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !aMap.IsEmpty() ) {
|
|
|
|
int anIndex = aMap( 1 );
|
|
|
|
if ( aNeedType == TopAbs_EDGE )
|
|
|
|
aName += QString( "_edge_%1" ).arg( anIndex );
|
2008-03-07 12:45:34 +05:00
|
|
|
else
|
2009-02-13 17:16:39 +05:00
|
|
|
aName += QString( "_vertex_%1" ).arg( anIndex );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape aShapes;
|
2009-02-13 17:16:39 +05:00
|
|
|
TopExp::MapShapes( aShape, aShapes );
|
|
|
|
aShape = aShapes.FindKey( anIndex );
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myEditCurrentArgument == Group2->LineEdit1 ) {
|
|
|
|
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
|
|
|
|
gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
|
|
|
|
myData[ X ]->setValue( aPnt.X() );
|
|
|
|
myData[ Y ]->setValue( aPnt.Y() );
|
|
|
|
myData[ Z ]->setValue( aPnt.Z() );
|
|
|
|
myEditCurrentArgument->setText( aName );
|
|
|
|
if (Group2->LineEdit2->text() == "")
|
|
|
|
Group2->PushButton2->click();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-01-20 19:15:21 +05:00
|
|
|
else {
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ X ]->setValue( 0 );
|
|
|
|
myData[ Y ]->setValue( 0 );
|
|
|
|
myData[ Z ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
else if (myEditCurrentArgument == Group2->LineEdit2) {
|
|
|
|
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
|
2009-02-13 17:16:39 +05:00
|
|
|
gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
|
|
|
|
gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
|
|
|
|
gp_Dir aDir( gp_Vec( aP1, aP2 ) );
|
|
|
|
|
|
|
|
myData[ DX1 ]->setValue( aDir.X() );
|
|
|
|
myData[ DY1 ]->setValue( aDir.Y() );
|
|
|
|
myData[ DZ1 ]->setValue( aDir.Z() );
|
|
|
|
myEditCurrentArgument->setText( aName );
|
|
|
|
if (Group2->LineEdit3->text() == "")
|
|
|
|
Group2->PushButton3->click();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-01-20 19:15:21 +05:00
|
|
|
else {
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX1 ]->setValue( 0 );
|
|
|
|
myData[ DY1 ]->setValue( 0 );
|
|
|
|
myData[ DZ1 ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
|
2009-02-13 17:16:39 +05:00
|
|
|
gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
|
|
|
|
gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
|
|
|
|
gp_Dir aDir(gp_Vec( aP1, aP2 ));
|
|
|
|
|
|
|
|
myData[ DX2 ]->setValue( aDir.X() );
|
|
|
|
myData[ DY2 ]->setValue( aDir.Y() );
|
|
|
|
myData[ DZ2 ]->setValue( aDir.Z() );
|
|
|
|
myEditCurrentArgument->setText( aName );
|
|
|
|
if (Group2->LineEdit1->text() == "")
|
|
|
|
Group2->PushButton1->click();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-01-20 19:15:21 +05:00
|
|
|
else {
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX2 ]->setValue( 0 );
|
|
|
|
myData[ DY2 ]->setValue( 0 );
|
|
|
|
myData[ DZ2 ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-20 19:15:21 +05:00
|
|
|
else {
|
|
|
|
if ( getConstructorId() == 1 ) {
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ X ]->setValue( 0 );
|
|
|
|
myData[ Y ]->setValue( 0 );
|
|
|
|
myData[ Z ]->setValue( 0 );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX1 ]->setValue( 0 );
|
|
|
|
myData[ DY1 ]->setValue( 0 );
|
|
|
|
myData[ DZ1 ]->setValue( 0 );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
myData[ DX2 ]->setValue( 0 );
|
|
|
|
myData[ DY2 ]->setValue( 0 );
|
|
|
|
myData[ DZ2 ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
|
|
|
else if ( getConstructorId() == 2 ) {
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( myEditCurrentArgument == Group2->LineEdit1 ) {
|
|
|
|
myData[ X ]->setValue( 0 );
|
|
|
|
myData[ Y ]->setValue( 0 );
|
|
|
|
myData[ Z ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( myEditCurrentArgument == Group2->LineEdit2 ) {
|
|
|
|
myData[ DX1 ]->setValue( 0 );
|
|
|
|
myData[ DY1 ]->setValue( 0 );
|
|
|
|
myData[ DZ1 ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
|
|
|
|
myData[ DX2 ]->setValue( 0 );
|
|
|
|
myData[ DY2 ]->setValue( 0 );
|
|
|
|
myData[ DZ2 ]->setValue( 0 );
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2005-01-20 19:15:21 +05:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : SetEditCurrentArgument()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::SetEditCurrentArgument()
|
|
|
|
{
|
|
|
|
QPushButton* send = (QPushButton*)sender();
|
2009-02-13 17:16:39 +05:00
|
|
|
globalSelection(); // close local contexts, if any
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( send == Group1->PushButton1 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = Group1->LineEdit1;
|
|
|
|
globalSelection( GEOM_ALLGEOM );
|
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( send == Group2->PushButton1 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = Group2->LineEdit1;
|
2008-03-07 12:45:34 +05:00
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->PushButton2->setDown( false );
|
|
|
|
Group2->PushButton3->setDown( false );
|
|
|
|
Group2->LineEdit1->setEnabled( true );
|
|
|
|
Group2->LineEdit2->setEnabled( false );
|
|
|
|
Group2->LineEdit3->setEnabled( false );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( send == Group2->PushButton2 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = Group2->LineEdit2;
|
2008-03-07 12:45:34 +05:00
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->PushButton1->setDown( false );
|
|
|
|
Group2->PushButton3->setDown( false );
|
|
|
|
Group2->LineEdit1->setEnabled( false );
|
|
|
|
Group2->LineEdit2->setEnabled( true );
|
|
|
|
Group2->LineEdit3->setEnabled( false );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
else if ( send == Group2->PushButton3 ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument = Group2->LineEdit3;
|
2008-03-07 12:45:34 +05:00
|
|
|
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
|
2009-02-13 17:16:39 +05:00
|
|
|
Group2->PushButton1->setDown( false );
|
|
|
|
Group2->PushButton2->setDown( false );
|
|
|
|
Group2->LineEdit1->setEnabled( false );
|
|
|
|
Group2->LineEdit2->setEnabled( false );
|
|
|
|
Group2->LineEdit3->setEnabled( true );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
myEditCurrentArgument->setFocus();
|
2009-02-13 17:16:39 +05:00
|
|
|
send->setDown(true);
|
2004-12-01 15:39:14 +05:00
|
|
|
onSelectionDone();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : LineEditReturnPressed()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::LineEditReturnPressed()
|
|
|
|
{
|
|
|
|
QLineEdit* send = (QLineEdit*)sender();
|
|
|
|
|
|
|
|
myEditCurrentArgument = send;
|
|
|
|
GEOMBase_Skeleton::LineEditReturnPressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onActivate()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onActivate()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::ActivateThisDialog();
|
2009-02-13 17:16:39 +05:00
|
|
|
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
|
|
|
this, SLOT( onSelectionDone() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
ConstructorsClicked( getConstructorId() );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onDeactivate()
|
|
|
|
// purpose : public slot to deactivate if active
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onDeactivate()
|
|
|
|
{
|
|
|
|
GEOMBase_Skeleton::DeactivateActiveDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : enterEvent()
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
2009-02-13 17:16:39 +05:00
|
|
|
void BasicGUI_MarkerDlg::enterEvent( QEvent* )
|
2008-03-07 12:45:34 +05:00
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !mainFrame()->GroupConstructors->isEnabled() )
|
2004-12-01 15:39:14 +05:00
|
|
|
onActivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : createOperation
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
|
|
|
|
{
|
2006-05-06 14:44:32 +06:00
|
|
|
return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : isValid
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool BasicGUI_MarkerDlg::isValid( QString& msg )
|
|
|
|
{
|
|
|
|
const int id = getConstructorId();
|
2009-02-13 17:16:39 +05:00
|
|
|
gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
|
|
|
|
v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
|
2004-12-17 16:18:33 +05:00
|
|
|
|
2005-01-20 19:15:21 +05:00
|
|
|
bool isOk = false;
|
2004-12-17 16:18:33 +05:00
|
|
|
// we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
|
2005-01-20 19:15:21 +05:00
|
|
|
// Vectors shouldn't be checked for being orthogonal here!
|
|
|
|
if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
|
|
|
|
isOk = !v1.IsParallel( v2, Precision::Angular() );
|
|
|
|
if ( !isOk )
|
|
|
|
msg += tr( "VEC_PARALLEL" );
|
|
|
|
}
|
2004-12-17 16:18:33 +05:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
switch ( id ) {
|
|
|
|
case 0: {
|
|
|
|
bool ok = true;
|
|
|
|
for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
|
|
|
|
ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
|
|
|
|
return isOk && ok;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
return !Group1->LineEdit1->text().isEmpty() && isOk;
|
|
|
|
case 2:
|
|
|
|
return !Group2->LineEdit1->text().isEmpty() &&
|
|
|
|
!Group2->LineEdit2->text().isEmpty() &&
|
|
|
|
!Group2->LineEdit3->text().isEmpty() && isOk;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : execute
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
GEOM::GEOM_Object_var anObj = GEOM::GEOM_IBasicOperations::_narrow(
|
|
|
|
getOperation() )->MakeMarker( myData[ X ]->value(), myData[ Y ]->value(), myData[ Z ]->value(),
|
|
|
|
myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
|
|
|
|
myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
|
|
|
|
QStringList aParameters;
|
|
|
|
aParameters<<myData[X]->text();
|
|
|
|
aParameters<<myData[Y]->text();
|
|
|
|
aParameters<<myData[Z]->text();
|
|
|
|
aParameters<<myData[ DX1 ]->text();
|
|
|
|
aParameters<<myData[ DY1 ]->text();
|
|
|
|
aParameters<<myData[ DZ1 ]->text();
|
|
|
|
aParameters<<myData[ DX2 ]->text();
|
|
|
|
aParameters<<myData[ DY2 ]->text();
|
|
|
|
aParameters<<myData[ DZ2 ]->text();
|
|
|
|
|
|
|
|
if ( !anObj->_is_nil() ) {
|
|
|
|
if ( !IsPreview() )
|
|
|
|
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
|
2004-12-01 15:39:14 +05:00
|
|
|
objects.push_back( anObj._retn() );
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : onValueChanged
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::onValueChanged( double )
|
|
|
|
{
|
|
|
|
displayPreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
// function : displayPreview
|
|
|
|
// purpose :
|
|
|
|
//=================================================================================
|
|
|
|
void BasicGUI_MarkerDlg::displayPreview ( const bool activate,
|
|
|
|
const bool update,
|
|
|
|
const bool toRemoveFromEngine,
|
|
|
|
const double lineWidth )
|
|
|
|
{
|
2009-02-13 17:16:39 +05:00
|
|
|
if ( !myBlockPreview ) {
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOMBase_Skeleton::displayPreview( activate, update, toRemoveFromEngine, lineWidth );
|
|
|
|
if ( myConstructorId == 0 )
|
|
|
|
GEOMBase_Skeleton::activate( GEOM_MARKER );
|
|
|
|
}
|
|
|
|
}
|