Salome HOME
Sub-features of sketcher support
authormpv <mikhail.ponikarov@opencascade.com>
Fri, 25 Apr 2014 11:18:07 +0000 (15:18 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Fri, 25 Apr 2014 11:18:07 +0000 (15:18 +0400)
src/GeomAPI/GeomAPI_Dir.h
src/GeomData/CMakeLists.txt
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Dir.h
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index a003d3826bf825ac8398ffd3525b3620f386c95e..7993a3d77d030e3adc6701457e36b686758d2b31 100644 (file)
@@ -24,6 +24,7 @@ public:
   double y() const;
   /// returns Z coordinate
   double z() const;
+
 };
 
 #endif
index 39f76ff1571b7365ecb44e34eeaa89686ee20bdd..de9142621337e532d65139719aba0ca8c14e02f0 100644 (file)
@@ -16,11 +16,12 @@ SET(PROJECT_SOURCES
 
 ADD_DEFINITIONS(-DGEOMDATA_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS})
 ADD_LIBRARY(GeomData SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(GeomData ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI)
+TARGET_LINK_LIBRARIES(GeomData ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI GeomAPI)
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomDataAPI
+  ../GeomAPI
   ../Events
   ../Config
   ${CAS_INCLUDE_DIRS}
index dc2ca123d2820ceb3721b73a834be66c9bc8f6fa..22dac3fe4df1cb7c186986feeb655bfda658bd1a 100644 (file)
@@ -3,6 +3,8 @@
 // Author:      Mikhail PONIKAROV
 
 #include "GeomData_Dir.h"
+#include "GeomAPI_Dir.h"
+#include <gp_Dir.hxx>
 
 using namespace std;
 
@@ -28,6 +30,12 @@ double GeomData_Dir::z() const
   return myCoords->Value(2);
 }
 
+boost::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
+{
+  return boost::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(
+    myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+}
+
 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
 {
   // check the attribute could be already presented in this doc (after load document)
index 554fd04c4f1bc4659d23d43cc1448a373ce01867..56a8b9d2ac80db8fac7a821493c9332bc7ddd1e1 100644 (file)
@@ -9,6 +9,9 @@
 #include "GeomDataAPI_Dir.h"
 #include <TDataStd_RealArray.hxx>
 #include <TDF_Label.hxx>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Dir;
 
 /**\class GeomData_Dir
  * \ingroup DataModel
@@ -27,6 +30,8 @@ public:
   GEOMDATA_EXPORT virtual double y() const;
   /// Returns the Z double value
   GEOMDATA_EXPORT virtual double z() const;
+  /// Returns the direction of this attribute
+  GEOMDATA_EXPORT boost::shared_ptr<GeomAPI_Dir> dir();
 
 protected:
   /// Initializes attributes
index 26efd6e054c4fa6284ba73e02861afd75f7ad2fe..0419550a84cc36da75907cec9368ed5651f46130 100644 (file)
@@ -24,6 +24,11 @@ public:
   /// \return the built preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
 
+  /// Adds sub-feature of the higher level feature (sub-element of the sketch)
+  /// \param theFeature sub-feature
+  SKETCHPLUGIN_EXPORT virtual const void addSub(
+    const boost::shared_ptr<ModelAPI_Feature>& theFeature) = 0;
+
 protected:
   /// Set the shape to the internal preview field
   /// \param theShape a preview shape
@@ -31,9 +36,16 @@ protected:
   /// Return the shape from the internal preview field
   /// \return theShape a preview shape
   const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
+  /// Sets the higher-level feature for the sub-feature (sketch for line)
+  void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
+  /// Returns the sketch of this feature
+  SketchPlugin_Sketch* sketch() {return mySketch;}
+
+  friend class SketchPlugin_Sketch;
 
 private:
   boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
+  SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
 };
 
 #endif
index 5b5cf510842e0bf04392c2f6df4e1fd4724795f8..8462d99bdea0ca55518a41d6c8fe4efce13b118a 100644 (file)
@@ -30,7 +30,7 @@ void SketchPlugin_Line::execute()
 
 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
 {
-  boost::shared_ptr<SketchPlugin_Sketch> aSketch = SketchPlugin_Sketch::active();
+  SketchPlugin_Sketch* aSketch = sketch();
   // compute a start point in 3D view
   boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_START));
index 83480d9a8138d96c61632d511e7e4bb9cf9ab255..6acb48d74992a873aabb1dc1ca9858de2166bae2 100644 (file)
@@ -46,14 +46,9 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
   return getPreview();
 }
 
-void SketchPlugin_Sketch::setActive(boost::shared_ptr<SketchPlugin_Sketch> theSketch)
+const void SketchPlugin_Sketch::addSub(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
 {
-  MY_ACITVE_SKETCH = theSketch;
-}
-
-boost::shared_ptr<SketchPlugin_Sketch> SketchPlugin_Sketch::active()
-{
-  return MY_ACITVE_SKETCH;
+  boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
 }
 
 void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
index 3c6181200faf5747bc70f4911c8da25dde1ac241..0fc24fb11ed0bea2f9b5f91501a7da4194ad3c0a 100644 (file)
@@ -43,13 +43,10 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
-  /// Sets the sketch as active. All features and features previews 
-  /// will be connected to this sketch.
-  SKETCHPLUGIN_EXPORT static void setActive(boost::shared_ptr<SketchPlugin_Sketch> theSketch);
-
-  /// Returns the currently active sketch. All features and features previews 
-  /// will be connected to this sketch.
-  SKETCHPLUGIN_EXPORT static boost::shared_ptr<SketchPlugin_Sketch> active();
+  /// Adds sub-feature of the higher level feature (sub-element of the sketch)
+  /// \param theFeature sub-feature
+  SKETCHPLUGIN_EXPORT virtual const void addSub(
+    const boost::shared_ptr<ModelAPI_Feature>& theFeature);
 
   /// Converts a 2D sketch space point into point in 3D space
   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(