]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Apr 2015 09:39:39 +0000 (12:39 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 8 Apr 2015 09:39:39 +0000 (12:39 +0300)
19 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/mirror.png [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Equal.cpp
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/SketcherPrs_Mirror.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Mirror.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp
src/SketcherPrs/SketcherPrs_SymbolPrs.h
src/SketcherPrs/SketcherPrs_Tangent.cpp
src/SketcherPrs/SketcherPrs_Tools.cpp
src/SketcherPrs/icons/mirror.png [new file with mode: 0644]

index 3d22b28a7bd9f3891ee04352bf40ea4d475fd6c3..b3332668714bd8b541491bb486fc5854a0b0435a 100644 (file)
@@ -130,12 +130,16 @@ void PartSet_Module::registerValidators()
   //Registering of validators
   SessionPtr aMgr = ModelAPI_Session::get();
   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
-  aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
-  aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
-  aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
-  aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
-  aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
+  aFactory->registerValidator("PartSet_DistanceSelection", new PartSet_DistanceSelection);
+  aFactory->registerValidator("PartSet_LengthSelection", new PartSet_LengthSelection);
+  aFactory->registerValidator("PartSet_PerpendicularSelection", new PartSet_PerpendicularSelection);
+  aFactory->registerValidator("PartSet_ParallelSelection", new PartSet_ParallelSelection);
+  aFactory->registerValidator("PartSet_RadiusSelection", new PartSet_RadiusSelection);
+  aFactory->registerValidator("PartSet_RigidSelection", new PartSet_RigidSelection);
+  aFactory->registerValidator("PartSet_CoincidentSelection", new PartSet_CoincidentSelection);
+  aFactory->registerValidator("PartSet_HVDirSelection", new PartSet_HVDirSelection);
+  aFactory->registerValidator("PartSet_TangentSelection", new PartSet_TangentSelection);
+
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
   aFactory->registerValidator("PartSet_DifferentShapes", new ModelAPI_ShapeValidator);
 
index 04bcb3663fd2587b91666f37598aaf205cc9b04d..2837ba7bff93c2e5e183119e70b0f47e53b05d5d 100644 (file)
@@ -63,31 +63,31 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection)
   return aCount;
 }
 
-bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_DistanceSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
-bool PartSet_LengthValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_LengthSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   int aCount = shapesNbLines(theSelection);
-  return (aCount > 0) && (aCount < 2);
+  return (aCount == 1);
 }
 
-bool PartSet_PerpendicularValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_PerpendicularSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   int aCount = shapesNbLines(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
-bool PartSet_ParallelValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_ParallelSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   int aCount = shapesNbLines(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
-bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
   ModuleBase_ViewerPrs aPrs;
@@ -105,15 +105,63 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection)
       }
     }
   }
-  return (aCount > 0) && (aCount < 2);
+  return (aCount == 1);
 }
 
-bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const
+bool PartSet_RigidSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();  
+  return (aList.count() == 1);
+}
+
+
+bool PartSet_CoincidentSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNbPoints(theSelection);
+  return (aCount > 0) && (aCount < 3);
+}
+
+bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection) const
 {
   int aCount = shapesNbLines(theSelection);
-  return (aCount > 0) && (aCount < 2);
+  return (aCount == 1);
 }
 
+bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+  ModuleBase_ViewerPrs aPrs;
+  if (aList.size() != 2)
+    return false;
+
+  ModuleBase_ViewerPrs aPrs1 = aList.first();
+  ModuleBase_ViewerPrs aPrs2 = aList.last();
+
+  const TopoDS_Shape& aShape1 = aPrs1.shape();
+  const TopoDS_Shape& aShape2 = aPrs2.shape();
+  if (aShape1.IsNull() || aShape2.IsNull())
+    return false;
+
+  if ((aShape1.ShapeType() != TopAbs_EDGE) || (aShape2.ShapeType() != TopAbs_EDGE))
+    return false;
+
+  TopoDS_Edge aEdge1 = TopoDS::Edge(aShape1);
+  TopoDS_Edge aEdge2 = TopoDS::Edge(aShape2);
+
+  Standard_Real aStart, aEnd;
+  Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(aEdge1, aStart, aEnd);
+  Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(aEdge2, aStart, aEnd);
+
+  GeomAdaptor_Curve aAdaptor1(aCurve1);
+  GeomAdaptor_Curve aAdaptor2(aCurve2);
+  if (aAdaptor1.GetType() == GeomAbs_Circle)
+    return aAdaptor2.GetType() == GeomAbs_Line;
+  else if (aAdaptor2.GetType() == GeomAbs_Circle)
+    return aAdaptor1.GetType() == GeomAbs_Line;
+  return false;
+}
+
+
 bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
                                                 const std::list<std::string>& theArguments) const
 {
index 7a7f2333c04bc740469e930e2f939843579a854d..101bba5f90ffd0dff1a7d7e0a51661610015c24e 100644 (file)
@@ -19,7 +19,7 @@
 
 //! \ingroup Validators
 //! A class to validate a selection for Distance constraint operation
-class PartSet_DistanceValidator : public ModuleBase_SelectionValidator
+class PartSet_DistanceSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
@@ -27,7 +27,7 @@ class PartSet_DistanceValidator : public ModuleBase_SelectionValidator
 
 //! \ingroup Validators
 //! A class to validate a selection for Length constraint operation
-class PartSet_LengthValidator : public ModuleBase_SelectionValidator
+class PartSet_LengthSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
@@ -35,36 +35,64 @@ class PartSet_LengthValidator : public ModuleBase_SelectionValidator
 
 //! \ingroup Validators
 //! A class to validate a selection for Perpendicular constraint operation
-class PartSet_PerpendicularValidator : public ModuleBase_SelectionValidator
+class PartSet_PerpendicularSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
 //! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_ParallelValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Parallel constraint operation
+class PartSet_ParallelSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
 //! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_RadiusValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Radius constraint operation
+class PartSet_RadiusSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
 //! \ingroup Validators
-//! A class to validate a selection for Perpendicular constraint operation
-class PartSet_RigidValidator : public ModuleBase_SelectionValidator
+//! A class to validate a selection for Rigid constraint operation
+class PartSet_RigidSelection : public ModuleBase_SelectionValidator
+{
+ public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+
+//! \ingroup Validators
+//! A class to validate a selection for coincedence constraint operation
+class PartSet_CoincidentSelection : public ModuleBase_SelectionValidator
+{
+ public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! \ingroup Validators
+//! A class to validate a selection for Horizontal and Vertical constraints operation
+class PartSet_HVDirSelection : public ModuleBase_SelectionValidator
+{
+ public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+//! \ingroup Validators
+//! A class to validate a selection for Tangential constraints operation
+class PartSet_TangentSelection : public ModuleBase_SelectionValidator
 {
  public:
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+////////////// Attribute validators ////////////////
+
+
 /**
 * \ingroup Validators
 * A validator which checks that objects selected for feature attributes are different (not the same)
index 62cefad4869b312719b4c8aa186014b9af079174..b37f9e71a15296dd4da7597fd00aa8dc52b30285 100644 (file)
@@ -36,5 +36,6 @@
      <file>icons/tangent.png</file>
      <file>icons/fillet.png</file>
      <file>icons/coincedence.png</file>
+     <file>icons/mirror.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/mirror.png b/src/PartSet/icons/mirror.png
new file mode 100644 (file)
index 0000000..1c12a71
Binary files /dev/null and b/src/PartSet/icons/mirror.png differ
index fd765dec9fb452fbc9e13b89f07a32b7e43fe460..f28a09516757ff59a05cbe8966e34693cfeb4fd4 100644 (file)
@@ -187,7 +187,9 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou
     return thePrevious;
 
   AISObjectPtr anAIS = thePrevious;
-  /// TODO: Equal constraint presentation should be put here
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::mirrorConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
index 62dd358f1a6773a4805624fef2de8d5c22f549f7..323120ce97e118b7ba7a2a910aaef4489415b097 100644 (file)
@@ -71,7 +71,7 @@
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
         
-        <validator id="PartSet_DistanceValidator"/>
+        <validator id="PartSet_DistanceSelection"/>
       </feature>
       
     <!--  SketchConstraintLength  -->      
@@ -85,7 +85,7 @@
         <doublevalue_editor label="Value" tooltip="Length" id="ConstraintValue" default="computed">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
-        <validator id="PartSet_LengthValidator"/>
+        <validator id="PartSet_LengthSelection"/>
       </feature>
       
     <!--  SketchConstraintRadius  -->
@@ -97,7 +97,7 @@
         </shape_selector>
         <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt"  default="computed" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Radius" id="ConstraintValue" default="computed"/>
-        <validator id="PartSet_RadiusValidator"/>
+        <validator id="PartSet_RadiusSelection"/>
       </feature>
       
     <!--  SketchConstraintParallel  -->
             <validator id="PartSet_DifferentObjects"/>
             <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
         </sketch_constraint_shape_selector>
-        <validator id="PartSet_ParallelValidator"/>
+        <validator id="PartSet_ParallelSelection"/>
       </feature>
       
     <!--  SketchConstraintPerpendicular  -->
           <validator id="SketchPlugin_ExternalValidator" parameters="ConstraintEntityA"/>
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
-        <validator id="PartSet_PerpendicularValidator"/>
+        <validator id="PartSet_PerpendicularSelection"/>
       </feature>
 
       <!--  SketchConstraintCoincedence  -->
         <sketch_shape_selector id="ConstraintEntityB" label="Second point" tooltip="Select a second point" shape_types="vertex">
           <validator id="PartSet_DifferentObjects"/>
         </sketch_shape_selector>
+        <validator id="PartSet_CoincidentSelection"/>
       </feature>
 
       <!--  SketchConstraintRigid  -->
           <validator id="PartSet_SketchEntityValidator" parameters="SketchPoint,SketchLine,SketchCircle,SketchArc"/>
           <validator id="SketchPlugin_NotFixed"/>
         </shape_selector>
-        <validator id="PartSet_RigidValidator"/>
+        <validator id="PartSet_RigidSelection"/>
       </feature>
       
     <!--  SketchConstraintHorizontal  -->
             label="Line" tooltip="Select a line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
+        <validator id="PartSet_HVDirSelection"/>
       </feature>
       
     <!--  SketchConstraintVertical  -->
             label="Line" tooltip="Select a line" shape_types="edge">
             <validator id="GeomValidators_Edge" parameters="line"/>
         </sketch_constraint_shape_selector>
+        <validator id="PartSet_HVDirSelection"/>
       </feature>
       
     <!--  SketchConstraintEqual  -->
         <validator id="SketchPlugin_TangentAttr" parameters="ConstraintEntityA"/>
         <validator id="PartSet_DifferentObjects"/>
         </sketch_constraint_shape_selector>
+        <validator id="PartSet_TangentSelection"/>
       </feature>
       
     <!--  SketchConstraintMirror  -->
       <feature
         id="SketchConstraintMirror"
-        title="Mirror"
+        title="Mirror" icon=":icons/mirror.png"
         tooltip="Create constraint, mirroring group of objects">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="Mirror line" tooltip="Select mirror line" shape_types="edge">
index be597690dc06f4a92d56770896d94c5823ea341b..963c7e54244d171e682de90299662e95c52283bf 100644 (file)
@@ -16,6 +16,7 @@ SET(PROJECT_HEADERS
        SketcherPrs_SensitivePoint.h
        SketcherPrs_Radius.h
        SketcherPrs_LengthDimension.h
+       SketcherPrs_Mirror.h
 )
 
 SET(PROJECT_SOURCES
@@ -33,6 +34,7 @@ SET(PROJECT_SOURCES
        SketcherPrs_SensitivePoint.cpp
        SketcherPrs_Radius.cpp
        SketcherPrs_LengthDimension.cpp
+       SketcherPrs_Mirror.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -62,6 +64,7 @@ SET(PROJECT_PICTURES
        icons/vertical.png
        icons/equal.png
        icons/tangent.png
+       icons/mirror.png
 )
 
 ADD_DEFINITIONS(-DSKETCHERPRS_EXPORTS ${CAS_DEFINITIONS})
index f26682c3cae4603bccf4c216fc3f7c54691fc9a7..90f705fd8512e2c9692145ef1d20c0a7e1c36e1d 100644 (file)
@@ -52,7 +52,16 @@ void SketcherPrs_Equal::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan
   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
   aGroup->SetPrimitivesAspect(aLineAspect);
 
-  addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
-  addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
+  ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getShape(aObj);
+  if (aLine.get() == NULL)
+    return;
+  drawShape(aLine, thePrs);
+
+  aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  aLine = SketcherPrs_Tools::getShape(aObj);
+  if (aLine.get() == NULL)
+    return;
+  drawShape(aLine, thePrs);
 }
 
index 7ef2368621dbf5a651055fc64e24a71af6b2fb83..39ce4d6e0ce01385eba019c200cec8431ea4c742 100644 (file)
@@ -15,6 +15,7 @@
 #include "SketcherPrs_Tangent.h"
 #include "SketcherPrs_Radius.h"
 #include "SketcherPrs_LengthDimension.h"
+#include "SketcherPrs_Mirror.h"
 
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(ModelAPI_Feature* theConstraint, \
@@ -34,6 +35,7 @@ CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
 CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
 CONSTRAINT_PRS_IMPL(radiusConstraint, SketcherPrs_Radius);
 CONSTRAINT_PRS_IMPL(lengthDimensionConstraint, SketcherPrs_LengthDimension);
+CONSTRAINT_PRS_IMPL(mirrorConstraint, SketcherPrs_Mirror);
 
 
 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(ModelAPI_Feature* theConstraint,
index c43fb948fed15389e49ed56601f858331dbdb61b..9b627b940650c0d30720e5c5b2a7e807621a43a8 100644 (file)
@@ -74,6 +74,11 @@ public:
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(lengthDimensionConstraint)
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(mirrorConstraint)
 };
 
 #endif
diff --git a/src/SketcherPrs/SketcherPrs_Mirror.cpp b/src/SketcherPrs/SketcherPrs_Mirror.cpp
new file mode 100644 (file)
index 0000000..2c05d22
--- /dev/null
@@ -0,0 +1,109 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Mirror.cpp
+// Created:     6 April 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Mirror.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_Mirror, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+}  
+
+
+bool SketcherPrs_Mirror::updatePoints(double theStep) const
+{
+  ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL)
+    return false;
+
+  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;
+  std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
+  if (anAttrC.get() == NULL)
+    return false;
+
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  int aNb = anAttrB->size();
+  if (aNb != anAttrC->size())
+    return false;
+
+  myPntArray = new Graphic3d_ArrayOfPoints(2 * aNb);
+  int i;
+  ObjectPtr aObj;
+  gp_Pnt aP1;
+  for (i = 0; i < aNb; i++) {
+    aObj = anAttrB->object(i);
+    aP1 = aMgr->getPosition(aObj, this, theStep);
+    myPntArray->SetVertice(i + 1, aP1);
+  }  
+  for (i = 0; i < aNb; i++) {
+    aObj = anAttrC->object(i);
+    aP1 = aMgr->getPosition(aObj, this, theStep);
+    myPntArray->SetVertice(aNb + i + 1, aP1);
+  }  
+  return true;
+}
+
+
+void SketcherPrs_Mirror::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;
+  std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
+  if (anAttrC.get() == NULL)
+    return;
+
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  int aNb = anAttrB->size();
+  if (aNb != anAttrC->size())
+    return;
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+  Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+  aGroup->SetPrimitivesAspect(aLineAspect);
+
+  // Draw axis line
+  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);
+  }
+  // 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);
+  }
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Mirror.h b/src/SketcherPrs/SketcherPrs_Mirror.h
new file mode 100644 (file)
index 0000000..69e9494
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Mirror.h
+// Created:     6 April 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Mirror_H
+#define SketcherPrs_Mirror_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of mirror constraint
+*/
+class SketcherPrs_Mirror: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Mirror(ModelAPI_Feature* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+  DEFINE_STANDARD_RTTI(SketcherPrs_Mirror)
+protected:
+  virtual const char* iconName() const { return "mirror.png"; }
+
+  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;
+};
+
+#endif
\ No newline at end of file
index 2a7245e1dfc809d1f91407c2a691f97d4153d632..73963b7fed11d3dce7c4356effe22da7981756d3 100644 (file)
@@ -66,25 +66,11 @@ void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quan
     return;
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
-  if (aShape->isEdge()) {
-    Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
-    aGroup->SetPrimitivesAspect(aLineAspect);
-    std::shared_ptr<GeomAPI_Curve> aCurve = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
-    if (aCurve->isLine()) {
-      addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
-    } else {
-      GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
-      StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
-    }
-  } else {
-    // This is a point
-    Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
-    myDrawer->SetPointAspect(aPntAspect);
-
-    std::shared_ptr<GeomAPI_Vertex> aVertex = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aShape));
-    std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
-    Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
-    StdPrs_Point::Add(thePrs, aPoint, myDrawer);
-  }
+  Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
+  aGroup->SetPrimitivesAspect(aLineAspect);
+
+  Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
+  myDrawer->SetPointAspect(aPntAspect);
+  drawShape(aShape, thePrs);
 }
 
index 20fc780a705d564a603b0e8dde375b97e2975123..b4e646709886c7f327bb81be9f1a16afe0d7c578 100644 (file)
@@ -9,6 +9,8 @@
 #include "SketcherPrs_PositionMgr.h"
 
 #include <GeomAPI_Edge.h>
+#include <GeomAPI_Vertex.h>
+#include <GeomAPI_Curve.h>
 
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_BndBox4f.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <V3d_Viewer.hxx>
 #include <Prs3d_Root.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <StdPrs_DeflectionCurve.hxx>
+#include <StdPrs_Point.hxx>
+#include <StdPrs_Curve.hxx>
 
 #include <OpenGl_Element.hxx>
 #include <OpenGl_GraphicDriver.hxx>
@@ -437,3 +444,24 @@ void SketcherPrs_SymbolPrs::Release (OpenGl_Context* theContext)
   }
 }
 
