]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Create tangent constraint presentation
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Mar 2015 14:36:59 +0000 (17:36 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Mar 2015 14:36:59 +0000 (17:36 +0300)
16 files changed:
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/tangent.png [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintTangent.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_HVDirection.cpp
src/SketcherPrs/SketcherPrs_Parallel.cpp
src/SketcherPrs/SketcherPrs_Perpendicular.cpp
src/SketcherPrs/SketcherPrs_Rigid.cpp
src/SketcherPrs/SketcherPrs_Tangent.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Tangent.h [new file with mode: 0644]
src/SketcherPrs/icons/tangent.png [new file with mode: 0644]

index 9567abc7c3667719690f4566353f38574eb4495d..64b07a1ee6a41ec3883f8d2374c74b07bbba022c 100644 (file)
@@ -51,6 +51,7 @@
 #include <SketchPlugin_ConstraintHorizontal.h>
 #include <SketchPlugin_ConstraintVertical.h>
 #include <SketchPlugin_ConstraintEqual.h>
+#include <SketchPlugin_ConstraintTangent.h>
 
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
@@ -584,6 +585,7 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList()
     aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
     aIds << SketchPlugin_ConstraintVertical::ID().c_str();
     aIds << SketchPlugin_ConstraintEqual::ID().c_str();
+    aIds << SketchPlugin_ConstraintTangent::ID().c_str();
   }
   return aIds;
 }
index f54b2c80cc0cb42a6eab919d65166d14dff67f39..90415fe296ee170dee7be2e535db85e569d65986 100644 (file)
@@ -33,5 +33,6 @@
      <file>icons/horisontal.png</file>
      <file>icons/vertical.png</file>
      <file>icons/equal.png</file>
+     <file>icons/tangent.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/tangent.png b/src/PartSet/icons/tangent.png
new file mode 100644 (file)
index 0000000..9cc2c73
Binary files /dev/null and b/src/PartSet/icons/tangent.png differ
index f2cf4a30717bd55cb221c21ff3e52791d31913b8..c979d8939ac74d1a45dbe903ad7a75761fa5557d 100644 (file)
@@ -37,7 +37,9 @@ AISObjectPtr SketchPlugin_ConstraintTangent::getAISObject(AISObjectPtr thePrevio
     return thePrevious;
 
   AISObjectPtr anAIS = thePrevious;
-  /// TODO: Tangency constraint presentation should be put here
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::tangentConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
index 55afbd01e7d9939cdcff3020c09f7259583d6140..3bbfbfead5ede7681d3377d7523da86fe28b7454 100644 (file)
         </sketch_constraint_shape_selector>
       </feature>
     <!--  SketchConstraintTangent  -->
-      <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects">
+      <feature id="SketchConstraintTangent" title="Tangent" tooltip="Create constraint defining tangency of two objects" icon=":icons/tangent.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line or arc" shape_types="edge">
         </sketch_constraint_shape_selector>
index 5c7f7b34ced1dfa9b5a919e7160956964b1817f6..5fe8b8437c12587826fa5990fada21a98b4d95e7 100644 (file)
@@ -12,6 +12,7 @@ SET(PROJECT_HEADERS
        SketcherPrs_Rigid.h
        SketcherPrs_HVDirection.h
        SketcherPrs_Equal.h
+       SketcherPrs_Tangent.h
 )
 
 SET(PROJECT_SOURCES
@@ -25,6 +26,7 @@ SET(PROJECT_SOURCES
        SketcherPrs_Rigid.cpp
        SketcherPrs_HVDirection.cpp
        SketcherPrs_Equal.cpp
+       SketcherPrs_Tangent.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -45,6 +47,7 @@ SET(PROJECT_PICTURES
        icons/horisontal.png
        icons/vertical.png
        icons/equal.png
+       icons/tangent.png
 )
 
 ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
index 9dd35cfe5daecb35f4fd64e08975654b4cb4ecd6..e14da56f39e506645ff77e762f3686951c6e7240 100644 (file)
@@ -32,9 +32,6 @@
 #include <SelectMgr_EntityOwner.hxx>
 
 
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
-                                                      const std::string& theAttribute);
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Equal, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Equal, SketcherPrs_SymbolPrs);
index 639a557f54e780c45ef2a65901905536ab5574ae..b46070694c1d2fd4db6e1df60880768f2e089b23 100644 (file)
@@ -12,6 +12,7 @@
 #include "SketcherPrs_Rigid.h"
 #include "SketcherPrs_HVDirection.h"
 #include "SketcherPrs_Equal.h"
+#include "SketcherPrs_Tangent.h"
 
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
@@ -28,6 +29,7 @@ CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
 CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
+CONSTRAINT_PRS_IMPL(tangentConstraint, SketcherPrs_Tangent);
 
 
 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
index 9de1038a8f440a09aa02d77f3a17eabd9e07798c..1d3f7335d66145c103603ffdf02b106e94f293f4 100644 (file)
@@ -59,6 +59,11 @@ public:
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(equalConstraint)
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(tangentConstraint)
 };
 
 #endif
