X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FPrimitiveGUI%2FPrimitiveGUI_BoxDlg.cxx;h=6bbc7b0f4feafd5850015f8ed0ddff0b62559d29;hb=1468abed08a815d69b4def5820b72178a4f7bdc2;hp=5ca674101dd52dd4d41f78eb1f62612c9482a4c0;hpb=3012e7ea8e821cf418c52109c8471ce0f41672d2;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 5ca674101..6bbc7b0f4 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -1,23 +1,23 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2011 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 +// 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // GEOM GEOMGUI : GUI for Geometry component @@ -43,7 +43,6 @@ #include #include -//#include //================================================================================= // class : PrimitiveGUI_BoxDlg() @@ -123,7 +122,8 @@ void PrimitiveGUI_BoxDlg::Init() GroupPoints->LineEdit1->setText(""); GroupPoints->LineEdit2->setText(""); - myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil(); + myPoint1.nullify(); + myPoint2.nullify(); double initValue = 200.0; GroupDimensions->SpinBox_DX->setValue(initValue); @@ -139,9 +139,6 @@ void PrimitiveGUI_BoxDlg::Init() connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); - connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); - connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); connect(GroupDimensions->SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox())); @@ -187,7 +184,7 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId) disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); globalSelection(); // close local contexts, if any - displayPreview(); + displayPreview(true); break; } } @@ -197,7 +194,7 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId) resize(minimumSizeHint()); SelectionIntoArgument(); - displayPreview(); + displayPreview(true); } //================================================================================= @@ -206,6 +203,7 @@ void PrimitiveGUI_BoxDlg::ConstructorsClicked (int constructorId) //================================================================================= void PrimitiveGUI_BoxDlg::ClickOnOk() { + setIsApplyAndClose( true ); if (ClickOnApply()) ClickOnCancel(); } @@ -242,71 +240,37 @@ void PrimitiveGUI_BoxDlg::SelectionIntoArgument() aSelMgr->selectedObjects(aSelList); if (aSelList.Extent() != 1) { - if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1 = GEOM::GEOM_Object::_nil(); - else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2 = GEOM::GEOM_Object::_nil(); + if (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint1.nullify(); + else if (myEditCurrentArgument == GroupPoints->LineEdit2) myPoint2.nullify(); return; } - // nbSel == 1 - GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); - - if ( CORBA::is_nil(aSelectedObject) ) - return; - - QString aName = GEOMBase::GetName(aSelectedObject); - - // Get Selected object if selected subshape + GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX ); TopoDS_Shape aShape; - if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull()) - { - TColStd_IndexedMapOfInteger aMap; - aSelMgr->GetIndexes(aSelList.First(), aMap); - if (aMap.Extent() == 1) // Local Selection - { - int anIndex = aMap(1); - aName.append(":vertex_" + QString::number(anIndex)); - - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); - - if (aFindedObject->_is_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 - } + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); + + myEditCurrentArgument->setText(aName); + + if (myEditCurrentArgument == GroupPoints->LineEdit1) { + myPoint1 = aSelectedObject; + if (myPoint1 && !myPoint2) + GroupPoints->PushButton2->click(); } - else // Global Selection - { - if (aShape.ShapeType() != TopAbs_VERTEX) { - aSelectedObject = GEOM::GEOM_Object::_nil(); - aName = ""; - } + else if (myEditCurrentArgument == GroupPoints->LineEdit2) { + myPoint2 = aSelectedObject; + if (myPoint2 && !myPoint1) + GroupPoints->PushButton1->click(); + } + if ((myPoint1 && !myPoint2) || (myPoint2 && !myPoint1)) { + // clear selection + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + myGeomGUI->getApp()->selectionMgr()->clearSelected(); + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); } } - - myEditCurrentArgument->setText(aName); - - // clear selection - disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); - myGeomGUI->getApp()->selectionMgr()->clearSelected(); - connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), - this, SLOT(SelectionIntoArgument())); - - if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myPoint1 = aSelectedObject; - if (!myPoint1->_is_nil() && myPoint2->_is_nil()) - GroupPoints->PushButton2->click(); - } - else if (myEditCurrentArgument == GroupPoints->LineEdit2) { - myPoint2 = aSelectedObject; - if (!myPoint2->_is_nil() && myPoint1->_is_nil()) - GroupPoints->PushButton1->click(); - } - - displayPreview(); + displayPreview(true); } //================================================================================= @@ -348,20 +312,7 @@ void PrimitiveGUI_BoxDlg::SetEditCurrentArgument() this, SLOT(SelectionIntoArgument())); // seems we need it only to avoid preview disappearing, caused by selection mode change - displayPreview(); -} - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void PrimitiveGUI_BoxDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if (send == GroupPoints->LineEdit1 || send == GroupPoints->LineEdit2) { - myEditCurrentArgument = send; - GEOMBase_Skeleton::LineEditReturnPressed(); - } + displayPreview(true); } //================================================================================= @@ -376,7 +327,7 @@ void PrimitiveGUI_BoxDlg::ActivateThisDialog() connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } - displayPreview(); + displayPreview(true); } //================================================================================= @@ -395,7 +346,7 @@ void PrimitiveGUI_BoxDlg::enterEvent (QEvent*) //================================================================================= void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox() { - displayPreview(); + displayPreview(true); } //================================================================================= @@ -413,18 +364,21 @@ GEOM::GEOM_IOperations_ptr PrimitiveGUI_BoxDlg::createOperation() //================================================================================= bool PrimitiveGUI_BoxDlg::isValid (QString& msg) { - bool ok = true; + bool ok = false; if( getConstructorId() == 1 ) { - ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && ok; - ok = GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok; - - ok = fabs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && ok; - ok = fabs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && ok; - ok = fabs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion() && ok; + ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) && + GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) && + qAbs( GroupDimensions->SpinBox_DX->value() ) > Precision::Confusion() && + qAbs( GroupDimensions->SpinBox_DY->value() ) > Precision::Confusion() && + qAbs( GroupDimensions->SpinBox_DZ->value() ) > Precision::Confusion(); + } + else + { + ok = myPoint1 && myPoint2 && myPoint1 != myPoint2; } - return getConstructorId() == 0 ? !(myPoint1->_is_nil() || myPoint2->_is_nil()) : ok; + return ok; } //================================================================================= @@ -442,8 +396,8 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects) switch (getConstructorId()) { case 0: { - if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) { - anObj = anOper->MakeBoxTwoPnt(myPoint1, myPoint2); + if ( myPoint1 && myPoint2 ) { + anObj = anOper->MakeBoxTwoPnt(myPoint1.get(), myPoint2.get()); res = true; } } @@ -481,9 +435,7 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects) void PrimitiveGUI_BoxDlg::addSubshapesToStudy() { if (getConstructorId() == 0) { - QMap objMap; - objMap[GroupPoints->LineEdit1->text()] = myPoint1; - objMap[GroupPoints->LineEdit2->text()] = myPoint2; - addSubshapesToFather(objMap); + GEOMBase::PublishSubObject( myPoint1.get() ); + GEOMBase::PublishSubObject( myPoint2.get() ); } }