-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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.
//
-// 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
+// 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
//
+// GEOM GEOMGUI : GUI for Geometry component
// File : BasicGUI_PointDlg.cxx
-// Author : Lucien PIGNOLONI
-// Module : GEOM
-// $Header$
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-using namespace std;
#include "BasicGUI_PointDlg.h"
-#include "QAD_RightFrame.h"
-#include "OCCViewer_Viewer3d.h"
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+
+#include <DlgRef.h>
-#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <GEOMImpl_Types.hxx>
+
+#include <QApplication>
+#include <QButtonGroup>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QRadioButton>
+#include <QMenu>
+#include <QTimer>
+
+#include <gp_Pnt.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
-#include <Geom_Curve.hxx>
-#if OCC_VERSION_MAJOR >= 5
-#include <BRepAlgo.hxx>
-#else
-#include <BRepAlgoAPI.hxx>
-#endif
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#define PARAM_VALUE 0
+#define COORD_VALUE 1
+
+#define GEOM_POINT_XYZ 0
+#define GEOM_POINT_REF 1
+#define GEOM_POINT_EDGE 2
+#define GEOM_POINT_INTINT 3
+#define GEOM_POINT_SURF 4
+
+#define SPACING 6
+#define MARGIN 9
//=================================================================================
// class : BasicGUI_PointDlg()
-// purpose : Constructs a BasicGUI_PointDlg which is a child of 'parent', with the
+// 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.
//=================================================================================
-BasicGUI_PointDlg::BasicGUI_PointDlg(QWidget* parent, const char* name, BasicGUI* theBasicGUI, SALOME_Selection* Sel, const Handle (AIS_InteractiveContext)& ic, bool modal, WFlags fl)
- :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+BasicGUI_PointDlg::BasicGUI_PointDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+ bool modal, Qt::WindowFlags fl )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
- QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT")));
- QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_POINT_EDGE")));
- QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")));
+ 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" ) ) );
+ QPixmap image4( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_LINES") ) );
+ QPixmap image5( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT_FACE" ) ) );
+ QPixmap image6( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_LINE" ) ) );
+ QPixmap image7( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_WIRE" ) ) );
- setCaption(tr("GEOM_POINT_TITLE"));
+ setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
/***************************************************************/
- GroupConstructors->setTitle(tr("GEOM_POINTS"));
- RadioButton1->setPixmap(image0);
- RadioButton2->setPixmap(image1);
- RadioButton3->close(TRUE);
-
- GroupPoints = new DlgRef_3Spin(this, "GroupPoints");
- GroupPoints->GroupBox1->setTitle(tr("GEOM_COORDINATES"));
- GroupPoints->TextLabel1->setText(tr("GEOM_X"));
- GroupPoints->TextLabel2->setText(tr("GEOM_Y"));
- GroupPoints->TextLabel3->setText(tr("GEOM_Z"));
-
- GroupDimensions = new DlgRef_1Sel1Spin(this, "GroupDimensions");
- GroupDimensions->GroupBox1->setTitle(tr("GEOM_PARAM_POINT"));
- GroupDimensions->TextLabel1->setText(tr("GEOM_EDGE"));
- GroupDimensions->TextLabel2->setText(tr("GEOM_PARAMETER"));
- GroupDimensions->PushButton1->setPixmap(image2);
-
- Layout1->addWidget(GroupPoints, 1, 0);
- Layout1->addWidget(GroupDimensions, 1, 0);
- /***************************************************************/
-
- /* Initialisations */
- myBasicGUI = theBasicGUI;
- Init(ic);
+ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_POINTS" ) );
+ mainFrame()->RadioButton1->setIcon( image0 );
+ mainFrame()->RadioButton2->setIcon( image3 );
+ mainFrame()->RadioButton3->setIcon( image1 );
+ mainFrame()->RadioButton4->show();
+ mainFrame()->RadioButton4->setIcon( image4 );
+ mainFrame()->RadioButton5->show();
+ mainFrame()->RadioButton5->setIcon( image5 );
+
+ myParamGroup = new QGroupBox( centralWidget() );
+ myParamCoord = new QButtonGroup( myParamGroup );
+ QHBoxLayout* boxLayout = new QHBoxLayout( myParamGroup );
+ boxLayout->setMargin( MARGIN ); boxLayout->setSpacing( SPACING );
+ QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), myParamGroup );
+ myParamCoord->addButton( btn, PARAM_VALUE );
+ boxLayout->addWidget( btn );
+ btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup );
+ myParamCoord->addButton( btn, COORD_VALUE );
+ boxLayout->addWidget( btn );
+ myParamCoord->setExclusive( true );
+ myParamCoord->button( PARAM_VALUE )->setChecked( true );
+
+ 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_POINT_ON_EDGE" ) );
+ GroupOnCurve->TextLabel1->setText( tr( "GEOM_EDGE" ) );
+ GroupOnCurve->TextLabel2->setText( tr( "GEOM_PARAMETER" ) );
+ GroupOnCurve->PushButton1->setIcon( image2 );
+
+ GroupOnSurface = new DlgRef_1Sel2Spin( centralWidget() );
+ GroupOnSurface->GroupBox1->setTitle( tr( "GEOM_POINT_ON_FACE" ) );
+ GroupOnSurface->TextLabel1->setText( tr( "GEOM_FACE" ) );
+ GroupOnSurface->TextLabel2->setText( tr( "GEOM_UPARAMETER" ) );
+ GroupOnSurface->TextLabel3->setText( tr( "GEOM_VPARAMETER" ) );
+ GroupOnSurface->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" ) );
+
+ /* popup menu for line intersect buttons */
+ myBtnPopup = new QMenu(this);
+ QIcon ico_line = QIcon( image6 );
+ QIcon ico_wire = QIcon( image7 );
+ myActions[myBtnPopup->addAction( ico_line, tr( "GEOM_EDGE" ) )] = 0;
+ myActions[myBtnPopup->addAction( ico_wire, tr( "GEOM_WIRE" ) )] = 1;
+
+ GroupLineIntersection = new DlgRef_2Sel( centralWidget() );
+ GroupLineIntersection->GroupBox1->setTitle( tr( "GEOM_LINE_INTERSECTION" ) );
+ GroupLineIntersection->TextLabel1->setText( tr( "GEOM_LINE1" ) );
+ GroupLineIntersection->TextLabel2->setText( tr( "GEOM_LINE2" ) );
+ GroupLineIntersection->PushButton1->setIcon( image2 );
+ GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
+ GroupLineIntersection->PushButton2->setIcon( image2 );
+ GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
+ GroupLineIntersection->LineEdit2->setEnabled(false);
+
+ myCoordGrp = new QGroupBox( tr( "GEOM_COORDINATES_RES" ), centralWidget() );
+ QGridLayout* myCoordGrpLayout = new QGridLayout( myCoordGrp );
+ myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_X" ), myCoordGrp ), 0, 0 );
+ myX = new QLineEdit( myCoordGrp );
+ myCoordGrpLayout->addWidget( myX, 0, 1 );
+ myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Y" ), myCoordGrp ), 1, 0 );
+ myY = new QLineEdit( myCoordGrp );
+ myCoordGrpLayout->addWidget( myY, 1, 1 );
+ myCoordGrpLayout->addWidget( new QLabel( tr( "GEOM_Z" ), myCoordGrp ), 2, 0 );
+ myZ = new QLineEdit( myCoordGrp );
+ myCoordGrpLayout->addWidget( myZ, 2, 1 );
+
+ QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+ layout->setMargin( 0 ); layout->setSpacing( 6 );
+ layout->addWidget( myParamGroup );
+ layout->addWidget( GroupXYZ );
+ layout->addWidget( GroupOnCurve );
+ layout->addWidget( GroupOnSurface );
+ layout->addWidget( GroupRefPoint );
+ layout->addWidget( GroupLineIntersection );
+ layout->addWidget( myCoordGrp );
+
+ myX->setReadOnly( true );
+ myY->setReadOnly( true );
+ myZ->setReadOnly( true );
+
+ myX->setEnabled( false );
+ myY->setEnabled( false );
+ myZ->setEnabled( false );
+
+ QPalette aPal = myX->palette();
+ aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) );
+ myX->setPalette( aPal );
+ myY->setPalette( aPal );
+ myZ->setPalette( aPal );
+
+ setHelpFileName( "create_point_page.html" );
+
+ Init();
}
-//=======================================================================
+//=================================================================================
// function : ~BasicGUI_PointDlg()
// purpose : Destructor
-//=======================================================================
+//=================================================================================
BasicGUI_PointDlg::~BasicGUI_PointDlg()
{
- /* no need to delete child widgets, Qt does it all for us */
}
// function : Init()
// purpose :
//=================================================================================
-void BasicGUI_PointDlg::Init(const Handle(AIS_InteractiveContext)& ic)
+void BasicGUI_PointDlg::Init()
{
- /* init variables */
- myConstructorId = 0;
- myEditCurrentArgument = GroupDimensions->LineEdit1;
+ GroupOnCurve->LineEdit1->setReadOnly( true );
+ GroupOnSurface->LineEdit1->setReadOnly( true );
+ GroupRefPoint->LineEdit1->setReadOnly( true );
+ GroupLineIntersection->LineEdit1->setReadOnly( true );
+ GroupLineIntersection->LineEdit2->setReadOnly( true );
+ GroupLineIntersection->LineEdit1->setEnabled( true );
+ GroupLineIntersection->LineEdit2->setEnabled( false );
- myIC = ic;
- myParameter = 0.50;
- myPoint.SetCoord(0.0, 0.0, 0.0);
- myOkEdge = false;
+ myEdge = GEOM::GEOM_Object::_nil();
+ myRefPoint = GEOM::GEOM_Object::_nil();
+ myNeedType = TopAbs_VERTEX;
- myGeomGUI->myState = 0;
-
- /* Vertices Filter for all arguments */
- myEdgeFilter = new GEOM_ShapeTypeFilter(TopAbs_EDGE, myGeom);
+ myEditCurrentArgument = 0;
/* Get setting of step value from file configuration */
- QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep");
- step = St.toDouble();
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
/* min, max, step and decimals for spin boxes */
- double specificStep = 0.1;
- GroupDimensions->SpinBox_DX->RangeStepAndValidator(-999999.99999, 999999.99999, specificStep, 5);
- GroupPoints->SpinBox_DX->RangeStepAndValidator(-999.999, 999.999, step, 3);
- GroupPoints->SpinBox_DY->RangeStepAndValidator(-999.999, 999.999, step, 3);
- GroupPoints->SpinBox_DZ->RangeStepAndValidator(-999.999, 999.999, step, 3);
- GroupDimensions->SpinBox_DX->SetValue(myParameter);
- GroupPoints->SpinBox_DX->SetValue(0.0);
- GroupPoints->SpinBox_DY->SetValue(0.0);
- GroupPoints->SpinBox_DZ->SetValue(0.0);
-
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- myLocalContextId = myIC->OpenLocalContext();
- //myGeomBase->SetDisplayedObjectList();
- /* sub shapes selection */
- myLocalContextMode = TopAbs_VERTEX;
- myIC->ActivateStandardMode(myLocalContextMode);
- myUseLocalContext = true;
- }
- else
- myUseLocalContext = false;
-
- TopoDS_Shape S;
- bool displayPoint = true;
- if(myGeomBase->GetTopoFromSelection(mySelection, S)) {
- /* Filter a possibly previous selection and try to put it into coordinates */
- if(myGeomBase->VertexToPoint(S, myPoint))
- displayPoint = false;
- }
- this->PointIntoCoordinates(myPoint, displayPoint);
-
+ initSpinBox( GroupXYZ->SpinBox_DX, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupXYZ->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupXYZ->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ 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, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupRefPoint->SpinBox_DY, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupRefPoint->SpinBox_DZ, COORD_MIN, COORD_MAX, step, 6 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ GroupRefPoint->SpinBox_DX->setValue( 0.0 );
+ GroupRefPoint->SpinBox_DY->setValue( 0.0 );
+ GroupRefPoint->SpinBox_DZ->setValue( 0.0 );
+
+ step = 0.1;
+
+ initSpinBox( GroupOnCurve->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+ GroupOnCurve->SpinBox_DX->setValue( 0.5 );
+
+ initSpinBox( GroupOnSurface->SpinBox_DX, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+ GroupOnSurface->SpinBox_DX->setValue( 0.5 );
+ initSpinBox( GroupOnSurface->SpinBox_DY, 0., 1., step, 6 ); // VSR:TODO : DBL_DIGITS_DISPLAY
+ GroupOnSurface->SpinBox_DY->setValue( 0.5 );
+
/* signals and slots connections */
- connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
- connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
- connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
+ 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(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
+ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
- connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
- connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
- connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
- connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
- connect(GroupPoints->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
+ connect( myParamCoord, SIGNAL( buttonClicked( int ) ), this, SLOT( ClickParamCoord( int ) ) );
+ connect( GroupOnCurve->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupOnCurve->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double)));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double)));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DZ, SLOT(SetStep(double)));
+ connect( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ connect( myBtnPopup, SIGNAL( triggered( QAction* ) ), SLOT( onBtnPopup( QAction* ) ) );
+ connect( GroupLineIntersection->PushButton1, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupLineIntersection->PushButton2, SIGNAL( pressed() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupLineIntersection->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
+ connect( GroupLineIntersection->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- /* displays Dialog */
- GroupDimensions->hide();
- GroupPoints->show();
- this->show();
+ connect( GroupOnCurve->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupOnSurface->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupOnSurface->SpinBox_DY, 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 ) ) );
- return;
+ connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
+ this, SLOT(SelectionIntoArgument() ) );
+
+ initName( tr( "GEOM_VERTEX" ) );
+
+ ConstructorsClicked( 0 );
+}
+
+//=================================================================================
+// function : SetDoubleSpinBoxStep()
+// purpose : Double spin box management
+//=================================================================================
+void BasicGUI_PointDlg::SetDoubleSpinBoxStep( double step )
+{
+ GroupOnCurve->SpinBox_DX->setSingleStep(step);
+ GroupXYZ->SpinBox_DX->setSingleStep(step);
+ GroupXYZ->SpinBox_DY->setSingleStep(step);
+ GroupXYZ->SpinBox_DZ->setSingleStep(step);
+ GroupRefPoint->SpinBox_DX->setSingleStep(step);
+ GroupRefPoint->SpinBox_DY->setSingleStep(step);
+ GroupRefPoint->SpinBox_DZ->setSingleStep(step);
+ GroupOnSurface->SpinBox_DX->setSingleStep(step);
+ GroupOnSurface->SpinBox_DY->setSingleStep(step);
}
//=================================================================================
void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
{
- myConstructorId = constructorId;
- mySelection->ClearFilters();
- myGeomBase->EraseSimulationShape();
- mySimulationTopoDs.Nullify();
- disconnect(mySelection, 0, this, 0);
-
- switch (constructorId)
+ switch ( constructorId ) {
+ case GEOM_POINT_XYZ:
{
- case 0:
- {
- if(myUseLocalContext == false && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- myLocalContextId = myIC->OpenLocalContext();
- //myGeomBase->SetDisplayedObjectList();
- /* sub shapes selection */
- myLocalContextMode = TopAbs_VERTEX;
- myIC->ActivateStandardMode(myLocalContextMode);
- myUseLocalContext = true;
- }
-
- GroupDimensions->hide();
- resize(0, 0);
- GroupPoints->show();
-
- /* Display point simulation */
- PointIntoCoordinates(myPoint, true);
- break;
- }
- case 1:
- {
- if(myUseLocalContext == true && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- myIC->CloseLocalContext(myLocalContextId);
- myUseLocalContext = false;
- }
-
- GroupPoints->hide();
- resize(0, 0);
- GroupDimensions->show();
-
- myEditCurrentArgument = GroupDimensions->LineEdit1;
- GroupDimensions->LineEdit1->setText("");
- myOkEdge = false;
-
- /* filter for next selections */
- mySelection->AddFilter(myEdgeFilter);
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- break;
- }
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+
+ GroupRefPoint->hide();
+ GroupOnCurve->hide();
+ GroupLineIntersection->hide();
+ GroupOnSurface->hide();
+ myCoordGrp->hide();
+ myParamGroup->hide();
+ GroupXYZ->show();
+ break;
+ }
+ case GEOM_POINT_REF:
+ {
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+
+ myEditCurrentArgument = GroupRefPoint->LineEdit1;
+ myEditCurrentArgument->setText( "" );
+ myRefPoint = GEOM::GEOM_Object::_nil();
+ GroupRefPoint->PushButton1->setDown(true);
+ myParamGroup->hide();
+ GroupXYZ->hide();
+ GroupOnCurve->hide();
+ GroupLineIntersection->hide();
+ GroupOnSurface->hide();
+ GroupRefPoint->show();
+ myCoordGrp->show();
+ break;
+ }
+ case GEOM_POINT_EDGE:
+ {
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+
+ myEditCurrentArgument = GroupOnCurve->LineEdit1;
+ myEditCurrentArgument->setText( "" );
+ myEdge = GEOM::GEOM_Object::_nil();
+ GroupOnCurve->PushButton1->setDown(true);
+ GroupRefPoint->hide();
+ GroupLineIntersection->hide();
+ GroupOnSurface->hide();
+ myParamGroup->show();
+ GroupOnCurve->show();
+ myCoordGrp->show();
+ updateParamCoord( false );
+ break;
+ }
+ case GEOM_POINT_INTINT:
+ {
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+ myNeedType = TopAbs_EDGE;
+
+ myEditCurrentArgument = GroupLineIntersection->LineEdit1;
+ GroupLineIntersection->LineEdit1->setText( "" );
+ GroupLineIntersection->LineEdit2->setText( "" );
+ GroupLineIntersection->LineEdit1->setEnabled( true );
+ GroupLineIntersection->LineEdit2->setEnabled( false );
+ myLine1 = GEOM::GEOM_Object::_nil();
+ myLine2 = GEOM::GEOM_Object::_nil();
+ GroupLineIntersection->PushButton1->setDown(true);
+ GroupLineIntersection->PushButton2->setDown(false);
+ myParamGroup->hide();
+ GroupXYZ->hide();
+ GroupRefPoint->hide();
+ GroupOnCurve->hide();
+ GroupOnSurface->hide();
+ myCoordGrp->hide();
+ GroupLineIntersection->show();
+ break;
+ }
+ case GEOM_POINT_SURF:
+ {
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
+
+ myEditCurrentArgument = GroupOnSurface->LineEdit1;
+ myEditCurrentArgument->setText( "" );
+ myFace = GEOM::GEOM_Object::_nil();
+ GroupOnSurface->PushButton1->setDown(true);
+ GroupRefPoint->hide();
+ GroupOnCurve->hide();
+ GroupLineIntersection->hide();
+ myParamGroup->show();
+ GroupOnSurface->show();
+ myCoordGrp->show();
+ updateParamCoord( false );
+ break;
}
- return;
+ }
+
+ myX->setText( "" );
+ myY->setText( "" );
+ myZ->setText( "" );
+
+ QTimer::singleShot(50, this, SLOT(updateSize()));
+
+ SelectionIntoArgument();
}
//=================================================================================
void BasicGUI_PointDlg::ClickOnOk()
{
- this->ClickOnApply();
- this->ClickOnCancel();
- return;
+ if ( onAccept() )
+ ClickOnCancel();
}
// function : ClickOnApply()
// purpose :
//=================================================================================
-void BasicGUI_PointDlg::ClickOnApply()
-{
- buttonApply->setFocus();
- QAD_Application::getDesktop()->putInfo(tr(""));
- if(mySimulationTopoDs.IsNull())
- return;
- myGeomBase->EraseSimulationShape();
- mySimulationTopoDs.Nullify();
-
- /* Close local context */
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- myIC->CloseLocalContext(myLocalContextId);
- myUseLocalContext = false;
- }
-
- switch(myConstructorId)
- {
- case 0 :
- {
- /* Recup args and call method */
- double x = GroupPoints->SpinBox_DX->GetValue();
- double y = GroupPoints->SpinBox_DY->GetValue();
- double z = GroupPoints->SpinBox_DZ->GetValue();
-
- myBasicGUI->MakePointAndDisplay(x,y,z); /* WARNING : no display if a local context is opened */
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- /* no display if a local context is opened */
- myLocalContextId = myIC->OpenLocalContext();
- //myGeomBase->SetDisplayedObjectList();
- /* sub shapes selection */
- myLocalContextMode = TopAbs_VERTEX;
- myIC->ActivateStandardMode(myLocalContextMode);
- myUseLocalContext = true;
- }
- break;
- }
- case 1 :
- {
- if(myOkEdge == true) {
- /* this constructor method has no idl interface : we use same than constructor 0 */
- myBasicGUI->MakePointAndDisplay(myPoint.X(), myPoint.Y(), myPoint.Z());
- }
- break;
- }
- }
- return;
-}
-
-
-//=======================================================================
-// function : ClickOnCancel()
-// purpose :
-//=======================================================================
-void BasicGUI_PointDlg::ClickOnCancel()
+bool BasicGUI_PointDlg::ClickOnApply()
{
- if(myConstructorId == 0 && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
- myIC = v3d->getAISContext();
- if(myIC->HasOpenedContext()) {
- myIC->CloseLocalContext(myLocalContextId);
- myUseLocalContext = false;
- }
- }
+ if ( !onAccept() )
+ return false;
- myGeomGUI->myState = -1;
- GEOMBase_Skeleton::ClickOnCancel();
- return;
+ initName();
+ ConstructorsClicked( getConstructorId() );
+ return true;
}
//=================================================================================
void BasicGUI_PointDlg::SelectionIntoArgument()
{
- myGeomBase->EraseSimulationShape();
- mySimulationTopoDs.Nullify();
- myEditCurrentArgument->setText("");
- QString aString = ""; /* name of selection */
-
- int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString);
- if(nbSel != 1) {
- myOkEdge = false;
- return;
+ erasePreview();
+ const int id = getConstructorId();
+
+ if ( ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) && myEditCurrentArgument != 0 )
+ {
+ myEditCurrentArgument->setText( "" );
+ myX->setText( "" );
+ myY->setText( "" );
+ myZ->setText( "" );
+ myRefPoint = myEdge = myFace = GEOM::GEOM_Object::_nil();
+ } else if ( id == GEOM_POINT_INTINT ) {
+ myEditCurrentArgument->setText( "" );
+ if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 )
+ myLine1 = GEOM::GEOM_Object::_nil();
+ else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 )
+ myLine2 = GEOM::GEOM_Object::_nil();
}
- // nbSel == 1
- TopoDS_Shape S;
- if(!myGeomBase->GetTopoFromSelection(mySelection, S))
- return;
-
- if(S.ShapeType() == TopAbs_EDGE) {
- if(CalculateVertexOnCurve(TopoDS::Edge(S), myParameter, mySimulationTopoDs)) {
- if(myGeomBase->VertexToPoint(mySimulationTopoDs, myPoint)) {
- GroupDimensions->LineEdit1->setText(aString);
- myOkEdge = true;
- myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
+
+ if (aSelList.Extent() == 1) {
+ Standard_Boolean aRes = Standard_False;
+ Handle(SALOME_InteractiveObject) anIO = aSelList.First();
+ GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
+ if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
+ QString aName = GEOMBase::GetName(aSelectedObject);
+ TopoDS_Shape aShape;
+ if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
+ if ( id == GEOM_POINT_XYZ || id == GEOM_POINT_REF)
+ myNeedType = TopAbs_VERTEX;
+ else if ( id == GEOM_POINT_EDGE )
+ myNeedType = TopAbs_EDGE;
+ else if ( id == GEOM_POINT_SURF )
+ myNeedType = TopAbs_FACE;
+
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(anIO, aMap);
+ if ( aMap.Extent() == 1 ) { // Local Selection
+ int anIndex = aMap( 1 );
+ if ( myNeedType == TopAbs_FACE )
+ aName += QString( ":face_%1" ).arg( anIndex );
+ else if ( myNeedType == TopAbs_WIRE )
+ aName += QString( ":wire_%1" ).arg( anIndex );
+ else if ( myNeedType == TopAbs_EDGE )
+ aName += QString( ":edge_%1" ).arg( anIndex );
+ else if ( myNeedType == TopAbs_VERTEX )
+ aName += QString( ":vertex_%1" ).arg( anIndex );
+
+ //Find SubShape Object in Father
+ GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
+
+ if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
+ GEOM::GEOM_IShapesOperations_var aShapesOp =
+ getGeomEngine()->GetIShapesOperations(getStudyId());
+ aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ aSelectedObject = aFindedObject; // get Object from study
+ }
+ GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
+ }
+ else { // Global Selection
+ if ( aShape.ShapeType() != myNeedType ) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ if ( id == GEOM_POINT_XYZ ) return;
+ }
+ }
+ }
+
+ if ( aShape.IsNull() || aShape.ShapeType() != myNeedType)
+ return;
+
+ if ( id == GEOM_POINT_XYZ ) {
+ gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
+ GroupXYZ->SpinBox_DX->setValue( aPnt.X() );
+ GroupXYZ->SpinBox_DY->setValue( aPnt.Y() );
+ GroupXYZ->SpinBox_DZ->setValue( aPnt.Z() );
+ }
+ else if ( id == GEOM_POINT_REF ) {
+ myRefPoint = aSelectedObject;
+ GroupRefPoint->LineEdit1->setText( aName );
+ }
+ else if ( id == GEOM_POINT_EDGE ) {
+ myEdge = aSelectedObject;
+ GroupOnCurve->LineEdit1->setText( aName );
+ }
+ else if ( id == GEOM_POINT_INTINT ) {
+ myEditCurrentArgument->setText( aName );
+ if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
+ myLine1 = aSelectedObject;
+ if ( !myLine1->_is_nil() && myLine2->_is_nil() ) {
+ GroupLineIntersection->PushButton2->setMenu( 0 );
+ GroupLineIntersection->PushButton2->click();
+ GroupLineIntersection->PushButton2->setDown(true);
+ GroupLineIntersection->PushButton2->setMenu( myBtnPopup );
+ }
+ }
+ else if ( myEditCurrentArgument == GroupLineIntersection->LineEdit2 ) {
+ myLine2 = aSelectedObject;
+ if ( !myLine2->_is_nil() && myLine1->_is_nil() ) {
+ GroupLineIntersection->PushButton1->setMenu( 0 );
+ GroupLineIntersection->PushButton1->click();
+ GroupLineIntersection->PushButton1->setDown(true);
+ GroupLineIntersection->PushButton1->setMenu( myBtnPopup );
+ }
+ }
+ }
+ else if ( id == GEOM_POINT_SURF )
+ {
+ myFace = aSelectedObject;
+ GroupOnSurface->LineEdit1->setText( aName );
}
}
}
- return;
+
+ displayPreview();
}
void BasicGUI_PointDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if(send == GroupDimensions->LineEdit1)
- myEditCurrentArgument = GroupDimensions->LineEdit1;
- else
- return;
-
- GEOMBase_Skeleton::LineEditReturnPressed();
- return;
+ if ( send == GroupRefPoint->LineEdit1 ||
+ send == GroupOnCurve->LineEdit1 ||
+ send == GroupLineIntersection->LineEdit1 ||
+ send == GroupLineIntersection->LineEdit2 ) {
+ myEditCurrentArgument = send;
+ GEOMBase_Skeleton::LineEditReturnPressed();
+ }
}
{
QPushButton* send = (QPushButton*)sender();
- if(send == GroupDimensions->PushButton1) {
- GroupDimensions->LineEdit1->setFocus();
- myEditCurrentArgument = GroupDimensions->LineEdit1;
- mySelection->AddFilter(myEdgeFilter);
- this->SelectionIntoArgument();
+ if ( send == GroupRefPoint->PushButton1 ) {
+ GroupRefPoint->LineEdit1->setFocus();
+ myEditCurrentArgument = GroupRefPoint->LineEdit1;
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+ }
+ else if ( send == GroupOnCurve->PushButton1 ) {
+ GroupOnCurve->LineEdit1->setFocus();
+ myEditCurrentArgument = GroupOnCurve->LineEdit1;
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
- return;
+ else if ( send == GroupOnSurface->PushButton1 )
+ {
+ GroupOnSurface->LineEdit1->setFocus();
+ myEditCurrentArgument = GroupOnSurface->LineEdit1;
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
+ }
+ else if ( send == GroupLineIntersection->PushButton1 ) {
+ GroupLineIntersection->LineEdit1->setFocus();
+ myEditCurrentArgument = GroupLineIntersection->LineEdit1;
+ GroupLineIntersection->PushButton2->setDown( false );
+ GroupLineIntersection->LineEdit1->setEnabled(true);
+ GroupLineIntersection->LineEdit2->setEnabled(false);
+ }
+ else if ( send == GroupLineIntersection->PushButton2 ) {
+ GroupLineIntersection->LineEdit2->setFocus();
+ myEditCurrentArgument = GroupLineIntersection->LineEdit2;
+ GroupLineIntersection->PushButton1->setDown( false );
+ GroupLineIntersection->LineEdit1->setEnabled(false);
+ GroupLineIntersection->LineEdit2->setEnabled(true);
+ }
+ send->setDown(true);
}
// function : enterEvent()
// purpose : to reactivate this dialog box when mouse enter onto the window
//=================================================================================
-void BasicGUI_PointDlg::enterEvent(QEvent* e)
-{
- if (GroupConstructors->isEnabled())
- return;
- this->ActivateThisDialog();
- return;
-}
-
-
-//=======================================================================
-// function : closeEvent()
-// purpose :
-//=======================================================================
-void BasicGUI_PointDlg::closeEvent(QCloseEvent* e)
+void BasicGUI_PointDlg::enterEvent( QEvent* )
{
- /* same than click on cancel button */
- this->ClickOnCancel();
+ if ( !mainFrame()->GroupConstructors->isEnabled() )
+ ActivateThisDialog();
}
void BasicGUI_PointDlg::ActivateThisDialog( )
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-
- myGeomGUI->myState = 0;
- if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
- myIC = v3d->getAISContext();
- myLocalContextId = myIC->OpenLocalContext();
- //myGeomBase->SetDisplayedObjectList();
- /* sub shapes selection */
- myLocalContextMode = TopAbs_VERTEX;
- myIC->ActivateStandardMode(myLocalContextMode);
- myUseLocalContext = true;
- }
- if(myConstructorId == 1)
- mySelection->AddFilter(myEdgeFilter);
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
- if(!mySimulationTopoDs.IsNull())
- myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
- return;
+ ConstructorsClicked( getConstructorId() );
}
//=================================================================================
void BasicGUI_PointDlg::DeactivateActiveDialog()
{
- if(myConstructorId == 0 && QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
- myIC->CloseLocalContext(myLocalContextId);
- myUseLocalContext = false;
- }
- myGeomGUI->myState = -1;
+ // myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
- return;
}
//=================================================================================
void BasicGUI_PointDlg::ValueChangedInSpinBox(double newValue)
{
- DlgRef_SpinBox* send = (DlgRef_SpinBox*)sender();
- double vx, vy, vz;
-
- if(send == GroupPoints->SpinBox_DX) {
- vx = newValue;
- vy = GroupPoints->SpinBox_DY->GetValue();
- vz = GroupPoints->SpinBox_DZ->GetValue();
- } else if(send == GroupPoints->SpinBox_DY) {
- vx = GroupPoints->SpinBox_DX->GetValue();
- vy = newValue;
- vz = GroupPoints->SpinBox_DZ->GetValue();
- } else if(send == GroupPoints->SpinBox_DZ) {
- vx = GroupPoints->SpinBox_DX->GetValue();
- vy = GroupPoints->SpinBox_DY->GetValue();
- vz = newValue;
- } else if(send == GroupDimensions->SpinBox_DX) {
- myParameter = newValue;
- } else
- return;
-
- switch(myConstructorId)
+ displayPreview();
+}
+
+//=================================================================================
+// funcion : getParameter()
+// purpose :
+//=================================================================================
+double BasicGUI_PointDlg::getParameter() const
+{
+ return GroupOnCurve->SpinBox_DX->value();
+}
+
+
+//=================================================================================
+// funcion : getUParameter()
+// purpose :
+//=================================================================================
+double BasicGUI_PointDlg::getUParameter() const
+{
+ return GroupOnSurface->SpinBox_DX->value();
+}
+
+
+//=================================================================================
+// funcion : getVParameter()
+// purpose :
+//=================================================================================
+double BasicGUI_PointDlg::getVParameter() const
+{
+ return GroupOnSurface->SpinBox_DY->value();
+}
+
+
+//=================================================================================
+// function : OnPointSelected
+// purpose :
+//=================================================================================
+void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
+{
+ if ( getConstructorId() == GEOM_POINT_XYZ ) {
+ GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
+ GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
+ GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
+
+ displayPreview();
+ }
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr BasicGUI_PointDlg::createOperation()
+{
+ return myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool BasicGUI_PointDlg::isValid( QString& msg )
+{
+ const int id = getConstructorId();
+ if ( id == GEOM_POINT_XYZ ) {
+ bool ok = true;
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ return ok;
+ }
+ else if ( id == GEOM_POINT_REF ) {
+ bool ok = true;
+ ok = GroupRefPoint->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupRefPoint->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupRefPoint->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+
+ return !myRefPoint->_is_nil() && ok;
+ }
+ else if ( id == GEOM_POINT_EDGE ) {
+ bool ok = true;
+ if ( myParamCoord->checkedId() == PARAM_VALUE )
+ ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
+ else {
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ }
+ return !myEdge->_is_nil() && ok;
+ }
+ else if ( id == GEOM_POINT_INTINT )
+ return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
+ else if ( id == GEOM_POINT_SURF ) {
+ bool ok = true;
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupOnSurface->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ }
+ else {
+ ok = GroupXYZ->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
+ ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
+ }
+ return !myFace->_is_nil() && ok;
+ }
+ return false;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool BasicGUI_PointDlg::execute( ObjectList& objects )
+{
+ bool res = false;
+
+ GEOM::GEOM_Object_var anObj;
+ QStringList aParameters;
+
+ GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
+
+ switch ( getConstructorId() ) {
+ case GEOM_POINT_XYZ :
{
- case 0: // default constructor
- {
- myPoint.SetCoord(vx, vy, vz);
- mySimulationTopoDs = BRepBuilderAPI_MakeVertex (myPoint).Shape();
- myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
- break;
+ double x = GroupXYZ->SpinBox_DX->value();
+ double y = GroupXYZ->SpinBox_DY->value();
+ double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointXYZ( x, y, z );
+ res = true;
+ break;
+ }
+ case GEOM_POINT_REF :
+ {
+ double dx = GroupRefPoint->SpinBox_DX->value();
+ double dy = GroupRefPoint->SpinBox_DY->value();
+ double dz = GroupRefPoint->SpinBox_DZ->value();
+
+ aParameters << GroupRefPoint->SpinBox_DX->text();
+ aParameters << GroupRefPoint->SpinBox_DY->text();
+ aParameters << GroupRefPoint->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
+ res = true;
+ break;
+ }
+ case GEOM_POINT_EDGE :
+ {
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ anObj = anOper->MakePointOnCurve( myEdge, getParameter() );
+ aParameters<<GroupOnCurve->SpinBox_DX->text();
+ } else {
+ double x = GroupXYZ->SpinBox_DX->value();
+ double y = GroupXYZ->SpinBox_DY->value();
+ double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
}
- case 1:
- {
- this->SelectionIntoArgument();
- break;
+ res = true;
+ break;
+ }
+ case GEOM_POINT_INTINT :
+ anObj = anOper->MakePointOnLinesIntersection( myLine1, myLine2 );
+ if ( !anObj->_is_nil() ) {
+ QString aName = getNewObjectName();
+ if ( anObj->GetShapeType() == GEOM::COMPOUND && aName.startsWith("Vertex") )
+ initName( tr( "GEOM_COMPOUND" ) );
+ else if ( anObj->GetShapeType() == GEOM::VERTEX && aName.startsWith("Compound"))
+ initName( tr( "GEOM_VERTEX" ) );
+ }
+ res = true;
+ break;
+ case GEOM_POINT_SURF :
+ {
+ if ( myParamCoord->checkedId() == PARAM_VALUE ) {
+ anObj = anOper->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
+ aParameters<<GroupOnSurface->SpinBox_DX->text();
+ aParameters<<GroupOnSurface->SpinBox_DY->text();
+ } else {
+ double x = GroupXYZ->SpinBox_DX->value();
+ double y = GroupXYZ->SpinBox_DY->value();
+ double z = GroupXYZ->SpinBox_DZ->value();
+
+ aParameters << GroupXYZ->SpinBox_DX->text();
+ aParameters << GroupXYZ->SpinBox_DY->text();
+ aParameters << GroupXYZ->SpinBox_DZ->text();
+
+ anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
}
+ res = true;
+ break;
+ }
+ }
+
+ const int id = getConstructorId();
+ if(!anObj->_is_nil() && !IsPreview() && (id == GEOM_POINT_XYZ ||
+ id == GEOM_POINT_REF ||
+ id == GEOM_POINT_EDGE ||
+ id == GEOM_POINT_SURF) ) {
+ anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ }
+
+ if ( id == GEOM_POINT_REF || id == GEOM_POINT_EDGE || id == GEOM_POINT_SURF ) {
+ TopoDS_Shape aShape;
+ if ( GEOMBase::GetShape( anObj, aShape ) && !aShape.IsNull() &&
+ aShape.ShapeType() == TopAbs_VERTEX ) {
+ 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() ) );
+ }
+ else {
+ myX->setText( "" );
+ myY->setText( "" );
+ myZ->setText( "" );
}
- return;
+ }
+
+ if ( !anObj->_is_nil() ) {
+ objects.push_back( anObj._retn() );
+ }
+
+ return res;
+}
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose : virtual method to add new SubObjects if local selection
+//=================================================================================
+void BasicGUI_PointDlg::addSubshapesToStudy()
+{
+ QMap<QString, GEOM::GEOM_Object_var> objMap;
+
+ switch ( getConstructorId() ) {
+ case GEOM_POINT_XYZ:
+ break;
+ case GEOM_POINT_REF:
+ objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
+ break;
+ case GEOM_POINT_EDGE:
+ objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
+ break;
+ case GEOM_POINT_INTINT:
+ objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
+ objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
+ break;
+ case GEOM_POINT_SURF:
+ objMap[GroupOnSurface->LineEdit1->text()] = myFace;
+ break;
+ }
+ addSubshapesToFather( objMap );
}
+//=================================================================================
+// function : ClickParamCoord()
+// purpose :
+//=================================================================================
+void BasicGUI_PointDlg::ClickParamCoord( int id )
+{
+ updateParamCoord( true );
+ displayPreview();
+}
//=================================================================================
-// function : CalculateVertexOnCurve()
-// purpose : Calculate a Vertex on the curve given by 'anEdge'.
-// : The position of resultVertex is given by aParameter.
-// : For a linear edge, aParameter=0.0 gives the first vertex of edge
-// : aParameter=1.0 gives the last vertex of edge
-// : aParameter=0.5 gives the vertex on the middle of edge
-// : It is possible to get vertices out of edge using values > 1.0 or < 0.0
+// function : updateParamCoord
+// purpose :
//=================================================================================
-bool BasicGUI_PointDlg::CalculateVertexOnCurve(const TopoDS_Edge& anEdge, const Standard_Real aParameter, TopoDS_Shape& resultVertex)
+void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
{
-#if OCC_VERSION_MAJOR >= 5
- if(anEdge.IsNull() || !BRepAlgo::IsValid(anEdge))
-#else
- if(anEdge.IsNull() || !BRepAlgoAPI::IsValid(anEdge))
-#endif
- return false;
+ bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
- Standard_Real first, last;
- Handle(Geom_Curve) curv = BRep_Tool::Curve(anEdge, first, last);
- if(!curv->IsCN(0))
- return false;
-
- Standard_Real param;
- if(anEdge.Orientation() == TopAbs_FORWARD)
- param = first + (last-first) * aParameter;
- else
- param = last + (first-last) * aParameter;
-
- gp_Pnt paramPoint;
- curv->D0(param, paramPoint);
- resultVertex = BRepBuilderAPI_MakeVertex(paramPoint);
- return true;
+ const int id = getConstructorId();
+ if ( id == GEOM_POINT_EDGE ) {
+ GroupOnCurve->TextLabel2->setShown( isParam );
+ GroupOnCurve->SpinBox_DX->setShown( isParam );
+ }
+ else if ( id == GEOM_POINT_SURF ) {
+ GroupOnSurface->TextLabel2->setShown( isParam );
+ GroupOnSurface->TextLabel3->setShown( isParam );
+ GroupOnSurface->SpinBox_DX->setShown( isParam );
+ GroupOnSurface->SpinBox_DY->setShown( isParam );
+ }
+
+ GroupXYZ->setShown( !isParam );
+
+ if ( theIsUpdate )
+ QTimer::singleShot(50, this, SLOT(updateSize()));
}
+//=================================================================================
+// function : onBtnPopup()
+// purpose :
+//=================================================================================
+void BasicGUI_PointDlg::onBtnPopup( QAction* a )
+{
+ int index = myActions[a];
+ globalSelection(); // close local contexts, if any
+ QString type;
+ if ( index == 0 )
+ myNeedType = TopAbs_EDGE;
+ else
+ myNeedType = TopAbs_WIRE;
+
+ localSelection( GEOM::GEOM_Object::_nil(), myNeedType );
+}
-//=======================================================================
-// funcion : PointIntoCoordinates()
-// purpose : Sets user point coordinates into this dialog Spin boxes
-// : and displays it or not according to 'bool displayPoint'
-//=======================================================================
-void BasicGUI_PointDlg::PointIntoCoordinates(gp_Pnt P, bool displayPoint)
+//=================================================================================
+// function : updateSize
+// purpose : adjust dialog size to minimum
+//=================================================================================
+void BasicGUI_PointDlg::updateSize()
{
- GroupPoints->SpinBox_DX->SetValue(P.X());
- GroupPoints->SpinBox_DY->SetValue(P.Y());
- GroupPoints->SpinBox_DZ->SetValue(P.Z());
- myPoint.SetCoord(P.X(), P.Y(), P.Z());
- if(displayPoint) {
- mySimulationTopoDs = BRepBuilderAPI_MakeVertex(P).Shape();
- myGeomBase->DisplaySimulationShape(mySimulationTopoDs);
- }
- return;
+ qApp->processEvents();
+ updateGeometry();
+ resize( minimumSizeHint() );
}