double y() const;
/// returns Z coordinate
double z() const;
+
};
#endif
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}
// Author: Mikhail PONIKAROV
#include "GeomData_Dir.h"
+#include "GeomAPI_Dir.h"
+#include <gp_Dir.hxx>
using namespace std;
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)
#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
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
/// \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
/// 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
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));
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,
/// 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(