]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Apr 2014 13:41:47 +0000 (17:41 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 25 Apr 2014 13:41:47 +0000 (17:41 +0400)
Conflicts:
src/XGUI/XGUI_Workshop.cpp

42 files changed:
src/Config/Config_Keywords.h
src/GeomAPI/GeomAPI_Dir.h
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h [new file with mode: 0644]
src/GeomData/CMakeLists.txt
src/GeomData/GeomData_Dir.cpp [new file with mode: 0644]
src/GeomData/GeomData_Dir.h [new file with mode: 0644]
src/GeomData/GeomData_Point.cpp
src/GeomData/GeomData_Point.h
src/GeomData/GeomData_Point2D.cpp [new file with mode: 0644]
src/GeomData/GeomData_Point2D.h [new file with mode: 0644]
src/GeomDataAPI/CMakeLists.txt
src/GeomDataAPI/GeomDataAPI.i
src/GeomDataAPI/GeomDataAPI_Dir.h [new file with mode: 0644]
src/GeomDataAPI/GeomDataAPI_Point.h
src/GeomDataAPI/GeomDataAPI_Point2D.h [new file with mode: 0644]
src/Model/CMakeLists.txt
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_Data.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Line.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_WidgetFactory.cpp
src/XGUI/XGUI_WidgetFactory.h
src/XGUI/XGUI_Workshop.cpp

index f5bfe19e80d16a2929efa6b9181370957503a6d9..6c8f91835460e5464b9d830424bff0e40458c6a3 100644 (file)
@@ -19,6 +19,7 @@ const static char* NODE_SOURCE = "source";
 //Widgets
 const static char* WDG_DOUBLEVALUE = "doublevalue";
 //Widget containers
+const static char* WDG_INFO = "label";
 const static char* WDG_GROUP = "groupbox";
 const static char* WDG_CHECK_GROUP = "check_groupbox";
 const static char* WDG_TOOLBOX = "toolbox";
@@ -38,6 +39,8 @@ const static char* SOURCE_FILE = "path";
 
 
 // doublevalue properties:
+const static char* INFO_WDG_TEXT = FEATURE_TEXT;
+const static char* INFO_WDG_TOOLTIP = FEATURE_TOOLTIP;
 const static char* DOUBLE_WDG_MIN = "min";
 const static char* DOUBLE_WDG_MAX = "max";
 const static char* DOUBLE_WDG_STEP = "step";
index a003d3826bf825ac8398ffd3525b3620f386c95e..7993a3d77d030e3adc6701457e36b686758d2b31 100644 (file)
@@ -24,6 +24,7 @@ public:
   double y() const;
   /// returns Z coordinate
   double z() const;
+
 };
 
 #endif
index c05fa5a2511e4f9e76d671ecb6c292551fffee0d..509c7fd9e0bc5ab7b01c1f3dc608e14e237709ab 100644 (file)
@@ -8,11 +8,13 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI.h
     GeomAlgoAPI_CompoundBuilder.h
     GeomAlgoAPI_FaceBuilder.h
+    GeomAlgoAPI_EdgeBuilder.h
 )
 
 SET(PROJECT_SOURCES
     GeomAlgoAPI_CompoundBuilder.cpp
     GeomAlgoAPI_FaceBuilder.cpp
+    GeomAlgoAPI_EdgeBuilder.cpp
 )
 
 ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
