-// 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
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx>
-//#include <ostream>
//=================================================================================
// class : PrimitiveGUI_BoxDlg()
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);
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()));
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
globalSelection(); // close local contexts, if any
- displayPreview();
+ displayPreview(true);
break;
}
}
resize(minimumSizeHint());
SelectionIntoArgument();
- displayPreview();
+ displayPreview(true);
}
//=================================================================================
//=================================================================================
void PrimitiveGUI_BoxDlg::ClickOnOk()
{
+ setIsApplyAndClose( true );
if (ClickOnApply())
ClickOnCancel();
}
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
- Standard_Boolean testResult = Standard_False;
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
-
- if (!testResult || 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 == 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
- }
+ 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);
}
//=================================================================================
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);
}
//=================================================================================
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
}
- displayPreview();
+ displayPreview(true);
}
//=================================================================================
//=================================================================================
void PrimitiveGUI_BoxDlg::ValueChangedInSpinBox()
{
- displayPreview();
+ displayPreview(true);
}
//=================================================================================
//=================================================================================
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;
}
//=================================================================================
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;
}
}
void PrimitiveGUI_BoxDlg::addSubshapesToStudy()
{
if (getConstructorId() == 0) {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
- objMap[GroupPoints->LineEdit1->text()] = myPoint1;
- objMap[GroupPoints->LineEdit2->text()] = myPoint2;
- addSubshapesToFather(objMap);
+ GEOMBase::PublishSubObject( myPoint1.get() );
+ GEOMBase::PublishSubObject( myPoint2.get() );
}
}