+void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape, 
+                                      const Handle(Prs3d_Presentation)& thePrs) const
+{
+  if (theShape->isEdge()) {
+    std::shared_ptr<GeomAPI_Curve> aCurve = 
+      std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(theShape));
+    if (aCurve->isLine()) {
+      GeomAdaptor_Curve aCurv(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
+      StdPrs_Curve::Add(thePrs, aCurv, myDrawer);
+    } else {
+      GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
+      StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
+    }
+  } else if (theShape->isVertex()) {
+    std::shared_ptr<GeomAPI_Vertex> aVertex = 
+      std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(theShape));
+    std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
+    Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
+    StdPrs_Point::Add(thePrs, aPoint, myDrawer);
+  }
+}
index 446cedabcd6fb9ad28a0d6c11bf2dadae315579b..91b2323ac5e74f7dfcfd1c8696f625877c69ca9e 100644 (file)
@@ -103,6 +103,10 @@ protected:
   /// \return true in case of success
   virtual bool updatePoints(double theStep) const { return true; }
 
+  void drawShape(const std::shared_ptr<GeomAPI_Shape>& theShape, 
+    const Handle(Prs3d_Presentation)& thePrs) const;
+
+
 protected:
   /// Constraint feature
   ModelAPI_Feature* myConstraint;
