\n To produce a <b>Simple Multi Translation</b> (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 <b>Number of Times</b> 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 <b>TUI Command:</b> <em>geompy.MakeMultiTranslation1D(Shape, Dir,
Step, NbTimes)</em>
\n <b>Arguments:</b> Name + 1 shape + 1 vector (for direction) + 1
\n To produce a <b>Double Multi Translation</b> (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 <b>Number of Times</b> 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 <b>TUI Command:</b> <em>geompy.MakeMultiTranslation2D(Shape, Dir1,
Step1, NbTimes1, Dir2, Step2, NbTimes2),</em> where \em Shape is a shape
\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 <b>TUI Command:</b> <em>geompy.MakeTranslationVector(Object, Vector)</em>
\n <b>Activate Distance</b> checkbox and <b>Distance</b> field allow defining the custom distance of translation.
\n <b>TUI Command </b> for translation by vector and custom distance: <em>geompy.MakeTranslationVectorDistance(Object, Vector, Distance)</em>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <GEOM_AISVector.hxx>
+#include <SOCC_Prs.h>
+#include <SOCC_ViewModel.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRep_Builder.hxx>
#include <GEOMImpl_Types.hxx>
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<<GroupPoints->SpinBox_DX->text();
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);
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_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+ if (aPrs)
+ aPrs->AddObject(anIO);
+ GEOMBase_Helper::displayPreview( aPrs, false, true );
+ }
+}
private:
void Init();
void enterEvent( QEvent* );
+ void createPathPreview( GEOM::GEOM_Object_var );
private:
GEOM::GEOM_Object_var myBase, myVectorU, myVectorV;
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <GEOM_AISVector.hxx>
+#include <SOCC_Prs.h>
+#include <SOCC_ViewModel.h>
// OCCT Includes
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRep_Builder.hxx>
#include <GEOMImpl_Types.hxx>
QStringList aParameters;
aParameters<<GroupPoints->SpinBox3->text();
bool byDistance = GroupPoints->CheckBox1->isChecked();
+ createPathPreview( myVector );
+
if (byDistance) {
double aDistance = GroupPoints->SpinBox3->value();
for (int i = 0; i < myObjects.length(); i++) {
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_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+ if (aPrs)
+ aPrs->AddObject(anIO);
+ GEOMBase_Helper::displayPreview( aPrs, false, true );
+ }
+}
private:
void Init();
void enterEvent( QEvent* );
+ void createPathPreview( GEOM::GEOM_Object_var );
private:
GEOM::ListOfGO myObjects;