-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// 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
+// 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.
//
+// 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
//
-// File : BasicGUI_CircleDlg.cxx
-// Author : Lucien PIGNOLONI
-// Module : GEOM
-// $Header$
+// GEOM GEOMGUI : GUI for Geometry component
+// File : BasicGUI_CircleDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+//
#include "BasicGUI_CircleDlg.h"
-#include "SUIT_Desktop.h"
-#include "SUIT_Session.h"
-#include "SalomeApp_Application.h"
-#include "LightApp_SelectionMgr.h"
+#include <DlgRef.h>
-#include <qlabel.h>
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
-#include "GEOMImpl_Types.hxx"
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
-#include "utilities.h"
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
//=================================================================================
// class : BasicGUI_CircleDlg()
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-BasicGUI_CircleDlg::BasicGUI_CircleDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
- const char* name, bool modal, WFlags fl)
- :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
- WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+BasicGUI_CircleDlg::BasicGUI_CircleDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
+ bool modal, Qt::WindowFlags fl )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
- QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_PV")));
- QPixmap image2(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_CIRCLE_PNTS")));
- QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
+ QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PV" ) ) );
+ QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_PNTS" ) ) );
+ QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_CIRCLE_C2P" ) ) );
+ QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
- setCaption(tr("GEOM_CIRCLE_TITLE"));
+ setWindowTitle( tr( "GEOM_CIRCLE_TITLE" ) );
/***************************************************************/
- GroupConstructors->setTitle(tr("GEOM_CIRCLE"));
- RadioButton1->setPixmap(image0);
- RadioButton2->setPixmap(image2);
- RadioButton3->close(TRUE);
+ mainFrame()->GroupConstructors->setTitle( tr( "GEOM_CIRCLE" ) );
+ mainFrame()->RadioButton1->setIcon( image0 );
+ mainFrame()->RadioButton2->setIcon( image2 );
+ mainFrame()->RadioButton3->setIcon( image3 );
- GroupPntVecR = new DlgRef_2Sel1Spin(this, "GroupPntVecR");
- GroupPntVecR->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
+ GroupPntVecR = new DlgRef_2Sel1Spin( centralWidget() );
+ GroupPntVecR->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
- GroupPntVecR->TextLabel1->setText(tr("GEOM_CENTER_POINT"));
- GroupPntVecR->TextLabel2->setText(tr("GEOM_VECTOR"));
- GroupPntVecR->TextLabel3->setText(tr("GEOM_RADIUS"));
- GroupPntVecR->PushButton1->setPixmap(image1);
- GroupPntVecR->PushButton2->setPixmap(image1);
+ GroupPntVecR->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) + " " + tr( "GEOM_CENTER_DEFAULT" ) );
+ GroupPntVecR->TextLabel2->setText( tr( "GEOM_VECTOR" ) + " " + tr( "GEOM_AXIS_DEFAULT" ) );
+ GroupPntVecR->TextLabel3->setText( tr( "GEOM_RADIUS" ) );
+ GroupPntVecR->PushButton1->setIcon( image1 );
+ GroupPntVecR->PushButton2->setIcon( image1 );
+ GroupPntVecR->PushButton1->setDown( true );
GroupPntVecR->LineEdit1->setReadOnly( true );
GroupPntVecR->LineEdit2->setReadOnly( true );
- Group3Pnts = new DlgRef_3Sel_QTD(this, "Group3Pnts");
- Group3Pnts->GroupBox1->setTitle(tr("GEOM_3_POINTS"));
- Group3Pnts->TextLabel1->setText(tr("GEOM_POINT1"));
- Group3Pnts->TextLabel2->setText(tr("GEOM_POINT2"));
- Group3Pnts->TextLabel3->setText(tr("GEOM_POINT3"));
- Group3Pnts->PushButton1->setPixmap(image1);
- Group3Pnts->PushButton2->setPixmap(image1);
- Group3Pnts->PushButton3->setPixmap(image1);
+ GroupPntVecR->LineEdit1->setEnabled( true );
+ GroupPntVecR->LineEdit2->setEnabled( false );
+
+ Group3Pnts = new DlgRef_3Sel( centralWidget() );
+
+ Group3Pnts->GroupBox1->setTitle( tr( "GEOM_3_POINTS" ) );
+ Group3Pnts->TextLabel1->setText( tr( "GEOM_POINT1" ) );
+ Group3Pnts->TextLabel2->setText( tr( "GEOM_POINT2" ) );
+ Group3Pnts->TextLabel3->setText( tr( "GEOM_POINT3" ) );
+ Group3Pnts->PushButton1->setIcon( image1 );
+ Group3Pnts->PushButton2->setIcon( image1 );
+ Group3Pnts->PushButton3->setIcon( image1 );
+ Group3Pnts->PushButton1->setDown( true );
Group3Pnts->LineEdit1->setReadOnly( true );
Group3Pnts->LineEdit2->setReadOnly( true );
Group3Pnts->LineEdit3->setReadOnly( true );
-
- Layout1->addWidget( GroupPntVecR, 2, 0 );
- Layout1->addWidget( Group3Pnts, 2, 0 );
+ Group3Pnts->LineEdit1->setEnabled( true );
+ Group3Pnts->LineEdit2->setEnabled( false );
+ Group3Pnts->LineEdit3->setEnabled( false );
+
+ GroupCenter2Pnts = new DlgRef_3Sel( centralWidget() );
+ GroupCenter2Pnts->GroupBox1->setTitle( tr( "GEOM_CENTER_2POINTS" ) );
+ GroupCenter2Pnts->TextLabel1->setText( tr( "GEOM_CENTER_POINT" ) );
+ GroupCenter2Pnts->TextLabel2->setText( tr( "GEOM_POINT1" ) );
+ GroupCenter2Pnts->TextLabel3->setText( tr( "GEOM_POINT2" ) );
+ GroupCenter2Pnts->PushButton1->setIcon( image1 );
+ GroupCenter2Pnts->PushButton2->setIcon( image1 );
+ GroupCenter2Pnts->PushButton3->setIcon( image1 );
+ GroupCenter2Pnts->PushButton1->setDown( true );
+
+ GroupCenter2Pnts->LineEdit1->setReadOnly( true );
+ GroupCenter2Pnts->LineEdit2->setReadOnly( true );
+ GroupCenter2Pnts->LineEdit3->setReadOnly( true );
+
+ GroupCenter2Pnts->LineEdit1->setEnabled( true );
+ GroupCenter2Pnts->LineEdit2->setEnabled( false );
+ GroupCenter2Pnts->LineEdit3->setEnabled( false );
+
+ QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+ layout->setMargin( 0 ); layout->setSpacing( 6 );
+ layout->addWidget( GroupPntVecR );
+ layout->addWidget( Group3Pnts );
+ layout->addWidget( GroupCenter2Pnts );
/***************************************************************/
- setHelpFileName("circle.htm");
+ setHelpFileName( "create_circle_page.html" );
Init();
}
/* init variables */
myEditCurrentArgument = GroupPntVecR->LineEdit1;
- myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
-
- // myGeomGUI->SetState( 0 );
+ myPoint.nullify();
+ myDir.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myPoint3.nullify();
+ myPoint4.nullify();
+ myPoint5.nullify();
+ myPoint6.nullify();
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
+ double aStep = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
/* min, max, step and decimals for spin boxes & initial values */
- GroupPntVecR->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, aStep, 3);
- GroupPntVecR->SpinBox_DX->SetValue( 100 );
+ initSpinBox( GroupPntVecR->SpinBox_DX, 0.000001, COORD_MAX, aStep, "length_precision" );
+ GroupPntVecR->SpinBox_DX->setValue( 100 );
/* 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(GroupPntVecR->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(GroupPntVecR->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(Group3Pnts->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(Group3Pnts->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(Group3Pnts->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+ connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
- connect(GroupPntVecR->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(GroupPntVecR->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
+ connect( GroupPntVecR->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupPntVecR->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( Group3Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( Group3Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( Group3Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect(GroupPntVecR->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPntVecR->SpinBox_DX, SLOT(SetStep(double)));
-
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
+ connect( GroupCenter2Pnts->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupCenter2Pnts->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupCenter2Pnts->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+
+ connect( GroupPntVecR->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT(ValueChangedInSpinBox() ) );
+ connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
initName( tr( "GEOM_CIRCLE" ) );
- Group3Pnts->hide();
ConstructorsClicked( 0 );
}
+//=================================================================================
+// function : SetDoubleSpinBoxStep()
+// purpose : Double spin box management
+//=================================================================================
+void BasicGUI_CircleDlg::SetDoubleSpinBoxStep( double step )
+{
+ GroupPntVecR->SpinBox_DX->setSingleStep(step);
+}
+
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void BasicGUI_CircleDlg::ConstructorsClicked( int constructorId )
{
- disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0 );
- myPoint = myDir = myPoint1 = myPoint2 = myPoint3 = GEOM::GEOM_Object::_nil();
-
- switch ( constructorId )
- {
- case 0:
- {
- Group3Pnts->hide();
- resize(0, 0);
- GroupPntVecR->show();
-
- myEditCurrentArgument = GroupPntVecR->LineEdit1;
- GroupPntVecR->LineEdit1->setText("");
- GroupPntVecR->LineEdit2->setText("");
- break;
- }
+ disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
+ myPoint.nullify();
+ myDir.nullify();
+ myPoint1.nullify();
+ myPoint2.nullify();
+ myPoint3.nullify();
+ myPoint4.nullify();
+ myPoint5.nullify();
+ myPoint6.nullify();
+
+ switch ( constructorId ) {
+ case 0:
+ {
+ Group3Pnts->hide();
+ GroupCenter2Pnts->hide();
+ GroupPntVecR->show();
+
+ myEditCurrentArgument = GroupPntVecR->LineEdit1;
+ GroupPntVecR->LineEdit1->setText( "" );
+ GroupPntVecR->LineEdit2->setText( "" );
+ GroupPntVecR->PushButton1->setDown( true );
+ GroupPntVecR->PushButton2->setDown( false );
+ GroupPntVecR->LineEdit1->setEnabled( true );
+ GroupPntVecR->LineEdit2->setEnabled( false );
+ break;
+ }
case 1:
{
GroupPntVecR->hide();
- resize( 0, 0 );
+ GroupCenter2Pnts->hide();
Group3Pnts->show();
myEditCurrentArgument = Group3Pnts->LineEdit1;
- Group3Pnts->LineEdit1->setText("");
- Group3Pnts->LineEdit2->setText("");
- Group3Pnts->LineEdit3->setText("");
+ Group3Pnts->LineEdit1->setText( "" );
+ Group3Pnts->LineEdit2->setText( "" );
+ Group3Pnts->LineEdit3->setText( "" );
+ Group3Pnts->PushButton1->setDown( true );
+ Group3Pnts->PushButton2->setDown( false );
+ Group3Pnts->PushButton3->setDown( false );
+ Group3Pnts->LineEdit1->setEnabled( true );
+ Group3Pnts->LineEdit2->setEnabled( false );
+ Group3Pnts->LineEdit3->setEnabled( false );
break;
- }
+ }
+ case 2:
+ {
+ GroupPntVecR->hide();
+ Group3Pnts->hide();
+ GroupCenter2Pnts->show();
+
+ myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
+ GroupCenter2Pnts->LineEdit1->setText( "" );
+ GroupCenter2Pnts->LineEdit2->setText( "" );
+ GroupCenter2Pnts->LineEdit3->setText( "" );
+ GroupCenter2Pnts->PushButton1->setDown( true );
+ GroupCenter2Pnts->PushButton2->setDown( false );
+ GroupCenter2Pnts->PushButton3->setDown( false );
+ GroupCenter2Pnts->LineEdit1->setEnabled( true );
+ GroupCenter2Pnts->LineEdit2->setEnabled( false );
+ GroupCenter2Pnts->LineEdit3->setEnabled( false );
+ break;
+ }
}
+ qApp->processEvents();
+ updateGeometry();
+ resize( minimumSizeHint() );
+ SelectionIntoArgument();
+
myEditCurrentArgument->setFocus();
- globalSelection( GEOM_POINT );
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
+
+ displayPreview(true);
}
//=================================================================================
//=================================================================================
void BasicGUI_CircleDlg::ClickOnOk()
{
+ setIsApplyAndClose( true );
if ( ClickOnApply() )
ClickOnCancel();
}
return true;
}
-//=======================================================================
-// function : ClickOnCancel()
-// purpose :
-//=======================================================================
-void BasicGUI_CircleDlg::ClickOnCancel()
-{
- GEOMBase_Skeleton::ClickOnCancel();
-}
-
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void BasicGUI_CircleDlg::SelectionIntoArgument()
{
- myEditCurrentArgument->setText("");
+ myEditCurrentArgument->setText( "" );
- if ( IObjectCount() != 1 )
- {
- if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = GEOM::GEOM_Object::_nil();
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = GEOM::GEOM_Object::_nil();
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aList;
+ aSelMgr->selectedObjects( aList );
+
+ if ( aList.Extent() != 1 ) {
+ if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint.nullify();
+ else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2.nullify();
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) myPoint4.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) myPoint5.nullify();
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) myPoint6.nullify();
return;
}
- // nbSel == 1
- Standard_Boolean aRes = Standard_False;
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
- if ( !CORBA::is_nil( aSelectedObject ) && aRes )
- {
- myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
- if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) myPoint = aSelectedObject;
- else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) myDir = aSelectedObject;
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) myPoint1 = aSelectedObject;
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) myPoint2 = aSelectedObject;
- else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) myPoint3 = aSelectedObject;
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
+ GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+
+ myEditCurrentArgument->setText( aName );
+
+ if ( myEditCurrentArgument == GroupPntVecR->LineEdit1 ) {
+ myPoint = aSelectedObject;
+ if ( myPoint && !myDir )
+ GroupPntVecR->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) {
+ myDir = aSelectedObject;
+ if ( myDir && !myPoint )
+ GroupPntVecR->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit1 ) {
+ myPoint1 = aSelectedObject;
+ if ( myPoint1 && !myPoint2 )
+ Group3Pnts->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit2 ) {
+ myPoint2 = aSelectedObject;
+ if ( myPoint2 && !myPoint3 )
+ Group3Pnts->PushButton3->click();
+ }
+ else if ( myEditCurrentArgument == Group3Pnts->LineEdit3 ) {
+ myPoint3 = aSelectedObject;
+ if ( myPoint3 && !myPoint1 )
+ Group3Pnts->PushButton1->click();
+ }
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit1 ) {
+ myPoint4 = aSelectedObject;
+ if ( myPoint4 && !myPoint5 )
+ GroupCenter2Pnts->PushButton2->click();
+ }
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit2 ) {
+ myPoint5 = aSelectedObject;
+ if ( myPoint5 && !myPoint6 )
+ GroupCenter2Pnts->PushButton3->click();
+ }
+ else if ( myEditCurrentArgument == GroupCenter2Pnts->LineEdit3 ) {
+ myPoint6 = aSelectedObject;
+ if ( myPoint6 && !myPoint4 )
+ GroupCenter2Pnts->PushButton1->click();
+ }
}
- displayPreview();
+ displayPreview(true);
}
{
QPushButton* send = (QPushButton*)sender();
- if ( send == GroupPntVecR->PushButton1 ) myEditCurrentArgument = GroupPntVecR->LineEdit1;
- else if ( send == GroupPntVecR->PushButton2 ) myEditCurrentArgument = GroupPntVecR->LineEdit2;
- else if ( send == Group3Pnts->PushButton1 ) myEditCurrentArgument = Group3Pnts->LineEdit1;
- else if ( send == Group3Pnts->PushButton2 ) myEditCurrentArgument = Group3Pnts->LineEdit2;
- else if ( send == Group3Pnts->PushButton3 ) myEditCurrentArgument = Group3Pnts->LineEdit3;
+ if ( send == GroupPntVecR->PushButton1 ) {
+ myEditCurrentArgument = GroupPntVecR->LineEdit1;
+ GroupPntVecR->PushButton2->setDown(false);
+ GroupPntVecR->LineEdit1->setEnabled( true );
+ GroupPntVecR->LineEdit2->setEnabled( false );
+ }
+ else if ( send == GroupPntVecR->PushButton2 ) {
+ myEditCurrentArgument = GroupPntVecR->LineEdit2;
+ GroupPntVecR->PushButton1->setDown(false);
+ GroupPntVecR->LineEdit1->setEnabled( false );
+ GroupPntVecR->LineEdit2->setEnabled( true );
+ }
+ else if ( send == Group3Pnts->PushButton1 ) {
+ myEditCurrentArgument = Group3Pnts->LineEdit1;
+ Group3Pnts->PushButton2->setDown( false );
+ Group3Pnts->PushButton3->setDown( false );
+ Group3Pnts->LineEdit1->setEnabled( true );
+ Group3Pnts->LineEdit2->setEnabled( false );
+ Group3Pnts->LineEdit3->setEnabled( false );
+ }
+ else if ( send == Group3Pnts->PushButton2 ) {
+ myEditCurrentArgument = Group3Pnts->LineEdit2;
+ Group3Pnts->PushButton1->setDown( false );
+ Group3Pnts->PushButton3->setDown( false );
+ Group3Pnts->LineEdit1->setEnabled( false );
+ Group3Pnts->LineEdit2->setEnabled( true );
+ Group3Pnts->LineEdit3->setEnabled( false );
+ }
+ else if ( send == Group3Pnts->PushButton3 ) {
+ myEditCurrentArgument = Group3Pnts->LineEdit3;
+ Group3Pnts->PushButton1->setDown( false );
+ Group3Pnts->PushButton2->setDown( false );
+ Group3Pnts->LineEdit1->setEnabled( false );
+ Group3Pnts->LineEdit2->setEnabled( false );
+ Group3Pnts->LineEdit3->setEnabled( true );
+ }
+ else if ( send == GroupCenter2Pnts->PushButton1 ) {
+ myEditCurrentArgument = GroupCenter2Pnts->LineEdit1;
+ GroupCenter2Pnts->PushButton2->setDown( false );
+ GroupCenter2Pnts->PushButton3->setDown( false );
+ GroupCenter2Pnts->LineEdit1->setEnabled( true );
+ GroupCenter2Pnts->LineEdit2->setEnabled( false );
+ GroupCenter2Pnts->LineEdit3->setEnabled( false );
+ }
+ else if ( send == GroupCenter2Pnts->PushButton2 ) {
+ myEditCurrentArgument = GroupCenter2Pnts->LineEdit2;
+ GroupCenter2Pnts->PushButton1->setDown( false );
+ GroupCenter2Pnts->PushButton3->setDown( false );
+ GroupCenter2Pnts->LineEdit1->setEnabled( false );
+ GroupCenter2Pnts->LineEdit2->setEnabled( true );
+ GroupCenter2Pnts->LineEdit3->setEnabled( false );
+
+ }
+ else if ( send == GroupCenter2Pnts->PushButton3 ) {
+ myEditCurrentArgument = GroupCenter2Pnts->LineEdit3;
+ GroupCenter2Pnts->PushButton1->setDown( false );
+ GroupCenter2Pnts->PushButton2->setDown( false );
+ GroupCenter2Pnts->LineEdit1->setEnabled( false );
+ GroupCenter2Pnts->LineEdit2->setEnabled( false );
+ GroupCenter2Pnts->LineEdit3->setEnabled( true );
+ }
+
myEditCurrentArgument->setFocus();
-
- if ( myEditCurrentArgument == GroupPntVecR->LineEdit2 )
- globalSelection( GEOM_LINE );
- else
- globalSelection( GEOM_POINT );
- SelectionIntoArgument();
-}
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void BasicGUI_CircleDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupPntVecR->LineEdit1 ||
- send == GroupPntVecR->LineEdit2 ||
- send == Group3Pnts->LineEdit1 ||
- send == Group3Pnts->LineEdit2 ||
- send == Group3Pnts->LineEdit3 )
- {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
+ TopAbs_ShapeEnum aNeedType = ( myEditCurrentArgument == GroupPntVecR->LineEdit2 ) ?
+ TopAbs_EDGE : TopAbs_VERTEX;
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), aNeedType );
+
+ myEditCurrentArgument->setFocus();
+ // SelectionIntoArgument();
+ send->setDown(true);
+ displayPreview(true);
}
void BasicGUI_CircleDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- globalSelection( GEOM_POINT );
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
- // myGeomGUI->SetState( 0 );
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
ConstructorsClicked( getConstructorId() );
}
// function : enterEvent()
// purpose :
//=================================================================================
-void BasicGUI_CircleDlg::enterEvent(QEvent* e)
+void BasicGUI_CircleDlg::enterEvent( QEvent* )
{
- if ( !GroupConstructors->isEnabled() )
+ if ( !mainFrame()->GroupConstructors->isEnabled() )
ActivateThisDialog();
}
//=================================================================================
void BasicGUI_CircleDlg::DeactivateActiveDialog()
{
- // myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//=================================================================================
void BasicGUI_CircleDlg::ValueChangedInSpinBox()
{
- displayPreview();
+ displayPreview(true);
}
//=================================================================================
//=================================================================================
double BasicGUI_CircleDlg::getRadius() const
{
- return GroupPntVecR->SpinBox_DX->GetValue();
+ double r = 0.;
+ switch ( getConstructorId() ) {
+ case 0:
+ r = GroupPntVecR->SpinBox_DX->value(); break;
+ }
+ return r;
}
//=================================================================================
return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
}
-//=================================================================================
-// function : isEqual
-// purpose : it may also be needed to check for min distance between gp_Pnt-s...
-//=================================================================================
-static bool isEqual( const GEOM::GEOM_Object_var& thePnt1, const GEOM::GEOM_Object_var& thePnt2 )
-{
- return thePnt1->_is_equivalent( thePnt2 );
-}
-
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool BasicGUI_CircleDlg::isValid( QString& msg )
{
- const int id = getConstructorId();
- if ( id == 0 )
- return !myPoint->_is_nil() && !myDir->_is_nil() && getRadius() > 0;
- else if ( id == 1 )
- return !myPoint1->_is_nil() && !myPoint2->_is_nil() && !myPoint3->_is_nil() &&
- !isEqual( myPoint1, myPoint2 ) && !isEqual( myPoint1, myPoint3 ) && !isEqual( myPoint2, myPoint3 );
- return false;
+ bool ok = false;
+ switch( getConstructorId() ) {
+ case 0:
+ // nil point means origin of global CS
+ // nil vector means Z axis
+ ok = GroupPntVecR->SpinBox_DX->isValid(msg, !IsPreview()) && getRadius() > 0;
+ break;
+ case 1:
+ ok = myPoint1 && myPoint2 && myPoint3 && myPoint1 != myPoint2 &&
+ myPoint1 != myPoint3 && myPoint2 != myPoint3;
+ break;
+ case 2:
+ ok = myPoint4 && myPoint5 && myPoint6 && myPoint4 != myPoint5 &&
+ myPoint5 != myPoint6 && myPoint4 != myPoint6;
+ break;
+ default:
+ break;
+ }
+ return ok;
}
//=================================================================================
GEOM::GEOM_Object_var anObj;
- switch ( getConstructorId() )
- {
+ GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
+
+ switch ( getConstructorId() ) {
case 0 :
- anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCirclePntVecR( myPoint, myDir, getRadius() );
+ {
+ QStringList aParameters;
+ aParameters << GroupPntVecR->SpinBox_DX->text();
+ anObj = anOper->MakeCirclePntVecR( myPoint.get(), myDir.get(), getRadius() );
+ if ( !anObj->_is_nil() && !IsPreview() )
+ anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ res = true;
+ break;
+ }
+ case 1 :
+ anObj = anOper->MakeCircleThreePnt( myPoint1.get(), myPoint2.get(), myPoint3.get() );
res = true;
break;
- case 1 :
- anObj = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() )->MakeCircleThreePnt( myPoint1, myPoint2, myPoint3 );
+ case 2:
+ anObj = anOper->MakeCircleCenter2Pnt( myPoint4.get(), myPoint5.get(), myPoint6.get() );
res = true;
break;
}
if ( !anObj->_is_nil() )
objects.push_back( anObj._retn() );
+ else {
+ MESSAGE( "Execute Object is NULL!" );
+ }
return res;
}
//=================================================================================
-// function : closeEvent
-// purpose :
+// function : addSubshapeToStudy
+// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
-void BasicGUI_CircleDlg::closeEvent( QCloseEvent* e )
+void BasicGUI_CircleDlg::addSubshapesToStudy()
{
- GEOMBase_Skeleton::closeEvent( e );
+ switch ( getConstructorId() ) {
+ case 0:
+ GEOMBase::PublishSubObject( myPoint.get() );
+ GEOMBase::PublishSubObject( myDir.get() );
+ break;
+ case 1:
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
+ GEOMBase::PublishSubObject( myPoint3.get() );
+ break;
+ case 2:
+ GEOMBase::PublishSubObject( myPoint4.get() );
+ GEOMBase::PublishSubObject( myPoint5.get() );
+ GEOMBase::PublishSubObject( myPoint6.get() );
+ break;
+ default:
+ break;
+ }
}
-