new file mode 100644 (file)
index 0000000..c8419fe
--- /dev/null
@@ -0,0 +1,24 @@
+// File:        GeomAlgoAPI_EdgeBuilder.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include <GeomAlgoAPI_EdgeBuilder.h>
+#include <gp_Pln.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Plane.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_EdgeBuilder::line(
+  boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd)
+{
+  const gp_Pnt& aStart = theStart->impl<gp_Pnt>();
+  const gp_Pnt& anEnd = theEnd->impl<gp_Pnt>();
+
+  BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
+  boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  aRes->setImpl(new TopoDS_Shape(anEdge));
+  return aRes;
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h
new file mode 100644 (file)
index 0000000..cd505a8
--- /dev/null
@@ -0,0 +1,26 @@
+// File:        GeomAlgoAPI_EdgeBuilder.h
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAlgoAPI_EdgeBuilder_HeaderFile
+#define GeomAlgoAPI_EdgeBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Pnt.h>
+#include <boost/shared_ptr.hpp>
+
+/**\class GeomAlgoAPI_EdgeBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder
+{
+public:
+  /// Creates linear edge by two points
+  static boost::shared_ptr<GeomAPI_Shape> line(
+    boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd);
+};
+
+#endif
index 05ee5eb3c7f806995e8d492ae0b96dbf73e70a9b..de9142621337e532d65139719aba0ca8c14e02f0 100644 (file)
@@ -4,19 +4,24 @@ INCLUDE(FindCAS)
 SET(PROJECT_HEADERS
     GeomData.h
     GeomData_Point.h
+    GeomData_Dir.h
+    GeomData_Point2D.h
 )
 
 SET(PROJECT_SOURCES
     GeomData_Point.cpp
+    GeomData_Dir.cpp
+    GeomData_Point2D.cpp
 )
 
 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 Events Config)
+TARGET_LINK_LIBRARIES(GeomData ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI GeomAPI)
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomDataAPI
+  ../GeomAPI
   ../Events
   ../Config
   ${CAS_INCLUDE_DIRS}
diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp
new file mode 100644 (file)
index 0000000..22dac3f
--- /dev/null
@@ -0,0 +1,46 @@
+// File:        GeomData_Dir.cxx
+// Created:     2 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include "GeomData_Dir.h"
+#include "GeomAPI_Dir.h"
+#include <gp_Dir.hxx>
+
+using namespace std;
+
+void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
+{
+  myCoords->SetValue(0, theX);
+  myCoords->SetValue(1, theY);
+  myCoords->SetValue(2, theZ);
+}
+
+double GeomData_Dir::x() const
+{
+  return myCoords->Value(0);
+}
+
+double GeomData_Dir::y() const
+{
+  return myCoords->Value(1);
+}
+
+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)
+  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+    // create attribute: not initialized by value yet, just zero
+    myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
+  }
+}
diff --git a/src/GeomData/GeomData_Dir.h b/src/GeomData/GeomData_Dir.h
new file mode 100644 (file)
index 0000000..56a8b9d
--- /dev/null
@@ -0,0 +1,43 @@
+// File:        GeomData_Dir.h
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomData_Dir_HeaderFile
+#define GeomData_Dir_HeaderFile
+
+#include "GeomData.h"
+#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
+ * \brief Attribute that contains direction.
+ */
+class GeomData_Dir : public GeomDataAPI_Dir
+{
+  Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2]
+public:
+  /// Defines the double value
+  GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
+
+  /// Returns the X double value
+  GEOMDATA_EXPORT virtual double x() const;
+  /// Returns the Y double value
+  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
+  GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index 9fbb5f4243fad2d51ce217dd5f32a76b6661eed6..6f57d4157225eea930577ce8acb462d4820821ab 100644 (file)
@@ -1,5 +1,5 @@
-// File:        ModelAPI_AttributeDouble.cxx
-// Created:     2 Apr 2014
+// File:        GeomData_Point.cxx
+// Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
 
 #include "GeomData_Point.h"
index 06f84959ac05f1f3fe87192b9a6e93945b9837c0..9886333c2fb63e5ac219a1d12a2b5b5e3a836c57 100644 (file)
 
 /**\class GeomData_Point
  * \ingroup DataModel
- * \brief Attribute that contains real value with double precision.
+ * \brief Attribute that contains 3D point.
  */
 
-class GeomData_Point : public ModelAPI_Attribute
+class GeomData_Point : public GeomDataAPI_Point
 {
   Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2]
 public:
   /// Defines the double value
-  virtual void setValue(const double theX, const double theY, const double theZ);
+  GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
 
   /// Returns the X double value
-  virtual double x() const;
+  GEOMDATA_EXPORT virtual double x() const;
   /// Returns the Y double value
-  virtual double y() const;
+  GEOMDATA_EXPORT virtual double y() const;
   /// Returns the Z double value
-  virtual double z() const;
+  GEOMDATA_EXPORT virtual double z() const;
 
 protected:
   /// Initializes attributes
-  GeomData_Point(TDF_Label& theLabel);
+  GEOMDATA_EXPORT GeomData_Point(TDF_Label& theLabel);
+
+  friend class Model_Data;
 };
 
 #endif
