Salome HOME
Symbols for translation/rotation are created
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 24 Apr 2015 10:44:40 +0000 (13:44 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 24 Apr 2015 10:44:40 +0000 (13:44 +0300)
14 files changed:
src/SketchPlugin/SketchPlugin_MultiRotation.cpp
src/SketchPlugin/SketchPlugin_MultiTranslation.cpp
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/SketcherPrs_Mirror.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Transformation.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Transformation.h [new file with mode: 0644]
src/SketcherPrs/icons/rotate.png [new file with mode: 0644]
src/SketcherPrs/icons/translate.png [new file with mode: 0644]
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/arrow.png [new file with mode: 0644]

index 86f6943facb6c185146a951f5d80b401a52d5293..2f5ad3a499ad4b51b21358990f4a0dbf3013d84b 100644 (file)
@@ -20,6 +20,8 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_XY.h>
 
+#include <SketcherPrs_Factory.h>
+
 #define PI 3.1415926535897932
 
 SketchPlugin_MultiRotation::SketchPlugin_MultiRotation()
@@ -190,8 +192,7 @@ AISObjectPtr SketchPlugin_MultiRotation::getAISObject(AISObjectPtr thePrevious)
 
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS) {
-// TODO:
-//    anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+    anAIS = SketcherPrs_Factory::rotateConstraint(this, sketch()->coordinatePlane());
   }
   return anAIS;
 }
index e7b850ec214c9ba4bdcd6a435ce363bad2874b90..06cbd55d7ef98258e3ef3ff1e5a707fbdc806a08 100644 (file)
@@ -18,6 +18,8 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
+#include <SketcherPrs_Factory.h>
+
 SketchPlugin_MultiTranslation::SketchPlugin_MultiTranslation()
 {
 }
@@ -174,8 +176,7 @@ AISObjectPtr SketchPlugin_MultiTranslation::getAISObject(AISObjectPtr thePreviou
 
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS) {
-// TODO:
-//    anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+    anAIS = SketcherPrs_Factory::translateConstraint(this, sketch()->coordinatePlane());
   }
   return anAIS;
 }
index 963c7e54244d171e682de90299662e95c52283bf..833d9b62b5fd4fc967dc3ecf91cbe987968041bb 100644 (file)
@@ -17,6 +17,7 @@ SET(PROJECT_HEADERS
        SketcherPrs_Radius.h
        SketcherPrs_LengthDimension.h
        SketcherPrs_Mirror.h
+       SketcherPrs_Transformation.h
 )
 
 SET(PROJECT_SOURCES
@@ -35,6 +36,7 @@ SET(PROJECT_SOURCES
        SketcherPrs_Radius.cpp
        SketcherPrs_LengthDimension.cpp
        SketcherPrs_Mirror.cpp
+       SketcherPrs_Transformation.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -65,6 +67,8 @@ SET(PROJECT_PICTURES
        icons/equal.png
        icons/tangent.png
        icons/mirror.png
+       icons/rotate.png
+       icons/translate.png
 )
 
 ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS})
index 39ce4d6e0ce01385eba019c200cec8431ea4c742..b855929ab16f7513ffb86b1fe71fd7761c31a492 100644 (file)
@@ -16,6 +16,7 @@
 #include "SketcherPrs_Radius.h"
 #include "SketcherPrs_LengthDimension.h"
 #include "SketcherPrs_Mirror.h"
+#include "SketcherPrs_Transformation.h"
 
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
@@ -55,3 +56,21 @@ AISObjectPtr SketcherPrs_Factory::verticalConstraint(ModelAPI_Feature* theConstr
   aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
   return aAISObj; 
 }
