]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Equal constraint presentation
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Mar 2015 12:58:11 +0000 (15:58 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 17 Mar 2015 12:58:11 +0000 (15:58 +0300)
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/equal.png [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintEqual.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Equal.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Equal.h [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/icons/equal.png [new file with mode: 0644]

index 1b30b61e38ac269bb587051aaf49371a9dc42549..f54b2c80cc0cb42a6eab919d65166d14dff67f39 100644 (file)
@@ -32,5 +32,6 @@
      <file>icons/geom_export.png</file>
      <file>icons/horisontal.png</file>
      <file>icons/vertical.png</file>
+     <file>icons/equal.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/equal.png b/src/PartSet/icons/equal.png
new file mode 100644 (file)
index 0000000..0b446f6
Binary files /dev/null and b/src/PartSet/icons/equal.png differ
index 00531acde1a652ade39dec6a05ea0489dfcc361b..efd034fea2ce18faa18d74b64d1790ef13b68e69 100644 (file)
@@ -37,7 +37,9 @@ AISObjectPtr SketchPlugin_ConstraintEqual::getAISObject(AISObjectPtr thePrevious
     return thePrevious;
 
   AISObjectPtr anAIS = thePrevious;
-  /// TODO: Equal constraint presentation should be put here
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::equalConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
index 8e88037581390215fa6a20e81f37c199c518bb84..55afbd01e7d9939cdcff3020c09f7259583d6140 100644 (file)
         </sketch_constraint_shape_selector>
       </feature>
     <!--  SketchConstraintEqual  -->
-      <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects">
+      <feature id="SketchConstraintEqual" title="Equal" tooltip="Create constraint defining equality of two objects" icon=":icons/equal.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="First object" tooltip="Select line, circle or arc" shape_types="edge">
         </sketch_constraint_shape_selector>
index b2061ca13fcee16998a1493ddb8c45fd08fc1629..5c7f7b34ced1dfa9b5a919e7160956964b1817f6 100644 (file)
@@ -11,6 +11,7 @@ SET(PROJECT_HEADERS
        SketcherPrs_PositionMgr.h
        SketcherPrs_Rigid.h
        SketcherPrs_HVDirection.h
+       SketcherPrs_Equal.h
 )
 
 SET(PROJECT_SOURCES
@@ -23,6 +24,7 @@ SET(PROJECT_SOURCES
        SketcherPrs_PositionMgr.cpp
        SketcherPrs_Rigid.cpp
        SketcherPrs_HVDirection.cpp
+       SketcherPrs_Equal.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -42,6 +44,7 @@ SET(PROJECT_PICTURES
        icons/anchor.png
        icons/horisontal.png
        icons/vertical.png
+       icons/equal.png
 )
 
 ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
diff --git a/src/SketcherPrs/SketcherPrs_Equal.cpp b/src/SketcherPrs/SketcherPrs_Equal.cpp
new file mode 100644 (file)
index 0000000..9dd35cf
--- /dev/null
@@ -0,0 +1,91 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Equal.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_Equal.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>
+
+
+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);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Equal::SketcherPrs_Equal(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_Equal::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_Equal::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_Equal.h b/src/SketcherPrs/SketcherPrs_Equal.h
new file mode 100644 (file)
index 0000000..90beb8c
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Equal.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_Equal_H
+#define SketcherPrs_Equal_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Equal, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of Equal constraint
+*/
+class SketcherPrs_Equal: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Equal(SketchPlugin_Constraint* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+  DEFINE_STANDARD_RTTI(SketcherPrs_Equal)
+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 "equal.png"; }
+
+  virtual void drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const;
+};
+
+#endif
\ No newline at end of file
index 95c79fc44832e24e492fecde5c706131bc7be9b2..639a557f54e780c45ef2a65901905536ab5574ae 100644 (file)
@@ -6,11 +6,12 @@
 
 #include "SketcherPrs_Factory.h"
 
-#include <SketcherPrs_Coincident.h>
-#include <SketcherPrs_Parallel.h>
-#include <SketcherPrs_Perpendicular.h>
-#include <SketcherPrs_Rigid.h>
-#include <SketcherPrs_HVDirection.h>
+#include "SketcherPrs_Coincident.h"
+#include "SketcherPrs_Parallel.h"
+#include "SketcherPrs_Perpendicular.h"
+#include "SketcherPrs_Rigid.h"
+#include "SketcherPrs_HVDirection.h"
+#include "SketcherPrs_Equal.h"
 
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
@@ -25,7 +26,8 @@ AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
 CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
-CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid)
+CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid);
+CONSTRAINT_PRS_IMPL(equalConstraint, SketcherPrs_Equal);
 
 
 AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
index 14a8f5e2ad895a26c0cea86bcfac850f1f7d31ab..9de1038a8f440a09aa02d77f3a17eabd9e07798c 100644 (file)
@@ -54,6 +54,11 @@ public:
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(verticalConstraint)
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(equalConstraint)
 };
 
 #endif
diff --git a/src/SketcherPrs/icons/equal.png b/src/SketcherPrs/icons/equal.png
new file mode 100644 (file)
index 0000000..e3af2c6
Binary files /dev/null and b/src/SketcherPrs/icons/equal.png differ