diff --git a/src/GeomData/GeomData_Point2D.cpp b/src/GeomData/GeomData_Point2D.cpp
new file mode 100644 (file)
index 0000000..3e57622
--- /dev/null
@@ -0,0 +1,32 @@
+// File:        GeomData_Point2D.cxx
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include "GeomData_Point2D.h"
+
+using namespace std;
+
+void GeomData_Point2D::setValue(const double theX, const double theY)
+{
+  myCoords->SetValue(0, theX);
+  myCoords->SetValue(1, theY);
+}
+
+double GeomData_Point2D::x() const
+{
+  return myCoords->Value(0);
+}
+
+double GeomData_Point2D::y() const
+{
+  return myCoords->Value(1);
+}
+
+GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
+{
+  // check the attribute could be already presented in this doc (after load document)
+  if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+    // create attribute: not initialized by value yet, just zero
+    myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);
+  }
+}
diff --git a/src/GeomData/GeomData_Point2D.h b/src/GeomData/GeomData_Point2D.h
new file mode 100644 (file)
index 0000000..4b3d467
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        GeomData_Point2D.h
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomData_Point2D_HeaderFile
+#define GeomData_Point2D_HeaderFile
+
+#include "GeomData.h"
+#include "GeomDataAPI_Point2D.h"
+#include <TDataStd_RealArray.hxx>
+#include <TDF_Label.hxx>
+
+/**\class GeomData_Point2D
+ * \ingroup DataModel
+ * \brief Attribute that contains 2D point.
+ */
+
+class GeomData_Point2D : public GeomDataAPI_Point2D
+{
+  Handle_TDataStd_RealArray myCoords; ///< X and Y doubles as real array attribute [0; 1]
+public:
+  /// Defines the double value
+  GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
+
+  /// Returns the X double value
+  GEOMDATA_EXPORT virtual double x() const;
+  /// Returns the Y double value
+  GEOMDATA_EXPORT virtual double y() const;
+
+protected:
+  /// Initializes attributes
+  GEOMDATA_EXPORT GeomData_Point2D(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index 9f09481b043df5a5e7bc6b29d6610cb444b7afa3..389463212ab4c13582cec1d6efebc801b4056c81 100644 (file)
@@ -5,6 +5,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 SET(PROJECT_HEADERS
     GeomDataAPI.h
     GeomDataAPI_Point.h
+    GeomDataAPI_Dir.h
+    GeomDataAPI_Point2D.h
 )
 
 SET(CMAKE_SWIG_FLAGS "")
index f759848d9c7b03fe532fc88afe142f5018a00d03..455e0122e642146eaa073e5176c52bd11564da39 100644 (file)
@@ -3,6 +3,8 @@
 %{
   #include "GeomDataAPI.h"
   #include "GeomDataAPI_Point.h"
+  #include "GeomDataAPI_Dir.h"
+  #include "GeomDataAPI_Point2D.h"
   #include <boost/shared_ptr.hpp>
 %}
 
 // boost pointers
 %include <boost_shared_ptr.i>
 %shared_ptr(GeomDataAPI_Point)
+%shared_ptr(GeomDataAPI_Dir)
+%shared_ptr(GeomDataAPI_Point2D)
 
 // all supported interfaces
 %include "GeomDataAPI_Point.h"
+%include "GeomDataAPI_Dir.h"
+%include "GeomDataAPI_Point2D.h"
diff --git a/src/GeomDataAPI/GeomDataAPI_Dir.h b/src/GeomDataAPI/GeomDataAPI_Dir.h
new file mode 100644 (file)
index 0000000..90ab616
--- /dev/null
@@ -0,0 +1,41 @@
+// File:        GeomDataAPI_Dir.h
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomDataAPI_Dir_HeaderFile
+#define GeomDataAPI_Dir_HeaderFile
+
+#include "GeomDataAPI.h"
+#include <ModelAPI_Attribute.h>
+
+/**\class GeomDataAPI_Dir
+ * \ingroup DataModel
+ * \brief Attribute that contains 3D direction coordinates. 
+ */
+
+class GeomDataAPI_Dir : public ModelAPI_Attribute
+{
+public:
+  /// Defines the double value
+  virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+
+  /// Returns the X double value
+  virtual double x() const = 0;
+  /// Returns the Y double value
+  virtual double y() const = 0;
+  /// Returns the Z double value
+  virtual double z() const = 0;
+
+  /// Returns the type of this class of attributes
+  static inline std::string type() {return std::string("Point");}
+
+  /// Returns the type of this class of attributes, not static method
+  virtual std::string attributeType() {return type();}
+
+protected:
+  /// Objects are created for features automatically
+  GeomDataAPI_Dir()
+  {}
+};
+
+#endif
index d53271fd7e540f9a3da38903da7b8f9b2d049152..68f294e60fc8a9d4e967690d3fd917461e7b9828 100644 (file)
@@ -1,16 +1,16 @@
-// File:        GeomData_AttributeDouble.h
-// Created:     2 Apr 2014
+// File:        GeomDataAPI_Point.h
+// Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef GeomData_AttributeDouble_HeaderFile
-#define GeomData_AttributeDouble_HeaderFile
+#ifndef GeomDataAPI_Point_HeaderFile
+#define GeomDataAPI_Point_HeaderFile
 
 #include "GeomDataAPI.h"
 #include <ModelAPI_Attribute.h>
 
-/**\class GeomData_AttributeDouble
+/**\class GeomDataAPI_Point
  * \ingroup DataModel
- * \brief Attribute that contains real value with double precision.
+ * \brief Attribute that contains 3D point coordinates. 
  */
 
 class GeomDataAPI_Point : public ModelAPI_Attribute
@@ -20,11 +20,11 @@ public:
   virtual void setValue(const double theX, const double theY, const double theZ) = 0;
 
   /// Returns the X double value
-  virtual double x() = 0;
+  virtual double x() const = 0;
   /// Returns the Y double value
-  virtual double y() = 0;
+  virtual double y() const = 0;
   /// Returns the Z double value
-  virtual double z() = 0;
+  virtual double z() const = 0;
 
   /// Returns the type of this class of attributes
   static inline std::string type() {return std::string("Point");}
diff --git a/src/GeomDataAPI/GeomDataAPI_Point2D.h b/src/GeomDataAPI/GeomDataAPI_Point2D.h
new file mode 100644 (file)
index 0000000..bfc8094
--- /dev/null
@@ -0,0 +1,39 @@
+// File:        GeomDataAPI_Point2D.h
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomDataAPI_Point2D_HeaderFile
+#define GeomDataAPI_Point2D_HeaderFile
+
+#include "GeomDataAPI.h"
+#include <ModelAPI_Attribute.h>
+
+/**\class GeomDataAPI_Point2D
+ * \ingroup DataModel
+ * \brief Attribute that contains 2D point coordinates.
+ */
+
+class GeomDataAPI_Point2D : public ModelAPI_Attribute
+{
+public:
+  /// Defines the double value
+  virtual void setValue(const double theX, const double theY) = 0;
+
+  /// Returns the X double value
+  virtual double x() const = 0;
+  /// Returns the Y double value
+  virtual double y() const = 0;
+
+  /// Returns the type of this class of attributes
+  static inline std::string type() {return std::string("Point2D");}
+
+  /// Returns the type of this class of attributes, not static method
+  virtual std::string attributeType() {return type();}
+
+protected:
+  /// Objects are created for features automatically
+  GeomDataAPI_Point2D()
+  {}
+};
+
+#endif
index 24bee85be889d3455ad8ed342b4e6271a187f057..7b60ee48c26499f706c4a4876d1630aea4ceac53 100644 (file)
@@ -26,12 +26,14 @@ SET(PROJECT_SOURCES
 
 ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS})
 ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Events Config)
+TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Events Config GeomData)
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../Events
   ../Config
+  ../GeomData
+  ../GeomDataAPI
   ${CAS_INCLUDE_DIRS}
 )
 
index 87c7be8672fda2dfa7b0a6b7c95ad461598d2bbc..121cd1902ce3bb63b3c025fd1c78c52a2585162a 100644 (file)
@@ -5,6 +5,8 @@
 #include <Model_Data.h>
 #include <Model_AttributeDocRef.h>
 #include <Model_AttributeDouble.h>
+#include <GeomData_Point.h>
+#include <GeomData_Point2D.h>
 #include <TDataStd_Name.hxx>
 
 using namespace std;
@@ -39,6 +41,10 @@ void Model_Data::addAttribute(string theID, string theAttrType)
     anAttr = new Model_AttributeDocRef(anAttrLab);
   else if (theAttrType == ModelAPI_AttributeDouble::type())
     anAttr = new Model_AttributeDouble(anAttrLab);
+  else if (theAttrType == GeomData_Point::type())
+    anAttr = new GeomData_Point(anAttrLab);
+  else if (theAttrType == GeomData_Point2D::type())
+    anAttr = new GeomData_Point2D(anAttrLab);
 
   if (anAttr)
     myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
@@ -75,3 +81,11 @@ boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
   }
   return aRes;
 }
+
+boost::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string theID)
+{
+  boost::shared_ptr<ModelAPI_Attribute> aResult;
+  if (myAttrs.find(theID) == myAttrs.end()) // no such attribute
+    return aResult;
+  return myAttrs[theID];
+}
index 5c3ffdf2ff66eb6105c92c829070792870712c36..647024e6d1290388f62ef50c583c0009741dc2cf 100644 (file)
@@ -43,6 +43,9 @@ public:
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
   /// Returns the attribute that contains real value with double precision
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
+  /// Returns the generic attribute by identifier
+  /// \param theID identifier of the attribute
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID);
 
   /// Initializes object by the attributes: must be called just after the object is created
   /// for each attribute of the object
index 1d4bf15e8b992db095952337e4cd4b04a4babea0..dfcdae495aefcf6f582c711b395af81c841384da 100644 (file)
@@ -12,7 +12,6 @@
  * \ingroup DataModel
  * \brief Generic attribute of the Object.
  */