+
+AISObjectPtr SketcherPrs_Factory::translateConstraint(ModelAPI_Feature* theConstraint,
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{ 
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
+  Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, true); 
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
+  return aAISObj; 
+}
+
+AISObjectPtr SketcherPrs_Factory::rotateConstraint(ModelAPI_Feature* theConstraint,
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{ 
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
+  Handle(SketcherPrs_Transformation) aPrs = new SketcherPrs_Transformation(theConstraint, thePlane, false); 
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
+  return aAISObj; 
+}
index 9b627b940650c0d30720e5c5b2a7e807621a43a8..291484d3b491e53960406d4d28462de3e29db618 100644 (file)
@@ -30,7 +30,7 @@ public:
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(coincidentConstraint)
 
-  /// Creates coincedent parallel presentation
+  /// Creates parallel constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(parallelConstraint)
@@ -40,45 +40,55 @@ public:
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(perpendicularConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates rigid constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(rigidConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates horizontal constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(horisontalConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates vertical constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(verticalConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates equal constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(equalConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates tangent constraiont presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(tangentConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates radius dimension presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(radiusConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates length dimension presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(lengthDimensionConstraint)
 
-  /// Creates coincedent perpendicular presentation
+  /// Creates mirror constraint presentation
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(mirrorConstraint)
+
+  /// Creates translate constraint presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(translateConstraint)
+
+  /// Creates rotate constraint presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(rotateConstraint)
 };
 
 #endif
index 2c05d225f25b00bf593763291f38d9ab833a6f55..2c680a64aaf7aae5a882f65c920772e048a3b382 100644 (file)
@@ -10,8 +10,6 @@
 
 #include <SketchPlugin_Constraint.h>
 
-#include <ModelAPI_AttributeRefList.h>
-
 #include <Graphic3d_AspectLine3d.hxx>
 #include <Prs3d_Root.hxx>
 
@@ -76,7 +74,6 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qua
   if (anAttrC.get() == NULL)
     return;
 
-  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
   int aNb = anAttrB->size();
   if (aNb != anAttrC->size())
     return;
@@ -90,20 +87,9 @@ void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qua
   addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
 
   // Draw source objects
-  int i;
-  ObjectPtr aObj;
-  for (i = 0; i < aNb; i++) {
-    aObj = anAttrB->object(i);
-    std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
-    if (aShape.get() != NULL)
-      drawShape(aShape, thePrs);
-  }
+  drawListOfShapes(anAttrB, thePrs);
+
   // draw mirrored objects
-  for (i = 0; i < aNb; i++) {
-    aObj = anAttrC->object(i);
-    std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
-    if (aShape.get() != NULL)
-      drawShape(aShape, thePrs);
-  }
+  drawListOfShapes(anAttrC, thePrs);
 }
 
index b4e646709886c7f327bb81be9f1a16afe0d7c578..9a7e9a43178df9d3460a6f9708133ede2718f951 100644 (file)
@@ -335,10 +335,12 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   int aNbVertex = myPntArray->VertexNumber();
   if (myOwner.IsNull()) {
     myOwner = new SelectMgr_EntityOwner(this);
-    for (int i = 1; i <= aNbVertex; i++) {
-      Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
-      mySPoints.Append(aSP);
-    }
+  }
+
+  mySPoints.Clear();
+  for (int i = 1; i <= aNbVertex; i++) {
+    Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
+    mySPoints.Append(aSP);
   }
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
@@ -465,3 +467,20 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theS
     StdPrs_Point::Add(thePrs, aPoint, myDrawer);
   }
 }
+
+void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr, 
+                                             const Handle(Prs3d_Presentation)& thePrs) const
+{
+  int aNb = theListAttr->size();
+  if (aNb == 0)
+    return;
+  int i;
+  ObjectPtr aObj;
+  for (i = 0; i < aNb; i++) {
+    aObj = theListAttr->object(i);
+    std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
+    if (aShape.get() != NULL)
+      drawShape(aShape, thePrs);
+  }
+}
+
index b6c0cf66a2b8a6407dadf7ad6ee10dc9b29fb42b..d2202bacf6f84cbb6f3fa0838e41fde18d73b291 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "SketcherPrs_SensitivePoint.h"
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_AttributeRefList.h>
 
 #include <AIS_InteractiveObject.hxx>
 #include <GeomAPI_Ax3.h>
@@ -115,6 +116,11 @@ protected:
   void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape, 
     const Handle(Prs3d_Presentation)& thePrs) const;
 
+  /// Draw a list of shapes stored in a RefListAttribute
+  /// \param theListAttr the attribute of reference3s list
+  /// \param thePrs the presentation scene
+  void drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr, 
+                        const Handle(Prs3d_Presentation)& thePrs) const;
 
 protected:
   /// Constraint feature
diff --git a/src/SketcherPrs/SketcherPrs_Transformation.cpp b/src/SketcherPrs/SketcherPrs_Transformation.cpp
new file mode 100644 (file)
index 0000000..dcbe966
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Transformation.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Transformation.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Constraint.h>
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+                                           bool isTranslation) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
+{
+}  
+
+bool SketcherPrs_Transformation::updatePoints(double theStep) const 
+{
+  std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+  if (anAttrB.get() == NULL)
+    return false;
+
+  int aNbB = anAttrB->size();
+  if (aNbB == 0)
+    return false;
+
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
+
+  int i;
+  ObjectPtr aObj;
+  gp_Pnt aP1;
+  for (i = 0; i < aNbB; i++) {
+    aObj = anAttrB->object(i);
+    aP1 = aMgr->getPosition(aObj, this, theStep);
+    myPntArray->SetVertice(i + 1, aP1);
+  }  
+
+  return true;
+}
+
+void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
+{
+  std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
+  std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
+  if (anAttrB.get() == NULL)
+    return;
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+  Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+  aGroup->SetPrimitivesAspect(aLineAspect);
+
+  drawListOfShapes(anAttrB, thePrs);
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Transformation.h b/src/SketcherPrs/SketcherPrs_Transformation.h
new file mode 100644 (file)
index 0000000..6ba9bc8
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Transformation.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Transformation_H
+#define SketcherPrs_Transformation_H
+
+#include "SketcherPrs_SymbolPrs.h"
+#include <ModelAPI_Feature.h>
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of parallel constraint
+*/
+class SketcherPrs_Transformation: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, 
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+                                         bool isTranslation);
+
+  DEFINE_STANDARD_RTTI(SketcherPrs_Transformation)
+protected:
+  virtual const char* iconName() const { return myIsTranslation? "translate.png" : "rotate.png"; }
+
+  /// Redefine this function in order to add additiona lines of constraint base
+  /// \param thePrs a presentation
+  /// \param theColor a color of additiona lines
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+
+  /// Update myPntArray according to presentation positions
+  /// \return true in case of success
+  virtual bool updatePoints(double theStep) const;
+
+private:
+  bool myIsTranslation;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/rotate.png b/src/SketcherPrs/icons/rotate.png
new file mode 100644 (file)
index 0000000..300121c
Binary files /dev/null and b/src/SketcherPrs/icons/rotate.png differ
diff --git a/src/SketcherPrs/icons/translate.png b/src/SketcherPrs/icons/translate.png
new file mode 100644 (file)
index 0000000..54be370
Binary files /dev/null and b/src/SketcherPrs/icons/translate.png differ
index 085837a9202a09c47140df20fd6b85a2fdc5cc19..de9da1ce1ba8cf5d576923b7e23b5f11a71f848f 100644 (file)
@@ -46,5 +46,6 @@
      <file>pictures/shading.png</file>
      <file>pictures/wireframe.png</file>
      <file>pictures/expression.png</file>
+     <file>pictures/arrow.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/arrow.png b/src/XGUI/pictures/arrow.png
new file mode 100644 (file)
index 0000000..47cc73d
Binary files /dev/null and b/src/XGUI/pictures/arrow.png differ