index 13b3def6ed7db543ecdbc8f6a1c9c6037ef07799..fe083121141a26dd8580267a72999f7b064d1f7d 100644 (file)
@@ -32,9 +32,6 @@
 #include <SelectMgr_EntityOwner.hxx>
 
 
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
-                                                      const std::string& theAttribute);
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
index b3bd0ffa96f68b0c6069a0c2bef14e338d1a3fb3..2736ee169181951f82e156d8c9fd211214cf5e5e 100644 (file)
@@ -32,9 +32,6 @@
 #include <SelectMgr_EntityOwner.hxx>
 
 
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
-                                                      const std::string& theAttribute);
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Parallel, SketcherPrs_SymbolPrs);
index 303daffeb4ca3a487541f26c674f8832d75e9a93..5158b932d181f143033f7f5ca29fbe9195019261 100644 (file)
 #include <Graphic3d_ArrayOfSegments.hxx>
 
 
-// Function which is defined in SketchPlugin_ConstraintDistance.cpp
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
-                                                      const std::string& theAttribute);
-
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
index c436e586acb5e8add2cb989cebcde831197ea507..34c02875139054996100edcf9aaf381b7ea7791f 100644 (file)
@@ -41,9 +41,6 @@
 #include <Geom_CartesianPoint.hxx>
 
 
-extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
-                                                      const std::string& theAttribute);
-
 
 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp
new file mode 100644 (file)
index 0000000..4d13a65
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Tangent.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Tangent.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <GeomAPI_Pnt.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <AIS_Drawer.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#include <Graphic3d_MarkerImage.hxx>
+#include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+
+#include <Select3D_SensitivePoint.hxx>
+#include <Select3D_SensitiveSegment.hxx>
+
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Tangent::SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane)
+{
+  myPntArray = new Graphic3d_ArrayOfPoints(2);
+  myPntArray->AddVertex(0., 0., 0.);
+  myPntArray->AddVertex(0., 0., 0.);
+}  
+
+void SketcherPrs_Tangent::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  prepareAspect();
+
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getShape(aObj1);
+  if (aLine1.get() == NULL)
+    return;
+
+  std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getShape(aObj2);
+  if (aLine2.get() == NULL)
+    return;
+  
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+  gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+  aGroup->SetPrimitivesAspect(myAspect);
+  myPntArray->SetVertice(1, aP1);
+  myPntArray->SetVertice(2, aP2);
+  aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_Tangent::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
+{
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
+
+  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());
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Tangent.h b/src/SketcherPrs/SketcherPrs_Tangent.h
new file mode 100644 (file)
index 0000000..e1faefe
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Tangent.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Tangent_H
+#define SketcherPrs_Tangent_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Tangent, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of tangent constraint
+*/
+class SketcherPrs_Tangent: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Tangent(SketchPlugin_Constraint* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+  DEFINE_STANDARD_RTTI(SketcherPrs_Tangent)
+protected:
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+    const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+  virtual const char* iconName() const { return "tangent.png"; }
+
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/tangent.png b/src/SketcherPrs/icons/tangent.png
new file mode 100644 (file)
index 0000000..d4d8cd7
Binary files /dev/null and b/src/SketcherPrs/icons/tangent.png differ