-
 class MODELAPI_EXPORT ModelAPI_Attribute
 {
 public:
index 73fe3d7ded337819b4e5ca8dbfbb7aa69755ac32..077e75d2766110a4eafea99537fb1641afd967f1 100644 (file)
@@ -12,6 +12,7 @@
 class ModelAPI_AttributeDocRef;
 class ModelAPI_AttributeDouble;
 class ModelAPI_Document;
+class ModelAPI_Attribute;
 
 /**\class ModelAPI_Data
  * \ingroup DataModel
@@ -34,6 +35,10 @@ public:
   /// Returns the attribute that contains real value with double precision
   virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
 
+  /// Returns the generic attribute by identifier
+  /// \param theID identifier of the attribute
+  virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string theID) = 0;
+
   /// Initializes object by the attributes: must be called just after the object is created
   /// for each attribute of the object
   /// \param theID identifier of the attribute that can be referenced by this ID later
index 260da21aa23d88a18d2849ad6bcacbab6b84d112..f8ce75a9284e361031176740707b573870993020 100644 (file)
@@ -47,6 +47,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/Events
                     ${CMAKE_SOURCE_DIR}/src/ModuleBase
                     ${CMAKE_SOURCE_DIR}/src/ModelAPI
+                    ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
+                    ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
                     ${CMAKE_SOURCE_DIR}/src/GeomAPI
                     ${CAS_INCLUDE_DIRS}
@@ -62,7 +64,7 @@ ADD_LIBRARY(PartSet SHARED
 )
 
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
-TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI)
+TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI GeomAlgoAPI)
 
 ADD_DEPENDENCIES(PartSet ModuleBase)
 
index c53208916bd95a0ab065bc8d194fc53333539ace..1a0e84dd5c0125236e3df181065eb3af7b6bc42f 100644 (file)
@@ -103,8 +103,11 @@ void PartSet_Module::onOperationStarted()
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
 
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp)
+  if (aPreviewOp) {
     visualizePreview(true);
+    connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)),
+            this, SLOT(onViewerProjectionChange(double, double, double)));
+  }
 }
 
 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
@@ -124,13 +127,21 @@ void PartSet_Module::onViewSelectionChanged()
   if (aPreviewOp) {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
     if (aViewer) {
-      AIS_ListOfInteractive aList;
-      aViewer->getSelectedObjects(aList);
-      aPreviewOp->setSelectedObjects(aList);
+      NCollection_List<TopoDS_Shape> aList;
+      aViewer->getSelectedShapes(aList);
+      aPreviewOp->setSelectedShapes(aList);
     }
   }
 }
 
+void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ)
+{
+  XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+  if (aViewer) {
+    aViewer->setViewProjection(theX, theY, theZ);
+  }
+}
+
 void PartSet_Module::visualizePreview(bool isDisplay)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -147,6 +158,6 @@ void PartSet_Module::visualizePreview(bool isDisplay)
   }
   else {
     myWorkshop->displayer()->GlobalSelection(false);
-    myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
+    myWorkshop->displayer()->Erase(anOperation->feature());
   }
 }
index 441014dde5a295d70edcb2c49c1b89f84153cfd5..523a15ad210a702de378f66562dc510329ff97c5 100644 (file)
@@ -36,6 +36,11 @@ public slots:
   /// SLOT, that is called by the selection in the viewer is changed.
   /// The selection is sent to the current operation if it listen the selection.
   void onViewSelectionChanged();
+  /// SLOT, to apply to the current viewer the operation
+  /// \param theX the X projection value
+  /// \param theY the Y projection value
+  /// \param theZ the Z projection value
+  void onViewerProjectionChange(double theX, double theY, double theZ);
 
 private:
   /// Displays or erase the current operation preview, if it has it.
index c9608cd2e1982d8536a3d49b45da62d9d528897f..c343503e2467bf22f60015430cd021df48d9c088 100644 (file)
@@ -4,9 +4,12 @@
 
 #include <PartSet_OperationSketch.h>
 
-#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
 #include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -37,27 +40,47 @@ int PartSet_OperationSketch::getSelectionMode() const
   return TopAbs_FACE;
 }
 
-void PartSet_OperationSketch::setSelectedObjects(const AIS_ListOfInteractive& theList)
+void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
 {
   if (theList.IsEmpty())
     return;
 
-  // 1. get selected fase
-  Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(theList.First());
-  if (anAISShape.IsNull())
-    return;
-
-  const TopoDS_Shape& aShape = anAISShape->Shape();
-  boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
-  aRes->setImpl(new TopoDS_Shape(aShape));
+  // get selected shape
+  const TopoDS_Shape& aShape = theList.First();
+  boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
+  aGShape->setImpl(new TopoDS_Shape(aShape));
 
   // get plane parameters
-  double anX = 1, anY = 0, aZ = 0, anOrigin = 0;
+  boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
 
   // set plane parameters to feature
-  //boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-  //boost::shared_ptr<ModelAPI_AttributeDocRef> anAttr = aData->docRef(SKETCH_ATTR_X);
-  //anAttr->setValue(anX);
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  double anA, aB, aC, aD;
+  aPlane->coefficients(anA, aB, aC, aD);
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
+  /*
+  aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA);
+  aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB);
+  aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
+  aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
+  */
+  // temporary solution for main planes only
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  anOrigin->setValue(0, 0, 0);
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  aNormal->setValue(anA, aB, aC);
+  boost::shared_ptr<GeomDataAPI_Dir> aDirX = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+  aDirX->setValue(aB, aC, anA);
+  boost::shared_ptr<GeomDataAPI_Dir> aDirY = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+  aDirY->setValue(aC, anA, aB);
+
+  boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+  emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
 
   commit();
 }
index 83be57a998259b46d5f91f16a8bb88bf2e614e74..6a7670b0007caf3a9927899b9c279331328428fb 100644 (file)
@@ -33,8 +33,8 @@ public:
   virtual int getSelectionMode() const;
 
   /// Gives the current selected objects to be processed by the operation
-  /// \param theList a list of interactive selected objects
-  virtual void setSelectedObjects(const AIS_ListOfInteractive& theList);
+  /// \param theList a list of interactive selected shapes
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
 };
 
 #endif
index b6c160ae7de0870d30a4738ad66d52cde5038f77..7ca7fd2d3ac30aa4a1cfaf37ad690c4fe6cdcb99 100644 (file)
@@ -8,12 +8,11 @@
 #include "PartSet.h"
 
 #include <TopoDS_Shape.hxx>
+#include <NCollection_List.hxx>
 
 #include <ModuleBase_PropPanelOperation.h>
 #include <QObject>
 
