X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPrimitiveGUI%2FPrimitiveGUI_BoxDlg.cxx;h=e68df444a1372b7408390ed668d5fbaa79c50fdf;hb=46574ac4f48a11f2161e754fe7c8df8684bc2b78;hp=5ca674101dd52dd4d41f78eb1f62612c9482a4c0;hpb=3012e7ea8e821cf418c52109c8471ce0f41672d2;p=modules%2Fgeom.git diff --git a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx index 5ca674101..e68df444a 100644 --- a/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx +++ b/src/PrimitiveGUI/PrimitiveGUI_BoxDlg.cxx @@ -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); } //================================================================================= @@ -242,71 +239,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)); + if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) { + QString aName = GEOMBase::GetName( aSelectedObject.get() ); - //Find SubShape Object in Father - GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName); + myEditCurrentArgument->setText(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 - } + // 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 && !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(); } + } - - 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 +311,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 +326,7 @@ void PrimitiveGUI_BoxDlg::ActivateThisDialog() connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); } - displayPreview(); + displayPreview(true); } //================================================================================= @@ -395,7 +345,7 @@ void PrimitiveGUI_BoxDlg::enterEvent (QEvent*) //================================================================================= void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox() { - displayPreview(); + displayPreview(true); } //================================================================================= @@ -413,18 +363,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 +395,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 +434,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() ); } }