]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1315 Middle point constraint problem: classes creation
authornds <nds@opencascade.com>
Mon, 29 Feb 2016 06:04:27 +0000 (09:04 +0300)
committernds <nds@opencascade.com>
Mon, 29 Feb 2016 12:43:56 +0000 (15:43 +0300)
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Collinear.cpp [new file with mode: 0755]
src/SketcherPrs/SketcherPrs_Collinear.h [new file with mode: 0755]
src/SketcherPrs/SketcherPrs_Middle.cpp [new file with mode: 0755]
src/SketcherPrs/SketcherPrs_Middle.h [new file with mode: 0755]

index e988b9a8471cca312043b4fc33f8f2eade10a34b..221e5a1b3b84d17da22c92586382fdb2ebf73a18 100644 (file)
@@ -8,6 +8,7 @@ FIND_PACKAGE(Freetype REQUIRED)
 SET(PROJECT_HEADERS
     SketcherPrs.h
     SketcherPrs_Coincident.h
+    SketcherPrs_Collinear.h
     SketcherPrs_Factory.h
     SketcherPrs_Parallel.h
     SketcherPrs_Tools.h
@@ -21,6 +22,7 @@ SET(PROJECT_HEADERS
     SketcherPrs_SensitivePoint.h
     SketcherPrs_Radius.h
     SketcherPrs_LengthDimension.h
+    SketcherPrs_Middle.h
     SketcherPrs_Mirror.h
     SketcherPrs_Transformation.h
     SketcherPrs_Angle.h
@@ -28,6 +30,7 @@ SET(PROJECT_HEADERS
 
 SET(PROJECT_SOURCES
     SketcherPrs_Coincident.cpp
+    SketcherPrs_Collinear.cpp
     SketcherPrs_Factory.cpp
     SketcherPrs_Parallel.cpp
     SketcherPrs_Tools.cpp
@@ -41,6 +44,7 @@ SET(PROJECT_SOURCES
     SketcherPrs_SensitivePoint.cpp
     SketcherPrs_Radius.cpp
     SketcherPrs_LengthDimension.cpp
+    SketcherPrs_Middle.cpp
     SketcherPrs_Mirror.cpp
     SketcherPrs_Transformation.cpp
     SketcherPrs_Angle.cpp
diff --git a/src/SketcherPrs/SketcherPrs_Collinear.cpp b/src/SketcherPrs/SketcherPrs_Collinear.cpp
new file mode 100755 (executable)
index 0000000..57cf264
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Collinear.cpp
+// Created:     29 February 2016
+// Author:      Natalia ERMOLAEVA
+
+#include "SketcherPrs_Collinear.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Constraint.h>
+
+#include "Events_Error.h"
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Collinear, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Collinear, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Collinear::SketcherPrs_Collinear(ModelAPI_Feature* 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.);
+}  
+
+bool SketcherPrs_Collinear::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+                                         const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+{
+  bool aReadyToDisplay = false;
+
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
+                    SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+
+  return aReadyToDisplay;
+}
+
+bool SketcherPrs_Collinear::updatePoints(double theStep) const
+{
+  if (!IsReadyToDisplay(myConstraint, myPlane))
+    return false;
+
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  // Set points of the presentation
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
+  gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
+  myPntArray->SetVertice(1, aP1);
+  myPntArray->SetVertice(2, aP2);
+  return true;
+}
+
+void SketcherPrs_Collinear::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);
+
+  // Draw first line
+  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);
+
+  // Draw second line
+  aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  aLine = SketcherPrs_Tools::getShape(aObj);
+  if (aLine.get() == NULL)
+    return;
+  drawShape(aLine, thePrs);
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Collinear.h b/src/SketcherPrs/SketcherPrs_Collinear.h
new file mode 100755 (executable)
index 0000000..e48065c
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Collinear.h
+// Created:     29 February 2016
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SketcherPrs_Collinear_H
+#define SketcherPrs_Collinear_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Collinear, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of Equal constraint
+*/
+class SketcherPrs_Collinear: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Collinear(ModelAPI_Feature* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+  DEFINE_STANDARD_RTTI(SketcherPrs_Collinear)
+
+  /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  /// \return boolean result value
+  static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+protected:
+
+  virtual const char* iconName() const { return "equal.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
diff --git a/src/SketcherPrs/SketcherPrs_Middle.cpp b/src/SketcherPrs/SketcherPrs_Middle.cpp
new file mode 100755 (executable)
index 0000000..a588752
--- /dev/null
@@ -0,0 +1,85 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Middle.cpp
+// Created:     29 February 2016
+// Author:      Natalia ERMOLAEVA
+
+#include "SketcherPrs_Middle.h"
+#include "SketcherPrs_Tools.h"
+#include "SketcherPrs_PositionMgr.h"
+
+#include <SketchPlugin_Constraint.h>
+
+#include "Events_Error.h"
+
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Root.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Middle, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Middle, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_Middle::SketcherPrs_Middle(ModelAPI_Feature* 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.);
+}  
+
+bool SketcherPrs_Middle::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+                                         const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
+{
+  bool aReadyToDisplay = false;
+
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
+                    SketcherPrs_Tools::getShape(aObj2).get() != NULL;
+
+  return aReadyToDisplay;
+}
+
+bool SketcherPrs_Middle::updatePoints(double theStep) const
+{
+  if (!IsReadyToDisplay(myConstraint, myPlane))
+    return false;
+
+  ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
+  ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+
+  // Set points of the presentation
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
+  gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
+  myPntArray->SetVertice(1, aP1);
+  myPntArray->SetVertice(2, aP2);
+  return true;
+}
+
+void SketcherPrs_Middle::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);
+
+  // Draw first line
+  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);
+
+  // Draw second line
+  aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
+  aLine = SketcherPrs_Tools::getShape(aObj);
+  if (aLine.get() == NULL)
+    return;
+  drawShape(aLine, thePrs);
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_Middle.h b/src/SketcherPrs/SketcherPrs_Middle.h
new file mode 100755 (executable)
index 0000000..fb72cec
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_Middle.h
+// Created:     29 February 2016
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SketcherPrs_Middle_H
+#define SketcherPrs_Middle_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_Middle, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of Equal constraint
+*/
+class SketcherPrs_Middle: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_Middle(ModelAPI_Feature* theConstraint, 
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+  DEFINE_STANDARD_RTTI(SketcherPrs_Middle)
+
+  /// Returns true if the constraint feature arguments are correcly filled to build AIS presentation
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  /// \return boolean result value
+  static bool IsReadyToDisplay(ModelAPI_Feature* theConstraint,
+                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
+protected:
+
+  virtual const char* iconName() const { return "equal.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