-class AIS_ListOfInteractive;
-
 /*!
   \class PartSet_OperationSketchBase
   * \brief The base operation for the sketch features.
@@ -39,7 +38,10 @@ public:
 
   /// Gives the current selected objects to be processed by the operation
   /// \param a list of interactive selected objects
-  virtual void setSelectedObjects(const AIS_ListOfInteractive& aList) = 0;
+  virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) = 0;
+
+signals:
+  void viewerProjectionChange(double theX, double theY, double theZ);
 };
 
 #endif
index c075da118ed41a99d4bdb784058506ec5c116ec1..347fabe8818e0f69d364c882db8d78958406e317 100644 (file)
@@ -5,12 +5,14 @@ SET(PROJECT_HEADERS
     SketchPlugin_Feature.h
     SketchPlugin_Plugin.h
     SketchPlugin_Sketch.h
+    SketchPlugin_Line.h
 )
 
 SET(PROJECT_SOURCES
     SketchPlugin_Feature.cpp
     SketchPlugin_Plugin.cpp
     SketchPlugin_Sketch.cpp
+    SketchPlugin_Line.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -26,6 +28,7 @@ INCLUDE_DIRECTORIES(
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
+  ../GeomDataAPI
 )
 
 SET(XML_RESOURCES
index 2bb33c268c36be267526e0b38cfa6aca00640d30..0419550a84cc36da75907cec9368ed5651f46130 100644 (file)
@@ -7,9 +7,10 @@
 
 #include "SketchPlugin.h"
 #include <ModelAPI_Feature.h>
-
 #include <GeomAPI_Shape.h>
 
+class SketchPlugin_Sketch;
+
 /**\class SketchPlugin_Feature
  * \ingroup DataModel
  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
@@ -19,9 +20,15 @@ class SketchPlugin_Feature: public ModelAPI_Feature
 {
 public:
   /// Returns the sketch preview
+  /// \param theSketch the owner of this feature
   /// \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
@@ -29,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
diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp
new file mode 100644 (file)
index 0000000..8462d99
--- /dev/null
@@ -0,0 +1,47 @@
+// File:        SketchPlugin_Line.cxx
+// Created:     27 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#include "SketchPlugin_Line.h"
+#include "SketchPlugin_Sketch.h"
+#include <ModelAPI_Data.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAlgoAPI_EdgeBuilder.h>
+#include <GeomDataAPI_Point2D.h>
+
+using namespace std;
+
+// face of the square-face displayed for selection of general plane
+const double PLANE_SIZE = 200;
+
+SketchPlugin_Line::SketchPlugin_Line()
+{
+}
+
+void SketchPlugin_Line::initAttributes()
+{
+  data()->addAttribute(LINE_ATTR_START, GeomDataAPI_Point2D::type());
+  data()->addAttribute(LINE_ATTR_END, GeomDataAPI_Point2D::type());
+}
+
+void SketchPlugin_Line::execute() 
+{
+}
+
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Line::preview()
+{
+  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));
+  boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
+  // compute an end point in 3D view
+  boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(LINE_ATTR_END));
+  boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
+  // make linear edge
+  boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+  setPreview(anEdge);
+
+  return getPreview();
+}
diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h
new file mode 100644 (file)
index 0000000..9d0ae50
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        SketchPlugin_Line.h
+// Created:     24 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef SketchPlugin_Line_HeaderFile
+#define SketchPlugin_Line_HeaderFile
+
+#include "SketchPlugin.h"
+#include <SketchPlugin_Feature.h>
+#include <list>
+
+/// Start 2D point of the line
+const std::string LINE_ATTR_START("StartPoint");
+/// End 2D point of the line
+const std::string LINE_ATTR_END("EndPoint");
+
+/**\class SketchPlugin_Line
+ * \ingroup DataModel
+ * \brief Feature for creation of the new part in PartSet.
+ */
+class SketchPlugin_Line: public SketchPlugin_Feature
+{
+public:
+  /// Returns the kind of a feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "SketchLine"; return MY_KIND;}
+
+  /// Returns to which group in the document must be added feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketch"; return MY_GROUP;}
+
+  /// Creates a new part document if needed
+ SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+ SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
+
+  /// Use plugin manager for features creation
+  SketchPlugin_Line();
+};
+
+#endif
index 878670ec209066a560bac09d903c460a74ada826..6acb48d74992a873aabb1dc1ca9858de2166bae2 100644 (file)
@@ -4,12 +4,16 @@
 
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomDataAPI_Point.h>
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
 
 using namespace std;
 
+/// the active sketch
+boost::shared_ptr<SketchPlugin_Sketch> MY_ACITVE_SKETCH;
+
 // face of the square-face displayed for selection of general plane
 const double PLANE_SIZE = 200;
 
@@ -19,10 +23,10 @@ SketchPlugin_Sketch::SketchPlugin_Sketch()
 
 void SketchPlugin_Sketch::initAttributes()
 {
-  data()->addAttribute(SKETCH_ATTR_PLANE_A, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SKETCH_ATTR_PLANE_B, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SKETCH_ATTR_PLANE_C, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(SKETCH_ATTR_PLANE_D, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(SKETCH_ATTR_ORIGIN, GeomDataAPI_Point::type());
+  data()->addAttribute(SKETCH_ATTR_DIRX, GeomDataAPI_Dir::type());
+  data()->addAttribute(SKETCH_ATTR_DIRY, GeomDataAPI_Dir::type());
+  data()->addAttribute(SKETCH_ATTR_NORM, GeomDataAPI_Dir::type());
 }
 
 void SketchPlugin_Sketch::execute() 
@@ -42,6 +46,11 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
   return getPreview();
 }
 
+const void SketchPlugin_Sketch::addSub(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+{
+  boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
+}
+
 void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
                                    std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const
 {
@@ -51,3 +60,18 @@ void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
     GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
   theShapes.push_back(aFace);
 }
+
+boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const double theY)
+{
+  boost::shared_ptr<GeomDataAPI_Point> aC = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aX = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRX));
+  boost::shared_ptr<GeomDataAPI_Dir> aY = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
+
+  return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(
+    aC->x() + aX->x() * theX + aY->x() * theY, 
+    aC->y() + aX->y() * theX + aY->y() * theY,
+    aC->z() + aX->z() * theX + aY->z() * theY));
+}
index ec81fe62e6fc0fe82744163617d108a253e193c8..0fc24fb11ed0bea2f9b5f91501a7da4194ad3c0a 100644 (file)
@@ -7,16 +7,17 @@
 
 #include "SketchPlugin.h"
 #include <SketchPlugin_Feature.h>
