Salome HOME
Horisontal and vertical constraints added
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 15:32:36 +0000 (18:32 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 16 Mar 2015 15:32:36 +0000 (18:32 +0300)
15 files changed:
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/horisontal.png [new file with mode: 0644]
src/PartSet/icons/vertical.png [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_ConstraintHorizontal.cpp
src/SketchPlugin/SketchPlugin_ConstraintVertical.cpp
src/SketchPlugin/plugin-Sketch.xml
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_Factory.cpp
src/SketcherPrs/SketcherPrs_Factory.h
src/SketcherPrs/SketcherPrs_HVDirection.cpp [new file with mode: 0644]
src/SketcherPrs/SketcherPrs_HVDirection.h [new file with mode: 0644]
src/SketcherPrs/icons/horisontal.png [new file with mode: 0644]
src/SketcherPrs/icons/vertical.png [new file with mode: 0644]

index ebc5db7324ace9de80c416d0630dfa7cdd8fa9d5..cb62b8797e4bb8cf8fc57af15810e506f12fa78e 100644 (file)
@@ -419,8 +419,8 @@ void PartSet_Module::onOperationActivatedByPreselection()
 void PartSet_Module::onNoMoreWidgets()
 {
   ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
-    if (anOperation) {
+  if (anOperation) {
+    if (PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) {
       if (myRestartingMode != RM_Forbided)
         myRestartingMode = RM_LastFeatureUsed;
       anOperation->commit();
index b55c62ad1eb5c63f1ef43177af02c643d176db02..9567abc7c3667719690f4566353f38574eb4495d 100644 (file)
@@ -48,6 +48,9 @@
 #include <SketchPlugin_ConstraintPerpendicular.h>
 #include <SketchPlugin_ConstraintRadius.h>
 #include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_ConstraintHorizontal.h>
+#include <SketchPlugin_ConstraintVertical.h>
+#include <SketchPlugin_ConstraintEqual.h>
 
 #include <SelectMgr_IndexedMapOfOwner.hxx>
 #include <StdSelect_BRepOwner.hxx>
@@ -578,6 +581,9 @@ QStringList PartSet_SketcherMgr::sketchOperationIdList()
     aIds << SketchPlugin_ConstraintRadius::ID().c_str();
     aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
     aIds << SketchPlugin_ConstraintParallel::ID().c_str();
+    aIds << SketchPlugin_ConstraintHorizontal::ID().c_str();
+    aIds << SketchPlugin_ConstraintVertical::ID().c_str();
+    aIds << SketchPlugin_ConstraintEqual::ID().c_str();
   }
   return aIds;
 }
index d580c0de6a89753e55cecf9f5d1dd217bab46a1b..1b30b61e38ac269bb587051aaf49371a9dc42549 100644 (file)
@@ -30,5 +30,7 @@
      <file>icons/fixed.png</file>
      <file>icons/placement.png</file>
      <file>icons/geom_export.png</file>
+     <file>icons/horisontal.png</file>
+     <file>icons/vertical.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/horisontal.png b/src/PartSet/icons/horisontal.png
new file mode 100644 (file)
index 0000000..a762149
Binary files /dev/null and b/src/PartSet/icons/horisontal.png differ
diff --git a/src/PartSet/icons/vertical.png b/src/PartSet/icons/vertical.png
new file mode 100644 (file)
index 0000000..a09de04
Binary files /dev/null and b/src/PartSet/icons/vertical.png differ
index 722ea659a0f96a54bae1f5e9d0fb01b0487e8b39..175715d28afd30f5f4a3694d6aa942753a81895c 100644 (file)
@@ -36,7 +36,9 @@ AISObjectPtr SketchPlugin_ConstraintHorizontal::getAISObject(AISObjectPtr thePre
     return thePrevious;
 
   AISObjectPtr anAIS = thePrevious;
-  /// TODO: Horizontal constraint presentation should be put here
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::horisontalConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
index ecfc9177612f6f941b1ad4a98e219fea06a42c82..bb824715ad5b91f22e6b7ac696cbdfbafd725f2c 100644 (file)
@@ -36,7 +36,9 @@ AISObjectPtr SketchPlugin_ConstraintVertical::getAISObject(AISObjectPtr thePrevi
     return thePrevious;
 
   AISObjectPtr anAIS = thePrevious;
-  /// TODO: Horizontal constraint presentation should be put here
+  if (!anAIS) {
+    anAIS = SketcherPrs_Factory::verticalConstraint(this, sketch()->coordinatePlane());
+  }
   return anAIS;
 }
 
index 06167aa91dc42af558e6a9963f2938e2a3bd9730..b33c14891f2aabc453efe2ad1ed8e58016beafe4 100644 (file)
         <validator id="PartSet_RigidValidator"/>
       </feature>
     <!--  SketchConstraintHorizontal  -->
-      <feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line">
+      <feature id="SketchConstraintHorizontal" title="Horizontal" tooltip="Create constraint defining horizontal line" icon=":icons/horisontal.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="Line" tooltip="Select a line" shape_types="edge">
             <selection_filter id="EdgeFilter" parameters="line"/>
         </sketch_constraint_shape_selector>
       </feature>
     <!--  SketchConstraintVertical  -->
-      <feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line">
+      <feature id="SketchConstraintVertical" title="Vertical" tooltip="Create constraint defining vertical line" icon=":icons/vertical.png">
         <sketch_constraint_shape_selector id="ConstraintEntityA" 
             label="Line" tooltip="Select a line" shape_types="edge">
             <selection_filter id="EdgeFilter" parameters="line"/>
index c2ed12fda0a75d63971b6d86c8595a0c6b1010c6..b2061ca13fcee16998a1493ddb8c45fd08fc1629 100644 (file)
@@ -10,6 +10,7 @@ SET(PROJECT_HEADERS
     SketcherPrs_SymbolPrs.h
        SketcherPrs_PositionMgr.h
        SketcherPrs_Rigid.h
+       SketcherPrs_HVDirection.h
 )
 
 SET(PROJECT_SOURCES
@@ -21,6 +22,7 @@ SET(PROJECT_SOURCES
     SketcherPrs_SymbolPrs.cpp
        SketcherPrs_PositionMgr.cpp
        SketcherPrs_Rigid.cpp
+       SketcherPrs_HVDirection.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -38,6 +40,8 @@ SET(PROJECT_PICTURES
     icons/parallel.png
     icons/perpendicular.png
        icons/anchor.png
+       icons/horisontal.png
+       icons/vertical.png
 )
 
 ADD_DEFINITIONS(-DCONSTRAINTS_EXPORTS ${CAS_DEFINITIONS})
index 8898569c3ca419595ed1fdf7d5e20cb4849c65d7..95c79fc44832e24e492fecde5c706131bc7be9b2 100644 (file)
@@ -10,6 +10,7 @@
 #include <SketcherPrs_Parallel.h>
 #include <SketcherPrs_Perpendicular.h>
 #include <SketcherPrs_Rigid.h>
+#include <SketcherPrs_HVDirection.h>
 
 #define CONSTRAINT_PRS_IMPL(NAME, CLASS) \
 AISObjectPtr SketcherPrs_Factory::NAME(SketchPlugin_Constraint* theConstraint, \
@@ -25,3 +26,22 @@ CONSTRAINT_PRS_IMPL(coincidentConstraint, SketcherPrs_Coincident);
 CONSTRAINT_PRS_IMPL(parallelConstraint, SketcherPrs_Parallel);
 CONSTRAINT_PRS_IMPL(perpendicularConstraint, SketcherPrs_Perpendicular);
 CONSTRAINT_PRS_IMPL(rigidConstraint, SketcherPrs_Rigid)
+
+
+AISObjectPtr SketcherPrs_Factory::horisontalConstraint(SketchPlugin_Constraint* theConstraint,
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{ 
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
+  Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, true); 
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
+  return aAISObj; 
+}
+
+AISObjectPtr SketcherPrs_Factory::verticalConstraint(SketchPlugin_Constraint* theConstraint,
+                                       const std::shared_ptr<GeomAPI_Ax3>& thePlane)
+{ 
+  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject()); 
+  Handle(SketcherPrs_HVDirection) aPrs = new SketcherPrs_HVDirection(theConstraint, thePlane, false); 
+  aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aPrs)); 
+  return aAISObj; 
+}
index a76b5a28531b2b0e0eabeda164f084b1ee452e12..14a8f5e2ad895a26c0cea86bcfac850f1f7d31ab 100644 (file)
@@ -44,6 +44,16 @@ public:
   /// \param theConstraint the constraint
   /// \param thePlane the current sketch plane
   GET_CONSTRAINT_PRS(rigidConstraint)
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(horisontalConstraint)
+
+  /// Creates coincedent perpendicular presentation
+  /// \param theConstraint the constraint
+  /// \param thePlane the current sketch plane
+  GET_CONSTRAINT_PRS(verticalConstraint)
 };
 
 #endif
diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.cpp b/src/SketcherPrs/SketcherPrs_HVDirection.cpp
new file mode 100644 (file)
index 0000000..0ad7c1f
--- /dev/null
@@ -0,0 +1,82 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_HVDirection.cpp
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "SketcherPrs_HVDirection.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_HVDirection, SketcherPrs_SymbolPrs);
+IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs);
+
+static Handle(Image_AlienPixMap) MyPixMap;
+
+SketcherPrs_HVDirection::SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint, 
+                                           const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+                                           bool isHorisontal) 
+ : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsHorisontal(isHorisontal)
+{
+  myPntArray = new Graphic3d_ArrayOfPoints(1);
+  myPntArray->AddVertex(0., 0., 0.);
+}  
+
+void SketcherPrs_HVDirection::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());
+  std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(aObj1);
+  if (aLine1.get() == NULL)
+    return;
+
+  SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
+  gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
+  aGroup->SetPrimitivesAspect(myAspect);
+  myPntArray->SetVertice(1, aP1);
+  aGroup->AddPrimitiveArray(myPntArray);
+}
+
+void SketcherPrs_HVDirection::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());
+}
+
diff --git a/src/SketcherPrs/SketcherPrs_HVDirection.h b/src/SketcherPrs/SketcherPrs_HVDirection.h
new file mode 100644 (file)
index 0000000..84e993b
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        SketcherPrs_HVDirection.h
+// Created:     16 February 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef SketcherPrs_HVDirection_H
+#define SketcherPrs_HVDirection_H
+
+#include "SketcherPrs_SymbolPrs.h"
+
+class SketchPlugin_Constraint;
+class SketchPlugin_Sketch;
+
+
+DEFINE_STANDARD_HANDLE(SketcherPrs_HVDirection, SketcherPrs_SymbolPrs)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide  
+* presentation of parallel constraint
+*/
+class SketcherPrs_HVDirection: public SketcherPrs_SymbolPrs
+{
+public:
+  /// Constructor
+  /// \param theConstraint a constraint feature
+  /// \param thePlane a coordinate plane of current sketch
+  Standard_EXPORT SketcherPrs_HVDirection(SketchPlugin_Constraint* theConstraint, 
+                                         const std::shared_ptr<GeomAPI_Ax3>& thePlane,
+                                         bool isHorisontal);
+
+  DEFINE_STANDARD_RTTI(SketcherPrs_HVDirection)
+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 myIsHorisontal? "horisontal.png" : "vertical.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;
+
+private:
+  bool myIsHorisontal;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/SketcherPrs/icons/horisontal.png b/src/SketcherPrs/icons/horisontal.png
new file mode 100644 (file)
index 0000000..ad67bb2
Binary files /dev/null and b/src/SketcherPrs/icons/horisontal.png differ
diff --git a/src/SketcherPrs/icons/vertical.png b/src/SketcherPrs/icons/vertical.png
new file mode 100644 (file)
index 0000000..68f8033
Binary files /dev/null and b/src/SketcherPrs/icons/vertical.png differ