diff --git a/doc/salome/gui/GEOM/input/multi_translation_operation.doc b/doc/salome/gui/GEOM/input/multi_translation_operation.doc
index 2bd2ef3fc..d33346d1b 100644
--- a/doc/salome/gui/GEOM/input/multi_translation_operation.doc
+++ b/doc/salome/gui/GEOM/input/multi_translation_operation.doc
@@ -12,7 +12,9 @@ two directions.
\n To produce a Simple Multi Translation (in one direction) you
need to indicate an \b Object to be translated, a \b Vector of
translation, a \b Step of translation and a Number of Times the
-Object should be duplicated.
+Object should be duplicated. If a curve was selected instead of Vector,
+only its first and last vertices will be used to get the vector direction
+and the dialog preview will display the vector along which the object will be translated.
\n TUI Command: geompy.MakeMultiTranslation1D(Shape, Dir,
Step, NbTimes)
\n Arguments: Name + 1 shape + 1 vector (for direction) + 1
@@ -27,6 +29,8 @@ step value + 1 value (repetition).
\n To produce a Double Multi Translation (in two directions) you need to
indicate an \b Object to be translated, and, for both axes, a \b
Vector of translation, a \b Step of translation and a Number of Times the shape must be duplicated.
+If a curve was selected instead of Vectors, only its first and last vertices will be used to get the vector direction
+and the dialog preview will display the vector along which the object will be translated.
\n TUI Command: geompy.MakeMultiTranslation2D(Shape, Dir1,
Step1, NbTimes1, Dir2, Step2, NbTimes2), where \em Shape is a shape
diff --git a/doc/salome/gui/GEOM/input/translation_operation.doc b/doc/salome/gui/GEOM/input/translation_operation.doc
index 32958367d..c36a259a3 100644
--- a/doc/salome/gui/GEOM/input/translation_operation.doc
+++ b/doc/salome/gui/GEOM/input/translation_operation.doc
@@ -31,7 +31,9 @@ of the vector.
\image html transformation2.png
-\n Finally you can define an \b Object and the vector. The object will be translated by the length of the vector.
+\n Finally you can define an \b Object and the vector. The object will be translated by the length of the vector.
+If a curve was selected instead of vector, only its first and last vertices will be used to get the vector direction
+and the dialog preview will display the vector along which the object will be translated.
\n TUI Command: geompy.MakeTranslationVector(Object, Vector)
\n Activate Distance checkbox and Distance field allow defining the custom distance of translation.
\n TUI Command for translation by vector and custom distance: geompy.MakeTranslationVectorDistance(Object, Vector, Distance)
diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx
index 3edb08022..36f2a54dc 100644
--- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx
+++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx
@@ -32,8 +32,14 @@
#include
#include
+#include
+#include
+#include
#include
#include
+#include
+#include
+#include
// OCCT Includes
#include
@@ -42,6 +48,10 @@
#include
#include
#include
+#include
+#include
+#include
+#include
#include
@@ -680,6 +690,7 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
switch (getConstructorId()) {
case 0:
if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) {
+ createPathPreview ( myVectorU );
anObj = anOper->MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU);
if(!IsPreview()) {
aParameters<SpinBox_DX->text();
@@ -691,6 +702,8 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects)
case 1:
if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) &&
!CORBA::is_nil(myVectorV)) {
+ createPathPreview ( myVectorU );
+ createPathPreview ( myVectorV );
anObj = anOper->MultiTranslate2D(myBase,
myVectorU, myStepU, myNbTimesU,
myVectorV, myStepV, myNbTimesV);
@@ -754,3 +767,29 @@ void TransformationGUI_MultiTranslationDlg::restoreSubShapes (SALOMEDS::Study_pt
mainFrame()->CheckBoxAddPrefix->isChecked());
}
}
+
+//=================================================================================
+// function : createPathPreview
+// purpose :
+//=================================================================================
+void TransformationGUI_MultiTranslationDlg::createPathPreview ( GEOM::GEOM_Object_var thePath )
+{
+ if ( IsPreview() ) {
+ TopoDS_Shape aShape;
+ GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
+ TopoDS_Edge anEdge = TopoDS::Edge( aShape );
+ ShapeAnalysis_Edge aShapeAnal;
+ TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
+ TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
+ TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
+ const char* aName = "tmpVector";
+ Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
+
+ // add Prs to preview
+ SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SOCC_Prs* aPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+ if (aPrs)
+ aPrs->AddObject(anIO);
+ GEOMBase_Helper::displayPreview( aPrs, false, true );
+ }
+}
diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h
index 92457a839..ec4904819 100644
--- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h
+++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.h
@@ -56,6 +56,7 @@ protected:
private:
void Init();
void enterEvent( QEvent* );
+ void createPathPreview( GEOM::GEOM_Object_var );
private:
GEOM::GEOM_Object_var myBase, myVectorU, myVectorV;
diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx
index a5f7c4d97..96f373177 100644
--- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx
+++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx
@@ -32,16 +32,27 @@
#include
#include
+#include
+#include
+#include
#include
#include
+#include
+#include
+#include
// OCCT Includes
#include
#include
+#include
#include
#include
#include
#include
+#include
+#include
+#include
+#include
#include
@@ -628,6 +639,8 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects)
QStringList aParameters;
aParameters<SpinBox3->text();
bool byDistance = GroupPoints->CheckBox1->isChecked();
+ createPathPreview( myVector );
+
if (byDistance) {
double aDistance = GroupPoints->SpinBox3->value();
for (int i = 0; i < myObjects.length(); i++) {
@@ -732,3 +745,29 @@ void TransformationGUI_TranslationDlg::addSubshapesToStudy()
addSubshapesToFather(objMap);
}
}
+
+//=================================================================================
+// function : createPathPreview
+// purpose :
+//=================================================================================
+void TransformationGUI_TranslationDlg::createPathPreview ( GEOM::GEOM_Object_var thePath )
+{
+ if ( IsPreview() ) {
+ TopoDS_Shape aShape;
+ GEOMBase::GetShape( thePath, aShape, TopAbs_SHAPE );
+ TopoDS_Edge anEdge = TopoDS::Edge( aShape );
+ ShapeAnalysis_Edge aShapeAnal;
+ TopoDS_Vertex aFirst = aShapeAnal.FirstVertex( anEdge );
+ TopoDS_Vertex aLast = aShapeAnal.LastVertex( anEdge );
+ TopoDS_Shape aVector = BRepBuilderAPI_MakeEdge(BRep_Tool::Pnt(aFirst), BRep_Tool::Pnt(aLast)).Shape();
+ const char* aName = "tmpVector";
+ Handle(GEOM_AISVector) anIO = new GEOM_AISVector( aVector, aName );
+
+ // add Prs to preview
+ SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SOCC_Prs* aPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+ if (aPrs)
+ aPrs->AddObject(anIO);
+ GEOMBase_Helper::displayPreview( aPrs, false, true );
+ }
+}
diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.h b/src/TransformationGUI/TransformationGUI_TranslationDlg.h
index 2d064dabb..02c437fd5 100644
--- a/src/TransformationGUI/TransformationGUI_TranslationDlg.h
+++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.h
@@ -55,6 +55,7 @@ protected:
private:
void Init();
void enterEvent( QEvent* );
+ void createPathPreview( GEOM::GEOM_Object_var );
private:
GEOM::ListOfGO myObjects;