+#include <GeomAPI_Pnt.h>
 #include <list>
 
-/// Coefficient A of the sketch plane (Ax+By+Cz+D=0)
-const std::string SKETCH_ATTR_PLANE_A("PlaneA");
-/// Coefficient B of the sketch plane
-const std::string SKETCH_ATTR_PLANE_B("PlaneB");
-/// Coefficient C of the sketch plane
-const std::string SKETCH_ATTR_PLANE_C("PlaneC");
-/// Coefficient D of the sketch plane
-const std::string SKETCH_ATTR_PLANE_D("PlaneD");
+/// Origin point of the sketcher in 3D space
+const std::string SKETCH_ATTR_ORIGIN("Origin");
+/// Vector X inside of the sketch plane
+const std::string SKETCH_ATTR_DIRX("DirX");
+/// Vector Y inside of the sketch plane
+const std::string SKETCH_ATTR_DIRY("DirY");
+/// Vector Z, normal to the sketch plane
+const std::string SKETCH_ATTR_NORM("Norm");
 
 /**\class SketchPlugin_Sketch
  * \ingroup DataModel
@@ -42,6 +43,15 @@ public:
   /// Returns the sketch preview
   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
 
+  /// 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(
+    const double theX, const double theY);
+
   /// Use plugin manager for features creation
   SketchPlugin_Sketch();
 protected:
index 03f85d0875646f55e335221a35340fda58d2c07b..09ac545be2f24fc6de3dd31a06b516a68cda2b50 100644 (file)
@@ -1,7 +1,10 @@
 <plugin>
   <workbench id="Sketch">
     <group id="Basic">
-      <feature id="Sketch" text="New sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png"/>
+      <feature id="Sketch" text="New sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
+        <label text="Natasha, please provide a text for the label" tooltip="Natasha, please provide a text for the tooltip"/> 
+      <!--icon=":pictures/x_point.png"-->
+      </feature>
     </group>
   </workbench>
 </plugin>
index a036e8f7503f43064338e915fdbdcf9720503a93..bca8d2d24c37de2107155910d1d9fc51cca2d3a4 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
 
 #include <AIS_Shape.hxx>
 
@@ -32,6 +33,13 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
 
   Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+  std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
+  if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
+    aDispAIS = myFeature2AISObjectMap[theFeature];
+  }
+  aDispAIS.push_back(anAIS);
+  myFeature2AISObjectMap[theFeature] = aDispAIS;
+
   aContext->Display(anAIS, Standard_False);
 
   if (isUpdateViewer)
@@ -39,10 +47,23 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
 }
 
 void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                           const TopoDS_Shape& theShape, const bool isUpdateViewer)
+                           const bool isUpdateViewer)
 {
+  if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end())
+    return;
+
+  std::vector<Handle(AIS_InteractiveObject)> aDispAIS = myFeature2AISObjectMap[theFeature];
+  std::vector<Handle(AIS_InteractiveObject)>::const_iterator anIt = aDispAIS.begin(),
+                                                             aLast = aDispAIS.end();
   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
-  aContext->EraseAll();
+  for (; anIt != aLast; anIt++) {
+    Handle(AIS_InteractiveObject) anAIS = *anIt;
+    Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+    if (anAISShape.IsNull())
+      continue;
+      aContext->Erase(anAISShape);
+  }
+
   if (isUpdateViewer)
     aContext->UpdateCurrentViewer();
 }
@@ -54,7 +75,14 @@ void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeatu
   Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
 
   Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+  std::vector<Handle(AIS_InteractiveObject)> aDispAIS;
+  if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end()) {
+    aDispAIS = myFeature2AISObjectMap[theFeature];
+  }
+  aDispAIS.push_back(anAIS);
+  myFeature2AISObjectMap[theFeature] = aDispAIS;
   aContext->Display(anAIS, Standard_False);
+
   AIS_ListOfInteractive anAISList;
   anAISList.Append(anAIS);
   myViewer->setLocalSelection(anAISList, theMode, true);
index 1dc238b906be7046c02f67a4ae8552df01562110..2a54cb9e41b29a32e92fa9bcbce6a02669169bb6 100644 (file)
 #include <boost/shared_ptr.hpp>
 
 #include <TopoDS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+
+#include <map>
+#include <vector>
 
 class XGUI_Viewer;
 class ModelAPI_Feature;
 
+
 /**\class XGUI_Displayer
  * \ingroup GUI
  * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
@@ -50,10 +55,8 @@ public:
 
   /// Erase the feature and a shape.
   /// \param theFeature a feature instance
-  /// \param theFeature a shape
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
-             const bool isUpdateViewer = true);
+  void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
 
   /// Deactivates selection of sub-shapes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
@@ -61,6 +64,7 @@ public:
 
 protected:
   XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
+  std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
 };
 
 #endif
index e6dd6e2b728597c75ae92e6fe7e4429a9b06c0f6..dd50e3e116e31c208803ecbcec655d9eb186c144 100644 (file)
@@ -238,6 +238,17 @@ void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
     theList.Append(myAISContext->SelectedInteractive());
 }
 
+void XGUI_Viewer::getSelectedShapes(NCollection_List<TopoDS_Shape>& theList)
+{
+  Handle(AIS_InteractiveContext) ic = AISContext();
+
+  for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) {
+    TopoDS_Shape aShape = ic->SelectedShape();
+    if (!aShape.IsNull())
+      theList.Append(aShape);
+  }
+}
+
 void XGUI_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
 {
   AIS_ListIteratorOfListOfInteractive aIt;
@@ -272,6 +283,17 @@ void XGUI_Viewer::getHotButton(XGUI::InteractionStyle theInteractionStyle,
   theButton = myButtonMap[theInteractionStyle][theOper];
 }
 
+void XGUI_Viewer::setViewProjection(double theX, double theY, double theZ)
+{
+  XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  if (aWindow) {
+    Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
+    if ( !aView3d.IsNull() ) 
+      aView3d->SetProj(theX, theY, theZ);
+    aWindow->viewPort()->fitAll();
+  }
+}
+
 /*!
  Changes visibility of trihedron to opposite
  */