index 45f32049425091c54120cc4d9426ca5457d3d15e..199eb782f8161ff7123909e695805e648292752e 100644 (file)
@@ -64,23 +64,7 @@ void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs, Qu
 
   if ((aShape1.get() == NULL) || (aShape2.get() == NULL))
     return;
-
-  std::shared_ptr<GeomAPI_Curve> aCurve1 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape1));
-  std::shared_ptr<GeomAPI_Curve> aCurve2 = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape2));
-  if (aCurve1->isCircle() && aCurve2->isLine()) {
-    addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());
-    GeomAdaptor_Curve aAdaptor(aCurve1->impl<Handle(Geom_Curve)>(), aCurve1->startParam(), aCurve1->endParam());
-    StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
-  } else if (aCurve1->isLine() && aCurve2->isCircle()) {
-    addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
-    GeomAdaptor_Curve aAdaptor(aCurve2->impl<Handle(Geom_Curve)>(), aCurve2->startParam(), aCurve2->endParam());
-    StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
-  } else {
-    // Both curves are arcs
-    GeomAdaptor_Curve aAdaptor1(aCurve1->impl<Handle(Geom_Curve)>(), aCurve1->startParam(), aCurve1->endParam());
-    StdPrs_DeflectionCurve::Add(thePrs, aAdaptor1, myDrawer);
-    GeomAdaptor_Curve aAdaptor2(aCurve2->impl<Handle(Geom_Curve)>(), aCurve2->startParam(), aCurve2->endParam());
-    StdPrs_DeflectionCurve::Add(thePrs, aAdaptor2, myDrawer);
-  }
+  drawShape(aShape1, thePrs);
+  drawShape(aShape2, thePrs);
 }
 
index 47468899ec7d2d7685b561f1277707b93d5c7bd8..8c28de0b09ff9888dff66e7313c3a7f637fa6a6d 100644 (file)
@@ -23,9 +23,7 @@ namespace SketcherPrs_Tools {
 ObjectPtr getResult(ModelAPI_Feature* theFeature, const std::string& theAttrName)
 {
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttrName));
-
+  std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = aData->refattr(theAttrName);
   return anAttr->object();
 }
 
diff --git a/src/SketcherPrs/icons/mirror.png b/src/SketcherPrs/icons/mirror.png
new file mode 100644 (file)
index 0000000..3197cf3
Binary files /dev/null and b/src/SketcherPrs/icons/mirror.png differ