//
// 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, Open CASCADE S.A.S.
-//
+// GEOM GEOMGUI : GUI for Geometry component
+// File : BasicGUI_PointDlg.cxx
+// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
+
#include "BasicGUI_PointDlg.h"
#include <SUIT_ResourceMgr.h>
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
+#include <QMenu>
+#include <QTimer>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#define PARAM_VALUE 0
#define COORD_VALUE 1
-#define POINT_XYZ 0
-#define POINT_REF 1
-#define POINT_EDGE 2
-#define POINT_INTINT 3
-#define POINT_SURF 4
+#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( GeometryGUI* theGeometryGUI, QWidget* parent,
- bool modal, Qt::WindowFlags fl )
+ bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_POINT") ) );
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" ) ) );
setWindowTitle( tr( "GEOM_POINT_TITLE" ) );
mainFrame()->RadioButton5->show();
mainFrame()->RadioButton5->setIcon( image5 );
- QGroupBox* paramGrp = new QGroupBox( centralWidget() );
- myParamCoord = new QButtonGroup( paramGrp );
- QHBoxLayout* boxLayout = new QHBoxLayout( paramGrp );
- boxLayout->setMargin( 0 ); boxLayout->setSpacing( 6 );
- QRadioButton* btn = new QRadioButton( tr( "GEOM_PARAM_VALUE" ), paramGrp );
+ 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" ), paramGrp );
+ btn = new QRadioButton( tr( "GEOM_COORD_VALUE" ), myParamGroup );
myParamCoord->addButton( btn, COORD_VALUE );
boxLayout->addWidget( btn );
myParamCoord->setExclusive( true );
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() );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( paramGrp );
+ layout->addWidget( myParamGroup );
layout->addWidget( GroupXYZ );
layout->addWidget( GroupOnCurve );
layout->addWidget( GroupOnSurface );
myZ->setEnabled( false );
QPalette aPal = myX->palette();
- aPal.setColor( QPalette::Disabled, QPalette::Text, QColor( 0, 0, 0 ) ) ;
+ 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();
}
myEdge = GEOM::GEOM_Object::_nil();
myRefPoint = GEOM::GEOM_Object::_nil();
+ myNeedType = TopAbs_VERTEX;
myEditCurrentArgument = 0;
/* Get setting of step value from file configuration */
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
-
+
/* min, max, step and decimals for spin boxes */
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
connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
-
- connect( myParamCoord->button( PARAM_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
- connect( myParamCoord->button( COORD_VALUE ), SIGNAL( clicked() ), this, SLOT( ClickParamCoord() ) );
+ 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( GroupOnSurface->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( GroupOnSurface->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
- connect( GroupLineIntersection->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
- connect( GroupLineIntersection->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ 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() ) );
connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged() ),
- this, SLOT(SelectionIntoArgument() ) );
+ this, SLOT(SelectionIntoArgument() ) );
-
initName( tr( "GEOM_VERTEX" ) );
-
+
ConstructorsClicked( 0 );
}
// purpose : Radio button management
//=================================================================================
void BasicGUI_PointDlg::ConstructorsClicked(int constructorId)
-{
- globalSelection(); // close local contexts, if any
-
+{
switch ( constructorId ) {
- case POINT_XYZ:
+ case GEOM_POINT_XYZ:
{
+ globalSelection(); // close local contexts, if any
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
-
+
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
GroupOnSurface->hide();
-
myCoordGrp->hide();
-
- myParamCoord->button( PARAM_VALUE )->hide();
- myParamCoord->button( COORD_VALUE )->hide();
+ myParamGroup->hide();
GroupXYZ->show();
break;
}
- case POINT_REF:
+ 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);
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
-
- myParamCoord->button( PARAM_VALUE )->hide();
- myParamCoord->button( COORD_VALUE )->hide();
+ GroupRefPoint->PushButton1->setDown(true);
+ myParamGroup->hide();
GroupXYZ->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
GroupOnSurface->hide();
-
GroupRefPoint->show();
-
myCoordGrp->show();
break;
}
- case POINT_EDGE:
+ 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);
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
-
GroupRefPoint->hide();
GroupLineIntersection->hide();
GroupOnSurface->hide();
-
- myParamCoord->button( PARAM_VALUE )->show();
- myParamCoord->button( COORD_VALUE )->show();
+ myParamGroup->show();
GroupOnCurve->show();
myCoordGrp->show();
-
updateParamCoord( false );
break;
}
- case POINT_INTINT:
+ 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( "" );
myLine2 = GEOM::GEOM_Object::_nil();
GroupLineIntersection->PushButton1->setDown(true);
GroupLineIntersection->PushButton2->setDown(false);
-
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
-
- myParamCoord->button( PARAM_VALUE )->hide();
- myParamCoord->button( COORD_VALUE )->hide();
+ myParamGroup->hide();
GroupXYZ->hide();
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupOnSurface->hide();
-
myCoordGrp->hide();
-
GroupLineIntersection->show();
break;
}
- case POINT_SURF:
+ 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);
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_FACE );
-
GroupRefPoint->hide();
GroupOnCurve->hide();
GroupLineIntersection->hide();
-
- myParamCoord->button( PARAM_VALUE )->show();
- myParamCoord->button( COORD_VALUE )->show();
+ myParamGroup->show();
GroupOnSurface->show();
myCoordGrp->show();
-
updateParamCoord( false );
break;
}
myY->setText( "" );
myZ->setText( "" );
- qApp->processEvents();
- updateGeometry();
- resize( minimumSizeHint() );
+ QTimer::singleShot(50, this, SLOT(updateSize()));
SelectionIntoArgument();
}
{
if ( !onAccept() )
return false;
-
+
initName();
ConstructorsClicked( getConstructorId() );
return true;
//=================================================================================
void BasicGUI_PointDlg::SelectionIntoArgument()
{
+ erasePreview();
const int id = getConstructorId();
- if ( ( id == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) && myEditCurrentArgument != 0 )
+ 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();
}
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIO, aRes );
if ( !CORBA::is_nil( aSelectedObject ) && aRes ) {
QString aName = GEOMBase::GetName(aSelectedObject);
- TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
TopoDS_Shape aShape;
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
- if ( id == POINT_EDGE || id == POINT_INTINT )
- aNeedType = TopAbs_EDGE;
- else if ( id == POINT_SURF )
- aNeedType = TopAbs_FACE;
+ 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 ( aNeedType == TopAbs_EDGE )
+ 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
+ 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 =
+ //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 );
+ aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ aSelectedObject = aFindedObject; // get Object from study
+ }
+ GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE );
}
else { // Global Selection
- if ( aShape.ShapeType() != aNeedType ) {
+ if ( aShape.ShapeType() != myNeedType ) {
aSelectedObject = GEOM::GEOM_Object::_nil();
aName = "";
- if ( id == POINT_XYZ ) return;
+ if ( id == GEOM_POINT_XYZ ) return;
}
}
}
- if ( aShape.IsNull() || aShape.ShapeType() != aNeedType)
- return;
+ if ( aShape.IsNull() || aShape.ShapeType() != myNeedType)
+ return;
- if ( id == POINT_XYZ ) {
+ 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 == POINT_REF ) {
+ else if ( id == GEOM_POINT_REF ) {
myRefPoint = aSelectedObject;
GroupRefPoint->LineEdit1->setText( aName );
}
- else if ( id == POINT_EDGE ) {
+ else if ( id == GEOM_POINT_EDGE ) {
myEdge = aSelectedObject;
GroupOnCurve->LineEdit1->setText( aName );
}
- else if ( id == POINT_INTINT ) {
- myEditCurrentArgument->setText( aName );
- globalSelection();
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
+ else if ( id == GEOM_POINT_INTINT ) {
+ myEditCurrentArgument->setText( aName );
if ( myEditCurrentArgument == GroupLineIntersection->LineEdit1 ) {
myLine1 = aSelectedObject;
- if ( !myLine1->_is_nil() && myLine2->_is_nil() )
- GroupLineIntersection->PushButton2->click();
+ 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->click();
+ 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 == POINT_SURF )
+ else if ( id == GEOM_POINT_SURF )
{
- myFace = aSelectedObject;
- GroupOnSurface->LineEdit1->setText( aName );
+ myFace = aSelectedObject;
+ GroupOnSurface->LineEdit1->setText( aName );
}
}
}
-
+
displayPreview();
}
void BasicGUI_PointDlg::LineEditReturnPressed()
{
QLineEdit* send = (QLineEdit*)sender();
- if ( send == GroupRefPoint->LineEdit1 ||
+ if ( send == GroupRefPoint->LineEdit1 ||
send == GroupOnCurve->LineEdit1 ||
- send == GroupLineIntersection->LineEdit1 ||
+ send == GroupLineIntersection->LineEdit1 ||
send == GroupLineIntersection->LineEdit2 ) {
myEditCurrentArgument = send;
GEOMBase_Skeleton::LineEditReturnPressed();
//=================================================================================
void BasicGUI_PointDlg::SetEditCurrentArgument()
{
- globalSelection(); // close local contexts, if any
-
QPushButton* send = (QPushButton*)sender();
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 );
}
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->PushButton2->setDown( false );
GroupLineIntersection->LineEdit1->setEnabled(true);
GroupLineIntersection->LineEdit2->setEnabled(false);
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupLineIntersection->PushButton2 ) {
GroupLineIntersection->LineEdit2->setFocus();
GroupLineIntersection->PushButton1->setDown( false );
GroupLineIntersection->LineEdit1->setEnabled(false);
GroupLineIntersection->LineEdit2->setEnabled(true);
- localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
send->setDown(true);
}
void BasicGUI_PointDlg::ActivateThisDialog( )
{
GEOMBase_Skeleton::ActivateThisDialog();
- // myGeomGUI->SetState( 0 );
+
+ connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
+ this, SLOT( SelectionIntoArgument() ) );
+
ConstructorsClicked( getConstructorId() );
}
//=================================================================================
void BasicGUI_PointDlg::OnPointSelected( const gp_Pnt& thePnt )
{
- if ( getConstructorId() == POINT_XYZ ) {
+ if ( getConstructorId() == GEOM_POINT_XYZ ) {
GroupXYZ->SpinBox_DX->setValue( thePnt.X() );
GroupXYZ->SpinBox_DY->setValue( thePnt.Y() );
GroupXYZ->SpinBox_DZ->setValue( thePnt.Z() );
bool BasicGUI_PointDlg::isValid( QString& msg )
{
const int id = getConstructorId();
- if ( id == POINT_XYZ ) {
+ 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 == POINT_REF ) {
+ 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;
return !myRefPoint->_is_nil() && ok;
}
- else if ( id == POINT_EDGE ) {
+ else if ( id == GEOM_POINT_EDGE ) {
bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE )
ok = GroupOnCurve->SpinBox_DX->isValid( msg, !IsPreview() );
}
return !myEdge->_is_nil() && ok;
}
- else if ( id == POINT_INTINT )
+ else if ( id == GEOM_POINT_INTINT )
return ( !myLine1->_is_nil() && !myLine2->_is_nil() );
- else if ( id == POINT_SURF ) {
+ else if ( id == GEOM_POINT_SURF ) {
bool ok = true;
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
ok = GroupOnSurface->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
ok = GroupXYZ->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
}
return !myFace->_is_nil() && ok;
-
}
return false;
}
GEOM::GEOM_Object_var anObj;
QStringList aParameters;
+ GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
+
switch ( getConstructorId() ) {
- case POINT_XYZ :
+ case GEOM_POINT_XYZ :
{
double x = GroupXYZ->SpinBox_DX->value();
double y = GroupXYZ->SpinBox_DY->value();
aParameters << GroupXYZ->SpinBox_DX->text();
aParameters << GroupXYZ->SpinBox_DY->text();
aParameters << GroupXYZ->SpinBox_DZ->text();
-
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->MakePointXYZ( x, y, z );
+
+ anObj = anOper->MakePointXYZ( x, y, z );
res = true;
break;
}
- case POINT_REF :
+ case GEOM_POINT_REF :
{
double dx = GroupRefPoint->SpinBox_DX->value();
double dy = GroupRefPoint->SpinBox_DY->value();
aParameters << GroupRefPoint->SpinBox_DX->text();
aParameters << GroupRefPoint->SpinBox_DY->text();
aParameters << GroupRefPoint->SpinBox_DZ->text();
-
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointWithReference( myRefPoint, dx, dy, dz );
+
+ anObj = anOper->MakePointWithReference( myRefPoint, dx, dy, dz );
res = true;
break;
}
- case POINT_EDGE :
+ case GEOM_POINT_EDGE :
{
- GEOM::GEOM_IBasicOperations_ptr anOp =
- GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
- anObj = anOp->MakePointOnCurve( myEdge, getParameter() );
+ 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 = anOp->MakePointOnCurveByCoord( myEdge, x, y, z );
+
+ anObj = anOper->MakePointOnCurveByCoord( myEdge, x, y, z );
}
res = true;
break;
}
- case POINT_INTINT :
- anObj = GEOM::GEOM_IBasicOperations::_narrow( getOperation() )->
- MakePointOnLinesIntersection( myLine1, myLine2 );
+ 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 POINT_SURF :
+ case GEOM_POINT_SURF :
{
- GEOM::GEOM_IBasicOperations_ptr anOp =
- GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
if ( myParamCoord->checkedId() == PARAM_VALUE ) {
- anObj = anOp->MakePointOnSurface( myFace, getUParameter(), getVParameter() );
+ 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 = anOp->MakePointOnSurfaceByCoord( myFace, x, y, z );
+
+ anObj = anOper->MakePointOnSurfaceByCoord( myFace, x, y, z );
}
res = true;
break;
}
}
-
+
const int id = getConstructorId();
- if(!anObj->_is_nil() && !IsPreview() && (id == POINT_XYZ ||
- id == POINT_REF ||
- id == POINT_EDGE ||
- id == POINT_SURF) ) {
- anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
+ 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 == POINT_REF || id == POINT_EDGE || id == POINT_SURF ) {
+ 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 ) {
myZ->setText( "" );
}
}
-
+
if ( !anObj->_is_nil() ) {
objects.push_back( anObj._retn() );
}
-
+
return res;
}
QMap<QString, GEOM::GEOM_Object_var> objMap;
switch ( getConstructorId() ) {
- case POINT_XYZ:
+ case GEOM_POINT_XYZ:
break;
- case POINT_REF:
+ case GEOM_POINT_REF:
objMap[GroupRefPoint->LineEdit1->text()] = myRefPoint;
break;
- case POINT_EDGE:
+ case GEOM_POINT_EDGE:
objMap[GroupOnCurve->LineEdit1->text()] = myEdge;
break;
- case POINT_INTINT:
+ case GEOM_POINT_INTINT:
objMap[GroupLineIntersection->LineEdit1->text()] = myLine1;
objMap[GroupLineIntersection->LineEdit2->text()] = myLine2;
break;
- case POINT_SURF:
+ case GEOM_POINT_SURF:
objMap[GroupOnSurface->LineEdit1->text()] = myFace;
break;
}
// function : ClickParamCoord()
// purpose :
//=================================================================================
-void BasicGUI_PointDlg::ClickParamCoord()
+void BasicGUI_PointDlg::ClickParamCoord( int id )
{
updateParamCoord( true );
displayPreview();
void BasicGUI_PointDlg::updateParamCoord(bool theIsUpdate)
{
bool isParam = myParamCoord->checkedId() == PARAM_VALUE;
- GroupXYZ->setShown( !isParam );
-
+
const int id = getConstructorId();
- if ( id == POINT_EDGE ) {
+ if ( id == GEOM_POINT_EDGE ) {
GroupOnCurve->TextLabel2->setShown( isParam );
GroupOnCurve->SpinBox_DX->setShown( isParam );
}
- else if ( id == POINT_SURF ) {
+ else if ( id == GEOM_POINT_SURF ) {
GroupOnSurface->TextLabel2->setShown( isParam );
GroupOnSurface->TextLabel3->setShown( isParam );
GroupOnSurface->SpinBox_DX->setShown( isParam );
GroupOnSurface->SpinBox_DY->setShown( isParam );
}
- if ( theIsUpdate ) {
- qApp->processEvents();
- updateGeometry();
- resize( minimumSizeHint() );
- }
+
+ 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 );
+}
+
+//=================================================================================
+// function : updateSize
+// purpose : adjust dialog size to minimum
+//=================================================================================
+void BasicGUI_PointDlg::updateSize()
+{
+ qApp->processEvents();
+ updateGeometry();
+ resize( minimumSizeHint() );
}