-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// GEOM GEOMGUI : GUI for Geometry component
// File : PrimitiveGUI_BoxDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
#include <TopTools_IndexedMapOfShape.hxx>
#include <GEOMImpl_Types.hxx>
-//#include <ostream>
//=================================================================================
// class : PrimitiveGUI_BoxDlg()
//=================================================================================
PrimitiveGUI_BoxDlg::PrimitiveGUI_BoxDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl)
- : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
- myInitial(true)
+ : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
{
QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_2P")));
QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_BOX_DXYZ")));
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
// min, max, step and decimals for spin boxes
- initSpinBox(GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, step, 6); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox(GroupDimensions->SpinBox_DY, 0.000001, COORD_MAX, step, 6); // VSR: TODO: DBL_DIGITS_DISPLAY
- initSpinBox(GroupDimensions->SpinBox_DZ, 0.000001, COORD_MAX, step, 6); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox(GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, step, "length_precision" );
+ initSpinBox(GroupDimensions->SpinBox_DY, 0.000001, COORD_MAX, step, "length_precision" );
+ initSpinBox(GroupDimensions->SpinBox_DZ, 0.000001, COORD_MAX, step, "length_precision" );
// init variables
GroupPoints->LineEdit1->setReadOnly(true);
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;
}
}
qApp->processEvents();
updateGeometry();
resize(minimumSizeHint());
+ SelectionIntoArgument();
- if (myInitial) {
- // on dialog initialization we init the first field with a selected object (if any)
- SelectionIntoArgument();
- myInitial = false;
- }
- else {
- displayPreview();
- }
+ displayPreview(true);
}
//=================================================================================
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));
+ 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 == 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
- }
+ // 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);
}
//=================================================================================
// clear selection
//disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- //if (myInitial)
- // myInitial = false;
- //else
- // myGeomGUI->getApp()->selectionMgr()->clearSelected();
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
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() );
}
}