// 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
//
//
//
#include "SalomeApp_Application.h"
#include "LightApp_SelectionMgr.h"
+#include <TopoDS_Shape.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
#include <qlabel.h>
#include "GEOMImpl_Types.hxx"
Layout1->addWidget(GroupDimensions, 2, 0);
/***************************************************************/
- setHelpFileName("sphere.htm");
+ setHelpFileName("create_sphere_page.html");
Init();
}
-
//=================================================================================
// function : ~PrimitiveGUI_SphereDlg()
// purpose : Destroys the object and frees any allocated resources
/* no need to delete child widgets, Qt does it all for us */
}
-
//=================================================================================
// function : Init()
// purpose :
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
/* min, max, step and decimals for spin boxes */
- GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3);
- GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, 999.999, step, 3);
+ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY);
+ GroupDimensions->SpinBox_DX->RangeStepAndValidator(0.001, COORD_MAX, step, DBL_DIGITS_DISPLAY);
GroupPoints->SpinBox_DX->SetValue(100.0);
GroupDimensions->SpinBox_DX->SetValue(100.0);
connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX, SLOT(SetStep(double)));
+ connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
+ GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
+ connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
+ GroupDimensions->SpinBox_DX, SLOT(SetStep(double)));
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
initName(tr("GEOM_SPHERE"));
ConstructorsClicked(0);
}
-
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
-void PrimitiveGUI_SphereDlg::ConstructorsClicked(int constructorId)
+void PrimitiveGUI_SphereDlg::ConstructorsClicked (int constructorId)
{
- disconnect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), 0, this, 0);
-
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+
switch (constructorId)
{
case 0:
{
- globalSelection( GEOM_POINT );
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
GroupDimensions->hide();
resize(0, 0);
GroupPoints->show();
GroupPoints->LineEdit1->setText("");
myPoint = GEOM::GEOM_Object::_nil();
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
+ connect(myGeomGUI->getApp()->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
break;
}
case 1:
{
GroupPoints->hide();
+ globalSelection(); // close local contexts, if any
resize(0, 0);
GroupDimensions->show();
displayPreview();
}
-
//=================================================================================
// function : ClickOnOk()
// purpose :
ClickOnCancel();
}
-
//=================================================================================
// function : ClickOnApply()
// purpose :
return true;
}
-
-
-//=======================================================================
+//=================================================================================
// function : ClickOnCancel()
// purpose :
-//=======================================================================
+//=================================================================================
void PrimitiveGUI_SphereDlg::ClickOnCancel()
{
GEOMBase_Skeleton::ClickOnCancel();
}
-
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case
//=================================================================================
void PrimitiveGUI_SphereDlg::SelectionIntoArgument()
{
- if ( getConstructorId() != 0 )
+ if (getConstructorId() != 0)
return;
-
+
myEditCurrentArgument->setText("");
-
- if(IObjectCount() != 1)
- {
- myPoint = GEOM::GEOM_Object::_nil();
- return;
- }
-
+
+ if (IObjectCount() != 1)
+ {
+ myPoint = GEOM::GEOM_Object::_nil();
+ return;
+ }
+
/* nbSel == 1 ! */
Standard_Boolean testResult = Standard_False;
- GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
-
- if (!testResult || CORBA::is_nil( aSelectedObject ))
+ GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult);
+
+ if (!testResult || CORBA::is_nil(aSelectedObject))
return;
-
+
+ QString aName = GEOMBase::GetName(aSelectedObject);
+ TopoDS_Shape aShape;
+ if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
+ {
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(firstIObject(), 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 = 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
+ }
+ else // Global Selection
+ {
+ if (aShape.ShapeType() != TopAbs_VERTEX) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ }
+ }
+
+ myEditCurrentArgument->setText(aName);
myPoint = aSelectedObject;
- myEditCurrentArgument->setText( GEOMBase::GetName( myPoint ) );
-
+
displayPreview();
}
-
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
}
}
-
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
{
QPushButton* send = (QPushButton*)sender();
- if(send == GroupPoints->PushButton1) {
+ if (send == GroupPoints->PushButton1) {
GroupPoints->LineEdit1->setFocus();
myEditCurrentArgument = GroupPoints->LineEdit1;
- globalSelection( GEOM_POINT );
+ globalSelection(); // close local contexts, if any
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
SelectionIntoArgument();
}
}
-
//=================================================================================
// function : ActivateThisDialog()
// purpose :
void PrimitiveGUI_SphereDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
- connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
- SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-
- ConstructorsClicked( getConstructorId() );
-}
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+ ConstructorsClicked(getConstructorId());
+}
//=================================================================================
// function : DeactivateActiveDialog()
GEOMBase_Skeleton::DeactivateActiveDialog();
}
-
//=================================================================================
// function : enterEvent()
// purpose :
ActivateThisDialog();
}
-
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
displayPreview();
}
-
//=================================================================================
// function : createOperation
// purpose :
return getGeomEngine()->GetI3DPrimOperations( getStudyId() );
}
-
//=================================================================================
// function : isValid
// purpose :
// function : execute
// purpose :
//=================================================================================
-bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects )
+bool PrimitiveGUI_SphereDlg::execute (ObjectList& objects)
{
bool res = false;
-
+
GEOM::GEOM_Object_var anObj;
- switch ( getConstructorId() )
+ switch (getConstructorId())
{
- case 0 :
+ case 0:
{
- if ( !CORBA::is_nil( myPoint ) ) {
- anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() );
+ if (!CORBA::is_nil(myPoint)) {
+ anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
+ MakeSpherePntR(myPoint, getRadius());
res = true;
}
break;
}
- case 1 :
+ case 1:
{
- anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() );
+ anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->
+ MakeSphereR(getRadius());
res = true;
break;
}
}
-
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
-
+
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
+
return res;
}
//=================================================================================
void PrimitiveGUI_SphereDlg::closeEvent( QCloseEvent* e )
{
- //myGeomGUI->SetState( -1 );
GEOMBase_Skeleton::closeEvent( e );
}
-
-
//=================================================================================
// function : getRadius()
// purpose :
return GroupDimensions->SpinBox_DX->GetValue();
return 0;
}
+
+//=================================================================================
+// function : addSubshapeToStudy
+// purpose : virtual method to add new SubObjects if local selection
+//=================================================================================
+void PrimitiveGUI_SphereDlg::addSubshapesToStudy()
+{
+ QMap<QString, GEOM::GEOM_Object_var> objMap;
+
+switch (getConstructorId())
+ {
+ case 0:
+ objMap[GroupPoints->LineEdit1->text()] = myPoint;
+ break;
+ case 1:
+ return;
+ }
+ addSubshapesToFather( objMap );
+}