#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
#include <GEOMImpl_Types.hxx>
//=================================================================================
layout->addWidget( GroupDimensions );
/***************************************************************/
- setHelpFileName( "multi_translation.htm" );
+ setHelpFileName( "multi_translation_operation_page.html" );
Init();
}
double SpecificStep = 1;
/* min, max, step and decimals for spin boxes & initial values */
- initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 3 );
- initSpinBox( GroupPoints->SpinBox_DY, 1.0, MAX_NUMBER, SpecificStep, 3 );
+ initSpinBox( GroupPoints->SpinBox_DX, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupPoints->SpinBox_DY, 1.0, MAX_NUMBER, SpecificStep, 10 );
GroupPoints->SpinBox_DX->setValue( myStepU );
GroupPoints->SpinBox_DY->setValue( myNbTimesU );
- initSpinBox( GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, 3 );
- initSpinBox( GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep, 3 );
- initSpinBox( GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 3 );
- initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 3 );
+ initSpinBox( GroupDimensions->SpinBox_DX1, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupDimensions->SpinBox_DY1, 1.0, MAX_NUMBER, SpecificStep, 10 );
+ initSpinBox( GroupDimensions->SpinBox_DX2, COORD_MIN, COORD_MAX, step, 10 ); // VSR: TODO: DBL_DIGITS_DISPLAY
+ initSpinBox( GroupDimensions->SpinBox_DY2, 1.0, MAX_NUMBER, SpecificStep, 10 );
GroupDimensions->SpinBox_DX1->setValue( myStepU );
GroupDimensions->SpinBox_DY1->setValue( myNbTimesU );
GroupDimensions->SpinBox_DX2->setValue( myStepV );
connect( GroupDimensions->CheckButton1, SIGNAL( toggled( bool ) ), this, SLOT( ReverseStepU() ) );
connect( GroupDimensions->CheckButton2, SIGNAL( toggled( bool ) ), this, SLOT( ReverseStepV() ) );
- connect( myGeomGUI->getApp()->selectionMgr(),
+ connect( myGeomGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
-
initName( tr( "GEOM_MULTITRANSLATION" ) );
if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) )
return;
- if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
+ QString aName = GEOMBase::GetName( aSelectedObject );
+
+ if ( myEditCurrentArgument == GroupPoints->LineEdit1 ||
myEditCurrentArgument == GroupDimensions->LineEdit1 )
- myBase = aSelectedObject;
- else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
- myEditCurrentArgument == GroupDimensions->LineEdit2 )
- myVectorU = aSelectedObject;
- else if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
- myVectorV = aSelectedObject;
-
- myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
+ myBase = aSelectedObject;
+ else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit2 ||
+ myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
+ if ( testResult && !aSelectedObject->_is_nil() ) {
+ 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 ) {
+ int anIndex = aMap( 1 );
+ aName += QString( ":edge_%1" ).arg( 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() );
+ if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
+ myVectorV = aShapesOp->GetSubShape( aSelectedObject, anIndex );
+ else
+ myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
+ }
+ else {
+ if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
+ myVectorV = aFindedObject;
+ else
+ myVectorU = aFindedObject;
+ }
+ }
+ else {
+ if ( aShape.ShapeType() != TopAbs_EDGE ) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
+ myVectorV = aSelectedObject;
+ else
+ myVectorU = aSelectedObject;
+ }
+ }
+ }
+ }
+
+ myEditCurrentArgument->setText( aName );
displayPreview();
}
void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
-
+ globalSelection( GEOM_ALLSHAPES );
if ( send == GroupPoints->PushButton1 ) {
myEditCurrentArgument = GroupPoints->LineEdit1;
- globalSelection( GEOM_ALLSHAPES );
}
else if ( send == GroupPoints->PushButton2 ) {
myEditCurrentArgument = GroupPoints->LineEdit2;
- globalSelection( GEOM_LINE );
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupDimensions->PushButton1 ) {
myEditCurrentArgument = GroupDimensions->LineEdit1;
- globalSelection( GEOM_ALLSHAPES );
}
else if ( send == GroupDimensions->PushButton2 ) {
myEditCurrentArgument = GroupDimensions->LineEdit2;
- globalSelection( GEOM_LINE );
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
else if ( send == GroupDimensions->PushButton3 ) {
myEditCurrentArgument = GroupDimensions->LineEdit3;
- globalSelection( GEOM_LINE );
+ localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
}
myEditCurrentArgument->setFocus();
//=================================================================================
-// function : closeEvent
-// purpose :
+// function : addSubshapeToStudy
+// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
-void TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e )
+void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
{
- // myGeomGUI->SetState( -1 );
- GEOMBase_Skeleton::closeEvent( e );
+ QMap<QString, GEOM::GEOM_Object_var> objMap;
+
+ switch ( getConstructorId() ) {
+ case 0:
+ objMap[GroupPoints->LineEdit2->text()] = myVectorU;
+ break;
+ case 1:
+ objMap[GroupDimensions->LineEdit2->text()] = myVectorU;
+ objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
+ break;
+ }
+ addSubshapesToFather( objMap );
}