index c4ae363b613fefe6da0be570a3033a997c0026a7..27df6840da36199369f2c72a6413650742bf5483 100644 (file)
@@ -11,6 +11,8 @@
 #include <V3d_Viewer.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Trihedron.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
 
 class XGUI_MainWindow;
 class QMdiSubWindow;
@@ -69,6 +71,10 @@ public:
   /// \param theList - list to be filled with selected objects
   void  getSelectedObjects(AIS_ListOfInteractive& theList);
 
+  /// Return shapes selected in 3D viewer
+  /// \param theList - list to be filled with selected shapes
+  void getSelectedShapes(NCollection_List<TopoDS_Shape>& theList);
+
   /// Selects objects in 3D viewer. Other selected objects are left as selected
   /// \param theList - list objects to be selected
   void  setObjectsSelected(const AIS_ListOfInteractive& theList);
@@ -113,6 +119,12 @@ public:
   static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
                            Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
 
+  //! Sets the view projection
+  /// \param theX the X projection value
+  /// \param theY the Y projection value
+  /// \param theZ the Z projection value
+  void setViewProjection(double theX, double theY, double theZ);
+
   typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
   typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
 
index 929f71771e761a342d9184d38cd3615eb39fc53c..17c3ab6c3dc196ad4533dd7a64b0f0badec8a105 100644 (file)
@@ -82,11 +82,26 @@ void XGUI_WidgetFactory::createWidget(QWidget* theParent)
   theParent->setLayout(aWidgetLay);
 }
 
+QWidget* XGUI_WidgetFactory::labelControl(QWidget* theParent)
+{
+  QWidget* result = new QWidget(theParent);
+  QVBoxLayout* aLabelLay = new QVBoxLayout(result);
+  QLabel* aLabel = new QLabel(result);
+  aLabel->setText(qs(myWidgetApi->getProperty(INFO_WDG_TEXT)));
+  aLabel->setToolTip(qs(myWidgetApi->getProperty(INFO_WDG_TOOLTIP)));
+  aLabelLay->addWidget(aLabel);
+  aLabelLay->addStretch(1);
+  result->setLayout(aLabelLay);
+  return result;
+}
+
 QWidget* XGUI_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent)
 {
   QWidget* result = NULL;
   if (theType == WDG_DOUBLEVALUE) {
     result = doubleSpinBoxControl();
+  } else if (theType == WDG_INFO) {
+    result = labelControl(theParent);
   } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
     result = createContainer(theType, theParent);
   }
index ed0ba16c6ab76077bff23e23c20cfe2cdd84c4e2..d83d8fbb4b61c09063323733e3656542187e7bf5 100644 (file)
@@ -25,11 +25,12 @@ public:
 
 protected:
   //Widgets
-  QWidget* doubleSpinBoxControl();
   QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
+  QWidget* labelControl(QWidget* theParent);
+  QWidget* doubleSpinBoxControl();
   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
-  bool connectWidget(QWidget*, const QString&);
 
+  bool connectWidget(QWidget*, const QString&);
   QString qs(const std::string& theStdString) const;
 
 private:
index 1835a13f096d9fe0f06dce2c4f425905ebd6a412..cbd6239cbb6642f88e114af2820c6fe2017cadd6 100644 (file)
@@ -216,13 +216,20 @@ void XGUI_Workshop::onOperationStarted()
 //******************************************************
 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 {
-  hidePropertyPanel();
-  updateCommandStatus();
+  ModuleBase_PropPanelOperation* aOperation =
+        (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+
+  if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+    updateCommandStatus();
+  } else {
+    hidePropertyPanel();
+    updateCommandStatus();
 
   if (myMainWindow) {
     XGUI_MainMenu* aMenu = myMainWindow->menuObject();
     aMenu->restoreCommandState();
   }
+  }
 }
 
 /*